From 85b1447bb3c4aaf2e041c8be120178257d7fbcfa Mon Sep 17 00:00:00 2001 From: tangkikodo Date: Fri, 3 Jul 2026 19:17:34 +0800 Subject: [PATCH] fix(voyager): refetch Related Entities sub-graph when main graph re-renders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Related Entities sub-graph (spec 005) was not following display-option changes — toggling Hide Reverse Relationships / brief mode / Better Cluster Display / Show Methods / etc. re-rendered the main ER diagram but left the sub-graph showing the previous config's edges. The Pure FK toggle (PR #99) made the issue most visible because missing edges are obvious, but the bug affected every display toggle since spec 005 introduced the sub-graph. Root cause: `onGenerate` only dispatches to `renderErDiagram` (main graph); it never touches the sub-graph. `fetchRelatedEntities` has a dedup guard (spec 005 FR-011) that returns early when `selectedSchema === schemaName` and the previous dot still exists, so any re-render of the main graph with a new config leaves the sub-graph stuck on stale data. Fix: in `renderErDiagram`, after the main graph renders, if a sub-graph is currently open (`selectedSchema` non-empty and `dot` present), clear `selectedSchema` to defeat the dedup guard and call `fetchRelatedEntities` again with the same schema. This picks up the latest toggle state through `buildErDiagramSubgraphPayload`, which already threads every display option (cluster display / brief / show methods / hide reverse / etc.). Spec 005 FR-011's anti-rapid-click dedup is preserved — the guard still fires when the same entity is clicked twice in quick succession while no config has changed. Manual verification: open ER diagram → double-click an entity with a `back_populates` relationship (e.g. Post↔User) → open Related Entities tab → toggle "Hide Reverse Relationships" → sub-graph now re-renders with ONETOMANY reverse edges hidden, matching the main graph. Co-Authored-By: Claude Opus 4.7 --- src/nexusx/voyager/web/vue-main.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/nexusx/voyager/web/vue-main.js b/src/nexusx/voyager/web/vue-main.js index 99263a8..bfed02b 100644 --- a/src/nexusx/voyager/web/vue-main.js +++ b/src/nexusx/voyager/web/vue-main.js @@ -201,6 +201,18 @@ const app = createApp({ const schemasArr = Array.isArray(data.schemas) ? data.schemas : [] store.state.erDiagramSchemas = Object.fromEntries(schemasArr.map((s) => [s.id, s])) await graphUI.render(data.dot, resetZoom) + // Spec 007 fix — when the main graph re-renders because a display + // toggle (Hide Reverse Relationships / brief mode / cluster display / + // show methods / etc.) changed, the Related Entities sub-graph must + // refetch too, otherwise it keeps showing the previous config's data. + // fetchRelatedEntities has a dedup guard (spec 005 FR-011) that would + // skip the fetch when the same schemaName is open; clearing + // selectedSchema forces the next call to actually hit the server. + const openSubSchema = store.state.relatedEntities.selectedSchema + if (openSubSchema && store.state.relatedEntities.dot) { + store.state.relatedEntities.selectedSchema = "" + store.actions.fetchRelatedEntities(openSubSchema) + } } catch (err) { console.error(err) } finally {