fix: better handling of empty model catalog
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user