Repository navigation
refactor: register node geometry at attach, delete useVueNodeLifecycle - #14128
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:
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🎨 Storybook: ✅ Built — View Storybook🎭 Playwright: ✅ 1761 passed, 0 failed · 3 flaky📊 Browser Reports
📦 Bundle Size
⚡ Performance Report
Absolute values
Raw data{
"timestamp": "2026-08-05T19:54:29.749Z",
"gitSha": "d0b50c5f163126231fad02b9b46756385f0d740f",
"branch": "drjkl/layout-registration-at-attach",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2033.3550000000287,
"styleRecalcs": 9,
"styleRecalcDurationMs": 8.03,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 573.744,
"heapDeltaBytes": 4703988,
"heapUsedBytes": 74281116,
"domNodes": 18,
"jsHeapTotalBytes": 18739200,
"scriptDurationMs": 29.541999999999998,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-idle",
"durationMs": 2025.3220000000738,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.987000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 560.9110000000001,
"heapDeltaBytes": 4767120,
"heapUsedBytes": 74404508,
"domNodes": 16,
"jsHeapTotalBytes": 19001344,
"scriptDurationMs": 29.765,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 2041.6349999999852,
"styleRecalcs": 79,
"styleRecalcDurationMs": 51.008,
"layouts": 12,
"layoutDurationMs": 4.063,
"taskDurationMs": 1053.746,
"heapDeltaBytes": -19882124,
"heapUsedBytes": 49586504,
"domNodes": -275,
"jsHeapTotalBytes": 19914752,
"scriptDurationMs": 201.041,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1957.5940000000855,
"styleRecalcs": 78,
"styleRecalcDurationMs": 41.812999999999995,
"layouts": 12,
"layoutDurationMs": 3.522,
"taskDurationMs": 966.6049999999999,
"heapDeltaBytes": -15778128,
"heapUsedBytes": 53899428,
"domNodes": -275,
"jsHeapTotalBytes": 19914752,
"scriptDurationMs": 181.305,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1755.4209999999557,
"styleRecalcs": 31,
"styleRecalcDurationMs": 19.680999999999997,
"layouts": 6,
"layoutDurationMs": 0.722,
"taskDurationMs": 431.75300000000004,
"heapDeltaBytes": 7709588,
"heapUsedBytes": 77183092,
"domNodes": 77,
"jsHeapTotalBytes": 19525632,
"scriptDurationMs": 31.453000000000003,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1735.0669999999582,
"styleRecalcs": 30,
"styleRecalcDurationMs": 17.209999999999997,
"layouts": 6,
"layoutDurationMs": 0.5820000000000001,
"taskDurationMs": 414.36899999999997,
"heapDeltaBytes": 7730752,
"heapUsedBytes": 77362140,
"domNodes": 76,
"jsHeapTotalBytes": 18739200,
"scriptDurationMs": 29.069,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "dom-widget-clipping",
"durationMs": 629.4149999999945,
"styleRecalcs": 12,
"styleRecalcDurationMs": 8.765,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 428.557,
"heapDeltaBytes": -10170156,
"heapUsedBytes": 59460652,
"domNodes": 20,
"jsHeapTotalBytes": 20312064,
"scriptDurationMs": 91.362,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "dom-widget-clipping",
"durationMs": 602.6770000000852,
"styleRecalcs": 9,
"styleRecalcDurationMs": 6.507999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 404.57699999999994,
"heapDeltaBytes": -9881752,
"heapUsedBytes": 59836036,
"domNodes": 14,
"jsHeapTotalBytes": 19787776,
"scriptDurationMs": 89.587,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2050.7939999999962,
"styleRecalcs": 7,
"styleRecalcDurationMs": 6.582999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 933.3530000000001,
"heapDeltaBytes": -10722860,
"heapUsedBytes": 68866732,
"domNodes": -277,
"jsHeapTotalBytes": 3325952,
"scriptDurationMs": 276.777,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "large-graph-idle",
"durationMs": 2059.6680000001015,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.4959999999999996,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 990.471,
"heapDeltaBytes": -9543064,
"heapUsedBytes": 69816580,
"domNodes": -274,
"jsHeapTotalBytes": 3325952,
"scriptDurationMs": 291.24899999999997,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 2773.5159999999723,
"styleRecalcs": 68,
"styleRecalcDurationMs": 11.834999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1946.8529999999998,
"heapDeltaBytes": -895416,
"heapUsedBytes": 79375232,
"domNodes": -278,
"jsHeapTotalBytes": 4055040,
"scriptDurationMs": 1080.186,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 3162.1200000000727,
"styleRecalcs": 68,
"styleRecalcDurationMs": 13.050000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2135.3940000000002,
"heapDeltaBytes": -1216704,
"heapUsedBytes": 79835044,
"domNodes": -279,
"jsHeapTotalBytes": 4317184,
"scriptDurationMs": 1193.913,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666696,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-zoom",
"durationMs": 4046.228000000042,
"styleRecalcs": 63,
"styleRecalcDurationMs": 13.193000000000003,
"layouts": 60,
"layoutDurationMs": 7.5840000000000005,
"taskDurationMs": 2221.9790000000003,
"heapDeltaBytes": 5383696,
"heapUsedBytes": 65768156,
"domNodes": -282,
"jsHeapTotalBytes": 3469312,
"scriptDurationMs": 1213.8960000000002,
"eventListeners": -150,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 4211.329999999975,
"styleRecalcs": 63,
"styleRecalcDurationMs": 13.561000000000003,
"layouts": 60,
"layoutDurationMs": 7.595,
"taskDurationMs": 2290.7249999999995,
"heapDeltaBytes": 16707520,
"heapUsedBytes": 77833916,
"domNodes": -283,
"jsHeapTotalBytes": 2420736,
"scriptDurationMs": 1258.4279999999999,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "legacy-node-drag",
"durationMs": 4391.434000000004,
"styleRecalcs": 44,
"styleRecalcDurationMs": 8.322000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3320.7210000000005,
"heapDeltaBytes": 15713348,
"heapUsedBytes": 77779308,
"domNodes": -283,
"jsHeapTotalBytes": 8855552,
"scriptDurationMs": 1296.0130000000001,
"eventListeners": -96,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "legacy-node-drag",
"durationMs": 4427.074999999945,
"styleRecalcs": 44,
"styleRecalcDurationMs": 7.972999999999997,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3328.101,
"heapDeltaBytes": 27231864,
"heapUsedBytes": 88937480,
"domNodes": 6,
"jsHeapTotalBytes": 11939840,
"scriptDurationMs": 1283.477,
"eventListeners": 190,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 2023.5000000000127,
"styleRecalcs": 6,
"styleRecalcDurationMs": 5.340999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 873.619,
"heapDeltaBytes": 7551616,
"heapUsedBytes": 68351980,
"domNodes": -276,
"jsHeapTotalBytes": 323584,
"scriptDurationMs": 267.915,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "minimap-idle",
"durationMs": 2043.8669999999775,
"styleRecalcs": 6,
"styleRecalcDurationMs": 5.637000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 887.9140000000001,
"heapDeltaBytes": 18479952,
"heapUsedBytes": 79721500,
"domNodes": -277,
"jsHeapTotalBytes": -1511424,
"scriptDurationMs": 271.607,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 658.4789999999998,
"styleRecalcs": 47,
"styleRecalcDurationMs": 12.238999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 450.875,
"heapDeltaBytes": -10079612,
"heapUsedBytes": 59821536,
"domNodes": 20,
"jsHeapTotalBytes": 19787776,
"scriptDurationMs": 148.761,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 612.367000000063,
"styleRecalcs": 47,
"styleRecalcDurationMs": 11.531999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 410.36100000000005,
"heapDeltaBytes": -10033828,
"heapUsedBytes": 59820000,
"domNodes": 20,
"jsHeapTotalBytes": 19525632,
"scriptDurationMs": 134.55800000000002,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-idle",
"durationMs": 2013.3839999999736,
"styleRecalcs": 9,
"styleRecalcDurationMs": 8.938999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 502.13700000000006,
"heapDeltaBytes": -23419844,
"heapUsedBytes": 46161336,
"domNodes": 18,
"jsHeapTotalBytes": 18604032,
"scriptDurationMs": 18.581999999999997,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-idle",
"durationMs": 2023.537000000033,
"styleRecalcs": 10,
"styleRecalcDurationMs": 10.176,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 524.277,
"heapDeltaBytes": -22676460,
"heapUsedBytes": 46814900,
"domNodes": -272,
"jsHeapTotalBytes": 19128320,
"scriptDurationMs": 19.891000000000002,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1713.501000000008,
"styleRecalcs": 76,
"styleRecalcDurationMs": 37.074,
"layouts": 16,
"layoutDurationMs": 4.327,
"taskDurationMs": 793.565,
"heapDeltaBytes": -3853224,
"heapUsedBytes": 65980972,
"domNodes": 64,
"jsHeapTotalBytes": 19263488,
"scriptDurationMs": 112.00200000000001,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1772.1599999999853,
"styleRecalcs": 77,
"styleRecalcDurationMs": 42.724000000000004,
"layouts": 16,
"layoutDurationMs": 5.383000000000001,
"taskDurationMs": 938.1229999999999,
"heapDeltaBytes": -20439852,
"heapUsedBytes": 49282292,
"domNodes": -275,
"jsHeapTotalBytes": 18866176,
"scriptDurationMs": 131.829,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-transition-enter",
"durationMs": 1385.672999999997,
"styleRecalcs": 18,
"styleRecalcDurationMs": 31.464999999999993,
"layouts": 14,
"layoutDurationMs": 12.547000000000002,
"taskDurationMs": 1014.8379999999999,
"heapDeltaBytes": 4692236,
"heapUsedBytes": 96384232,
"domNodes": 13671,
"jsHeapTotalBytes": 10747904,
"scriptDurationMs": 54.34799999999999,
"eventListeners": 2377,
"totalBlockingTimeMs": 126,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 9463.371999999992,
"styleRecalcs": 251,
"styleRecalcDurationMs": 37.727999999999994,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 6740.728,
"heapDeltaBytes": 11232388,
"heapUsedBytes": 90217564,
"domNodes": -273,
"jsHeapTotalBytes": 4812800,
"scriptDurationMs": 3561.482,
"eventListeners": -130,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 10584.45400000005,
"styleRecalcs": 250,
"styleRecalcDurationMs": 37.412,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 7213.509,
"heapDeltaBytes": -7282536,
"heapUsedBytes": 71970516,
"domNodes": -272,
"jsHeapTotalBytes": 4288512,
"scriptDurationMs": 3794.3509999999997,
"eventListeners": -126,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 17479.42699999999,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 17462.5,
"heapDeltaBytes": -42424536,
"heapUsedBytes": 161014756,
"domNodes": -6548,
"jsHeapTotalBytes": 2420736,
"scriptDurationMs": 1127.042,
"eventListeners": -7471,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 17793.115000000056,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 17774.301,
"heapDeltaBytes": -39716936,
"heapUsedBytes": 163955000,
"domNodes": -6548,
"jsHeapTotalBytes": 1634304,
"scriptDurationMs": 1153.17,
"eventListeners": -7467,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.77333333333336,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "vue-large-graph-pan",
"durationMs": 21945.74099999994,
"styleRecalcs": 160,
"styleRecalcDurationMs": 22.05800000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 21921.147999999997,
"heapDeltaBytes": -18172020,
"heapUsedBytes": 170177000,
"domNodes": -6548,
"jsHeapTotalBytes": 2596864,
"scriptDurationMs": 1637.6650000000002,
"eventListeners": -7467,
"totalBlockingTimeMs": 673,
"frameDurationMs": 18.333333333333332,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 22908.285999999975,
"styleRecalcs": 177,
"styleRecalcDurationMs": 26.168999999999997,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 22878.590000000004,
"heapDeltaBytes": -36070948,
"heapUsedBytes": 164235024,
"domNodes": -6548,
"jsHeapTotalBytes": 585728,
"scriptDurationMs": 1766.6770000000001,
"eventListeners": -7461,
"totalBlockingTimeMs": 941,
"frameDurationMs": 18.890000000000025,
"p95FrameDurationMs": 33.400000000001455
},
{
"name": "workflow-execution",
"durationMs": 460.26599999993323,
"styleRecalcs": 13,
"styleRecalcDurationMs": 19.923,
"layouts": 3,
"layoutDurationMs": 0.575,
"taskDurationMs": 123.13999999999999,
"heapDeltaBytes": -16393192,
"heapUsedBytes": 51963420,
"domNodes": 128,
"jsHeapTotalBytes": 7204864,
"scriptDurationMs": 11.98,
"eventListeners": 65,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "workflow-execution",
"durationMs": 474.1960000000063,
"styleRecalcs": 13,
"styleRecalcDurationMs": 19.907,
"layouts": 3,
"layoutDurationMs": 0.6560000000000001,
"taskDurationMs": 121.40299999999999,
"heapDeltaBytes": -15943944,
"heapUsedBytes": 52377468,
"domNodes": 121,
"jsHeapTotalBytes": 6418432,
"scriptDurationMs": 10.987999999999998,
"eventListeners": 65,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
}
]
} |
783e1eb to
1cfc056
Compare
564572c to
fdc25a2
Compare
6fdc295 to
19e2281
Compare
0bb1940 to
27e9108
Compare
19e2281 to
4352c66
Compare
dbc2873 to
2999a25
Compare
d9fdbd4 to
861ea25
Compare
3fcda24 to
37b8bbd
Compare
## Summary Centralizes node, group, and reroute geometry in `layoutStore` so moves, resizes, snapping, workflow insertion, and subgraph operations update one authoritative geometry path without colliding with live workflow state. ## Changes - **What**: - Stores node and group bounds as single rectangle values and makes reroute position read and write through `layoutStore`. - Routes drag, paste, snap, legacy-scale normalization, arrangement, and subgraph unpacking through whole-value geometry setters. - Adds group and reroute lifecycle handling, minimap reads, hit testing, undo/redo support, and subgraph-safe geometry IDs. - Converts inserted workflows directly to clipboard items instead of configuring a scratch graph whose entity IDs can collide with the open workflow. - Removes the redundant graph-to-layout resync and unused previous values from layout operations. - Updates the ECS architecture docs and adds focused unit and browser coverage for geometry, subgraphs, workflow insertion, and undo/redo. - **Compatibility**: `LGraphNode.pos` / `size`, group geometry, and `Reroute.pos` retain stable mutable array or rectangle identities through a shared geometry view. Indexed writes and mutating methods commit through `layoutStore`; whole-value assignment remains supported. The internal `moveChildNodesInGroupVueMode` and `repositionNodesVueMode` helpers are removed. ## Geometry before this PR ```mermaid flowchart LR interactions[Drag, snap, paste, arrange, normalize] --> direct[Direct array writes] interactions --> setters[Setters and move methods] interactions --> helpers[Mode-specific helpers] direct --> nodeClass[Node Rectangle] setters --> nodeClass helpers --> nodeClass nodeClass --> nodeStore[layoutStore node position, size, bounds] nodeClass --> resync[Bulk graph-to-store resync] resync --> nodeStore direct --> groupClass[Group _bounding only] setters --> groupClass direct --> rerouteClass[Reroute posInternal] setters --> rerouteClass rerouteClass --> rerouteYjs[Yjs position] rerouteClass --> rerouteLayout[RerouteLayout position] nodeStore --> minimap[Minimap and spatial index] groupClass --> minimap rerouteLayout --> hitTest[Hit testing] ``` | Entity or operation | Geometry storage | Write paths | Lifecycle and consumers | Resulting risk | | --- | --- | --- | --- | --- | | Nodes | Class `Rectangle` plus separate `position`, `size`, and `bounds` store fields | Setters, `move`, direct element writes, mode-specific helpers | Store seeding and a bulk resync patched missed writes | Class and store values could diverge; snapping or offsets could disappear on writeback | | Groups | `LGraphGroup._bounding` only | Setters, direct writes, `resize`, `resizeTo`, `configure`, and `snapToGrid` | Graph owned the class instance; minimap read the class | Group geometry was absent from the CRDT-backed layout model | | Reroutes | `posInternal`, Yjs position, and `RerouteLayout.position` | `move`, setter, and in-place snapping each updated a different subset | Separate seeding paths populated render and hit-test state | Three copies could disagree; the setter did not commit to the store | | Workflow insertion | Temporary `LGraph` configured before clipboard serialization | Scratch entities wrote through normal layout hooks | Temporary IDs shared the same numeric range as the open workflow | Inserting a workflow could move or delete live layout entries | | Subgraphs | Entity IDs and geometry were handled locally by several conversion paths | Element-wise offsets and shared IDs | Groups and reroutes crossed graph boundaries without complete scoping | Stored positions could use inner-graph coordinates or collide across subgraphs | ## Geometry with this PR ```mermaid flowchart LR interactions[Drag, snap, paste, arrange, normalize] --> api[Whole-value setters and move] api --> commands[Serializable layout mutations] commands --> store[layoutStore] store --> nodeRect[Node rect] store --> groupRect[Group rect] store --> reroutePoint[Reroute position] nodeRect --> sync[Class writeback] groupRect --> sync sync --> canvas[Canvas and serialization] nodeRect --> minimap[Minimap and spatial index] groupRect --> minimap reroutePoint --> hitTest[Hit testing] commands --> history[Undo and redo] workflow[Workflow data] --> clipboard[Clipboard items] clipboard --> liveGraph[Open workflow] subgraphs[Subgraph mapping and ID deduplication] --> commands ``` | Entity or operation | Geometry storage | Write path | Lifecycle and consumers | Effect of this PR | | --- | --- | --- | --- | --- | | Nodes | One `rect` value in `layoutStore`, with class geometry kept in sync for litegraph | Whole-value setters and `move` produce layout mutations | Existing node registration, renderer sync, minimap, spatial index, and undo/redo | Position, size, and bounds cannot disagree inside the store | | Groups | One `rect` value in `layoutStore` | `setBounds` is the single internal writer; public geometry APIs delegate to it | `LGraph.add`, `remove`, and `clear` register or remove entries; minimap reads the store | Groups participate in the same command and store model as nodes | | Reroutes | One authoritative position in `layoutStore`; `Reroute.pos` exposes a stable synchronized view | Assignment, indexed or method mutation, `move`, and snapping commit through layout mutations | Constructor registration, graph-scoped lookup, hit testing, and undo/redo use stored geometry | Removes `posInternal` and the duplicate hit-test position without breaking mutable point access | | Workflow insertion | Workflow data converts directly to clipboard items | `workflowToClipboardItems` avoids constructing entities | Only pasted entities enter the open graph and layout lifecycle | Temporary entity IDs can no longer touch live layout state | | Subgraphs | Group and reroute geometry uses graph-aware mapping and deduplicated IDs | Conversion and unpacking assign whole values through setters | Reroutes survive graph traversal; group IDs are unique after deduplication | Geometry stays attached to the correct graph and coordinates | ## Downstream stack - [#14128](../pull/14128) moves node layout registration and recursive teardown to entity attach/detach paths, then deletes the renderer-owned `useVueNodeLifecycle` composable and the unused operation log. - [#14133](../pull/14133) makes `layoutStore` authoritative for node reads through the shared geometry view's versioned projection, removes `useLayoutSync`, 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 - Geometry ownership and lifecycle in `layoutStore`, especially registration and cleanup for groups and reroutes. - Subgraph boundaries: reroute preservation, group ID deduplication, and mapping stored geometry to the active graph. - Workflow insertion now uses `workflowToClipboardItems` directly; check parity with the previous scratch-graph serialization path. - Extension compatibility around stable node, group, and reroute geometry views, including indexed and method-based mutation as well as whole-value assignment. - The PR changes 56 files and includes mechanical setter migrations alongside the store changes. The core review path is `layoutStore`, `layoutMutations`, `createGeometryView`, `LGraphGroup`, `LGraphNode`, `Reroute`, subgraph deduplication, then workflow conversion. <details> <summary>Findings that a dumb agent might call out</summary> These are plausible-looking review findings that do not survive inspection: - **"Remote reroute moves leave the geometry cache stale."** Remote Yjs updates are explicitly future work. Local reroute moves update the cache and spatial index synchronously, and this PR does not claim to ship collaboration. - **"Removing `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. - **"The shared geometry view is unnecessary magic."** It is the compatibility boundary that preserves stable legacy node, group, and reroute `Point`, `Size`, and `Rectangle` identities, including element-wise and method-based mutation. Focused tests cover synchronization, read-through, and write-through behavior. </details> --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Nodes were the only positionable whose layout entry was created by the renderer: groups register in `LGraph.add`, reroutes in their constructor, while nodes went through `useVueNodeLifecycle` listening to node:added and node:removed. That indirection is why entries could outlive the graph that made them, which is what both of yesterday's ownership attempts were trying to paper over. Registering at attach makes the entry's lifetime the node's. `initializeFromLiteGraph` did two jobs under one name. The seeding half is gone; the other half — dropping slot, link and reroute geometry when the viewed graph changes — is now `clearViewGeometry`, which is what `useVueNodeLifecycle` calls. `reset` covers full teardown for tests. zIndex was seeded two ways that disagreed: `initializeFromLiteGraph` used the node's index in `_nodes`, the per-node path used `node.order`. `node.order` is execution order from `computeExecutionOrder` and has nothing to do with stacking, so the draw index wins. The composable no longer owns node lifetime — only the sync lifecycle and mode-switch cleanup. `setupEmptyGraphListener` existed solely to defer seeding until a first node existed, so it goes too. Three tests asserted the policy this reverses (no layout while the renderer is off; seeding stops on dispose; adds to unviewed graphs ignored). They pinned the old design rather than any behaviour worth keeping, so they are deleted; the one contract still worth holding — add creates an entry, remove drops it — moves next to LGraph, along with a test that zIndex follows draw order. layoutStore now holds every node in the workflow rather than just the viewed graph. Only tests call `queryNodeAtPoint` / `getNodesInBounds`, and both `getAllNodes` callers only take a max zIndex, so nothing reads across the wider set. The cost this adds to legacy-mode dragging is dealt with next.
Every layout operation appended to a Y.Array that nothing ever read. `getOperationsSince` and `getOperationsByActor` were not on the LayoutStore interface and had no callers outside the one test that exercised the log itself; both were marked as being for a future sync feature that no provider exists for. It was not free. The array is never trimmed, so per-operation cost grew with session length. Measured on `moveNode` with an entry present: 197 us/op with 22k entries logged, 375 us/op at 40k. Without the log, 5.4 us/op and flat (2.9 us/op after another 18k operations) — the growth disappears with it. This is a live cost in Vue nodes mode today, on every drag frame and every resize, and it is what made registering node geometry at attach look unaffordable for the legacy canvas: dragging 100 selected nodes went from 10.8 ms/frame (65% of a 16.7ms frame) to 0.60 ms/frame (3.6%). The store's test helper observed operations through the log; it spies on applyOperation instead, which is what nodeSizeReflow.test.ts already did.
What was left after node registration moved to `LGraph.add` was two calls on two transitions, wrapped in a shared composable with one consumer. - The `clearAllSlotLayouts` watch was redundant entering Vue mode, since `clearViewGeometry` already drops slot layouts along with link and reroute geometry. It was only doing work on the way out, so dispose clears instead and the watch goes. This widens what mode-leave clears; legacy mode reads none of it and re-entry clears again. - `isInitialized` guarded nothing: `startSync` opens with `stopSync()`, and `clearViewGeometry` is idempotent. - `createSharedComposable` held no shared state once that flag was gone, and `GraphCanvas.vue` was the only caller. - The `arrange()` pass is legacy-canvas preparation, not Vue node lifecycle — it computes slot positions before `drawConnections` can run without them. It moves to `arrangeForLegacyRender` next to the other litegraph canvas adapters, rather than becoming another method on LGraph. The transitions were already driven from `GraphCanvas.vue`, which watches `currentGraph` and `isInSubgraph`, so the remainder lands where it was being called from.
`LGraph.clear()` hand-listed the group and reroute deletions instead of routing through the paired remove helpers, so node geometry registered in `add` was never reclaimed: every workflow load leaked its predecessor into `ynodes`, inflating the max-zIndex scans that place pasted nodes. The same gap dropped interior geometry from orphaned subgraph definitions. Route every attach/detach through `graphLayoutRegistration`, and have bulk teardown call `unregisterAllGraphLayout` beside `unregisterAllNodeStates` rather than re-deriving what those helpers do. Deletes the hand-written block, six copies of the `setSource` dance, and the seeding fixture that diverged from it by omitting the source. `unpackSubgraph` re-homes groups under their original ids, and layout keys groups by root graph id, so its re-add now follows removal of the wrapper -- as reroute migration already did.
`initializeFromLiteGraph` and `useVueNodeLifecycle` no longer exist, and the layout operation log is gone. Records what replaced them: geometry registers at attach and unregisters at detach, with a matching sweep for bulk teardown.
Rebase-time semantic conflict: the parent branch added this test against `layoutStore.getOperationsSince`, which this branch removes. Spying on `applyOperation` asserts the same thing.
| for (let i = 0; i < newPositions.length; i++) { | ||
| setNodeZIndex(newPositions[i].nodeId, maxZIndex + i + 1) | ||
| for (const { nodeId } of newPositions) { | ||
| setNodeZIndex(rootGraphId, nodeId, layoutStore.allocateZIndex()) |
There was a problem hiding this comment.
This loop is now redundant and double-burns the counter.
Every pasted/cloned node already went through graph.add → registerNodeLayout → allocateZIndex(), in paste order. Allocating a second zIndex here preserves relative order, so there is no visual bug — but it consumes 2 counter values per pasted node and re-dispatches a setNodeZIndex operation (plus a LayoutChange, plus a useLayoutSync flush) for every node in the paste.
On the base branch this loop was load-bearing: it scanned layoutStore.getAllNodes() for maxZIndex because add did not allocate. With attach-time registration it can just be deleted.
There was a problem hiding this comment.
Can you provide a user-observable or measured reproduction showing this redundant allocation causes harm?
The extra operation is present, but the visible contract is unchanged: pasted nodes remain above existing nodes, preserve relative order, and receive distinct z-indexes. Exact counter density is not user-visible, and the existing clone tests correctly pass. A large-paste benchmark, collaboration trace, or other concrete expected/actual result would help justify treating this as more than optional cleanup.
| if (e.detail.active && graphId) { | ||
| const mutations = useLayoutMutations() | ||
| mutations.bringNodeToFront(e.detail.nodeId) | ||
| mutations.bringNodeToFront(graphId, e.detail.nodeId) |
There was a problem hiding this comment.
This is the only bringNodeToFront call site that does not setSource(...) first — every other one goes through useNodeZIndex (useNodeZIndex.ts:34) or sets the source explicitly.
The resulting operation therefore inherits whatever layoutStore.currentSource was last set to by unrelated code. That is not cosmetic: useLayoutSync.scheduleFlush (useLayoutSync.ts:68-71) branches on change.source to pick microtask vs requestAnimationFrame flushing, and LGraphNode.vue's handleLayoutChange filters on Canvas/External. So ghost placement gets nondeterministic flush timing depending on what ran before it.
Pre-existing, but the PR is already touching this line.
There was a problem hiding this comment.
Could you provide a deterministic user sequence where the inherited source changes ghost-placement behavior?
The provenance mismatch is real, but the downstream sync flush writes position and size rather than z-index, and I have not reproduced incorrect stacking, placement, or interaction behavior. Please include the preceding action needed to establish the problematic source and the observable expected/actual result after ghost placement.
| isMicrotaskQueued = false | ||
| if (!canvas?.graph || pendingNodeIds.size === 0) return | ||
|
|
||
| const rootGraphId = canvas.graph.rootGraph.id |
There was a problem hiding this comment.
useLayoutSync is the one consumer the graph-scoping refactor missed.
pendingNodeIds is still a bare Set<NodeId> (L20) and startSync's onChange handler (L105-112) discards change.operation.graphId — which this PR just added to OperationMeta precisely so changes carry their graph. The flush then resolves every queued id against canvas.graph.rootGraph.id, i.e. whatever graph is on screen when the rAF fires.
Today that is benign, because Subgraph.state is shared so ids are unique root-wide and there is only ever one LGraph instance. But it is now the single place in the layout system that assumes "all changes belong to the viewed graph", right after the PR made the store hold every graph in the workflow. Two concrete consequences:
layoutStore.clearGraph(A)during a workflow load queues every node id of the outgoing graph. The flush then runsgetNodeLayoutRef(B, id)for each — a no-op write, but it creates a permanentnodeRefs/nodeTriggersentry per id as a side effect (see my comment ongetNodeLayoutRef).- It silently unscopes an otherwise-scoped invariant, so the next thing that introduces a second live root graph (thumbnail renderer, preview pane, multi-tab) breaks here rather than at a type error.
Cheap fix: queue { graphId, nodeId } and drop entries whose graphId !== canvas.graph.rootGraph.id at flush.
There was a problem hiding this comment.
Can you provide a current single-root user reproduction for this assertion?
The comment notes that the behavior is benign today and identifies a future second-root design as the breaking condition. I have not found a supported thumbnail, preview-pane, or multi-root flow that reaches that condition, nor a workflow transition that produces incorrect visible geometry. An exact sequence and observable result would help distinguish a current regression from forward-looking architecture hardening.
|
|
||
| await comfyPage.workflow.loadWorkflow('default') | ||
| await comfyPage.vueNodes.waitForNodes() | ||
| const [reloadedNodeId] = await comfyPage.vueNodes.getNodeIds() |
There was a problem hiding this comment.
This step does not exercise the case the PR flags as the dangerous one.
The PR body and the new docstring on deduplicateSubgraphNodeIds both call out that GraphCanvas.vue keys the node v-for on a bare NodeId, so ids present in both workflows are patched, never unmounted — which is why useNodeLayout captures rootGraphIdAtMount for cleanup.
But the two fixtures have disjoint root node ids:
subgraphs/basic-subgraph.json→[2]default.json→[7, 6, 5, 3, 8, 9, 4]
So every component unmounts and remounts across this transition, and the patched-component path — where onNodeChange was wiped by clearViewGeometry() and never re-subscribed (LGraphNode.vue:473-483), and where the new graph's nodeRefs entry leaks — is never hit. The test passes by fixture construction, not by covering the risk.
Suggest a fixture whose root node ids overlap the first workflow's, so the patched case is actually asserted.
Two other gaps in this spec worth noting: it only mutates size, never pos (write-through of node.pos across transitions is untested), and it only ever takes the first node of each graph.
There was a problem hiding this comment.
Thanks for calling out the fixture-ID distinction. We tested the supported workflow-load and subgraph-navigation interactions, and the components are remounted on the reachable transitions we found; the existing subgraph layout synchronization spec also passes in this branch. We were not able to produce a surviving-component transition with stale position or size behavior through the UI.
Could you provide the exact user steps and a workflow pair that preserve the component while exposing an incorrect position or size? That would give us a user-observable contract to add to this Playwright spec. Without that sequence, changing the fixture only to exercise internal component reuse would test a theoretical implementation path rather than a demonstrated regression.
| mutations.deleteReroute(rootGraphId, rerouteId) | ||
| } | ||
|
|
||
| for (const subgraph of graph._subgraphs.values()) { |
There was a problem hiding this comment.
This recursion is dead in practice, and no test executes it.
_subgraphs is a class field on LGraph (LGraph.ts:367), so a Subgraph gets its own map, while every write goes through get subgraphs() { return this.rootGraph._subgraphs } (LGraph.ts:583). So subgraph._subgraphs is always empty and this loop is a no-op whenever graph is a Subgraph. It happens to be correct anyway — the root's _subgraphs is a flat map of all definitions including nested ones, so one level is sufficient — but the code reads as if it were handling arbitrary nesting.
Worth a comment saying depth-1 is sufficient because the root map is flat, or dropping the recursion for an explicit graph.rootGraph === graph ? [...graph._subgraphs.values()] : [].
Test coverage for this whole function is thin:
LGraph.test.ts:1594(drops every entry on clear/reconfigure) setsgraph.id = createUuidv4(), so it takes thelayoutStore.clearGraphbranch at LGraph.ts:505 and never reaches this function.LGraph.test.ts:1609does reach it via LGraph.ts:1241, but on a flat subgraph with one node, no groups and no reroutes.- So this recursion, the group sweep (L40-42), the reroute sweep (L44-46) and the
!graph.rootGraphguard (L36) are all uncovered.
There was a problem hiding this comment.
Good catch. I verified the ownership model: supported writes all land in the root graph's flat _subgraphs registry, so recursive calls on a Subgraph cannot discover another level. The root-level sweep still matters for individual teardown because it removes layouts owned by each definition.
8c7d3b1f43 replaces the misleading recursion with an explicit root-only pass over that flat registry. It also adds focused coverage showing that nested-definition node, group, and reroute layouts are removed; deleting the flat-registry pass makes that test fail.
| // TODO: Finish typing configure() | ||
| if (!data) return | ||
| if (options.clearGraph) this.clear() | ||
| else unregisterAllGraphLayout(this) |
There was a problem hiding this comment.
Two things about this hunk and the deletions further down the file.
1. ensureGlobalIdUniqueness is deleted with no mention in the PR description. It is a public method on LGraph, so it is reachable from extensions, and its six tests go with it. It had no in-repo caller, so mechanically the removal is fine — but the invariant it repaired (node ids unique across a root graph and its subgraph definitions) is now load-bearing for the new layout key: root and subgraph-interior nodes share one ${rootGraphId}:${nodeId} bucket, so a collision silently means one layout entry for two nodes. The PR body argues at length that collisions cannot happen via deduplicateSubgraphNodeIds and the shared state counter — I agree with that argument — but removing the last defensive repair in the same PR that makes the invariant load-bearing deserves to be called out in the description rather than discovered in the diff.
Related: this leaves patchLinkNodeIds duplicated-then-orphaned — the LGraph.ts copy goes away, the independent copy at LGraphCanvas.ts:8973 stays.
2. The keep_old branch this line adds is unreachable. git grep finds no caller passing keep_old = true anywhere in src/. It also has a latent inversion: a subgraph definition present in _subgraphs but absent from the incoming data gets unregistered here and never re-registered, i.e. missing entries rather than orphaned ones. Since nothing exercises it and nothing tests it, consider either deleting the branch or adding a test.
There was a problem hiding this comment.
Can you point to a supported first-party flow or a known extension that exercises either ensureGlobalIdUniqueness() or configure(..., true), together with reproduction steps for the resulting failure?
Repository-wide caller searches found no keep_old=true production path and no extension fixture using the removed method. Normal workflow loading still exercises deduplicateSubgraphNodeIds() and retains browser coverage for globally unique IDs. Without a concrete consumer, these currently look like hypothetical compatibility concerns rather than user-reachable regressions.
benjcooley
left a comment
There was a problem hiding this comment.
Reviewed at 3081bc4. I read the surrounding systems rather than just the hunks — LGraph.add/remove/clear/configure, layoutStore's ref/trigger/listener maps, useLayoutSync, the six Vue composables that gained rootGraphId, and the deleted useVueNodeLifecycle — and traced the claims in the description against the code.
The direction is right and the description is unusually thorough. Most of the pre-emptive rebuttals hold up: I checked the LGraph.add Pinia claim, the litegraph→layout layering claim, the unpackSubgraph reordering (toSelect order really is unchanged — groups follow nodes in both revisions), the _subgraphs recursion, and the minimap data-source rationale, and none of those are valid findings. I also independently confirmed the id-collision argument: Subgraph.state proxies to the root's, _configureBase runs before any add, and LGraph.id is a shallowRef so canvasStore.rootGraphId genuinely does invalidate across a workflow reconfigure (I initially suspected it did not — it does, and the rootGraphIdAtMount reasoning is sound).
What follows is what survived that.
Blocking
1. The new key reintroduces an unbounded per-session leak — the same class of cost this PR deletes.
getNodeLayoutRef caches a customRef + trigger under ${rootGraphId}:${nodeId}. Previously the key was the bare NodeId, so those two maps were bounded by the set of distinct node ids ever seen and were reused across workflow loads. Now every workflow load starts a generation that can never be reused, and nothing reaps it: handleClearGraph sweeps only the three Yjs maps, clearViewGeometry deliberately preserves refs, handleDeleteNode explicitly declines. The only pruner is cleanupNodeRef, called from one place with the mount-time graph id.
The population path is not renderer-gated either: LGraphNode._positionUpdated / _sizeUpdated call getNodeLayoutRef on every pos/size write, and configure writes both for every node. So a legacy-canvas session — where no Vue node component ever mounts and cleanupNodeRef is therefore never called at all — accumulates two closures per node per workflow loaded, for the life of the page. And clearViewGeometry does nodeTriggers.forEach(t => t()), so the per-transition cost grows with the leak.
Given the PR's headline result is deleting an unbounded per-operation cost, this one should not ship alongside it. Details inline on layoutStore.ts:226 and useNodeLayout.ts:31.
2. "Draw order wins" only holds at add time; the reconciliation that used to fix it is deleted.
LGraphCanvas.bringToFront / sendToBack splice graph._nodes without touching the store, and bringToFront fires on every legacy node click (_processNodeClick) and every legacy widget click (DomWidget.vue:165). On feature/ecs-migration this self-healed, because initializeFromLiteGraph re-seeded zIndex: index from _nodes order on every renderer entry. This PR removes that and enterVueRendering does not replace it, so stacking established in legacy mode is now silently discarded on switch to Vue. The new tests assert counter monotonicity in add order, which is a weaker and different claim than the one in the description. Inline on graphLayoutRegistration.ts:18.
3. LGraphNode.vue:473-483 — one-shot subscription with a permanent silent failure.
If rootGraphId is falsy at mount the component never subscribes to onNodeChange again, so extension-driven node.setSize() stops updating it forever. Every other guarded site recovers on the next call; this one cannot. Compounded by clearViewGeometry() calling nodeChangeListeners.clear() on every subgraph navigation and renderer toggle — a component patched across that transition loses its listener and never re-subscribes.
Worth fixing before merge
4. useLayoutSync is the one consumer the graph-scoping refactor missed. pendingNodeIds is still a bare Set<NodeId> and the onChange handler discards change.operation.graphId — the field this PR added for exactly this. Benign today (one live LGraph, ids unique root-wide), but it unscopes an otherwise-scoped invariant and creates ref entries as a flush side effect. Inline.
5. ensureGlobalIdUniqueness deleted without a mention in the description. Public method on LGraph, six tests removed with it, no in-repo caller — mechanically fine. But the invariant it repaired is now load-bearing for the layout key (root and subgraph nodes share one bucket), so removing the last defensive repair in the same PR that makes the invariant structural should be stated, not discovered. Also orphans the duplicated patchLinkNodeIds in LGraphCanvas.ts:8973.
6. The custom-node audit should gate this, not follow it. ecs-migration-plan.md marks it "pending" — but this PR both removes five layoutStore query methods and changes the signature of every node method on layoutStore / useLayoutMutations. Any extension calling layoutStore.getNodeLayoutRef(id) or moveNode(id, pos) now silently writes to a "5:undefined"-shaped bucket rather than failing loudly. The unbranded UUID (utils/uuid.ts:2) is what makes that silent, while NodeId and the new GroupId are both branded — worth branding UUID (or a RootGraphId) so graph.id vs graph.rootGraph.id mix-ups are compile errors.
7. Redundant double zIndex allocation on paste (LGraphCanvas.ts:4378) and missing setSource on the ghost-placement bringNodeToFront (canvasStore.ts:183). Both inline.
Test coverage
Net line count is positive (+1132/-767 across specs), which hides some specific losses:
unregisterAllGraphLayout's subgraph recursion, its group sweep, its reroute sweep, and its!graph.rootGraphguard are executed by no test —LGraph.test.ts:1594sets a real UUID so it takes theclearGraphbranch instead, and:1609uses a flat one-node subgraph.subgraphLayoutSync.spec.ts's "after loading a second workflow" step uses fixtures with disjoint root node ids ([2]vs[7,6,5,3,8,9,4]), so every component remounts and the patched-component path — the one the PR itself identifies as risky — is never exercised. Inline.arrangeForLegacyRender.test.tsasserts the positive case only as "does not throw"; it would pass against an empty body wrapped in try/catch. The collapsed-node test is real.useNodeLayout.test.tspins the weaker half: it does not assert cleanup was not also called with the second id, does not observe store state, and does not coverlayoutre-targeting while mounted — the actual reason for the rewrite.- No test covers
allocateZIndexacrossclearGraph, or root-vs-subgraph id isolation at the layout-key level (theroot-scoped node layoutssuite only isolates across different root graphs). - Six litegraph canvas tests moved to the shared
__mocks__/layoutStore.ts. That is a clean dedup versus their previous inline stubs, butallocateZIndex: () => 1is a constant andgetNodeLayoutRef: () => ({ value: null })short-circuits every mutation guard, sovi.mock('...layoutStore')as a bare one-liner now hides substantially more than the explicit literals it replaced. Worth a comment in the mock. resetForTests()ships on the production class.
Architectural note
Attach-time registration replaces one imperative sync point (node:added/node:removed) with several (add, remove, clear, configure's two branches, unpackSubgraph's reordered group loop, released-subgraph teardown), and most of the findings above are lifetime bugs at the seams between them — entries and refs that outlive or under-live the entity.
Worth considering reconcile instead of push: on graph change, diff the store's key set for the root graph against graph._nodes (plus subgraph definitions) and add/drop the difference. Node ids are unique root-wide and already the key, so it is a set difference over ids — cheap, and it makes teardown correct by construction rather than by every mutation path remembering to call the right unregister. It would also collapse clearGraph + unregisterAllGraphLayout + the configure branches into one path, and it naturally reaps nodeRefs/nodeTriggers (finding 1) since the reconcile pass already knows which keys are dead.
Not asking for that in this PR — but if the seams keep producing findings on #14133, it is the cheaper shape.
Nits
SpatialIndex.ts:1-6docblock still says "efficient node queries"; nodes are no longer indexed.SpatialIndexManager<TId … = NodeId>'s default is now never exercised, leaving a vestigialNodeIdimport.rootGraphIdAtMountis captured at setup, not mount.- The
graph.onNodeAddedhook inLGraphCanvas.cloneZIndex.test.ts:149-151("Simulate Vue runtime: create layout entries when nodes are added") is now dead — productionaddcallsregisterNodeLayoutafteronNodeAdded, so the entry it writes is immediately overwritten. The comment misdescribes production behaviour. graphLayoutRegistration.ts:49— the recursion is depth-1-sufficient by accident of_subgraphsbeing flat on the root; worth saying so.
Requesting changes on 1-3. The rest are discussion.
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/renderer/core/layout/operations/layoutMutations.test.ts (1)
14-29: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winAdd per-test store reset.
GRAPHis shared across tests, andlayoutStoreis a module-level singleton. ThebeforeEachhook creates a new Pinia instance but does not calllayoutStore.resetForTests(). Reset the store before recreatingNODE_1andNODE_2to prevent test-order dependence.🤖 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/renderer/core/layout/operations/layoutMutations.test.ts` around lines 14 - 29, Reset the module-level layout store in beforeEach before recreating NODE_1 and NODE_2. Call layoutStore.resetForTests() after creating the testing Pinia and before canvasLayoutMutations() performs the node setup, preserving isolated state for every test despite the shared GRAPH identifier.docs/adr/0003-crdt-based-layout-system.md (1)
141-150: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winRemove the stale operation-history statements.
The amendment says operation-history storage and pruning no longer apply. Lines
130 and 138 still list those items as a cost and mitigation. Remove or revise
those entries so the ADR has one consistent description.🤖 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 `@docs/adr/0003-crdt-based-layout-system.md` around lines 141 - 150, Update the ADR’s earlier cost and mitigation sections to remove or revise the operation-history storage and history-pruning statements referenced by the amendment. Keep the remaining documented costs and mitigations intact, ensuring the ADR consistently reflects that the Yjs operation log is no longer stored or pruned.src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts (1)
26-32: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winHoist
ROOT_GRAPH_IDinuseNodeZIndex.test.ts.The
canvasStoremock runs before the test module initializes its top-levelROOT_GRAPH_ID, which throws a TDZReferenceErrorduring test collection. Define it withvi.hoistedand use a self-contained literal, as inuseVueNodeResizeTracking.test.ts.🤖 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/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts` around lines 26 - 32, Hoist ROOT_GRAPH_ID in src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts:15-18 with vi.hoisted and initialize it from a self-contained literal, then use that hoisted value in the canvasStore mock. The anchor site src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts:26-32 requires no direct change; it is only cited as the consolidated comment location.Source: Learnings
🤖 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.
Inline comments:
In `@browser_tests/tests/performance.spec.ts`:
- Around line 160-208: Update the setup in the “large graph legacy node drag”
test to set Comfy.VueNodes.Enabled to false before measuring, then wait for the
renderer transition to complete before starting the drag. Keep the existing
node-position setup and drag verification unchanged.
In `@src/renderer/core/canvas/litegraph/arrangeForLegacyRender.test.ts`:
- Around line 25-46: Update the tests in arrangeForLegacyRender.test.ts to spy
on node.arrange, clear the setup invocation before exercising
arrangeForLegacyRender, and assert it is called once for the normal node. In the
collapsed-node test, add the same spy setup and assert arrange is not called
while preserving the existing _widgetSlotsDirty assertion.
In `@src/renderer/core/layout/sync/useLayoutSync.test.ts`:
- Line 36: Update the getNodeLayoutRef mock in
src/renderer/core/layout/sync/useLayoutSync.test.ts:36-36 to key fixture layouts
by both root graph ID and node ID, and assert the lookup uses rootGraph.id.
Apply the same graph-scoped fixture key in
src/renderer/extensions/minimap/data/MinimapDataSource.test.ts:40-40, adding a
case with distinct root graph IDs that share the same node ID.
In `@src/renderer/extensions/vueNodes/layout/useNodeDrag.test.ts`:
- Around line 67-68: Add a Vitest case in the drag tests using the mocked
useCanvasStore with rootGraphId absent, then exercise startDrag, movement, and
snapping and assert that no layout mutation occurs. Keep the existing
ROOT_GRAPH_ID setup for other tests and verify the unavailable-root-graph path
remains mutation-free.
---
Outside diff comments:
In `@docs/adr/0003-crdt-based-layout-system.md`:
- Around line 141-150: Update the ADR’s earlier cost and mitigation sections to
remove or revise the operation-history storage and history-pruning statements
referenced by the amendment. Keep the remaining documented costs and mitigations
intact, ensuring the ADR consistently reflects that the Yjs operation log is no
longer stored or pruned.
In `@src/renderer/core/layout/operations/layoutMutations.test.ts`:
- Around line 14-29: Reset the module-level layout store in beforeEach before
recreating NODE_1 and NODE_2. Call layoutStore.resetForTests() after creating
the testing Pinia and before canvasLayoutMutations() performs the node setup,
preserving isolated state for every test despite the shared GRAPH identifier.
In `@src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts`:
- Around line 26-32: Hoist ROOT_GRAPH_ID in
src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts:15-18 with
vi.hoisted and initialize it from a self-contained literal, then use that
hoisted value in the canvasStore mock. The anchor site
src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts:26-32
requires no direct change; it is only cited as the consolidated comment
location.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b1a13328-3fe9-44a8-889d-05cc41a8ef9d
📒 Files selected for processing (48)
browser_tests/tests/performance.spec.tsbrowser_tests/tests/vueNodes/interactions/node/bringToFront.spec.tsbrowser_tests/tests/vueNodes/layout/rendererToggleGeometry.spec.tsbrowser_tests/tests/vueNodes/layout/subgraphLayoutSync.spec.tsdocs/adr/0003-crdt-based-layout-system.mddocs/architecture/ecs-migration-plan.mddocs/architecture/node-data-store.mdsrc/components/graph/GraphCanvas.vuesrc/composables/canvas/useSelectionToolboxPosition.tssrc/composables/graph/useArrangeNodes.tssrc/lib/litegraph/src/LGraph.test.tssrc/lib/litegraph/src/LGraph.tssrc/lib/litegraph/src/LGraphCanvas.cloneZIndex.test.tssrc/lib/litegraph/src/LGraphCanvas.tssrc/lib/litegraph/src/LGraphNode.test.tssrc/lib/litegraph/src/LGraphNode.tssrc/lib/litegraph/src/subgraph/subgraphDeduplication.tssrc/renderer/core/canvas/canvasStore.tssrc/renderer/core/canvas/litegraph/arrangeForLegacyRender.test.tssrc/renderer/core/canvas/litegraph/arrangeForLegacyRender.tssrc/renderer/core/canvas/litegraph/slotCalculations.tssrc/renderer/core/layout/operations/graphLayoutRegistration.tssrc/renderer/core/layout/operations/layoutMutations.test.tssrc/renderer/core/layout/operations/layoutMutations.tssrc/renderer/core/layout/store/__mocks__/layoutStore.tssrc/renderer/core/layout/store/layoutStore.test.tssrc/renderer/core/layout/store/layoutStore.tssrc/renderer/core/layout/sync/useLayoutSync.test.tssrc/renderer/core/layout/sync/useLayoutSync.tssrc/renderer/core/layout/types.tssrc/renderer/extensions/minimap/data/LayoutStoreDataSource.tssrc/renderer/extensions/minimap/data/MinimapDataSource.test.tssrc/renderer/extensions/vueNodes/components/LGraphNode.vuesrc/renderer/extensions/vueNodes/composables/useNodeEventHandlers.test.tssrc/renderer/extensions/vueNodes/composables/useNodeZIndex.test.tssrc/renderer/extensions/vueNodes/composables/useNodeZIndex.tssrc/renderer/extensions/vueNodes/composables/useSlotElementTracking.test.tssrc/renderer/extensions/vueNodes/composables/useSlotElementTracking.tssrc/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.test.tssrc/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.tssrc/renderer/extensions/vueNodes/interactions/resize/useNodeResize.test.tssrc/renderer/extensions/vueNodes/interactions/resize/useNodeResize.tssrc/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.tssrc/renderer/extensions/vueNodes/layout/nodeSizeReflow.test.tssrc/renderer/extensions/vueNodes/layout/useNodeDrag.test.tssrc/renderer/extensions/vueNodes/layout/useNodeDrag.tssrc/renderer/extensions/vueNodes/layout/useNodeLayout.test.tssrc/renderer/extensions/vueNodes/layout/useNodeLayout.ts
| it('arranges nodes after Vue rendering clears the legacy draw gate', () => { | ||
| const graph = new LGraph() | ||
| const node = addedNode(graph) | ||
|
|
||
| LiteGraph.vueNodesMode = true | ||
| node.arrange() | ||
|
|
||
| expect(node._widgetSlotsDirty).toBe(false) | ||
|
|
||
| LiteGraph.vueNodesMode = false | ||
| expect(() => arrangeForLegacyRender(graph)).not.toThrow() | ||
| }) | ||
|
|
||
| it('leaves collapsed nodes alone', () => { | ||
| const graph = new LGraph() | ||
| const node = addedNode(graph) | ||
| node.flags.collapsed = true | ||
| node._widgetSlotsDirty = true | ||
|
|
||
| arrangeForLegacyRender(graph) | ||
|
|
||
| expect(node._widgetSlotsDirty).toBe(true) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert the arrangement behavior.
The first test passes if arrangeForLegacyRender does not call
node.arrange(). Spy on node.arrange, clear the setup call, then assert one
call for the normal node and zero calls for the collapsed node.
As per coding guidelines, write Vitest tests for behavior changes.
🤖 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/renderer/core/canvas/litegraph/arrangeForLegacyRender.test.ts` around
lines 25 - 46, Update the tests in arrangeForLegacyRender.test.ts to spy on
node.arrange, clear the setup invocation before exercising
arrangeForLegacyRender, and assert it is called once for the normal node. In the
collapsed-node test, add the same spy setup and assert arrange is not called
while preserving the existing _widgetSlotsDirty assertion.
Source: Coding guidelines
| } | ||
| ), | ||
| getNodeLayoutRef: vi.fn((nodeId: string) => ({ | ||
| getNodeLayoutRef: vi.fn((_rootGraphId: string, nodeId: string) => ({ |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Test the root-graph lookup contract.
Both mocks discard the root graph ID. The tests can pass when a consumer uses an incorrect graph ID for a node layout lookup.
src/renderer/core/layout/sync/useLayoutSync.test.ts#L36-L36: Key fixture layouts by root graph ID and node ID. Assert the lookup usesrootGraph.id.src/renderer/extensions/minimap/data/MinimapDataSource.test.ts#L40-L40: Use the same graph-scoped fixture key. Add a distinct-root-graph case with the same node ID.
As per coding guidelines, “Write Vitest unit/component tests for behavior changes, especially bug fixes.”
📍 Affects 2 files
src/renderer/core/layout/sync/useLayoutSync.test.ts#L36-L36(this comment)src/renderer/extensions/minimap/data/MinimapDataSource.test.ts#L40-L40
🤖 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/renderer/core/layout/sync/useLayoutSync.test.ts` at line 36, Update the
getNodeLayoutRef mock in
src/renderer/core/layout/sync/useLayoutSync.test.ts:36-36 to key fixture layouts
by both root graph ID and node ID, and assert the lookup uses rootGraph.id.
Apply the same graph-scoped fixture key in
src/renderer/extensions/minimap/data/MinimapDataSource.test.ts:40-40, adding a
case with distinct root graph IDs that share the same node ID.
Source: Coding guidelines
DrJKL
left a comment
There was a problem hiding this comment.
One review-body finding does not have an inline thread to answer, so I am recording the disposition here.
CodeRabbit came riding in hard on a supposed ROOT_GRAPH_ID temporal-dead-zone failure in useNodeZIndex.test.ts. I appreciate a keen young buck checking whether the cinch is tight, but this particular horse never threw its rider:
ROOT_GRAPH_IDis declared at module scope before the mock's returned function uses it at runtime.- The focused
useNodeZIndex.test.tssuite collects and all four tests pass at this HEAD, directly contradicting the predictedReferenceError. - The review body anchors the claim to
ensureCorrectLayoutScale.test.ts, which is not the file containing the alleged failure.
That makes this finding unsupported, so no hoisting change is warranted. Thanks for scouting the ravine; this time the bridge is sound.
Amp-Thread-ID: https://ampcode.com/threads/T-019fd031-29ec-7358-b59d-8003d7d6b4f0 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019fd031-29ec-7358-b59d-8003d7d6b4f0 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/lib/litegraph/src/LGraph.ts (2)
1080-1088: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPublish add notifications after layout registration.
Group add calls
change()beforeregisterGroupLayout. Node add dispatchesnode:addedbeforeregisterNodeLayout. Consumers can observe an attached item without layout state. If a node callback removes the node,remove()deletes the layout and the delayed registration creates a stale entry. Register layout before public notifications, or guard and reconcile registration after callbacks. Add tests for synchronous read and remove callbacks.Also applies to: 1149-1151
🤖 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 1080 - 1088, Update the group-add flow around registerGroupLayout and the public notifications so layout registration completes before change() exposes the attached group; apply the same ordering fix to node additions around registerNodeLayout and node:added. Ensure synchronous callbacks can read layout state and that removal during callbacks cannot leave a stale layout entry, then add coverage for both read and remove callback cases.
505-512: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winRun removal callbacks before deleting layout state.
Both
layoutStore.clearGraph(graphId)andunregisterAllGraphLayout(this)run beforefireNodeRemovalLifecycle.onRemovedremains an extension-facing callback, so it can read or synchronize layout whilenode.graphis still attached. This differs fromremove(), which callsonRemovedbefore deleting node layout. Move layout cleanup after lifecycle callbacks and add regression coverage forclear().🤖 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 505 - 512, Reorder graph removal so node removal lifecycle callbacks run before layout cleanup: move `layoutStore.clearGraph(graphId)` and `unregisterAllGraphLayout(this)` to after `fireNodeRemovalLifecycle`, while preserving the other topology, reroute, and node-state cleanup behavior. Add regression coverage for `clear()` verifying `onRemoved` can access or synchronize layout while `node.graph` remains attached.
🤖 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.
Inline comments:
In `@browser_tests/tests/vueNodes/layout/rendererToggleGeometry.spec.ts`:
- Around line 193-205: Update the z-index assertion in
rendererToggleGeometry.spec.ts so KSampler is verified as frontmost among all
rendered nodes, not only against CLIP Text Encode. Use the rendered-node
collection to compare KSampler’s z-index with every other node or assert it has
the unique maximum, preserving the polling behavior during the Vue transition.
In `@src/lib/litegraph/src/LGraphCanvas.ts`:
- Around line 5012-5013: Update sendToBack to call
canvasLayoutMutations().sendNodeToBack (or the corresponding root-graph layout
mutation) with graph.rootGraph.id and node.id before graph._nodes.unshift(node),
matching bringNodeToFront’s layout synchronization. Extend the renderer-order
test to verify both the layout mutation and legacy node ordering.
In `@src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts`:
- Around line 236-244: Add an afterEach teardown in the test suite containing
ensureCorrectLayoutScale to call vi.restoreAllMocks() and
layoutStore.resetForTests(). Keep the existing test setup unchanged while
ensuring the applyOperation spy is restored and singleton layout state is reset
after every test.
---
Outside diff comments:
In `@src/lib/litegraph/src/LGraph.ts`:
- Around line 1080-1088: Update the group-add flow around registerGroupLayout
and the public notifications so layout registration completes before change()
exposes the attached group; apply the same ordering fix to node additions around
registerNodeLayout and node:added. Ensure synchronous callbacks can read layout
state and that removal during callbacks cannot leave a stale layout entry, then
add coverage for both read and remove callback cases.
- Around line 505-512: Reorder graph removal so node removal lifecycle callbacks
run before layout cleanup: move `layoutStore.clearGraph(graphId)` and
`unregisterAllGraphLayout(this)` to after `fireNodeRemovalLifecycle`, while
preserving the other topology, reroute, and node-state cleanup behavior. Add
regression coverage for `clear()` verifying `onRemoved` can access or
synchronize layout while `node.graph` remains attached.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c2005be6-ace1-4b41-b075-7d81b6482df1
📒 Files selected for processing (4)
browser_tests/tests/vueNodes/layout/rendererToggleGeometry.spec.tssrc/lib/litegraph/src/LGraph.tssrc/lib/litegraph/src/LGraphCanvas.tssrc/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts
| const ksamplerNode = comfyPage.vueNodes.getNodeByTitle('KSampler') | ||
| const clipNode = comfyPage.vueNodes.getNodeByTitle('CLIP Text Encode') | ||
| await expect | ||
| .poll(async () => { | ||
| const ksamplerZIndex = await ksamplerNode.evaluate((node) => | ||
| Number(getComputedStyle(node).zIndex) | ||
| ) | ||
| const clipZIndex = await clipNode.evaluate((node) => | ||
| Number(getComputedStyle(node).zIndex) | ||
| ) | ||
| return ksamplerZIndex - clipZIndex | ||
| }) | ||
| .toBeGreaterThan(0) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert frontmost order against all rendered nodes.
The test compares KSampler only with CLIP. The workflow has a third node. KSampler can remain below that node after the Vue transition while this assertion passes. Compare KSampler’s z-index with every other rendered node, or assert that it has the unique maximum z-index.
As per path instructions, test behavior must cover relevant edge cases and use behavioral assertions.
🤖 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 `@browser_tests/tests/vueNodes/layout/rendererToggleGeometry.spec.ts` around
lines 193 - 205, Update the z-index assertion in rendererToggleGeometry.spec.ts
so KSampler is verified as frontmost among all rendered nodes, not only against
CLIP Text Encode. Use the rendered-node collection to compare KSampler’s z-index
with every other node or assert it has the unique maximum, preserving the
polling behavior during the Vue transition.
Source: Path instructions
| group.graph = graph | ||
| layoutMutations.createGroup(graph.id, toGroupId(810), { | ||
| position: { x: 150, y: 150 }, | ||
| size: { width: 300, height: 200 } | ||
| }) | ||
| graph.groups!.push(group) | ||
|
|
||
| const applyOperation = vi.spyOn(layoutStore, 'applyOperation') | ||
| ensureCorrectLayoutScale(undefined, graph as LGraph) | ||
| ensureCorrectLayoutScale(undefined, graph) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n 'clearAllMocks|restoreAllMocks|resetForTests|clearGraph' \
src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts \
src/renderer/core/layout/store/layoutStore.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 580
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- test structure ---'
sed -n '1,285p' src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts
printf '%s\n' '--- layout store reset implementation ---'
sed -n '870,935p' src/renderer/core/layout/store/layoutStore.ts
printf '%s\n' '--- layout store imports and reset-related symbols ---'
rg -n 'layoutStore|resetForTests|clearAllMocks|afterEach|beforeEach|applyOperation' \
src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts \
src/renderer/core/layout/store/layoutStore.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 12743
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- remaining test hooks and state-using tests ---'
sed -n '280,620p' src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts
printf '%s\n' '--- layout mutation implementation ---'
ast-grep outline src/renderer/core/layout/operations/layoutMutations.ts
rg -n -A35 -B10 'createGroup|useLayoutMutations' \
src/renderer/core/layout/operations/layoutMutations.ts \
src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.ts
printf '%s\n' '--- deterministic source checks ---'
python3 - <<'PY'
from pathlib import Path
test = Path('src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts').read_text()
store = Path('src/renderer/core/layout/store/layoutStore.ts').read_text()
assert 'vi.clearAllMocks()' in test
assert 'vi.restoreAllMocks()' not in test
assert 'layoutStore.resetForTests()' not in test
assert 'const applyOperation = vi.spyOn(layoutStore, \\'applyOperation\\')' in test
reset = store[store.index('resetForTests(): void'):store.index('clearViewGeometry(): void')]
for symbol in ('ynodes.clear()', 'ygroups.clear()', 'yreroutes.clear()', 'rerouteLayouts.clear()', 'rerouteSpatialIndex.clear()', 'clearViewGeometry()'):
assert symbol in reset, symbol
print('The test clears mock history only, installs a persistent spy, and has no teardown.')
print('resetForTests clears entity/layout collections and view geometry.')
PYRepository: Comfy-Org/ComfyUI_frontend
Length of output: 12832
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
test = Path(
'src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts'
).read_text()
mutations = Path(
'src/renderer/core/layout/operations/layoutMutations.ts'
).read_text()
store = Path(
'src/renderer/core/layout/store/layoutStore.ts'
).read_text()
assert 'vi.clearAllMocks()' in test
assert 'vi.restoreAllMocks()' not in test
assert 'layoutStore.resetForTests()' not in test
assert "vi.spyOn(layoutStore, 'applyOperation')" in test
create_group = mutations[
mutations.index('const createGroup = '):
mutations.index('const setGroupBounds = ')
]
assert "layoutStore.applyOperation({" in create_group
assert "type: 'createGroup'" in create_group
reset = store[
store.index('resetForTests(): void'):
store.index('clearViewGeometry(): void')
]
for symbol in (
'ynodes.clear()',
'ygroups.clear()',
'yreroutes.clear()',
'rerouteLayouts.clear()',
'rerouteSpatialIndex.clear()',
'clearViewGeometry()',
):
assert symbol in reset, symbol
print('The test clears mock history but does not restore spies.')
print('The group setup mutates the singleton layoutStore.')
print('The available resetForTests API clears layout collections and view geometry.')
PYRepository: Comfy-Org/ComfyUI_frontend
Length of output: 349
Reset layout state and restore mocks after each test.
vi.clearAllMocks() only clears call history. It does not restore the layoutStore.applyOperation spy. The group setup also mutates the singleton layoutStore. Add afterEach teardown with vi.restoreAllMocks() and layoutStore.resetForTests().
🤖 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/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts`
around lines 236 - 244, Add an afterEach teardown in the test suite containing
ensureCorrectLayoutScale to call vi.restoreAllMocks() and
layoutStore.resetForTests(). Keep the existing test setup unchanged while
ensuring the applyOperation spy is restored and singleton layout state is reset
after every test.
Source: Path instructions
|
|
||
| const beforeSlots = slotsOf(before) | ||
| const afterSlots = slotsOf(after) | ||
| expect(afterSlots, 'slot count after drag').toHaveLength(beforeSlots.length) |
There was a problem hiding this comment.
I'm reminded of the toBeCloseToArray custom matcher I tried to get in.
| .evaluate((element) => [ | ||
| element instanceof HTMLElement ? element.offsetWidth : 0, | ||
| element instanceof HTMLElement ? element.offsetHeight : 0 | ||
| ]) |
There was a problem hiding this comment.
You yell at me for ⛳ and then do this?
| typeof useLayoutMutations | ||
| >) | ||
| mockedUseLayoutMutations.mockReturnValue( | ||
| fromPartial<ReturnType<typeof useLayoutMutations>>({ |
There was a problem hiding this comment.
| fromPartial<ReturnType<typeof useLayoutMutations>>({ | |
| fromPartial({ |
Delete all of these.
There was a problem hiding this comment.
Fixed all four occurrences in 4b3f9b283e. mockReturnValue() supplies the contextual return type, so the explicit ReturnType<typeof useLayoutMutations> arguments were redundant. A scan of the rest of this PR found no other contextually typed fromPartial<T>() calls that can be simplified the same way.
Co-authored-by: AustinMroz <austin@comfy.org>
Amp-Thread-ID: https://ampcode.com/threads/T-019fd031-29ec-7358-b59d-8003d7d6b4f0 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019fd031-29ec-7358-b59d-8003d7d6b4f0 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019fd031-29ec-7358-b59d-8003d7d6b4f0 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019fd031-29ec-7358-b59d-8003d7d6b4f0 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019fd031-29ec-7358-b59d-8003d7d6b4f0 Co-authored-by: Amp <amp@ampcode.com>
…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>
Phase: move node layout registration to the entity's attach point, so the renderer stops owning node lifetime.
Nodes were the only positionable whose layout entry was created by the renderer — groups register in
LGraph.add, reroutes in their constructor, nodes went throughuseVueNodeLifecyclelistening tonode:added/node:removed. That indirection is why entries could outlive the graph that created them, which is what the ownership attempts on the parent branch were working around.Changes
LGraph.addand deregisters inLGraph.remove, besideregisterNodeState/unregisterNodeState.graphLayoutRegistrationcentralizes node, group, and reroute registration and teardown, including graph clear, non-clearing configure, and recursive subgraph release paths.initializeFromLiteGraphsplit: the seeding half is gone, the view-change reset becomesclearViewGeometry;resetcovers full teardown.useVueNodeLifecycledeleted.GraphCanvasdirectly owns the remaininguseLayoutSyncand mode-switch lifecycle, while legacy-node arrangement moves toarrangeForLegacyRender.setupEmptyGraphListenerdisappears with renderer-owned seeding.makeScopedLayoutKey(rootGraphId, nodeId), the scheme groups and reroutes already used (see below).Fixed along the way
initializeFromLiteGraphused the node's index in_nodes; the per-node path usednode.order, which is execution order fromcomputeExecutionOrderand unrelated to stacking. Draw order wins.Performance
Deleting the never-read operation log removed an unbounded per-operation cost that grew with session length, in Vue nodes mode today:
moveNodewith an entryThat is also what made attach-time registration affordable for the legacy canvas, which now pays for entries it does not read. Dragging 100 selected nodes: 10.8 ms/frame (65% of a 16.7ms frame) before, 0.60 ms/frame (3.6%) after.
Behaviour change to review
layoutStorenow holds every node in the workflow rather than only the viewed graph. Only tests callqueryNodeAtPoint/getNodesInBounds, and bothgetAllNodescallers only take a max zIndex, so nothing reads across the wider set today.Three tests asserted the policy this reverses (no layout while the renderer is off; seeding stops on dispose; adds to unviewed graphs ignored). They pinned the old design rather than behaviour worth keeping, so they are deleted; the contract still worth holding — add creates an entry, remove drops it — moved next to
LGraph, with a test that zIndex follows draw order.Node layout keys are now root-graph scoped
Groups and reroutes were already keyed by
makeScopedLayoutKey(rootGraphId, id); nodes were the exception, keyed by a bareNodeId. Now that registration is unconditional, that exception is what kept layout from having a bucket to wipe — hence the// Geometry has no per-rootGraph bucket to wipe, so both branches sweepcomment this removes.Node methods on
LayoutStoreandLayoutMutationstake a leadingrootGraphId.graphIdlifts intoOperationMetaso all three entity bases inherit it.parseLayoutKeysplits on the first:rather than the last, so node ids containing:round-trip; graph ids are UUIDs and never contain one.This does not fix an id collision — there was never one to fix.
Subgraphshares the root graph'sstate, so one counter issues every node id, and root and interior nodes sharing a bucket is safe. What it buys is that a root graph's teardown becomes a singlelayoutStore.clearGraph(graphId)sitting beside the five peer stores already cleared there, instead of layout being the one exception that had to walk the subgraph tree.unregisterAllGraphLayoutstays for graphs that share the root's bucket — subgraphs, unconfigured graphs, orphaned subgraph release — and now mirrorsunregisterAllNodeStatesexactly.Worth a second opinion: six Vue-node composables now read
useCanvasStore().rootGraphIdwhere they previously only touched the layout singleton. They are all current-canvas-only paths, and the alternative pushesrootGraphId!non-null assertions into.vuetemplates.One consequence of that read is worth knowing about, since it caught me out. In
useNodeLayoutthe layout read must stay dynamic — the nodev-forkeys on a bare node id, so Vue patches a component across a graph change rather than remounting it, and a captured id would resolve stale. Ref cleanup must be the opposite:rootGraphIdflips before the outgoing graph's components unmount, so reading it inonUnmountedreleased the ref into the incoming bucket and stranded the real one. Captured at setup now, with a test pinning it. Only ids that do not survive a workflow load were affected; ids present in both are patched, never unmounted.Downstream stack
#14133 completes node geometry ownership after this PR establishes attach/detach lifetime. It makes the node
Rectanglea versioned projection oflayoutStore, reuses the shared geometry view for compatible mutablepos/sizeaccess, deletesuseLayoutSync, and replaces writeback with operation-driven resize notifications and canvas invalidation.Review this PR's registration and teardown contract independently of that downstream read-path change: this PR still retains
useLayoutSyncby design.Things an inattentive agent might call out but which are not valid findings
Each of these has been checked against the code. If you are about to file one, read the rebuttal first.
"Node layout entries are keyed by a bare node id with no graph scope, unlike groups and reroutes."
No longer true — they are scoped by
rootGraphId, as of the commit above. Note what that did and did not change: root and subgraph-interior nodes still share one bucket, and that is deliberate, because node ids are unique root-wide. Deserialized ids go throughdeduplicateSubgraphNodeIds, called fromLGraph.configurewhenisRootGraph, which remaps colliding interior ids and patches links and promoted widgets. Runtime-allocated ids come from++state.lastNodeId, andSubgraph.statereturnsrootGraph.state— one counter for the whole workflow. Clipboard paste and unpack have their own remapping.basic-subgraph.jsonlooks like a collision on disk (root2, interior1, 2) and loads as2,1,3.LGraph.test.tspins both halves:expect(subgraph.state).toBe(rootGraph.state)and'node IDs never collide between root and subgraph'.A repro that reaches a collision by assigning
node.iddirectly beforeadd()is not evidence —LGraph.add's duplicate guard is per-graph by design, and no production path assigns ids that way."
useLayoutSynccan now resolve a store change against the wrong node, because changes from unviewed graphs flush against the viewed graph."Same root cause as above, same rebuttal. Ids do not collide, so
getNodeByIdcannot resolve to a different node."
LGraph.addnow requires an active Pinia instance, breaking headless and extension use."layoutStoreis a plain module singleton, not a Pinia store, anduseLayoutMutationstouches nothing else.LGraph.addalready required Pinia before this PR viaregisterNodeStateanduseWidgetValueStore. Net change to Pinia surface: zero."
src/lib/litegraphimporting fromsrc/renderer/core/layoutviolates the layering boundary."import-x/no-restricted-pathsdeliberately scopes its zones tobase,platform,workbench, andworld; litegraph is outside them. ADR 0001 merged litegraph into the frontend precisely so mutations route through one CRDT-mediated access point.LGraph.tsalready importeduseLayoutMutationsandlayoutStore; this PR swaps a raw mutations import for a named registration module, leaving the edge count unchanged."Registering layout inside
LGraph.addis god-object growth onLGraph(ADR 0008)."No methods or properties are added to
LGraph,LGraphNode,LGraphCanvas, orSubgraph. Existing methods delegate to a module, and every write still lands as aLayoutOperationthroughapplyOperation— the command pattern is intact.clearGraphis likewise aClearGraphOperationdispatched throughapplyOperation, not a side-channel wipe."
deleteGroupanddeleteReroutegained an existence guard butdeleteNodedid not — inconsistent."deleteNodealready had the identical guard before this PR. Its absence from the diff is correct."Those existence guards are redundant with a check
applyOperationalready does."applyOperationcallsY.Map.deleteunconditionally and still bumpsversionand dispatches change listeners. The early return suppresses real churn."Moving the group loop after
this.remove(subgraphNode)inunpackSubgraphchanges behaviour."toSelectordering is unchanged,offsetX/offsetYare not mutated in between, and nothing in the intervening block reads groups. The move is required:remove()now triggersunregisterAllGraphLayout(subgraph), which would otherwise run after the unpacked groups registered and drop their entries."Populating
layoutStorewith the Vue renderer off breaks the minimap, which picks its data source by asking whether the store has nodes."That rationale is stale — it survived in a docstring longer than in the code.
MinimapDataSourceFactoryselects onLiteGraph.vueNodesMode, andMinimapDataSource.test.tshas an explicit regression test forbidding the emptiness check."
startSynccan be skipped on the immediate run when the canvas is not ready, and removingsetupEmptyGraphListenerloses the empty-graph deferral."startSyncno-ops safely when there is no graph, and the watcher re-fires whencanvasStore.currentGraphflips fromnull, which is reactive — unlike the oldcomfyApp.canvas?.graphsource thatsetupEmptyGraphListenerexisted to work around.stopSyncis idempotent. The deferral is obsolete, not lost."Dropping the
isInSubgraphwatcher's layout reset breaks subgraph navigation."canvasStore.currentGraphupdates on subgraph navigation, so the consolidated watcher covers it. Node membership comes fromnodeDataStore.getGraphNodesFor, which stays graph-scoped regardless."The new e2e spec uses
page.evaluateinstead of user actions."The regression under test is an extension calling
node.setSize()and the Vue node not moving. No user gesture reaches that path; driving the resize handle would exercise a different one and pass with the bug present.