From e73c7ed305588d62ff53a50e5d235abcecb0de59 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Wed, 11 Mar 2026 18:50:33 +0100 Subject: [PATCH] fix: compute group bounding box using container descendants from layout Thread a shared containerDescendants map through layoutLevel recursion instead of re-running detectGroups in a separate pass. This ensures group overlays properly encompass container modules (branchall, branchone, forloop, whileloop) in width by including their synthetic nodes. Co-Authored-By: Claude Opus 4.6 --- .../lib/components/graph/FlowGraphV2.svelte | 5 +- .../lib/components/graph/GroupOverlay.svelte | 87 +++++++++++-------- .../lib/components/graph/compoundLayout.ts | 25 +++++- frontend/src/lib/components/graph/util.ts | 38 +++++++- 4 files changed, 111 insertions(+), 44 deletions(-) diff --git a/frontend/src/lib/components/graph/FlowGraphV2.svelte b/frontend/src/lib/components/graph/FlowGraphV2.svelte index 15851b812c..cb63777683 100644 --- a/frontend/src/lib/components/graph/FlowGraphV2.svelte +++ b/frontend/src/lib/components/graph/FlowGraphV2.svelte @@ -349,6 +349,7 @@ } type NodePos = { position: { x: number; y: number } } let lastNodes: [NodeDep[], (NodeDep & NodePos)[]] | undefined = undefined + let currentContainerDescendants: Map = new Map() function layoutNodes(nodes: NodeDep[]): (NodeDep & NodePos)[] { let lastResult = lastNodes?.[1] @@ -366,7 +367,7 @@ } // Run recursive compound layout - const { positions, bbox } = compoundLayout(nodes, { + const { positions, bbox, containerDescendants: layoutContainerDescendants } = compoundLayout(nodes, { nodeWidth: NODE.width, nodeHeight: NODE.height, gapH: NODE.gap.horizontal, @@ -383,6 +384,7 @@ } })) + currentContainerDescendants = layoutContainerDescendants ?? new Map() lastNodes = [nodes, newNodes] return newNodes } @@ -1111,6 +1113,7 @@ allNodes={nodesWithOffset as (Node & { type: string })[]} {editMode} {showNotes} + containerDescendants={currentContainerDescendants} /> diff --git a/frontend/src/lib/components/graph/GroupOverlay.svelte b/frontend/src/lib/components/graph/GroupOverlay.svelte index 4083448614..af9c2c2338 100644 --- a/frontend/src/lib/components/graph/GroupOverlay.svelte +++ b/frontend/src/lib/components/graph/GroupOverlay.svelte @@ -1,6 +1,6 @@