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

+3 -4
View File
@@ -2,6 +2,7 @@ import { API_BASE_URL } from "@/config"
import type { FormAnswer, IntegrationInfo, IntegrationMethod } from "@opencode-manager/shared/opencode"
import type { OAuthAttemptStatus, OAuthAuthorizeResponse } from "@opencode-manager/shared/schemas"
import { fetchWrapper, fetchWrapperVoid } from "./fetchWrapper"
import { callOpenCode } from "./opencodeApi"
export type {
FormAnswer,
@@ -48,9 +49,7 @@ export const oauthApi = {
},
getIntegrations: async (): Promise<IntegrationInfo[]> => {
const { integrations } = await fetchWrapper<{ integrations: IntegrationInfo[] }>(
`${API_BASE_URL}/api/oauth/integrations`
)
return integrations
const { data } = await callOpenCode((api) => api.integration.list())
return data
},
}
-7
View File
@@ -304,13 +304,6 @@ describe('providerCredentialsApi', () => {
vi.clearAllMocks()
})
it('lists provider ids with credentials from the Manager response', async () => {
mockFetchWrapper.mockResolvedValue({ providers: ['anthropic', 'openai'] })
await expect(providerCredentialsApi.list()).resolves.toEqual(['anthropic', 'openai'])
expect(mockFetchWrapper).toHaveBeenCalledWith(`${API_BASE_URL}/api/providers/credentials`)
})
it('reports credential status from the Manager response', async () => {
mockFetchWrapper.mockResolvedValue({ hasCredentials: true })
+1 -6
View File
@@ -16,7 +16,7 @@ import {
type ModelPreferenceModel,
type ModelRef,
} from "@opencode-manager/shared/opencode";
import type { CredentialListResponse, CredentialStatusResponse } from "@opencode-manager/shared/schemas";
import type { CredentialStatusResponse } from "@opencode-manager/shared/schemas";
export type Model = Pick<ModelInfo, 'id' | 'modelID' | 'name'> & {
limit?: {
@@ -186,11 +186,6 @@ export function formatProviderName(provider: Provider): string {
}
export const providerCredentialsApi = {
list: async (): Promise<string[]> => {
const { providers } = await fetchWrapper<CredentialListResponse>(`${API_BASE_URL}/api/providers/credentials`);
return providers;
},
getStatus: async (providerId: string): Promise<boolean> => {
const { hasCredentials } = await fetchWrapper<CredentialStatusResponse>(
`${API_BASE_URL}/api/providers/${providerId}/credentials/status`