Repository navigation
fix: clear widget-order and preview-exposure entries on node teardown - #14276
mattmillerai merged 2 commits into
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:
Comment |
📄 Knowledge reviewDosu skipped reviewing this PR because your organization has used its |
🎨 Storybook: ✅ Built — View Storybook🎭 Playwright: ✅ 1824 passed, 0 failed · 2 flaky📊 Browser Reports
📦 Bundle Size
⚡ Performance Report
Absolute values
Raw data{
"timestamp": "2026-08-15T23:58:02.557Z",
"gitSha": "924dc50468b7a0e5576da3b02859356b22be0b71",
"branch": "matt/be-5137-node-teardown-stores",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2021.4220000000296,
"styleRecalcs": 8,
"styleRecalcDurationMs": 5.958000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 457.03400000000005,
"heapDeltaBytes": 5638632,
"heapUsedBytes": 74168616,
"domNodes": 16,
"jsHeapTotalBytes": 21495808,
"scriptDurationMs": 7.739000000000001,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-idle",
"durationMs": 2034.9979999999732,
"styleRecalcs": 6,
"styleRecalcDurationMs": 5.661000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 556.9759999999999,
"heapDeltaBytes": 5712428,
"heapUsedBytes": 74330900,
"domNodes": 12,
"jsHeapTotalBytes": 20971520,
"scriptDurationMs": 9.650000000000002,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 2250.655999999992,
"styleRecalcs": 82,
"styleRecalcDurationMs": 51.066,
"layouts": 12,
"layoutDurationMs": 4.156,
"taskDurationMs": 1277.004,
"heapDeltaBytes": -4647612,
"heapUsedBytes": 63981316,
"domNodes": -282,
"jsHeapTotalBytes": 21860352,
"scriptDurationMs": 144.791,
"eventListeners": -157,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "canvas-mouse-sweep",
"durationMs": 2274.811999999997,
"styleRecalcs": 82,
"styleRecalcDurationMs": 47.772999999999996,
"layouts": 12,
"layoutDurationMs": 4.149,
"taskDurationMs": 1280.2930000000001,
"heapDeltaBytes": -5779392,
"heapUsedBytes": 62730952,
"domNodes": -282,
"jsHeapTotalBytes": 20287488,
"scriptDurationMs": 149.114,
"eventListeners": -155,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1738.5140000000092,
"styleRecalcs": 31,
"styleRecalcDurationMs": 14.885,
"layouts": 6,
"layoutDurationMs": 0.6539999999999999,
"taskDurationMs": 364.433,
"heapDeltaBytes": 8605564,
"heapUsedBytes": 77196620,
"domNodes": 77,
"jsHeapTotalBytes": 21495808,
"scriptDurationMs": 10.668000000000001,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1742.260999999985,
"styleRecalcs": 30,
"styleRecalcDurationMs": 17.131,
"layouts": 6,
"layoutDurationMs": 0.727,
"taskDurationMs": 384.50600000000003,
"heapDeltaBytes": 8560152,
"heapUsedBytes": 77142516,
"domNodes": 75,
"jsHeapTotalBytes": 21495808,
"scriptDurationMs": 10.866,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "dom-widget-clipping",
"durationMs": 737.7349999999865,
"styleRecalcs": 11,
"styleRecalcDurationMs": 7.146,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 423.09200000000004,
"heapDeltaBytes": -3860052,
"heapUsedBytes": 64646696,
"domNodes": 18,
"jsHeapTotalBytes": 22282240,
"scriptDurationMs": 32.102,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "dom-widget-clipping",
"durationMs": 719.2380000000185,
"styleRecalcs": 8,
"styleRecalcDurationMs": 4.735999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 438.31499999999994,
"heapDeltaBytes": -3082472,
"heapUsedBytes": 65493600,
"domNodes": 12,
"jsHeapTotalBytes": 21757952,
"scriptDurationMs": 33.612,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "large-graph-idle",
"durationMs": 2033.6189999999874,
"styleRecalcs": 7,
"styleRecalcDurationMs": 5.117999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 538.8870000000002,
"heapDeltaBytes": 6724228,
"heapUsedBytes": 69612436,
"domNodes": -282,
"jsHeapTotalBytes": -1736704,
"scriptDurationMs": 29.068000000000005,
"eventListeners": -155,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2039.4680000000562,
"styleRecalcs": 5,
"styleRecalcDurationMs": 3.6850000000000027,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 559.359,
"heapDeltaBytes": 4398164,
"heapUsedBytes": 67295612,
"domNodes": -282,
"jsHeapTotalBytes": -1998848,
"scriptDurationMs": 30.186000000000003,
"eventListeners": -153,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 3204.272000000003,
"styleRecalcs": 65,
"styleRecalcDurationMs": 11.181,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2235.8879999999995,
"heapDeltaBytes": 10159732,
"heapUsedBytes": 74018684,
"domNodes": -285,
"jsHeapTotalBytes": 3174400,
"scriptDurationMs": 737.369,
"eventListeners": -151,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-pan",
"durationMs": 3200.1430000000255,
"styleRecalcs": 66,
"styleRecalcDurationMs": 11.892,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2311.257,
"heapDeltaBytes": 2407880,
"heapUsedBytes": 66119708,
"domNodes": -283,
"jsHeapTotalBytes": 2387968,
"scriptDurationMs": 776.32,
"eventListeners": -151,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 4197.289000000012,
"styleRecalcs": 68,
"styleRecalcDurationMs": 13.679,
"layouts": 60,
"layoutDurationMs": 8.249,
"taskDurationMs": 2226.989,
"heapDeltaBytes": 21425072,
"heapUsedBytes": 88743160,
"domNodes": 28,
"jsHeapTotalBytes": 4718592,
"scriptDurationMs": 730.94,
"eventListeners": 12,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 4416.111000000001,
"styleRecalcs": 68,
"styleRecalcDurationMs": 14.793999999999999,
"layouts": 60,
"layoutDurationMs": 8.819,
"taskDurationMs": 2456.067,
"heapDeltaBytes": -5581616,
"heapUsedBytes": 61976564,
"domNodes": -267,
"jsHeapTotalBytes": 2195456,
"scriptDurationMs": 769.359,
"eventListeners": -183,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "legacy-node-drag",
"durationMs": 3195.0120000000197,
"styleRecalcs": 42,
"styleRecalcDurationMs": 6.662000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2015.5069999999998,
"heapDeltaBytes": -336900,
"heapUsedBytes": 67793336,
"domNodes": -286,
"jsHeapTotalBytes": 6807552,
"scriptDurationMs": 214.61300000000003,
"eventListeners": -156,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "legacy-node-drag",
"durationMs": 3509.0450000000146,
"styleRecalcs": 43,
"styleRecalcDurationMs": 7.456,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2352.43,
"heapDeltaBytes": -7747044,
"heapUsedBytes": 55841468,
"domNodes": -286,
"jsHeapTotalBytes": 5865472,
"scriptDurationMs": 272.895,
"eventListeners": -139,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 2019.0620000000195,
"styleRecalcs": 4,
"styleRecalcDurationMs": 3.057999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 551.9859999999999,
"heapDeltaBytes": 4680912,
"heapUsedBytes": 68395688,
"domNodes": -282,
"jsHeapTotalBytes": -2523136,
"scriptDurationMs": 33.17700000000001,
"eventListeners": -155,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 2016.1500000000387,
"styleRecalcs": 4,
"styleRecalcDurationMs": 3.962999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 709.7789999999999,
"heapDeltaBytes": 2657256,
"heapUsedBytes": 67036404,
"domNodes": -286,
"jsHeapTotalBytes": 1409024,
"scriptDurationMs": 35.22999999999999,
"eventListeners": -183,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 777.6569999999765,
"styleRecalcs": 46,
"styleRecalcDurationMs": 13.152,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 577.9730000000001,
"heapDeltaBytes": -5413364,
"heapUsedBytes": 63923540,
"domNodes": 18,
"jsHeapTotalBytes": 22020096,
"scriptDurationMs": 145.51600000000002,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 773.3729999999923,
"styleRecalcs": 45,
"styleRecalcDurationMs": 9.286,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 546.261,
"heapDeltaBytes": -4942740,
"heapUsedBytes": 64299964,
"domNodes": 16,
"jsHeapTotalBytes": 22282240,
"scriptDurationMs": 141.66899999999998,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 1994.436999999948,
"styleRecalcs": 8,
"styleRecalcDurationMs": 5.7459999999999996,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 433.37499999999994,
"heapDeltaBytes": 5743164,
"heapUsedBytes": 75191784,
"domNodes": 16,
"jsHeapTotalBytes": 20709376,
"scriptDurationMs": 6.572000000000002,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-idle",
"durationMs": 2050.591999999938,
"styleRecalcs": 9,
"styleRecalcDurationMs": 7.827000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 511.05999999999995,
"heapDeltaBytes": 5746968,
"heapUsedBytes": 75066688,
"domNodes": 18,
"jsHeapTotalBytes": 20971520,
"scriptDurationMs": 15.262999999999998,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1872.4970000000098,
"styleRecalcs": 78,
"styleRecalcDurationMs": 36.57,
"layouts": 16,
"layoutDurationMs": 4.594,
"taskDurationMs": 1081.226,
"heapDeltaBytes": -13746564,
"heapUsedBytes": 55384284,
"domNodes": -296,
"jsHeapTotalBytes": 20418560,
"scriptDurationMs": 97.176,
"eventListeners": -203,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1880.4470000000038,
"styleRecalcs": 77,
"styleRecalcDurationMs": 38.86600000000001,
"layouts": 16,
"layoutDurationMs": 4.965,
"taskDurationMs": 1121.7540000000001,
"heapDeltaBytes": -13383640,
"heapUsedBytes": 55807028,
"domNodes": -298,
"jsHeapTotalBytes": 20942848,
"scriptDurationMs": 109.318,
"eventListeners": -203,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-transition-enter",
"durationMs": 1402.5270000000774,
"styleRecalcs": 19,
"styleRecalcDurationMs": 29.659999999999993,
"layouts": 15,
"layoutDurationMs": 11.515,
"taskDurationMs": 1014.229,
"heapDeltaBytes": -9515000,
"heapUsedBytes": 76330812,
"domNodes": 13671,
"jsHeapTotalBytes": 9961472,
"scriptDurationMs": 22.60799999999999,
"eventListeners": 2383,
"totalBlockingTimeMs": 117,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 12219.30999999995,
"styleRecalcs": 247,
"styleRecalcDurationMs": 40.01,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 7670.727,
"heapDeltaBytes": -4578300,
"heapUsedBytes": 57954256,
"domNodes": -282,
"jsHeapTotalBytes": 3506176,
"scriptDurationMs": 2455.447,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 12422.674999999912,
"styleRecalcs": 246,
"styleRecalcDurationMs": 40.856,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8604.331999999999,
"heapDeltaBytes": -4448456,
"heapUsedBytes": 58483820,
"domNodes": -285,
"jsHeapTotalBytes": 2719744,
"scriptDurationMs": 2712.305,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 18507.50300000004,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 17738.677,
"heapDeltaBytes": -25968640,
"heapUsedBytes": 165926444,
"domNodes": -6548,
"jsHeapTotalBytes": 3727360,
"scriptDurationMs": 246.31499999999997,
"eventListeners": -7471,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.780000000000047,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 18055.366999999933,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 17448.775,
"heapDeltaBytes": -42701324,
"heapUsedBytes": 164113252,
"domNodes": -6548,
"jsHeapTotalBytes": 1368064,
"scriptDurationMs": 230.337,
"eventListeners": -7467,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.77333333333336,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-large-graph-pan",
"durationMs": 22342.284000000007,
"styleRecalcs": 171,
"styleRecalcDurationMs": 22.32600000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 22080.069000000003,
"heapDeltaBytes": -3396104,
"heapUsedBytes": 175231176,
"domNodes": -6548,
"jsHeapTotalBytes": 2347008,
"scriptDurationMs": 771.828,
"eventListeners": -7465,
"totalBlockingTimeMs": 90,
"frameDurationMs": 17.776666666666763,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 22545.338000000014,
"styleRecalcs": 175,
"styleRecalcDurationMs": 21.417999999999992,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 22162.836,
"heapDeltaBytes": -37241032,
"heapUsedBytes": 155456032,
"domNodes": -6548,
"jsHeapTotalBytes": 1892352,
"scriptDurationMs": 769.302,
"eventListeners": -7465,
"totalBlockingTimeMs": 172,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "workflow-execution",
"durationMs": 467.7649999999858,
"styleRecalcs": 13,
"styleRecalcDurationMs": 23.226,
"layouts": 4,
"layoutDurationMs": 1.5399999999999998,
"taskDurationMs": 140.727,
"heapDeltaBytes": -14005104,
"heapUsedBytes": 52156608,
"domNodes": 120,
"jsHeapTotalBytes": 10223616,
"scriptDurationMs": 8.991000000000003,
"eventListeners": 97,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "workflow-execution",
"durationMs": 483.56200000000626,
"styleRecalcs": 15,
"styleRecalcDurationMs": 24.166,
"layouts": 3,
"layoutDurationMs": 0.803,
"taskDurationMs": 135.034,
"heapDeltaBytes": 5367932,
"heapUsedBytes": 71759256,
"domNodes": 121,
"jsHeapTotalBytes": 5505024,
"scriptDurationMs": 9.708000000000002,
"eventListeners": 97,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.800000000000182
}
]
} |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## matt/be-5050-node-shell-state #14276 +/- ##
================================================================
Coverage ? 81.96%
================================================================
Files ? 1902
Lines ? 116021
Branches ? 33354
================================================================
Hits ? 95100
Misses ? 20474
Partials ? 447
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
Found 6 finding(s).
| Severity | Count |
|---|---|
| 🟠 High | 1 |
| 🟡 Medium | 2 |
| 🟢 Low | 3 |
Panel: 8/8 reviewers contributed findings.
|
STACKED — merging lands on Review pass on the 6 cursor-review findings: Fixed (0a9ee19) — widget release now reads the node's order record in Not changed, with evidence on each thread — the zero-uuid cross-graph delete (only two No follow-ups filed — the unreachable findings would be hardening against cases current code can't produce. |
950e26e to
7ca4449
Compare
b7423a4 to
a2f0cb3
Compare
7ca4449 to
af6567c
Compare
attachNodeToStores registers a node's shell state, widget bindings and widget order, but every teardown path only undid the shell state, so widget-order and preview-exposure entries orphaned in the shared root bucket until the whole root graph was wiped. Add detachNodeFromStores as the exact inverse of attachNodeToStores and route LGraph.remove and the graph-wide walk through it. Single-node removal keeps stored widget values (it may be undone); a graph or subgraph-definition teardown discards them, matching the whole-bucket wipe a root graph already performs.
releaseNodeWidgets derived the ids to clean from node.widgets, which diverges from what the store tracks: PrimitiveNode empties its widget array (widgetInputs._removeWidgets) without unregistering, so removing that node left its order and value entries behind — the leak this change set out to close. Move the release into widgetValueStore, keyed by the node's own order record, which registerWidget keeps authoritative. Ids no longer round-trip through parseWidgetId either, so an un-keyable id can't throw mid-teardown.
|
STACKED — merging lands on Rebased onto the current tip of #14257 to resolve the merge conflict (that branch was force-pushed/rebased after this PR branched off it). Also fixed: #14257's own rebase left |
a2f0cb3 to
b5efa00
Compare
6ae10d9
into
matt/be-5050-node-shell-state
…#14276) **STACKED — merging lands on `matt/be-5050-node-shell-state` (owned by @mattmillerai), NOT `main`.** That branch is itself based on `feature/ecs-migration`, where `src/core/graph/nodeShell/` lives. Do not merge before its parent lands; GitHub retargets this PR as the stack unwinds. ## ELI-5 When a node joins a graph we write it into three places: its shell state, its widget bindings, and its widget ordering (plus preview exposures accumulate against the same bucket). When a node left, we only erased the first one. The leftovers piled up in a bucket shared by the whole workflow and stayed there until the entire graph was thrown away. This adds the missing "undo" for the other two and points every teardown path at it. ## Summary `attachNodeToStores` registers three things; every teardown path only undid one, so widget-order and preview-exposure entries orphaned in the shared root-graph bucket. This adds `detachNodeFromStores` as its exact inverse and routes the teardown paths through it. ## Changes - **What**: New `detachNodeFromStores(graph, node, mode)` in `nodeShellLifecycle.ts` — unregisters the shell state, removes each `getWidgetIds(node.widgets)` entry from the widget order, and clears the node's preview exposures (`String(node.id)` host locator, the same key `promotionUtils`/`SubgraphNode` write under). `unregisterAllNodeStates` moves out of `nodeShellState.ts` and becomes `detachAllNodesFromStores` in the same module — it needs the root graph to reach those buckets, so it now takes the graph (which carries `rootGraph`) rather than just `_nodes`/`_subgraphs`. Call sites: `LGraph.remove` (both the per-node teardown and the released-subgraph-definition walk) and `releaseGraphStores`'s non-root branch. - **Breaking**: none — `unregisterAllNodeStates` had exactly one external caller (`LGraph.ts`), and no behavior the extension surface can observe changes. ## Reachability the leak had (all three are load-bearing, not theoretical) - Subgraphs always take the non-root `else` branch of `releaseGraphStores`, and `LGraph.configure` calls `clear()` first — so re-configuring a subgraph orphaned its nodes' entries. - `clear()` sets `id = zeroUuid` on exit, so a root graph whose serialized data carries no id keeps taking the `else` branch for the rest of the session. - Plain `LGraph.remove(node)` leaked per-node on every branch, since it never removed the widget order it added. ## Review Focus **The judgment call the ticket left open — `deleteWidget` vs `removeNodeWidgetOrder` — is decided per call site, and both are covered by tests.** `LGraph.remove(node)` drops only the ordering and **keeps** the stored widget values: a single node removal feeds undo/redo and a node moved between graphs (`remove` then `add`) must not lose its values. Graph and subgraph-definition teardown (`detachAllNodesFromStores`) **discards** them, which is what the root branch already does one line up — `clearGraph` on `widgetValueStore` wipes that graph's widget states wholesale, so the non-root path was the inconsistent one. **Riskiest line: `deleteWidget` in the discard path**, because it is the one edit that removes data rather than an index. It is safe because `deleteWidget` only drops the store's map entry — the widget instance's `_state` object is untouched, so a widget that survives the clear still reads its own value, and re-registration (`setNodeId` → `registerWidget`) writes it back from the widget/serialized data rather than from store leftovers. Without this, a re-configure would silently reuse the *stale* store value: `registerWidget` returns the existing state when the type matches and ignores the incoming `init.value`. **Deliberately not routed through the new helper:** `useNodeReplacement.replaceWithMapping`. It calls `unregisterNodeState`/`registerNodeState` for an in-place swap where the new node inherits the same id and re-registers the same widgets — clearing exposures there would drop a replaced host node's promoted previews. It is a replacement, not a teardown. **Deviation from the ticket's sketch:** preview exposures are cleared with `setExposures(rootGraphId, locator, [])` (guarded by a `getExposures(...).length` read) rather than a `removeExposure` per name. Same result, one write instead of N, and the guard keeps the reactive `exposures` ref from being touched on every ordinary node deletion. ## Verification New `src/core/graph/nodeShell/nodeShellLifecycle.test.ts` covers all three: widget order dropped and values kept on `subgraph.remove(node)`; exposures dropped when a host `SubgraphNode` is removed; order, values and exposures all released when a zero-uuid root graph is cleared. **All three fail on the base branch** (verified by stashing the source change and re-running — `expected [ Array(1) ] to deeply equal []`). `vitest run src/lib/litegraph src/core/graph src/platform/nodeReplacement src/stores/widgetValueStore.test.ts src/composables/node` — 1591 passed. `pnpm typecheck`, `pnpm knip`, eslint and oxfmt on the changed files: clean.
…#14276) **STACKED — merging lands on `matt/be-5050-node-shell-state` (owned by @mattmillerai), NOT `main`.** That branch is itself based on `feature/ecs-migration`, where `src/core/graph/nodeShell/` lives. Do not merge before its parent lands; GitHub retargets this PR as the stack unwinds. ## ELI-5 When a node joins a graph we write it into three places: its shell state, its widget bindings, and its widget ordering (plus preview exposures accumulate against the same bucket). When a node left, we only erased the first one. The leftovers piled up in a bucket shared by the whole workflow and stayed there until the entire graph was thrown away. This adds the missing "undo" for the other two and points every teardown path at it. ## Summary `attachNodeToStores` registers three things; every teardown path only undid one, so widget-order and preview-exposure entries orphaned in the shared root-graph bucket. This adds `detachNodeFromStores` as its exact inverse and routes the teardown paths through it. ## Changes - **What**: New `detachNodeFromStores(graph, node, mode)` in `nodeShellLifecycle.ts` — unregisters the shell state, removes each `getWidgetIds(node.widgets)` entry from the widget order, and clears the node's preview exposures (`String(node.id)` host locator, the same key `promotionUtils`/`SubgraphNode` write under). `unregisterAllNodeStates` moves out of `nodeShellState.ts` and becomes `detachAllNodesFromStores` in the same module — it needs the root graph to reach those buckets, so it now takes the graph (which carries `rootGraph`) rather than just `_nodes`/`_subgraphs`. Call sites: `LGraph.remove` (both the per-node teardown and the released-subgraph-definition walk) and `releaseGraphStores`'s non-root branch. - **Breaking**: none — `unregisterAllNodeStates` had exactly one external caller (`LGraph.ts`), and no behavior the extension surface can observe changes. ## Reachability the leak had (all three are load-bearing, not theoretical) - Subgraphs always take the non-root `else` branch of `releaseGraphStores`, and `LGraph.configure` calls `clear()` first — so re-configuring a subgraph orphaned its nodes' entries. - `clear()` sets `id = zeroUuid` on exit, so a root graph whose serialized data carries no id keeps taking the `else` branch for the rest of the session. - Plain `LGraph.remove(node)` leaked per-node on every branch, since it never removed the widget order it added. ## Review Focus **The judgment call the ticket left open — `deleteWidget` vs `removeNodeWidgetOrder` — is decided per call site, and both are covered by tests.** `LGraph.remove(node)` drops only the ordering and **keeps** the stored widget values: a single node removal feeds undo/redo and a node moved between graphs (`remove` then `add`) must not lose its values. Graph and subgraph-definition teardown (`detachAllNodesFromStores`) **discards** them, which is what the root branch already does one line up — `clearGraph` on `widgetValueStore` wipes that graph's widget states wholesale, so the non-root path was the inconsistent one. **Riskiest line: `deleteWidget` in the discard path**, because it is the one edit that removes data rather than an index. It is safe because `deleteWidget` only drops the store's map entry — the widget instance's `_state` object is untouched, so a widget that survives the clear still reads its own value, and re-registration (`setNodeId` → `registerWidget`) writes it back from the widget/serialized data rather than from store leftovers. Without this, a re-configure would silently reuse the *stale* store value: `registerWidget` returns the existing state when the type matches and ignores the incoming `init.value`. **Deliberately not routed through the new helper:** `useNodeReplacement.replaceWithMapping`. It calls `unregisterNodeState`/`registerNodeState` for an in-place swap where the new node inherits the same id and re-registers the same widgets — clearing exposures there would drop a replaced host node's promoted previews. It is a replacement, not a teardown. **Deviation from the ticket's sketch:** preview exposures are cleared with `setExposures(rootGraphId, locator, [])` (guarded by a `getExposures(...).length` read) rather than a `removeExposure` per name. Same result, one write instead of N, and the guard keeps the reactive `exposures` ref from being touched on every ordinary node deletion. ## Verification New `src/core/graph/nodeShell/nodeShellLifecycle.test.ts` covers all three: widget order dropped and values kept on `subgraph.remove(node)`; exposures dropped when a host `SubgraphNode` is removed; order, values and exposures all released when a zero-uuid root graph is cleared. **All three fail on the base branch** (verified by stashing the source change and re-running — `expected [ Array(1) ] to deeply equal []`). `vitest run src/lib/litegraph src/core/graph src/platform/nodeReplacement src/stores/widgetValueStore.test.ts src/composables/node` — 1591 passed. `pnpm typecheck`, `pnpm knip`, eslint and oxfmt on the changed files: clean. Amp-Thread-ID: https://ampcode.com/threads/T-01a027af-1c32-7532-84f9-b94aa90620fa
…#14276) **STACKED — merging lands on `matt/be-5050-node-shell-state` (owned by @mattmillerai), NOT `main`.** That branch is itself based on `feature/ecs-migration`, where `src/core/graph/nodeShell/` lives. Do not merge before its parent lands; GitHub retargets this PR as the stack unwinds. ## ELI-5 When a node joins a graph we write it into three places: its shell state, its widget bindings, and its widget ordering (plus preview exposures accumulate against the same bucket). When a node left, we only erased the first one. The leftovers piled up in a bucket shared by the whole workflow and stayed there until the entire graph was thrown away. This adds the missing "undo" for the other two and points every teardown path at it. ## Summary `attachNodeToStores` registers three things; every teardown path only undid one, so widget-order and preview-exposure entries orphaned in the shared root-graph bucket. This adds `detachNodeFromStores` as its exact inverse and routes the teardown paths through it. ## Changes - **What**: New `detachNodeFromStores(graph, node, mode)` in `nodeShellLifecycle.ts` — unregisters the shell state, removes each `getWidgetIds(node.widgets)` entry from the widget order, and clears the node's preview exposures (`String(node.id)` host locator, the same key `promotionUtils`/`SubgraphNode` write under). `unregisterAllNodeStates` moves out of `nodeShellState.ts` and becomes `detachAllNodesFromStores` in the same module — it needs the root graph to reach those buckets, so it now takes the graph (which carries `rootGraph`) rather than just `_nodes`/`_subgraphs`. Call sites: `LGraph.remove` (both the per-node teardown and the released-subgraph-definition walk) and `releaseGraphStores`'s non-root branch. - **Breaking**: none — `unregisterAllNodeStates` had exactly one external caller (`LGraph.ts`), and no behavior the extension surface can observe changes. ## Reachability the leak had (all three are load-bearing, not theoretical) - Subgraphs always take the non-root `else` branch of `releaseGraphStores`, and `LGraph.configure` calls `clear()` first — so re-configuring a subgraph orphaned its nodes' entries. - `clear()` sets `id = zeroUuid` on exit, so a root graph whose serialized data carries no id keeps taking the `else` branch for the rest of the session. - Plain `LGraph.remove(node)` leaked per-node on every branch, since it never removed the widget order it added. ## Review Focus **The judgment call the ticket left open — `deleteWidget` vs `removeNodeWidgetOrder` — is decided per call site, and both are covered by tests.** `LGraph.remove(node)` drops only the ordering and **keeps** the stored widget values: a single node removal feeds undo/redo and a node moved between graphs (`remove` then `add`) must not lose its values. Graph and subgraph-definition teardown (`detachAllNodesFromStores`) **discards** them, which is what the root branch already does one line up — `clearGraph` on `widgetValueStore` wipes that graph's widget states wholesale, so the non-root path was the inconsistent one. **Riskiest line: `deleteWidget` in the discard path**, because it is the one edit that removes data rather than an index. It is safe because `deleteWidget` only drops the store's map entry — the widget instance's `_state` object is untouched, so a widget that survives the clear still reads its own value, and re-registration (`setNodeId` → `registerWidget`) writes it back from the widget/serialized data rather than from store leftovers. Without this, a re-configure would silently reuse the *stale* store value: `registerWidget` returns the existing state when the type matches and ignores the incoming `init.value`. **Deliberately not routed through the new helper:** `useNodeReplacement.replaceWithMapping`. It calls `unregisterNodeState`/`registerNodeState` for an in-place swap where the new node inherits the same id and re-registers the same widgets — clearing exposures there would drop a replaced host node's promoted previews. It is a replacement, not a teardown. **Deviation from the ticket's sketch:** preview exposures are cleared with `setExposures(rootGraphId, locator, [])` (guarded by a `getExposures(...).length` read) rather than a `removeExposure` per name. Same result, one write instead of N, and the guard keeps the reactive `exposures` ref from being touched on every ordinary node deletion. ## Verification New `src/core/graph/nodeShell/nodeShellLifecycle.test.ts` covers all three: widget order dropped and values kept on `subgraph.remove(node)`; exposures dropped when a host `SubgraphNode` is removed; order, values and exposures all released when a zero-uuid root graph is cleared. **All three fail on the base branch** (verified by stashing the source change and re-running — `expected [ Array(1) ] to deeply equal []`). `vitest run src/lib/litegraph src/core/graph src/platform/nodeReplacement src/stores/widgetValueStore.test.ts src/composables/node` — 1591 passed. `pnpm typecheck`, `pnpm knip`, eslint and oxfmt on the changed files: clean. Amp-Thread-ID: https://ampcode.com/threads/T-01a027af-1c32-7532-84f9-b94aa90620fa
STACKED — merging lands on
matt/be-5050-node-shell-state(owned by @mattmillerai), NOTmain. That branch is itself based onfeature/ecs-migration, wheresrc/core/graph/nodeShell/lives. Do not merge before its parent lands; GitHub retargets this PR as the stack unwinds.ELI-5
When a node joins a graph we write it into three places: its shell state, its widget bindings, and its widget ordering (plus preview exposures accumulate against the same bucket). When a node left, we only erased the first one. The leftovers piled up in a bucket shared by the whole workflow and stayed there until the entire graph was thrown away. This adds the missing "undo" for the other two and points every teardown path at it.
Summary
attachNodeToStoresregisters three things; every teardown path only undid one, so widget-order and preview-exposure entries orphaned in the shared root-graph bucket. This addsdetachNodeFromStoresas its exact inverse and routes the teardown paths through it.Changes
detachNodeFromStores(graph, node, mode)innodeShellLifecycle.ts— unregisters the shell state, removes eachgetWidgetIds(node.widgets)entry from the widget order, and clears the node's preview exposures (String(node.id)host locator, the same keypromotionUtils/SubgraphNodewrite under).unregisterAllNodeStatesmoves out ofnodeShellState.tsand becomesdetachAllNodesFromStoresin the same module — it needs the root graph to reach those buckets, so it now takes the graph (which carriesrootGraph) rather than just_nodes/_subgraphs. Call sites:LGraph.remove(both the per-node teardown and the released-subgraph-definition walk) andreleaseGraphStores's non-root branch.unregisterAllNodeStateshad exactly one external caller (LGraph.ts), and no behavior the extension surface can observe changes.Reachability the leak had (all three are load-bearing, not theoretical)
elsebranch ofreleaseGraphStores, andLGraph.configurecallsclear()first — so re-configuring a subgraph orphaned its nodes' entries.clear()setsid = zeroUuidon exit, so a root graph whose serialized data carries no id keeps taking theelsebranch for the rest of the session.LGraph.remove(node)leaked per-node on every branch, since it never removed the widget order it added.Review Focus
The judgment call the ticket left open —
deleteWidgetvsremoveNodeWidgetOrder— is decided per call site, and both are covered by tests.LGraph.remove(node)drops only the ordering and keeps the stored widget values: a single node removal feeds undo/redo and a node moved between graphs (removethenadd) must not lose its values. Graph and subgraph-definition teardown (detachAllNodesFromStores) discards them, which is what the root branch already does one line up —clearGraphonwidgetValueStorewipes that graph's widget states wholesale, so the non-root path was the inconsistent one.Riskiest line:
deleteWidgetin the discard path, because it is the one edit that removes data rather than an index. It is safe becausedeleteWidgetonly drops the store's map entry — the widget instance's_stateobject is untouched, so a widget that survives the clear still reads its own value, and re-registration (setNodeId→registerWidget) writes it back from the widget/serialized data rather than from store leftovers. Without this, a re-configure would silently reuse the stale store value:registerWidgetreturns the existing state when the type matches and ignores the incominginit.value.Deliberately not routed through the new helper:
useNodeReplacement.replaceWithMapping. It callsunregisterNodeState/registerNodeStatefor an in-place swap where the new node inherits the same id and re-registers the same widgets — clearing exposures there would drop a replaced host node's promoted previews. It is a replacement, not a teardown.Deviation from the ticket's sketch: preview exposures are cleared with
setExposures(rootGraphId, locator, [])(guarded by agetExposures(...).lengthread) rather than aremoveExposureper name. Same result, one write instead of N, and the guard keeps the reactiveexposuresref from being touched on every ordinary node deletion.Verification
New
src/core/graph/nodeShell/nodeShellLifecycle.test.tscovers all three: widget order dropped and values kept onsubgraph.remove(node); exposures dropped when a hostSubgraphNodeis removed; order, values and exposures all released when a zero-uuid root graph is cleared. All three fail on the base branch (verified by stashing the source change and re-running —expected [ Array(1) ] to deeply equal []).vitest run src/lib/litegraph src/core/graph src/platform/nodeReplacement src/stores/widgetValueStore.test.ts src/composables/node— 1591 passed.pnpm typecheck,pnpm knip, eslint and oxfmt on the changed files: clean.