Repository navigation
fix: restore SubgraphNode.widgets_values dead-field invariant (#10849 regression) - #11559
dante01yoon wants to merge 18 commits into
Conversation
…10849) Reproduces the Z-Image-Turbo regression: SubgraphNode.serialize writes widgets_values and SubgraphNode.configure applies it positionally to promoted widgets, corrupting pre-existing templates whose widgets_values was never produced by the promoted-widget save path. Both tests assert the pre-#10849 invariant that widgets_values on a SubgraphNode must remain a dead field.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughPromoted-widget per-instance values are moved into Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant SubgraphNode
participant PromotedView
participant Serializer
Client->>SubgraphNode: request serialize()
SubgraphNode->>PromotedView: query promotion identity / instanceKey
PromotedView-->>SubgraphNode: return instanceKey and per-instance state (if any)
alt has per-instance value
SubgraphNode->>Serializer: emit proxyWidgets entry [id, name, null, {value}]
else no per-instance value
SubgraphNode->>Serializer: emit proxyWidgets entry [id, name] or [id, name, ...]
end
Serializer-->>Client: return payload (without widgets_values)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 6 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎨 Storybook: ✅ Built — View Storybook |
🎭 Playwright: ✅ 1426 passed, 0 failed📊 Browser Reports
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/litegraph/src/subgraph/SubgraphNode.multiInstance.test.ts`:
- Around line 262-302: The existing test that currently expects
serialize().widgets_values to equal [10] and [20] must be updated to expect
undefined to match the new behavior; locate the test that uses
serialize().widgets_values (the one alongside serializeValue and round-trip
assertions) and change those direct widgets_values assertions to expect
undefined (leave serializeValue and round-trip tests unchanged), ensuring the
test names remain the same so it still verifies per-instance value preservation
while no longer asserting a top-level widgets_values array on SubgraphNode.
🪄 Autofix (Beta)
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: CHILL
Plan: Pro
Run ID: f15da234-8042-4877-b801-b43d2cdee2c1
📒 Files selected for processing (1)
src/lib/litegraph/src/subgraph/SubgraphNode.multiInstance.test.ts
📦 Bundle: 5.23 MB gzip 🔴 +1.45 kBDetailsSummary
Category Glance App Entry Points — 22.5 kB (baseline 22.5 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.24 MB (baseline 1.24 MB) • 🔴 +142 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 77.7 kB (baseline 77.7 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 9 added / 9 removed / 2 unchanged Panels & Settings — 488 kB (baseline 488 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 10 added / 10 removed / 11 unchanged User & Accounts — 17.4 kB (baseline 17.4 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 5 added / 5 removed / 2 unchanged Editors & Dialogs — 113 kB (baseline 113 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 4 added / 4 removed UI Components — 61 kB (baseline 61 kB) • ⚪ 0 BReusable component library chunks
Status: 5 added / 5 removed / 8 unchanged Data & Services — 3.04 MB (baseline 3.04 MB) • 🔴 +3.15 kBStores, services, APIs, and repositories
Status: 13 added / 13 removed / 4 unchanged Utilities & Hooks — 364 kB (baseline 364 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 13 added / 13 removed / 18 unchanged Vendor & Third-Party — 9.88 MB (baseline 9.88 MB) • 🔴 +861 BExternal libraries and shared vendor chunks
Status: 1 added / 1 removed / 15 unchanged Other — 8.83 MB (baseline 8.83 MB) • ⚪ 0 BBundles that do not match a named category
Status: 58 added / 58 removed / 77 unchanged ⚡ Performance Report
No regressions detected. All metrics
Historical variance (last 15 runs)
Trend (last 15 commits on main)
Raw data{
"timestamp": "2026-04-29T06:01:34.351Z",
"gitSha": "045a6c35d0ed7a17d3927f440d6158d73528dc36",
"branch": "fix/subgraph-promoted-widget-inline-state",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2052.6089999999613,
"styleRecalcs": 11,
"styleRecalcDurationMs": 9.547000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 390.77099999999996,
"heapDeltaBytes": 1130632,
"heapUsedBytes": 67292540,
"domNodes": 22,
"jsHeapTotalBytes": 19234816,
"scriptDurationMs": 23.977999999999998,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-idle",
"durationMs": 2013.826999999992,
"styleRecalcs": 9,
"styleRecalcDurationMs": 8.546999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 351.551,
"heapDeltaBytes": 22925828,
"heapUsedBytes": 71584996,
"domNodes": 18,
"jsHeapTotalBytes": 14417920,
"scriptDurationMs": 17.405000000000005,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-idle",
"durationMs": 2003.9379999999483,
"styleRecalcs": 11,
"styleRecalcDurationMs": 8.812999999999997,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 345.831,
"heapDeltaBytes": 1221380,
"heapUsedBytes": 67301488,
"domNodes": 22,
"jsHeapTotalBytes": 19759104,
"scriptDurationMs": 19.970000000000002,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1921.3320000000067,
"styleRecalcs": 77,
"styleRecalcDurationMs": 43.38,
"layouts": 12,
"layoutDurationMs": 3.8120000000000003,
"taskDurationMs": 822.827,
"heapDeltaBytes": -1755428,
"heapUsedBytes": 66641424,
"domNodes": 62,
"jsHeapTotalBytes": 20185088,
"scriptDurationMs": 126.01199999999999,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1811.2179999999398,
"styleRecalcs": 75,
"styleRecalcDurationMs": 36.257,
"layouts": 12,
"layoutDurationMs": 3.8989999999999996,
"taskDurationMs": 814.6379999999999,
"heapDeltaBytes": -20780172,
"heapUsedBytes": 45262944,
"domNodes": -259,
"jsHeapTotalBytes": 20410368,
"scriptDurationMs": 119.175,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1875.774999999976,
"styleRecalcs": 77,
"styleRecalcDurationMs": 39.167,
"layouts": 12,
"layoutDurationMs": 3.6929999999999996,
"taskDurationMs": 839.477,
"heapDeltaBytes": -13866788,
"heapUsedBytes": 52686180,
"domNodes": -258,
"jsHeapTotalBytes": 19099648,
"scriptDurationMs": 127.40700000000002,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1741.9759999999656,
"styleRecalcs": 30,
"styleRecalcDurationMs": 18.185,
"layouts": 6,
"layoutDurationMs": 0.652,
"taskDurationMs": 330.055,
"heapDeltaBytes": 5932100,
"heapUsedBytes": 71918596,
"domNodes": 79,
"jsHeapTotalBytes": 19759104,
"scriptDurationMs": 29.003,
"eventListeners": 21,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1710.4950000000372,
"styleRecalcs": 30,
"styleRecalcDurationMs": 16.389,
"layouts": 6,
"layoutDurationMs": 0.7490000000000001,
"taskDurationMs": 295.036,
"heapDeltaBytes": 5577536,
"heapUsedBytes": 72004716,
"domNodes": 76,
"jsHeapTotalBytes": 18972672,
"scriptDurationMs": 18.381,
"eventListeners": 21,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1724.8220000000174,
"styleRecalcs": 32,
"styleRecalcDurationMs": 17.014,
"layouts": 6,
"layoutDurationMs": 0.644,
"taskDurationMs": 307.974,
"heapDeltaBytes": 5927048,
"heapUsedBytes": 72370560,
"domNodes": 79,
"jsHeapTotalBytes": 18710528,
"scriptDurationMs": 23.725,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "dom-widget-clipping",
"durationMs": 576.7369999999801,
"styleRecalcs": 13,
"styleRecalcDurationMs": 8.896999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 359.115,
"heapDeltaBytes": -11992644,
"heapUsedBytes": 54164524,
"domNodes": 22,
"jsHeapTotalBytes": 19759104,
"scriptDurationMs": 58.17099999999999,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.663333333333338,
"p95FrameDurationMs": 16.700000000000273
},
{
"name": "dom-widget-clipping",
"durationMs": 519.3110000000161,
"styleRecalcs": 11,
"styleRecalcDurationMs": 7.279000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 339.5199999999999,
"heapDeltaBytes": -12486804,
"heapUsedBytes": 54021908,
"domNodes": 18,
"jsHeapTotalBytes": 18710528,
"scriptDurationMs": 52.14600000000001,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999727
},
{
"name": "dom-widget-clipping",
"durationMs": 538.2690000000139,
"styleRecalcs": 12,
"styleRecalcDurationMs": 7.908999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 335.804,
"heapDeltaBytes": -12359660,
"heapUsedBytes": 53763500,
"domNodes": 20,
"jsHeapTotalBytes": 20283392,
"scriptDurationMs": 58.184,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.700000000000273
},
{
"name": "large-graph-idle",
"durationMs": 2012.8469999999652,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.481999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 568.805,
"heapDeltaBytes": 6893744,
"heapUsedBytes": 66426912,
"domNodes": -263,
"jsHeapTotalBytes": 3497984,
"scriptDurationMs": 87.943,
"eventListeners": -129,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-idle",
"durationMs": 2068.0990000000747,
"styleRecalcs": 10,
"styleRecalcDurationMs": 9.135000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 557.0500000000001,
"heapDeltaBytes": 11182732,
"heapUsedBytes": 66109636,
"domNodes": -260,
"jsHeapTotalBytes": -491520,
"scriptDurationMs": 92.39500000000001,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2024.925000000053,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.551000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 564.717,
"heapDeltaBytes": 7499932,
"heapUsedBytes": 65784724,
"domNodes": -265,
"jsHeapTotalBytes": -229376,
"scriptDurationMs": 89.26599999999999,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-pan",
"durationMs": 2119.3850000000225,
"styleRecalcs": 68,
"styleRecalcDurationMs": 17.286,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1133.373,
"heapDeltaBytes": 8502544,
"heapUsedBytes": 69093620,
"domNodes": -260,
"jsHeapTotalBytes": -24576,
"scriptDurationMs": 385.276,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-pan",
"durationMs": 2129.82599999998,
"styleRecalcs": 68,
"styleRecalcDurationMs": 17.472,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1111.564,
"heapDeltaBytes": 11571900,
"heapUsedBytes": 72182432,
"domNodes": -262,
"jsHeapTotalBytes": 4198400,
"scriptDurationMs": 382.07,
"eventListeners": -125,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-pan",
"durationMs": 2120.9749999999303,
"styleRecalcs": 68,
"styleRecalcDurationMs": 18.15,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1134.548,
"heapDeltaBytes": 1198376,
"heapUsedBytes": 59449972,
"domNodes": -263,
"jsHeapTotalBytes": 958464,
"scriptDurationMs": 379.116,
"eventListeners": -125,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-zoom",
"durationMs": 3149.633999999992,
"styleRecalcs": 65,
"styleRecalcDurationMs": 27.479,
"layouts": 60,
"layoutDurationMs": 7.643000000000001,
"taskDurationMs": 1347.485,
"heapDeltaBytes": 9077556,
"heapUsedBytes": 69520984,
"domNodes": -268,
"jsHeapTotalBytes": 229376,
"scriptDurationMs": 460.77299999999997,
"eventListeners": -123,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 3149.1439999999784,
"styleRecalcs": 65,
"styleRecalcDurationMs": 17.953,
"layouts": 60,
"layoutDurationMs": 7.5329999999999995,
"taskDurationMs": 1308.504,
"heapDeltaBytes": 16197520,
"heapUsedBytes": 75711844,
"domNodes": -267,
"jsHeapTotalBytes": -229376,
"scriptDurationMs": 454.456,
"eventListeners": -123,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-zoom",
"durationMs": 3138.2770000000164,
"styleRecalcs": 65,
"styleRecalcDurationMs": 19.429000000000002,
"layouts": 60,
"layoutDurationMs": 7.8069999999999995,
"taskDurationMs": 1322.284,
"heapDeltaBytes": 8574856,
"heapUsedBytes": 69189280,
"domNodes": -267,
"jsHeapTotalBytes": 4423680,
"scriptDurationMs": 462.5400000000001,
"eventListeners": -123,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "minimap-idle",
"durationMs": 2024.675000000002,
"styleRecalcs": 7,
"styleRecalcDurationMs": 6.518000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 553.72,
"heapDeltaBytes": 2810876,
"heapUsedBytes": 63069116,
"domNodes": -266,
"jsHeapTotalBytes": 32768,
"scriptDurationMs": 88.37,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 2026.90599999994,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.542,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 523.303,
"heapDeltaBytes": 6306296,
"heapUsedBytes": 64352476,
"domNodes": -266,
"jsHeapTotalBytes": 557056,
"scriptDurationMs": 83.01099999999998,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "minimap-idle",
"durationMs": 2029.6869999999672,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.68,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 537.473,
"heapDeltaBytes": 12666444,
"heapUsedBytes": 72855832,
"domNodes": -262,
"jsHeapTotalBytes": 294912,
"scriptDurationMs": 83.652,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 541.6180000000281,
"styleRecalcs": 47,
"styleRecalcDurationMs": 11.153000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 365.41400000000004,
"heapDeltaBytes": -11778736,
"heapUsedBytes": 54683564,
"domNodes": 20,
"jsHeapTotalBytes": 19759104,
"scriptDurationMs": 120.98500000000001,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999727
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 546.3730000000169,
"styleRecalcs": 48,
"styleRecalcDurationMs": 11.254,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 355.131,
"heapDeltaBytes": -10780132,
"heapUsedBytes": 55776544,
"domNodes": 21,
"jsHeapTotalBytes": 20971520,
"scriptDurationMs": 117.46499999999999,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000273
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 556.7300000000159,
"styleRecalcs": 45,
"styleRecalcDurationMs": 9.144,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 353.52099999999996,
"heapDeltaBytes": 9081936,
"heapUsedBytes": 57590456,
"domNodes": 16,
"jsHeapTotalBytes": 15728640,
"scriptDurationMs": 119.114,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000273
},
{
"name": "subgraph-idle",
"durationMs": 1998.7240000000384,
"styleRecalcs": 10,
"styleRecalcDurationMs": 8.963000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 374.95200000000006,
"heapDeltaBytes": 959256,
"heapUsedBytes": 67519216,
"domNodes": 20,
"jsHeapTotalBytes": 19234816,
"scriptDurationMs": 18.09499999999999,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 2012.3669999999265,
"styleRecalcs": 9,
"styleRecalcDurationMs": 7.636,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 370.81899999999996,
"heapDeltaBytes": 699460,
"heapUsedBytes": 67426820,
"domNodes": 18,
"jsHeapTotalBytes": 18972672,
"scriptDurationMs": 16.989000000000004,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 1988.9419999999518,
"styleRecalcs": 11,
"styleRecalcDurationMs": 8.534,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 340.458,
"heapDeltaBytes": 1322304,
"heapUsedBytes": 67782052,
"domNodes": 21,
"jsHeapTotalBytes": 18972672,
"scriptDurationMs": 16.049,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1760.4460000000017,
"styleRecalcs": 76,
"styleRecalcDurationMs": 43.958,
"layouts": 16,
"layoutDurationMs": 5.707,
"taskDurationMs": 804.861,
"heapDeltaBytes": -4069412,
"heapUsedBytes": 44459308,
"domNodes": -261,
"jsHeapTotalBytes": 14807040,
"scriptDurationMs": 95.836,
"eventListeners": -129,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 2021.861000000058,
"styleRecalcs": 86,
"styleRecalcDurationMs": 46.883,
"layouts": 16,
"layoutDurationMs": 4.431,
"taskDurationMs": 990.317,
"heapDeltaBytes": -17092768,
"heapUsedBytes": 49562160,
"domNodes": -256,
"jsHeapTotalBytes": 18837504,
"scriptDurationMs": 96.11200000000001,
"eventListeners": -129,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1687.0209999999588,
"styleRecalcs": 76,
"styleRecalcDurationMs": 35.409,
"layouts": 16,
"layoutDurationMs": 4.421,
"taskDurationMs": 682.5799999999999,
"heapDeltaBytes": -5469568,
"heapUsedBytes": 62661772,
"domNodes": 61,
"jsHeapTotalBytes": 19136512,
"scriptDurationMs": 84.619,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 8182.598999999982,
"styleRecalcs": 251,
"styleRecalcDurationMs": 54.995999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3896.5449999999996,
"heapDeltaBytes": 19950200,
"heapUsedBytes": 75833600,
"domNodes": -259,
"jsHeapTotalBytes": 2072576,
"scriptDurationMs": 1259.478,
"eventListeners": -111,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 8132.75699999997,
"styleRecalcs": 249,
"styleRecalcDurationMs": 51.73799999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3649.043,
"heapDeltaBytes": 19259852,
"heapUsedBytes": 78943764,
"domNodes": -261,
"jsHeapTotalBytes": 5509120,
"scriptDurationMs": 1177.154,
"eventListeners": -111,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 8170.916000000034,
"styleRecalcs": 250,
"styleRecalcDurationMs": 52.528,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3752.8250000000003,
"heapDeltaBytes": 9253844,
"heapUsedBytes": 67435320,
"domNodes": -263,
"jsHeapTotalBytes": 1548288,
"scriptDurationMs": 1215.282,
"eventListeners": -111,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-large-graph-idle",
"durationMs": 10641.921999999966,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 10627.566,
"heapDeltaBytes": -44077464,
"heapUsedBytes": 173661800,
"domNodes": -9850,
"jsHeapTotalBytes": 25489408,
"scriptDurationMs": 575.093,
"eventListeners": -23961,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.223333333333237,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 10736.810999999989,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 10719.977,
"heapDeltaBytes": -39378584,
"heapUsedBytes": 182433544,
"domNodes": -9845,
"jsHeapTotalBytes": 24702976,
"scriptDurationMs": 576.463,
"eventListeners": -23961,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-large-graph-idle",
"durationMs": 10564.614000000005,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 10551.435000000001,
"heapDeltaBytes": -57440112,
"heapUsedBytes": 171564564,
"domNodes": -9849,
"jsHeapTotalBytes": 22605824,
"scriptDurationMs": 571.643,
"eventListeners": -23965,
"totalBlockingTimeMs": 0,
"frameDurationMs": 18.329999999999927,
"p95FrameDurationMs": 33.39999999999782
},
{
"name": "vue-large-graph-pan",
"durationMs": 12950.071999999978,
"styleRecalcs": 66,
"styleRecalcDurationMs": 17.132000000000037,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 12932.078000000001,
"heapDeltaBytes": -66901592,
"heapUsedBytes": 155403200,
"domNodes": -9852,
"jsHeapTotalBytes": -13045760,
"scriptDurationMs": 868.7589999999999,
"eventListeners": -23955,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.223333333333358,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "vue-large-graph-pan",
"durationMs": 12500.854000000003,
"styleRecalcs": 64,
"styleRecalcDurationMs": 16.75500000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 12482.979999999998,
"heapDeltaBytes": -49854048,
"heapUsedBytes": 171484128,
"domNodes": -9850,
"jsHeapTotalBytes": 24178688,
"scriptDurationMs": 821.946,
"eventListeners": -23957,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.223333333333358,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "vue-large-graph-pan",
"durationMs": 12828.175999999985,
"styleRecalcs": 66,
"styleRecalcDurationMs": 17.881000000000007,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 12807.729,
"heapDeltaBytes": -64350840,
"heapUsedBytes": 155560092,
"domNodes": -9850,
"jsHeapTotalBytes": -13832192,
"scriptDurationMs": 854.267,
"eventListeners": -23955,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.219999999999953,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "workflow-execution",
"durationMs": 474.19800000000123,
"styleRecalcs": 17,
"styleRecalcDurationMs": 26.036,
"layouts": 5,
"layoutDurationMs": 1.604,
"taskDurationMs": 152.15300000000002,
"heapDeltaBytes": -15122108,
"heapUsedBytes": 52602556,
"domNodes": 166,
"jsHeapTotalBytes": 4292608,
"scriptDurationMs": 24.755000000000006,
"eventListeners": 71,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.663333333333338,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "workflow-execution",
"durationMs": 156.3099999999622,
"styleRecalcs": 14,
"styleRecalcDurationMs": 22.899999999999995,
"layouts": 5,
"layoutDurationMs": 1.583,
"taskDurationMs": 127.86799999999998,
"heapDeltaBytes": -17266420,
"heapUsedBytes": 50461512,
"domNodes": 150,
"jsHeapTotalBytes": 5079040,
"scriptDurationMs": 24.179000000000002,
"eventListeners": 39,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000273
},
{
"name": "workflow-execution",
"durationMs": 479.0140000000065,
"styleRecalcs": 16,
"styleRecalcDurationMs": 22.3,
"layouts": 4,
"layoutDurationMs": 1.0990000000000002,
"taskDurationMs": 129.57599999999996,
"heapDeltaBytes": -15002900,
"heapUsedBytes": 52744164,
"domNodes": 154,
"jsHeapTotalBytes": 4554752,
"scriptDurationMs": 23.233999999999998,
"eventListeners": 71,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000273
}
]
} |
Restore the pre-#10849 invariant that SubgraphNode.widgets_values is a dead field. Per-instance promoted widget values are now carried inline on their proxyWidgets entry, so identity and value cannot be separated under reorder, null-entry filter, clipboard paste / subgraph dedup / nested-pack ID remap. Add PromotedWidgetView.restorePerInstanceValue to seed _instanceWidgetValues and promotedSourceWriteMeta without triggering sibling-fallback capture during configure. Align the shared value so the getTrackedValue self-heal does not discard the restored state. Legacy workflows with stale widgets_values on SubgraphNode are ignored; values fall back to inner-widget delegation as pre-#10849.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/core/graph/subgraph/promotedWidgetView.ts (1)
232-353: Extract shared write-to-store logic;set valueand_writeValueToSharedStateare now near-duplicates.Lines 233–274 and 311–352 implement the same linked-widgets → resolved-deepest → widget-state → resolve-at-host cascade. The only difference in
set valueis the precedingcaptureSiblingFallbackValues()and the instance-map/meta writes. Recommend having the setter delegate to_writeValueToSharedState(value)to keep both code paths in lockstep — otherwise future fixes (new store, new resolution path, etc.) will need to be applied in two places and can silently drift, reintroducing exactly the class of regression this PR is fixing.♻️ Proposed consolidation
set value(value: IBaseWidget['value']) { this.captureSiblingFallbackValues() - - // Keep per-instance map in sync for execution (graphToPrompt) this.subgraphNode._instanceWidgetValues.set( this.instanceKey, cloneWidgetValue(value) ) setPromotedSourceWriteMeta( this.subgraphNode.rootGraph, this._sharedSourceKey, { value: cloneWidgetValue(value), writerInstanceId: String(this.subgraphNode.id) } ) - - const linkedWidgets = this.getLinkedInputWidgets() - if (linkedWidgets.length > 0) { - // …duplicated body… - } - - const state = this.getWidgetState() - if (state) { - state.value = value - return - } - - const resolved = this.resolveAtHost() - if (resolved && isWidgetValue(value)) { - resolved.widget.value = value - } + this._writeValueToSharedState(value) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/core/graph/subgraph/promotedWidgetView.ts` around lines 232 - 353, The setter duplicates the shared "write-to-store" cascade implemented in _writeValueToSharedState(value); refactor set value to call _writeValueToSharedState(value) after it runs captureSiblingFallbackValues() and the per-instance map + setPromotedSourceWriteMeta updates so the linked-widgets → resolveDeepest → getWidgetState → resolveAtHost logic is only implemented once; update set value to remove the duplicated loop and resolution code and delegate to _writeValueToSharedState(value), ensuring _writeValueToSharedState uses useWidgetValueStore(), getLinkedInputWidgets(), resolveDeepest(), stripGraphPrefix(), getWidgetState(), resolveAtHost(), and isWidgetValue() exactly as the existing implementation.src/lib/litegraph/src/subgraph/SubgraphNode.ts (1)
658-692: Serialize-side clone handles primitives and objects correctly; two small notes.
raw ?? nullcoercesundefined→nullon the wire. That's fine for JSON round-trip, but any call site inspecting{ value }on an in-memory workflow right after serialize should not distinguish absent-value-from-default (undefined) vs. explicit null. Given Zod'svalue: z.unknown()accepts both, the restore path treats them identically — acceptable.JSON.parse(JSON.stringify(raw))dropsDate,Map,Set,Function, etc. If any promoted widget ever has a non-JSON-serializable value, it will mutate on save. Current widgets appear to only hold JSON-safe values, but worth a note for future widget types.No change required; logging here for awareness.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/litegraph/src/subgraph/SubgraphNode.ts` around lines 658 - 692, The serialize logic in _serializeEntriesWithState currently coerces undefined to null via (raw ?? null) and deep-clones objects using JSON.parse(JSON.stringify(raw)), which loses Dates, Maps, Sets, Functions, etc.; to fix/mitigate, update _serializeEntriesWithState (see function name and variables raw, cloned, view.serializeValue) to preserve undefined when appropriate (e.g., use raw === undefined ? undefined : raw) and replace the JSON-based clone with a more robust clone such as structuredClone(raw) with a safe fallback to JSON.stringify for environments without structuredClone, or add a clear inline comment documenting the known limitation if you intentionally accept JSON-only values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/core/graph/subgraph/promotedWidgetView.ts`:
- Around line 232-353: The setter duplicates the shared "write-to-store" cascade
implemented in _writeValueToSharedState(value); refactor set value to call
_writeValueToSharedState(value) after it runs captureSiblingFallbackValues() and
the per-instance map + setPromotedSourceWriteMeta updates so the linked-widgets
→ resolveDeepest → getWidgetState → resolveAtHost logic is only implemented
once; update set value to remove the duplicated loop and resolution code and
delegate to _writeValueToSharedState(value), ensuring _writeValueToSharedState
uses useWidgetValueStore(), getLinkedInputWidgets(), resolveDeepest(),
stripGraphPrefix(), getWidgetState(), resolveAtHost(), and isWidgetValue()
exactly as the existing implementation.
In `@src/lib/litegraph/src/subgraph/SubgraphNode.ts`:
- Around line 658-692: The serialize logic in _serializeEntriesWithState
currently coerces undefined to null via (raw ?? null) and deep-clones objects
using JSON.parse(JSON.stringify(raw)), which loses Dates, Maps, Sets, Functions,
etc.; to fix/mitigate, update _serializeEntriesWithState (see function name and
variables raw, cloned, view.serializeValue) to preserve undefined when
appropriate (e.g., use raw === undefined ? undefined : raw) and replace the
JSON-based clone with a more robust clone such as structuredClone(raw) with a
safe fallback to JSON.stringify for environments without structuredClone, or add
a clear inline comment documenting the known limitation if you intentionally
accept JSON-only values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 72b53e3f-728a-4901-9ce0-1c4cd1da1b7b
📒 Files selected for processing (7)
src/core/graph/subgraph/promotedWidgetTypes.tssrc/core/graph/subgraph/promotedWidgetView.test.tssrc/core/graph/subgraph/promotedWidgetView.tssrc/core/graph/subgraph/subgraphNodePromotion.test.tssrc/core/schemas/promotionSchema.tssrc/lib/litegraph/src/subgraph/SubgraphNode.multiInstance.test.tssrc/lib/litegraph/src/subgraph/SubgraphNode.ts
✅ Files skipped from review due to trivial changes (1)
- src/core/graph/subgraph/promotedWidgetView.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/litegraph/src/subgraph/SubgraphNode.multiInstance.test.ts
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #11559 +/- ##
===========================================
- Coverage 70.44% 52.46% -17.99%
===========================================
Files 1482 1374 -108
Lines 85986 70279 -15707
Branches 24088 18670 -5418
===========================================
- Hits 60576 36869 -23707
- Misses 24468 32863 +8395
+ Partials 942 547 -395
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 985 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/litegraph/src/subgraph/SubgraphNode.ts`:
- Around line 1141-1170: When handling legacy '-1' widget entries in
SubgraphNode.ts, the resolved PromotedWidgetSource can lose its
disambiguatingSourceNodeId, causing pendingValues' key to not match
view.instanceKey during restore; update the '-1' branch (where
_resolveLegacyEntry is used) to populate the resolved object with
disambiguatingSourceNodeId (set it from sourceNodeId or the appropriate
variable) before calling makePromotionEntryKey and inserting into pendingValues,
and apply the same fix in the other occurrence (around the
normalizeLegacyProxyWidgetEntry/assignment block referenced at the second
location) so both code paths preserve disambiguatingSourceNodeId for
PromotedWidgetSource used by makePromotionEntryKey and pendingValues.
- Around line 691-693: The serializeValue call is passing a hardcoded -1 which
breaks dynamicPrompts because it expects the promoted widget index; locate the
usage of view.serializeValue(this, -1) in SubgraphNode (and the similar
occurrences around the other block referenced) and replace the -1 with the
actual promoted view index obtained from SubgraphNode._getPromotedViews() (e.g.,
find the promoted views array, determine the index of the current view within
that array and pass that index into serializeValue) so dynamicPrompts receives
the correct widgetIndex for writing back widgets_values.
🪄 Autofix (Beta)
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: CHILL
Plan: Pro
Run ID: 8bce7522-3a98-4508-a496-2a5ef7d5db3f
📒 Files selected for processing (2)
src/core/graph/subgraph/promotedWidgetView.tssrc/lib/litegraph/src/subgraph/SubgraphNode.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/core/graph/subgraph/promotedWidgetView.ts
…state The fixture was authored in v1.44.5-7 format where per-instance values lived on widgets_values. With widgets_values restored to a dead field, values now live inline on properties.proxyWidgets entries.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
browser_tests/assets/subgraphs/subgraph-multi-instance-promoted-text-values.json (1)
11-11:⚠️ Potential issue | 🟡 MinorIncrease test asset node sizes to the browser-test minimum.
These node sizes are below
[400, 200]in at least one dimension, which can makenavigateIntoSubgraphflaky for this asset.Proposed fixture size update
- "size": [210, 168], + "size": [400, 200], @@ - "size": [210, 168], + "size": [400, 200], @@ - "size": [210, 168], + "size": [400, 200], @@ - "size": [270, 262], + "size": [400, 262],As per coding guidelines,
browser_tests/assets/**/*.json: Use node size[400, 200]minimum in test asset JSON to preventnavigateIntoSubgraphtimeout issues.Also applies to: 31-31, 51-51, 179-179
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/assets/subgraphs/subgraph-multi-instance-promoted-text-values.json` at line 11, Update the "size" arrays in the test asset subgraph-multi-instance-promoted-text-values.json so no node has dimensions smaller than the browser-test minimum [400, 200]; locate each "size" field (e.g., the entries currently set to [210,168] and the other smaller occurrences) and change them to at least [400,200] (or larger in width/height as needed) to prevent navigateIntoSubgraph flakiness.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@browser_tests/assets/subgraphs/subgraph-multi-instance-promoted-text-values.json`:
- Line 11: Update the "size" arrays in the test asset
subgraph-multi-instance-promoted-text-values.json so no node has dimensions
smaller than the browser-test minimum [400, 200]; locate each "size" field
(e.g., the entries currently set to [210,168] and the other smaller occurrences)
and change them to at least [400,200] (or larger in width/height as needed) to
prevent navigateIntoSubgraph flakiness.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4dda05e0-b544-453e-9298-acbac71ca444
📒 Files selected for processing (1)
browser_tests/assets/subgraphs/subgraph-multi-instance-promoted-text-values.json
jaeone94
left a comment
There was a problem hiding this comment.
Reviewed the save/load contract reshape end-to-end. The inline {value} on proxyWidgets tuples is the right direction — identity and value are coupled in a single record so ordering/filter drift can't misalign them, and no new top-level JSON key is introduced. Approach is sound.
My concerns cluster around load/clone edge cases (value corruption and silent drop), and a migration gap for workflows saved during the #10849 window. Inline comments below.
Breakdown: 4 issue · 4 suggestion · 1 nit. Approach itself is not blocked; the issues are worth resolving before merge.
| /** | ||
| * Hydrate per-instance values by resolved identity key. The pending | ||
| * map is built alongside entry resolution so legacy `-1` and ancestor | ||
| * normalization paths are handled with the same logic as the promotion | ||
| * store, and reorder / filter / ID-remap can't desync identity from | ||
| * value. | ||
| */ | ||
| if (pendingValues.size > 0) { |
There was a problem hiding this comment.
issue — write-back immediately above (lines ~1181-1185 in the current file, just before the virtual-canvas auto-promote loop) demotes {value} right before this hydration block runs.
const serialized = this._serializeEntries(entries)
if (JSON.stringify(serialized) !== JSON.stringify(raw)) {
this.properties.proxyWidgets = serialized
}After loading a 4-tuple workflow, raw is 4-tuple and _serializeEntries (no State suffix) produces 2/3-tuple — the compare is always unequal → properties.proxyWidgets is demoted to state-less form. Live views still work (this pendingValues hydration runs against the still-buffered state), but any caller snapshotting properties.proxyWidgets between load and the next serialize() (extensions, undo/diff, clipboard clone) sees no {value}.
Fix: switch the write-back to _serializeEntriesWithState, or narrow the write-back condition to entries that actually needed resolution (legacy -1 normalization).
There was a problem hiding this comment.
Fair catch. Replaced the write-back with a new _serializeEntriesWithPendingValues helper (identity from resolved entries, value from pendingValues), so normalization no longer demotes 4-tuples to 2/3-tuples in properties.proxyWidgets. Live views are unaffected (pendingValues hydration was already the source of truth) but snapshots from clone/undo/extensions now stay faithful to the loaded state. Commit e2ca5e8.
| const cloned = | ||
| raw != null && typeof raw === 'object' | ||
| ? JSON.parse(JSON.stringify(raw)) | ||
| : (raw ?? null) | ||
|
|
There was a problem hiding this comment.
issue — undefined → null coercion feeds back into load-side map poisoning.
const cloned = raw != null && typeof raw === 'object'
? JSON.parse(JSON.stringify(raw))
: (raw ?? null)Any promoted widget whose serializeValue() returns undefined is persisted as null. On reload, null is fed to restorePerInstanceValue (promotedWidgetView.ts:221–242), which has no null/undefined guard — it sets _instanceWidgetValues[key] = null, creating a ghost entry. getTrackedValue then treats null as a real value and returns it (numeric widgets display null), while captureSiblingFallbackValues.has(key) sees true and skips sibling propagation.
Fix: on serialize, skip entries whose resolved value is undefined (downgrade to 2/3-tuple here). On load, early-return in restorePerInstanceValue when value === undefined (and, if desired, when value === null).
There was a problem hiding this comment.
Fixed both sides. Save: _serializeEntriesWithState now downgrades to identity-only 2/3-tuple when the resolved value is undefined (no more ?? null coercion). Load: restorePerInstanceValue early-returns on undefined to avoid seeding a ghost null that captureSiblingFallbackValues would treat as already-written. null is still allowed through since some widgets persist it legitimately. Commit e2ca5e8.
| } | ||
|
|
||
| if (resolved && rawEntry.length >= 4) { | ||
| const state = (rawEntry as unknown[])[3] |
There was a problem hiding this comment.
suggestion — three as casts in PR-new code, all avoidable.
const state = (rawEntry as unknown[])[3] // L1166
(state as { value: unknown }).value // L1170
pendingValues.get(key) as typeof view.value // L1228Per AGENTS.md, "Type assertions are a last resort". TS narrows tuple unions by length and 'value' in state narrows via the in operator.
Fix: add a typed helper in promotionSchema.ts:
export function getInlineState(
tuple: ProxyWidgetsProperty[number]
): { value: unknown } | undefined {
return tuple.length === 4 ? tuple[3] : undefined
}Then replace all three casts with direct typed access.
There was a problem hiding this comment.
Two of three removed via a new getProxyWidgetInlineState typed helper in promotionSchema.ts — narrows by tuple length for the state-object accessor. The third (pendingValues.get(key) as typeof view.value) is the genuine JSON-input-to-typed-API boundary and felt like a legitimate "legacy interop" assertion per AGENTS.md, so I left it. Commit e2ca5e8.
_resolveLegacyEntry now returns a full PromotedWidgetSource rather than a
bare [nodeId, widgetName] tuple, carrying disambiguatingSourceNodeId when
the resolved input widget is a nested PromotedWidgetView.
Without this, legacy -1 entries in nested subgraphs resolved to a key
'${source}:${widget}' while the promoted view registered under
'${source}:${widget}:${disambig}', causing the per-instance value
hydration lookup to miss silently. Values then fell back to inner-widget
delegation instead of the saved per-instance state.
Addresses CodeRabbit Major finding on PR #11559.
Addresses jaeone94's review on #11559: - write-back during configure now uses `_serializeEntriesWithPendingValues` so legacy-entry normalization doesn't demote the freshly-loaded 4-tuple into an identity-only 2/3-tuple, which would drop per-instance values from `properties.proxyWidgets` until the next full `serialize()`. - `cloneWidgetValue` now uses `structuredClone` with a raw-reference fallback, so a malformed `{value}` blob (circular ref, throwing `toJSON`, etc.) in saved JSON can't crash the whole subgraph load. - `_serializeEntriesWithState` skips the `{value}` wrapper when the resolved value is `undefined`, preventing ghost `null` entries from poisoning the per-instance map and sibling-fallback capture. - `restorePerInstanceValue` early-returns on `undefined` for the same reason. - `set value` now shares `_seedInstanceState` with `restorePerInstanceValue` to prevent drift between the setter and load paths. - `promotionSchema.ts` exposes `getProxyWidgetInlineState` + typed tuple names so inline state is read without `as` casts. Union order is load-bearing and now documented. - Regression test now asserts the LOAD invariant (inner widget value survives stale `widgets_values` in the payload), not just the SAVE invariant.
Knip flagged the newly exported types as unused. They're consumed only by getProxyWidgetInlineState in the same file, so keep them internal.
jaeone94
left a comment
There was a problem hiding this comment.
Confirmed that the previous review feedback was addressed thoroughly — _serializeEntriesWithPendingValues handles the write-back demote, structuredClone with fallback prevents configure crashes, _seedInstanceState unifies the setter/restore paths, getProxyWidgetInlineState eliminates the type casts, the LOAD-side behavioral assertion was added, and the Zod union precedence comment is in. All of the issue-tier items and both of the partial/declined items came back with sound reasoning. 👍
However, one valid bug still remains after the follow-ups. The disambiguator preservation commit (968a2fd9a) correctly implemented CodeRabbit's suggested diff, but I traced the control flow and the fix actually covers a code path that isn't reachable during normal configure. The production-reachable path still drops the disambiguator — this is a narrow edge case (requires very-old workflow + nested subgraph + duplicate widget names), but it is a real remaining bug path. CodeRabbit's original suggestion itself was incomplete; Dante faithfully implemented it, so this isn't a review-follow-through issue.
One suggestion on test coverage attached as well. Everything here is follow-up territory, not a merge blocker.
|
@coderabbitai approve |
✅ Actions performedComments resolved and changes approved. |
…ine-state' into fix/subgraph-promoted-widget-inline-state
DrJKL
left a comment
There was a problem hiding this comment.
A Gentle, Detailed Re-review
"The function of good software is to make the complex appear to be simple." — Grady Booch
"If you have a procedure with ten parameters, you probably missed some." — Alan Perlis, Epigram #11
Hello! Thank you for putting this PR together. The instinct that drove this change — the discomfort with three competing per-instance value channels (_instanceWidgetValues, promotedSourceWriteMetaByGraph, the unscoped widgetValueStore) — is exactly the right kind of architectural unease to follow. The deletions in this diff are genuinely good, and I want to walk through the rest of the change in the slow, patient way the code deserves, because the direction you're heading is right and the path you've taken needs a couple of corrections before it gets there.
What follows is long on purpose. I'd rather over-cite first principles than leave you guessing why a particular smell triggers a reviewer's instinct. Treat the citations as a reading list, not as gatekeeping.
I've also dropped inline comments at the most actionable spots in the diff. The body below is the framework; the inline comments are the local moves.
1. The Map of Where Data Lives Today
Let's start by counting. Every node in this diagram is a place this PR (or the surrounding code) can store the answer to "what is this promoted widget's identity / value?" Every edge is a place where two stores have to be kept in sync, which means every edge is a future bug.
%%{init: {'flowchart': {'htmlLabels': false, 'curve': 'basis'}}}%%
flowchart TB
%% ════════════════════════════════════════════════════════════
%% IDENTITY — the question "which widget is promoted?"
%% ════════════════════════════════════════════════════════════
subgraph IDENT["PROMOTION IDENTITY — 6 storage sites for one logical fact"]
direction TB
SSOT["`**Subgraph (definition-level)**
_The single source of truth that does not exist_
Identity should live here once, referenced by N instances`"]:::missing
PROPS["`**SubgraphNode.properties.proxyWidgets**
per-instance, persisted
tuple shapes:
[nid, name]
[nid, name, disambig]
[nid, name, disambig|null, {value}] ← NEW`"]:::storage
PSTORE["`**usePromotionStore()**
key: (rootGraphId, instanceId)
value: PromotedWidgetSource[]
runtime mirror`"]:::storage
VIEWS["`**_promotedViewManager.views[]**
PromotedWidgetView instances`"]:::storage
INPUT["`**SubgraphNode.inputs[i]._widget**
back-reference to view`"]:::storage
WIDS["`**SubgraphNode.widgets[]**
getter materializing views`"]:::storage
end
SSOT -. "would obviate ↓" .-> PROPS
PROPS <-->|"hydrate / serialize"| PSTORE
PSTORE -->|"build views"| VIEWS
VIEWS -->|"_resolveInputWidget"| INPUT
VIEWS -->|"materialized via getter"| WIDS
%% ════════════════════════════════════════════════════════════
%% VALUE — the question "what is the current value of the promoted widget?"
%% ════════════════════════════════════════════════════════════
subgraph VAL["PROMOTED WIDGET VALUE — 8 storage sites for one logical fact"]
direction TB
INLINE["`**properties.proxyWidgets[i][3].value**
PERSISTED — NEW
value smuggled into identity tuple`"]:::new
WSCOPE["`**useWidgetValueStore (scoped)**
key: instanceId@nodeId:widgetName
runtime, per-instance`"]:::storage
WGLOBAL["`**useWidgetValueStore (unscoped)**
key: nodeId:widgetName
legacy / shared fallback`"]:::storage
HOST["`**inner LGraphNode.widgets[i].value**
the actual source widget`"]:::storage
SAFE["`**SafeWidgetData.value**
non-reactive snapshot — NEW`"]:::new
LEGACY["`**legacy widgets_values[]**
still parsed on import,
length-aligned migration only`"]:::legacy
PEND1["`**_pendingLegacyWidgetsValues**
transient instance field,
covert parameter`"]:::transient
PEND2["`**pendingValues: Map**
local in
_internalConfigureAfterSlots`"]:::transient
VIEWGET["`**PromotedWidgetView.value getter**
precedence: scoped → host → legacy
8th read site`"]:::storage
end
INLINE -->|"hydrate → "| PEND2
LEGACY -->|"if length === raw.length"| PEND2
LEGACY -->|"else: silently dropped"| LOSS["`💀 _data loss_`"]:::loss
PEND1 -.->|"covert param"| PEND2
PEND2 -->|"writeScopedValue"| WSCOPE
WSCOPE -->|"serialize ← "| INLINE
HOST --- VIEWGET
WGLOBAL --- VIEWGET
WSCOPE --- VIEWGET
HOST -->|"snapshotted at map time"| SAFE
%% ════════════════════════════════════════════════════════════
%% IDENTITY KEYS — 4 incompatible encodings of the same key
%% ════════════════════════════════════════════════════════════
subgraph KEYS["IDENTITY-KEYING SCHEMES — 4 mutually translated encodings"]
direction TB
K1["`**PromotedWidgetView.instanceKey**
${nid}:${name}[:${disamb}]`"]:::keyfmt
K2["`**WidgetKey** _stringly-typed_
${nid}:${name} |
${iid}@${nid}:${name}`"]:::keyfmt
K3["`**makePromotionEntryKey()**
used by promotionStore`"]:::keyfmt
K4["`**SafeWidgetData identity fields**
nodeId, storeNodeId,
storeInstanceId, name, storeName`"]:::keyfmt
end
VIEWS -.-> K1
WSCOPE -.-> K2
PSTORE -.-> K3
SAFE -.-> K4
PROPS -.->|"identity tuple now also carries value"| INLINE
classDef missing fill:#fff7e6,stroke:#d97706,stroke-width:2px,stroke-dasharray:4 4,color:#7c2d12
classDef storage fill:#eef2ff,stroke:#4f46e5,stroke-width:1px,color:#1e1b4b
classDef new fill:#fee2e2,stroke:#b91c1c,stroke-width:2px,color:#7f1d1d
classDef transient fill:#f5f3ff,stroke:#7c3aed,stroke-width:1px,stroke-dasharray:2 2,color:#3b0764
classDef legacy fill:#fef3c7,stroke:#a16207,stroke-width:1px,color:#713f12
classDef keyfmt fill:#ecfeff,stroke:#0e7490,stroke-width:1px,color:#083344
classDef loss fill:#000,stroke:#dc2626,color:#fff
Read this diagram with the question: if I edit a promoted widget once, how many writes have to happen, and how many reads have to agree? The answer this PR ships is "many." The answer the codebase deserves is "one."
2. Diagnostic Lenses (Why Each Issue Is An Issue)
Naming the lenses up front so my objections don't read as taste preferences. Each one is well-trodden ground in the literature.
2a. Single Source of Truth (SSOT)
"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." — Hunt & Thomas, The Pragmatic Programmer, "DRY", §1.7
DRY is famously misquoted as "don't repeat code." The original is "don't repeat knowledge." A logical fact (this promotion's identity, this promotion's value) must live in one place; everything else either references it or derives from it. When the same fact lives in two stores you do not have one fact — you have two facts that happen to agree until they don't.
2b. Connascence
Meilir Page-Jones (What Every Programmer Should Know About Object-Oriented Design, 1996) and Jim Weirich popularized the connascence taxonomy. The forms relevant here, in order from least-bad to worst:
- Connascence of Name (CoN) — two things must agree on a name. Cheap.
- Connascence of Type (CoT) — two things must agree on a type. Cheap, compiler helps.
- Connascence of Position (CoP) — two things must agree on the order in a sequence. Expensive — invisible to the compiler, fragile under reordering. Tuples are the textbook example.
- Connascence of Algorithm (CoA) — two things must run the same logic to agree.
- Connascence of Identity (CoI) — two things must reference the same object. The worst form.
The 4-tuple [nodeId, widgetName, disambig|null, {value}] is CoP-3 spread across _serializeEntries, parseProxyWidgets, getProxyWidgetInlineState, the configure hydration path, and external custom-node consumers. CoP across module boundaries is the highest-cost form of coupling you can introduce in a serialized format.
2c. Information Hiding
"The connections between modules are the assumptions which the modules make about each other." — David Parnas, On the Criteria To Be Used in Decomposing Systems into Modules, CACM 1972
A field on this that is only meaningful during a single method's execution (_pendingLegacyWidgetsValues) leaks an internal assumption: that nothing else observes the field while it's set. Parnas would say this module's secret has been published.
2d. Deep Modules
"The best modules are deep: they have powerful functionality yet simple interfaces." — John Ousterhout, A Philosophy of Software Design, §4.5
When PromotedWidgetView grows seven near-synonymous getters, the module has become shallow — its interface (verbs callers must learn) has expanded faster than its underlying model. This is a refactoring signal, not a stylistic preference.
2e. Make Illegal States Unrepresentable
"Make illegal states unrepresentable." — Yaron Minsky, Jane Street, Effective ML, 2010
A value is either inside a legal envelope or it isn't. cloneWidgetValue's try { ... } catch { return value } represents the illegal state ("this value cannot be cloned") with the same shape as the legal one. The type system can no longer tell them apart, and the runtime now has a silent shared-reference path.
2f. Errors Are Values
"Don't just check errors, handle them gracefully." — Hunt & Thomas, The Pragmatic Programmer
Swallowing failure in a catch and returning the input untouched is the Pokémon exception handler anti-pattern: "gotta catch 'em all." It reframes a bug into normal control flow and erases the diagnostic.
2g. Hyrum's Law
"With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody." — Hyrum Wright
AGENTS.md itself flags 40+ custom-node ecosystem consumers depending on the existing surface. The behavior change "writing a promoted widget no longer mutates the source widget" is observable. Some extension out there is observing it.
2h. Domain-Driven Design's Ubiquitous Language
"A domain model is the backbone of a language used by all team members." — Eric Evans, Domain-Driven Design, ch. 2
When the same concept is encoded as instanceKey, WidgetKey, makePromotionEntryKey, and {nodeId, storeNodeId, storeInstanceId}, the codebase has stopped having a ubiquitous language and started having four dialects.
2i. The ECS Architectural Constraint
The project has explicit ADR guidance (ADR 0003 + 0008 referenced in AGENTS.md):
"Centralized registries and ECS-style access: Entity data lives in the World, queried via
world.getComponent(entityId, ComponentType)."
Stringly-typed keys in a flat Map are the opposite of ECS-style access. They re-encode an entity ID as a substring and depend on prefix scanning for collection operations. ECS exists precisely to avoid this.
3. The Issues, Walked Through Patiently
Each subsection names the smell, points at where it lives in the diff, names the principle, and proposes the alternative. Inline comments accompany the most actionable items.
3.1. Identity And Value Are Conflated In One Tuple
Where: src/core/schemas/promotionSchema.ts, src/lib/litegraph/src/subgraph/SubgraphNode.ts
properties.proxyWidgets is the persisted identity of which inner widgets a SubgraphNode promotes. Inlining {value} makes one record carry two unrelated concerns: who and what. This is Data Clumps with two clumps glued together (Fowler, Refactoring, ch. 3).
The principle violated — Single Responsibility (Robert C. Martin, Clean Architecture, ch. 7):
"A module should have one, and only one, reason to change."
Promotion identity changes when the user re-promotes a widget. Promotion value changes on every keystroke in a textbox. These are different cadences, different actors, different invariants. Co-storing them means every value edit produces a write to the identity record.
The defense in the PR description ("identity and value carry together so reorders, ID-remap, and dedup don't desync") is the problem statement, not the solution. The reason they desync is that they are stored separately. The fix is not to staple them together; it is to consolidate the value into a single per-instance store and let identity be reordered freely.
Architectural answer:
flowchart LR
SG["`**Subgraph** (definition)
proxyWidgets: PromotedWidgetSource[]
_identity, shared by all instances_`"]
INST["`**SubgraphNode** (instance)
id: NodeId`"]
STORE["`**WidgetValueStore**
Map<(SubgraphNode.id, PromotionId), Value>
_value, per instance_`"]
SG -.->|"defines what is promoted"| STORE
INST -.->|"scopes value lookups"| STORE
Identity belongs on the subgraph definition (one copy, N references). Value belongs in a single per-instance store keyed by (SubgraphNode.id, PromotionId). The persisted form serializes the store separately from the definition.
3.2. The 4-Tuple Schema Is Connascence-of-Position In Public Persisted Form
const proxyWidgetTupleSchema = z.union([
z.tuple([z.string(), z.string(), z.union([z.string(), z.null()]), proxyWidgetStateSchema]),
z.tuple([z.string(), z.string(), z.string()]),
z.tuple([z.string(), z.string()])
])Three smells in three lines:
- CoP across the persistence boundary. Position 2 must be
nullwhen absent so position 3 can be present. A future field needs a 5-tuple. Custom-node authors must memorize positions, not field names. - The "ordering is defensive" comment is incorrect.
z.tupleenforces arity; the union order does not affect matching. The comment is cargo-culted reassurance. proxyWidgetStateSchema = z.object({ value: z.unknown() }). Withz.unknown(), an explicitundefinedpasses validation. So callers must dostate && state.value !== undefined. The schema validates the illegal state.
Parse, Don't Validate (Alexis King, 2019):
type PromotedWidgetEntry =
| { kind: 'identity', sourceNodeId: string, sourceWidgetName: string, disambiguator?: string }
| { kind: 'instance-value', sourceNodeId: string, sourceWidgetName: string, disambiguator?: string, value: WidgetValue }The kind discriminator is CoN (a name) rather than CoP (a position). Adding a future variant is additive.
3.3. cloneWidgetValue's Catch Hides A Correctness Bug
export function cloneWidgetValue<TValue>(value: TValue): TValue {
if (value == null || typeof value !== 'object') return value
try {
return structuredClone(value)
} catch {
return value
}
}Two layers of concern:
Layer 1 — the test that locks this in fabricates an illegal input to satisfy a coverage goal. A widget value that contains a function is not a real product scenario; it's a contrivance constructed to make the catch branch reachable. Per the project's own AGENTS.md:
"Do not focus on making tests pass at the expense of correctness. Never hard-code expected values, add special-case logic only to satisfy a test, or use workarounds that mask the real problem."
Layer 2 — the catch undoes the very invariant the rest of this PR is fixing. When structuredClone fails and we return value, we return the same object reference. The next state.value = clonedValue write makes two instances point at the same object. Subsequent in-place mutation will leak across instances — exactly the bug the PR claims to fix.
The right code is loud:
export function cloneWidgetValue<TValue>(value: TValue): TValue {
if (value == null || typeof value !== 'object') return value
return structuredClone(value) // let it throw, find the upstream offender
}"An aborted serialize is recoverable; a silently corrupted multi-instance state is not." — paraphrasing the Erlang motto, "Let it crash."
3.4. Length-Aligned Legacy Migration Silently Discards User Data
const canHydrateLegacyWidgetsValues =
this._pendingLegacyWidgetsValues?.length === raw.lengthIf raw and _pendingLegacyWidgetsValues are different lengths for any reason — a workflow saved by a prior version, a manual edit, partial corruption — canHydrateLegacyWidgetsValues becomes false and every legacy value is discarded with no warning, no error, no log.
Postel's Law's lesser-known corollary:
Be liberal in accepting, but loud about ambiguity.
Silent acceptance of malformed data and silent dropping of malformed data are both violations.
The fix:
- Migrate per-index where indices align (the 80% case).
console.warnon length mismatch with enough context to diagnose.- Even better: emit a structured migration result that callers can surface to the user.
3.5. delete serialized.widgets_values Is The Subclass Fighting The Base Class
override serialize(): ISerialisedNode {
// ...write proxyWidgets with inline values...
const serialized = super.serialize()
delete serialized.widgets_values
return serialized
}The override calls super.serialize() to get a record, then deletes a field from it. The relationship between subclass and base class is now adversarial.
Liskov Substitution + Open/Closed (SOLID):
"Software entities should be open for extension, but closed for modification."
The base class should grow a hook:
protected getSerializableWidgetsValues(): unknown[] | undefined {
return /* default: derive from this.widgets */
}
// SubgraphNode overrides:
protected override getSerializableWidgetsValues(): undefined {
return undefined
}If anyone ever adds a non-promoted widget to a SubgraphNode (a label widget, the CANVAS_IMAGE_PREVIEW_WIDGET already imported in this file), their value will be silently deleted by this single line. The delete is a tripwire for future contributors.
3.6. _pendingLegacyWidgetsValues Is A Covert Function Parameter
override configure(info: ExportedSubgraphInstance): void {
this._pendingLegacyWidgetsValues = Array.isArray(info.widgets_values) ? info.widgets_values : undefined
try { super.configure(info) }
finally { this._pendingLegacyWidgetsValues = undefined }
}
override _internalConfigureAfterSlots() {
// ...reads this._pendingLegacyWidgetsValues...
}_pendingLegacyWidgetsValues exists only to pass data from configure to _internalConfigureAfterSlots. It is an instance field for the duration of one method call. This is Action At A Distance.
Information Hiding: the secret of "we're carrying widgets_values across a callback boundary" is broadcast to every method on the class — and every subclass override, every callback that fires during super.configure, every introspecting extension.
The fix — pass it explicitly:
override configure(info: ExportedSubgraphInstance): void {
this._configureWith(info, info.widgets_values)
}
private _configureWith(info: ExportedSubgraphInstance, legacyValues: unknown[] | undefined) {
super.configure(info)
this._hydrateAfterSlots(legacyValues)
}The parameter has a type, a scope, and a single visible call site. The try/finally cleanup disappears.
3.7. WidgetKey Is Stringly-Typed Identity (Primitive Obsession)
type WidgetKey = `${NodeId}:${string}` | `${NodeId}@${NodeId}:${string}`
function clearInstanceWidgets(graphId: UUID, instanceId: NodeId): void {
const widgetStates = getWidgetStateMap(graphId)
const prefix = `${instanceId}@`
for (const key of widgetStates.keys()) {
if (key.startsWith(prefix)) widgetStates.delete(key)
}
}Smells, plural:
- Primitive Obsession (Fowler, code smell #11). The compound concept "(instanceId?, nodeId, widgetName)" is encoded as a
stringwhose internal structure is private convention. - The encoding leaks via
clearInstanceWidgets. The very existence of this method tells you the data shape was wrong. - The format is fragile. The day a node ID legitimately contains
@, this collides silently. - It violates the project's own ADR. ECS-style access is structured, not stringified.
type WidgetIdentity = { readonly nodeId: NodeId, readonly widgetName: string }
type InstanceScope = NodeId | typeof UNSCOPED
const widgetStates: Map<UUID, Map<InstanceScope, Map<WidgetIdentity, WidgetState>>>Now clearInstanceWidgets is widgetStates.get(graphId)?.delete(instanceId). No string parsing.
3.8. SafeWidgetData.value Is A Stale Snapshot Of A Reactive Value
value: normalizeWidgetValue(widget.value), // captured non-reactively at mapping time
// consumed:
const value = (widgetState ? widgetState.value : widget.value) as WidgetValueThe previous comment on SafeWidgetData told the truth:
"Value and metadata (label, hidden, disabled, etc.) are accessed via widgetValueStore."
That was the right design. The new comment says:
"
valueprovides the LiteGraph fallback when no scoped store entry exists yet."
"When no scoped store entry exists yet." That is a description of an eager-initialization bug, not a missing API. The right fix is "promoted views eagerly register a scoped store entry on creation," not "every consumer learns to fall back to a snapshot."
3.9. The Promoted-View Class Has Become Shallow
PromotedWidgetView now exposes getStoreBackedValue, getScopedStoreValue (public, on the interface), getScopedWidgetState, getLegacyWidgetState, getWidgetState, getWidgetStateForRefs, getStoreRefs, writeScopedValue. Eight methods, near-synonyms.
Ousterhout's deep modules:
"Modules should be deep: a simple interface that hides a great deal of complexity."
Collapse to one method that returns a precise value:
type PromotedWidgetSource =
| { source: 'scoped', state: WidgetState }
| { source: 'host', widget: IBaseWidget, node: LGraphNode }
| { source: 'legacy', state: WidgetState }
| { source: 'missing' }
class PromotedWidgetView {
resolve(): PromotedWidgetSource { /* one place, one precedence */ }
get value() { return reduce(this.resolve()) }
set value(v) { write(this.resolve(), v) }
}The precedence (scoped → host → legacy) is named and visible, callers branch once on a discriminated union, adding a new resolution mode is a typed addition.
3.10. properties.proxyWidgets Gets Rewritten On Every Configure
const serialized = this._serializeEntries(entries, (key) => pendingValues.get(key))
if (JSON.stringify(serialized) !== JSON.stringify(raw)) {
this.properties.proxyWidgets = serialized
}Three concerns:
JSON.stringifyequality on a hot path. Twice per configure.JSON.stringifyordering is implementation-defined for object keys.- The 4-tuple branch reconstructs
{value}frompendingValues, so theserializedshape rarely matches the raw input byte-for-byte. Theifcheck is a mirage; the write happens on essentially every load. - External watchers fire on every load.
Idempotence:
"A noop should be a noop."
Loading a workflow and immediately saving it should produce a byte-identical artifact.
3.11. The Behavior Change Has No Migration Story
Tests confirm a deliberate behavioral inversion:
- expect(innerNodes[0].widgets![0].value).toBe('test2') // old: source updated
+ expect(innerNodes[0].widgets![0].value).toBe('test') // new: source unchangedHyrum's Law applies. AGENTS.md flags 40+ custom-node repos as observers of node.serialize and the propagation contract. The PR description should include a breaking-changes note, an extension-API audit, and (ideally) a defineDeprecatedProperty-style warning for the previous contract. The repo has an adding-deprecation-warnings skill specifically for this scenario.
3.12. The New Tests Are Change Detectors
Examples:
- "uses storeInstanceId to resolve and update scoped widget state" — asserts that the new parameter exists and is wired through.
- "clearInstanceWidgets removes only one instance scope" — asserts that prefix-string scanning works as designed.
AGENTS.md:
"Do not write change detector tests."
These pin the shape of the implementation, not the user-visible behavior. Reframe to:
test('multi-instance promoted widgets are isolated', () => {
const [a, b] = makeTwoInstancesOfSameSubgraph()
a.widgets[0].value = 'alpha'
b.widgets[0].value = 'beta'
expect(a.widgets[0].value).toBe('alpha')
expect(b.widgets[0].value).toBe('beta')
})That test passes today and will also pass under any of the refactors I'm suggesting.
3.13. getProxyWidgetInlineState Inflates Module Surface For A One-Liner
export function getProxyWidgetInlineState(entry: ProxyWidgetEntry): { value?: unknown } | undefined {
return entry.length === 4 ? entry[3] : undefined
}If the schema were a discriminated union (per §3.2), this helper would be unnecessary. The discriminator field would tell callers which variant they have, type-narrowed.
"Each new piece of vocabulary is a tax on every reader." — Ousterhout, paraphrased
4. The Path To Enlightenment (A Concrete Refactor Ladder)
Each rung is independently mergeable, and each one strictly improves on the previous.
Rung 0 — Land The Pure Deletions (Yes, Today)
These are subtractions and they are good:
- Delete
_instanceWidgetValuesMap onSubgraphNode. ✓ - Delete
promotedSourceWriteMetaByGraphWeakMap. ✓ - Delete
captureSiblingFallbackValues. ✓ - Replace inline
JSON.parse(JSON.stringify(...))withstructuredClone. ✓ (then see Rung 6)
These can ship as a smaller PR. They reduce duplication unambiguously.
Rung 1 — One Per-Instance Value Store, Structured Keys
- Replace
WidgetKeywithMap<InstanceScope, Map<{nodeId, widgetName}, WidgetState>>. clearInstanceWidgets(scope)becomesouterMap.delete(scope).getWidget(scope, identity)is a structured lookup with no string parsing.
Rung 2 — Eagerly Register Promoted Views
- On
PromotedWidgetViewconstruction, insert a scoped store entry. - On
onRemoved, clear it. - Delete
SafeWidgetData.value. Consumers read the store unconditionally.
Rung 3 — Move Identity Off properties.proxyWidgets
- Promotion identity becomes a property of the
Subgraphdefinition. SubgraphNode.properties.proxyWidgetsis removed (or kept only as a one-time read-time migrator).
Rung 4 — Per-Instance Value Persistence In Its Own Slot
- Workflow JSON gains
subgraphInstanceState: { [subgraphNodeId]: { [promotionId]: value } }. - The 4-tuple inline form is replaced by direct serialization of the value store.
Rung 5 — Schema As Discriminated Union
- Replace the 2/3/4-tuple union with named-variant objects.
- Delete
getProxyWidgetInlineState. - Delete the "ordering is defensive" comment.
Rung 6 — Replace cloneWidgetValue With An Invariant
- Either widget values are JSON-serializable (assert at write time), or they aren't (typed escape hatch).
cloneWidgetValuebecomes a thin alias forstructuredCloneor goes away.
Rung 7 — Fix Tests To Pin Behavior, Not Shape
- Delete change-detector tests for
storeInstanceId,clearInstanceWidgetsprefix matching, etc. - Add behavioral tests of the form "two instances of the same subgraph isolate user edits."
5. A Word Of Encouragement
I want to emphasize, before signing off: the architectural instinct that produced this PR is correct. You looked at a system with three competing per-instance state channels and said "this should be one." That is the right diagnosis. The disagreement is only about the medicine.
The reason this re-review is so long is precisely because the issues are subtle. Inlining {value} into the identity tuple looks like consolidation. Adding instanceId to WidgetKey looks like scoping. cloneWidgetValue's try/catch looks like robustness. Each of these is a local improvement that, when composed, recreates the disease at a different layer.
The literature has names for every smell I cited above because every smell is common, well-known, and survivable. Robert Martin, John Ousterhout, Martin Fowler, Eric Evans, David Parnas, Yaron Minsky, Joe Armstrong, Hunt & Thomas — these authors have spent decades teaching exactly the moves this PR is one or two refactors away from.
If we ship Rung 0 now, and then walk Rungs 1–7 as separate PRs, the result will be:
- One identity store (on the subgraph definition).
- One per-instance value store (structured keys, no string concatenation).
- One read precedence rule (named, typed, single method).
- One schema (discriminated union, no positional tuples).
- One failure mode for uncloneable values (loud).
- One test class (behavioral, not shape-pinning).
- Zero covert function parameters on
this. - Zero silent data-loss branches.
That is an end-state worth aiming for, and you are closer to it than the diff makes it look.
"The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." — Edsger W. Dijkstra, The Humble Programmer, Turing Award Lecture, 1972
Onward — and gently. 🌱
| try { | ||
| return structuredClone(value) | ||
| } catch { | ||
| return value |
There was a problem hiding this comment.
🌱 The catch undoes the very invariant the rest of this PR is fixing.
When structuredClone fails and we return value, we return the same reference. The next state.value = clonedValue then makes two instances point at the same object, and subsequent in-place mutation will leak across instances — which is exactly the multi-instance bug this PR claims to fix.
The accompanying test that forces a function-valued widget value to "prove the catch branch is reachable" is the giveaway. Per AGENTS.md:
Do not focus on making tests pass at the expense of correctness. Never add special-case logic only to satisfy a test, or use workarounds that mask the real problem.
This is the Pokémon exception handler anti-pattern (Hunt & Thomas, The Pragmatic Programmer): swallow everything, surface nothing. An aborted serialize is recoverable; a silently corrupted multi-instance state is not.
Suggested move: let it throw. If a DataCloneError happens in production, that is a real upstream bug worth surfacing.
| return value | |
| return structuredClone(value) |
— “Make illegal states unrepresentable.” — Yaron Minsky, Effective ML, 2010
| * Ordering is defensive: longest tuple first, though `z.tuple` also enforces | ||
| * exact arity so a 4-tuple cannot match the 3-tuple form by length alone. | ||
| */ | ||
| const proxyWidgetTupleSchema = z.union([ |
There was a problem hiding this comment.
🌱 Connascence of Position across the persistence boundary.
This 4-tuple form encodes a compound concept (source identity + optional disambiguator + optional inline value state) by position. Three downstream concerns:
- Position 2 must be
nullwhen absent so position 3 can be present. Adding any future field requires a 5-tuple, then a 6-tuple. Custom-node authors must memorize positions, not field names. - The
Ordering is defensive: longest tuple firstcomment is incorrect.z.tupleenforces arity exactly; the union order does not affect matching. The comment is cargo-culted reassurance and tells future readers to be afraid of something that isn't there. proxyWidgetStateSchema = z.object({ value: z.unknown() })—z.unknown()acceptsundefined, which forces every caller to dostate && state.value !== undefined. The schema is validating the illegal state.
This is CoP-3 (Page-Jones / Weirich connascence taxonomy) spread across _serializeEntries, parseProxyWidgets, getProxyWidgetInlineState, the configure hydration path, and any downstream extension that touches proxyWidgets. CoP across module boundaries is the most expensive form of coupling you can ship in a serialized format.
Parse, don't validate (Alexis King, 2019) — replace the union with a discriminated union of objects:
type PromotedWidgetEntry =
| { kind: 'identity', sourceNodeId: string, sourceWidgetName: string, disambiguator?: string }
| { kind: 'instance-value', sourceNodeId: string, sourceWidgetName: string, disambiguator?: string, value: WidgetValue }The kind discriminator is CoN (a name) rather than CoP (a position). Adding a future variant becomes additive, and getProxyWidgetInlineState disappears.
| * the legacy slot. | ||
| */ | ||
| type WidgetKey = `${NodeId}:${string}` | ||
| type WidgetKey = `${NodeId}:${string}` | `${NodeId}@${NodeId}:${string}` |
There was a problem hiding this comment.
🌱 Primitive Obsession — stringly-typed identity (Fowler, Refactoring, code smell #11).
The compound concept (instanceId?, nodeId, widgetName) is encoded as a string whose internal structure is private convention (@ separates instance from node, : separates node from widget). Three concerns flow from this:
-
clearInstanceWidgetsbecomes a prefix-string scan (line 99) — its very existence is a tell that the data shape is wrong. -
The format is fragile. The day a node ID legitimately contains
@(UUID-prefixed scoped IDs already use:perstripGraphPrefix), this collides silently. -
It contradicts the project's own ADR.
AGENTS.mdcites ADR 0003 + 0008:Centralized registries and ECS-style access: Entity data lives in the World, queried via
world.getComponent(entityId, ComponentType).ECS-style access is structured composite keys, not stringified ones.
Suggested shape:
type WidgetIdentity = { readonly nodeId: NodeId; readonly widgetName: string }
type InstanceScope = NodeId | typeof UNSCOPED
const widgetStates: Map<UUID, Map<InstanceScope, Map<WidgetIdentity, WidgetState>>>Now clearInstanceWidgets is outerMap.get(graphId)?.delete(scope) — no string parsing, no prefix scan, no fragility.
| const widgetStates = getWidgetStateMap(graphId) | ||
| const prefix = `${instanceId}@` | ||
| for (const key of widgetStates.keys()) { | ||
| if (key.startsWith(prefix)) widgetStates.delete(key) |
There was a problem hiding this comment.
🌱 The existence of this method is the smell, not its implementation. Prefix-string scanning a Map to delete-by-instance only makes sense when instance scope has been encoded into the key.
With the structured-key suggestion in the comment above, this method collapses to:
function clearInstanceWidgets(graphId: UUID, instanceId: NodeId): void {
getWidgetStateMap(graphId).get(instanceId)?.clear()
// or simply: outerMap.delete(instanceId)
}No iteration, no string matching, no risk that a node ID containing @ collides with the scope prefix.
“The connections between modules are the assumptions which the modules make about each other.” — David Parnas, On the Criteria To Be Used in Decomposing Systems into Modules, CACM 1972.
| hasMissingBoundSourceWidget: boolean | ||
| views: PromotedWidgetView[] | ||
| } | ||
| private _pendingLegacyWidgetsValues?: unknown[] |
There was a problem hiding this comment.
🌱 This is a covert function parameter masquerading as instance state.
_pendingLegacyWidgetsValues exists only to pass data from configure to _internalConfigureAfterSlots. It is an instance field for the duration of one method call. Two costs follow:
- Information leakage (Parnas, 1972): the secret of "we're carrying widgets_values across a callback boundary" is broadcast to every method on the class — every subclass override, every callback that fires during
super.configure, every introspecting extension. PerAGENTS.md, this surface has 40+ external observers. - The
try/finallycleanup at line 1113 only exists because the field outlives the call. Pass-by-parameter has no cleanup phase.
Suggested refactor:
override configure(info: ExportedSubgraphInstance): void {
// ...other setup that doesn't need legacyValues...
this._configureWith(info, info.widgets_values)
}
private _configureWith(info: ExportedSubgraphInstance, legacyValues: unknown[] | undefined) {
super.configure(info)
// _internalConfigureAfterSlots receives legacyValues directly via closure or another param
}The parameter gains a type, a scope, and a single visible call site. The try/finally cleanup disappears. The blast radius shrinks from "the entire class hierarchy and all its callbacks" to "two methods and the lexical scope between them."
“If you have to look at the body of a function to understand its parameters, the function has lied to you.” — folk wisdom, often attributed to Steve McConnell, Code Complete.
| const pendingValues = new Map<string, unknown>() | ||
|
|
||
| const canHydrateLegacyWidgetsValues = | ||
| this._pendingLegacyWidgetsValues?.length === raw.length |
There was a problem hiding this comment.
🌱 Silent data-loss branch.
The length === raw.length gate is all-or-nothing: if a single legacy widgets_values length differs from raw.length for any reason — a workflow saved by a prior version that emitted N+1 values, a partial file edit, slight schema drift — every legacy value gets discarded. No warning, no error, no log.
This is a Postel's-Law-corollary violation. Postel's liberal in accepting is sometimes paraphrased as "accept anything," but the lesser-known corollary is be loud about ambiguity. Silent acceptance and silent dropping are both forms of the same anti-pattern.
Three improvements, smallest first:
- Migrate per-index where indices align (the 80% case) — even a length mismatch usually has a recoverable prefix.
console.warn(or better,console.error) on length mismatch with enough context to diagnose: workflow name, node ID, expected vs. actual length.- Surface a structured migration result the caller can present to the user ("this workflow had N legacy values; we recovered M").
“Errors should be loud.” — Joe Armstrong, Programming Erlang.
This is exactly the kind of place where data loss breeds support tickets that are impossible to triage because there is no log of the loss.
| const serialized = this._serializeEntries(entries, (key) => | ||
| pendingValues.get(key) | ||
| ) | ||
| if (JSON.stringify(serialized) !== JSON.stringify(raw)) { |
There was a problem hiding this comment.
🌱 Idempotence quietly broken.
Three concerns layered here:
JSON.stringifyequality on a hot path — twice per configure.JSON.stringifyordering is implementation-defined for object keys (V8 vs. JSC differ in edge cases), so the comparison is not even a stable canonical equality.- The
ifis a mirage. The 4-tuple branch reconstructs{value}frompendingValuesrather than preserving the original object reference, so theserializedshape rarely matches the raw input byte-for-byte.properties.proxyWidgetsis mutated on essentially every configure pass. - External watchers fire on every load. Any extension or store observing
properties.proxyWidgetswill see a change-event on every workflow load even when nothing changed.
A noop should be a noop. — twelve-factor app, Stable Configuration
Loading a workflow and immediately saving it should produce a byte-identical artifact. Today it doesn't.
If the schema becomes a discriminated union (see promotionSchema.ts), the rewrite isn't needed at all — the in-memory representation can carry the canonical shape from the moment of parse, and there is nothing to "normalize back."
| * live inline on `proxyWidgets` entries. Delete any value the base-class | ||
| * serialize path may have written for defence in depth. | ||
| */ | ||
| delete serialized.widgets_values |
There was a problem hiding this comment.
🌱 The subclass is fighting the base class.
This override calls super.serialize() to get a record, then deletes a field from it. Two costs:
- Liskov Substitution / Open–Closed (SOLID) —
SubgraphNodeis modifying the base class's output rather than extending it.LGraphNodehas no hook for "I have nowidgets_valuesto serialize," so the subclass reaches into the base class's result. Future contributors changingLGraphNode.serializewon't know they have to coordinate with thisdelete. - Tripwire for future contributors — the moment anyone adds a non-promoted widget to a SubgraphNode (a label widget, the
CANVAS_IMAGE_PREVIEW_WIDGETalready imported in this file), their value will be silently deleted by this single line.
Cleaner pattern — let the base class ask the subclass:
// In LGraphNode:
protected getSerializableWidgetsValues(): unknown[] | undefined {
return /* current logic */
}
// In SubgraphNode:
protected override getSerializableWidgetsValues(): undefined {
return undefined // intent stated, typed, discoverable
}“Software entities should be open for extension, but closed for modification.” — Bertrand Meyer / Robert C. Martin, SOLID.
This is Tell, Don't Ask at the inheritance boundary.
| name: string | ||
| storeName?: string | ||
| type: string | ||
| value?: WidgetValue |
There was a problem hiding this comment.
🌱 A non-reactive snapshot of a reactive value.
The previous SafeWidgetData comment told the truth:
Value and metadata (label, hidden, disabled, etc.) are accessed via widgetValueStore.
That was the right design — single source of truth, reactive, store-backed. The new comment says:
valueprovides the LiteGraph fallback when no scoped store entry exists yet.
Re-read "when no scoped store entry exists yet." That's a description of an eager-initialization bug, not a missing API. The right fix is "promoted views eagerly register a scoped store entry on creation," not "every consumer learns to fall back to a snapshot."
Once snapshots exist, two consumers have to decide which one to read, and the snapshot inevitably drifts from widget.value. Vue's whole reason for existing is to avoid hand-rolled snapshots.
Suggested move (Rung 2 in the review body): in PromotedWidgetView's constructor, register a scoped entry in widgetValueStore seeded from the source widget's current value. Now the store always has an entry, consumers read the store unconditionally, and SafeWidgetData.value can be deleted.
| cloneWidgetValue(sharedValue) | ||
| ) | ||
| return sharedValue | ||
| private getStoreBackedValue(): IBaseWidget['value'] { |
There was a problem hiding this comment.
🌱 The class has become shallow (Ousterhout, A Philosophy of Software Design, §4).
PromotedWidgetView now exposes:
getStoreBackedValuegetScopedStoreValue(public, on the interface)getScopedWidgetStategetLegacyWidgetStategetWidgetStategetWidgetStateForRefsgetStoreRefswriteScopedValue
Eight near-synonymous methods. The fan-out signals that the abstraction "a promoted widget view that may or may not have a scoped store entry" is fighting the data shape.
Suggested refactor — collapse to one method that returns a precise value:
type PromotedWidgetSource =
| { source: 'scoped', state: WidgetState }
| { source: 'host', widget: IBaseWidget, node: LGraphNode }
| { source: 'legacy', state: WidgetState }
| { source: 'missing' }
class PromotedWidgetView {
resolve(): PromotedWidgetSource { /* one place, one precedence */ }
get value() { return reduce(this.resolve()) }
set value(v) { write(this.resolve(), v) }
}The precedence (scoped → host → legacy) is named and visible, callers branch once on a discriminated union, adding a new resolution mode is a typed addition rather than a new private getter.
The best modules are deep: they have powerful functionality yet simple interfaces. — Ousterhout, APoSD, §4.5
|
Follow-up on @DrJKL re-review: Fixed in
I am intentionally keeping the larger architecture points as follow-up work rather than expanding this regression PR:
Those are good directions, but they touch persisted workflow format, store architecture, LiteGraph serialization hooks, and extension-observable behavior. This PR is scoped to restoring the Validation for
|
|
Hello again — and thank you genuinely for the careful follow-up on I do want to gently push back on the framing of the rest, though — because there is an important distinction hiding inside the deferral list, and I think it's worth surfacing before this lands. The distinction: deferring existing debt vs. shipping new debtThe two are not the same thing, and our usual scope-discipline arguments only license the first.
The Boy Scout Rule explicitly tolerates not improving what you didn't touch. It does not tolerate worsening it. Of the seven items in your deferral list, four are existing debt the PR isn't expanding (#1, #3, #7 — and arguably #9 of my numbering above). I have no objection to deferring those. But three of the seven are debt this PR is creating, not pre-existing debt being left alone: A. The 4-tuple persisted shape (deferral item 2)Pre-#10849 there was no inline
Doing it now costs:
This is the textbook case where Hunt & Thomas's "broken windows" framing applies most strongly: the cost of fixing a persisted-format choice scales with the number of artifacts saved between now and the fix. That number starts climbing the moment this merges. B.
|
|
@DrJKL thank you for drawing the distinction between deferring existing debt and shipping new debt. I agree that this PR needed a bit more than the previous follow-up comment captured. Fixed in
I also filed concrete follow-up issues with code references:
I left the discriminated persisted shape and eager scoped-store registration as follow-ups rather than landing them in this regression PR because both change broader persisted/render architecture beyond the immediate corruption fix. They are now tracked as backlog issues instead of living only in this review thread. Validation:
|
|
Thank you for I owe you a third (and intended-final) round of feedback, and I want to be upfront about its shape before you read it: I spent meaningful time on this before writing, including weighing whether the right thing was simply to drop my objections, given that you have already shipped working behavior under regression tests, and given that the seven deferred items are real and reasonable to defer. I considered that, and rejected it — not because the deferrals are unreasonable individually, but because re-reading the PR end-to-end against Issue #10146 made me believe the PR is solving two problems where there is really only one, and the second "problem" is an artifact of how the first was approached rather than a thing that exists in the domain. I also want to be clear that I considered (and rejected) asking for a pure rollback of #10849. The user impact of #10146 — silent wrong image generation on workflow load — is strictly worse than the template-corruption regression #11559 is fixing, and a pure revert resurrects it. So this isn't an argument for "don't fix it." It's an argument for "the cleaner fix is smaller than what's currently in the diff." What follows is an attempt to lay that out as carefully as I can, so you (and the maintainers reading along) can decide whether it's worth a course correction now or whether the cost of re-cutting the PR exceeds the cost of carrying the extra surface area forward. I will try to be specific where I can, fair where the PR has good arguments on its side, and brief where the previous two reviews already covered the ground. I. The story of how we got hereI think the clearest way to talk about this is as a sequence of timelines — five small acts, each ending with a single new piece of state being introduced that, with the benefit of hindsight, was either avoidable or pointed in a different direction than the one taken. Forgive me the theatricality; I find it easier to reason about regressions when they are told as a sequence of decisions rather than as a static diff. Act I — v1.39.x and earlier: one widget, one valueBefore the Vue-rendered widget pipeline, a widget's value lived in exactly one place: as a property on the plain widget object hanging off One cell, one consumer, no ambiguity. The schema ( Act II — v1.41.3 (PR #8594):
|
| Lens | PR #11559 today | S7 |
|---|---|---|
| Per-instance value storage sites | 4+ (proxyWidgets[3].value, _instanceWidgetValues legacy, _pendingLegacyWidgetsValues, store) |
1 (store) |
| Key-encoding schemes | 4 (@-string store key, 4-tuple positional, proxyWidgets[3].value inline, snapshot field) |
1 (store key) |
| New persisted-format variants | 1 (4-tuple) | 0 |
| Backwards-compat scaffolding for the new format | _pendingLegacyWidgetsValues + 4-tuple migrator + snapshot + clone |
none |
| New files | 3 | 0 |
| Diff size relative to #10849 | +876 / −382 | ~+150 / −50 |
This is approximate, not a sharp measurement. But the order of magnitude difference is the point: when the keying is fixed at the source, almost everything else falls out, because almost everything else was scaffolding to keep two would-be sources of truth from disagreeing.
"There is no part so reliable as the part you didn't add." — folk variant of Antoine de Saint-Exupéry, by way of every embedded engineer who has had to debug at 3 a.m.
V. Steelman for keeping #11559 as-is
I want to make sure I'm being fair here. The PR is not arbitrary; there are real arguments for the inline-{value} schema. Here are the four strongest I can construct, with what I take to be honest counters:
1. Inline {value} is robust to the blueprint changing between saves. If a user adds or removes a promoted widget between save and load, positional widgets_values shifts and indices may misalign. An inline {value} keyed by widget identity does not have this problem.
Counter: this is a real concern, but it is a separate concern from #10146, and it predates this PR. If we want robustness against blueprint shape drift, the focused answer is a sidecar
{instanceKey → index}map written alongsidewidgets_values, not a universal schema change. We can ship that change deliberately when we're ready to commit to a new persisted shape, with the migration story planned end-to-end. Bundling it into a regression fix forecloses better designs.
2. SafeWidgetData.value snapshot helps Vue avoid reactive-proxy issues during serialize. Reactive proxies inside JSON.stringify paths have bitten this codebase before.
Counter:
LGraphNode.serializealready does a structured-clone-equivalent (JSON.parse(JSON.stringify(...))) on widget values precisely to handle this. Adding a parallel snapshot field is belt-and-suspenders that introduces a second authoritative copy of every widget value at serialize time. If reactive-proxy escape is a real and reproducible bug, it's worth fixing directly in the existing clone path; if it isn't, the snapshot is dead code that future maintainers will be afraid to remove (Hyrum's Law in slow motion).
3. Two-source-of-truth drift between widgets_values and inline {value} is exactly what delete serialized.widgets_values prevents. Removing the legacy projection guarantees the new schema is authoritative.
Counter: under S7 there is one source — the store.
widgets_valuesis just the on-wire projection of the store; nothing reads it at runtime. There is no drift to prevent because there is no second source to drift from. Thedeleteis a sensible patch given the inline-{value}decision; remove that decision and the patch is unnecessary. SubvertingLGraphNode.serialize's contract from a subclass with adeleteis precisely the kind of base-class subversion Liskov would frown at, and the prior follow-up's "base-class hook instead ofdelete" suggestion was an attempt to sand that edge — but the cleanest sanding is "don't need to delete it in the first place."
4. The PR has been red-green verified with it.fails regression tests from PR #11697 flipping to passing on this branch.
Counter: this is real and important, and I want to acknowledge it without diminishing it. Those tests are testing a runtime contract: each instance's promoted-widget value round-trips independently of every other instance's. S7 implements the same contract — instance-scoped writes through
PromotedWidgetView.value's setter — on a simpler persistence surface. If S7 lands, the same tests pass. The tests do not constrain which implementation; they only verify the externally observable behavior, which is exactly the property we want of regression tests (per Beck's "tests are the shape of the cliff edge, not the path you walked along it").
There may be a fifth steelman I haven't found, and if so I'd genuinely like to hear it; reviewing my own argument for holes is the part I'm least confident about.
VI. Migration story (the three cohorts)
There are three populations of workflow files in the wild, and a serious answer needs to be honest about what each one experiences.
Cohort A — pre-v1.41.3 workflows. Positional widgets_values carries per-instance data correctly, because there was no shared store collapsing it. Under S7, these load correctly — more correctly than they do today, since today's path runs them through #10849's instance Map and PR #11559's 4-tuple, neither of which they were saved against. This is the cohort that benefits most from S7: it restores forward compatibility with the same positional format their files have always carried.
Cohort B — v1.41.3 through v1.43.x workflows. These were saved while the store was collapsing all instances into one cell. On disk, widgets_values for a given SubgraphNode reflects whichever instance was serialized last — every instance shows the same value. There is no recovery story for these. No PR can magically reconstruct data that was never persisted. Under both #11559-as-shipped and S7, users with these files re-edit per-instance values once after upgrade. This is unfortunate but is not a difference between the two approaches.
Cohort C — v1.44.x workflows saved under PR #11559's 4-tuple form. This is the only cohort where the choice has a cost. If S7 simply drops the 4-tuple, these files lose their per-instance values on load (they fall back to positional widgets_values, which #11559 now deletes, leaving nothing).
Mitigation: keep the 4-tuple parser in
parseProxyWidgetsfor one release cycle as a read-only fallback. Roughly:// ~5 lines: if 4-tuple inline {value} is present, populate the store // for that instance/widget. This is read-only fallback; the writer // always emits the 3-tuple + positional widgets_values shape.Drop the parser in the next release with a console deprecation notice in between. This is consistent with how the prior follow-up framed deprecation ("warn loudly when accommodating legacy data, then remove the accommodation in a subsequent release") and gives Cohort C a clean upgrade path.
Cohort C is small if PR #11559 has not yet reached a stable release. If it has, the cost of the parser-shim mitigation is bounded and clearly time-limited.
VII. The ask
I want to be specific about what I am asking for, because "rework" without specifics is not a fair request to make of an author who has already shipped working behavior under regression tests.
Two procedural shapes are worth considering, and I do not have a strong preference between them — they are both honest paths and the choice is yours and the maintainers':
Option 1 — Rework this branch in place
Push the S7 changes onto the existing PR branch. This preserves PR history, reviewer continuity, and the regression tests already attached to the PR. The transitional 4-tuple parser shim (§VI) goes in alongside the schema revert. The branch goes from "introduces 4-tuple persistence" to "tightens widgetValueStore keying" — a smaller, more focused PR with the same green tests.
Estimated cost: ~1–2 days of author time, given that the runtime chokepoint (PromotedWidgetView.value setter) is already where instance scoping lives in the current branch. The mechanical work is removing the schema scaffolding and routing the existing serialize/configure projections through the store instead of the instance Map.
Option 2 — Close this PR; open a smaller successor
Land PR #11697's it.fails markers on main as a holding pattern, and open a new PR scoped to "add instanceId to widgetValueStore + replace _instanceWidgetValues Map with store-keyed reads." The new PR inherits this PR's regression contract and reviewer audience but starts fresh from a clean diff base.
Estimated cost: comparable to Option 1, with the trade that PR history is split (this PR's discussion threads don't carry over) but the resulting diff is easier for new reviewers to evaluate from cold start.
What either option requires
- The runtime contract under regression tests stays exactly as it is now (same
it.failsflips, same multi-instance isolation). _instanceWidgetValuesMap from fix: store promoted widget values per SubgraphNode instance #10849 is removed; the store replaces it.- The 4-tuple parser stays for one release as the migration shim for Cohort C; the writer never emits it.
- A short note in the PR description and CHANGELOG explaining the Cohort C migration window.
- No deprecation warnings on the source-widget-mutation contract change are needed under S7, because the runtime contract is the same as fix: restore SubgraphNode.widgets_values dead-field invariant (#10849 regression) #11559's — it's the persistence surface that shrinks. (The earlier follow-up's request for deprecation warnings was conditional on shipping the new contract; that becomes a non-issue here.)
What re-review costs
The Codex / @jaeone94 reviewers who endorsed the 4-tuple shape because "identity and value travel together so reorders don't desync" will rightly want to weigh in on the trade. The honest framing for them: "S7 makes the store the SSOT; identity and value desync is impossible because there is only one place values live; the persistence surface is the existing positional format that the entire ComfyUI ecosystem already speaks." If they push back hard, that's a real signal worth taking seriously, and at that point shipping #11559 as-is with the prior follow-up's items addressed (the console.warn on legacy length-mismatch drop, the base-class serialize hook, the migration note, the filed follow-up issues) is a reasonable fallback.
I am asking for the architectural conversation to happen now, before the persistence surface ships, because §VI's Cohort C only grows once #11559 reaches a stable release.
VIII. Closing word
The throughline I want to leave you with is this: #10849 was correct in instinct and small in size; #11559 has correct instincts but very much not small in size, and the difference between them is that #11559 chose to fix the regression and land an architectural commitment to a new persisted shape simultaneously. Those are separable concerns. S7 is what the regression fix looks like when they are separated.
You have engaged seriously with every round of feedback so far. The work in this PR — the regression contract, the instance-scoped chokepoint, the test inversions, the responses to the prior reviews — informs whatever ships next. The question now is just where the architectural commitment line gets drawn, and how durable that commitment is. The persisted format is the most durable kind of commitment a codebase can make; I'd ask that we be especially deliberate about that one.
Whichever path you take, thank you for the patience with three rounds of dense feedback. I really do think the codebase ends up better for the engagement, even when (especially when) the conclusion is "do less."
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." — Antoine de Saint-Exupéry, Wind, Sand and Stars
🌱
|
@DrJKL thanks for taking the time to write this out. I agree with the main architectural instinct behind S7: the instance dimension belongs in the value layer, and the current I do not think we should re-cut this PR to S7 before landing, though. First, a couple of details in the S7 comparison are now stale against the current head:
The larger reason is that I think there are two separate constraints here, not one:
The reason I am comfortable with the current inline I think S7 is worth prototyping as follow-up work, especially under #11740 / #11741. The acceptance bar I would want for that prototype is:
Given the current branch state, green CI, and the already-filed follow-ups, my preference is to land this regression fix and evaluate S7 as a deliberate successor/prototype rather than resetting this PR into a broader architecture rewrite. |
Summary
widgets_valuesround-trip onSubgraphNode, corrupting pre-existing templates (for example Z-Image-Turbo) whosewidgets_valueswas never produced by the promoted-widget save path.proxyWidgetsentry so identity and value travel together through reorder, null-entry filtering, clipboard paste, subgraph dedup, nested-pack ID remap, and sibling instance fallback paths.SubgraphNode.widgets_valuesis a dead field. Subgraph instances now serialize promoted values only through inlineproxyWidgetsstate.Reported: Slack thread
Root Cause
Pre-#10849,
PromotedWidgetView.serialize = falseandSubgraphNodenever setserialize_widgets, sowidgets_valueson aSubgraphNodewas a dead field. Saved templates could carry arbitrary stale content there without affecting runtime.PR #10849 started writing
widgets_valuespositionally from_getPromotedViews().filter(v => v.sourceSerialize)and reading it back positionally in_internalConfigureAfterSlots. Pre-existing templates can havewidgets_valuesarrays that do not align with current promoted-view order, so the new loader applied stale values to the wrong slots.Design
The chosen regression-fix format keeps promotion identity and per-instance value in the same existing
proxyWidgetsrecord:// 4-tuple: [sourceNodeId, sourceWidgetName, disambiguator | null, { value }]This avoids a broader migration of the clipboard, subgraph-dedup, and nested-pack ID-remap paths in this PR while making save/load robust against promoted-view reorder.
Important implementation details:
cloneWidgetValuenow usesstructuredClonewithout a raw-reference fallback, so uncloneable mutable values fail loudly instead of sharing references across instances.{ value }state rejects explicitundefined; missing inline state remains represented by the 2/3-tuple forms.widgets_valuesfrom v1.44.5-7 are migrated into scoped inline state on load. Mismatched legacy arrays are not applied and now warn in DEV.SubgraphNodesuppresseswidgets_valuesthroughLGraphNode.getSerializableWidgetsValues()instead of deleting the serialized field aftersuper.serialize().PromotedWidgetView.valuewrites scoped per-instance state only. It no longer mutates the source widget's.value.Migration / Extension Notes
widgets_valuesare not applied to promoted-widget state, so inner widget defaults remain intact.proxyWidgetsstate on load and are re-saved there.proxyWidgetsentries. Opening those workflows in pre-merge frontends can drop promotions for thatSubgraphNode. If cross-version sharing is a release requirement, a tolerant-schema patch release against v1.44.x is needed before this ships..value. Extensions that need per-instance state should read/write the promoted widget orwidgetValueStore; the source widget remains the definition/default fallback.Follow-Up Issues
SubgraphNode.widgets_valuesexplicitly during configure.Verification
pnpm test:unit -- src/lib/litegraph/src/subgraph/SubgraphNode.multiInstance.test.ts src/lib/litegraph/src/LGraphNode.test.tspnpm typecheckpnpm format:checkpnpm exec oxlint src/core/graph/subgraph/promotedWidgetView.ts src/lib/litegraph/src/LGraphNode.ts src/lib/litegraph/src/subgraph/SubgraphNode.ts src/lib/litegraph/src/subgraph/SubgraphNode.multiInstance.test.tspnpm knipVideo
Screen.Recording.2026-04-28.at.12.06.02.PM.mov