Repository navigation
refactor(layout): centralize node, group, and reroute geometry - #14110
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 inconclusive)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🎨 Storybook: ✅ Built — View Storybook🎭 Playwright: ✅ 1755 passed, 0 failed · 4 flaky📊 Browser Reports
📦 Bundle Size
⚡ Performance Report
Absolute values
Raw data{
"timestamp": "2026-07-31T09:01:57.171Z",
"gitSha": "50d07fec394b2f547d45dba277a080db71c6356f",
"branch": "drjkl/layout-single-source",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2038.2390000000044,
"styleRecalcs": 9,
"styleRecalcDurationMs": 7.872000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 456.099,
"heapDeltaBytes": 4786880,
"heapUsedBytes": 73874892,
"domNodes": 18,
"jsHeapTotalBytes": 19525632,
"scriptDurationMs": 28.643,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "canvas-idle",
"durationMs": 2021.2390000000369,
"styleRecalcs": 9,
"styleRecalcDurationMs": 6.904999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 456.912,
"heapDeltaBytes": 4506768,
"heapUsedBytes": 73581248,
"domNodes": 18,
"jsHeapTotalBytes": 19525632,
"scriptDurationMs": 19.972,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "canvas-mouse-sweep",
"durationMs": 2105.913000000015,
"styleRecalcs": 82,
"styleRecalcDurationMs": 51.187999999999995,
"layouts": 12,
"layoutDurationMs": 3.891,
"taskDurationMs": 1138.487,
"heapDeltaBytes": -15517784,
"heapUsedBytes": 53686328,
"domNodes": -269,
"jsHeapTotalBytes": 20701184,
"scriptDurationMs": 198.013,
"eventListeners": -150,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1852.5340000000483,
"styleRecalcs": 79,
"styleRecalcDurationMs": 36.152,
"layouts": 12,
"layoutDurationMs": 3.3040000000000007,
"taskDurationMs": 903.0070000000001,
"heapDeltaBytes": -22913704,
"heapUsedBytes": 46134948,
"domNodes": 61,
"jsHeapTotalBytes": 21225472,
"scriptDurationMs": 153.002,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1756.129000000044,
"styleRecalcs": 33,
"styleRecalcDurationMs": 15.885,
"layouts": 6,
"layoutDurationMs": 0.608,
"taskDurationMs": 371.412,
"heapDeltaBytes": 7921512,
"heapUsedBytes": 76942144,
"domNodes": 78,
"jsHeapTotalBytes": 19525632,
"scriptDurationMs": 22.728999999999996,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1745.151000000078,
"styleRecalcs": 31,
"styleRecalcDurationMs": 16.796,
"layouts": 6,
"layoutDurationMs": 0.603,
"taskDurationMs": 383.56,
"heapDeltaBytes": 7988184,
"heapUsedBytes": 76868500,
"domNodes": 77,
"jsHeapTotalBytes": 19525632,
"scriptDurationMs": 22.764,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "dom-widget-clipping",
"durationMs": 587.6030000000014,
"styleRecalcs": 10,
"styleRecalcDurationMs": 6.226000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 403.209,
"heapDeltaBytes": -10016488,
"heapUsedBytes": 59134912,
"domNodes": 16,
"jsHeapTotalBytes": 20574208,
"scriptDurationMs": 81.579,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "dom-widget-clipping",
"durationMs": 572.731000000033,
"styleRecalcs": 12,
"styleRecalcDurationMs": 8.337,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 380.542,
"heapDeltaBytes": -9968564,
"heapUsedBytes": 59021440,
"domNodes": 20,
"jsHeapTotalBytes": 20049920,
"scriptDurationMs": 76.842,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.663333333333338,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2041.8510000000083,
"styleRecalcs": 8,
"styleRecalcDurationMs": 5.7059999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 800.138,
"heapDeltaBytes": -12143724,
"heapUsedBytes": 58625764,
"domNodes": -275,
"jsHeapTotalBytes": 4288512,
"scriptDurationMs": 230.99800000000005,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2037.50500000001,
"styleRecalcs": 7,
"styleRecalcDurationMs": 5.131999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 804.994,
"heapDeltaBytes": -1450016,
"heapUsedBytes": 69424484,
"domNodes": -273,
"jsHeapTotalBytes": 2977792,
"scriptDurationMs": 232.85,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-pan",
"durationMs": 2249.0119999999933,
"styleRecalcs": 69,
"styleRecalcDurationMs": 13.986999999999997,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1719.208,
"heapDeltaBytes": -7483992,
"heapUsedBytes": 64553764,
"domNodes": -274,
"jsHeapTotalBytes": 4493312,
"scriptDurationMs": 937.4810000000001,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 2293.3439999999337,
"styleRecalcs": 69,
"styleRecalcDurationMs": 13.772,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1708.4060000000002,
"heapDeltaBytes": -5597052,
"heapUsedBytes": 67292024,
"domNodes": -277,
"jsHeapTotalBytes": 2920448,
"scriptDurationMs": 922.462,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-zoom",
"durationMs": 3703.7460000000237,
"styleRecalcs": 65,
"styleRecalcDurationMs": 14.102999999999998,
"layouts": 60,
"layoutDurationMs": 7.531000000000001,
"taskDurationMs": 2016.774,
"heapDeltaBytes": -4253152,
"heapUsedBytes": 70360852,
"domNodes": -280,
"jsHeapTotalBytes": 6647808,
"scriptDurationMs": 1074.792,
"eventListeners": -150,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 3734.3980000000556,
"styleRecalcs": 64,
"styleRecalcDurationMs": 13.582,
"layouts": 60,
"layoutDurationMs": 7.601,
"taskDurationMs": 1993.944,
"heapDeltaBytes": 1043360,
"heapUsedBytes": 75656680,
"domNodes": -281,
"jsHeapTotalBytes": 6385664,
"scriptDurationMs": 1074.659,
"eventListeners": -150,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 2087.02999999997,
"styleRecalcs": 8,
"styleRecalcDurationMs": 6.134,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 832.3610000000001,
"heapDeltaBytes": 4317460,
"heapUsedBytes": 77538504,
"domNodes": -274,
"jsHeapTotalBytes": 2977792,
"scriptDurationMs": 264.312,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 2044.7470000000294,
"styleRecalcs": 7,
"styleRecalcDurationMs": 5.877000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 810.3629999999999,
"heapDeltaBytes": -10303968,
"heapUsedBytes": 62850968,
"domNodes": -277,
"jsHeapTotalBytes": 3764224,
"scriptDurationMs": 233.043,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 606.77000000004,
"styleRecalcs": 48,
"styleRecalcDurationMs": 14.002999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 428.69700000000006,
"heapDeltaBytes": -10236716,
"heapUsedBytes": 59213364,
"domNodes": 22,
"jsHeapTotalBytes": 20574208,
"scriptDurationMs": 146.147,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 613.0339999999705,
"styleRecalcs": 48,
"styleRecalcDurationMs": 10.742,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 412.606,
"heapDeltaBytes": -10673584,
"heapUsedBytes": 58283240,
"domNodes": 22,
"jsHeapTotalBytes": 21622784,
"scriptDurationMs": 136.704,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-idle",
"durationMs": 1994.956000000002,
"styleRecalcs": 10,
"styleRecalcDurationMs": 7.250000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 494.029,
"heapDeltaBytes": -21527956,
"heapUsedBytes": 47620896,
"domNodes": -274,
"jsHeapTotalBytes": 19128320,
"scriptDurationMs": 14.617,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-idle",
"durationMs": 2029.1320000000042,
"styleRecalcs": 10,
"styleRecalcDurationMs": 7.874999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 495.84000000000003,
"heapDeltaBytes": -23206716,
"heapUsedBytes": 45901524,
"domNodes": -272,
"jsHeapTotalBytes": 19652608,
"scriptDurationMs": 15.263,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1725.8649999999989,
"styleRecalcs": 75,
"styleRecalcDurationMs": 33.196999999999996,
"layouts": 16,
"layoutDurationMs": 4.258,
"taskDurationMs": 784.32,
"heapDeltaBytes": -21532640,
"heapUsedBytes": 47413356,
"domNodes": -272,
"jsHeapTotalBytes": 19652608,
"scriptDurationMs": 100.64099999999999,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1714.8440000000846,
"styleRecalcs": 76,
"styleRecalcDurationMs": 33.263,
"layouts": 16,
"layoutDurationMs": 4.308,
"taskDurationMs": 770.561,
"heapDeltaBytes": -19321212,
"heapUsedBytes": 49698040,
"domNodes": -273,
"jsHeapTotalBytes": 19652608,
"scriptDurationMs": 102.752,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-transition-enter",
"durationMs": 1334.6900000000232,
"styleRecalcs": 9,
"styleRecalcDurationMs": 23.92699999999999,
"layouts": 6,
"layoutDurationMs": 9.231,
"taskDurationMs": 842.3720000000001,
"heapDeltaBytes": 7052296,
"heapUsedBytes": 97850364,
"domNodes": 13671,
"jsHeapTotalBytes": 11010048,
"scriptDurationMs": 40.329000000000015,
"eventListeners": 2383,
"totalBlockingTimeMs": 112,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 8359.267999999985,
"styleRecalcs": 250,
"styleRecalcDurationMs": 38.131,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 6006.821,
"heapDeltaBytes": 3398604,
"heapUsedBytes": 74933160,
"domNodes": -277,
"jsHeapTotalBytes": 4202496,
"scriptDurationMs": 3117.628,
"eventListeners": -130,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 8416.094000000045,
"styleRecalcs": 250,
"styleRecalcDurationMs": 38.348,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 6109.884,
"heapDeltaBytes": -3138792,
"heapUsedBytes": 67710700,
"domNodes": -274,
"jsHeapTotalBytes": 5251072,
"scriptDurationMs": 3160.492,
"eventListeners": -132,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 17658.61799999999,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 17640.049000000003,
"heapDeltaBytes": -12899656,
"heapUsedBytes": 183554900,
"domNodes": -6548,
"jsHeapTotalBytes": 1634304,
"scriptDurationMs": 948.007,
"eventListeners": -7469,
"totalBlockingTimeMs": 0,
"frameDurationMs": 18.333333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-large-graph-idle",
"durationMs": 17532.277000000024,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 17517.124,
"heapDeltaBytes": -18935164,
"heapUsedBytes": 178859188,
"domNodes": -6548,
"jsHeapTotalBytes": 2682880,
"scriptDurationMs": 969.706,
"eventListeners": -7469,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.779999999999927,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 22142.91799999995,
"styleRecalcs": 159,
"styleRecalcDurationMs": 21.818999999999978,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 22122.981000000003,
"heapDeltaBytes": -35407200,
"heapUsedBytes": 157265952,
"domNodes": -6548,
"jsHeapTotalBytes": -987136,
"scriptDurationMs": 1470.2740000000001,
"eventListeners": -7467,
"totalBlockingTimeMs": 521,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 21564.682999999946,
"styleRecalcs": 156,
"styleRecalcDurationMs": 20.416000000000018,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 21543.446,
"heapDeltaBytes": -38294568,
"heapUsedBytes": 157141616,
"domNodes": -6548,
"jsHeapTotalBytes": 323584,
"scriptDurationMs": 1446.1960000000001,
"eventListeners": -7465,
"totalBlockingTimeMs": 568,
"frameDurationMs": 18.333333333333332,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "workflow-execution",
"durationMs": 467.44599999999537,
"styleRecalcs": 20,
"styleRecalcDurationMs": 22.967000000000002,
"layouts": 4,
"layoutDurationMs": 1.637,
"taskDurationMs": 136.687,
"heapDeltaBytes": -15392096,
"heapUsedBytes": 52531896,
"domNodes": 154,
"jsHeapTotalBytes": 6942720,
"scriptDurationMs": 13.753,
"eventListeners": 67,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "workflow-execution",
"durationMs": 466.1900000000969,
"styleRecalcs": 13,
"styleRecalcDurationMs": 18.881,
"layouts": 3,
"layoutDurationMs": 0.5940000000000001,
"taskDurationMs": 112.893,
"heapDeltaBytes": -15901816,
"heapUsedBytes": 51779752,
"domNodes": 117,
"jsHeapTotalBytes": 7204864,
"scriptDurationMs": 9.496,
"eventListeners": 65,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
}
]
} |
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## feature/ecs-migration #14110 +/- ##
=======================================================
Coverage 79.22% 79.22%
=======================================================
Files 1764 1765 +1
Lines 103132 102997 -135
Branches 33462 34171 +709
=======================================================
- Hits 81703 81601 -102
+ Misses 20957 20924 -33
Partials 472 472
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
ecfbb0f to
18ada3a
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
a842338 to
64d12b6
Compare
6fdc295 to
19e2281
Compare
LGraphNode.move() returned early in Vue nodes mode, so the Positionable contract silently depended on which renderer was active: dragging a group moved its child nodes via LGraphGroup.move -> item.move, which did nothing for nodes. Three call sites worked around that by reimplementing the same arithmetic: - moveChildNodesInGroupVueMode + calculateNewPosition, used by the canvas drag and auto-pan paths, computed pos + delta and called setPos - the paste path branched on item type, calling setPos for nodes and move() for reroutes and groups All three are the same operation. The pos setter has committed to layoutMutations since Phase 2, so move() reaches the layout store on its own and the workaround no longer buys anything: setPos(pos + delta) and move(delta) are now the same two writes in the same order. Drops the mode branch and the two helpers; the drag, auto-pan and paste sites each become one item.move(delta) loop. Pinned items were already filtered by getDraggedItems, so selection behaviour is unchanged. Verified: litegraph, layout, graph-composable and vueNodes-layout unit suites (1369 tests); Vue group drag e2e including nested groups and the ctrl/meta no-drag-contents cases; group paste offset. Nine local screenshot failures in groups/copyPaste are pre-existing and identical before and after.
ensureCorrectLayoutScale wrote geometry element-wise (`node.pos[0] = x`). Element writes reach `_pos` directly, so positions never got to the layout store; sizes did, but only by accident, because `size` returns a Proxy whose set trap commits. The snap pass ran after the writes, so snapped positions were dropped on the floor as well, and reroutes lost their snap entirely — `reroute.pos = [...]` committed, then snapPoint mutated the array in place behind the setter. syncLayoutStoreNodeBoundsFromGraph existed to paper over exactly this: a bulk re-push of every root node's bounds, run only when the normalizer had touched the graph. Snap the unprojected values first, then assign once through `pos` and `size`. Every write now takes the same path the rest of the app uses, so the bulk re-push is redundant and goes away with its test. It was also narrower than what it patched: it covered `rootGraph` only, while the normalizer runs over the root graph and every loaded subgraph. Folds the module-level unprojectPosSize helper into one local `normalize`, dropping its copy of the snap logic; nodes, groups and subgraph IO nodes all use it now instead of two near-identical bodies. The group in-place test built its fixture from a bare object literal, which has no setters and so could not model the contract it was asserting — real `pos` and `size` write through to a shared Rectangle buffer. It now uses a real LGraphGroup and reads back through the captured array. Verified: layout, vueNodes-layout and litegraph unit suites (1231 tests); knip; Vue groups e2e including "keep groups aligned after loading legacy Vue workflows"; subgraph draft-position and navigation e2e. Four local failures across those specs are pre-existing and reproduce on a clean tree.
Groups were the last positionable outside the layout store: LGraphGroup._bounding was the only copy, so group geometry never entered the CRDT and could not be read from the store the way node geometry can. Store side, kept deliberately small. `GroupLayout` is id, position and size — no zIndex and no spatial index, because groups draw beneath nodes in insertion order and the canvas hit-tests them against their own bounds, so nothing queries them positionally. Geometry is one `setGroupBounds` operation rather than separate move and resize: a group's pos and size are two views onto one Rectangle, so writing the whole rectangle means the halves can never be stored apart. Reactivity is the version bump alone — there are no per-group refs because there is no Vue group component to hold one. LGraphGroup had seven ways to write geometry, three of which duplicated or bypassed the clamping: - `resize` re-implemented the `size` setter's min-width/height clamping - `resizeTo` wrote all four components element-wise, bypassing both setters - `snapToGrid` handed `this.pos` to snapPoint, which mutated it behind the setter - `configure` wrote `_bounding` directly All of them now funnel through one protected `setBounds`, which writes the rectangle and commits it. The public setters clamp and delegate; `resizeTo` and `configure` use it directly to keep their existing unclamped behaviour — a group fitted to its contents may still be narrower than minWidth, as before. Entries are created and destroyed at the LGraph chokepoints that already own group membership: `add`, `remove`, and `clear`. `clear` deletes per group rather than clearing a bucket, because group ids come from the root graph's shared `state` and subgraphs share it — the same reason a flat store map is safe here. `clear` skips the store entirely when there are no groups, so constructing an LGraph no longer touches it. The minimap's layout-store source now reads group geometry from the store while taking membership from the viewed graph, mirroring how it already handles nodes. The legacy source still reads groups off the graph. Verified: full unit suite (13693 passing; the two failures are the known onboardingCloudRoutes and previewAny load-timeouts, both green in isolation); typecheck; lint; knip. E2E: Vue groups, group copy/paste, groupSelectChildren and changeTracker. Nine local failures across those specs are pre-existing — each one re-run against a stashed tree to confirm.
useNodeDrag ran two idioms for one gesture. Nodes were positioned absolutely from a drag-start snapshot, while groups and reroutes were nudged by a per-frame delta, which needed `lastCanvasDelta` bookkeeping to derive that delta and a second code path in the auto-pan handler — nodes had their start positions shifted by the pan, groups were moved by it immediately. Non-node positionables now get the same treatment: their start positions are snapshotted alongside the nodes' and every frame recomputes an absolute target. `pos` is readonly on Positionable, so the target is reached through move(), which is also what keeps the pinned guard and, since groups landed in layoutStore, what commits their geometry. Both branches of updateNodePositions now say the same thing, auto-pan shifts one set of start positions, and `lastCanvasDelta` is gone. Re-deriving from the start each frame is also self-correcting: a dropped frame cannot leave an item behind and per-frame deltas cannot accumulate error. Drops a redundant pinned check I had added in the loop — LGraphGroup.move already enforces it, and duplicating it there would have made the test for it tautological. The test file's litegraph mock exported isLGraphGroup, which this composable never calls; it went unnoticed because selectedItems was always empty, so the predicate never ran. Corrected to isLGraphNode, and three tests cover the new path: a selected group tracks the drag offset, a pinned one does not move, and auto-pan carries non-nodes along. Verified: full unit suite (13696 passing; the two failures are the known onboardingCloudRoutes and previewAny load-timeouts); typecheck, lint, knip. E2E: "dragging a node moves all selected items" — which asserts graph.groups[0].pos after a node drag, exactly this path — plus Vue groups and groupSelectChildren. Eight local failures across those specs are pre-existing, each re-run against a stashed tree to confirm.
Unpacking a subgraph adds each inner group to the root graph, configures it,
then shifts it by the wrapper's position. That shift was element-wise, which
reaches _pos but not the layout store — harmless while groups lived only on
the class, wrong now that they are stored. The store kept the pre-offset
position, so in Vue nodes mode the minimap drew unpacked groups at their
inner-graph coordinates while the canvas drew them correctly.
Whole-value assignment through the `pos` setter instead. Not move(), which
would skip pinned groups and leave them un-offset.
The regression test fails without the fix with the store holding {x:10,y:20}
against a class position of {x:100,y:75}.
Element writes reach the backing Rectangle but not the layout store, so every one of these was either already dropping a write or relying on the `size` Proxy to catch it. Whole-value assignment goes through the setters, which is the one path that commits. Two were live gaps. groupNode's unpack shifted nodes already attached to the graph, so the store kept their pre-shift positions. SubgraphIONodeBase.move never reached any store at all. The rest were latent: vintageClipboard offsets a node before `graph.add`, so seeding covered it; widgetInputs and dynamicWidgets write `size`, which the Proxy catches. Converting them removes the dependence on that Proxy — it exists to catch this idiom, and every in-repo caller that stops using the idiom narrows what it has to cover to genuine third-party code. widgetInputs' pair of `if (a < b) a = b` guards collapse into one Math.max assignment, which is what they were spelling out. No element-wise geometry writes remain in src outside the layoutStore -> class writeback in useLayoutSync.
Reroute position was in three places: `posInternal` on the class, `position` in the Yjs map, and `position` again on the RerouteLayout used for hit testing. Three writers kept them in step by hand, and they disagreed about how: - `move()` wrote posInternal then committed - `snapToGrid()` mutated the array through the getter, then committed - the `pos` setter wrote posInternal and committed nothing at all That last one is why normalising a legacy workflow never moved a reroute in the store — `ensureCorrectLayoutScale` assigns `reroute.pos`, which silently went no further than the class. My earlier commit describing that path said the setter committed and the snap was lost behind it; the setter never committed at all. posInternal is gone. `pos` reads the stored point and the setter commits; `move` and `snapToGrid` compute a target and assign it, so all three paths are one write. `boundingRect`, `hoverArea` and the spline maths read the stored point directly rather than allocating through `pos`. A reroute now registers its geometry in its own constructor, which is what makes the store safe to read unconditionally. Two seeding sites become redundant and go: `LGraph.createReroute`'s explicit createReroute call, and the loop in useVueNodeLifecycle that existed because "deserialised reroutes bypass createReroute" — they no longer bypass anything. `moveReroute`'s previousPosition is now optional and defaults to the stored point, since no caller had a better answer than the store itself. The read-through is verified by moving a reroute in the store alone and reading it back off the class — a mirrored copy could not see that without a synchronisation step. E2E: "Floating reroutes", which drags by coordinate onto a reroute, so hit testing resolves against the stored position.
…t doing so
snapPoint mutates its argument in place, and `pos` hands out the backing array,
so `snapPoint(this.pos, snapTo)` never reached the layout store. LGraph.configure
already knew: it re-assigned `node.pos = [node.pos[0], node.pos[1]]` after
snapping, with a comment explaining that snapToGrid bypasses the setter. Three
other call sites had no such workaround — LGraph.add, LGraph.snapToGrid over a
selection (the drag-end path), and alignToGrid — so in Vue nodes mode the store
kept the pre-snap position and the next writeback flush could undo the snap on
screen.
LGraphNode.snapToGrid and SubgraphIONodeBase.snapToGrid now snap a copy and
assign it, so every caller commits and the workaround is deleted. The size snap
beside it stops relying on the `size` Proxy for the same reason.
Also converts SubgraphIONodeBase.arrange, which sized itself with `size[0] =`
through a destructured local. My earlier claim that no element-wise geometry
writes remained was wrong: it was based on a pattern that only matched writes
through `this`, and missed both the destructured-local form and anything routed
through a helper like snapPoint.
The regression test seeds a layout entry the way the renderer does, then snaps:
without the fix the store holds {x:103,y:97} against a class position of
{x:100,y:100}.
Completes the helper-routed half of the element-write sweep. alignToContainer and alignOutsideContainer mutate the rectangle handed to them, so passing a node's live geometry writes straight past the setters: - `alignToContainer(subgraphNode._posSize, ...)` reached into the backing Rectangle from outside the class entirely. Harmless today only because the node is not yet attached when it runs, so add-time seeding captures the result — the same accident that made the following setPos look like a title correction rather than the thing that commits the position. - `alignOutsideContainer(inputRect, ...)` mutates each subgraph IO node's own boundingRect. Both helpers write only the position components, so aligning a copy and assigning through `pos` is exactly equivalent. The centring and the title-height correction now happen in one assignment instead of a mutate-then-reassign pair, and the two IO node calls collapse into one loop. `_posSize` is no longer touched outside LGraphNode.
repositionNodesVueMode was misnamed and redundant at once: it worked in both render modes, because setPos commits regardless, and its body was a single call to a private applyNodePositionUpdates with the same signature. Collapsed into one public applyNodePositions. Six call sites — align, distribute and three clone paths in LGraphCanvas, plus useNodeArrangement — updated. The "setPos automatically syncs to layout store" comment goes with it; that is what the setter is for and no longer worth restating here.
The draft expected this phase to add a compatibility shim. It mostly deleted them: every entity now has one write path, and the workarounds that existed because writes bypassed it are gone. Records the three forms element-wise writes took and why the helper-routed one was the expensive one to miss, what groups and reroutes look like in the store, and why the store -> legacy writeback stays — serialize() and the canvas renderer read the class, and ~231 element-indexed reads depend on pos/size being views onto one buffer. Notes that the re-entrancy the draft worried about did not materialise, since the writeback compares before writing. Lists the three things left, each needing a decision rather than more inference, and keeps the original draft below for the record.
Stage 1 of removing useLayoutSync. The store now holds each node's `Rectangle` by reference — the very buffer whose `pos` and `size` subarrays back LGraphNode._pos and _size — and reads geometry from it. Class and store are the same memory, so there is no longer a direction to reconcile. Three facts made this cheaper than the two-copy shape suggested: - `getNodeLayoutRef().value` already built a fresh NodeLayout on every read, so no consumer held one expecting it to mutate. Changing what backs it breaks no contract. - `bounds` was position and size copied verbatim, so it is derived now rather than stored. - `Rectangle` already exposes pos and size as subarray views over one buffer, which is the facade shape the class needs. Every read path goes through one `nodeLayoutFor`, including the whole-map walks in getNodesInBounds, getAllNodes and the z-ordered read, so a single lookup and a map walk cannot disagree. Yjs stays a projection, written on commit. That is a serialization boundary rather than a peer mirror: local edits flow one way into it, and the inbound direction only matters for remote CRDT updates, which nothing wires up today. useLayoutSync still runs. Its writeback should now be inert, since it compares before writing and the values it would copy are already the same object — confirming that, then deleting it, is stage 3. Known gap, deliberately not papered over: the spatial index is a derived copy that a raw buffer write does not reach. Writes committed through layoutMutations still update it. The test says so rather than asserting a pass that would come from stale index data.
…ction
Stage 1 moved node geometry reads onto the registered Rectangle but left every
mutation writing only the Yjs projection, so anything committed through
layoutMutations was invisible to the store's own reads: moveNode wrote y, the
read returned x. That breaks the Vue drag, resize and arrange paths — the store
reported the pre-move position no matter how far the node was dragged.
handleMoveNode, handleResizeNode and handleBatchUpdateBounds now write the
rectangle, which is the authority, before projecting into Yjs. handleCreateNode
deliberately does not: a create that disagrees with a registered rectangle
should lose to it rather than clobber newer geometry.
Caught by asking what the drag path does rather than trusting the suites — the
unit tests I added covered raw buffer writes only, and locally the plain
"moving nodes by dragging" e2e sits in the pre-existing-failure bucket, so it
could not discriminate. The new test drives moveNode and resizeNode through the
mutation API and fails on the committed code with {x:10,y:20} against
{x:500,y:600}.
Sharing the geometry buffer silently killed an extension callback. useLayoutSync fired node.onResize only when the store's size differed from the class's; with one buffer behind both, that comparison is never true, so Vue-driven resizes stopped calling it. useLoad3d chains onto node.onResize to re-lay-out its viewport, so a Load3D node resized in Vue nodes mode would have stopped responding. The change notification already carries the intent, so the resize is tracked from `operation.type` and the callback fires per flush regardless of whether any value moved. The existing tests could not catch this: they stub the store with geometry that differs from the node's, which is the one arrangement that no longer occurs. The new test sets them equal — the real case — and fails without the fix with onResize called 0 times. The value copy stays. It is inert for nodes registered by reference, but it still covers nodes that have no registered rectangle, and it is the path a remote CRDT update would arrive on.
Reverts 88d4e51 (store reads the class Rectangle), dfa3882 (commit mutations to that rectangle) and 7addc4b (fire onResize from the operation). Two reasons, either sufficient. It broke resize. CI E2E failed on five size and reflow tests — Vue node resizing, both runtime reflow cases, image preview and painter compact layout. Writing the whole four-tuple on commit meant a resize measurement's x and y were applied to the node's position, not just its size. More importantly it pointed the wrong way. Making the class Rectangle authoritative and Yjs a write-only projection puts component data back on the entity, which is the opposite of ECS: the Y.Doc should be the World that holds Position and Size, and the class should hold nothing. Fixing the resize break would have entrenched that. Two findings survive the revert and are worth keeping in mind: - Nothing replicates the Y.Doc. There is no y-websocket, y-webrtc or IndexeddbPersistence anywhere, and nothing outside the store reads getYDoc or encodeStateAsUpdate. The CRDT is local-only today. - Sharing a buffer between class and store turns divergence-detecting code silently inert. useLayoutSync fires node.onResize only when the store's size differs from the class's; with one buffer behind both, that is never true, and useLoad3d chains onto that callback. Whatever replaces the writeback has to fire from the operation's intent, not from a value diff.
Groundwork for making the Y.Doc authoritative for Position and Size. The node map held `position`, `size` and `bounds` as separate entries, with `bounds` being the other two copied verbatim and an updateNodeBounds helper existing only to keep them in step. Three writes per move, three chances to disagree. Now one `rect: [x, y, width, height]`. Position, size and bounds are views derived on read, so they cannot diverge, and the helper is deleted along with them. A whole-tuple replace is also the write a CRDT register wants, which matches the whole-value assignment discipline the rest of the branch adopted. Measured before choosing the shape, over 800k reads: | read path | ns/read | vs current | | ---------------------------------- | ------- | ---------- | | Float64Array subarray (current) | 4.2 | - | | Yjs, separate position/size fields | 19.9 | 4.7x | | Yjs, one rect field | 13.6 | 3.2x | | Yjs, one rect + cached Y.Map ref | 7.2 | 1.7x | Real read counts, instrumented over 60 frames: 7.3 per node per frame in Vue nodes mode, 44 in legacy — the canvas draws node bodies there, Vue draws them in the DOM. At 9.4ns of added cost per read that is 0.41% of a 16.7ms frame for 1000 Vue-mode nodes, 2.5% for legacy. No cached map reference, despite it being the fastest. It is a cache with an invalidation failure mode — a deleted node leaves a stale reference reading old values — and it buys 5.5ns/read, or 1.4% of a frame at 1000 legacy nodes. Not worth it. If large legacy graphs ever bite, the fix is fewer reads per frame, measured then. Benchmark and the read-count probe are in temp/scripts/geobench.ts.
Entity ids are only unique within a root graph, but `layoutStore` keys nodes, groups and reroutes in one flat map. `workflowService.insertWorkflow` builds a scratch `LGraph` from the workflow being inserted, and its ids start at 1 like the open workflow's — so configuring it moved the open workflow's nodes to the inserted coordinates, and the `graph.clear()` that follows deleted the open workflow's group layout. The node half reproduces on main; the group half arrived with group geometry moving into the store. Operations now carry the writer's root graph id and the store records which root graph created each entry, dropping operations aimed at a stranger's geometry. This is the collision-loser rule `registerNodeState` already applies for `nodeDataStore` and `unregisterRerouteChain` for `rerouteStore`; layout was the one entity store without it. Ownership is opt-in: callers already scoped to the viewed graph omit it, so the renderer's call sites are unchanged. Reroutes do not claim ownership yet — their constructor takes a `LinkNetwork`, not a graph, and no failing case needs it.
Replaces the per-entry ownership map from the previous commit. That tracked which root graph created every node, group and reroute entry, which needed a side map, a composite string key, a second switch over operation types kept in sync with the dispatch switch, and a prefix scan to clear one entity's keys. All of it existed to answer one question. The store holds the layout of one root graph — the open workflow — so it can just know which one that is. Operations from a different root graph are out of scope and ignored. One field, one comparison, and the entry bookkeeping goes away. Scope is bound where the workflow is opened: `addAfterConfigureHandler` runs after configure has assigned the graph's id, and is installed only on the app's root graph, so a graph built off to the side never claims it. The renderer rebinds on seeding, which covers subgraph navigation. Unset until a workflow opens, during which nothing is out of scope. I had reached for per-entry ownership because the sibling stores use a collision-loser rule, but they key their buckets by root graph and layout does not, so the rule was carrying weight the scope field carries for free. Scope is sticky, and the store is a module singleton, so the regression tests move to their own file where the binding cannot leak into tests that expect an unscoped store.
Amp-Thread-ID: https://ampcode.com/threads/T-019fb44b-a733-76a8-a6d9-6e5614cbf856 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/lib/litegraph/src/Reroute.store.test.ts (1)
378-399: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAssert independent expected positions, not
Reroute.posagainst the store.
Reroute.posis backed bylayoutStore, so comparing those two values only verifies that both reads share the same source. Assert the known literal coordinates for the store result andreroute.posseparately.Based on learnings: layout-store-backed geometry tests must avoid comparing a store value to
Reroute.posbecause that is self-referential.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/litegraph/src/Reroute.store.test.ts` around lines 378 - 399, The test “routes move and snapToGrid through the same stored point” must avoid self-referential validation because Reroute.pos reads from layoutStore. Assert the literal expected coordinates independently for the layoutStore result and reroute.pos after snapToGrid, preserving the existing move and snapping expectations.Source: Learnings
src/lib/litegraph/src/LGraph.ts (2)
1933-1933: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftUse serializable layout commands for all changed geometry writes.
These call sites directly mutate node/group geometry instead of routing changes through the layout command API.
src/lib/litegraph/src/LGraph.ts#L1933-L1933: replace the direct IO-node position assignment with the appropriate layout command.src/lib/litegraph/src/LGraph.ts#L2163-L2163: replace the direct group position assignment with a layout mutation.src/lib/litegraph/src/LGraph.ts#L2717-L2719: route snapped node-size updates through the layout mutation API.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/litegraph/src/LGraph.ts` at line 1933, Replace the direct geometry writes in LGraph.ts at lines 1933, 2163, and 2717-2719: use the layout command API for the IO-node position assignment, route the group position update through a layout mutation, and route snapped node-size changes through the same layout mutation API. Ensure all three updates remain serializable.Source: Coding guidelines
508-524: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftClear node layouts during graph teardown.
clear()drops groups and reroutes, but node positions and sizes still remain in the layout store. That can leave stale geometry behind after a root-graph reset and let reused node ids pick up old bounds. Delete each node layout in this path as well.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/litegraph/src/LGraph.ts` around lines 508 - 524, Extend the layout cleanup in LGraph.clear() to delete the layout entry for every node in each graph being cleared, alongside the existing group and reroute deletions. Use the root graph ID and each node’s ID with the existing layoutMutations API, preserving the current graphsToClear handling for root and subgraphs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/lib/litegraph/src/LGraph.ts`:
- Line 1933: Replace the direct geometry writes in LGraph.ts at lines 1933,
2163, and 2717-2719: use the layout command API for the IO-node position
assignment, route the group position update through a layout mutation, and route
snapped node-size changes through the same layout mutation API. Ensure all three
updates remain serializable.
- Around line 508-524: Extend the layout cleanup in LGraph.clear() to delete the
layout entry for every node in each graph being cleared, alongside the existing
group and reroute deletions. Use the root graph ID and each node’s ID with the
existing layoutMutations API, preserving the current graphsToClear handling for
root and subgraphs.
In `@src/lib/litegraph/src/Reroute.store.test.ts`:
- Around line 378-399: The test “routes move and snapToGrid through the same
stored point” must avoid self-referential validation because Reroute.pos reads
from layoutStore. Assert the literal expected coordinates independently for the
layoutStore result and reroute.pos after snapToGrid, preserving the existing
move and snapping expectations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: fb2d2b6e-3ebe-4341-be9e-c305844d259e
📒 Files selected for processing (2)
src/lib/litegraph/src/LGraph.tssrc/lib/litegraph/src/Reroute.store.test.ts
Amp-Thread-ID: https://ampcode.com/threads/T-019fb4a0-661f-70e8-ace2-c5f69c13d425 Co-authored-by: Amp <amp@ampcode.com>
christian-byrne
left a comment
There was a problem hiding this comment.
I'm reading this code now and also sent an agent at it. From the system diagram it seems perfect. Can you double check that this API is fully compatible with multiplayer (see https://app.notion.com/p/comfy-org/Offline-Edits-Initial-Mutations-Implementation-3a76d73d365080ad8d88ed7dc24885e0?showMoveTo=true&saveParent=true)?
christian-byrne
left a comment
There was a problem hiding this comment.
Reviewed the geometry centralization end to end, with most attention on the four areas you called out. The store redesign itself reads well: collapsing position/size/bounds into one rect is clearly right, createGeometryView committing on observed value change is strictly better than the allowlist in the _sizeProxy it replaces, and the Reflect.get(target, property, target) receiver choice is the correct one for proxying a Rectangle. I did not re-raise the three findings in your details block; I checked all three and they hold.
The findings below were each put through a cross-model refutation pass before posting, and several were dropped or narrowed there. Two things I would flag as worth resolving before this lands:
- Workflow insertion. Two normalizations that
LGraph.configureused to guarantee no longer run:realignInputLinkSlots, and the link-id stripping thatLGraphNode.clonedid implicitly. The first can miswire inputs on older workflows, the second feeds unrelatedLLinks toonConnectionsChangeduring insert. Both are inworkflowToClipboardItems. - Paste offset. Routing nodes through
move()picks up its pinned guard, so pinned nodes stop being repositioned on both Ctrl+V and Insert Workflow.
On scope, and take this as a suggestion rather than a request: the workflow-insertion work (workflowToClipboardItems.ts plus workflowService.ts, roughly 330 lines across 5 files) is fully separable. It imports only types/serialisation, calls _deserializeItems which is unchanged on the base branch, and touches layoutStore nowhere. The scratch-graph collision it fixes was surfaced by the layout work but does not depend on it. Splitting it out would give the two findings above their own review surface instead of sitting behind 2000 lines of geometry diff, and would leave this PR closer to the 300-line guidance in AGENTS.md.
Nothing here is a blocker on the geometry model itself, which I think is the right direction.
| } | ||
|
|
||
| function getLinks(graph: WorkflowGraph): SerialisableLLink[] { | ||
| if (graph.version !== 0.4) return graph.links ?? [] |
There was a problem hiding this comment.
issue: this drops realignInputLinkSlots, so inserted workflows can wire links to the wrong input slots.
The old path built a scratch LGraph and ran LGraph.configure, which ends with realignInputLinkSlots(...) at LGraph.ts:2750. Its docblock (linkDeduplication.ts:74-87) states the reason: node configure() overrides reorder serialized inputs in place to match the current node definition, invalidating the slot indices stored on links. After realignment LLink.target_slot reads the patched _state.targetSlot (LLink.ts:172-173), and _serializeItems copied links out of the live graph._links (LGraphCanvas.ts:4069-4073), so the old clipboard payload carried corrected indices.
The new path takes graph.links verbatim from the workflow JSON, and _deserializeItems connects with the raw index: outNode?.connect(info.origin_slot, inNode, info.target_slot, afterRerouteId) (LGraphCanvas.ts:4314-4318). node.configure(info) runs first at :4258 and reorders info.inputs in place, but nothing re-points info.target_slot, and connect() only resolves string slot names by name (LGraphNode.ts:2969-2987). realignInputLinkSlots has exactly one caller, LGraph.ts:2750.
Every ComfyUI node's configure override rewrites input order to definition order (src/services/litegraphService.ts:463, and :575 for subgraph nodes), so this bites whenever a workflow's serialized input order differs from the currently registered definition: older workflows, converted widget inputs appended at the end, or a node pack that reordered its inputs. Workflows whose order already matches are unaffected, and regular Ctrl+V is unaffected because _serializeItems reads already-realigned live links.
Options: call realignInputLinkSlots after the node loop in _deserializeItems, or keep _deserializeItems' clipboard contract intact and re-point target_slot here by matching link.id against node.inputs[i].link in the source JSON, which is the mapping realignInputLinkSlots already uses (linkDeduplication.ts:95-106).
There was a problem hiding this comment.
Fixed in 894756f, though not quite where you suggested. realignInputLinkSlots can't run after the node loop here: the clipboard path has no links in graph._links at that point, because connect() invents them afterwards with fresh ids. So the re-point happens on parsed.links between the two loops, keyed off the post-configure input order.
Regression test in workflowToClipboardItems.integration.test.ts ("re-points input links when configure reorders serialized inputs"). Before the fix the link landed on model instead of clip, which is a fun thing to silently do to someone's workflow.
| const graph = structuredClone(workflow) | ||
|
|
||
| return { | ||
| nodes: graph.nodes ?? [], |
There was a problem hiding this comment.
issue: passing raw workflow nodes carries the source workflow's link ids into a graph that has its own links with the same numeric ids.
Every existing ClipboardItems producer guarantees link-free node payloads: _serializeItems serializes item.clone()?.serialize() (LGraphCanvas.ts:4059), and LGraphNode.clone strips ids with input.link = null / links.length = 0 (LGraphNode.ts:1170-1181), after which the graph-less clone serializes to link: null / links: null (node/slotUtils.ts:58-66, :78-85).
graph.nodes ?? [] keeps inputs[i].link and outputs[i].links from the source workflow. In _deserializeItems, graph.add(node); node.configure(info) (LGraphCanvas.ts:4257-4258) reaches LGraphNode.configure, which resolves those ids against the target graph's map and fires callbacks: this.graph._links.get(toLinkId(serialisedLink)) then onConnectionsChange?.(INPUT, i, true, link, input) (LGraphNode.ts:1032-1037), and the same for outputs plus onOutputAdded?.(output) at :1045-1052. Link ids start at 1 in every workflow, so inserting into a non-empty canvas collides and the handler receives a real but unrelated LLink. The output branch also fires where it previously did not, since the old payload had links: null.
Insert does not enter app.configuringGraph (that flag is set only around LGraph.configure, app.ts:874-884), so the guards that protect other paths do not apply here. Shipped autogrow logic treats any non-null resolved link as a real connection (src/core/graph/widgets/dynamicWidgets.ts:582-601) and can grow inputs before the real links are created at :4290-4320; the later connect() fixes topology but cannot undo configure-time side effects. onConnectionsChange is listed in AGENTS.md as affecting 40+ custom node repos.
This is the same hazard already documented and guarded against at LGraph.ts:2140-2149: "Strip links from serialized data before configure to prevent onConnectionsChange from resolving subgraph-internal link IDs against the parent graph's link map (which may contain unrelated links with the same numeric IDs)." Mirroring that here (null out input.link, empty output.links on root and subgraph interiors) would close it.
There was a problem hiding this comment.
Fixed in 894756f. Links are now stripped in _deserializeItems via detachSerialisedLinks, mirroring the guard at LGraph.ts:2140 you cited — the one I evidently read, agreed with, and then declined to apply twelve hundred lines further down.
It couldn't go in workflowToClipboardItems as suggested: the realignInputLinkSlots fix in the sibling thread needs those ids to survive until after configure reorders the inputs, so both fixes share a call site. Test asserts onConnectionsChange never receives the destination graph's own pre-existing link.
| } else if (item instanceof LGraphGroup) { | ||
| item.move(dx, dy, true) | ||
| } | ||
| item.move(dx, dy, true) |
There was a problem hiding this comment.
issue: collapsing the offset loop to item.move() stops pinned nodes from being repositioned on paste and on Insert Workflow.
LGraphNode.move short-circuits on pinned (LGraphNode.ts:2216-2219). Pre-PR the node branch was item.setPos(item.pos[0] + dx, item.pos[1] + dy), added in 6cf0357b3e (#7993) so the offset would reach layoutStore; before that it was an unconditional item.pos[0] += dx. setPos has no pinned guard, so pinned nodes have been offset on paste for the entire history of this loop. The group branch using move(dx, dy, true) came separately from a96c61d2c2 (#9962).
flags.pinned round-trips through serialize/configure and node.configure(info) runs at :4258, before this loop, so a pasted node arrives already pinned. Result: copy a selection containing a pinned node and Ctrl+V, and the pinned node is recreated stacked on the original while its unpinned siblings land at the cursor. Since workflowService.ts:546-548 now calls _deserializeItems directly, this is also the only path for Insert Workflow, so inserting a workflow with pinned nodes drops them at their saved absolute coordinates instead of the drop point.
Repositioning on paste is not a user drag and arguably should not respect the pin. Keeping the node branch on an absolute write would preserve both properties, since setPos now commits through the pos setter anyway:
for (const item of created) {
if (item instanceof LGraphNode) item.setPos(item.pos[0] + dx, item.pos[1] + dy)
else item.move(dx, dy, true)
}There was a problem hiding this comment.
Fixed in 894756f, your diff verbatim.
New e2e in copyPaste.spec.ts pins a KSampler, copies, pastes, and asserts the copy isn't where the original is. Without the fix it fails identically on repeat runs: Expected: not {"x": 863, "y": 186}. So the pasted node was not merely near the original, it was exactly on it — a bar we were, until today, failing.
| group.configure(g_info) | ||
| group.pos[0] += offsetX | ||
| group.pos[1] += offsetY | ||
| group.pos = [group.pos[0] + offsetX, group.pos[1] + offsetY] |
There was a problem hiding this comment.
issue: unpacking reuses the inner group's id, so two live LGraphGroup objects end up sharing one layout entry.
Reroutes are migrated to fresh ids a few hundred lines down (LGraph.ts:2301-2313), but groups keep g_info.id verbatim, and layoutStore keys groups only by (rootGraphId, groupId) (layoutStore.ts:78-88). deduplicateSubgraphGroupIds establishes root-wide uniqueness at load time but is not called on the unpack path.
this.remove(subgraphNode) does not run until :2240, and findReleasableSubgraphs deliberately retains a definition that still has another live instance (subgraphUtils.ts:538-545). So for a workflow with two SubgraphNode instances of one definition, unpacking one leaves the definition's group alive while creating a root group under the same key. Both objects then read and write the same entry through syncBoundsFromStore / setBounds (LGraphGroup.ts:139-168): moving one moves both, and removing either runs deleteGroup (LGraph.ts:1202) and wipes the other's only geometry.
The existing two-instance test (LGraph.test.ts:1384-1402) verifies definition retention but never gives the definition a group, so it does not catch this.
Allocating a fresh id would match how reroutes are handled, e.g. g_info.id = ++this.state.lastGroupId, or set group.id = -1 before this.add() and let add assign.
There was a problem hiding this comment.
Fixed in 894756f, allocating from rootGraph.state.lastGroupId rather than this.state — the layout keys are root-scoped and unpack can run inside a subgraph, so the local counter would just have moved the collision somewhere less obvious. (add()'s local allocation has the same gap; separate change.)
Extended the two-instance test you pointed at, exactly as advertised: it now gives the definition a group, moves the unpacked copy, and asserts the retained one stays where it was. Before the fix it followed along to [150, 125], which is not the collaborative spirit anyone asked for.
| layoutMutations.setSource(LayoutSource.Canvas) | ||
| for (const graph of graphsToClear) { | ||
| for (const group of graph._groups) { | ||
| layoutMutations.deleteGroup(rootGraphId, group.id) |
There was a problem hiding this comment.
issue: this teardown has no counterpart on the subgraph-definition release path, and once a definition is released nothing can reach its layout keys.
Registration is unconditional and root-scoped: the Reroute constructor always calls createReroute(this.rootGraphId, ...) (Reroute.ts:294-302) and LGraph.add always calls createGroup(this.rootGraph.id, ...) (:1100-1105), including for entities inside subgraph definitions. The release loop at LGraph.ts:1249-1259 unregisters link topologies, reroute chains and node states, then does this.rootGraph.subgraphs.delete(subgraph.id). It never calls deleteGroup / deleteReroute, and unregisterAllRerouteChains only touches useRerouteStore (Reroute.ts:863-878). Because the definition is now gone from rootGraph.subgraphs, the graphsToClear enumeration here can never reach it either.
Unpack makes the reroute half deterministic: :2240 removes the SubgraphNode, and the migrated reroutes get fresh ids at :2302-2315, so the old keys are orphaned rather than overwritten. A definition with 20 reroutes leaks 20 entries each time its last instance goes away, and each orphan stays in rerouteSpatialIndex as a hit-test candidate (the callers do re-resolve via graph.getReroute and fall back geometrically, so this is wasted work rather than a wrong selection, but it is unbounded within a session).
Groups are the narrower case: unpack reuses the group id, so that key is transferred to the new root group rather than orphaned. Groups leak when the last instance is deleted outright without unpacking.
The body needed is the same one already written here, so it may be worth factoring into a helper so the two cannot drift.
There was a problem hiding this comment.
Confirmed and deferring to a follow-up issue. The release loop really does skip deleteGroup/deleteReroute, and the definition is gone from rootGraph.subgraphs before clear() could reach it. Impact is narrower than filed, though: ids are made root-wide unique at load and lastRerouteId never decrements, so orphan keys can't be reoccupied by a live entity — it's roughly 4 KB per subgraph deletion with no correctness consequence.
One thing to carry into that follow-up, because it isn't visible from the diff: this.remove(subgraphNode) runs at LGraph.ts:2243, but the reroute migration loop reads reroute.pos at :2311, and Reroute.pos falls back to ORIGIN once the store entry is gone. Adding deleteReroute to the release loop without reordering that would drop every migrated reroute at the paste offset. Groups escape only because they're structuredCloned before the remove.
Also note the group half of your analysis is now stale — unpack allocates a fresh id at LGraph.ts:2162 as of 894756f. Skipping the shared helper: clear()'s version iterates multiple graphs and has a .some() fast path, so two dissimilar call sites would be sharing six lines.
| getNodeLayoutRef(nodeId: NodeId): Ref<NodeLayout | null> | ||
| getNodesInBounds(bounds: Bounds): ComputedRef<NodeId[]> | ||
| getAllNodes(): ComputedRef<ReadonlyMap<NodeId, NodeLayout>> | ||
| getAllGroups(graphId: UUID): ComputedRef<ReadonlyMap<GroupId, GroupLayout>> |
There was a problem hiding this comment.
suggestion: these graphId parameters are root-graph ids, and nothing in the name or type says so.
Every producer passes rootGraph.id, never the owning graph's id: LGraph.ts:1101, :1202, :1631, LGraphGroup.ts:142, Reroute.ts:294, LGraphCanvas.ts:2531, findRerouteAtPoint.ts:16, useSlotLinkInteraction.ts:143,251,279,490, LayoutStoreDataSource.ts:58. That is exactly why this PR needs deduplicateSubgraphGroupIds, whose own comment says the keys "share the root graph scope and therefore require root-wide IDs".
The failure mode for the next caller is quiet: passing graph.id for a subgraph builds a key that matches nothing, and all of these return null or empty rather than throwing. The PR's own test already writes layoutStore.getGroupLayout(graph.id!, 810) (ensureCorrectLayoutScale.test.ts:255) and passes only because that fixture happens to be a root graph.
Renaming the parameter to rootGraphId across types.ts / layoutStore.ts / layoutMutations.ts would be enough; a branded RootGraphId would make subgraph.id unpassable.
There was a problem hiding this comment.
Renamed in 0873ed0 across types.ts, layoutStore.ts and layoutMutations.ts. The argument that settled it is one you undersold: this PR introduces the parameter — at the merge base the API was getRerouteLayout(rerouteId) with no scope argument and the group APIs didn't exist — so there was no debt to defer, only a new name to get right the first time. Positional args, so no call-site churn.
Skipped the branded RootGraphId. It needs an application point at every producer and a cast in every fixture across 28 files, which is a lot of type-system apparatus to guard a mistake nobody has made yet. Also left the graphId field on the op payloads alone — that's the CRDT-ready shape and a separate decision.
| } | ||
|
|
||
| export interface ReadonlyLinkNetwork { | ||
| readonly rootGraph: { readonly id: UUID } |
There was a problem hiding this comment.
question: should this be optional, given Reroute dereferences it unguarded at construction?
ReadonlyLinkNetwork is exported via the litegraph barrel, and adding a required member narrows the contract for implementers rather than adding capability for consumers. Reroute.ts:294 then does this.rootGraphId = network.rootGraph.id with no guard, so external code that hands litegraph a structural network object without rootGraph now throws TypeError: Cannot read properties of undefined (reading 'id') at construction instead of failing at a type check.
All in-repo production callers pass this from LGraph/Subgraph and the direct-construction fixture supplies rootGraph explicitly (LinkConnector.core.test.ts:34-72), so nothing internal breaks today. createMockLinkNetwork (src/utils/__tests__/litegraphTestUtils.ts:199-204) returns { ...overrides } as LinkNetwork, so the cast will keep hiding the new member from the type checker if it is ever used this way.
Either network.rootGraph?.id with registration skipped when absent, or a named error at Reroute.ts:294 so the failure is diagnosable, would be an improvement over the anonymous undefined dereference.
There was a problem hiding this comment.
Not changing this. The premise doesn't hold: ReadonlyLinkNetwork is not exported from the litegraph barrel — litegraph.ts:95-108 exports LinkNetwork only, and it's absent from src/types/index.ts. It appears in three internal files. Reroute's constructor also takes LinkNetwork, not the readonly variant, so the hypothetical caller would have to hand-roll addFloatingLink, removeReroute, _removeReroute, removeFloatingLink and both getLink/getReroute overloads; the one object in the repo that does (LinkConnector.core.test.ts:34-72) already supplies rootGraph.
Both remedies also make things worse. network.rootGraph?.id means rootGraphId goes optional, the reroute never registers, storedPosition falls back to ORIGIN permanently and set pos silently discards — a loud TypeError traded for a reroute pinned at (0,0) with no error at all, and a hole in the invariant this PR exists to establish.
The adjacent hole is real though: createMockLinkNetwork still returns { ...overrides } as LinkNetwork, so the cast hides the member regardless. That's the ~4 lines worth doing, and it's already tracked on the CodeRabbit thread.
| parentId | ||
| ]) | ||
| ) | ||
| return graph.links.map( |
There was a problem hiding this comment.
issue: the 0.4 branch calls graph.links.map unguarded while the branch two lines up guards with graph.links ?? [].
workflowJSON is toRaw(loadedWorkflow.initialState), which is user-supplied JSON that does not pass through a zod schema on this path, so a 0.4 workflow with links absent or null throws TypeError: Cannot read properties of undefined (reading 'map') and the insert fails with no useful message. A null entry in the array would also throw on the destructure.
Same guard as line 30 would cover it.
Separately, and lower priority: getLinks and getReroutes re-implement litegraph's 0.4 decoding (positional link tuples, extra.linkExtensions, extra.reroutes) that LGraph.configure already does at LGraph.ts:2553-2575 via LLink.createFromArray. The schema is litegraph's, so a future version bump now has to be applied in two files in two layers, and getting it wrong here fails silently (an inserted workflow loses links while opening the same file works). Worth considering moving the version branching next to the existing decoder and keeping this as the thin platform-layer caller.
There was a problem hiding this comment.
Fixed in 894756f: (graph.links ?? []), i.e. the guard from eight lines up, applied a second time by someone who had clearly stopped paying attention halfway through the function. Test covers a 0.4 workflow with links absent.
The getLinks/getReroutes re-implementation of litegraph's 0.4 decoder is a fair point and untouched here — that one wants its own PR rather than a quiet ride along with five bug fixes.
| import { createGeometryView } from './createGeometryView' | ||
| import { Rectangle } from './Rectangle' | ||
|
|
||
| describe('createGeometryView', () => { |
There was a problem hiding this comment.
suggestion: since this file is the ecosystem compatibility boundary, it would be worth pinning the observable JS-value contract here.
The three tests cover indexed writes, set(), change suppression, synchronize-before-read and nested mapValue. None of them covers the properties an extension actually depends on, and those are where the behaviour changed: Array.isArray on the reroute view, length, JSON.stringify shape, [...] and {...} spread, instanceof, constructor identity, and structured-clone survivability. LGraphGroup.test.ts and Reroute.store.test.ts only exercise attached, registered entities, so the "attached but no store entry" path is untested too.
This is also the concrete half of the question at #14110 (comment) that is still open: useLayoutSync.ts:44 and LGraphNode.ts:1046 were both converted, but "basically every custom node" is answered by this shim rather than by a code change, and right now nothing pins what the shim guarantees. One table-driven test asserting the observable value contract would turn that from an argument into a regression gate.
There was a problem hiding this comment.
Partially. I ran all seven properties against both real view shapes (Float64Array for node pos/size, plain Array for Reroute.pos) before writing anything, and five of them — Array.isArray, length, JSON.stringify, spread, instanceof — are structurally unchangeable by this Proxy. No getPrototypeOf/ownKeys/has traps are defined, and Array.isArray pierces proxies per spec. Asserting those pins behaviour the code cannot vary, which is the change-detector testing AGENTS.md rules out.
The two that did change are the two you filed separately. constructor is now fixed and pinned by a test (0873ed0). structuredClone I've declined on the sibling thread for lack of any measurable consumer. Writing the table before resolving those would have locked a known regression in as intended behaviour.
Your secondary point — "attached but no store entry" being untested — was the sharper one, and it's covered now by the regression test for the setBounds bug.
| | ----------------------- | ----------------------------------- | ------------------------------ | ------------------------------------------------------------------ | ----------------------------- | | ||
| | WidgetValueStore | `BaseWidget` | `graphId` | `WidgetId` (`graphId:nodeId:name`) | Plain `WidgetState` object | | ||
| | DomWidgetStore | `BaseDOMWidget` | Global | `widgetId` (UUID) | Position, visibility, z-index | | ||
| | LayoutStore | Node, Link, Group, Reroute geometry | Root graph for groups/reroutes | Raw node/link IDs; `${rootGraphId}:${localId}` for groups/reroutes | Y.js CRDT maps (pos, size) | |
There was a problem hiding this comment.
suggestion: a few doc statements elsewhere now contradict the code this PR ships.
The summary row here is updated, but the sections below it and two other files still describe the pre-PR world:
proto-ecs-stores.md:337-338,:344,:396,:414-415still sayReroute.posInternalis the position truth and the store holds a partial mirror.posInternalis deleted.proto-ecs-stores.md:350-357,:375,:397,:416still list Group as "Extracted: (nothing)" / "no extraction started". Groups now haveGroupLayout,ygroups, andcreateGroup/setGroupBounds/deleteGroup.proto-ecs-stores.md:175still documentsynodesasnodeId -> { pos, size, zIndex, bounds }; the stored shape is now a singlerecttuple (mappers.ts:14-20). Theygroupsline right below it was updated.proto-ecs-stores.md:189-198"Write API" omitscreateGroup/setGroupBounds/deleteGroup.ecs-target-architecture.md:236-238still saysReroute.posInternalremains the source of truth.reroute-chain-store.md:114-117still saysReroute.pos"still mirrors" the store as a separate concern.ecs-migration-plan.md:473-476(added here) points atTODO(litegraph-stable-resize-api), but this PR deleted the only occurrence of that marker along with the hand-written size proxy. The same bullet says "ThesizeProxy" as if one exists, where there are now aposview plus three onLGraphGroup.reroute-chain-store.md:58-61: the edit removed the subject of the sentence, so it now reads "Today this is bucket would break on it."
Also worth considering: the new invariant that group ids must be root-wide unique is recorded only in a code comment in subgraphDeduplication.ts, and prior store migrations each got an ADR 0008 amendment plus a design record in the supporting-documents table.
There was a problem hiding this comment.
Done in 2a2514d: proto-ecs-stores.md (ynodes shape, group write API, both mermaid blocks, gap-analysis rows, priority order), ecs-target-architecture.md:237, and the ecs-migration-plan.md bullet that pointed at the deleted TODO(litegraph-stable-resize-api). Every line reference you gave checked out, and the doc set was contradicting itself — proto-ecs-stores.md called posInternal the truth while ecs-migration-plan.md in the same branch said it was deleted.
One bullet declined: reroute-chain-store.md:114-117. That file is a design record for #13449, not a current-state doc, and the convention for superseded records here is an appended **Update (date):** note — proto-ecs-stores.md:27,35,42 all do that — rather than rewriting the original scoping text. Happy to append a line if you'd rather it not read as current.
ADR 0008 amendment: agreed the precedent is real (three dated amendments plus the Supporting Documents table), deferring to a follow-up rather than growing this PR. Not inventing a new design-record doc to fill the table cell.
Insert Workflow feeds raw workflow JSON straight to _deserializeItems, which the clone-based clipboard path never did. Five defects follow: - Serialized link ids reached node.configure, resolving against the destination graph's link map and firing onConnectionsChange with real but unrelated links. Strip them first, as LGraph.configure already does. - configure() overrides reorder inputs to definition order, invalidating the serialized target_slot. Re-point links from the post-configure input order. - Pinned nodes were skipped by the paste offset loop, landing stacked on the original. Repositioning a paste is not a user drag. - Unpacking reused the definition's group id, so a retained definition and the unpacked copy shared one root-scoped layout entry. - A 0.4 workflow with no links threw on graph.links.map. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- LGraphGroup.setBounds wrote nothing when the group was attached but had no store entry, so pos/size/resize/move/snapToGrid/configure became silent no-ops. Write the local bounds first, then attempt the store. - createGeometryView wrapped constructor along with every other function value, so `x.constructor === Array` clone helpers took the wrong branch. - repositionNodesVueMode was removed with no shim despite being public and shipped; restore it as a deprecated alias for applyNodePositions. - LGraphGroup and SubgraphIONodeBase both returned true from snapToGrid unconditionally, while LGraphNode and Reroute mean "the position moved". - layoutStore and layoutMutations take root-graph ids; name them that way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
proto-ecs-stores and ecs-target-architecture still described posInternal as the position truth and Group as unextracted, contradicting ecs-migration-plan in the same branch. Also updates the ynodes shape to the single rect tuple, lists the group write API, and drops the deleted resize-API TODO reference. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
useLayoutMutations' createNode, moveNode and resizeNode gained a rootGraphId first parameter in #14110. nodeMoveBridge's test was the only caller on this branch and did not compile after the merge. The bridge itself needs no change — it subscribes through layoutStore.onChange, which is graph-agnostic, so the test supplies its own id the way layoutMutations.test.ts does. Note for the ECS branch, not caused by this merge: the four failing TransformPane tests fail identically on origin/feature/ecs-migration with this branch absent.
useLayoutMutations' createNode, moveNode and resizeNode gained a rootGraphId first parameter in #14110. nodeMoveBridge's test was the only caller on this branch and did not compile after the merge. The bridge itself needs no change — it subscribes through layoutStore.onChange, which is graph-agnostic, so the test supplies its own id the way layoutMutations.test.ts does. Note for the ECS branch, not caused by this merge: the four failing TransformPane tests fail identically on origin/feature/ecs-migration with this branch absent.
…Shell (#14257) **STACKED — merging lands on `feature/ecs-migration` (owned by @DrJKL, PR #13963's base), NOT `main`.** ## ELI-5 The code that wires a node's "shell state" (title, mode, colours, shape…) into the app's Pinia stores was living inside the vendored `src/lib/litegraph` folder, even though it is entirely app-owned. This moves those definitions into `src/core/graph/nodeShell/` and leaves one-line call sites behind in litegraph. Nothing changes at runtime — same functions, same order, same events. Fulfils the TODO committed to in #13963 (comment). cc @DrJKL ## What moved `src/core/graph/nodeShell/nodeShellState.ts` - `createNodeShellState(title, type, titleMode)` — the object literal that was inline in the `LGraphNode` constructor. - `setTrackedNodeState(node, property, value)` — the body of the former private `LGraphNode.setTrackedState`; the six accessors (`title`, `mode`, `color`, `bgcolor`, `showAdvanced`, `shape`) now call it. - `registerNodeState` / `unregisterNodeState` / `unregisterAllNodeStates` — moved verbatim. `src/core/graph/nodeShell/nodeShellLifecycle.ts` - `attachNodeToStores(graph, node)` — `registerNodeState` plus the widget `setNodeId` / `setNodeWidgetOrder` block that was inline in `LGraph.add`. `LGraph.add` is now a single call, in exactly the position `registerNodeState` occupied (after `node.graph = this`, before `_nodes.push` / `onAdded` / `node:added`). - `releaseGraphStores(graph)` — the store-teardown block from `LGraph.clear`. `LGraph.clear` is now a single call. Also: `LGraph.remove` imports `unregisterNodeState` / `unregisterAllNodeStates` from the new module, `LGraphNode.ts` no longer imports `useNodeDataStore`, and the litegraph barrel no longer re-exports `registerNodeState` / `unregisterNodeState` (new in #13963, nothing external can depend on them yet — keeping the surface private per review feedback). `useNodeReplacement` imports them from the new module instead. `fireNodeRemovalLifecycle` stays in `LGraph.ts` (litegraph events only, no store access), and the link/reroute helpers stay in `LLink.ts` / `Reroute.ts` — `releaseGraphStores` imports them from their current homes. ## Judgment calls - **Two files rather than one.** `nodeShellState.ts` holds the node-level definitions and imports only `nodeDataStore`; `nodeShellLifecycle.ts` holds the graph-level attach/release coordination and is the only one that reaches for `LLink` / `Reroute` / the other stores. That keeps `LGraphNode`'s new runtime import off the `Reroute → litegraph barrel → LGraphNode` cycle. A production `vite build` was run to confirm the module graph still resolves. - **Skipped the optional `graphTriggers.ts` move.** DrJKL's stack (#14110 → #14128 → #14133) is still open against this base, so the diff is kept to a strict definitions-move to keep those rebases cheap. Moving `graphTriggers.ts` would touch the barrel's export path and `LGraph.ts`'s import block for no functional gain in this pass. - **Tests.** The two registration/unregistration cases from `LGraphNode.nodeState.test.ts` moved to `src/core/graph/nodeShell/nodeShellState.test.ts` with assertions unchanged; the accessor and `configure` cases stay where they are. Two new cases cover `createNodeShellState`'s defaults. No test was deleted or weakened. `useNodeReplacement.test.ts`'s barrel mock split into a second `vi.mock` for the new module. ## Verification `pnpm typecheck`, `pnpm lint` (0 errors), `pnpm knip`, and `vite build` are clean. Targeted suites (litegraph, nodeShell, nodeDataStore, nodeReplacement, minimap) — 91 files / 1341 tests pass. Full `vitest run`: 14260 passed, 1 failed — `src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts > lazily resolves the /oauth layout and consent view components`, a 5s timeout on a dynamic route import. It passes in isolation, is untouched by this diff, and an earlier full run under load failed a different pair of tests, so it reads as a load-dependent flake rather than a regression. Flagging rather than hiding it. --------- Co-authored-by: Christian Byrne <cbyrne@comfy.org>
## Summary Still-draft feature branch for migrating entity state from LiteGraph objects and runtime mirrors into dedicated stores with derived, reactive views. This consolidates the reviewed ECS migration slices, strengthens their coverage, incorporates the layout-state follow-up, and documents the current migration status and remaining work. ## Changes - Move widget values and node shell state into dedicated stores. - Make link topology the source of truth for connectivity. - Store reroute chains while deriving membership and floating-link state. - Derive widgeted input connectivity, badges, and promoted widget rows from store-backed state. - Remove the input and output runtime link mirrors. - Keep DOM measurements separate from persisted node layout state. - Add migration coverage, extension guidance, and architecture/status documentation. Reviewed PRs merged into this feature branch: - [Comfy-Org#13322 — Move widgets out of node data](Comfy-Org#13322) - [Comfy-Org#13434 — Host-scoped promoted widget rows](Comfy-Org#13434) - [Comfy-Org#13436 — Link topology store](Comfy-Org#13436) - [Comfy-Org#13449 — Reroute chain store](Comfy-Org#13449) - [Comfy-Org#13451 — Derived floating links and reroute cleanup](Comfy-Org#13451) - [Comfy-Org#13455 — Store-backed widgeted input connectivity](Comfy-Org#13455) - [Comfy-Org#13458 — Badge store and system](Comfy-Org#13458) - [Comfy-Org#13479 — Remove the output-link runtime mirror](Comfy-Org#13479) - [Comfy-Org#13498 — Remove the input-link runtime mirror](Comfy-Org#13498) - [Comfy-Org#13528 — Cross-stack migration audit fixes](Comfy-Org#13528) - [Comfy-Org#13686 — Derive badges on read](Comfy-Org#13686) - [Comfy-Org#13963 — Node data store](Comfy-Org#13963) - [Comfy-Org#14110 — Centralize node, group, and reroute geometry](Comfy-Org#14110) - [Comfy-Org#14128 — Register node geometry at attach](Comfy-Org#14128) - [Comfy-Org#14133 — Read node geometry from the store](Comfy-Org#14133) - [Comfy-Org#14758 — Keep DOM measurements out of saved node sizes](Comfy-Org#14758) - [Comfy-Org#15001 — Extract entity ID allocation](Comfy-Org#15001) - [Comfy-Org#15009 — Scope link and reroute topology by owning graph](Comfy-Org#15009) - [Comfy-Org#15017 — Centralize layout ownership and command submission](Comfy-Org#15017) - [Comfy-Org#15018 — Preserve subgraph topology during unpack](Comfy-Org#15018) - [Comfy-Org#15019 — Transfer node ownership during replacement](Comfy-Org#15019) - [Comfy-Org#15330 — Map migration status and remaining work](Comfy-Org#15330) ## Review Focus - Store ownership and synchronization boundaries. - Serialization, undo/redo, subgraph, and extension compatibility. - Whether remaining direct entity state should migrate before this feature leaves draft. ## Status Still draft. The branch is rebased onto `main`; CI is running against the rebased history. --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Christian Byrne <cbyrne@comfy.org> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Matt Miller <mattmiller@comfy.org>
useLayoutMutations' createNode, moveNode and resizeNode gained a rootGraphId first parameter in #14110. nodeMoveBridge's test was the only caller on this branch and did not compile after the merge. The bridge itself needs no change — it subscribes through layoutStore.onChange, which is graph-agnostic, so the test supplies its own id the way layoutMutations.test.ts does. Note for the ECS branch, not caused by this merge: the four failing TransformPane tests fail identically on origin/feature/ecs-migration with this branch absent.
Summary
Centralizes node, group, and reroute geometry in
layoutStoreso moves, resizes, snapping, workflow insertion, and subgraph operations update one authoritative geometry path without colliding with live workflow state.Changes
layoutStore.LGraphNode.pos/size, group geometry, andReroute.posretain stable mutable array or rectangle identities through a shared geometry view. Indexed writes and mutating methods commit throughlayoutStore; whole-value assignment remains supported. The internalmoveChildNodesInGroupVueModeandrepositionNodesVueModehelpers are removed.Geometry before this PR
Rectangleplus separateposition,size, andboundsstore fieldsmove, direct element writes, mode-specific helpersLGraphGroup._boundingonlyresize,resizeTo,configure, andsnapToGridposInternal, Yjs position, andRerouteLayout.positionmove, setter, and in-place snapping each updated a different subsetLGraphconfigured before clipboard serializationGeometry with this PR
rectvalue inlayoutStore, with class geometry kept in sync for litegraphmoveproduce layout mutationsrectvalue inlayoutStoresetBoundsis the single internal writer; public geometry APIs delegate to itLGraph.add,remove, andclearregister or remove entries; minimap reads the storelayoutStore;Reroute.posexposes a stable synchronized viewmove, and snapping commit through layout mutationsposInternaland the duplicate hit-test position without breaking mutable point accessworkflowToClipboardItemsavoids constructing entitiesDownstream stack
useVueNodeLifecyclecomposable and the unused operation log.layoutStoreauthoritative for node reads through the shared geometry view's versioned projection, removesuseLayoutSync, and leaves only operation-driven resize notifications and canvas invalidation.This PR retains the current node-registration and Layout→LiteGraph synchronization boundaries. The downstream PRs change each boundary separately.
Review Focus
layoutStore, especially registration and cleanup for groups and reroutes.workflowToClipboardItemsdirectly; check parity with the previous scratch-graph serialization path.layoutStore,layoutMutations,createGeometryView,LGraphGroup,LGraphNode,Reroute, subgraph deduplication, then workflow conversion.Findings that a dumb agent might call out
These are plausible-looking review findings that do not survive inspection:
previous*fields breaks undo." Undo/redo uses serialized graph snapshots through the change tracker, not inverse layout operations. The removed fields had no consumers, and browser coverage exercises undo/redo across node, group, and reroute movement.Point,Size, andRectangleidentities, including element-wise and method-based mutation. Focused tests cover synchronization, read-through, and write-through behavior.