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:
wizardchen
2026-06-09 18:03:28 +08:00
committed by lyingbug
parent e78a9482d4
commit 4de3c3efbd
3 changed files with 18 additions and 3 deletions
+3 -1
View File
@@ -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);
});
});
}