Skip to content

refactor: register node geometry at attach, delete useVueNodeLifecycle - #14128

Merged
DrJKL merged 40 commits into
feature/ecs-migrationfrom
drjkl/layout-registration-at-attach
Aug 5, 2026
Merged

DrJKL merged 40 commits into
feature/ecs-migrationfrom
drjkl/layout-registration-at-attach

Conversation

@DrJKL

@DrJKL DrJKL commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Phase: move node layout registration to the entity's attach point, so the renderer stops owning node lifetime.

Nodes were the only positionable whose layout entry was created by the renderer — groups register in LGraph.add, reroutes in their constructor, nodes went through useVueNodeLifecycle listening to node:added / node:removed. That indirection is why entries could outlive the graph that created them, which is what the ownership attempts on the parent branch were working around.

Changes

  • Node geometry registers in LGraph.add and deregisters in LGraph.remove, beside registerNodeState / unregisterNodeState.
  • graphLayoutRegistration centralizes node, group, and reroute registration and teardown, including graph clear, non-clearing configure, and recursive subgraph release paths.
  • initializeFromLiteGraph split: the seeding half is gone, the view-change reset becomes clearViewGeometry; reset covers full teardown.
  • useVueNodeLifecycle deleted. GraphCanvas directly owns the remaining useLayoutSync and mode-switch lifecycle, while legacy-node arrangement moves to arrangeForLegacyRender. setupEmptyGraphListener disappears with renderer-owned seeding.
  • Deleted the layout operation log (see below).
  • Node layout is keyed by makeScopedLayoutKey(rootGraphId, nodeId), the scheme groups and reroutes already used (see below).

Fixed along the way

  • zIndex was seeded two ways that disagreed. initializeFromLiteGraph used the node's index in _nodes; the per-node path used node.order, which is execution order from computeExecutionOrder and unrelated to stacking. Draw order wins.

Performance

Deleting the never-read operation log removed an unbounded per-operation cost that grew with session length, in Vue nodes mode today:

moveNode with an entry
22k operations logged 197 us/op
40k operations logged 375 us/op
log deleted 5.4 us/op, flat (2.9 us/op after 18k more)

That is also what made attach-time registration affordable for the legacy canvas, which now pays for entries it does not read. Dragging 100 selected nodes: 10.8 ms/frame (65% of a 16.7ms frame) before, 0.60 ms/frame (3.6%) after.

Behaviour change to review

layoutStore now holds every node in the workflow rather than only the viewed graph. Only tests call queryNodeAtPoint / getNodesInBounds, and both getAllNodes callers only take a max zIndex, so nothing reads across the wider set today.

Three tests asserted the policy this reverses (no layout while the renderer is off; seeding stops on dispose; adds to unviewed graphs ignored). They pinned the old design rather than behaviour worth keeping, so they are deleted; the contract still worth holding — add creates an entry, remove drops it — moved next to LGraph, with a test that zIndex follows draw order.

Node layout keys are now root-graph scoped

Groups and reroutes were already keyed by makeScopedLayoutKey(rootGraphId, id); nodes were the exception, keyed by a bare NodeId. Now that registration is unconditional, that exception is what kept layout from having a bucket to wipe — hence the // Geometry has no per-rootGraph bucket to wipe, so both branches sweep comment this removes.

Node methods on LayoutStore and LayoutMutations take a leading rootGraphId. graphId lifts into OperationMeta so all three entity bases inherit it. parseLayoutKey splits on the first : rather than the last, so node ids containing : round-trip; graph ids are UUIDs and never contain one.

This does not fix an id collision — there was never one to fix. Subgraph shares the root graph's state, so one counter issues every node id, and root and interior nodes sharing a bucket is safe. What it buys is that a root graph's teardown becomes a single layoutStore.clearGraph(graphId) sitting beside the five peer stores already cleared there, instead of layout being the one exception that had to walk the subgraph tree. unregisterAllGraphLayout stays for graphs that share the root's bucket — subgraphs, unconfigured graphs, orphaned subgraph release — and now mirrors unregisterAllNodeStates exactly.

Worth a second opinion: six Vue-node composables now read useCanvasStore().rootGraphId where they previously only touched the layout singleton. They are all current-canvas-only paths, and the alternative pushes rootGraphId! non-null assertions into .vue templates.

One consequence of that read is worth knowing about, since it caught me out. In useNodeLayout the layout read must stay dynamic — the node v-for keys on a bare node id, so Vue patches a component across a graph change rather than remounting it, and a captured id would resolve stale. Ref cleanup must be the opposite: rootGraphId flips before the outgoing graph's components unmount, so reading it in onUnmounted released the ref into the incoming bucket and stranded the real one. Captured at setup now, with a test pinning it. Only ids that do not survive a workflow load were affected; ids present in both are patched, never unmounted.

Downstream stack

#14133 completes node geometry ownership after this PR establishes attach/detach lifetime. It makes the node Rectangle a versioned projection of layoutStore, reuses the shared geometry view for compatible mutable pos / size access, deletes useLayoutSync, and replaces writeback with operation-driven resize notifications and canvas invalidation.

Review this PR's registration and teardown contract independently of that downstream read-path change: this PR still retains useLayoutSync by design.

Things an inattentive agent might call out but which are not valid findings

Each of these has been checked against the code. If you are about to file one, read the rebuttal first.

"Node layout entries are keyed by a bare node id with no graph scope, unlike groups and reroutes."

No longer true — they are scoped by rootGraphId, as of the commit above. Note what that did and did not change: root and subgraph-interior nodes still share one bucket, and that is deliberate, because node ids are unique root-wide. Deserialized ids go through deduplicateSubgraphNodeIds, called from LGraph.configure when isRootGraph, which remaps colliding interior ids and patches links and promoted widgets. Runtime-allocated ids come from ++state.lastNodeId, and Subgraph.state returns rootGraph.state — one counter for the whole workflow. Clipboard paste and unpack have their own remapping. basic-subgraph.json looks like a collision on disk (root 2, interior 1, 2) and loads as 2, 1, 3. LGraph.test.ts pins both halves: expect(subgraph.state).toBe(rootGraph.state) and 'node IDs never collide between root and subgraph'.

A repro that reaches a collision by assigning node.id directly before add() is not evidence — LGraph.add's duplicate guard is per-graph by design, and no production path assigns ids that way.

"useLayoutSync can now resolve a store change against the wrong node, because changes from unviewed graphs flush against the viewed graph."

Same root cause as above, same rebuttal. Ids do not collide, so getNodeById cannot resolve to a different node.

"LGraph.add now requires an active Pinia instance, breaking headless and extension use."

layoutStore is a plain module singleton, not a Pinia store, and useLayoutMutations touches nothing else. LGraph.add already required Pinia before this PR via registerNodeState and useWidgetValueStore. Net change to Pinia surface: zero.

"src/lib/litegraph importing from src/renderer/core/layout violates the layering boundary."

import-x/no-restricted-paths deliberately scopes its zones to base, platform, workbench, and world; litegraph is outside them. ADR 0001 merged litegraph into the frontend precisely so mutations route through one CRDT-mediated access point. LGraph.ts already imported useLayoutMutations and layoutStore; this PR swaps a raw mutations import for a named registration module, leaving the edge count unchanged.

"Registering layout inside LGraph.add is god-object growth on LGraph (ADR 0008)."

No methods or properties are added to LGraph, LGraphNode, LGraphCanvas, or Subgraph. Existing methods delegate to a module, and every write still lands as a LayoutOperation through applyOperation — the command pattern is intact. clearGraph is likewise a ClearGraphOperation dispatched through applyOperation, not a side-channel wipe.

"deleteGroup and deleteReroute gained an existence guard but deleteNode did not — inconsistent."

deleteNode already had the identical guard before this PR. Its absence from the diff is correct.

"Those existence guards are redundant with a check applyOperation already does."

applyOperation calls Y.Map.delete unconditionally and still bumps version and dispatches change listeners. The early return suppresses real churn.

"Moving the group loop after this.remove(subgraphNode) in unpackSubgraph changes behaviour."

toSelect ordering is unchanged, offsetX / offsetY are not mutated in between, and nothing in the intervening block reads groups. The move is required: remove() now triggers unregisterAllGraphLayout(subgraph), which would otherwise run after the unpacked groups registered and drop their entries.

"Populating layoutStore with the Vue renderer off breaks the minimap, which picks its data source by asking whether the store has nodes."

That rationale is stale — it survived in a docstring longer than in the code. MinimapDataSourceFactory selects on LiteGraph.vueNodesMode, and MinimapDataSource.test.ts has an explicit regression test forbidding the emptiness check.

"startSync can be skipped on the immediate run when the canvas is not ready, and removing setupEmptyGraphListener loses the empty-graph deferral."

startSync no-ops safely when there is no graph, and the watcher re-fires when canvasStore.currentGraph flips from null, which is reactive — unlike the old comfyApp.canvas?.graph source that setupEmptyGraphListener existed to work around. stopSync is idempotent. The deferral is obsolete, not lost.

"Dropping the isInSubgraph watcher's layout reset breaks subgraph navigation."

canvasStore.currentGraph updates on subgraph navigation, so the consolidated watcher covers it. Node membership comes from nodeDataStore.getGraphNodesFor, which stays graph-scoped regardless.

"The new e2e spec uses page.evaluate instead of user actions."

The regression under test is an extension calling node.setSize() and the Vue node not moving. No user gesture reaches that path; driving the resize handle would exercise a different one and pass with the bug present.

@coderabbitai

coderabbitai Bot commented Jul 27, 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: 991c5a1c-752f-4afe-9fe8-1119d0bba4a4

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
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 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.
End-To-End Regression Coverage For Fixes ✅ Passed The PR changes frontend files under src/ and also adds browser_tests/tests/vueNodes/layout/subgraphLayoutSync.spec.ts, so the required browser test coverage is present.
Adr Compliance For Entity/Litegraph Changes ✅ Passed Changed paths trigger the check, but metadata shows registration delegates to layout mutations, adds no LGraph/entity methods, and changes no extension callback contracts or ECS component patterns.
Title check ✅ Passed The title clearly summarizes the primary changes: attach-time node geometry registration and removal of useVueNodeLifecycle.
Description check ✅ Passed The description provides a detailed summary, change list, behavior changes, performance data, risks, and review context, despite missing some template headings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drjkl/layout-registration-at-attach

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

@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 08/05/2026, 07:43:19 PM UTC

Links

🎭 Playwright: ✅ 1761 passed, 0 failed · 3 flaky

📊 Browser Reports
  • chromium: View Report (✅ 1740 / ❌ 0 / ⚠️ 3 / ⏭️ 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.9 MB heap
canvas-mouse-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 49.3 MB heap
canvas-zoom-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 73.7 MB heap
dom-widget-clipping: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 56.9 MB heap
large-graph-idle: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 66.1 MB heap
large-graph-pan: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 75.9 MB heap
large-graph-zoom: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 68.5 MB heap
legacy-node-drag: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 79.5 MB heap
minimap-idle: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 70.6 MB heap
subgraph-dom-widget-clipping: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 57.0 MB heap
subgraph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 44.3 MB heap
subgraph-mouse-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 55.0 MB heap
subgraph-transition-enter: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 126ms TBT · 91.9 MB heap
viewport-pan-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 77.3 MB heap
vue-large-graph-idle: · 56.3 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 155.0 MB heap
vue-large-graph-pan: · 53.7 avg FPS · 39.8 P5 FPS ❌ (target: ≥52) · 807ms TBT · 159.5 MB heap
workflow-execution: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 49.8 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 8ms
canvas-idle: layout count 0
canvas-idle: style recalc count 9
canvas-idle: task duration 567ms
canvas-idle: script duration 30ms
canvas-idle: TBT 0ms
canvas-idle: heap used 70.9 MB
canvas-idle: DOM nodes 17
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 46ms
canvas-mouse-sweep: layout count 12
canvas-mouse-sweep: style recalc count 79
canvas-mouse-sweep: task duration 1010ms
canvas-mouse-sweep: script duration 191ms
canvas-mouse-sweep: TBT 0ms
canvas-mouse-sweep: heap used 49.3 MB
canvas-mouse-sweep: DOM nodes -275
canvas-mouse-sweep: event listeners -152
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 18ms
canvas-zoom-sweep: layout count 6
canvas-zoom-sweep: style recalc count 31
canvas-zoom-sweep: task duration 423ms
canvas-zoom-sweep: script duration 30ms
canvas-zoom-sweep: TBT 0ms
canvas-zoom-sweep: heap used 73.7 MB
canvas-zoom-sweep: DOM nodes 77
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 8ms
dom-widget-clipping: layout count 0
dom-widget-clipping: style recalc count 11
dom-widget-clipping: task duration 417ms
dom-widget-clipping: script duration 90ms
dom-widget-clipping: TBT 0ms
dom-widget-clipping: heap used 56.9 MB
dom-widget-clipping: DOM nodes 17
dom-widget-clipping: event listeners 2
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 7ms
large-graph-idle: layout count 0
large-graph-idle: style recalc count 8
large-graph-idle: task duration 962ms
large-graph-idle: script duration 284ms
large-graph-idle: TBT 0ms
large-graph-idle: heap used 66.1 MB
large-graph-idle: DOM nodes -276
large-graph-idle: event listeners -148
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 12ms
large-graph-pan: layout count 0
large-graph-pan: style recalc count 68
large-graph-pan: task duration 2041ms
large-graph-pan: script duration 1137ms
large-graph-pan: TBT 0ms
large-graph-pan: heap used 75.9 MB
large-graph-pan: DOM nodes -279
large-graph-pan: event listeners -146
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 13ms
large-graph-zoom: layout count 60
large-graph-zoom: style recalc count 63
large-graph-zoom: task duration 2256ms
large-graph-zoom: script duration 1236ms
large-graph-zoom: TBT 0ms
large-graph-zoom: heap used 68.5 MB
large-graph-zoom: DOM nodes -283
large-graph-zoom: event listeners -149
legacy-node-drag: avg frame time 17ms
legacy-node-drag: p95 frame time 17ms
legacy-node-drag: layout duration 0ms
legacy-node-drag: style recalc duration 8ms
legacy-node-drag: layout count 0
legacy-node-drag: style recalc count 44
legacy-node-drag: task duration 3324ms
legacy-node-drag: script duration 1290ms
legacy-node-drag: TBT 0ms
legacy-node-drag: heap used 79.5 MB
legacy-node-drag: DOM nodes -139
legacy-node-drag: event listeners 47
minimap-idle: avg frame time 17ms
minimap-idle: p95 frame time 17ms
minimap-idle: layout duration 0ms
minimap-idle: style recalc duration 5ms
minimap-idle: layout count 0
minimap-idle: style recalc count 6
minimap-idle: task duration 881ms
minimap-idle: script duration 270ms
minimap-idle: TBT 0ms
minimap-idle: heap used 70.6 MB
minimap-idle: DOM nodes -277
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 47
subgraph-dom-widget-clipping: task duration 431ms
subgraph-dom-widget-clipping: script duration 142ms
subgraph-dom-widget-clipping: TBT 0ms
subgraph-dom-widget-clipping: heap used 57.0 MB
subgraph-dom-widget-clipping: DOM nodes 20
subgraph-dom-widget-clipping: event listeners 8
subgraph-idle: avg frame time 17ms
subgraph-idle: p95 frame time 17ms
subgraph-idle: layout duration 0ms
subgraph-idle: style recalc duration 10ms
subgraph-idle: layout count 0
subgraph-idle: style recalc count 10
subgraph-idle: task duration 513ms
subgraph-idle: script duration 19ms
subgraph-idle: TBT 0ms
subgraph-idle: heap used 44.3 MB
subgraph-idle: DOM nodes -127
subgraph-idle: event listeners -74
subgraph-mouse-sweep: avg frame time 17ms
subgraph-mouse-sweep: p95 frame time 17ms
subgraph-mouse-sweep: layout duration 5ms
subgraph-mouse-sweep: style recalc duration 40ms
subgraph-mouse-sweep: layout count 16
subgraph-mouse-sweep: style recalc count 77
subgraph-mouse-sweep: task duration 866ms
subgraph-mouse-sweep: script duration 122ms
subgraph-mouse-sweep: TBT 0ms
subgraph-mouse-sweep: heap used 55.0 MB
subgraph-mouse-sweep: DOM nodes -106
subgraph-mouse-sweep: event listeners -74
subgraph-transition-enter: avg frame time 17ms
subgraph-transition-enter: p95 frame time 17ms
subgraph-transition-enter: layout duration 13ms
subgraph-transition-enter: style recalc duration 31ms
subgraph-transition-enter: layout count 14
subgraph-transition-enter: style recalc count 18
subgraph-transition-enter: task duration 1015ms
subgraph-transition-enter: script duration 54ms
subgraph-transition-enter: TBT 126ms
subgraph-transition-enter: heap used 91.9 MB
subgraph-transition-enter: DOM nodes 13671
subgraph-transition-enter: event listeners 2377
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 251
viewport-pan-sweep: task duration 6977ms
viewport-pan-sweep: script duration 3678ms
viewport-pan-sweep: TBT 0ms
viewport-pan-sweep: heap used 77.3 MB
viewport-pan-sweep: DOM nodes -273
viewport-pan-sweep: event listeners -128
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 17618ms
vue-large-graph-idle: script duration 1140ms
vue-large-graph-idle: TBT 0ms
vue-large-graph-idle: heap used 155.0 MB
vue-large-graph-idle: DOM nodes -6548
vue-large-graph-idle: event listeners -7469
vue-large-graph-pan: avg frame time 19ms
vue-large-graph-pan: p95 frame time 25ms
vue-large-graph-pan: layout duration 0ms
vue-large-graph-pan: style recalc duration 24ms
vue-large-graph-pan: layout count 0
vue-large-graph-pan: style recalc count 169
vue-large-graph-pan: task duration 22400ms
vue-large-graph-pan: script duration 1702ms
vue-large-graph-pan: TBT 807ms
vue-large-graph-pan: heap used 159.5 MB
vue-large-graph-pan: DOM nodes -6548
vue-large-graph-pan: event listeners -7464
workflow-execution: avg frame time 17ms
workflow-execution: p95 frame time 17ms
workflow-execution: layout duration 1ms
workflow-execution: style recalc duration 20ms
workflow-execution: layout count 3
workflow-execution: style recalc count 13
workflow-execution: task duration 122ms
workflow-execution: script duration 11ms
workflow-execution: TBT 0ms
workflow-execution: heap used 49.8 MB
workflow-execution: DOM nodes 125
workflow-execution: event listeners 65
Raw data
{
  "timestamp": "2026-08-05T19:54:29.749Z",
  "gitSha": "d0b50c5f163126231fad02b9b46756385f0d740f",
  "branch": "drjkl/layout-registration-at-attach",
  "measurements": [
    {
      "name": "canvas-idle",
      "durationMs": 2033.3550000000287,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 8.03,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 573.744,
      "heapDeltaBytes": 4703988,
      "heapUsedBytes": 74281116,
      "domNodes": 18,
      "jsHeapTotalBytes": 18739200,
      "scriptDurationMs": 29.541999999999998,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-idle",
      "durationMs": 2025.3220000000738,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 7.987000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 560.9110000000001,
      "heapDeltaBytes": 4767120,
      "heapUsedBytes": 74404508,
      "domNodes": 16,
      "jsHeapTotalBytes": 19001344,
      "scriptDurationMs": 29.765,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 2041.6349999999852,
      "styleRecalcs": 79,
      "styleRecalcDurationMs": 51.008,
      "layouts": 12,
      "layoutDurationMs": 4.063,
      "taskDurationMs": 1053.746,
      "heapDeltaBytes": -19882124,
      "heapUsedBytes": 49586504,
      "domNodes": -275,
      "jsHeapTotalBytes": 19914752,
      "scriptDurationMs": 201.041,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 1957.5940000000855,
      "styleRecalcs": 78,
      "styleRecalcDurationMs": 41.812999999999995,
      "layouts": 12,
      "layoutDurationMs": 3.522,
      "taskDurationMs": 966.6049999999999,
      "heapDeltaBytes": -15778128,
      "heapUsedBytes": 53899428,
      "domNodes": -275,
      "jsHeapTotalBytes": 19914752,
      "scriptDurationMs": 181.305,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1755.4209999999557,
      "styleRecalcs": 31,
      "styleRecalcDurationMs": 19.680999999999997,
      "layouts": 6,
      "layoutDurationMs": 0.722,
      "taskDurationMs": 431.75300000000004,
      "heapDeltaBytes": 7709588,
      "heapUsedBytes": 77183092,
      "domNodes": 77,
      "jsHeapTotalBytes": 19525632,
      "scriptDurationMs": 31.453000000000003,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1735.0669999999582,
      "styleRecalcs": 30,
      "styleRecalcDurationMs": 17.209999999999997,
      "layouts": 6,
      "layoutDurationMs": 0.5820000000000001,
      "taskDurationMs": 414.36899999999997,
      "heapDeltaBytes": 7730752,
      "heapUsedBytes": 77362140,
      "domNodes": 76,
      "jsHeapTotalBytes": 18739200,
      "scriptDurationMs": 29.069,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 629.4149999999945,
      "styleRecalcs": 12,
      "styleRecalcDurationMs": 8.765,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 428.557,
      "heapDeltaBytes": -10170156,
      "heapUsedBytes": 59460652,
      "domNodes": 20,
      "jsHeapTotalBytes": 20312064,
      "scriptDurationMs": 91.362,
      "eventListeners": 2,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 602.6770000000852,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 6.507999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 404.57699999999994,
      "heapDeltaBytes": -9881752,
      "heapUsedBytes": 59836036,
      "domNodes": 14,
      "jsHeapTotalBytes": 19787776,
      "scriptDurationMs": 89.587,
      "eventListeners": 2,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2050.7939999999962,
      "styleRecalcs": 7,
      "styleRecalcDurationMs": 6.582999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 933.3530000000001,
      "heapDeltaBytes": -10722860,
      "heapUsedBytes": 68866732,
      "domNodes": -277,
      "jsHeapTotalBytes": 3325952,
      "scriptDurationMs": 276.777,
      "eventListeners": -148,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2059.6680000001015,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 7.4959999999999996,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 990.471,
      "heapDeltaBytes": -9543064,
      "heapUsedBytes": 69816580,
      "domNodes": -274,
      "jsHeapTotalBytes": 3325952,
      "scriptDurationMs": 291.24899999999997,
      "eventListeners": -148,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.670000000000012,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2773.5159999999723,
      "styleRecalcs": 68,
      "styleRecalcDurationMs": 11.834999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1946.8529999999998,
      "heapDeltaBytes": -895416,
      "heapUsedBytes": 79375232,
      "domNodes": -278,
      "jsHeapTotalBytes": 4055040,
      "scriptDurationMs": 1080.186,
      "eventListeners": -146,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-pan",
      "durationMs": 3162.1200000000727,
      "styleRecalcs": 68,
      "styleRecalcDurationMs": 13.050000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 2135.3940000000002,
      "heapDeltaBytes": -1216704,
      "heapUsedBytes": 79835044,
      "domNodes": -279,
      "jsHeapTotalBytes": 4317184,
      "scriptDurationMs": 1193.913,
      "eventListeners": -146,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666696,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 4046.228000000042,
      "styleRecalcs": 63,
      "styleRecalcDurationMs": 13.193000000000003,
      "layouts": 60,
      "layoutDurationMs": 7.5840000000000005,
      "taskDurationMs": 2221.9790000000003,
      "heapDeltaBytes": 5383696,
      "heapUsedBytes": 65768156,
      "domNodes": -282,
      "jsHeapTotalBytes": 3469312,
      "scriptDurationMs": 1213.8960000000002,
      "eventListeners": -150,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 4211.329999999975,
      "styleRecalcs": 63,
      "styleRecalcDurationMs": 13.561000000000003,
      "layouts": 60,
      "layoutDurationMs": 7.595,
      "taskDurationMs": 2290.7249999999995,
      "heapDeltaBytes": 16707520,
      "heapUsedBytes": 77833916,
      "domNodes": -283,
      "jsHeapTotalBytes": 2420736,
      "scriptDurationMs": 1258.4279999999999,
      "eventListeners": -148,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "legacy-node-drag",
      "durationMs": 4391.434000000004,
      "styleRecalcs": 44,
      "styleRecalcDurationMs": 8.322000000000003,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 3320.7210000000005,
      "heapDeltaBytes": 15713348,
      "heapUsedBytes": 77779308,
      "domNodes": -283,
      "jsHeapTotalBytes": 8855552,
      "scriptDurationMs": 1296.0130000000001,
      "eventListeners": -96,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "legacy-node-drag",
      "durationMs": 4427.074999999945,
      "styleRecalcs": 44,
      "styleRecalcDurationMs": 7.972999999999997,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 3328.101,
      "heapDeltaBytes": 27231864,
      "heapUsedBytes": 88937480,
      "domNodes": 6,
      "jsHeapTotalBytes": 11939840,
      "scriptDurationMs": 1283.477,
      "eventListeners": 190,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "minimap-idle",
      "durationMs": 2023.5000000000127,
      "styleRecalcs": 6,
      "styleRecalcDurationMs": 5.340999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 873.619,
      "heapDeltaBytes": 7551616,
      "heapUsedBytes": 68351980,
      "domNodes": -276,
      "jsHeapTotalBytes": 323584,
      "scriptDurationMs": 267.915,
      "eventListeners": -148,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "minimap-idle",
      "durationMs": 2043.8669999999775,
      "styleRecalcs": 6,
      "styleRecalcDurationMs": 5.637000000000003,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 887.9140000000001,
      "heapDeltaBytes": 18479952,
      "heapUsedBytes": 79721500,
      "domNodes": -277,
      "jsHeapTotalBytes": -1511424,
      "scriptDurationMs": 271.607,
      "eventListeners": -146,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 658.4789999999998,
      "styleRecalcs": 47,
      "styleRecalcDurationMs": 12.238999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 450.875,
      "heapDeltaBytes": -10079612,
      "heapUsedBytes": 59821536,
      "domNodes": 20,
      "jsHeapTotalBytes": 19787776,
      "scriptDurationMs": 148.761,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 612.367000000063,
      "styleRecalcs": 47,
      "styleRecalcDurationMs": 11.531999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 410.36100000000005,
      "heapDeltaBytes": -10033828,
      "heapUsedBytes": 59820000,
      "domNodes": 20,
      "jsHeapTotalBytes": 19525632,
      "scriptDurationMs": 134.55800000000002,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2013.3839999999736,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 8.938999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 502.13700000000006,
      "heapDeltaBytes": -23419844,
      "heapUsedBytes": 46161336,
      "domNodes": 18,
      "jsHeapTotalBytes": 18604032,
      "scriptDurationMs": 18.581999999999997,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2023.537000000033,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 10.176,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 524.277,
      "heapDeltaBytes": -22676460,
      "heapUsedBytes": 46814900,
      "domNodes": -272,
      "jsHeapTotalBytes": 19128320,
      "scriptDurationMs": 19.891000000000002,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1713.501000000008,
      "styleRecalcs": 76,
      "styleRecalcDurationMs": 37.074,
      "layouts": 16,
      "layoutDurationMs": 4.327,
      "taskDurationMs": 793.565,
      "heapDeltaBytes": -3853224,
      "heapUsedBytes": 65980972,
      "domNodes": 64,
      "jsHeapTotalBytes": 19263488,
      "scriptDurationMs": 112.00200000000001,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1772.1599999999853,
      "styleRecalcs": 77,
      "styleRecalcDurationMs": 42.724000000000004,
      "layouts": 16,
      "layoutDurationMs": 5.383000000000001,
      "taskDurationMs": 938.1229999999999,
      "heapDeltaBytes": -20439852,
      "heapUsedBytes": 49282292,
      "domNodes": -275,
      "jsHeapTotalBytes": 18866176,
      "scriptDurationMs": 131.829,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "subgraph-transition-enter",
      "durationMs": 1385.672999999997,
      "styleRecalcs": 18,
      "styleRecalcDurationMs": 31.464999999999993,
      "layouts": 14,
      "layoutDurationMs": 12.547000000000002,
      "taskDurationMs": 1014.8379999999999,
      "heapDeltaBytes": 4692236,
      "heapUsedBytes": 96384232,
      "domNodes": 13671,
      "jsHeapTotalBytes": 10747904,
      "scriptDurationMs": 54.34799999999999,
      "eventListeners": 2377,
      "totalBlockingTimeMs": 126,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 9463.371999999992,
      "styleRecalcs": 251,
      "styleRecalcDurationMs": 37.727999999999994,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 6740.728,
      "heapDeltaBytes": 11232388,
      "heapUsedBytes": 90217564,
      "domNodes": -273,
      "jsHeapTotalBytes": 4812800,
      "scriptDurationMs": 3561.482,
      "eventListeners": -130,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 10584.45400000005,
      "styleRecalcs": 250,
      "styleRecalcDurationMs": 37.412,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 7213.509,
      "heapDeltaBytes": -7282536,
      "heapUsedBytes": 71970516,
      "domNodes": -272,
      "jsHeapTotalBytes": 4288512,
      "scriptDurationMs": 3794.3509999999997,
      "eventListeners": -126,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 17479.42699999999,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 17462.5,
      "heapDeltaBytes": -42424536,
      "heapUsedBytes": 161014756,
      "domNodes": -6548,
      "jsHeapTotalBytes": 2420736,
      "scriptDurationMs": 1127.042,
      "eventListeners": -7471,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.776666666666642,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 17793.115000000056,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 17774.301,
      "heapDeltaBytes": -39716936,
      "heapUsedBytes": 163955000,
      "domNodes": -6548,
      "jsHeapTotalBytes": 1634304,
      "scriptDurationMs": 1153.17,
      "eventListeners": -7467,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.77333333333336,
      "p95FrameDurationMs": 16.80000000000291
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 21945.74099999994,
      "styleRecalcs": 160,
      "styleRecalcDurationMs": 22.05800000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 21921.147999999997,
      "heapDeltaBytes": -18172020,
      "heapUsedBytes": 170177000,
      "domNodes": -6548,
      "jsHeapTotalBytes": 2596864,
      "scriptDurationMs": 1637.6650000000002,
      "eventListeners": -7467,
      "totalBlockingTimeMs": 673,
      "frameDurationMs": 18.333333333333332,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 22908.285999999975,
      "styleRecalcs": 177,
      "styleRecalcDurationMs": 26.168999999999997,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 22878.590000000004,
      "heapDeltaBytes": -36070948,
      "heapUsedBytes": 164235024,
      "domNodes": -6548,
      "jsHeapTotalBytes": 585728,
      "scriptDurationMs": 1766.6770000000001,
      "eventListeners": -7461,
      "totalBlockingTimeMs": 941,
      "frameDurationMs": 18.890000000000025,
      "p95FrameDurationMs": 33.400000000001455
    },
    {
      "name": "workflow-execution",
      "durationMs": 460.26599999993323,
      "styleRecalcs": 13,
      "styleRecalcDurationMs": 19.923,
      "layouts": 3,
      "layoutDurationMs": 0.575,
      "taskDurationMs": 123.13999999999999,
      "heapDeltaBytes": -16393192,
      "heapUsedBytes": 51963420,
      "domNodes": 128,
      "jsHeapTotalBytes": 7204864,
      "scriptDurationMs": 11.98,
      "eventListeners": 65,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "workflow-execution",
      "durationMs": 474.1960000000063,
      "styleRecalcs": 13,
      "styleRecalcDurationMs": 19.907,
      "layouts": 3,
      "layoutDurationMs": 0.6560000000000001,
      "taskDurationMs": 121.40299999999999,
      "heapDeltaBytes": -15943944,
      "heapUsedBytes": 52377468,
      "domNodes": 121,
      "jsHeapTotalBytes": 6418432,
      "scriptDurationMs": 10.987999999999998,
      "eventListeners": 65,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    }
  ]
}

@codecov

codecov Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.73469% with 57 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/components/graph/GraphCanvas.vue 0.00% 21 Missing ⚠️
...enderer/core/layout/store/__mocks__/layoutStore.ts 35.29% 11 Missing ⚠️
...renderer/core/canvas/litegraph/slotCalculations.ts 0.00% 4 Missing ⚠️
...nderer/extensions/vueNodes/layout/useNodeLayout.ts 73.33% 4 Missing ⚠️
.../composables/canvas/useSelectionToolboxPosition.ts 0.00% 3 Missing ⚠️
src/composables/graph/useArrangeNodes.ts 25.00% 3 Missing ⚠️
src/renderer/core/canvas/canvasStore.ts 0.00% 3 Missing ⚠️
...erer/extensions/vueNodes/components/LGraphNode.vue 40.00% 3 Missing ⚠️
...er/core/canvas/litegraph/arrangeForLegacyRender.ts 91.66% 1 Missing ⚠️
...ons/vueNodes/composables/useSlotElementTracking.ts 87.50% 1 Missing ⚠️
... and 3 more
@@                   Coverage Diff                    @@
##             feature/ecs-migration   #14128   +/-   ##
========================================================
  Coverage                         ?   79.23%           
========================================================
  Files                            ?     1769           
  Lines                            ?   102922           
  Branches                         ?    33389           
========================================================
  Hits                             ?    81549           
  Misses                           ?    20903           
  Partials                         ?      470           
Flag Coverage Δ
unit 69.85% <76.73%> (?)

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

Files with missing lines Coverage Δ
src/lib/litegraph/src/LGraph.ts 78.56% <ø> (ø)
src/lib/litegraph/src/LGraphCanvas.ts 63.03% <ø> (ø)
src/lib/litegraph/src/LGraphGroup.ts 80.53% <ø> (ø)
src/lib/litegraph/src/LGraphNode.ts 65.18% <ø> (ø)
src/lib/litegraph/src/litegraph.ts 100.00% <ø> (ø)
...ib/litegraph/src/subgraph/subgraphDeduplication.ts 98.78% <100.00%> (ø)
.../core/layout/operations/graphLayoutRegistration.ts 100.00% <100.00%> (ø)
...renderer/core/layout/operations/layoutMutations.ts 90.40% <100.00%> (ø)
src/renderer/core/layout/store/layoutStore.ts 83.72% <100.00%> (ø)
src/renderer/core/layout/sync/useLayoutSync.ts 98.48% <100.00%> (ø)
... and 19 more
🚀 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 changed the title refactor: register node geometry at attach refactor: register node geometry at attach, delete useVueNodeLifecycle Jul 27, 2026
@DrJKL
DrJKL force-pushed the drjkl/layout-single-source branch from 783e1eb to 1cfc056 Compare July 27, 2026 23:55
@DrJKL
DrJKL force-pushed the drjkl/layout-registration-at-attach branch 2 times, most recently from 564572c to fdc25a2 Compare July 28, 2026 23:39
@DrJKL
DrJKL force-pushed the drjkl/layout-single-source branch 2 times, most recently from 6fdc295 to 19e2281 Compare July 29, 2026 00:40
@DrJKL
DrJKL force-pushed the drjkl/layout-registration-at-attach branch 2 times, most recently from 0bb1940 to 27e9108 Compare July 29, 2026 05:10
@DrJKL
DrJKL force-pushed the drjkl/layout-single-source branch from 19e2281 to 4352c66 Compare July 29, 2026 05:10
@DrJKL
DrJKL force-pushed the drjkl/layout-single-source branch from dbc2873 to 2999a25 Compare July 29, 2026 23:00
@DrJKL
DrJKL force-pushed the drjkl/layout-registration-at-attach branch 3 times, most recently from d9fdbd4 to 861ea25 Compare July 30, 2026 21:49
@DrJKL DrJKL removed the preview label Jul 30, 2026
@DrJKL
DrJKL force-pushed the drjkl/layout-registration-at-attach branch from 3fcda24 to 37b8bbd Compare July 31, 2026 18:16
DrJKL added a commit that referenced this pull request Jul 31, 2026
## Summary

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

## Changes

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

## Geometry before this PR

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

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

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

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

  nodeStore --> minimap[Minimap and spatial index]
  groupClass --> minimap
  rerouteLayout --> hitTest[Hit testing]
```

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

## Geometry with this PR

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

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

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

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

  commands --> history[Undo and redo]
  workflow[Workflow data] --> clipboard[Clipboard items]
  clipboard --> liveGraph[Open workflow]
  subgraphs[Subgraph mapping and ID deduplication] --> commands
```

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

## Downstream stack

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

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

## Review Focus

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

<details>
<summary>Findings that a dumb agent might call out</summary>

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

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

</details>

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Base automatically changed from drjkl/layout-single-source to feature/ecs-migration July 31, 2026 20:49
DrJKL added 6 commits July 31, 2026 13:57
Nodes were the only positionable whose layout entry was created by the
renderer: groups register in `LGraph.add`, reroutes in their constructor,
while nodes went through `useVueNodeLifecycle` listening to node:added and
node:removed. That indirection is why entries could outlive the graph that
made them, which is what both of yesterday's ownership attempts were trying
to paper over. Registering at attach makes the entry's lifetime the node's.

`initializeFromLiteGraph` did two jobs under one name. The seeding half is
gone; the other half — dropping slot, link and reroute geometry when the
viewed graph changes — is now `clearViewGeometry`, which is what
`useVueNodeLifecycle` calls. `reset` covers full teardown for tests.

zIndex was seeded two ways that disagreed: `initializeFromLiteGraph` used the
node's index in `_nodes`, the per-node path used `node.order`. `node.order` is
execution order from `computeExecutionOrder` and has nothing to do with
stacking, so the draw index wins.

The composable no longer owns node lifetime — only the sync lifecycle and
mode-switch cleanup. `setupEmptyGraphListener` existed solely to defer seeding
until a first node existed, so it goes too.

Three tests asserted the policy this reverses (no layout while the renderer is
off; seeding stops on dispose; adds to unviewed graphs ignored). They pinned
the old design rather than any behaviour worth keeping, so they are deleted;
the one contract still worth holding — add creates an entry, remove drops it —
moves next to LGraph, along with a test that zIndex follows draw order.

layoutStore now holds every node in the workflow rather than just the viewed
graph. Only tests call `queryNodeAtPoint` / `getNodesInBounds`, and both
`getAllNodes` callers only take a max zIndex, so nothing reads across the
wider set. The cost this adds to legacy-mode dragging is dealt with next.
Every layout operation appended to a Y.Array that nothing ever read.
`getOperationsSince` and `getOperationsByActor` were not on the LayoutStore
interface and had no callers outside the one test that exercised the log
itself; both were marked as being for a future sync feature that no provider
exists for.

It was not free. The array is never trimmed, so per-operation cost grew with
session length. Measured on `moveNode` with an entry present: 197 us/op with
22k entries logged, 375 us/op at 40k. Without the log, 5.4 us/op and flat
(2.9 us/op after another 18k operations) — the growth disappears with it.

This is a live cost in Vue nodes mode today, on every drag frame and every
resize, and it is what made registering node geometry at attach look
unaffordable for the legacy canvas: dragging 100 selected nodes went from
10.8 ms/frame (65% of a 16.7ms frame) to 0.60 ms/frame (3.6%).

The store's test helper observed operations through the log; it spies on
applyOperation instead, which is what nodeSizeReflow.test.ts already did.
What was left after node registration moved to `LGraph.add` was two calls on
two transitions, wrapped in a shared composable with one consumer.

- The `clearAllSlotLayouts` watch was redundant entering Vue mode, since
  `clearViewGeometry` already drops slot layouts along with link and reroute
  geometry. It was only doing work on the way out, so dispose clears instead
  and the watch goes. This widens what mode-leave clears; legacy mode reads
  none of it and re-entry clears again.
- `isInitialized` guarded nothing: `startSync` opens with `stopSync()`, and
  `clearViewGeometry` is idempotent.
- `createSharedComposable` held no shared state once that flag was gone, and
  `GraphCanvas.vue` was the only caller.
- The `arrange()` pass is legacy-canvas preparation, not Vue node lifecycle —
  it computes slot positions before `drawConnections` can run without them. It
  moves to `arrangeForLegacyRender` next to the other litegraph canvas
  adapters, rather than becoming another method on LGraph.

The transitions were already driven from `GraphCanvas.vue`, which watches
`currentGraph` and `isInSubgraph`, so the remainder lands where it was being
called from.
`LGraph.clear()` hand-listed the group and reroute deletions instead of
routing through the paired remove helpers, so node geometry registered in
`add` was never reclaimed: every workflow load leaked its predecessor into
`ynodes`, inflating the max-zIndex scans that place pasted nodes. The same
gap dropped interior geometry from orphaned subgraph definitions.

Route every attach/detach through `graphLayoutRegistration`, and have bulk
teardown call `unregisterAllGraphLayout` beside `unregisterAllNodeStates`
rather than re-deriving what those helpers do. Deletes the hand-written
block, six copies of the `setSource` dance, and the seeding fixture that
diverged from it by omitting the source.

`unpackSubgraph` re-homes groups under their original ids, and layout keys
groups by root graph id, so its re-add now follows removal of the wrapper --
as reroute migration already did.
`initializeFromLiteGraph` and `useVueNodeLifecycle` no longer exist, and
the layout operation log is gone. Records what replaced them: geometry
registers at attach and unregisters at detach, with a matching sweep for
bulk teardown.
Rebase-time semantic conflict: the parent branch added this test against
`layoutStore.getOperationsSince`, which this branch removes. Spying on
`applyOperation` asserts the same thing.
for (let i = 0; i < newPositions.length; i++) {
setNodeZIndex(newPositions[i].nodeId, maxZIndex + i + 1)
for (const { nodeId } of newPositions) {
setNodeZIndex(rootGraphId, nodeId, layoutStore.allocateZIndex())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This loop is now redundant and double-burns the counter.

Every pasted/cloned node already went through graph.add → registerNodeLayout → allocateZIndex(), in paste order. Allocating a second zIndex here preserves relative order, so there is no visual bug — but it consumes 2 counter values per pasted node and re-dispatches a setNodeZIndex operation (plus a LayoutChange, plus a useLayoutSync flush) for every node in the paste.

On the base branch this loop was load-bearing: it scanned layoutStore.getAllNodes() for maxZIndex because add did not allocate. With attach-time registration it can just be deleted.

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.

Can you provide a user-observable or measured reproduction showing this redundant allocation causes harm?

The extra operation is present, but the visible contract is unchanged: pasted nodes remain above existing nodes, preserve relative order, and receive distinct z-indexes. Exact counter density is not user-visible, and the existing clone tests correctly pass. A large-paste benchmark, collaboration trace, or other concrete expected/actual result would help justify treating this as more than optional cleanup.

if (e.detail.active && graphId) {
const mutations = useLayoutMutations()
mutations.bringNodeToFront(e.detail.nodeId)
mutations.bringNodeToFront(graphId, e.detail.nodeId)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is the only bringNodeToFront call site that does not setSource(...) first — every other one goes through useNodeZIndex (useNodeZIndex.ts:34) or sets the source explicitly.

The resulting operation therefore inherits whatever layoutStore.currentSource was last set to by unrelated code. That is not cosmetic: useLayoutSync.scheduleFlush (useLayoutSync.ts:68-71) branches on change.source to pick microtask vs requestAnimationFrame flushing, and LGraphNode.vue's handleLayoutChange filters on Canvas/External. So ghost placement gets nondeterministic flush timing depending on what ran before it.

Pre-existing, but the PR is already touching this line.

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.

Could you provide a deterministic user sequence where the inherited source changes ghost-placement behavior?

The provenance mismatch is real, but the downstream sync flush writes position and size rather than z-index, and I have not reproduced incorrect stacking, placement, or interaction behavior. Please include the preceding action needed to establish the problematic source and the observable expected/actual result after ghost placement.

isMicrotaskQueued = false
if (!canvas?.graph || pendingNodeIds.size === 0) return

const rootGraphId = canvas.graph.rootGraph.id

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

useLayoutSync is the one consumer the graph-scoping refactor missed.

pendingNodeIds is still a bare Set&lt;NodeId&gt; (L20) and startSync's onChange handler (L105-112) discards change.operation.graphId — which this PR just added to OperationMeta precisely so changes carry their graph. The flush then resolves every queued id against canvas.graph.rootGraph.id, i.e. whatever graph is on screen when the rAF fires.

Today that is benign, because Subgraph.state is shared so ids are unique root-wide and there is only ever one LGraph instance. But it is now the single place in the layout system that assumes "all changes belong to the viewed graph", right after the PR made the store hold every graph in the workflow. Two concrete consequences:

  1. layoutStore.clearGraph(A) during a workflow load queues every node id of the outgoing graph. The flush then runs getNodeLayoutRef(B, id) for each — a no-op write, but it creates a permanent nodeRefs/nodeTriggers entry per id as a side effect (see my comment on getNodeLayoutRef).
  2. It silently unscopes an otherwise-scoped invariant, so the next thing that introduces a second live root graph (thumbnail renderer, preview pane, multi-tab) breaks here rather than at a type error.

Cheap fix: queue { graphId, nodeId } and drop entries whose graphId !== canvas.graph.rootGraph.id at flush.

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.

Can you provide a current single-root user reproduction for this assertion?

The comment notes that the behavior is benign today and identifies a future second-root design as the breaking condition. I have not found a supported thumbnail, preview-pane, or multi-root flow that reaches that condition, nor a workflow transition that produces incorrect visible geometry. An exact sequence and observable result would help distinguish a current regression from forward-looking architecture hardening.


await comfyPage.workflow.loadWorkflow('default')
await comfyPage.vueNodes.waitForNodes()
const [reloadedNodeId] = await comfyPage.vueNodes.getNodeIds()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This step does not exercise the case the PR flags as the dangerous one.

The PR body and the new docstring on deduplicateSubgraphNodeIds both call out that GraphCanvas.vue keys the node v-for on a bare NodeId, so ids present in both workflows are patched, never unmounted — which is why useNodeLayout captures rootGraphIdAtMount for cleanup.

But the two fixtures have disjoint root node ids:

  • subgraphs/basic-subgraph.json → [2]
  • default.json → [7, 6, 5, 3, 8, 9, 4]

So every component unmounts and remounts across this transition, and the patched-component path — where onNodeChange was wiped by clearViewGeometry() and never re-subscribed (LGraphNode.vue:473-483), and where the new graph's nodeRefs entry leaks — is never hit. The test passes by fixture construction, not by covering the risk.

Suggest a fixture whose root node ids overlap the first workflow's, so the patched case is actually asserted.

Two other gaps in this spec worth noting: it only mutates size, never pos (write-through of node.pos across transitions is untested), and it only ever takes the first node of each graph.

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.

Thanks for calling out the fixture-ID distinction. We tested the supported workflow-load and subgraph-navigation interactions, and the components are remounted on the reachable transitions we found; the existing subgraph layout synchronization spec also passes in this branch. We were not able to produce a surviving-component transition with stale position or size behavior through the UI.

Could you provide the exact user steps and a workflow pair that preserve the component while exposing an incorrect position or size? That would give us a user-observable contract to add to this Playwright spec. Without that sequence, changing the fixture only to exercise internal component reuse would test a theoretical implementation path rather than a demonstrated regression.

mutations.deleteReroute(rootGraphId, rerouteId)
}

for (const subgraph of graph._subgraphs.values()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This recursion is dead in practice, and no test executes it.

_subgraphs is a class field on LGraph (LGraph.ts:367), so a Subgraph gets its own map, while every write goes through get subgraphs() { return this.rootGraph._subgraphs } (LGraph.ts:583). So subgraph._subgraphs is always empty and this loop is a no-op whenever graph is a Subgraph. It happens to be correct anyway — the root's _subgraphs is a flat map of all definitions including nested ones, so one level is sufficient — but the code reads as if it were handling arbitrary nesting.

Worth a comment saying depth-1 is sufficient because the root map is flat, or dropping the recursion for an explicit graph.rootGraph === graph ? [...graph._subgraphs.values()] : [].

Test coverage for this whole function is thin:

  • LGraph.test.ts:1594 (drops every entry on clear/reconfigure) sets graph.id = createUuidv4(), so it takes the layoutStore.clearGraph branch at LGraph.ts:505 and never reaches this function.
  • LGraph.test.ts:1609 does reach it via LGraph.ts:1241, but on a flat subgraph with one node, no groups and no reroutes.
  • So this recursion, the group sweep (L40-42), the reroute sweep (L44-46) and the !graph.rootGraph guard (L36) are all uncovered.

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.

Good catch. I verified the ownership model: supported writes all land in the root graph's flat _subgraphs registry, so recursive calls on a Subgraph cannot discover another level. The root-level sweep still matters for individual teardown because it removes layouts owned by each definition.

8c7d3b1f43 replaces the misleading recursion with an explicit root-only pass over that flat registry. It also adds focused coverage showing that nested-definition node, group, and reroute layouts are removed; deleting the flat-registry pass makes that test fail.

// TODO: Finish typing configure()
if (!data) return
if (options.clearGraph) this.clear()
else unregisterAllGraphLayout(this)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two things about this hunk and the deletions further down the file.

1. ensureGlobalIdUniqueness is deleted with no mention in the PR description. It is a public method on LGraph, so it is reachable from extensions, and its six tests go with it. It had no in-repo caller, so mechanically the removal is fine — but the invariant it repaired (node ids unique across a root graph and its subgraph definitions) is now load-bearing for the new layout key: root and subgraph-interior nodes share one ${rootGraphId}:${nodeId} bucket, so a collision silently means one layout entry for two nodes. The PR body argues at length that collisions cannot happen via deduplicateSubgraphNodeIds and the shared state counter — I agree with that argument — but removing the last defensive repair in the same PR that makes the invariant load-bearing deserves to be called out in the description rather than discovered in the diff.

Related: this leaves patchLinkNodeIds duplicated-then-orphaned — the LGraph.ts copy goes away, the independent copy at LGraphCanvas.ts:8973 stays.

2. The keep_old branch this line adds is unreachable. git grep finds no caller passing keep_old = true anywhere in src/. It also has a latent inversion: a subgraph definition present in _subgraphs but absent from the incoming data gets unregistered here and never re-registered, i.e. missing entries rather than orphaned ones. Since nothing exercises it and nothing tests it, consider either deleting the branch or adding a test.

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.

Can you point to a supported first-party flow or a known extension that exercises either ensureGlobalIdUniqueness() or configure(..., true), together with reproduction steps for the resulting failure?

Repository-wide caller searches found no keep_old=true production path and no extension fixture using the removed method. Normal workflow loading still exercises deduplicateSubgraphNodeIds() and retains browser coverage for globally unique IDs. Without a concrete consumer, these currently look like hypothetical compatibility concerns rather than user-reachable regressions.

@benjcooley benjcooley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at 3081bc4. I read the surrounding systems rather than just the hunks — LGraph.add/remove/clear/configure, layoutStore's ref/trigger/listener maps, useLayoutSync, the six Vue composables that gained rootGraphId, and the deleted useVueNodeLifecycle — and traced the claims in the description against the code.

The direction is right and the description is unusually thorough. Most of the pre-emptive rebuttals hold up: I checked the LGraph.add Pinia claim, the litegraph→layout layering claim, the unpackSubgraph reordering (toSelect order really is unchanged — groups follow nodes in both revisions), the _subgraphs recursion, and the minimap data-source rationale, and none of those are valid findings. I also independently confirmed the id-collision argument: Subgraph.state proxies to the root's, _configureBase runs before any add, and LGraph.id is a shallowRef so canvasStore.rootGraphId genuinely does invalidate across a workflow reconfigure (I initially suspected it did not — it does, and the rootGraphIdAtMount reasoning is sound).

What follows is what survived that.

Blocking

1. The new key reintroduces an unbounded per-session leak — the same class of cost this PR deletes.
getNodeLayoutRef caches a customRef + trigger under ${rootGraphId}:${nodeId}. Previously the key was the bare NodeId, so those two maps were bounded by the set of distinct node ids ever seen and were reused across workflow loads. Now every workflow load starts a generation that can never be reused, and nothing reaps it: handleClearGraph sweeps only the three Yjs maps, clearViewGeometry deliberately preserves refs, handleDeleteNode explicitly declines. The only pruner is cleanupNodeRef, called from one place with the mount-time graph id.

The population path is not renderer-gated either: LGraphNode._positionUpdated / _sizeUpdated call getNodeLayoutRef on every pos/size write, and configure writes both for every node. So a legacy-canvas session — where no Vue node component ever mounts and cleanupNodeRef is therefore never called at all — accumulates two closures per node per workflow loaded, for the life of the page. And clearViewGeometry does nodeTriggers.forEach(t => t()), so the per-transition cost grows with the leak.

Given the PR's headline result is deleting an unbounded per-operation cost, this one should not ship alongside it. Details inline on layoutStore.ts:226 and useNodeLayout.ts:31.

2. "Draw order wins" only holds at add time; the reconciliation that used to fix it is deleted.
LGraphCanvas.bringToFront / sendToBack splice graph._nodes without touching the store, and bringToFront fires on every legacy node click (_processNodeClick) and every legacy widget click (DomWidget.vue:165). On feature/ecs-migration this self-healed, because initializeFromLiteGraph re-seeded zIndex: index from _nodes order on every renderer entry. This PR removes that and enterVueRendering does not replace it, so stacking established in legacy mode is now silently discarded on switch to Vue. The new tests assert counter monotonicity in add order, which is a weaker and different claim than the one in the description. Inline on graphLayoutRegistration.ts:18.

3. LGraphNode.vue:473-483 — one-shot subscription with a permanent silent failure.
If rootGraphId is falsy at mount the component never subscribes to onNodeChange again, so extension-driven node.setSize() stops updating it forever. Every other guarded site recovers on the next call; this one cannot. Compounded by clearViewGeometry() calling nodeChangeListeners.clear() on every subgraph navigation and renderer toggle — a component patched across that transition loses its listener and never re-subscribes.

Worth fixing before merge

4. useLayoutSync is the one consumer the graph-scoping refactor missed. pendingNodeIds is still a bare Set<NodeId> and the onChange handler discards change.operation.graphId — the field this PR added for exactly this. Benign today (one live LGraph, ids unique root-wide), but it unscopes an otherwise-scoped invariant and creates ref entries as a flush side effect. Inline.

5. ensureGlobalIdUniqueness deleted without a mention in the description. Public method on LGraph, six tests removed with it, no in-repo caller — mechanically fine. But the invariant it repaired is now load-bearing for the layout key (root and subgraph nodes share one bucket), so removing the last defensive repair in the same PR that makes the invariant structural should be stated, not discovered. Also orphans the duplicated patchLinkNodeIds in LGraphCanvas.ts:8973.

6. The custom-node audit should gate this, not follow it. ecs-migration-plan.md marks it "pending" — but this PR both removes five layoutStore query methods and changes the signature of every node method on layoutStore / useLayoutMutations. Any extension calling layoutStore.getNodeLayoutRef(id) or moveNode(id, pos) now silently writes to a "5:undefined"-shaped bucket rather than failing loudly. The unbranded UUID (utils/uuid.ts:2) is what makes that silent, while NodeId and the new GroupId are both branded — worth branding UUID (or a RootGraphId) so graph.id vs graph.rootGraph.id mix-ups are compile errors.

7. Redundant double zIndex allocation on paste (LGraphCanvas.ts:4378) and missing setSource on the ghost-placement bringNodeToFront (canvasStore.ts:183). Both inline.

Test coverage

Net line count is positive (+1132/-767 across specs), which hides some specific losses:

  • unregisterAllGraphLayout's subgraph recursion, its group sweep, its reroute sweep, and its !graph.rootGraph guard are executed by no test — LGraph.test.ts:1594 sets a real UUID so it takes the clearGraph branch instead, and :1609 uses a flat one-node subgraph.
  • subgraphLayoutSync.spec.ts's "after loading a second workflow" step uses fixtures with disjoint root node ids ([2] vs [7,6,5,3,8,9,4]), so every component remounts and the patched-component path — the one the PR itself identifies as risky — is never exercised. Inline.
  • arrangeForLegacyRender.test.ts asserts the positive case only as "does not throw"; it would pass against an empty body wrapped in try/catch. The collapsed-node test is real.
  • useNodeLayout.test.ts pins the weaker half: it does not assert cleanup was not also called with the second id, does not observe store state, and does not cover layout re-targeting while mounted — the actual reason for the rewrite.
  • No test covers allocateZIndex across clearGraph, or root-vs-subgraph id isolation at the layout-key level (the root-scoped node layouts suite only isolates across different root graphs).
  • Six litegraph canvas tests moved to the shared __mocks__/layoutStore.ts. That is a clean dedup versus their previous inline stubs, but allocateZIndex: () => 1 is a constant and getNodeLayoutRef: () => ({ value: null }) short-circuits every mutation guard, so vi.mock('...layoutStore') as a bare one-liner now hides substantially more than the explicit literals it replaced. Worth a comment in the mock.
  • resetForTests() ships on the production class.

Architectural note

Attach-time registration replaces one imperative sync point (node:added/node:removed) with several (add, remove, clear, configure's two branches, unpackSubgraph's reordered group loop, released-subgraph teardown), and most of the findings above are lifetime bugs at the seams between them — entries and refs that outlive or under-live the entity.

Worth considering reconcile instead of push: on graph change, diff the store's key set for the root graph against graph._nodes (plus subgraph definitions) and add/drop the difference. Node ids are unique root-wide and already the key, so it is a set difference over ids — cheap, and it makes teardown correct by construction rather than by every mutation path remembering to call the right unregister. It would also collapse clearGraph + unregisterAllGraphLayout + the configure branches into one path, and it naturally reaps nodeRefs/nodeTriggers (finding 1) since the reconcile pass already knows which keys are dead.

Not asking for that in this PR — but if the seams keep producing findings on #14133, it is the cheaper shape.

Nits

  • SpatialIndex.ts:1-6 docblock still says "efficient node queries"; nodes are no longer indexed. SpatialIndexManager<TId … = NodeId>'s default is now never exercised, leaving a vestigial NodeId import.
  • rootGraphIdAtMount is captured at setup, not mount.
  • The graph.onNodeAdded hook in LGraphCanvas.cloneZIndex.test.ts:149-151 ("Simulate Vue runtime: create layout entries when nodes are added") is now dead — production add calls registerNodeLayout after onNodeAdded, so the entry it writes is immediately overwritten. The comment misdescribes production behaviour.
  • graphLayoutRegistration.ts:49 — the recursion is depth-1-sufficient by accident of _subgraphs being flat on the root; worth saying so.

Requesting changes on 1-3. The rest are discussion.

@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.

Actionable comments posted: 4

Caution

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

⚠️ Outside diff range comments (3)
src/renderer/core/layout/operations/layoutMutations.test.ts (1)

14-29: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add per-test store reset.

GRAPH is shared across tests, and layoutStore is a module-level singleton. The beforeEach hook creates a new Pinia instance but does not call layoutStore.resetForTests(). Reset the store before recreating NODE_1 and NODE_2 to prevent test-order dependence.

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

In `@src/renderer/core/layout/operations/layoutMutations.test.ts` around lines 14
- 29, Reset the module-level layout store in beforeEach before recreating NODE_1
and NODE_2. Call layoutStore.resetForTests() after creating the testing Pinia
and before canvasLayoutMutations() performs the node setup, preserving isolated
state for every test despite the shared GRAPH identifier.
docs/adr/0003-crdt-based-layout-system.md (1)

141-150: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the stale operation-history statements.

The amendment says operation-history storage and pruning no longer apply. Lines
130 and 138 still list those items as a cost and mitigation. Remove or revise
those entries so the ADR has one consistent description.

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

In `@docs/adr/0003-crdt-based-layout-system.md` around lines 141 - 150, Update the
ADR’s earlier cost and mitigation sections to remove or revise the
operation-history storage and history-pruning statements referenced by the
amendment. Keep the remaining documented costs and mitigations intact, ensuring
the ADR consistently reflects that the Yjs operation log is no longer stored or
pruned.
src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts (1)

26-32: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Hoist ROOT_GRAPH_ID in useNodeZIndex.test.ts.

The canvasStore mock runs before the test module initializes its top-level ROOT_GRAPH_ID, which throws a TDZ ReferenceError during test collection. Define it with vi.hoisted and use a self-contained literal, as in useVueNodeResizeTracking.test.ts.

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

In `@src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts`
around lines 26 - 32, Hoist ROOT_GRAPH_ID in
src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts:15-18 with
vi.hoisted and initialize it from a self-contained literal, then use that
hoisted value in the canvasStore mock. The anchor site
src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts:26-32
requires no direct change; it is only cited as the consolidated comment
location.

Source: Learnings

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

Inline comments:
In `@browser_tests/tests/performance.spec.ts`:
- Around line 160-208: Update the setup in the “large graph legacy node drag”
test to set Comfy.VueNodes.Enabled to false before measuring, then wait for the
renderer transition to complete before starting the drag. Keep the existing
node-position setup and drag verification unchanged.

In `@src/renderer/core/canvas/litegraph/arrangeForLegacyRender.test.ts`:
- Around line 25-46: Update the tests in arrangeForLegacyRender.test.ts to spy
on node.arrange, clear the setup invocation before exercising
arrangeForLegacyRender, and assert it is called once for the normal node. In the
collapsed-node test, add the same spy setup and assert arrange is not called
while preserving the existing _widgetSlotsDirty assertion.

In `@src/renderer/core/layout/sync/useLayoutSync.test.ts`:
- Line 36: Update the getNodeLayoutRef mock in
src/renderer/core/layout/sync/useLayoutSync.test.ts:36-36 to key fixture layouts
by both root graph ID and node ID, and assert the lookup uses rootGraph.id.
Apply the same graph-scoped fixture key in
src/renderer/extensions/minimap/data/MinimapDataSource.test.ts:40-40, adding a
case with distinct root graph IDs that share the same node ID.

In `@src/renderer/extensions/vueNodes/layout/useNodeDrag.test.ts`:
- Around line 67-68: Add a Vitest case in the drag tests using the mocked
useCanvasStore with rootGraphId absent, then exercise startDrag, movement, and
snapping and assert that no layout mutation occurs. Keep the existing
ROOT_GRAPH_ID setup for other tests and verify the unavailable-root-graph path
remains mutation-free.

---

Outside diff comments:
In `@docs/adr/0003-crdt-based-layout-system.md`:
- Around line 141-150: Update the ADR’s earlier cost and mitigation sections to
remove or revise the operation-history storage and history-pruning statements
referenced by the amendment. Keep the remaining documented costs and mitigations
intact, ensuring the ADR consistently reflects that the Yjs operation log is no
longer stored or pruned.

In `@src/renderer/core/layout/operations/layoutMutations.test.ts`:
- Around line 14-29: Reset the module-level layout store in beforeEach before
recreating NODE_1 and NODE_2. Call layoutStore.resetForTests() after creating
the testing Pinia and before canvasLayoutMutations() performs the node setup,
preserving isolated state for every test despite the shared GRAPH identifier.

In `@src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts`:
- Around line 26-32: Hoist ROOT_GRAPH_ID in
src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts:15-18 with
vi.hoisted and initialize it from a self-contained literal, then use that
hoisted value in the canvasStore mock. The anchor site
src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts:26-32
requires no direct change; it is only cited as the consolidated comment
location.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b1a13328-3fe9-44a8-889d-05cc41a8ef9d

📥 Commits

Reviewing files that changed from the base of the PR and between a7ae9e8 and c7e51e5.

📒 Files selected for processing (48)
  • browser_tests/tests/performance.spec.ts
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts
  • browser_tests/tests/vueNodes/layout/rendererToggleGeometry.spec.ts
  • browser_tests/tests/vueNodes/layout/subgraphLayoutSync.spec.ts
  • docs/adr/0003-crdt-based-layout-system.md
  • docs/architecture/ecs-migration-plan.md
  • docs/architecture/node-data-store.md
  • src/components/graph/GraphCanvas.vue
  • src/composables/canvas/useSelectionToolboxPosition.ts
  • src/composables/graph/useArrangeNodes.ts
  • src/lib/litegraph/src/LGraph.test.ts
  • src/lib/litegraph/src/LGraph.ts
  • src/lib/litegraph/src/LGraphCanvas.cloneZIndex.test.ts
  • src/lib/litegraph/src/LGraphCanvas.ts
  • src/lib/litegraph/src/LGraphNode.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/lib/litegraph/src/subgraph/subgraphDeduplication.ts
  • src/renderer/core/canvas/canvasStore.ts
  • src/renderer/core/canvas/litegraph/arrangeForLegacyRender.test.ts
  • src/renderer/core/canvas/litegraph/arrangeForLegacyRender.ts
  • src/renderer/core/canvas/litegraph/slotCalculations.ts
  • src/renderer/core/layout/operations/graphLayoutRegistration.ts
  • src/renderer/core/layout/operations/layoutMutations.test.ts
  • src/renderer/core/layout/operations/layoutMutations.ts
  • src/renderer/core/layout/store/__mocks__/layoutStore.ts
  • src/renderer/core/layout/store/layoutStore.test.ts
  • src/renderer/core/layout/store/layoutStore.ts
  • src/renderer/core/layout/sync/useLayoutSync.test.ts
  • src/renderer/core/layout/sync/useLayoutSync.ts
  • src/renderer/core/layout/types.ts
  • src/renderer/extensions/minimap/data/LayoutStoreDataSource.ts
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts
  • src/renderer/extensions/vueNodes/components/LGraphNode.vue
  • src/renderer/extensions/vueNodes/composables/useNodeEventHandlers.test.ts
  • src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts
  • src/renderer/extensions/vueNodes/composables/useNodeZIndex.ts
  • src/renderer/extensions/vueNodes/composables/useSlotElementTracking.test.ts
  • src/renderer/extensions/vueNodes/composables/useSlotElementTracking.ts
  • src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.test.ts
  • src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.ts
  • src/renderer/extensions/vueNodes/interactions/resize/useNodeResize.test.ts
  • src/renderer/extensions/vueNodes/interactions/resize/useNodeResize.ts
  • src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts
  • src/renderer/extensions/vueNodes/layout/nodeSizeReflow.test.ts
  • src/renderer/extensions/vueNodes/layout/useNodeDrag.test.ts
  • src/renderer/extensions/vueNodes/layout/useNodeDrag.ts
  • src/renderer/extensions/vueNodes/layout/useNodeLayout.test.ts
  • src/renderer/extensions/vueNodes/layout/useNodeLayout.ts

Comment thread browser_tests/tests/performance.spec.ts Resolved
Comment on lines +25 to +46
it('arranges nodes after Vue rendering clears the legacy draw gate', () => {
const graph = new LGraph()
const node = addedNode(graph)

LiteGraph.vueNodesMode = true
node.arrange()

expect(node._widgetSlotsDirty).toBe(false)

LiteGraph.vueNodesMode = false
expect(() => arrangeForLegacyRender(graph)).not.toThrow()
})

it('leaves collapsed nodes alone', () => {
const graph = new LGraph()
const node = addedNode(graph)
node.flags.collapsed = true
node._widgetSlotsDirty = true

arrangeForLegacyRender(graph)

expect(node._widgetSlotsDirty).toBe(true)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the arrangement behavior.

The first test passes if arrangeForLegacyRender does not call
node.arrange(). Spy on node.arrange, clear the setup call, then assert one
call for the normal node and zero calls for the collapsed node.

As per coding guidelines, write Vitest tests for behavior changes.

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

In `@src/renderer/core/canvas/litegraph/arrangeForLegacyRender.test.ts` around
lines 25 - 46, Update the tests in arrangeForLegacyRender.test.ts to spy on
node.arrange, clear the setup invocation before exercising
arrangeForLegacyRender, and assert it is called once for the normal node. In the
collapsed-node test, add the same spy setup and assert arrange is not called
while preserving the existing _widgetSlotsDirty assertion.

Source: Coding guidelines

}
),
getNodeLayoutRef: vi.fn((nodeId: string) => ({
getNodeLayoutRef: vi.fn((_rootGraphId: string, nodeId: string) => ({

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Test the root-graph lookup contract.

Both mocks discard the root graph ID. The tests can pass when a consumer uses an incorrect graph ID for a node layout lookup.

  • src/renderer/core/layout/sync/useLayoutSync.test.ts#L36-L36: Key fixture layouts by root graph ID and node ID. Assert the lookup uses rootGraph.id.
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts#L40-L40: Use the same graph-scoped fixture key. Add a distinct-root-graph case with the same node ID.

As per coding guidelines, “Write Vitest unit/component tests for behavior changes, especially bug fixes.”

📍 Affects 2 files
  • src/renderer/core/layout/sync/useLayoutSync.test.ts#L36-L36 (this comment)
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts#L40-L40
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/renderer/core/layout/sync/useLayoutSync.test.ts` at line 36, Update the
getNodeLayoutRef mock in
src/renderer/core/layout/sync/useLayoutSync.test.ts:36-36 to key fixture layouts
by both root graph ID and node ID, and assert the lookup uses rootGraph.id.
Apply the same graph-scoped fixture key in
src/renderer/extensions/minimap/data/MinimapDataSource.test.ts:40-40, adding a
case with distinct root graph IDs that share the same node ID.

Source: Coding guidelines

@DrJKL DrJKL left a comment

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.

One review-body finding does not have an inline thread to answer, so I am recording the disposition here.

CodeRabbit came riding in hard on a supposed ROOT_GRAPH_ID temporal-dead-zone failure in useNodeZIndex.test.ts. I appreciate a keen young buck checking whether the cinch is tight, but this particular horse never threw its rider:

That makes this finding unsupported, so no hoisting change is warranted. Thanks for scouting the ravine; this time the bridge is sound.

@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.

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (2)
src/lib/litegraph/src/LGraph.ts (2)

1080-1088: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Publish add notifications after layout registration.

Group add calls change() before registerGroupLayout. Node add dispatches node:added before registerNodeLayout. Consumers can observe an attached item without layout state. If a node callback removes the node, remove() deletes the layout and the delayed registration creates a stale entry. Register layout before public notifications, or guard and reconcile registration after callbacks. Add tests for synchronous read and remove callbacks.

Also applies to: 1149-1151

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

In `@src/lib/litegraph/src/LGraph.ts` around lines 1080 - 1088, Update the
group-add flow around registerGroupLayout and the public notifications so layout
registration completes before change() exposes the attached group; apply the
same ordering fix to node additions around registerNodeLayout and node:added.
Ensure synchronous callbacks can read layout state and that removal during
callbacks cannot leave a stale layout entry, then add coverage for both read and
remove callback cases.

505-512: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Run removal callbacks before deleting layout state.

Both layoutStore.clearGraph(graphId) and unregisterAllGraphLayout(this) run before fireNodeRemovalLifecycle. onRemoved remains an extension-facing callback, so it can read or synchronize layout while node.graph is still attached. This differs from remove(), which calls onRemoved before deleting node layout. Move layout cleanup after lifecycle callbacks and add regression coverage for clear().

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

In `@src/lib/litegraph/src/LGraph.ts` around lines 505 - 512, Reorder graph
removal so node removal lifecycle callbacks run before layout cleanup: move
`layoutStore.clearGraph(graphId)` and `unregisterAllGraphLayout(this)` to after
`fireNodeRemovalLifecycle`, while preserving the other topology, reroute, and
node-state cleanup behavior. Add regression coverage for `clear()` verifying
`onRemoved` can access or synchronize layout while `node.graph` remains
attached.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@browser_tests/tests/vueNodes/layout/rendererToggleGeometry.spec.ts`:
- Around line 193-205: Update the z-index assertion in
rendererToggleGeometry.spec.ts so KSampler is verified as frontmost among all
rendered nodes, not only against CLIP Text Encode. Use the rendered-node
collection to compare KSampler’s z-index with every other node or assert it has
the unique maximum, preserving the polling behavior during the Vue transition.

In `@src/lib/litegraph/src/LGraphCanvas.ts`:
- Around line 5012-5013: Update sendToBack to call
canvasLayoutMutations().sendNodeToBack (or the corresponding root-graph layout
mutation) with graph.rootGraph.id and node.id before graph._nodes.unshift(node),
matching bringNodeToFront’s layout synchronization. Extend the renderer-order
test to verify both the layout mutation and legacy node ordering.

In `@src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts`:
- Around line 236-244: Add an afterEach teardown in the test suite containing
ensureCorrectLayoutScale to call vi.restoreAllMocks() and
layoutStore.resetForTests(). Keep the existing test setup unchanged while
ensuring the applyOperation spy is restored and singleton layout state is reset
after every test.

---

Outside diff comments:
In `@src/lib/litegraph/src/LGraph.ts`:
- Around line 1080-1088: Update the group-add flow around registerGroupLayout
and the public notifications so layout registration completes before change()
exposes the attached group; apply the same ordering fix to node additions around
registerNodeLayout and node:added. Ensure synchronous callbacks can read layout
state and that removal during callbacks cannot leave a stale layout entry, then
add coverage for both read and remove callback cases.
- Around line 505-512: Reorder graph removal so node removal lifecycle callbacks
run before layout cleanup: move `layoutStore.clearGraph(graphId)` and
`unregisterAllGraphLayout(this)` to after `fireNodeRemovalLifecycle`, while
preserving the other topology, reroute, and node-state cleanup behavior. Add
regression coverage for `clear()` verifying `onRemoved` can access or
synchronize layout while `node.graph` remains attached.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c2005be6-ace1-4b41-b075-7d81b6482df1

📥 Commits

Reviewing files that changed from the base of the PR and between c7e51e5 and 8c3e1f7.

📒 Files selected for processing (4)
  • browser_tests/tests/vueNodes/layout/rendererToggleGeometry.spec.ts
  • src/lib/litegraph/src/LGraph.ts
  • src/lib/litegraph/src/LGraphCanvas.ts
  • src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts

Comment on lines +193 to +205
const ksamplerNode = comfyPage.vueNodes.getNodeByTitle('KSampler')
const clipNode = comfyPage.vueNodes.getNodeByTitle('CLIP Text Encode')
await expect
.poll(async () => {
const ksamplerZIndex = await ksamplerNode.evaluate((node) =>
Number(getComputedStyle(node).zIndex)
)
const clipZIndex = await clipNode.evaluate((node) =>
Number(getComputedStyle(node).zIndex)
)
return ksamplerZIndex - clipZIndex
})
.toBeGreaterThan(0)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert frontmost order against all rendered nodes.

The test compares KSampler only with CLIP. The workflow has a third node. KSampler can remain below that node after the Vue transition while this assertion passes. Compare KSampler’s z-index with every other rendered node, or assert that it has the unique maximum z-index.

As per path instructions, test behavior must cover relevant edge cases and use behavioral assertions.

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

In `@browser_tests/tests/vueNodes/layout/rendererToggleGeometry.spec.ts` around
lines 193 - 205, Update the z-index assertion in rendererToggleGeometry.spec.ts
so KSampler is verified as frontmost among all rendered nodes, not only against
CLIP Text Encode. Use the rendered-node collection to compare KSampler’s z-index
with every other node or assert it has the unique maximum, preserving the
polling behavior during the Vue transition.

Source: Path instructions

Comment thread src/lib/litegraph/src/LGraphCanvas.ts Resolved
Comment on lines +236 to +244
group.graph = graph
layoutMutations.createGroup(graph.id, toGroupId(810), {
position: { x: 150, y: 150 },
size: { width: 300, height: 200 }
})
graph.groups!.push(group)

const applyOperation = vi.spyOn(layoutStore, 'applyOperation')
ensureCorrectLayoutScale(undefined, graph as LGraph)
ensureCorrectLayoutScale(undefined, graph)

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n 'clearAllMocks|restoreAllMocks|resetForTests|clearGraph' \
  src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts \
  src/renderer/core/layout/store/layoutStore.ts

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 580


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- test structure ---'
sed -n '1,285p' src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts

printf '%s\n' '--- layout store reset implementation ---'
sed -n '870,935p' src/renderer/core/layout/store/layoutStore.ts

printf '%s\n' '--- layout store imports and reset-related symbols ---'
rg -n 'layoutStore|resetForTests|clearAllMocks|afterEach|beforeEach|applyOperation' \
  src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts \
  src/renderer/core/layout/store/layoutStore.ts

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 12743


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- remaining test hooks and state-using tests ---'
sed -n '280,620p' src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts

printf '%s\n' '--- layout mutation implementation ---'
ast-grep outline src/renderer/core/layout/operations/layoutMutations.ts
rg -n -A35 -B10 'createGroup|useLayoutMutations' \
  src/renderer/core/layout/operations/layoutMutations.ts \
  src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.ts

printf '%s\n' '--- deterministic source checks ---'
python3 - <<'PY'
from pathlib import Path
test = Path('src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts').read_text()
store = Path('src/renderer/core/layout/store/layoutStore.ts').read_text()

assert 'vi.clearAllMocks()' in test
assert 'vi.restoreAllMocks()' not in test
assert 'layoutStore.resetForTests()' not in test
assert 'const applyOperation = vi.spyOn(layoutStore, \\'applyOperation\\')' in test

reset = store[store.index('resetForTests(): void'):store.index('clearViewGeometry(): void')]
for symbol in ('ynodes.clear()', 'ygroups.clear()', 'yreroutes.clear()', 'rerouteLayouts.clear()', 'rerouteSpatialIndex.clear()', 'clearViewGeometry()'):
    assert symbol in reset, symbol

print('The test clears mock history only, installs a persistent spy, and has no teardown.')
print('resetForTests clears entity/layout collections and view geometry.')
PY

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 12832


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path

test = Path(
    'src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts'
).read_text()
mutations = Path(
    'src/renderer/core/layout/operations/layoutMutations.ts'
).read_text()
store = Path(
    'src/renderer/core/layout/store/layoutStore.ts'
).read_text()

assert 'vi.clearAllMocks()' in test
assert 'vi.restoreAllMocks()' not in test
assert 'layoutStore.resetForTests()' not in test
assert "vi.spyOn(layoutStore, 'applyOperation')" in test

create_group = mutations[
    mutations.index('const createGroup = '):
    mutations.index('const setGroupBounds = ')
]
assert "layoutStore.applyOperation({" in create_group
assert "type: 'createGroup'" in create_group

reset = store[
    store.index('resetForTests(): void'):
    store.index('clearViewGeometry(): void')
]
for symbol in (
    'ynodes.clear()',
    'ygroups.clear()',
    'yreroutes.clear()',
    'rerouteLayouts.clear()',
    'rerouteSpatialIndex.clear()',
    'clearViewGeometry()',
):
    assert symbol in reset, symbol

print('The test clears mock history but does not restore spies.')
print('The group setup mutates the singleton layoutStore.')
print('The available resetForTests API clears layout collections and view geometry.')
PY

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 349


Reset layout state and restore mocks after each test.

vi.clearAllMocks() only clears call history. It does not restore the layoutStore.applyOperation spy. The group setup also mutates the singleton layoutStore. Add afterEach teardown with vi.restoreAllMocks() and layoutStore.resetForTests().

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

In `@src/renderer/extensions/vueNodes/layout/ensureCorrectLayoutScale.test.ts`
around lines 236 - 244, Add an afterEach teardown in the test suite containing
ensureCorrectLayoutScale to call vi.restoreAllMocks() and
layoutStore.resetForTests(). Keep the existing test setup unchanged while
ensuring the applyOperation spy is restored and singleton layout state is reset
after every test.

Source: Path instructions


const beforeSlots = slotsOf(before)
const afterSlots = slotsOf(after)
expect(afterSlots, 'slot count after drag').toHaveLength(beforeSlots.length)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm reminded of the toBeCloseToArray custom matcher I tried to get in.

Comment on lines +13 to +16
.evaluate((element) => [
element instanceof HTMLElement ? element.offsetWidth : 0,
element instanceof HTMLElement ? element.offsetHeight : 0
])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You yell at me for ⛳ and then do this?

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.

🤷🏼

Comment thread browser_tests/tests/performance.spec.ts Resolved
typeof useLayoutMutations
>)
mockedUseLayoutMutations.mockReturnValue(
fromPartial<ReturnType<typeof useLayoutMutations>>({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
fromPartial<ReturnType<typeof useLayoutMutations>>({
fromPartial({

Delete all of these.

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 all four occurrences in 4b3f9b283e. mockReturnValue() supplies the contextual return type, so the explicit ReturnType<typeof useLayoutMutations> arguments were redundant. A scan of the rest of this PR found no other contextually typed fromPartial<T>() calls that can be simplified the same way.

@AustinMroz AustinMroz removed their assignment Aug 5, 2026
@DrJKL
DrJKL requested a review from benjcooley August 5, 2026 19:50
@DrJKL
DrJKL merged commit c7b84f4 into feature/ecs-migration Aug 5, 2026
58 checks passed
@DrJKL
DrJKL deleted the drjkl/layout-registration-at-attach branch August 5, 2026 20:26
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>
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.

4 participants