Skip to content

refactor(layout): centralize node, group, and reroute geometry - #14110

Merged
DrJKL merged 37 commits into
feature/ecs-migrationfrom
drjkl/layout-single-source
Jul 31, 2026
Merged

DrJKL merged 37 commits into
feature/ecs-migrationfrom
drjkl/layout-single-source

Conversation

@DrJKL

@DrJKL DrJKL commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Centralizes node, group, and reroute geometry in layoutStore so moves, resizes, snapping, workflow insertion, and subgraph operations update one authoritative geometry path without colliding with live workflow state.

Changes

  • What:
    • Stores node and group bounds as single rectangle values and makes reroute position read and write through layoutStore.
    • Routes drag, paste, snap, legacy-scale normalization, arrangement, and subgraph unpacking through whole-value geometry setters.
    • Adds group and reroute lifecycle handling, minimap reads, hit testing, undo/redo support, and subgraph-safe geometry IDs.
    • Converts inserted workflows directly to clipboard items instead of configuring a scratch graph whose entity IDs can collide with the open workflow.
    • Removes the redundant graph-to-layout resync and unused previous values from layout operations.
    • Updates the ECS architecture docs and adds focused unit and browser coverage for geometry, subgraphs, workflow insertion, and undo/redo.
  • Compatibility: LGraphNode.pos / size, group geometry, and Reroute.pos retain stable mutable array or rectangle identities through a shared geometry view. Indexed writes and mutating methods commit through layoutStore; whole-value assignment remains supported. The internal moveChildNodesInGroupVueMode and repositionNodesVueMode helpers are removed.

Geometry before this PR

flowchart LR
  interactions[Drag, snap, paste, arrange, normalize] --> direct[Direct array writes]
  interactions --> setters[Setters and move methods]
  interactions --> helpers[Mode-specific helpers]

  direct --> nodeClass[Node Rectangle]
  setters --> nodeClass
  helpers --> nodeClass
  nodeClass --> nodeStore[layoutStore node position, size, bounds]
  nodeClass --> resync[Bulk graph-to-store resync]
  resync --> nodeStore

  direct --> groupClass[Group _bounding only]
  setters --> groupClass

  direct --> rerouteClass[Reroute posInternal]
  setters --> rerouteClass
  rerouteClass --> rerouteYjs[Yjs position]
  rerouteClass --> rerouteLayout[RerouteLayout position]

  nodeStore --> minimap[Minimap and spatial index]
  groupClass --> minimap
  rerouteLayout --> hitTest[Hit testing]
Loading
Entity or operation Geometry storage Write paths Lifecycle and consumers Resulting risk
Nodes Class Rectangle plus separate position, size, and bounds store fields Setters, move, direct element writes, mode-specific helpers Store seeding and a bulk resync patched missed writes Class and store values could diverge; snapping or offsets could disappear on writeback
Groups LGraphGroup._bounding only Setters, direct writes, resize, resizeTo, configure, and snapToGrid Graph owned the class instance; minimap read the class Group geometry was absent from the CRDT-backed layout model
Reroutes posInternal, Yjs position, and RerouteLayout.position move, setter, and in-place snapping each updated a different subset Separate seeding paths populated render and hit-test state Three copies could disagree; the setter did not commit to the store
Workflow insertion Temporary LGraph configured before clipboard serialization Scratch entities wrote through normal layout hooks Temporary IDs shared the same numeric range as the open workflow Inserting a workflow could move or delete live layout entries
Subgraphs Entity IDs and geometry were handled locally by several conversion paths Element-wise offsets and shared IDs Groups and reroutes crossed graph boundaries without complete scoping Stored positions could use inner-graph coordinates or collide across subgraphs

Geometry with this PR

flowchart LR
  interactions[Drag, snap, paste, arrange, normalize] --> api[Whole-value setters and move]
  api --> commands[Serializable layout mutations]
  commands --> store[layoutStore]

  store --> nodeRect[Node rect]
  store --> groupRect[Group rect]
  store --> reroutePoint[Reroute position]

  nodeRect --> sync[Class writeback]
  groupRect --> sync
  sync --> canvas[Canvas and serialization]

  nodeRect --> minimap[Minimap and spatial index]
  groupRect --> minimap
  reroutePoint --> hitTest[Hit testing]

  commands --> history[Undo and redo]
  workflow[Workflow data] --> clipboard[Clipboard items]
  clipboard --> liveGraph[Open workflow]
  subgraphs[Subgraph mapping and ID deduplication] --> commands
Loading
Entity or operation Geometry storage Write path Lifecycle and consumers Effect of this PR
Nodes One rect value in layoutStore, with class geometry kept in sync for litegraph Whole-value setters and move produce layout mutations Existing node registration, renderer sync, minimap, spatial index, and undo/redo Position, size, and bounds cannot disagree inside the store
Groups One rect value in layoutStore setBounds is the single internal writer; public geometry APIs delegate to it LGraph.add, remove, and clear register or remove entries; minimap reads the store Groups participate in the same command and store model as nodes
Reroutes One authoritative position in layoutStore; Reroute.pos exposes a stable synchronized view Assignment, indexed or method mutation, move, and snapping commit through layout mutations Constructor registration, graph-scoped lookup, hit testing, and undo/redo use stored geometry Removes posInternal and the duplicate hit-test position without breaking mutable point access
Workflow insertion Workflow data converts directly to clipboard items workflowToClipboardItems avoids constructing entities Only pasted entities enter the open graph and layout lifecycle Temporary entity IDs can no longer touch live layout state
Subgraphs Group and reroute geometry uses graph-aware mapping and deduplicated IDs Conversion and unpacking assign whole values through setters Reroutes survive graph traversal; group IDs are unique after deduplication Geometry stays attached to the correct graph and coordinates

Downstream stack

  • #14128 moves node layout registration and recursive teardown to entity attach/detach paths, then deletes the renderer-owned useVueNodeLifecycle composable and the unused operation log.
  • #14133 makes layoutStore authoritative for node reads through the shared geometry view's versioned projection, removes useLayoutSync, and leaves only operation-driven resize notifications and canvas invalidation.

This PR retains the current node-registration and Layout→LiteGraph synchronization boundaries. The downstream PRs change each boundary separately.

Review Focus

  • Geometry ownership and lifecycle in layoutStore, especially registration and cleanup for groups and reroutes.
  • Subgraph boundaries: reroute preservation, group ID deduplication, and mapping stored geometry to the active graph.
  • Workflow insertion now uses workflowToClipboardItems directly; check parity with the previous scratch-graph serialization path.
  • Extension compatibility around stable node, group, and reroute geometry views, including indexed and method-based mutation as well as whole-value assignment.
  • The PR changes 56 files and includes mechanical setter migrations alongside the store changes. The core review path is layoutStore, layoutMutations, createGeometryView, LGraphGroup, LGraphNode, Reroute, subgraph deduplication, then workflow conversion.
Findings that a dumb agent might call out

These are plausible-looking review findings that do not survive inspection:

  • "Remote reroute moves leave the geometry cache stale." Remote Yjs updates are explicitly future work. Local reroute moves update the cache and spatial index synchronously, and this PR does not claim to ship collaboration.
  • "Removing previous* fields breaks undo." Undo/redo uses serialized graph snapshots through the change tracker, not inverse layout operations. The removed fields had no consumers, and browser coverage exercises undo/redo across node, group, and reroute movement.
  • "The shared geometry view is unnecessary magic." It is the compatibility boundary that preserves stable legacy node, group, and reroute Point, Size, and Rectangle identities, including element-wise and method-based mutation. Focused tests cover synchronization, read-through, and write-through behavior.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f34d70e0-39bf-4b29-b8b1-2f420bfb81b3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
End-To-End Regression Coverage For Fixes ❓ Inconclusive PR title/commit subjects aren’t provided here, so I can’t verify the bug-fix signal required by the check. Please provide the PR title or commit subjects so I can determine whether bug-fix language is present and apply the regression-test rule.
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Adr Compliance For Entity/Litegraph Changes ✅ Passed PASS: The metadata shows geometry mutations moving to store-backed setters/commands, with legacy helpers removed and no clear ADR 0003/0008 violations.
Title check ✅ Passed The title is concise and accurately summarizes the main refactor: centralizing geometry for nodes, groups, and reroutes.
Description check ✅ Passed It covers Summary, Changes, compatibility notes, and Review Focus; screenshots are optional, so the template is mostly complete.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drjkl/layout-single-source

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 07/31/2026, 08:51:44 AM UTC

Links

🎭 Playwright: ✅ 1755 passed, 0 failed · 4 flaky

📊 Browser Reports
  • chromium: View Report (✅ 1734 / ❌ 0 / ⚠️ 4 / ⏭️ 5)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

📦 Bundle Size

⏳ Size data collection in progress…

⚡ Performance Report

canvas-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 70.3 MB heap
canvas-mouse-sweep: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 47.6 MB heap
canvas-zoom-sweep: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 73.3 MB heap
dom-widget-clipping: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 56.3 MB heap
large-graph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 61.1 MB heap
large-graph-pan: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 62.9 MB heap
large-graph-zoom: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 69.6 MB heap
minimap-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 66.9 MB heap
subgraph-dom-widget-clipping: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 56.0 MB heap
subgraph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 44.6 MB heap
subgraph-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 46.3 MB heap
subgraph-transition-enter: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 112ms TBT · 93.3 MB heap
viewport-pan-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 68.0 MB heap
vue-large-graph-idle: · 55.4 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 172.8 MB heap
vue-large-graph-pan: · 55.4 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 545ms TBT · 149.9 MB heap
workflow-execution: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 49.7 MB heap

ℹ️ No baseline found — significance unavailable.

Absolute values
Metric Value
canvas-idle: avg frame time 17ms
canvas-idle: p95 frame time 17ms
canvas-idle: layout duration 0ms
canvas-idle: style recalc duration 7ms
canvas-idle: layout count 0
canvas-idle: style recalc count 9
canvas-idle: task duration 457ms
canvas-idle: script duration 24ms
canvas-idle: TBT 0ms
canvas-idle: heap used 70.3 MB
canvas-idle: DOM nodes 18
canvas-idle: event listeners 4
canvas-mouse-sweep: avg frame time 17ms
canvas-mouse-sweep: p95 frame time 17ms
canvas-mouse-sweep: layout duration 4ms
canvas-mouse-sweep: style recalc duration 44ms
canvas-mouse-sweep: layout count 12
canvas-mouse-sweep: style recalc count 81
canvas-mouse-sweep: task duration 1021ms
canvas-mouse-sweep: script duration 176ms
canvas-mouse-sweep: TBT 0ms
canvas-mouse-sweep: heap used 47.6 MB
canvas-mouse-sweep: DOM nodes -104
canvas-mouse-sweep: event listeners -151
canvas-zoom-sweep: avg frame time 17ms
canvas-zoom-sweep: p95 frame time 17ms
canvas-zoom-sweep: layout duration 1ms
canvas-zoom-sweep: style recalc duration 16ms
canvas-zoom-sweep: layout count 6
canvas-zoom-sweep: style recalc count 32
canvas-zoom-sweep: task duration 377ms
canvas-zoom-sweep: script duration 23ms
canvas-zoom-sweep: TBT 0ms
canvas-zoom-sweep: heap used 73.3 MB
canvas-zoom-sweep: DOM nodes 78
canvas-zoom-sweep: event listeners 19
dom-widget-clipping: avg frame time 17ms
dom-widget-clipping: p95 frame time 17ms
dom-widget-clipping: layout duration 0ms
dom-widget-clipping: style recalc duration 7ms
dom-widget-clipping: layout count 0
dom-widget-clipping: style recalc count 11
dom-widget-clipping: task duration 392ms
dom-widget-clipping: script duration 79ms
dom-widget-clipping: TBT 0ms
dom-widget-clipping: heap used 56.3 MB
dom-widget-clipping: DOM nodes 18
dom-widget-clipping: event listeners 0
large-graph-idle: avg frame time 17ms
large-graph-idle: p95 frame time 17ms
large-graph-idle: layout duration 0ms
large-graph-idle: style recalc duration 5ms
large-graph-idle: layout count 0
large-graph-idle: style recalc count 8
large-graph-idle: task duration 803ms
large-graph-idle: script duration 232ms
large-graph-idle: TBT 0ms
large-graph-idle: heap used 61.1 MB
large-graph-idle: DOM nodes -274
large-graph-idle: event listeners -146
large-graph-pan: avg frame time 17ms
large-graph-pan: p95 frame time 17ms
large-graph-pan: layout duration 0ms
large-graph-pan: style recalc duration 14ms
large-graph-pan: layout count 0
large-graph-pan: style recalc count 69
large-graph-pan: task duration 1714ms
large-graph-pan: script duration 930ms
large-graph-pan: TBT 0ms
large-graph-pan: heap used 62.9 MB
large-graph-pan: DOM nodes -276
large-graph-pan: event listeners -147
large-graph-zoom: avg frame time 17ms
large-graph-zoom: p95 frame time 17ms
large-graph-zoom: layout duration 8ms
large-graph-zoom: style recalc duration 14ms
large-graph-zoom: layout count 60
large-graph-zoom: style recalc count 65
large-graph-zoom: task duration 2005ms
large-graph-zoom: script duration 1075ms
large-graph-zoom: TBT 0ms
large-graph-zoom: heap used 69.6 MB
large-graph-zoom: DOM nodes -281
large-graph-zoom: event listeners -150
minimap-idle: avg frame time 17ms
minimap-idle: p95 frame time 17ms
minimap-idle: layout duration 0ms
minimap-idle: style recalc duration 6ms
minimap-idle: layout count 0
minimap-idle: style recalc count 8
minimap-idle: task duration 821ms
minimap-idle: script duration 249ms
minimap-idle: TBT 0ms
minimap-idle: heap used 66.9 MB
minimap-idle: DOM nodes -276
minimap-idle: event listeners -147
subgraph-dom-widget-clipping: avg frame time 17ms
subgraph-dom-widget-clipping: p95 frame time 17ms
subgraph-dom-widget-clipping: layout duration 0ms
subgraph-dom-widget-clipping: style recalc duration 12ms
subgraph-dom-widget-clipping: layout count 0
subgraph-dom-widget-clipping: style recalc count 48
subgraph-dom-widget-clipping: task duration 421ms
subgraph-dom-widget-clipping: script duration 141ms
subgraph-dom-widget-clipping: TBT 0ms
subgraph-dom-widget-clipping: heap used 56.0 MB
subgraph-dom-widget-clipping: DOM nodes 22
subgraph-dom-widget-clipping: event listeners 7
subgraph-idle: avg frame time 17ms
subgraph-idle: p95 frame time 17ms
subgraph-idle: layout duration 0ms
subgraph-idle: style recalc duration 8ms
subgraph-idle: layout count 0
subgraph-idle: style recalc count 10
subgraph-idle: task duration 495ms
subgraph-idle: script duration 15ms
subgraph-idle: TBT 0ms
subgraph-idle: heap used 44.6 MB
subgraph-idle: DOM nodes -273
subgraph-idle: event listeners -152
subgraph-mouse-sweep: avg frame time 17ms
subgraph-mouse-sweep: p95 frame time 17ms
subgraph-mouse-sweep: layout duration 4ms
subgraph-mouse-sweep: style recalc duration 33ms
subgraph-mouse-sweep: layout count 16
subgraph-mouse-sweep: style recalc count 76
subgraph-mouse-sweep: task duration 777ms
subgraph-mouse-sweep: script duration 102ms
subgraph-mouse-sweep: TBT 0ms
subgraph-mouse-sweep: heap used 46.3 MB
subgraph-mouse-sweep: DOM nodes -273
subgraph-mouse-sweep: event listeners -152
subgraph-transition-enter: avg frame time 17ms
subgraph-transition-enter: p95 frame time 17ms
subgraph-transition-enter: layout duration 9ms
subgraph-transition-enter: style recalc duration 24ms
subgraph-transition-enter: layout count 6
subgraph-transition-enter: style recalc count 9
subgraph-transition-enter: task duration 842ms
subgraph-transition-enter: script duration 40ms
subgraph-transition-enter: TBT 112ms
subgraph-transition-enter: heap used 93.3 MB
subgraph-transition-enter: DOM nodes 13671
subgraph-transition-enter: event listeners 2383
viewport-pan-sweep: avg frame time 17ms
viewport-pan-sweep: p95 frame time 17ms
viewport-pan-sweep: layout duration 0ms
viewport-pan-sweep: style recalc duration 38ms
viewport-pan-sweep: layout count 0
viewport-pan-sweep: style recalc count 250
viewport-pan-sweep: task duration 6058ms
viewport-pan-sweep: script duration 3139ms
viewport-pan-sweep: TBT 0ms
viewport-pan-sweep: heap used 68.0 MB
viewport-pan-sweep: DOM nodes -276
viewport-pan-sweep: event listeners -131
vue-large-graph-idle: avg frame time 18ms
vue-large-graph-idle: p95 frame time 17ms
vue-large-graph-idle: layout duration 0ms
vue-large-graph-idle: style recalc duration 0ms
vue-large-graph-idle: layout count 0
vue-large-graph-idle: style recalc count 0
vue-large-graph-idle: task duration 17579ms
vue-large-graph-idle: script duration 959ms
vue-large-graph-idle: TBT 0ms
vue-large-graph-idle: heap used 172.8 MB
vue-large-graph-idle: DOM nodes -6548
vue-large-graph-idle: event listeners -7469
vue-large-graph-pan: avg frame time 18ms
vue-large-graph-pan: p95 frame time 17ms
vue-large-graph-pan: layout duration 0ms
vue-large-graph-pan: style recalc duration 21ms
vue-large-graph-pan: layout count 0
vue-large-graph-pan: style recalc count 158
vue-large-graph-pan: task duration 21833ms
vue-large-graph-pan: script duration 1458ms
vue-large-graph-pan: TBT 545ms
vue-large-graph-pan: heap used 149.9 MB
vue-large-graph-pan: DOM nodes -6548
vue-large-graph-pan: event listeners -7466
workflow-execution: avg frame time 17ms
workflow-execution: p95 frame time 17ms
workflow-execution: layout duration 1ms
workflow-execution: style recalc duration 21ms
workflow-execution: layout count 4
workflow-execution: style recalc count 17
workflow-execution: task duration 125ms
workflow-execution: script duration 12ms
workflow-execution: TBT 0ms
workflow-execution: heap used 49.7 MB
workflow-execution: DOM nodes 136
workflow-execution: event listeners 66
Raw data
{
  "timestamp": "2026-07-31T09:01:57.171Z",
  "gitSha": "50d07fec394b2f547d45dba277a080db71c6356f",
  "branch": "drjkl/layout-single-source",
  "measurements": [
    {
      "name": "canvas-idle",
      "durationMs": 2038.2390000000044,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 7.872000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 456.099,
      "heapDeltaBytes": 4786880,
      "heapUsedBytes": 73874892,
      "domNodes": 18,
      "jsHeapTotalBytes": 19525632,
      "scriptDurationMs": 28.643,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "canvas-idle",
      "durationMs": 2021.2390000000369,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 6.904999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 456.912,
      "heapDeltaBytes": 4506768,
      "heapUsedBytes": 73581248,
      "domNodes": 18,
      "jsHeapTotalBytes": 19525632,
      "scriptDurationMs": 19.972,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 2105.913000000015,
      "styleRecalcs": 82,
      "styleRecalcDurationMs": 51.187999999999995,
      "layouts": 12,
      "layoutDurationMs": 3.891,
      "taskDurationMs": 1138.487,
      "heapDeltaBytes": -15517784,
      "heapUsedBytes": 53686328,
      "domNodes": -269,
      "jsHeapTotalBytes": 20701184,
      "scriptDurationMs": 198.013,
      "eventListeners": -150,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 1852.5340000000483,
      "styleRecalcs": 79,
      "styleRecalcDurationMs": 36.152,
      "layouts": 12,
      "layoutDurationMs": 3.3040000000000007,
      "taskDurationMs": 903.0070000000001,
      "heapDeltaBytes": -22913704,
      "heapUsedBytes": 46134948,
      "domNodes": 61,
      "jsHeapTotalBytes": 21225472,
      "scriptDurationMs": 153.002,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1756.129000000044,
      "styleRecalcs": 33,
      "styleRecalcDurationMs": 15.885,
      "layouts": 6,
      "layoutDurationMs": 0.608,
      "taskDurationMs": 371.412,
      "heapDeltaBytes": 7921512,
      "heapUsedBytes": 76942144,
      "domNodes": 78,
      "jsHeapTotalBytes": 19525632,
      "scriptDurationMs": 22.728999999999996,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1745.151000000078,
      "styleRecalcs": 31,
      "styleRecalcDurationMs": 16.796,
      "layouts": 6,
      "layoutDurationMs": 0.603,
      "taskDurationMs": 383.56,
      "heapDeltaBytes": 7988184,
      "heapUsedBytes": 76868500,
      "domNodes": 77,
      "jsHeapTotalBytes": 19525632,
      "scriptDurationMs": 22.764,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.670000000000012,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 587.6030000000014,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 6.226000000000003,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 403.209,
      "heapDeltaBytes": -10016488,
      "heapUsedBytes": 59134912,
      "domNodes": 16,
      "jsHeapTotalBytes": 20574208,
      "scriptDurationMs": 81.579,
      "eventListeners": 0,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 572.731000000033,
      "styleRecalcs": 12,
      "styleRecalcDurationMs": 8.337,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 380.542,
      "heapDeltaBytes": -9968564,
      "heapUsedBytes": 59021440,
      "domNodes": 20,
      "jsHeapTotalBytes": 20049920,
      "scriptDurationMs": 76.842,
      "eventListeners": 0,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.663333333333338,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2041.8510000000083,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 5.7059999999999995,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 800.138,
      "heapDeltaBytes": -12143724,
      "heapUsedBytes": 58625764,
      "domNodes": -275,
      "jsHeapTotalBytes": 4288512,
      "scriptDurationMs": 230.99800000000005,
      "eventListeners": -146,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2037.50500000001,
      "styleRecalcs": 7,
      "styleRecalcDurationMs": 5.131999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 804.994,
      "heapDeltaBytes": -1450016,
      "heapUsedBytes": 69424484,
      "domNodes": -273,
      "jsHeapTotalBytes": 2977792,
      "scriptDurationMs": 232.85,
      "eventListeners": -146,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2249.0119999999933,
      "styleRecalcs": 69,
      "styleRecalcDurationMs": 13.986999999999997,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1719.208,
      "heapDeltaBytes": -7483992,
      "heapUsedBytes": 64553764,
      "domNodes": -274,
      "jsHeapTotalBytes": 4493312,
      "scriptDurationMs": 937.4810000000001,
      "eventListeners": -146,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2293.3439999999337,
      "styleRecalcs": 69,
      "styleRecalcDurationMs": 13.772,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1708.4060000000002,
      "heapDeltaBytes": -5597052,
      "heapUsedBytes": 67292024,
      "domNodes": -277,
      "jsHeapTotalBytes": 2920448,
      "scriptDurationMs": 922.462,
      "eventListeners": -148,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 3703.7460000000237,
      "styleRecalcs": 65,
      "styleRecalcDurationMs": 14.102999999999998,
      "layouts": 60,
      "layoutDurationMs": 7.531000000000001,
      "taskDurationMs": 2016.774,
      "heapDeltaBytes": -4253152,
      "heapUsedBytes": 70360852,
      "domNodes": -280,
      "jsHeapTotalBytes": 6647808,
      "scriptDurationMs": 1074.792,
      "eventListeners": -150,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 3734.3980000000556,
      "styleRecalcs": 64,
      "styleRecalcDurationMs": 13.582,
      "layouts": 60,
      "layoutDurationMs": 7.601,
      "taskDurationMs": 1993.944,
      "heapDeltaBytes": 1043360,
      "heapUsedBytes": 75656680,
      "domNodes": -281,
      "jsHeapTotalBytes": 6385664,
      "scriptDurationMs": 1074.659,
      "eventListeners": -150,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "minimap-idle",
      "durationMs": 2087.02999999997,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 6.134,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 832.3610000000001,
      "heapDeltaBytes": 4317460,
      "heapUsedBytes": 77538504,
      "domNodes": -274,
      "jsHeapTotalBytes": 2977792,
      "scriptDurationMs": 264.312,
      "eventListeners": -148,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "minimap-idle",
      "durationMs": 2044.7470000000294,
      "styleRecalcs": 7,
      "styleRecalcDurationMs": 5.877000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 810.3629999999999,
      "heapDeltaBytes": -10303968,
      "heapUsedBytes": 62850968,
      "domNodes": -277,
      "jsHeapTotalBytes": 3764224,
      "scriptDurationMs": 233.043,
      "eventListeners": -146,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 606.77000000004,
      "styleRecalcs": 48,
      "styleRecalcDurationMs": 14.002999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 428.69700000000006,
      "heapDeltaBytes": -10236716,
      "heapUsedBytes": 59213364,
      "domNodes": 22,
      "jsHeapTotalBytes": 20574208,
      "scriptDurationMs": 146.147,
      "eventListeners": 6,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 613.0339999999705,
      "styleRecalcs": 48,
      "styleRecalcDurationMs": 10.742,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 412.606,
      "heapDeltaBytes": -10673584,
      "heapUsedBytes": 58283240,
      "domNodes": 22,
      "jsHeapTotalBytes": 21622784,
      "scriptDurationMs": 136.704,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-idle",
      "durationMs": 1994.956000000002,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 7.250000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 494.029,
      "heapDeltaBytes": -21527956,
      "heapUsedBytes": 47620896,
      "domNodes": -274,
      "jsHeapTotalBytes": 19128320,
      "scriptDurationMs": 14.617,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2029.1320000000042,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 7.874999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 495.84000000000003,
      "heapDeltaBytes": -23206716,
      "heapUsedBytes": 45901524,
      "domNodes": -272,
      "jsHeapTotalBytes": 19652608,
      "scriptDurationMs": 15.263,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1725.8649999999989,
      "styleRecalcs": 75,
      "styleRecalcDurationMs": 33.196999999999996,
      "layouts": 16,
      "layoutDurationMs": 4.258,
      "taskDurationMs": 784.32,
      "heapDeltaBytes": -21532640,
      "heapUsedBytes": 47413356,
      "domNodes": -272,
      "jsHeapTotalBytes": 19652608,
      "scriptDurationMs": 100.64099999999999,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1714.8440000000846,
      "styleRecalcs": 76,
      "styleRecalcDurationMs": 33.263,
      "layouts": 16,
      "layoutDurationMs": 4.308,
      "taskDurationMs": 770.561,
      "heapDeltaBytes": -19321212,
      "heapUsedBytes": 49698040,
      "domNodes": -273,
      "jsHeapTotalBytes": 19652608,
      "scriptDurationMs": 102.752,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "subgraph-transition-enter",
      "durationMs": 1334.6900000000232,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 23.92699999999999,
      "layouts": 6,
      "layoutDurationMs": 9.231,
      "taskDurationMs": 842.3720000000001,
      "heapDeltaBytes": 7052296,
      "heapUsedBytes": 97850364,
      "domNodes": 13671,
      "jsHeapTotalBytes": 11010048,
      "scriptDurationMs": 40.329000000000015,
      "eventListeners": 2383,
      "totalBlockingTimeMs": 112,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 8359.267999999985,
      "styleRecalcs": 250,
      "styleRecalcDurationMs": 38.131,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 6006.821,
      "heapDeltaBytes": 3398604,
      "heapUsedBytes": 74933160,
      "domNodes": -277,
      "jsHeapTotalBytes": 4202496,
      "scriptDurationMs": 3117.628,
      "eventListeners": -130,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 8416.094000000045,
      "styleRecalcs": 250,
      "styleRecalcDurationMs": 38.348,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 6109.884,
      "heapDeltaBytes": -3138792,
      "heapUsedBytes": 67710700,
      "domNodes": -274,
      "jsHeapTotalBytes": 5251072,
      "scriptDurationMs": 3160.492,
      "eventListeners": -132,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 17658.61799999999,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 17640.049000000003,
      "heapDeltaBytes": -12899656,
      "heapUsedBytes": 183554900,
      "domNodes": -6548,
      "jsHeapTotalBytes": 1634304,
      "scriptDurationMs": 948.007,
      "eventListeners": -7469,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 18.333333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 17532.277000000024,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 17517.124,
      "heapDeltaBytes": -18935164,
      "heapUsedBytes": 178859188,
      "domNodes": -6548,
      "jsHeapTotalBytes": 2682880,
      "scriptDurationMs": 969.706,
      "eventListeners": -7469,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.779999999999927,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 22142.91799999995,
      "styleRecalcs": 159,
      "styleRecalcDurationMs": 21.818999999999978,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 22122.981000000003,
      "heapDeltaBytes": -35407200,
      "heapUsedBytes": 157265952,
      "domNodes": -6548,
      "jsHeapTotalBytes": -987136,
      "scriptDurationMs": 1470.2740000000001,
      "eventListeners": -7467,
      "totalBlockingTimeMs": 521,
      "frameDurationMs": 17.776666666666642,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 21564.682999999946,
      "styleRecalcs": 156,
      "styleRecalcDurationMs": 20.416000000000018,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 21543.446,
      "heapDeltaBytes": -38294568,
      "heapUsedBytes": 157141616,
      "domNodes": -6548,
      "jsHeapTotalBytes": 323584,
      "scriptDurationMs": 1446.1960000000001,
      "eventListeners": -7465,
      "totalBlockingTimeMs": 568,
      "frameDurationMs": 18.333333333333332,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "workflow-execution",
      "durationMs": 467.44599999999537,
      "styleRecalcs": 20,
      "styleRecalcDurationMs": 22.967000000000002,
      "layouts": 4,
      "layoutDurationMs": 1.637,
      "taskDurationMs": 136.687,
      "heapDeltaBytes": -15392096,
      "heapUsedBytes": 52531896,
      "domNodes": 154,
      "jsHeapTotalBytes": 6942720,
      "scriptDurationMs": 13.753,
      "eventListeners": 67,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "workflow-execution",
      "durationMs": 466.1900000000969,
      "styleRecalcs": 13,
      "styleRecalcDurationMs": 18.881,
      "layouts": 3,
      "layoutDurationMs": 0.5940000000000001,
      "taskDurationMs": 112.893,
      "heapDeltaBytes": -15901816,
      "heapUsedBytes": 51779752,
      "domNodes": 117,
      "jsHeapTotalBytes": 7204864,
      "scriptDurationMs": 9.496,
      "eventListeners": 65,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    }
  ]
}

@codecov

codecov Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.28340% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ons/vueNodes/composables/useSlotLinkInteraction.ts 0.00% 11 Missing ⚠️
src/extensions/core/groupNode.ts 0.00% 3 Missing ⚠️
src/composables/graph/useNodeArrangement.ts 0.00% 2 Missing ⚠️
src/extensions/core/widgetInputs.ts 0.00% 1 Missing ⚠️
...c/lib/litegraph/src/subgraph/SubgraphIONodeBase.ts 87.50% 1 Missing ⚠️
...ib/litegraph/src/subgraph/subgraphDeduplication.ts 96.77% 1 Missing ⚠️
...rm/workflow/core/utils/workflowToClipboardItems.ts 96.55% 1 Missing ⚠️
...nsions/vueNodes/layout/ensureCorrectLayoutScale.ts 94.44% 1 Missing ⚠️
...renderer/extensions/vueNodes/layout/useNodeDrag.ts 92.30% 1 Missing ⚠️
src/scripts/app.ts 0.00% 1 Missing ⚠️
... and 1 more
@@                   Coverage Diff                   @@
##           feature/ecs-migration   #14110    +/-   ##
=======================================================
  Coverage                  79.22%   79.22%            
=======================================================
  Files                       1764     1765     +1     
  Lines                     103132   102997   -135     
  Branches                   33462    34171   +709     
=======================================================
- Hits                       81703    81601   -102     
+ Misses                     20957    20924    -33     
  Partials                     472      472            
Flag Coverage Δ
unit 69.86% <90.28%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/composables/graph/useVueNodeLifecycle.ts 85.07% <ø> (+2.21%) ⬆️
src/core/graph/widgets/dynamicWidgets.ts 90.83% <100.00%> (ø)
src/lib/litegraph/src/LGraph.ts 75.85% <ø> (+0.28%) ⬆️
src/lib/litegraph/src/LGraphCanvas.ts 63.09% <ø> (-0.14%) ⬇️
src/lib/litegraph/src/LGraphGroup.ts 80.86% <ø> (+1.79%) ⬆️
src/lib/litegraph/src/LGraphNode.ts 65.24% <ø> (-0.12%) ⬇️
src/lib/litegraph/src/Reroute.ts 63.25% <ø> (-1.10%) ⬇️
...litegraph/src/canvas/getCanvasContextMenuTarget.ts 100.00% <ø> (ø)
src/lib/litegraph/src/linkDeduplication.ts 93.33% <ø> (ø)
...platform/workflow/core/services/workflowService.ts 86.61% <100.00%> (+0.27%) ⬆️
... and 17 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DrJKL
DrJKL force-pushed the drjkl/layout-single-source branch from ecfbb0f to 18ada3a Compare July 26, 2026 07:42
@vercel

vercel Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pillar5-agent Ready Ready Preview, Comment Jul 26, 2026 6:54pm

Request Review

DrJKL added 18 commits July 28, 2026 21:23
LGraphNode.move() returned early in Vue nodes mode, so the Positionable
contract silently depended on which renderer was active: dragging a group
moved its child nodes via LGraphGroup.move -> item.move, which did nothing
for nodes. Three call sites worked around that by reimplementing the same
arithmetic:

- moveChildNodesInGroupVueMode + calculateNewPosition, used by the canvas
  drag and auto-pan paths, computed pos + delta and called setPos
- the paste path branched on item type, calling setPos for nodes and move()
  for reroutes and groups

All three are the same operation. The pos setter has committed to
layoutMutations since Phase 2, so move() reaches the layout store on its own
and the workaround no longer buys anything: setPos(pos + delta) and
move(delta) are now the same two writes in the same order.

Drops the mode branch and the two helpers; the drag, auto-pan and paste sites
each become one item.move(delta) loop. Pinned items were already filtered by
getDraggedItems, so selection behaviour is unchanged.

Verified: litegraph, layout, graph-composable and vueNodes-layout unit suites
(1369 tests); Vue group drag e2e including nested groups and the ctrl/meta
no-drag-contents cases; group paste offset. Nine local screenshot failures in
groups/copyPaste are pre-existing and identical before and after.
ensureCorrectLayoutScale wrote geometry element-wise (`node.pos[0] = x`).
Element writes reach `_pos` directly, so positions never got to the layout
store; sizes did, but only by accident, because `size` returns a Proxy whose
set trap commits. The snap pass ran after the writes, so snapped positions
were dropped on the floor as well, and reroutes lost their snap entirely —
`reroute.pos = [...]` committed, then snapPoint mutated the array in place
behind the setter.

syncLayoutStoreNodeBoundsFromGraph existed to paper over exactly this: a bulk
re-push of every root node's bounds, run only when the normalizer had touched
the graph.

Snap the unprojected values first, then assign once through `pos` and `size`.
Every write now takes the same path the rest of the app uses, so the bulk
re-push is redundant and goes away with its test. It was also narrower than
what it patched: it covered `rootGraph` only, while the normalizer runs over
the root graph and every loaded subgraph.

Folds the module-level unprojectPosSize helper into one local `normalize`,
dropping its copy of the snap logic; nodes, groups and subgraph IO nodes all
use it now instead of two near-identical bodies.

The group in-place test built its fixture from a bare object literal, which
has no setters and so could not model the contract it was asserting — real
`pos` and `size` write through to a shared Rectangle buffer. It now uses a
real LGraphGroup and reads back through the captured array.

Verified: layout, vueNodes-layout and litegraph unit suites (1231 tests);
knip; Vue groups e2e including "keep groups aligned after loading legacy Vue
workflows"; subgraph draft-position and navigation e2e. Four local failures
across those specs are pre-existing and reproduce on a clean tree.
Groups were the last positionable outside the layout store: LGraphGroup._bounding
was the only copy, so group geometry never entered the CRDT and could not be read
from the store the way node geometry can.

Store side, kept deliberately small. `GroupLayout` is id, position and size —
no zIndex and no spatial index, because groups draw beneath nodes in insertion
order and the canvas hit-tests them against their own bounds, so nothing queries
them positionally. Geometry is one `setGroupBounds` operation rather than
separate move and resize: a group's pos and size are two views onto one
Rectangle, so writing the whole rectangle means the halves can never be stored
apart. Reactivity is the version bump alone — there are no per-group refs
because there is no Vue group component to hold one.

LGraphGroup had seven ways to write geometry, three of which duplicated or
bypassed the clamping:

- `resize` re-implemented the `size` setter's min-width/height clamping
- `resizeTo` wrote all four components element-wise, bypassing both setters
- `snapToGrid` handed `this.pos` to snapPoint, which mutated it behind the setter
- `configure` wrote `_bounding` directly

All of them now funnel through one protected `setBounds`, which writes the
rectangle and commits it. The public setters clamp and delegate; `resizeTo` and
`configure` use it directly to keep their existing unclamped behaviour — a group
fitted to its contents may still be narrower than minWidth, as before.

Entries are created and destroyed at the LGraph chokepoints that already own
group membership: `add`, `remove`, and `clear`. `clear` deletes per group rather
than clearing a bucket, because group ids come from the root graph's shared
`state` and subgraphs share it — the same reason a flat store map is safe here.
`clear` skips the store entirely when there are no groups, so constructing an
LGraph no longer touches it.

The minimap's layout-store source now reads group geometry from the store while
taking membership from the viewed graph, mirroring how it already handles nodes.
The legacy source still reads groups off the graph.

Verified: full unit suite (13693 passing; the two failures are the known
onboardingCloudRoutes and previewAny load-timeouts, both green in isolation);
typecheck; lint; knip. E2E: Vue groups, group copy/paste, groupSelectChildren
and changeTracker. Nine local failures across those specs are pre-existing —
each one re-run against a stashed tree to confirm.
useNodeDrag ran two idioms for one gesture. Nodes were positioned absolutely
from a drag-start snapshot, while groups and reroutes were nudged by a
per-frame delta, which needed `lastCanvasDelta` bookkeeping to derive that
delta and a second code path in the auto-pan handler — nodes had their start
positions shifted by the pan, groups were moved by it immediately.

Non-node positionables now get the same treatment: their start positions are
snapshotted alongside the nodes' and every frame recomputes an absolute
target. `pos` is readonly on Positionable, so the target is reached through
move(), which is also what keeps the pinned guard and, since groups landed in
layoutStore, what commits their geometry.

Both branches of updateNodePositions now say the same thing, auto-pan shifts
one set of start positions, and `lastCanvasDelta` is gone. Re-deriving from the
start each frame is also self-correcting: a dropped frame cannot leave an item
behind and per-frame deltas cannot accumulate error.

Drops a redundant pinned check I had added in the loop — LGraphGroup.move
already enforces it, and duplicating it there would have made the test for it
tautological.

The test file's litegraph mock exported isLGraphGroup, which this composable
never calls; it went unnoticed because selectedItems was always empty, so the
predicate never ran. Corrected to isLGraphNode, and three tests cover the new
path: a selected group tracks the drag offset, a pinned one does not move, and
auto-pan carries non-nodes along.

Verified: full unit suite (13696 passing; the two failures are the known
onboardingCloudRoutes and previewAny load-timeouts); typecheck, lint, knip.
E2E: "dragging a node moves all selected items" — which asserts graph.groups[0].pos
after a node drag, exactly this path — plus Vue groups and groupSelectChildren.
Eight local failures across those specs are pre-existing, each re-run against a
stashed tree to confirm.
Unpacking a subgraph adds each inner group to the root graph, configures it,
then shifts it by the wrapper's position. That shift was element-wise, which
reaches _pos but not the layout store — harmless while groups lived only on
the class, wrong now that they are stored. The store kept the pre-offset
position, so in Vue nodes mode the minimap drew unpacked groups at their
inner-graph coordinates while the canvas drew them correctly.

Whole-value assignment through the `pos` setter instead. Not move(), which
would skip pinned groups and leave them un-offset.

The regression test fails without the fix with the store holding {x:10,y:20}
against a class position of {x:100,y:75}.
Element writes reach the backing Rectangle but not the layout store, so every
one of these was either already dropping a write or relying on the `size`
Proxy to catch it. Whole-value assignment goes through the setters, which is
the one path that commits.

Two were live gaps. groupNode's unpack shifted nodes already attached to the
graph, so the store kept their pre-shift positions. SubgraphIONodeBase.move
never reached any store at all.

The rest were latent: vintageClipboard offsets a node before `graph.add`, so
seeding covered it; widgetInputs and dynamicWidgets write `size`, which the
Proxy catches. Converting them removes the dependence on that Proxy — it
exists to catch this idiom, and every in-repo caller that stops using the
idiom narrows what it has to cover to genuine third-party code.

widgetInputs' pair of `if (a < b) a = b` guards collapse into one Math.max
assignment, which is what they were spelling out.

No element-wise geometry writes remain in src outside the layoutStore -> class
writeback in useLayoutSync.
Reroute position was in three places: `posInternal` on the class, `position`
in the Yjs map, and `position` again on the RerouteLayout used for hit
testing. Three writers kept them in step by hand, and they disagreed about
how:

- `move()` wrote posInternal then committed
- `snapToGrid()` mutated the array through the getter, then committed
- the `pos` setter wrote posInternal and committed nothing at all

That last one is why normalising a legacy workflow never moved a reroute in
the store — `ensureCorrectLayoutScale` assigns `reroute.pos`, which silently
went no further than the class. My earlier commit describing that path said
the setter committed and the snap was lost behind it; the setter never
committed at all.

posInternal is gone. `pos` reads the stored point and the setter commits;
`move` and `snapToGrid` compute a target and assign it, so all three paths are
one write. `boundingRect`, `hoverArea` and the spline maths read the stored
point directly rather than allocating through `pos`.

A reroute now registers its geometry in its own constructor, which is what
makes the store safe to read unconditionally. Two seeding sites become
redundant and go: `LGraph.createReroute`'s explicit createReroute call, and
the loop in useVueNodeLifecycle that existed because "deserialised reroutes
bypass createReroute" — they no longer bypass anything.

`moveReroute`'s previousPosition is now optional and defaults to the stored
point, since no caller had a better answer than the store itself.

The read-through is verified by moving a reroute in the store alone and
reading it back off the class — a mirrored copy could not see that without a
synchronisation step. E2E: "Floating reroutes", which drags by coordinate onto
a reroute, so hit testing resolves against the stored position.
…t doing so

snapPoint mutates its argument in place, and `pos` hands out the backing array,
so `snapPoint(this.pos, snapTo)` never reached the layout store. LGraph.configure
already knew: it re-assigned `node.pos = [node.pos[0], node.pos[1]]` after
snapping, with a comment explaining that snapToGrid bypasses the setter. Three
other call sites had no such workaround — LGraph.add, LGraph.snapToGrid over a
selection (the drag-end path), and alignToGrid — so in Vue nodes mode the store
kept the pre-snap position and the next writeback flush could undo the snap on
screen.

LGraphNode.snapToGrid and SubgraphIONodeBase.snapToGrid now snap a copy and
assign it, so every caller commits and the workaround is deleted. The size snap
beside it stops relying on the `size` Proxy for the same reason.

Also converts SubgraphIONodeBase.arrange, which sized itself with `size[0] =`
through a destructured local. My earlier claim that no element-wise geometry
writes remained was wrong: it was based on a pattern that only matched writes
through `this`, and missed both the destructured-local form and anything routed
through a helper like snapPoint.

The regression test seeds a layout entry the way the renderer does, then snaps:
without the fix the store holds {x:103,y:97} against a class position of
{x:100,y:100}.
Completes the helper-routed half of the element-write sweep. alignToContainer
and alignOutsideContainer mutate the rectangle handed to them, so passing a
node's live geometry writes straight past the setters:

- `alignToContainer(subgraphNode._posSize, ...)` reached into the backing
  Rectangle from outside the class entirely. Harmless today only because the
  node is not yet attached when it runs, so add-time seeding captures the
  result — the same accident that made the following setPos look like a title
  correction rather than the thing that commits the position.
- `alignOutsideContainer(inputRect, ...)` mutates each subgraph IO node's own
  boundingRect.

Both helpers write only the position components, so aligning a copy and
assigning through `pos` is exactly equivalent. The centring and the title-height
correction now happen in one assignment instead of a mutate-then-reassign pair,
and the two IO node calls collapse into one loop.

`_posSize` is no longer touched outside LGraphNode.
repositionNodesVueMode was misnamed and redundant at once: it worked in both
render modes, because setPos commits regardless, and its body was a single
call to a private applyNodePositionUpdates with the same signature.

Collapsed into one public applyNodePositions. Six call sites — align,
distribute and three clone paths in LGraphCanvas, plus useNodeArrangement —
updated. The "setPos automatically syncs to layout store" comment goes with
it; that is what the setter is for and no longer worth restating here.
The draft expected this phase to add a compatibility shim. It mostly deleted
them: every entity now has one write path, and the workarounds that existed
because writes bypassed it are gone.

Records the three forms element-wise writes took and why the helper-routed one
was the expensive one to miss, what groups and reroutes look like in the store,
and why the store -> legacy writeback stays — serialize() and the canvas
renderer read the class, and ~231 element-indexed reads depend on pos/size
being views onto one buffer. Notes that the re-entrancy the draft worried about
did not materialise, since the writeback compares before writing.

Lists the three things left, each needing a decision rather than more
inference, and keeps the original draft below for the record.
Stage 1 of removing useLayoutSync. The store now holds each node's `Rectangle`
by reference — the very buffer whose `pos` and `size` subarrays back
LGraphNode._pos and _size — and reads geometry from it. Class and store are the
same memory, so there is no longer a direction to reconcile.

Three facts made this cheaper than the two-copy shape suggested:

- `getNodeLayoutRef().value` already built a fresh NodeLayout on every read, so
  no consumer held one expecting it to mutate. Changing what backs it breaks no
  contract.
- `bounds` was position and size copied verbatim, so it is derived now rather
  than stored.
- `Rectangle` already exposes pos and size as subarray views over one buffer,
  which is the facade shape the class needs.

Every read path goes through one `nodeLayoutFor`, including the whole-map walks
in getNodesInBounds, getAllNodes and the z-ordered read, so a single lookup and
a map walk cannot disagree.

Yjs stays a projection, written on commit. That is a serialization boundary
rather than a peer mirror: local edits flow one way into it, and the inbound
direction only matters for remote CRDT updates, which nothing wires up today.

useLayoutSync still runs. Its writeback should now be inert, since it compares
before writing and the values it would copy are already the same object —
confirming that, then deleting it, is stage 3.

Known gap, deliberately not papered over: the spatial index is a derived copy
that a raw buffer write does not reach. Writes committed through
layoutMutations still update it. The test says so rather than asserting a pass
that would come from stale index data.
…ction

Stage 1 moved node geometry reads onto the registered Rectangle but left every
mutation writing only the Yjs projection, so anything committed through
layoutMutations was invisible to the store's own reads: moveNode wrote y, the
read returned x. That breaks the Vue drag, resize and arrange paths — the store
reported the pre-move position no matter how far the node was dragged.

handleMoveNode, handleResizeNode and handleBatchUpdateBounds now write the
rectangle, which is the authority, before projecting into Yjs. handleCreateNode
deliberately does not: a create that disagrees with a registered rectangle
should lose to it rather than clobber newer geometry.

Caught by asking what the drag path does rather than trusting the suites — the
unit tests I added covered raw buffer writes only, and locally the plain
"moving nodes by dragging" e2e sits in the pre-existing-failure bucket, so it
could not discriminate. The new test drives moveNode and resizeNode through the
mutation API and fails on the committed code with {x:10,y:20} against
{x:500,y:600}.
Sharing the geometry buffer silently killed an extension callback. useLayoutSync
fired node.onResize only when the store's size differed from the class's; with
one buffer behind both, that comparison is never true, so Vue-driven resizes
stopped calling it. useLoad3d chains onto node.onResize to re-lay-out its
viewport, so a Load3D node resized in Vue nodes mode would have stopped
responding.

The change notification already carries the intent, so the resize is tracked
from `operation.type` and the callback fires per flush regardless of whether any
value moved.

The existing tests could not catch this: they stub the store with geometry that
differs from the node's, which is the one arrangement that no longer occurs. The
new test sets them equal — the real case — and fails without the fix with
onResize called 0 times.

The value copy stays. It is inert for nodes registered by reference, but it
still covers nodes that have no registered rectangle, and it is the path a
remote CRDT update would arrive on.
Reverts 88d4e51 (store reads the class Rectangle), dfa3882 (commit mutations to
that rectangle) and 7addc4b (fire onResize from the operation).

Two reasons, either sufficient.

It broke resize. CI E2E failed on five size and reflow tests — Vue node
resizing, both runtime reflow cases, image preview and painter compact layout.
Writing the whole four-tuple on commit meant a resize measurement's x and y
were applied to the node's position, not just its size.

More importantly it pointed the wrong way. Making the class Rectangle
authoritative and Yjs a write-only projection puts component data back on the
entity, which is the opposite of ECS: the Y.Doc should be the World that holds
Position and Size, and the class should hold nothing. Fixing the resize break
would have entrenched that.

Two findings survive the revert and are worth keeping in mind:

- Nothing replicates the Y.Doc. There is no y-websocket, y-webrtc or
  IndexeddbPersistence anywhere, and nothing outside the store reads getYDoc or
  encodeStateAsUpdate. The CRDT is local-only today.
- Sharing a buffer between class and store turns divergence-detecting code
  silently inert. useLayoutSync fires node.onResize only when the store's size
  differs from the class's; with one buffer behind both, that is never true, and
  useLoad3d chains onto that callback. Whatever replaces the writeback has to
  fire from the operation's intent, not from a value diff.
Groundwork for making the Y.Doc authoritative for Position and Size. The node
map held `position`, `size` and `bounds` as separate entries, with `bounds`
being the other two copied verbatim and an updateNodeBounds helper existing only
to keep them in step. Three writes per move, three chances to disagree.

Now one `rect: [x, y, width, height]`. Position, size and bounds are views
derived on read, so they cannot diverge, and the helper is deleted along with
them. A whole-tuple replace is also the write a CRDT register wants, which
matches the whole-value assignment discipline the rest of the branch adopted.

Measured before choosing the shape, over 800k reads:

| read path                          | ns/read | vs current |
| ---------------------------------- | ------- | ---------- |
| Float64Array subarray (current)    |     4.2 |          - |
| Yjs, separate position/size fields |    19.9 |       4.7x |
| Yjs, one rect field                |    13.6 |       3.2x |
| Yjs, one rect + cached Y.Map ref   |     7.2 |       1.7x |

Real read counts, instrumented over 60 frames: 7.3 per node per frame in Vue
nodes mode, 44 in legacy — the canvas draws node bodies there, Vue draws them in
the DOM. At 9.4ns of added cost per read that is 0.41% of a 16.7ms frame for
1000 Vue-mode nodes, 2.5% for legacy.

No cached map reference, despite it being the fastest. It is a cache with an
invalidation failure mode — a deleted node leaves a stale reference reading old
values — and it buys 5.5ns/read, or 1.4% of a frame at 1000 legacy nodes. Not
worth it. If large legacy graphs ever bite, the fix is fewer reads per frame,
measured then.

Benchmark and the read-count probe are in temp/scripts/geobench.ts.
Entity ids are only unique within a root graph, but `layoutStore` keys
nodes, groups and reroutes in one flat map. `workflowService.insertWorkflow`
builds a scratch `LGraph` from the workflow being inserted, and its ids start
at 1 like the open workflow's — so configuring it moved the open workflow's
nodes to the inserted coordinates, and the `graph.clear()` that follows
deleted the open workflow's group layout. The node half reproduces on main;
the group half arrived with group geometry moving into the store.

Operations now carry the writer's root graph id and the store records which
root graph created each entry, dropping operations aimed at a stranger's
geometry. This is the collision-loser rule `registerNodeState` already
applies for `nodeDataStore` and `unregisterRerouteChain` for `rerouteStore`;
layout was the one entity store without it.

Ownership is opt-in: callers already scoped to the viewed graph omit it, so
the renderer's call sites are unchanged. Reroutes do not claim ownership yet
— their constructor takes a `LinkNetwork`, not a graph, and no failing case
needs it.
Replaces the per-entry ownership map from the previous commit. That tracked
which root graph created every node, group and reroute entry, which needed a
side map, a composite string key, a second switch over operation types kept
in sync with the dispatch switch, and a prefix scan to clear one entity's
keys. All of it existed to answer one question.

The store holds the layout of one root graph — the open workflow — so it can
just know which one that is. Operations from a different root graph are out
of scope and ignored. One field, one comparison, and the entry bookkeeping
goes away.

Scope is bound where the workflow is opened: `addAfterConfigureHandler` runs
after configure has assigned the graph's id, and is installed only on the
app's root graph, so a graph built off to the side never claims it. The
renderer rebinds on seeding, which covers subgraph navigation. Unset until a
workflow opens, during which nothing is out of scope.

I had reached for per-entry ownership because the sibling stores use a
collision-loser rule, but they key their buckets by root graph and layout
does not, so the rule was carrying weight the scope field carries for free.

Scope is sticky, and the store is a module singleton, so the regression tests
move to their own file where the binding cannot leak into tests that expect
an unscoped store.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/lib/litegraph/src/Reroute.store.test.ts (1)

378-399: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert independent expected positions, not Reroute.pos against the store.

Reroute.pos is backed by layoutStore, so comparing those two values only verifies that both reads share the same source. Assert the known literal coordinates for the store result and reroute.pos separately.

Based on learnings: layout-store-backed geometry tests must avoid comparing a store value to Reroute.pos because that is self-referential.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/litegraph/src/Reroute.store.test.ts` around lines 378 - 399, The test
“routes move and snapToGrid through the same stored point” must avoid
self-referential validation because Reroute.pos reads from layoutStore. Assert
the literal expected coordinates independently for the layoutStore result and
reroute.pos after snapToGrid, preserving the existing move and snapping
expectations.

Source: Learnings

src/lib/litegraph/src/LGraph.ts (2)

1933-1933: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Use serializable layout commands for all changed geometry writes.

These call sites directly mutate node/group geometry instead of routing changes through the layout command API.

  • src/lib/litegraph/src/LGraph.ts#L1933-L1933: replace the direct IO-node position assignment with the appropriate layout command.
  • src/lib/litegraph/src/LGraph.ts#L2163-L2163: replace the direct group position assignment with a layout mutation.
  • src/lib/litegraph/src/LGraph.ts#L2717-L2719: route snapped node-size updates through the layout mutation API.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/litegraph/src/LGraph.ts` at line 1933, Replace the direct geometry
writes in LGraph.ts at lines 1933, 2163, and 2717-2719: use the layout command
API for the IO-node position assignment, route the group position update through
a layout mutation, and route snapped node-size changes through the same layout
mutation API. Ensure all three updates remain serializable.

Source: Coding guidelines


508-524: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Clear node layouts during graph teardown. clear() drops groups and reroutes, but node positions and sizes still remain in the layout store. That can leave stale geometry behind after a root-graph reset and let reused node ids pick up old bounds. Delete each node layout in this path as well.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/litegraph/src/LGraph.ts` around lines 508 - 524, Extend the layout
cleanup in LGraph.clear() to delete the layout entry for every node in each
graph being cleared, alongside the existing group and reroute deletions. Use the
root graph ID and each node’s ID with the existing layoutMutations API,
preserving the current graphsToClear handling for root and subgraphs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/lib/litegraph/src/LGraph.ts`:
- Line 1933: Replace the direct geometry writes in LGraph.ts at lines 1933,
2163, and 2717-2719: use the layout command API for the IO-node position
assignment, route the group position update through a layout mutation, and route
snapped node-size changes through the same layout mutation API. Ensure all three
updates remain serializable.
- Around line 508-524: Extend the layout cleanup in LGraph.clear() to delete the
layout entry for every node in each graph being cleared, alongside the existing
group and reroute deletions. Use the root graph ID and each node’s ID with the
existing layoutMutations API, preserving the current graphsToClear handling for
root and subgraphs.

In `@src/lib/litegraph/src/Reroute.store.test.ts`:
- Around line 378-399: The test “routes move and snapToGrid through the same
stored point” must avoid self-referential validation because Reroute.pos reads
from layoutStore. Assert the literal expected coordinates independently for the
layoutStore result and reroute.pos after snapToGrid, preserving the existing
move and snapping expectations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fb2d2b6e-3ebe-4341-be9e-c305844d259e

📥 Commits

Reviewing files that changed from the base of the PR and between eeb681f and 8de2474.

📒 Files selected for processing (2)
  • src/lib/litegraph/src/LGraph.ts
  • src/lib/litegraph/src/Reroute.store.test.ts

@christian-byrne christian-byrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reading this code now and also sent an agent at it. From the system diagram it seems perfect. Can you double check that this API is fully compatible with multiplayer (see https://app.notion.com/p/comfy-org/Offline-Edits-Initial-Mutations-Implementation-3a76d73d365080ad8d88ed7dc24885e0?showMoveTo=true&saveParent=true)?

@christian-byrne christian-byrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the geometry centralization end to end, with most attention on the four areas you called out. The store redesign itself reads well: collapsing position/size/bounds into one rect is clearly right, createGeometryView committing on observed value change is strictly better than the allowlist in the _sizeProxy it replaces, and the Reflect.get(target, property, target) receiver choice is the correct one for proxying a Rectangle. I did not re-raise the three findings in your details block; I checked all three and they hold.

The findings below were each put through a cross-model refutation pass before posting, and several were dropped or narrowed there. Two things I would flag as worth resolving before this lands:

  1. Workflow insertion. Two normalizations that LGraph.configure used to guarantee no longer run: realignInputLinkSlots, and the link-id stripping that LGraphNode.clone did implicitly. The first can miswire inputs on older workflows, the second feeds unrelated LLinks to onConnectionsChange during insert. Both are in workflowToClipboardItems.
  2. Paste offset. Routing nodes through move() picks up its pinned guard, so pinned nodes stop being repositioned on both Ctrl+V and Insert Workflow.

On scope, and take this as a suggestion rather than a request: the workflow-insertion work (workflowToClipboardItems.ts plus workflowService.ts, roughly 330 lines across 5 files) is fully separable. It imports only types/serialisation, calls _deserializeItems which is unchanged on the base branch, and touches layoutStore nowhere. The scratch-graph collision it fixes was surfaced by the layout work but does not depend on it. Splitting it out would give the two findings above their own review surface instead of sitting behind 2000 lines of geometry diff, and would leave this PR closer to the 300-line guidance in AGENTS.md.

Nothing here is a blocker on the geometry model itself, which I think is the right direction.

}

function getLinks(graph: WorkflowGraph): SerialisableLLink[] {
if (graph.version !== 0.4) return graph.links ?? []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: this drops realignInputLinkSlots, so inserted workflows can wire links to the wrong input slots.

The old path built a scratch LGraph and ran LGraph.configure, which ends with realignInputLinkSlots(...) at LGraph.ts:2750. Its docblock (linkDeduplication.ts:74-87) states the reason: node configure() overrides reorder serialized inputs in place to match the current node definition, invalidating the slot indices stored on links. After realignment LLink.target_slot reads the patched _state.targetSlot (LLink.ts:172-173), and _serializeItems copied links out of the live graph._links (LGraphCanvas.ts:4069-4073), so the old clipboard payload carried corrected indices.

The new path takes graph.links verbatim from the workflow JSON, and _deserializeItems connects with the raw index: outNode?.connect(info.origin_slot, inNode, info.target_slot, afterRerouteId) (LGraphCanvas.ts:4314-4318). node.configure(info) runs first at :4258 and reorders info.inputs in place, but nothing re-points info.target_slot, and connect() only resolves string slot names by name (LGraphNode.ts:2969-2987). realignInputLinkSlots has exactly one caller, LGraph.ts:2750.

Every ComfyUI node's configure override rewrites input order to definition order (src/services/litegraphService.ts:463, and :575 for subgraph nodes), so this bites whenever a workflow's serialized input order differs from the currently registered definition: older workflows, converted widget inputs appended at the end, or a node pack that reordered its inputs. Workflows whose order already matches are unaffected, and regular Ctrl+V is unaffected because _serializeItems reads already-realigned live links.

Options: call realignInputLinkSlots after the node loop in _deserializeItems, or keep _deserializeItems' clipboard contract intact and re-point target_slot here by matching link.id against node.inputs[i].link in the source JSON, which is the mapping realignInputLinkSlots already uses (linkDeduplication.ts:95-106).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 894756f, though not quite where you suggested. realignInputLinkSlots can't run after the node loop here: the clipboard path has no links in graph._links at that point, because connect() invents them afterwards with fresh ids. So the re-point happens on parsed.links between the two loops, keyed off the post-configure input order.

Regression test in workflowToClipboardItems.integration.test.ts ("re-points input links when configure reorders serialized inputs"). Before the fix the link landed on model instead of clip, which is a fun thing to silently do to someone's workflow.

const graph = structuredClone(workflow)

return {
nodes: graph.nodes ?? [],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: passing raw workflow nodes carries the source workflow's link ids into a graph that has its own links with the same numeric ids.

Every existing ClipboardItems producer guarantees link-free node payloads: _serializeItems serializes item.clone()?.serialize() (LGraphCanvas.ts:4059), and LGraphNode.clone strips ids with input.link = null / links.length = 0 (LGraphNode.ts:1170-1181), after which the graph-less clone serializes to link: null / links: null (node/slotUtils.ts:58-66, :78-85).

graph.nodes ?? [] keeps inputs[i].link and outputs[i].links from the source workflow. In _deserializeItems, graph.add(node); node.configure(info) (LGraphCanvas.ts:4257-4258) reaches LGraphNode.configure, which resolves those ids against the target graph's map and fires callbacks: this.graph._links.get(toLinkId(serialisedLink)) then onConnectionsChange?.(INPUT, i, true, link, input) (LGraphNode.ts:1032-1037), and the same for outputs plus onOutputAdded?.(output) at :1045-1052. Link ids start at 1 in every workflow, so inserting into a non-empty canvas collides and the handler receives a real but unrelated LLink. The output branch also fires where it previously did not, since the old payload had links: null.

Insert does not enter app.configuringGraph (that flag is set only around LGraph.configure, app.ts:874-884), so the guards that protect other paths do not apply here. Shipped autogrow logic treats any non-null resolved link as a real connection (src/core/graph/widgets/dynamicWidgets.ts:582-601) and can grow inputs before the real links are created at :4290-4320; the later connect() fixes topology but cannot undo configure-time side effects. onConnectionsChange is listed in AGENTS.md as affecting 40+ custom node repos.

This is the same hazard already documented and guarded against at LGraph.ts:2140-2149: "Strip links from serialized data before configure to prevent onConnectionsChange from resolving subgraph-internal link IDs against the parent graph's link map (which may contain unrelated links with the same numeric IDs)." Mirroring that here (null out input.link, empty output.links on root and subgraph interiors) would close it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 894756f. Links are now stripped in _deserializeItems via detachSerialisedLinks, mirroring the guard at LGraph.ts:2140 you cited — the one I evidently read, agreed with, and then declined to apply twelve hundred lines further down.

It couldn't go in workflowToClipboardItems as suggested: the realignInputLinkSlots fix in the sibling thread needs those ids to survive until after configure reorders the inputs, so both fixes share a call site. Test asserts onConnectionsChange never receives the destination graph's own pre-existing link.

Comment thread src/lib/litegraph/src/LGraphCanvas.ts Outdated
} else if (item instanceof LGraphGroup) {
item.move(dx, dy, true)
}
item.move(dx, dy, true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: collapsing the offset loop to item.move() stops pinned nodes from being repositioned on paste and on Insert Workflow.

LGraphNode.move short-circuits on pinned (LGraphNode.ts:2216-2219). Pre-PR the node branch was item.setPos(item.pos[0] + dx, item.pos[1] + dy), added in 6cf0357b3e (#7993) so the offset would reach layoutStore; before that it was an unconditional item.pos[0] += dx. setPos has no pinned guard, so pinned nodes have been offset on paste for the entire history of this loop. The group branch using move(dx, dy, true) came separately from a96c61d2c2 (#9962).

flags.pinned round-trips through serialize/configure and node.configure(info) runs at :4258, before this loop, so a pasted node arrives already pinned. Result: copy a selection containing a pinned node and Ctrl+V, and the pinned node is recreated stacked on the original while its unpinned siblings land at the cursor. Since workflowService.ts:546-548 now calls _deserializeItems directly, this is also the only path for Insert Workflow, so inserting a workflow with pinned nodes drops them at their saved absolute coordinates instead of the drop point.

Repositioning on paste is not a user drag and arguably should not respect the pin. Keeping the node branch on an absolute write would preserve both properties, since setPos now commits through the pos setter anyway:

for (const item of created) {
  if (item instanceof LGraphNode) item.setPos(item.pos[0] + dx, item.pos[1] + dy)
  else item.move(dx, dy, true)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 894756f, your diff verbatim.

New e2e in copyPaste.spec.ts pins a KSampler, copies, pastes, and asserts the copy isn't where the original is. Without the fix it fails identically on repeat runs: Expected: not {"x": 863, "y": 186}. So the pasted node was not merely near the original, it was exactly on it — a bar we were, until today, failing.

group.configure(g_info)
group.pos[0] += offsetX
group.pos[1] += offsetY
group.pos = [group.pos[0] + offsetX, group.pos[1] + offsetY]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: unpacking reuses the inner group's id, so two live LGraphGroup objects end up sharing one layout entry.

Reroutes are migrated to fresh ids a few hundred lines down (LGraph.ts:2301-2313), but groups keep g_info.id verbatim, and layoutStore keys groups only by (rootGraphId, groupId) (layoutStore.ts:78-88). deduplicateSubgraphGroupIds establishes root-wide uniqueness at load time but is not called on the unpack path.

this.remove(subgraphNode) does not run until :2240, and findReleasableSubgraphs deliberately retains a definition that still has another live instance (subgraphUtils.ts:538-545). So for a workflow with two SubgraphNode instances of one definition, unpacking one leaves the definition's group alive while creating a root group under the same key. Both objects then read and write the same entry through syncBoundsFromStore / setBounds (LGraphGroup.ts:139-168): moving one moves both, and removing either runs deleteGroup (LGraph.ts:1202) and wipes the other's only geometry.

The existing two-instance test (LGraph.test.ts:1384-1402) verifies definition retention but never gives the definition a group, so it does not catch this.

Allocating a fresh id would match how reroutes are handled, e.g. g_info.id = ++this.state.lastGroupId, or set group.id = -1 before this.add() and let add assign.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 894756f, allocating from rootGraph.state.lastGroupId rather than this.state — the layout keys are root-scoped and unpack can run inside a subgraph, so the local counter would just have moved the collision somewhere less obvious. (add()'s local allocation has the same gap; separate change.)

Extended the two-instance test you pointed at, exactly as advertised: it now gives the definition a group, moves the unpacked copy, and asserts the retained one stays where it was. Before the fix it followed along to [150, 125], which is not the collaborative spirit anyone asked for.

layoutMutations.setSource(LayoutSource.Canvas)
for (const graph of graphsToClear) {
for (const group of graph._groups) {
layoutMutations.deleteGroup(rootGraphId, group.id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: this teardown has no counterpart on the subgraph-definition release path, and once a definition is released nothing can reach its layout keys.

Registration is unconditional and root-scoped: the Reroute constructor always calls createReroute(this.rootGraphId, ...) (Reroute.ts:294-302) and LGraph.add always calls createGroup(this.rootGraph.id, ...) (:1100-1105), including for entities inside subgraph definitions. The release loop at LGraph.ts:1249-1259 unregisters link topologies, reroute chains and node states, then does this.rootGraph.subgraphs.delete(subgraph.id). It never calls deleteGroup / deleteReroute, and unregisterAllRerouteChains only touches useRerouteStore (Reroute.ts:863-878). Because the definition is now gone from rootGraph.subgraphs, the graphsToClear enumeration here can never reach it either.

Unpack makes the reroute half deterministic: :2240 removes the SubgraphNode, and the migrated reroutes get fresh ids at :2302-2315, so the old keys are orphaned rather than overwritten. A definition with 20 reroutes leaks 20 entries each time its last instance goes away, and each orphan stays in rerouteSpatialIndex as a hit-test candidate (the callers do re-resolve via graph.getReroute and fall back geometrically, so this is wasted work rather than a wrong selection, but it is unbounded within a session).

Groups are the narrower case: unpack reuses the group id, so that key is transferred to the new root group rather than orphaned. Groups leak when the last instance is deleted outright without unpacking.

The body needed is the same one already written here, so it may be worth factoring into a helper so the two cannot drift.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and deferring to a follow-up issue. The release loop really does skip deleteGroup/deleteReroute, and the definition is gone from rootGraph.subgraphs before clear() could reach it. Impact is narrower than filed, though: ids are made root-wide unique at load and lastRerouteId never decrements, so orphan keys can't be reoccupied by a live entity — it's roughly 4 KB per subgraph deletion with no correctness consequence.

One thing to carry into that follow-up, because it isn't visible from the diff: this.remove(subgraphNode) runs at LGraph.ts:2243, but the reroute migration loop reads reroute.pos at :2311, and Reroute.pos falls back to ORIGIN once the store entry is gone. Adding deleteReroute to the release loop without reordering that would drop every migrated reroute at the paste offset. Groups escape only because they're structuredCloned before the remove.

Also note the group half of your analysis is now stale — unpack allocates a fresh id at LGraph.ts:2162 as of 894756f. Skipping the shared helper: clear()'s version iterates multiple graphs and has a .some() fast path, so two dissimilar call sites would be sharing six lines.

Comment thread src/renderer/core/layout/types.ts Outdated
getNodeLayoutRef(nodeId: NodeId): Ref<NodeLayout | null>
getNodesInBounds(bounds: Bounds): ComputedRef<NodeId[]>
getAllNodes(): ComputedRef<ReadonlyMap<NodeId, NodeLayout>>
getAllGroups(graphId: UUID): ComputedRef<ReadonlyMap<GroupId, GroupLayout>>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: these graphId parameters are root-graph ids, and nothing in the name or type says so.

Every producer passes rootGraph.id, never the owning graph's id: LGraph.ts:1101, :1202, :1631, LGraphGroup.ts:142, Reroute.ts:294, LGraphCanvas.ts:2531, findRerouteAtPoint.ts:16, useSlotLinkInteraction.ts:143,251,279,490, LayoutStoreDataSource.ts:58. That is exactly why this PR needs deduplicateSubgraphGroupIds, whose own comment says the keys "share the root graph scope and therefore require root-wide IDs".

The failure mode for the next caller is quiet: passing graph.id for a subgraph builds a key that matches nothing, and all of these return null or empty rather than throwing. The PR's own test already writes layoutStore.getGroupLayout(graph.id!, 810) (ensureCorrectLayoutScale.test.ts:255) and passes only because that fixture happens to be a root graph.

Renaming the parameter to rootGraphId across types.ts / layoutStore.ts / layoutMutations.ts would be enough; a branded RootGraphId would make subgraph.id unpassable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed in 0873ed0 across types.ts, layoutStore.ts and layoutMutations.ts. The argument that settled it is one you undersold: this PR introduces the parameter — at the merge base the API was getRerouteLayout(rerouteId) with no scope argument and the group APIs didn't exist — so there was no debt to defer, only a new name to get right the first time. Positional args, so no call-site churn.

Skipped the branded RootGraphId. It needs an application point at every producer and a cast in every fixture across 28 files, which is a lot of type-system apparatus to guard a mistake nobody has made yet. Also left the graphId field on the op payloads alone — that's the CRDT-ready shape and a separate decision.

}

export interface ReadonlyLinkNetwork {
readonly rootGraph: { readonly id: UUID }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: should this be optional, given Reroute dereferences it unguarded at construction?

ReadonlyLinkNetwork is exported via the litegraph barrel, and adding a required member narrows the contract for implementers rather than adding capability for consumers. Reroute.ts:294 then does this.rootGraphId = network.rootGraph.id with no guard, so external code that hands litegraph a structural network object without rootGraph now throws TypeError: Cannot read properties of undefined (reading 'id') at construction instead of failing at a type check.

All in-repo production callers pass this from LGraph/Subgraph and the direct-construction fixture supplies rootGraph explicitly (LinkConnector.core.test.ts:34-72), so nothing internal breaks today. createMockLinkNetwork (src/utils/__tests__/litegraphTestUtils.ts:199-204) returns { ...overrides } as LinkNetwork, so the cast will keep hiding the new member from the type checker if it is ever used this way.

Either network.rootGraph?.id with registration skipped when absent, or a named error at Reroute.ts:294 so the failure is diagnosable, would be an improvement over the anonymous undefined dereference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this. The premise doesn't hold: ReadonlyLinkNetwork is not exported from the litegraph barrel — litegraph.ts:95-108 exports LinkNetwork only, and it's absent from src/types/index.ts. It appears in three internal files. Reroute's constructor also takes LinkNetwork, not the readonly variant, so the hypothetical caller would have to hand-roll addFloatingLink, removeReroute, _removeReroute, removeFloatingLink and both getLink/getReroute overloads; the one object in the repo that does (LinkConnector.core.test.ts:34-72) already supplies rootGraph.

Both remedies also make things worse. network.rootGraph?.id means rootGraphId goes optional, the reroute never registers, storedPosition falls back to ORIGIN permanently and set pos silently discards — a loud TypeError traded for a reroute pinned at (0,0) with no error at all, and a hole in the invariant this PR exists to establish.

The adjacent hole is real though: createMockLinkNetwork still returns { ...overrides } as LinkNetwork, so the cast hides the member regardless. That's the ~4 lines worth doing, and it's already tracked on the CodeRabbit thread.

parentId
])
)
return graph.links.map(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: the 0.4 branch calls graph.links.map unguarded while the branch two lines up guards with graph.links ?? [].

workflowJSON is toRaw(loadedWorkflow.initialState), which is user-supplied JSON that does not pass through a zod schema on this path, so a 0.4 workflow with links absent or null throws TypeError: Cannot read properties of undefined (reading 'map') and the insert fails with no useful message. A null entry in the array would also throw on the destructure.

Same guard as line 30 would cover it.

Separately, and lower priority: getLinks and getReroutes re-implement litegraph's 0.4 decoding (positional link tuples, extra.linkExtensions, extra.reroutes) that LGraph.configure already does at LGraph.ts:2553-2575 via LLink.createFromArray. The schema is litegraph's, so a future version bump now has to be applied in two files in two layers, and getting it wrong here fails silently (an inserted workflow loses links while opening the same file works). Worth considering moving the version branching next to the existing decoder and keeping this as the thin platform-layer caller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 894756f: (graph.links ?? []), i.e. the guard from eight lines up, applied a second time by someone who had clearly stopped paying attention halfway through the function. Test covers a 0.4 workflow with links absent.

The getLinks/getReroutes re-implementation of litegraph's 0.4 decoder is a fair point and untouched here — that one wants its own PR rather than a quiet ride along with five bug fixes.

import { createGeometryView } from './createGeometryView'
import { Rectangle } from './Rectangle'

describe('createGeometryView', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: since this file is the ecosystem compatibility boundary, it would be worth pinning the observable JS-value contract here.

The three tests cover indexed writes, set(), change suppression, synchronize-before-read and nested mapValue. None of them covers the properties an extension actually depends on, and those are where the behaviour changed: Array.isArray on the reroute view, length, JSON.stringify shape, [...] and {...} spread, instanceof, constructor identity, and structured-clone survivability. LGraphGroup.test.ts and Reroute.store.test.ts only exercise attached, registered entities, so the "attached but no store entry" path is untested too.

This is also the concrete half of the question at #14110 (comment) that is still open: useLayoutSync.ts:44 and LGraphNode.ts:1046 were both converted, but "basically every custom node" is answered by this shim rather than by a code change, and right now nothing pins what the shim guarantees. One table-driven test asserting the observable value contract would turn that from an argument into a regression gate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially. I ran all seven properties against both real view shapes (Float64Array for node pos/size, plain Array for Reroute.pos) before writing anything, and five of them — Array.isArray, length, JSON.stringify, spread, instanceof — are structurally unchangeable by this Proxy. No getPrototypeOf/ownKeys/has traps are defined, and Array.isArray pierces proxies per spec. Asserting those pins behaviour the code cannot vary, which is the change-detector testing AGENTS.md rules out.

The two that did change are the two you filed separately. constructor is now fixed and pinned by a test (0873ed0). structuredClone I've declined on the sibling thread for lack of any measurable consumer. Writing the table before resolving those would have locked a known regression in as intended behaviour.

Your secondary point — "attached but no store entry" being untested — was the sharper one, and it's covered now by the regression test for the setBounds bug.

| ----------------------- | ----------------------------------- | ------------------------------ | ------------------------------------------------------------------ | ----------------------------- |
| WidgetValueStore | `BaseWidget` | `graphId` | `WidgetId` (`graphId:nodeId:name`) | Plain `WidgetState` object |
| DomWidgetStore | `BaseDOMWidget` | Global | `widgetId` (UUID) | Position, visibility, z-index |
| LayoutStore | Node, Link, Group, Reroute geometry | Root graph for groups/reroutes | Raw node/link IDs; `${rootGraphId}:${localId}` for groups/reroutes | Y.js CRDT maps (pos, size) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: a few doc statements elsewhere now contradict the code this PR ships.

The summary row here is updated, but the sections below it and two other files still describe the pre-PR world:

  • proto-ecs-stores.md:337-338, :344, :396, :414-415 still say Reroute.posInternal is the position truth and the store holds a partial mirror. posInternal is deleted.
  • proto-ecs-stores.md:350-357, :375, :397, :416 still list Group as "Extracted: (nothing)" / "no extraction started". Groups now have GroupLayout, ygroups, and createGroup / setGroupBounds / deleteGroup.
  • proto-ecs-stores.md:175 still documents ynodes as nodeId -> { pos, size, zIndex, bounds }; the stored shape is now a single rect tuple (mappers.ts:14-20). The ygroups line right below it was updated.
  • proto-ecs-stores.md:189-198 "Write API" omits createGroup / setGroupBounds / deleteGroup.
  • ecs-target-architecture.md:236-238 still says Reroute.posInternal remains the source of truth.
  • reroute-chain-store.md:114-117 still says Reroute.pos "still mirrors" the store as a separate concern.
  • ecs-migration-plan.md:473-476 (added here) points at TODO(litegraph-stable-resize-api), but this PR deleted the only occurrence of that marker along with the hand-written size proxy. The same bullet says "The size Proxy" as if one exists, where there are now a pos view plus three on LGraphGroup.
  • reroute-chain-store.md:58-61: the edit removed the subject of the sentence, so it now reads "Today this is bucket would break on it."

Also worth considering: the new invariant that group ids must be root-wide unique is recorded only in a code comment in subgraphDeduplication.ts, and prior store migrations each got an ADR 0008 amendment plus a design record in the supporting-documents table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2a2514d: proto-ecs-stores.md (ynodes shape, group write API, both mermaid blocks, gap-analysis rows, priority order), ecs-target-architecture.md:237, and the ecs-migration-plan.md bullet that pointed at the deleted TODO(litegraph-stable-resize-api). Every line reference you gave checked out, and the doc set was contradicting itself — proto-ecs-stores.md called posInternal the truth while ecs-migration-plan.md in the same branch said it was deleted.

One bullet declined: reroute-chain-store.md:114-117. That file is a design record for #13449, not a current-state doc, and the convention for superseded records here is an appended **Update (date):** note — proto-ecs-stores.md:27,35,42 all do that — rather than rewriting the original scoping text. Happy to append a line if you'd rather it not read as current.

ADR 0008 amendment: agreed the precedent is real (three dated amendments plus the Supporting Documents table), deferring to a follow-up rather than growing this PR. Not inventing a new design-record doc to fill the table cell.

DrJKL and others added 3 commits July 30, 2026 19:10
Insert Workflow feeds raw workflow JSON straight to _deserializeItems,
which the clone-based clipboard path never did. Five defects follow:

- Serialized link ids reached node.configure, resolving against the
  destination graph's link map and firing onConnectionsChange with real
  but unrelated links. Strip them first, as LGraph.configure already does.
- configure() overrides reorder inputs to definition order, invalidating
  the serialized target_slot. Re-point links from the post-configure
  input order.
- Pinned nodes were skipped by the paste offset loop, landing stacked on
  the original. Repositioning a paste is not a user drag.
- Unpacking reused the definition's group id, so a retained definition
  and the unpacked copy shared one root-scoped layout entry.
- A 0.4 workflow with no links threw on graph.links.map.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- LGraphGroup.setBounds wrote nothing when the group was attached but had
  no store entry, so pos/size/resize/move/snapToGrid/configure became
  silent no-ops. Write the local bounds first, then attempt the store.
- createGeometryView wrapped constructor along with every other function
  value, so `x.constructor === Array` clone helpers took the wrong branch.
- repositionNodesVueMode was removed with no shim despite being public and
  shipped; restore it as a deprecated alias for applyNodePositions.
- LGraphGroup and SubgraphIONodeBase both returned true from snapToGrid
  unconditionally, while LGraphNode and Reroute mean "the position moved".
- layoutStore and layoutMutations take root-graph ids; name them that way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
proto-ecs-stores and ecs-target-architecture still described posInternal as
the position truth and Group as unextracted, contradicting ecs-migration-plan
in the same branch. Also updates the ynodes shape to the single rect tuple,
lists the group write API, and drops the deleted resize-API TODO reference.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@DrJKL
DrJKL requested a review from christian-byrne July 31, 2026 20:48
@DrJKL
DrJKL merged commit 15db3dd into feature/ecs-migration Jul 31, 2026
93 of 96 checks passed
@DrJKL
DrJKL deleted the drjkl/layout-single-source branch July 31, 2026 20:49
benjcooley added a commit that referenced this pull request Aug 10, 2026
useLayoutMutations' createNode, moveNode and resizeNode gained a rootGraphId
first parameter in #14110. nodeMoveBridge's test was the only caller on this
branch and did not compile after the merge.

The bridge itself needs no change — it subscribes through layoutStore.onChange,
which is graph-agnostic, so the test supplies its own id the way
layoutMutations.test.ts does.

Note for the ECS branch, not caused by this merge: the four failing
TransformPane tests fail identically on origin/feature/ecs-migration with this
branch absent.
benjcooley added a commit that referenced this pull request Aug 19, 2026
useLayoutMutations' createNode, moveNode and resizeNode gained a rootGraphId
first parameter in #14110. nodeMoveBridge's test was the only caller on this
branch and did not compile after the merge.

The bridge itself needs no change — it subscribes through layoutStore.onChange,
which is graph-agnostic, so the test supplies its own id the way
layoutMutations.test.ts does.

Note for the ECS branch, not caused by this merge: the four failing
TransformPane tests fail identically on origin/feature/ecs-migration with this
branch absent.
christian-byrne added a commit that referenced this pull request Aug 24, 2026
…Shell (#14257)

**STACKED — merging lands on `feature/ecs-migration` (owned by @DrJKL,
PR #13963's base), NOT `main`.**

## ELI-5

The code that wires a node's "shell state" (title, mode, colours,
shape…) into the app's Pinia stores was living inside the vendored
`src/lib/litegraph` folder, even though it is entirely app-owned. This
moves those definitions into `src/core/graph/nodeShell/` and leaves
one-line call sites behind in litegraph. Nothing changes at runtime —
same functions, same order, same events.

Fulfils the TODO committed to in
#13963 (comment).
cc @DrJKL

## What moved

`src/core/graph/nodeShell/nodeShellState.ts`

- `createNodeShellState(title, type, titleMode)` — the object literal
that was inline in the `LGraphNode` constructor.
- `setTrackedNodeState(node, property, value)` — the body of the former
private `LGraphNode.setTrackedState`; the six accessors (`title`,
`mode`, `color`, `bgcolor`, `showAdvanced`, `shape`) now call it.
- `registerNodeState` / `unregisterNodeState` /
`unregisterAllNodeStates` — moved verbatim.

`src/core/graph/nodeShell/nodeShellLifecycle.ts`

- `attachNodeToStores(graph, node)` — `registerNodeState` plus the
widget `setNodeId` / `setNodeWidgetOrder` block that was inline in
`LGraph.add`. `LGraph.add` is now a single call, in exactly the position
`registerNodeState` occupied (after `node.graph = this`, before
`_nodes.push` / `onAdded` / `node:added`).
- `releaseGraphStores(graph)` — the store-teardown block from
`LGraph.clear`. `LGraph.clear` is now a single call.

Also: `LGraph.remove` imports `unregisterNodeState` /
`unregisterAllNodeStates` from the new module, `LGraphNode.ts` no longer
imports `useNodeDataStore`, and the litegraph barrel no longer
re-exports `registerNodeState` / `unregisterNodeState` (new in #13963,
nothing external can depend on them yet — keeping the surface private
per review feedback). `useNodeReplacement` imports them from the new
module instead.

`fireNodeRemovalLifecycle` stays in `LGraph.ts` (litegraph events only,
no store access), and the link/reroute helpers stay in `LLink.ts` /
`Reroute.ts` — `releaseGraphStores` imports them from their current
homes.

## Judgment calls

- **Two files rather than one.** `nodeShellState.ts` holds the
node-level definitions and imports only `nodeDataStore`;
`nodeShellLifecycle.ts` holds the graph-level attach/release
coordination and is the only one that reaches for `LLink` / `Reroute` /
the other stores. That keeps `LGraphNode`'s new runtime import off the
`Reroute → litegraph barrel → LGraphNode` cycle. A production `vite
build` was run to confirm the module graph still resolves.
- **Skipped the optional `graphTriggers.ts` move.** DrJKL's stack
(#14110 → #14128 → #14133) is still open against this base, so the diff
is kept to a strict definitions-move to keep those rebases cheap. Moving
`graphTriggers.ts` would touch the barrel's export path and
`LGraph.ts`'s import block for no functional gain in this pass.
- **Tests.** The two registration/unregistration cases from
`LGraphNode.nodeState.test.ts` moved to
`src/core/graph/nodeShell/nodeShellState.test.ts` with assertions
unchanged; the accessor and `configure` cases stay where they are. Two
new cases cover `createNodeShellState`'s defaults. No test was deleted
or weakened. `useNodeReplacement.test.ts`'s barrel mock split into a
second `vi.mock` for the new module.

## Verification

`pnpm typecheck`, `pnpm lint` (0 errors), `pnpm knip`, and `vite build`
are clean. Targeted suites (litegraph, nodeShell, nodeDataStore,
nodeReplacement, minimap) — 91 files / 1341 tests pass.

Full `vitest run`: 14260 passed, 1 failed —
`src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts > lazily
resolves the /oauth layout and consent view components`, a 5s timeout on
a dynamic route import. It passes in isolation, is untouched by this
diff, and an earlier full run under load failed a different pair of
tests, so it reads as a load-dependent flake rather than a regression.
Flagging rather than hiding it.

---------

Co-authored-by: Christian Byrne <cbyrne@comfy.org>
balpreetgrowthnatives pushed a commit to balpreetgrowthnatives/ComfyUI_frontend that referenced this pull request Aug 24, 2026
## Summary

Still-draft feature branch for migrating entity state from LiteGraph
objects and runtime mirrors into dedicated stores with derived, reactive
views.

This consolidates the reviewed ECS migration slices, strengthens their
coverage, incorporates the layout-state follow-up, and documents the
current migration status and remaining work.

## Changes

- Move widget values and node shell state into dedicated stores.
- Make link topology the source of truth for connectivity.
- Store reroute chains while deriving membership and floating-link
state.
- Derive widgeted input connectivity, badges, and promoted widget rows
from store-backed state.
- Remove the input and output runtime link mirrors.
- Keep DOM measurements separate from persisted node layout state.
- Add migration coverage, extension guidance, and architecture/status
documentation.

Reviewed PRs merged into this feature branch:

- [Comfy-Org#13322 — Move widgets out of node
data](Comfy-Org#13322)
- [Comfy-Org#13434 — Host-scoped promoted widget
rows](Comfy-Org#13434)
- [Comfy-Org#13436 — Link topology
store](Comfy-Org#13436)
- [Comfy-Org#13449 — Reroute chain
store](Comfy-Org#13449)
- [Comfy-Org#13451 — Derived floating links and reroute
cleanup](Comfy-Org#13451)
- [Comfy-Org#13455 — Store-backed widgeted input
connectivity](Comfy-Org#13455)
- [Comfy-Org#13458 — Badge store and
system](Comfy-Org#13458)
- [Comfy-Org#13479 — Remove the output-link runtime
mirror](Comfy-Org#13479)
- [Comfy-Org#13498 — Remove the input-link runtime
mirror](Comfy-Org#13498)
- [Comfy-Org#13528 — Cross-stack migration audit
fixes](Comfy-Org#13528)
- [Comfy-Org#13686 — Derive badges on
read](Comfy-Org#13686)
- [Comfy-Org#13963 — Node data
store](Comfy-Org#13963)
- [Comfy-Org#14110 — Centralize node, group, and reroute
geometry](Comfy-Org#14110)
- [Comfy-Org#14128 — Register node geometry at
attach](Comfy-Org#14128)
- [Comfy-Org#14133 — Read node geometry from the
store](Comfy-Org#14133)
- [Comfy-Org#14758 — Keep DOM measurements out of saved node
sizes](Comfy-Org#14758)
- [Comfy-Org#15001 — Extract entity ID
allocation](Comfy-Org#15001)
- [Comfy-Org#15009 — Scope link and reroute topology by owning
graph](Comfy-Org#15009)
- [Comfy-Org#15017 — Centralize layout ownership and command
submission](Comfy-Org#15017)
- [Comfy-Org#15018 — Preserve subgraph topology during
unpack](Comfy-Org#15018)
- [Comfy-Org#15019 — Transfer node ownership during
replacement](Comfy-Org#15019)
- [Comfy-Org#15330 — Map migration status and remaining
work](Comfy-Org#15330)

## Review Focus

- Store ownership and synchronization boundaries.
- Serialization, undo/redo, subgraph, and extension compatibility.
- Whether remaining direct entity state should migrate before this
feature leaves draft.

## Status

Still draft. The branch is rebased onto `main`; CI is running against
the rebased history.

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Christian Byrne <cbyrne@comfy.org>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Matt Miller <mattmiller@comfy.org>
benjcooley added a commit that referenced this pull request Aug 26, 2026
useLayoutMutations' createNode, moveNode and resizeNode gained a rootGraphId
first parameter in #14110. nodeMoveBridge's test was the only caller on this
branch and did not compile after the merge.

The bridge itself needs no change — it subscribes through layoutStore.onChange,
which is graph-agnostic, so the test supplies its own id the way
layoutMutations.test.ts does.

Note for the ECS branch, not caused by this merge: the four failing
TransformPane tests fail identically on origin/feature/ecs-migration with this
branch absent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants