Skip to content

Commit a55d21e

Browse files
committed
Revert "refactor(webview): keep selected model cache out of provider settings"
This reverts commit d22864b.
1 parent d22864b commit a55d21e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

webview-ui/src/components/settings/providers/LiteLLM.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ export const LiteLLM = ({
5858
if (refreshStatus === "loading") {
5959
if (!litellmErrorJustReceived.current) {
6060
setRefreshStatus("success")
61-
// Refresh the shared cache used by ApiOptions without invalidating unrelated queries.
61+
// Refresh the provider-scoped cache used by useSelectedModel and the shared cache used by
62+
// ApiOptions. Target both exact keys rather than the bare ["routerModels"] prefix, which
63+
// would needlessly invalidate every other provider's query too.
64+
void queryClient.invalidateQueries({ queryKey: ["routerModels", providerIdentifiers.litellm] })
6265
void queryClient.invalidateQueries({ queryKey: ["routerModels", "all"] })
6366
}
6467
// If litellmErrorJustReceived.current is true, status is already (or will be) "error".

webview-ui/src/components/settings/providers/__tests__/LiteLLM.spec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe("LiteLLM", () => {
4747
mockUseExtensionState.mockReturnValue({ routerModels: { [providerIdentifiers.litellm]: {} } })
4848
})
4949

50-
it("invalidates the shared LiteLLM cache after a successful model refresh", async () => {
50+
it("invalidates both LiteLLM caches after a successful model refresh", async () => {
5151
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
5252
const invalidateQueries = vi.spyOn(queryClient, "invalidateQueries")
5353
const apiConfiguration: ProviderSettings = {
@@ -72,6 +72,9 @@ describe("LiteLLM", () => {
7272
})
7373

7474
await waitFor(() => {
75+
expect(invalidateQueries).toHaveBeenCalledWith({
76+
queryKey: ["routerModels", providerIdentifiers.litellm],
77+
})
7578
expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ["routerModels", "all"] })
7679
})
7780
})

0 commit comments

Comments
 (0)