Skip to content

Commit d5bd771

Browse files
committed
fix(webview): handle remaining model providers explicitly
1 parent 68f6226 commit d5bd771

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { Mock } from "vitest"
88
import {
99
ProviderSettings,
1010
ModelInfo,
11+
anthropicModels,
1112
BEDROCK_1M_CONTEXT_MODEL_IDS,
1213
litellmDefaultModelInfo,
1314
kenariDefaultModelId,
@@ -440,6 +441,23 @@ describe("useSelectedModel", () => {
440441
expect(result.current.info?.inputPrice).toBe(6.0)
441442
expect(result.current.info?.outputPrice).toBe(22.5)
442443
})
444+
445+
it.each(["anthropic", "gemini-cli", "fake-ai"] as const)(
446+
"should explicitly resolve configured models for %s",
447+
(apiProvider) => {
448+
const apiConfiguration: ProviderSettings = {
449+
apiProvider,
450+
apiModelId: "claude-sonnet-4-6",
451+
}
452+
453+
const wrapper = createWrapper()
454+
const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper })
455+
456+
expect(result.current.provider).toBe(apiProvider)
457+
expect(result.current.id).toBe("claude-sonnet-4-6")
458+
expect(result.current.info).toEqual(anthropicModels["claude-sonnet-4-6"])
459+
},
460+
)
443461
})
444462

445463
describe("bedrock provider with 1M context", () => {

webview-ui/src/components/ui/hooks/useSelectedModel.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,9 @@ function getSelectedModel({
418418
const info = routerModels["zoo-gateway"]?.[id]
419419
return { id, info }
420420
}
421-
// case providerIdentifiers.anthropic:
422-
// case providerIdentifiers.fakeAi:
423-
default: {
424-
provider satisfies "anthropic" | "gemini-cli" | "fake-ai"
421+
case providerIdentifiers.anthropic:
422+
case providerIdentifiers.geminiCli:
423+
case providerIdentifiers.fakeAi: {
425424
const id = apiConfiguration.apiModelId ?? defaultModelId
426425
const baseInfo = anthropicModels[id as keyof typeof anthropicModels]
427426

@@ -462,5 +461,9 @@ function getSelectedModel({
462461

463462
return { id, info: baseInfo }
464463
}
464+
default: {
465+
provider satisfies never
466+
throw new Error(`Unsupported provider: ${provider}`)
467+
}
465468
}
466469
}

0 commit comments

Comments
 (0)