WeKnora/frontend/src/composables
lyingbug 745a22d066
refactor(frontend): drop TTL resource caches and remove duplicate startup requests (#3562)
* refactor(frontend): drop TTL resource caches and remove duplicate startup requests

Space-level resource stores (chatResources / editorResources / organization)
cached lists for 60s. Pages that own the data bypassed the cache with force,
while side consumers (chat input bar, selectors) read stale values and relied
on a web of indirect refresh signals. Replace the TTL with in-flight
deduplication plus explicit invalidation:

- add stores/resourceCache.ts: createCachedResource (one request in flight
  per resource, force queues behind it, invalidate/markLoaded discard stale
  responses) and createKeyedSnapshotCache for per-id details
- rebuild chatResources / editorResources on those primitives; organization
  store drops its loadedAt timestamps and uses the request coordinator only
- isFresh -> isLoaded (only "has a snapshot" is meaningful now)

Fix concrete duplicates found on the way:

- /auth/me was fetched twice on every cold load (main.ts + UserMenu); auth
  store now dedupes in-flight calls and exposes ensureAuthMe, router hydrate
  reuses refreshFromAuthMe instead of a second copy of the persist logic
- /system/info was fetched by menu.vue directly next to editorResources
- /platform/settings rendered Settings.vue as the route component while the
  platform layout already mounts it, so two modals were visible and every
  settings panel request ran twice; the route now renders an empty view
- components that called listKnowledgeBases / listAgents / getParserEngines /
  getPromptTemplates directly now go through the stores
- Input-field no longer force-refreshes models and web-search providers on
  "settings closed" / "left settings route"; WebSearchSettings writes back to
  the shared snapshot and useTenantModelReadiness derives from the store

Measured with a mock backend: cold load 19 -> 18 requests (/auth/me once),
settings model panel 3 -> 2 (one modal), route changes now refetch lists
(creatChat 3 -> 9, back to KB list 0 -> 4) instead of serving 60s-old data.

* fix(frontend): fence stale responses in the resource caches and /auth/me refresh

Review follow-ups on the TTL removal:

- createKeyedSnapshotCache tracks a per-key revision; invalidate() and a
  force read both advance it, so a response that lands after invalidation
  or behind a newer request is handed to its caller but never written back
  into the snapshot. Previously a KB detail read still in flight during
  save could re-pin the pre-save detail until the next explicit invalidate.
- ensureKnowledgeBases / ensureAgents no longer reject when the shared
  resource fetch fails; the own list is already applied and the previous
  shared snapshot is kept. Callers migrated onto the store (manual editor,
  KB selector, FAQ manager, API integration page) had independent failure
  handling before. McpServerIntegrationSettings shows empty lists on
  failure instead of the last snapshot.
- /auth/me refresh is sequenced via a new createSequencedRefresh helper:
  refreshFromAuthMe() always resolves on a request issued after the call
  (queued behind an in-flight one), ensureAuthMe() shares in-flight, and
  logout() invalidates so a late response cannot re-apply the old session.

Tests: keyed cache invalidate-during-flight and force-overlap; sequencer
refresh ordering, invalidate after logout, and recovery after a failed
in-flight request.

* fix(frontend): refetch models after publishing a catalog change

invalidate() no longer triggers a refetch and the chat input stopped
reloading models when settings close, so the reasoning-level selector kept
stale capabilities after a catalog publish. Force-refresh the snapshot.
2026-09-25 22:22:48 +08:00
..
preferenceStorage.ts fix(frontend): drop infectious preference fallback, add migration latch 2026-05-05 00:48:40 +08:00
skillInstallProgress.ts feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
useApiBaseUrlDisplay.ts feat(frontend): add Chrome extension and Claw Skill integration landing pages 2026-06-28 00:31:38 +08:00
useArtifactArriveMotion.ts feat(chat): pulse the artifact folder when generated files arrive 2026-09-02 15:08:05 +08:00
useChatAttachmentPreviewDrawer.ts feat(chat): add session-scoped temporary attachments with async parsing 2026-07-16 17:41:27 +08:00
useChatCitationPopover.ts refactor(frontend): share citation popover lifecycle 2026-09-17 15:28:31 +08:00
useChatMemoryRow.ts fix(frontend): 修复占位行样式并把记忆行统一收进时间轴 2026-08-13 21:34:21 +08:00
useChatQuestionMinimap.ts fix(chat): keep composer fixed while messages overscroll 2026-09-22 23:27:20 +08:00
useChatReferencesDrawer.ts feat(chat): open cited documents at the cited passage (#3700) 2026-09-25 13:26:16 +08:00
useChatSandboxPanel.test.mjs fix(chat): refine sandbox artifact panel interactions 2026-09-09 21:42:04 +08:00
useChatSandboxPanel.ts Revert "feat(sandbox): add safe live file management to session sandboxes (#3…" 2026-09-11 17:42:08 +08:00
useChatStreamHandler.integration.test.ts fix(chat): restore shared workspace images after stream completion (#3523) 2026-09-22 00:16:58 +08:00
useChatStreamHandler.test.mjs fix(chat): restore shared workspace images after stream completion (#3523) 2026-09-22 00:16:58 +08:00
useChatStreamHandler.ts fix(chat): restore shared workspace images after stream completion (#3523) 2026-09-22 00:16:58 +08:00
useCitationPopover.test.ts feat(chat): open cited documents at the cited passage (#3700) 2026-09-25 13:26:16 +08:00
useCitationPopover.ts feat(chat): open cited documents at the cited passage (#3700) 2026-09-25 13:26:16 +08:00
useConfigSkillInstallProgress.test.mjs refactor(frontend): share skill install progress subscriptions 2026-09-16 23:12:14 +08:00
useConfigSkillInstallProgress.test.ts feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
useConfigSkillInstallProgress.ts feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
useDocumentPictureInPicture.test.ts feat(browser): add picture-in-picture task preview 2026-09-12 11:11:36 +08:00
useDocumentPictureInPicture.ts feat(browser): add picture-in-picture task preview 2026-09-12 11:11:36 +08:00
useEmbedBridge.ts feat(frontend): embed OAuth wiring and API integration UI polish 2026-06-30 20:01:05 +08:00
useEmbedChatSession.ts fix(chat): prevent pending steer messages from jittering during streaming 2026-09-09 22:58:09 +08:00
useEmbedCitationPopover.ts refactor(frontend): share citation popover lifecycle 2026-09-17 15:28:31 +08:00
useFloatingPreviewDrag.test.ts feat(browser): polish connection settings, open tasks in a new window, and streamline prompts (#3193) 2026-09-11 21:28:58 +08:00
useFloatingPreviewDrag.ts feat(browser): polish connection settings, open tasks in a new window, and streamline prompts (#3193) 2026-09-11 21:28:58 +08:00
useFont.ts fix(frontend): make general-settings font picker actually work 2026-05-07 15:07:24 +08:00
useListUrlState.ts feat(favorites): implement user favorites and recents functionality 2026-05-18 17:28:58 +08:00
useModalShell.ts feat(toolbox): introduce toolbox feature with skills, MCP, and browser connection management 2026-09-23 17:12:19 +08:00
useProtectedImageRecovery.ts fix(chat): restore shared workspace images after stream completion (#3523) 2026-09-22 00:16:58 +08:00
useResourcePins.ts feat(favorites): implement user favorites and recents functionality 2026-05-18 17:28:58 +08:00
useRoleLabel.ts feat(rbac-ui): rework tenant identity surfaces 2026-05-18 17:28:58 +08:00
useSandboxDesktop.test.mjs feat(sandbox): add a graphical desktop to session sandboxes (#3245) 2026-09-14 20:37:37 +08:00
useSandboxDesktop.ts feat(sandbox): add a graphical desktop to session sandboxes (#3245) 2026-09-14 20:37:37 +08:00
useSandboxTerminal.ts feat(sandbox): unify the interactive PTY prompt and reconnect running sandboxes (#3128) 2026-09-09 18:17:10 +08:00
useSessionTitleMotion.ts fix(ui): 优化对话布局、导航与产物和引用展示 (#3427) 2026-09-19 19:25:52 +08:00
useSkillInstallerModel.test.ts refactor(frontend): share skill installer model configuration 2026-09-16 20:58:03 +08:00
useSkillInstallerModel.ts refactor(frontend): share skill installer model configuration 2026-09-16 20:58:03 +08:00
useStickyBottomOnResize.test.ts fix(ui): 优化对话布局、导航与产物和引用展示 (#3427) 2026-09-19 19:25:52 +08:00
useStickyBottomOnResize.ts fix(ui): 优化对话布局、导航与产物和引用展示 (#3427) 2026-09-19 19:25:52 +08:00
useTagChipsOverflow.ts fix(knowledge): harden multi-tag data integrity and UX follow-ups 2026-06-26 10:52:52 +08:00
useTenantModelReadiness.ts refactor(frontend): drop TTL resource caches and remove duplicate startup requests (#3562) 2026-09-25 22:22:48 +08:00
useTheme.ts fix(frontend): drop infectious preference fallback, add migration latch 2026-05-05 00:48:40 +08:00
useTypewriter.test.ts feat(agent): unify sandbox tools and drop host preloaded skills (#3033) 2026-09-05 16:45:59 +08:00
useTypewriter.ts feat(agent): unify sandbox tools and drop host preloaded skills (#3033) 2026-09-05 16:45:59 +08:00