From 09308631bce85b269c3fd48d5e2cd2cdb26bd6bb Mon Sep 17 00:00:00 2001 From: Lum1104 Date: Sun, 3 May 2026 17:26:49 +0800 Subject: [PATCH] fix(dashboard): clear container cache on focus, deprecate applyDagreLayout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setFocusNode was missed in the C1 cache-reset pass. Focus mode narrows filteredGraphNodes to focus + 1-hop neighbors, so a container that survives still has a subset of its children — the cache must drop or it'll keep returning positions for filtered-out ids. Mark applyDagreLayout @deprecated. The structural views all use ELK now; the helper is retained for one release as a quick fallback path and removed in the next. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../packages/dashboard/src/store.ts | 12 +++++++++++- .../packages/dashboard/src/utils/layout.ts | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/understand-anything-plugin/packages/dashboard/src/store.ts b/understand-anything-plugin/packages/dashboard/src/store.ts index a8cfdf1..ec833d4 100644 --- a/understand-anything-plugin/packages/dashboard/src/store.ts +++ b/understand-anything-plugin/packages/dashboard/src/store.ts @@ -387,7 +387,17 @@ export const useDashboardStore = create()((set, get) => ({ expandedContainers: new Set(), }), - setFocusNode: (nodeId) => set({ focusNodeId: nodeId, selectedNodeId: nodeId }), + setFocusNode: (nodeId) => + set({ + focusNodeId: nodeId, + selectedNodeId: nodeId, + // Focus mode narrows filteredGraphNodes to focus + 1-hop; the + // surviving containers have a subset of their original children, + // and the cache must not return positions for filtered-out ids. + containerLayoutCache: new Map(), + containerSizeMemory: new Map(), + expandedContainers: new Set(), + }), setSearchMode: (mode) => set({ searchMode: mode }), setSearchQuery: (query) => { const engine = get().searchEngine; diff --git a/understand-anything-plugin/packages/dashboard/src/utils/layout.ts b/understand-anything-plugin/packages/dashboard/src/utils/layout.ts index cd73fb6..b35328c 100644 --- a/understand-anything-plugin/packages/dashboard/src/utils/layout.ts +++ b/understand-anything-plugin/packages/dashboard/src/utils/layout.ts @@ -21,6 +21,11 @@ export const PORTAL_NODE_HEIGHT = 80; /** * Synchronous dagre layout — used for small graphs. + * + * @deprecated The dashboard's structural views all use ELK now + * (`applyElkLayout` from `./elk-layout`). This helper is kept for one + * release to allow a quick fallback if ELK has a regression. Slated for + * removal in the version after layout migration is verified stable. */ export function applyDagreLayout( nodes: Node[],