diff --git a/src/main/engine/OpenCodeManager.ts b/src/main/engine/OpenCodeManager.ts index f8e4cf7..f2ed18b 100644 --- a/src/main/engine/OpenCodeManager.ts +++ b/src/main/engine/OpenCodeManager.ts @@ -2167,6 +2167,15 @@ NOTE: Use pagination (offset/limit) in list_posts and search_posts to access all return this.modelCatalogEngine; } + /** + * Invalidate the in-memory model cache so the next getAvailableModels() + * re-fetches and re-cross-references with the catalog. + */ + invalidateModelCache(): void { + this.cachedModels = null; + this.cachedModelsAt = 0; + } + /** * Check whether the given provider's API key is configured. * All non-mistral providers are routed through OpenCode Zen and share apiKey. diff --git a/src/main/ipc/chatHandlers.ts b/src/main/ipc/chatHandlers.ts index 0755db4..fdfc156 100644 --- a/src/main/ipc/chatHandlers.ts +++ b/src/main/ipc/chatHandlers.ts @@ -330,6 +330,9 @@ export function registerChatHandlers(): void { try { const manager = await getOpenCodeManager(); const result = await manager.getModelCatalogEngine().refresh(); + // Invalidate the in-memory model cache so vision/name data + // from the freshly populated catalog is picked up immediately. + manager.invalidateModelCache(); return result; } catch (error) { console.error('[Chat IPC] Error refreshing model catalog:', error);