fix: better handling of empty model catalog

This commit is contained in:
2026-03-01 17:09:29 +01:00
parent 63674266f5
commit c02ddc6d7a
2 changed files with 12 additions and 0 deletions

View File

@@ -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.

View File

@@ -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);