fix(frontend): harden chat resources cache invalidation and dedup
- Invalidate the single-KB detail cache when editing a KB from the list page, matching the detail page so the sidebar/detail no longer show a stale name/config for up to the cache TTL. - Reject (instead of swallowing) listModels network failures so the cache layer can tell a transient failure apart from a genuinely empty model list and avoid caching the empty result for the whole TTL. All UI callers already wrap listModels in try/catch. - Guard the kb/agent in-flight handles with a generation counter so a concurrent force refresh cannot null out a still-running request, and clear all in-flight maps on invalidate() so stale requests cannot repopulate the cache after invalidation.
This commit is contained in:
@@ -80,7 +80,9 @@ export function listModels(type?: string): Promise<ModelConfig[]> {
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.error('Failed to list models:', error);
|
||||
resolve([]);
|
||||
// 抛出而非吞掉:调用方(含缓存层)才能区分「真失败」与「成功但无模型」,
|
||||
// 避免把一次瞬时失败的空结果缓存下来。各 UI 调用点均已 try/catch 兜底。
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user