mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
fix(ollama): address Rooviewer feedback - double API calls and silent failures
- Change flushModels(options, true) to flushModels(options, false) in both requestOllamaModels and refreshOllamaModels handlers to avoid redundant /api/tags + /api/show calls (discoverOllamaModelsWithSorting already performs the full discovery) - Always send ollamaModels message to the UI regardless of totalCount, so the UI clears stale state when no models are found - Update test expectation for flushModels(_, false)
This commit is contained in:
parent
609fbac98e
commit
6d14eecce3
2 changed files with 18 additions and 19 deletions
|
|
@ -252,7 +252,7 @@ describe("webviewMessageHandler - requestOllamaModels", () => {
|
|||
type: "requestOllamaModels",
|
||||
})
|
||||
|
||||
expect(mockFlushModels).toHaveBeenCalledWith({ provider: "ollama", baseUrl: "http://localhost:1234" }, true)
|
||||
expect(mockFlushModels).toHaveBeenCalledWith({ provider: "ollama", baseUrl: "http://localhost:1234" }, false)
|
||||
expect(mockDiscoverOllamaModels).toHaveBeenCalledWith(
|
||||
"http://localhost:1234",
|
||||
undefined,
|
||||
|
|
|
|||
|
|
@ -990,7 +990,7 @@ export const webviewMessageHandler = async (
|
|||
baseUrl: ollamaApiConfig.ollamaBaseUrl,
|
||||
apiKey: ollamaApiConfig.ollamaApiKey,
|
||||
}
|
||||
await flushModels(ollamaOptions, true)
|
||||
await flushModels(ollamaOptions, false)
|
||||
|
||||
const result = await discoverOllamaModelsWithSorting(
|
||||
ollamaApiConfig.ollamaBaseUrl,
|
||||
|
|
@ -1009,15 +1009,13 @@ export const webviewMessageHandler = async (
|
|||
modelsWithToolsRecord[model.name] = model.modelInfo
|
||||
}
|
||||
|
||||
// Always send the models message if we have any results
|
||||
if (result.totalCount > 0) {
|
||||
provider.postMessageToWebview({
|
||||
type: "ollamaModels",
|
||||
ollamaModels: modelsWithToolsRecord,
|
||||
ollamaModelsWithTools: result.modelsWithTools,
|
||||
modelsWithoutTools: result.modelsWithoutTools,
|
||||
})
|
||||
}
|
||||
// Always send the models message so the UI reflects current state
|
||||
provider.postMessageToWebview({
|
||||
type: "ollamaModels",
|
||||
ollamaModels: modelsWithToolsRecord,
|
||||
ollamaModelsWithTools: result.modelsWithTools,
|
||||
modelsWithoutTools: result.modelsWithoutTools,
|
||||
})
|
||||
} catch (error) {
|
||||
console.debug("Ollama models fetch failed:", error)
|
||||
}
|
||||
|
|
@ -1075,7 +1073,7 @@ export const webviewMessageHandler = async (
|
|||
ollamaEnableLogging: ollamaApiConfig.ollamaEnableLogging,
|
||||
}
|
||||
|
||||
await flushModels(ollamaOptions, true)
|
||||
await flushModels(ollamaOptions, false)
|
||||
|
||||
const result = await discoverOllamaModelsWithSorting(baseUrl, apiKey, {
|
||||
modelDiscoveryTimeout: ollamaApiConfig.ollamaModelDiscoveryTimeout,
|
||||
|
|
@ -1104,14 +1102,15 @@ export const webviewMessageHandler = async (
|
|||
})
|
||||
}
|
||||
|
||||
// Always send the models message if we have any results
|
||||
// Always send the models message so the UI reflects current state
|
||||
provider.postMessageToWebview({
|
||||
type: "ollamaModels",
|
||||
ollamaModels: modelsWithToolsRecord,
|
||||
ollamaModelsWithTools: result.modelsWithTools,
|
||||
modelsWithoutTools: result.modelsWithoutTools,
|
||||
})
|
||||
|
||||
if (result.totalCount > 0) {
|
||||
provider.postMessageToWebview({
|
||||
type: "ollamaModels",
|
||||
ollamaModels: modelsWithToolsRecord,
|
||||
ollamaModelsWithTools: result.modelsWithTools,
|
||||
modelsWithoutTools: result.modelsWithoutTools,
|
||||
})
|
||||
provider.postMessageToWebview({
|
||||
type: "ollamaModelsRefreshResult",
|
||||
success: true,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue