File tree Expand file tree Collapse file tree
webview-ui/src/components/settings/providers Expand file tree Collapse file tree Original file line number Diff line number Diff 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".
Original file line number Diff line number Diff 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 } )
You can’t perform that action at this time.
0 commit comments