Skip to content

Commit c19730e

Browse files
committed
fix: enable Requesty refresh models with credentials
The existing flushRouterModels pattern doesn't work for Requesty because it doesn't pass API credentials. This caused the 'Refresh Models' button to return stale cached data instead of fresh models. This fix: - Adds a 'refresh: true' flag to requestRouterModels handler - When refresh=true with a provider filter, flushes cache WITH credentials - Updates Requesty.tsx to use this new pattern instead of flushRouterModels The approach reuses existing infrastructure while ensuring the credential- aware cache flush works for providers like Requesty that require apiKey and baseUrl for API calls. Supersedes #10264
1 parent 2bb3755 commit c19730e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/core/webview/webviewMessageHandler.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,9 @@ export const webviewMessageHandler = async (
790790
const requestedProvider = message?.values?.provider
791791
const providerFilter = requestedProvider ? toRouterName(requestedProvider) : undefined
792792

793+
// Optional refresh flag to flush cache before fetching (useful for providers requiring credentials)
794+
const shouldRefresh = message?.values?.refresh === true
795+
793796
const routerModels: Record<RouterName, ModelRecord> = providerFilter
794797
? ({} as Record<RouterName, ModelRecord>)
795798
: {
@@ -887,6 +890,12 @@ export const webviewMessageHandler = async (
887890
? candidates.filter(({ key }) => key === providerFilter)
888891
: candidates
889892

893+
// If refresh flag is set and we have a specific provider, flush its cache first
894+
if (shouldRefresh && providerFilter && modelFetchPromises.length > 0) {
895+
const targetCandidate = modelFetchPromises[0]
896+
await flushModels(targetCandidate.options, true)
897+
}
898+
890899
const results = await Promise.allSettled(
891900
modelFetchPromises.map(async ({ key, options }) => {
892901
const models = await safeGetModels(options)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const Requesty = ({
3030
apiConfiguration,
3131
setApiConfigurationField,
3232
routerModels,
33-
refetchRouterModels,
3433
organizationAllowList,
3534
modelValidationError,
3635
uriScheme,
@@ -127,8 +126,7 @@ export const Requesty = ({
127126
<Button
128127
variant="outline"
129128
onClick={() => {
130-
vscode.postMessage({ type: "flushRouterModels", text: "requesty" })
131-
refetchRouterModels()
129+
vscode.postMessage({ type: "requestRouterModels", values: { provider: "requesty", refresh: true } })
132130
}}>
133131
<div className="flex items-center gap-2">
134132
<span className="codicon codicon-refresh" />

0 commit comments

Comments
 (0)