fix(frontend): load provider integrations through the typed OpenCode client

Fetch integrations with callOpenCode instead of a dedicated backend route,
drop the unused provider credentials list query, label an existing key as
"Edit API key", and keep the loaded provider list when a background
refetch fails.
This commit is contained in:
Chris Scott committed 2026-11-06 00:10:20 -05:00
1 parent b179267376
commit 99713e15b4
13 files changed
+44 -84

No files matched your search

-35
View File
@@ -126,41 +126,6 @@ describe('oauth routes /auth-methods', () => {
})
})
describe('oauth routes /integrations', () => {
it('returns every integration with its methods and connections', async () => {
const client = createStubOpenCodeClient()
const integrations = [
integrationFixture({
id: 'openrouter',
name: 'OpenRouter',
methods: [{ type: 'key' }],
}),
integrationFixture({
id: 'anthropic',
name: 'Anthropic',
methods: [{ type: 'key' }, { type: 'env', names: ['ANTHROPIC_API_KEY'] }],
connections: [{ type: 'credential', id: 'cred_1', label: 'Anthropic', method: 'key' }],
}),
]
vi.mocked(client.api.integration.list).mockResolvedValueOnce({ location: LOCATION, data: integrations })
const res = await createOAuthApp(client).request('/oauth/integrations')
expect(res.status).toBe(200)
expect(await res.json()).toEqual({ integrations })
})
it('returns 502 when the upstream is unreachable', async () => {
const client = createStubOpenCodeClient()
vi.mocked(client.api.integration.list).mockRejectedValueOnce(new ClientError('UnexpectedStatus'))
const res = await createOAuthApp(client).request('/oauth/integrations')
expect(res.status).toBe(502)
expect(await res.json()).toEqual({ error: 'Failed to list provider integrations', code: 'ClientError' })
})
})
describe('oauth routes /:id/oauth/authorize', () => {
it('starts the V2 attempt with the method and answer and returns it', async () => {
const client = createStubOpenCodeClient()
-9
View File
@@ -23,15 +23,6 @@ export function createOAuthRoutes(openCodeClient: OpenCodeClient) {
}
})
app.get('/integrations', async (c) => {
try {
const integrations = await openCodeClient.api.integration.list()
return c.json({ integrations: integrations.data })
} catch (error) {
return handleOpenCodeError(c, error, 'Failed to list provider integrations')
}
})
app.post('/:id/oauth/authorize', async (c) => {
try {
const body = await c.req.json()