Skip to content

feat(agent): drive tab switching through the activation coordinator - #18326

Closed
claude[bot] wants to merge 8 commits into
feat/graph-document-activation-seamfrom
agent/tab-switch-activation-hooks
Closed

claude[bot] wants to merge 8 commits into
feat/graph-document-activation-seamfrom
agent/tab-switch-activation-hooks

Conversation

@claude

@claude claude Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Christian Byrne · Slack thread

Stacked on #16375 (base: feat/graph-document-activation-seam). Implements its follow-up 3, "host-side wiring: activation coordinator driving the real canvas binding (replacing tab-switch ad hoc logic)".

This is an architecture demonstration, opened as a draft so the design can be argued about before it is hardened. See Tradeoffs.

Summary

Before. The app keeps one root LGraph and reconfigures it in place on every workflow load, so "which graph is the canvas showing" is a moving target with no owner. Each consumer re-derives it, and the derivations disagree during a switch. Nothing tells the mint path that a handoff is in progress, so a layout createNode queued for the incoming tab can drain on a later microtask and mint an add_node into the previous tab's document. #16375 added a coordinator that models the handoff correctly but left it unwired: nothing ever called activate() or deactivate().

After. The load path drives the coordinator, and the coordinator publishes exactly one answer that everyone reads.

  • beforeLoadNewGraph retracts the outgoing document's canvas binding, synchronously, before anything touches the shared graph.
  • afterLoadNewGraph activates the incoming document, at the first point where the workflow taking the canvas is actually known.
  • layoutMintPort asks the activation host which root graph is activated, and drops any root-scoped createNode/deleteNode/clearGraph naming a different graph (agent_crdt_op_for_inactive_document).
  • app.clean() (Clear Workflow) republishes the activated binding on the reminted root id, since LGraph.clear() remints it in place and reaches no load path.

The wrong-document mint stops being a race to win and becomes unrepresentable: an op can only mint into the document whose root graph it names, and during the handoff no document is activated at all, so nothing mints.

Design

src/core/graph/document/documentActivationHost.ts — the seam. Wraps #16375's generation-raced createActivationCoordinator with the canvas-side DocumentViewBinding: attach publishes the {documentId, rootGraphId} pair, detach retracts it. Publishing lives in the binding, so the coordinator's existing ordering guarantees (ordered detach → attach → publish, stale requests can never publish) carry over unchanged rather than being reimplemented.

deactivate() retracts the in-flight request as well as the published binding. Without that, a load starting while a previous activate is still mid-handoff would let that activation publish a graph the canvas had already moved past — the exact window the seam exists to close.

src/stores/documentActivationStore.ts — app-wide singleton over the registry. isLoaded is the registry's phase check; commitScope hydrates (or rebinds) the document's ECS scope, and is called only after the coordinator's handoff actually wins (activated), so a rejected or superseded request never stamps a graph id the winner already owns.

workflowService drives the seam; app.ts carries one rebind for Clear Workflow. The first draft hooked loadGraphData directly, which meant three copy-pasted call-site pairs, since loadApiJson and importA1111 also reconfigure the shared graph without going through loadGraphData. beforeLoadNewGraph/afterLoadNewGraph is the funnel all three already share and is already where changeTracker.deactivate() lives, so activation rides the workflow lifecycle. Clear Workflow is the one graph swap that reaches no load path — LGraph.clear() remints the root id in place — so app.clean() calls documentActivationStore.rebindActiveScope() to republish the same document on the new id; everything else in app.ts is untouched.

Scope from the live root graph. activateLoadedDocument reads app.rootGraph.id, not the workflow's serialized activeState.id, because the live graph's id is what every layout change's graphId carries — comparing against anything else reintroduces a derivation that can disagree.

Registry scope now learned at activation. The host is the first caller that knows the root graph id, so hydrateDocument/rebindScope happens at bind time instead of lazily on the document's first agent write.

Compared with #18109

#18109 fixes the same bug from the other end: AgentPanelRoot re-derives boundRootGraphId() from the bound workflow's activeState.id and threads it down to the mint port. It works, and it is much smaller, but it is a second derivation of a fact nobody owns — hence its care about computed vs plain accessor, markRaw'd change trackers, and stale latching. Here the fact has one owner and changes exactly once per handoff, so the consumer reads rather than derives.

Two consequences worth arguing about:

#18109 has since merged and is integrated into this branch. mintedNodeIdsByRoot/mintedNodeIdsForRoot in layoutMintPort.ts now key the dedupe set on operation.graphId instead of re-deriving boundRootGraphId — a genuine improvement over main's version, not just a transcription: by the time a create reaches the bucket lookup, isForActivatedDocument has already established that the key names the activated document, so the ambiguous "activation unresolved" case main had to special-case can't arise.

Tradeoffs and what is deliberately not hardened

  • isDocBound still compares tab paths. AgentPanelRoot's isBoundWorkflowActive is the other ad-hoc derivation, and the coordinator could answer it (boundTab.documentId === activeDocumentId()). Left alone here because it also drives the CRDT follower's subscribe/suspend trigger, so moving it changes follower behaviour and deserves its own PR. The scope check closes the bug without it.
  • Concurrent direct loadGraphData calls are not serialized here. Normal openWorkflow() calls are serialized, so this does not defeat the common tab-switch path, but some direct app.loadGraphData() callers remain outside that queue; real serialization belongs in the load path.
  • A failed load leaves nothing activated until the next load. Fail-safe, and it matches the existing mint-session bracket behaviour, but it is a degraded state with no recovery path of its own.
  • src/stores/ is a frozen directory and the pre-commit warning fires for documentActivationStore.ts. Same placement rationale feat(agent): add GraphDocument registry and activation seam #16375 used for graphDocumentStore.ts: it is a sibling of the registry it wraps.
  • Duplicate serialized root IDs remain a broader, pre-existing identity gap. Save As and in-app duplicate both remint IDs, so an externally copied workflow file colliding on id is the residual case, and it is a systemic load-time identity issue the existing ECS stores already key around — this PR intentionally does not grow a local activation-generation protocol to paper over it.
  • Targeting policy (comparing activation state, once-per-tick reporting) is now independently implemented in the layout, link, and widget mint ports. Coherent today, but the next targeting change has to land three times; a shared predicate/reporter at the wiring seam would be a good follow-up.
  • beforeLoadNewGraph/afterLoadNewGraph also fire on undo and redo, not just tab switches (ChangeTracker.updateState reaches them with suppressWorkflowReset = false), so an undo retracts and republishes the activation binding even though the same document owns the canvas before and after. In that window activeRootGraphId() is null and root-scoped ops are dropped fail-closed — correct for a tab switch, but an undo drops rather than applies an in-flight op during that window. The round trip itself is covered (workflowService.test.ts, "republishes the same document and root graph id across an undo/redo round trip"), but the in-window drop is not fixed here: ADR-GRAPH-DOCUMENT-0026 Phase 1 calls out this exact hook pair as needing to gate on document-identity change rather than on graph load, and that belongs with the phase that builds the identity/lifecycle bus, not with this PR's retrofit onto the existing hooks.

Tests

  • src/core/graph/document/documentActivationHost.test.ts (17) — publish/retract, the switch handoff, the empty mid-reconfigure window, graph-id rotation in place, refusing an unloaded document, in-flight cancellation, and rapid switching settling on the last request rather than the last to resolve.
  • src/renderer/core/layout/store/tabSwitchActivation.test.ts (8) — the real layout store through the real mint wiring, targeted by the real host and registry: a change draining after a switch reaches no document, a stale change for the previous graph is dropped once the new tab is active, rapid switching leaves one tab holding the canvas, and each tab's scope is learned from its activation.
  • src/workbench/extensions/agent/crdt/layoutMintPort.test.ts (50) — foreign-graph drops for all three root-scoped op types, once-per-tick reporting, recovery when the other graph becomes activated, the fail-closed unactivated case, the fix(agent-crdt): scope layout mint ops to the bound document's root graph #18109 dedupe regressions (root-graph replay, dropped-delete, interior-delete), and the disabled-delete/unbound-doc double-mint regressions for the dedupe-forget invariant.
  • src/workbench/extensions/agent/crdt/linkMintPort.test.ts (15) — foreign-severance capture, the once-per-tick coalescer's burst/reset behavior, and the fix that keeps a foreign, non-mintable severance out of removed_links.
  • src/platform/workflow/core/services/workflowService.test.ts — includes an undo/redo round-trip regression: beforeLoadNewGraph/afterLoadNewGraph also fire on undo/redo, and the same {documentId, rootGraphId} is republished at the end of the round trip (see the known-limitation note above on the in-window drop).

Verification

  • pnpm vitest run on the directly affected suites (documentActivationHost, tabSwitchActivation, layoutStoreMintDelivery, layoutMintPort, linkMintPort, workflowService) — all passing at the current head.
  • pnpm typecheck, pnpm lint (0 errors), pnpm knip, pnpm format — clean at the current head.
  • CI (typecheck, lint, unit, E2E, matrix) is green on this SHA.

🤖 Generated with Claude Code

https://claude.ai/code/session_01U73XrPUkU81hiq71XZY4mr

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
billing-web-test Error Error Sep 25, 2026 3:44am UTC
1 Skipped Deployment
Project Deployment Actions Updated
billing-web Ignored Ignored Sep 25, 2026 3:44am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: eec83837-9d2d-4410-ab10-1383eb96b2d1

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

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

Wires the GraphDocument activation seam into the real workflow load path,
so op targeting reads the activated document instead of re-deriving which
graph is bound.

The app reuses one root LGraph across tabs and reconfigures it in place, so
"the graph the canvas holds" is a moving target. Consumers that re-derive it
can lag the reconfigure, and a layout change draining on a later microtask
then mints into the previous tab's document.

- documentActivationHost: the coordinator plus the canvas DocumentViewBinding,
  publishing one activated {document, root graph} pair. Deactivate retracts
  an in-flight activation as well as the published one.
- documentActivationStore: app-wide singleton over the document registry.
- workflowService drives it: beforeLoadNewGraph retracts, afterLoadNewGraph
  activates. That is the single funnel all three graph-load paths share
  (loadGraphData, loadApiJson, importA1111).
- layoutMintPort drops a root-scoped createNode/deleteNode/clearGraph that
  names a graph the activated document does not own, reporting
  agent_crdt_op_for_inactive_document. It fails closed while nothing is
  activated, which is exactly the handoff window.
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright: ✅ 1944 passed, 0 failed · 1 flaky

📊 Browser Reports
  • chromium: View Report (✅ 1923 / ❌ 0 / ⚠️ 1 / ⏭️ 13)
  • 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)

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 09/25/2026, 04:11:51 AM UTC

Links

📦 Bundle Size

⏳ Size data collection in progress…

⚡ Performance Report

canvas-idle: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 68.5 MB heap
canvas-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 65.8 MB heap
canvas-zoom-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 60.5 MB heap
dom-widget-clipping: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 76.5 MB heap
large-graph-idle: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 78.8 MB heap
large-graph-pan: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 71.6 MB heap
large-graph-zoom: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 70.7 MB heap
legacy-node-drag: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 82.7 MB heap
minimap-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 79.4 MB heap
subgraph-dom-widget-clipping: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 73.2 MB heap
subgraph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 70.0 MB heap
subgraph-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 65.9 MB heap
subgraph-transition-enter: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 155ms TBT · 95.8 MB heap
viewport-pan-sweep: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 64.5 MB heap
vue-large-graph-idle: · 56.2 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 156.3 MB heap
vue-large-graph-pan: · 56.3 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 37ms TBT · 156.6 MB heap
vue-node-resize-workload: · 56.3 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 268ms TBT · 186.1 MB heap
vue-zoom-out-idle: · 56.2 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 176.9 MB heap
workflow-execution: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 63.5 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 7
canvas-idle: task duration 491ms
canvas-idle: script duration 13ms
canvas-idle: TBT 0ms
canvas-idle: heap used 68.5 MB
canvas-idle: DOM nodes -264
canvas-idle: event listeners -155
canvas-mouse-sweep: avg frame time 17ms
canvas-mouse-sweep: p95 frame time 17ms
canvas-mouse-sweep: layout duration 5ms
canvas-mouse-sweep: style recalc duration 32ms
canvas-mouse-sweep: layout count 14
canvas-mouse-sweep: style recalc count 77
canvas-mouse-sweep: task duration 929ms
canvas-mouse-sweep: script duration 174ms
canvas-mouse-sweep: TBT 0ms
canvas-mouse-sweep: heap used 65.8 MB
canvas-mouse-sweep: DOM nodes -263
canvas-mouse-sweep: event listeners -169
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 378ms
canvas-zoom-sweep: script duration 15ms
canvas-zoom-sweep: TBT 0ms
canvas-zoom-sweep: heap used 60.5 MB
canvas-zoom-sweep: DOM nodes 75
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 477ms
dom-widget-clipping: script duration 171ms
dom-widget-clipping: TBT 0ms
dom-widget-clipping: heap used 76.5 MB
dom-widget-clipping: DOM nodes 18
dom-widget-clipping: event listeners 1
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 4ms
large-graph-idle: layout count 0
large-graph-idle: style recalc count 4
large-graph-idle: task duration 554ms
large-graph-idle: script duration 39ms
large-graph-idle: TBT 0ms
large-graph-idle: heap used 78.8 MB
large-graph-idle: DOM nodes -252
large-graph-idle: event listeners -168
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 13ms
large-graph-pan: layout count 0
large-graph-pan: style recalc count 67
large-graph-pan: task duration 1805ms
large-graph-pan: script duration 897ms
large-graph-pan: TBT 0ms
large-graph-pan: heap used 71.6 MB
large-graph-pan: DOM nodes -242
large-graph-pan: event listeners -182
large-graph-zoom: avg frame time 17ms
large-graph-zoom: p95 frame time 17ms
large-graph-zoom: layout duration 13ms
large-graph-zoom: style recalc duration 10ms
large-graph-zoom: layout count 60
large-graph-zoom: style recalc count 60
large-graph-zoom: task duration 1778ms
large-graph-zoom: script duration 818ms
large-graph-zoom: TBT 0ms
large-graph-zoom: heap used 70.7 MB
large-graph-zoom: DOM nodes -264
large-graph-zoom: event listeners 10
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 5ms
legacy-node-drag: layout count 0
legacy-node-drag: style recalc count 40
legacy-node-drag: task duration 2005ms
legacy-node-drag: script duration 1009ms
legacy-node-drag: TBT 0ms
legacy-node-drag: heap used 82.7 MB
legacy-node-drag: DOM nodes 0
legacy-node-drag: event listeners 188
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 5
minimap-idle: task duration 630ms
minimap-idle: script duration 38ms
minimap-idle: TBT 0ms
minimap-idle: heap used 79.4 MB
minimap-idle: DOM nodes -252
minimap-idle: event listeners -167
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 11ms
subgraph-dom-widget-clipping: layout count 0
subgraph-dom-widget-clipping: style recalc count 46
subgraph-dom-widget-clipping: task duration 422ms
subgraph-dom-widget-clipping: script duration 149ms
subgraph-dom-widget-clipping: TBT 0ms
subgraph-dom-widget-clipping: heap used 73.2 MB
subgraph-dom-widget-clipping: DOM nodes 18
subgraph-dom-widget-clipping: event listeners 7
subgraph-idle: avg frame time 17ms
subgraph-idle: p95 frame time 17ms
subgraph-idle: layout duration 0ms
subgraph-idle: style recalc duration 10ms
subgraph-idle: layout count 0
subgraph-idle: style recalc count 10
subgraph-idle: task duration 509ms
subgraph-idle: script duration 11ms
subgraph-idle: TBT 0ms
subgraph-idle: heap used 70.0 MB
subgraph-idle: DOM nodes -277
subgraph-idle: event listeners -200
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 31ms
subgraph-mouse-sweep: layout count 18
subgraph-mouse-sweep: style recalc count 78
subgraph-mouse-sweep: task duration 858ms
subgraph-mouse-sweep: script duration 119ms
subgraph-mouse-sweep: TBT 0ms
subgraph-mouse-sweep: heap used 65.9 MB
subgraph-mouse-sweep: DOM nodes -276
subgraph-mouse-sweep: event listeners -217
subgraph-transition-enter: avg frame time 17ms
subgraph-transition-enter: p95 frame time 17ms
subgraph-transition-enter: layout duration 14ms
subgraph-transition-enter: style recalc duration 31ms
subgraph-transition-enter: layout count 5
subgraph-transition-enter: style recalc count 17
subgraph-transition-enter: task duration 995ms
subgraph-transition-enter: script duration 34ms
subgraph-transition-enter: TBT 155ms
subgraph-transition-enter: heap used 95.8 MB
subgraph-transition-enter: DOM nodes 13587
subgraph-transition-enter: event listeners 2385
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 248
viewport-pan-sweep: task duration 6259ms
viewport-pan-sweep: script duration 2943ms
viewport-pan-sweep: TBT 0ms
viewport-pan-sweep: heap used 64.5 MB
viewport-pan-sweep: DOM nodes -249
viewport-pan-sweep: event listeners -150
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 16965ms
vue-large-graph-idle: script duration 281ms
vue-large-graph-idle: TBT 0ms
vue-large-graph-idle: heap used 156.3 MB
vue-large-graph-idle: DOM nodes -6559
vue-large-graph-idle: event listeners -7479
vue-large-graph-pan: avg frame time 18ms
vue-large-graph-pan: p95 frame time 17ms
vue-large-graph-pan: layout duration 0ms
vue-large-graph-pan: style recalc duration 21ms
vue-large-graph-pan: layout count 0
vue-large-graph-pan: style recalc count 156
vue-large-graph-pan: task duration 21105ms
vue-large-graph-pan: script duration 939ms
vue-large-graph-pan: TBT 37ms
vue-large-graph-pan: heap used 156.6 MB
vue-large-graph-pan: DOM nodes -6542
vue-large-graph-pan: event listeners -7474
vue-node-resize-workload: avg frame time 18ms
vue-node-resize-workload: p95 frame time 17ms
vue-node-resize-workload: layout duration 24ms
vue-node-resize-workload: style recalc duration 81ms
vue-node-resize-workload: layout count 20
vue-node-resize-workload: style recalc count 20
vue-node-resize-workload: task duration 5518ms
vue-node-resize-workload: script duration 121ms
vue-node-resize-workload: TBT 268ms
vue-node-resize-workload: heap used 186.1 MB
vue-node-resize-workload: DOM nodes -6544
vue-node-resize-workload: event listeners -7478
vue-zoom-out-idle: avg frame time 18ms
vue-zoom-out-idle: p95 frame time 17ms
vue-zoom-out-idle: layout duration 0ms
vue-zoom-out-idle: style recalc duration 0ms
vue-zoom-out-idle: layout count 0
vue-zoom-out-idle: style recalc count 0
vue-zoom-out-idle: task duration 8519ms
vue-zoom-out-idle: script duration 135ms
vue-zoom-out-idle: TBT 0ms
vue-zoom-out-idle: heap used 176.9 MB
vue-zoom-out-idle: DOM nodes -1
vue-zoom-out-idle: event listeners -11
workflow-execution: avg frame time 17ms
workflow-execution: p95 frame time 17ms
workflow-execution: layout duration 2ms
workflow-execution: style recalc duration 25ms
workflow-execution: layout count 5
workflow-execution: style recalc count 18
workflow-execution: task duration 126ms
workflow-execution: script duration 12ms
workflow-execution: TBT 0ms
workflow-execution: heap used 63.5 MB
workflow-execution: DOM nodes 134
workflow-execution: event listeners 75
Raw data
{
  "timestamp": "2026-09-25T04:38:06.740Z",
  "gitSha": "daa5b57dfb8c77fec6dce3e1b9e10ab950ac82d5",
  "branch": "agent/tab-switch-activation-hooks",
  "measurements": [
    {
      "name": "canvas-idle",
      "durationMs": 2013.0620000000476,
      "styleRecalcs": 6,
      "styleRecalcDurationMs": 8.048000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 475.877,
      "heapDeltaBytes": 13385516,
      "heapUsedBytes": 75055048,
      "domNodes": -264,
      "jsHeapTotalBytes": 4448256,
      "scriptDurationMs": 13.330000000000002,
      "eventListeners": -156,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-idle",
      "durationMs": 2010.0029999999833,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 8.471999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 505.606,
      "heapDeltaBytes": 7617592,
      "heapUsedBytes": 68513336,
      "domNodes": -263,
      "jsHeapTotalBytes": 4710400,
      "scriptDurationMs": 11.908999999999999,
      "eventListeners": -154,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 1872.5529999999821,
      "styleRecalcs": 76,
      "styleRecalcDurationMs": 32.733,
      "layouts": 14,
      "layoutDurationMs": 4.441,
      "taskDurationMs": 934.4480000000001,
      "heapDeltaBytes": 11737132,
      "heapUsedBytes": 73304844,
      "domNodes": -263,
      "jsHeapTotalBytes": 5496832,
      "scriptDurationMs": 176.054,
      "eventListeners": -154,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 1905.6949999999233,
      "styleRecalcs": 77,
      "styleRecalcDurationMs": 32.11,
      "layouts": 14,
      "layoutDurationMs": 4.597,
      "taskDurationMs": 923.568,
      "heapDeltaBytes": 2496068,
      "heapUsedBytes": 64601344,
      "domNodes": -262,
      "jsHeapTotalBytes": 6545408,
      "scriptDurationMs": 172.68100000000004,
      "eventListeners": -184,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1738.868000000025,
      "styleRecalcs": 31,
      "styleRecalcDurationMs": 19.08,
      "layouts": 6,
      "layoutDurationMs": 1.162,
      "taskDurationMs": 386.77000000000004,
      "heapDeltaBytes": 2033548,
      "heapUsedBytes": 63464308,
      "domNodes": 76,
      "jsHeapTotalBytes": 4980736,
      "scriptDurationMs": 15.604,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1738.3050000000821,
      "styleRecalcs": 31,
      "styleRecalcDurationMs": 17.869,
      "layouts": 6,
      "layoutDurationMs": 1.19,
      "taskDurationMs": 369.285,
      "heapDeltaBytes": 2042884,
      "heapUsedBytes": 63348648,
      "domNodes": 74,
      "jsHeapTotalBytes": 4980736,
      "scriptDurationMs": 15.351999999999997,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 692.5509999999804,
      "styleRecalcs": 11,
      "styleRecalcDurationMs": 7.680999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 473.842,
      "heapDeltaBytes": 18076484,
      "heapUsedBytes": 80204760,
      "domNodes": 18,
      "jsHeapTotalBytes": 5505024,
      "scriptDurationMs": 168.64700000000002,
      "eventListeners": 0,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 727.8069999999843,
      "styleRecalcs": 11,
      "styleRecalcDurationMs": 8.585000000000003,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 479.30299999999994,
      "heapDeltaBytes": 18074084,
      "heapUsedBytes": 80316348,
      "domNodes": 18,
      "jsHeapTotalBytes": 5767168,
      "scriptDurationMs": 173.86200000000002,
      "eventListeners": 2,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2028.8140000000112,
      "styleRecalcs": 4,
      "styleRecalcDurationMs": 4.751000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 485.36499999999995,
      "heapDeltaBytes": 2859632,
      "heapUsedBytes": 82282948,
      "domNodes": -253,
      "jsHeapTotalBytes": -1056768,
      "scriptDurationMs": 37.513000000000005,
      "eventListeners": -182,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66999999999998,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2037.2150000000602,
      "styleRecalcs": 4,
      "styleRecalcDurationMs": 3.727999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 622.9630000000001,
      "heapDeltaBytes": 4019804,
      "heapUsedBytes": 82944628,
      "domNodes": -250,
      "jsHeapTotalBytes": -794624,
      "scriptDurationMs": 39.486999999999995,
      "eventListeners": -154,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2540.4189999999858,
      "styleRecalcs": 66,
      "styleRecalcDurationMs": 12.652999999999997,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1785.954,
      "heapDeltaBytes": -12957640,
      "heapUsedBytes": 66828576,
      "domNodes": -229,
      "jsHeapTotalBytes": 1826816,
      "scriptDurationMs": 886.1320000000001,
      "eventListeners": -182,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2682.2919999999613,
      "styleRecalcs": 67,
      "styleRecalcDurationMs": 13.057999999999996,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1824.577,
      "heapDeltaBytes": 2846820,
      "heapUsedBytes": 83276424,
      "domNodes": -254,
      "jsHeapTotalBytes": 2052096,
      "scriptDurationMs": 907.162,
      "eventListeners": -182,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 3600.571000000002,
      "styleRecalcs": 60,
      "styleRecalcDurationMs": 10.401,
      "layouts": 60,
      "layoutDurationMs": 12.764000000000001,
      "taskDurationMs": 1775.0790000000002,
      "heapDeltaBytes": 9856048,
      "heapUsedBytes": 74513192,
      "domNodes": -263,
      "jsHeapTotalBytes": 0,
      "scriptDurationMs": 816.643,
      "eventListeners": 10,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 3622.8810000000067,
      "styleRecalcs": 60,
      "styleRecalcDurationMs": 10.560999999999998,
      "layouts": 60,
      "layoutDurationMs": 12.884999999999998,
      "taskDurationMs": 1781.633,
      "heapDeltaBytes": 9831868,
      "heapUsedBytes": 73731928,
      "domNodes": -265,
      "jsHeapTotalBytes": 0,
      "scriptDurationMs": 820.35,
      "eventListeners": 10,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "legacy-node-drag",
      "durationMs": 3156.4500000000066,
      "styleRecalcs": 40,
      "styleRecalcDurationMs": 5.281999999999995,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 2004.9070000000002,
      "heapDeltaBytes": 20447572,
      "heapUsedBytes": 86670512,
      "domNodes": 0,
      "jsHeapTotalBytes": 417792,
      "scriptDurationMs": 1004.4159999999999,
      "eventListeners": 188,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "legacy-node-drag",
      "durationMs": 3146.0950000000594,
      "styleRecalcs": 40,
      "styleRecalcDurationMs": 5.3329999999999975,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 2004.7939999999999,
      "heapDeltaBytes": 20469120,
      "heapUsedBytes": 86691080,
      "domNodes": 0,
      "jsHeapTotalBytes": 1204224,
      "scriptDurationMs": 1013.2269999999999,
      "eventListeners": 188,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333338,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "minimap-idle",
      "durationMs": 2016.6960000000245,
      "styleRecalcs": 5,
      "styleRecalcDurationMs": 4.572,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 609.9680000000001,
      "heapDeltaBytes": -3295668,
      "heapUsedBytes": 83861876,
      "domNodes": -249,
      "jsHeapTotalBytes": -495616,
      "scriptDurationMs": 38.974999999999994,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "minimap-idle",
      "durationMs": 2054.41600000006,
      "styleRecalcs": 5,
      "styleRecalcDurationMs": 4.699999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 649.1429999999999,
      "heapDeltaBytes": -4679516,
      "heapUsedBytes": 82617524,
      "domNodes": -254,
      "jsHeapTotalBytes": -495616,
      "scriptDurationMs": 37.328,
      "eventListeners": -182,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 608.5190000000011,
      "styleRecalcs": 46,
      "styleRecalcDurationMs": 10.928,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 422.29400000000004,
      "heapDeltaBytes": 13910020,
      "heapUsedBytes": 76666176,
      "domNodes": 18,
      "jsHeapTotalBytes": 6029312,
      "scriptDurationMs": 150.352,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 605.4789999999457,
      "styleRecalcs": 46,
      "styleRecalcDurationMs": 11.639,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 420.76800000000003,
      "heapDeltaBytes": 13758576,
      "heapUsedBytes": 76847032,
      "domNodes": 18,
      "jsHeapTotalBytes": 5505024,
      "scriptDurationMs": 147.81000000000003,
      "eventListeners": 6,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2022.2519999999804,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 10.839000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 520.8349999999999,
      "heapDeltaBytes": 11959076,
      "heapUsedBytes": 75034080,
      "domNodes": -277,
      "jsHeapTotalBytes": 4710400,
      "scriptDurationMs": 11.880999999999998,
      "eventListeners": -200,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2015.3029999999035,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 8.201,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 498.04,
      "heapDeltaBytes": 8512352,
      "heapUsedBytes": 71734228,
      "domNodes": -277,
      "jsHeapTotalBytes": 4710400,
      "scriptDurationMs": 10.22,
      "eventListeners": -200,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1720.9650000000352,
      "styleRecalcs": 77,
      "styleRecalcDurationMs": 28.900000000000002,
      "layouts": 18,
      "layoutDurationMs": 4.809000000000001,
      "taskDurationMs": 837.6790000000001,
      "heapDeltaBytes": 14424048,
      "heapUsedBytes": 77630024,
      "domNodes": -276,
      "jsHeapTotalBytes": 5234688,
      "scriptDurationMs": 115.98899999999999,
      "eventListeners": -202,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1722.695999999928,
      "styleRecalcs": 79,
      "styleRecalcDurationMs": 32.248,
      "layouts": 18,
      "layoutDurationMs": 5.949,
      "taskDurationMs": 878.665,
      "heapDeltaBytes": -2500304,
      "heapUsedBytes": 60516292,
      "domNodes": -276,
      "jsHeapTotalBytes": 5234688,
      "scriptDurationMs": 122.613,
      "eventListeners": -232,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-transition-enter",
      "durationMs": 1401.8250000000307,
      "styleRecalcs": 17,
      "styleRecalcDurationMs": 31.021,
      "layouts": 5,
      "layoutDurationMs": 13.668,
      "taskDurationMs": 994.7270000000001,
      "heapDeltaBytes": 19621632,
      "heapUsedBytes": 100486824,
      "domNodes": 13587,
      "jsHeapTotalBytes": 11010048,
      "scriptDurationMs": 34.49,
      "eventListeners": 2385,
      "totalBlockingTimeMs": 155,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 9377.060999999969,
      "styleRecalcs": 247,
      "styleRecalcDurationMs": 37.83200000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 6419.963,
      "heapDeltaBytes": -10283056,
      "heapUsedBytes": 68534500,
      "domNodes": -248,
      "jsHeapTotalBytes": 4186112,
      "scriptDurationMs": 3026.1369999999997,
      "eventListeners": -134,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.80000000000109
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 8657.785999999987,
      "styleRecalcs": 248,
      "styleRecalcDurationMs": 37.916999999999994,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 6098.21,
      "heapDeltaBytes": -12285788,
      "heapUsedBytes": 66643800,
      "domNodes": -249,
      "jsHeapTotalBytes": 4448256,
      "scriptDurationMs": 2859.871,
      "eventListeners": -166,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.670000000000012,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 17444.654000000013,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 16981.439,
      "heapDeltaBytes": -54873536,
      "heapUsedBytes": 159610448,
      "domNodes": -6575,
      "jsHeapTotalBytes": 1064960,
      "scriptDurationMs": 278.219,
      "eventListeners": -7478,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.780000000000047,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 17274.110999999946,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 16948.090999999997,
      "heapDeltaBytes": -39803040,
      "heapUsedBytes": 168255720,
      "domNodes": -6542,
      "jsHeapTotalBytes": 3424256,
      "scriptDurationMs": 283.999,
      "eventListeners": -7480,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.780000000000047,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 21088.037999999982,
      "styleRecalcs": 157,
      "styleRecalcDurationMs": 21.030999999999967,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 20954.068,
      "heapDeltaBytes": -31831144,
      "heapUsedBytes": 163214480,
      "domNodes": -6542,
      "jsHeapTotalBytes": 372736,
      "scriptDurationMs": 955.7710000000002,
      "eventListeners": -7474,
      "totalBlockingTimeMs": 62,
      "frameDurationMs": 17.776666666666642,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 21431.44600000005,
      "styleRecalcs": 154,
      "styleRecalcDurationMs": 20.706999999999976,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 21256.084000000003,
      "heapDeltaBytes": -33319232,
      "heapUsedBytes": 165111176,
      "domNodes": -6542,
      "jsHeapTotalBytes": 1589248,
      "scriptDurationMs": 922.312,
      "eventListeners": -7474,
      "totalBlockingTimeMs": 12,
      "frameDurationMs": 17.776666666666642,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-node-resize-workload",
      "durationMs": 6326.976000000002,
      "styleRecalcs": 20,
      "styleRecalcDurationMs": 79.878,
      "layouts": 20,
      "layoutDurationMs": 23.921999999999997,
      "taskDurationMs": 6254.259999999999,
      "heapDeltaBytes": -8554304,
      "heapUsedBytes": 193384964,
      "domNodes": -6542,
      "jsHeapTotalBytes": 16625664,
      "scriptDurationMs": 116.52399999999999,
      "eventListeners": -7476,
      "totalBlockingTimeMs": 416,
      "frameDurationMs": 17.776666666666642,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-node-resize-workload",
      "durationMs": 4828.9459999999735,
      "styleRecalcs": 20,
      "styleRecalcDurationMs": 82.09,
      "layouts": 20,
      "layoutDurationMs": 23.85899999999999,
      "taskDurationMs": 4780.839999999999,
      "heapDeltaBytes": 1612136,
      "heapUsedBytes": 196855552,
      "domNodes": -6546,
      "jsHeapTotalBytes": 20295680,
      "scriptDurationMs": 124.59599999999999,
      "eventListeners": -7480,
      "totalBlockingTimeMs": 120,
      "frameDurationMs": 17.776666666666642,
      "p95FrameDurationMs": 16.80000000000109
    },
    {
      "name": "vue-zoom-out-idle",
      "durationMs": 8812.072999999999,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 8585.464000000002,
      "heapDeltaBytes": 5350872,
      "heapUsedBytes": 182014816,
      "domNodes": -1,
      "jsHeapTotalBytes": 786432,
      "scriptDurationMs": 134.83200000000005,
      "eventListeners": -10,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.776666666666642,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-zoom-out-idle",
      "durationMs": 8699.214999999982,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 8453.369,
      "heapDeltaBytes": 16732452,
      "heapUsedBytes": 188881448,
      "domNodes": 0,
      "jsHeapTotalBytes": -2097152,
      "scriptDurationMs": 136.096,
      "eventListeners": -12,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.779999999999927,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "workflow-execution",
      "durationMs": 460.33199999999397,
      "styleRecalcs": 16,
      "styleRecalcDurationMs": 27.095,
      "layouts": 4,
      "layoutDurationMs": 2.162,
      "taskDurationMs": 136.52599999999998,
      "heapDeltaBytes": 5034716,
      "heapUsedBytes": 66716256,
      "domNodes": 126,
      "jsHeapTotalBytes": 262144,
      "scriptDurationMs": 12.559000000000001,
      "eventListeners": 83,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "workflow-execution",
      "durationMs": 475.2680000000282,
      "styleRecalcs": 19,
      "styleRecalcDurationMs": 21.926,
      "layouts": 5,
      "layoutDurationMs": 1.78,
      "taskDurationMs": 115.25800000000002,
      "heapDeltaBytes": 4842508,
      "heapUsedBytes": 66395724,
      "domNodes": 142,
      "jsHeapTotalBytes": 0,
      "scriptDurationMs": 11.315000000000001,
      "eventListeners": 67,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    }
  ]
}

🔬 E2E Coverage

Note

Shard completeness could not be verified for this run, so these totals may not be comparable with a whole merge.

Metric Covered Total Pct
Lines 50445 75139 67.1% 🟡
Functions 0 0 — —
Branches 0 0 — —
Top 10 files by uncovered lines
File Coverage Missed
src/LGraphCanvas.ts 67.4% 1159
src/LGraphNode.ts 69.7% 390
src/extensions/core/cameraInfo/CameraInfoViewport.ts 2.0% 343
src/renderer/extensions/layerEditor/composables/useLayerEditorSession.ts 40.1% 332
src/platform/workspace/stores/billingOperationStore.ts 8.0% 309
src/platform/workspace/stores/workspaceAuthStore.ts 36.0% 288
src/LGraph.ts 78.9% 268
src/platform/workspace/stores/teamWorkspaceStore.ts 38.9% 256
src/scripts/app.ts 71.8% 251
src/scripts/pnginfo.ts 21.4% 221

@github-actions github-actions Bot added the risk:xhigh PR risk grade (advisory shadow check; grader-owned) label Sep 22, 2026
@claude
claude Bot force-pushed the agent/tab-switch-activation-hooks branch from 624fac5 to 228153e Compare September 22, 2026 01:05
@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

CI note on the "Custom Nodes Ecosystem Matrix test" failure reported against the pre-amend commit 624fac5a1.

That failure is not a real test failure and not caused by this PR's diff. Looking at the run, all 8 ecosystem-matrix shard jobs show cancelled, not failed — the enforcer job ("Enforce complete matrix result") just fails whenever any shard didn't finish. The commit message amend (stripping AI trailers) force-pushed a new head, and GitHub's concurrency group cancelled the in-flight matrix run for the superseded commit before its shards could finish. That's a CI artifact of the push, not a regression from documentActivationHost/documentActivationStore/workflowService.

The amend push triggered a fresh, non-superseded run on the current head (228153ec5): https://github.com/Comfy-Org/ComfyUI_frontend/actions/runs/35674453364. As of this comment, changes, matrix-detection-proof (vue/legacy), corpus, and pin-status have all passed, and the 8 ecosystem-matrix shards are running (not cancelled). No new push is needed here; the check should update in place once that run finishes.

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.80420% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...platform/workflow/core/services/workflowService.ts 75.00% 5 Missing ⚠️
src/workbench/extensions/agent/AgentPanelRoot.vue 50.00% 1 Missing ⚠️
@@                          Coverage Diff                           @@
##             feat/graph-document-activation-seam   #18326   +/-   ##
======================================================================
  Coverage                                       ?   83.36%           
======================================================================
  Files                                          ?     2081           
  Lines                                          ?   121312           
  Branches                                       ?    31525           
======================================================================
  Hits                                           ?   101127           
  Misses                                         ?    20004           
  Partials                                       ?      181           
Flag Coverage Δ
e2e 67.16% <75.00%> (?)
unit 78.15% <95.80%> (?)

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

Files with missing lines Coverage Δ
src/core/graph/document/documentActivationHost.ts 100.00% <100.00%> (ø)
src/scripts/app.ts 77.48% <100.00%> (ø)
src/stores/documentActivationStore.ts 100.00% <100.00%> (ø)
src/stores/graphDocumentStore.ts 100.00% <100.00%> (ø)
.../workbench/extensions/agent/crdt/layoutMintPort.ts 100.00% <100.00%> (ø)
...rc/workbench/extensions/agent/crdt/linkMintPort.ts 100.00% <100.00%> (ø)
.../workbench/extensions/agent/crdt/mintPortWiring.ts 92.00% <ø> (ø)
.../workbench/extensions/agent/crdt/widgetMintPort.ts 100.00% <100.00%> (ø)
src/workbench/extensions/agent/AgentPanelRoot.vue 94.29% <50.00%> (ø)
...platform/workflow/core/services/workflowService.ts 95.87% <75.00%> (ø)
🚀 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.

@christian-byrne christian-byrne added needs-backport Fix/change that needs to be cherry-picked to the current feature freeze branch cursor-review Trigger multi-model Cursor agent review on this PR core/1.54 Backport PRs for core 1.54 cloud/1.54 Backport PRs for cloud 1.54 labels Sep 22, 2026
@christian-byrne
christian-byrne marked this pull request as ready for review September 22, 2026 01:51

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

🔍 Cursor Review — Consolidated panel

Triggered by @christian-byrne.

Found 10 finding(s).

Severity Count
🟠 High 4
🟡 Medium 5
🟢 Low 1

Panel: 8/8 reviewers contributed findings.

*/
const activateLoadedDocument = async (): Promise<void> => {
const documentId = useWorkspaceStore().workflow.activeWorkflow?.documentId
if (!documentId || !app.isGraphReady) return

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.

🟠 High — When activeWorkflow.documentId is null or app.isGraphReady is false this returns without activating, and a rejected/superseded ActivationOutcome is discarded too — but beforeLoadNewGraph has already retracted the previous binding, so activeRootGraphId() stays null for the rest of that workflow's lifetime. The new fail-closed gate then drops every root-scoped create/delete/clear with no user-visible signal, no retry, and only once-per-tick telemetry. Raised by 5 of 8 reviewers (claude-opus-5-thinking-max adversarial, gemini-3.1-pro adversarial, gemini-3.1-pro edge-case, kimi-k3-max adversarial, kimi-k3-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed on the silence, fixed in 08e3674, with one part I read differently.

activateLoadedDocument now reports every ending that leaves nothing activated: document_activation_unavailable when the graph is ready but the active workflow has no documentId, and document_activation_rejected (with the reason and root graph id) when the coordinator refuses. That ends the "only once-per-tick telemetry" problem: the drop is now attributable to the load that caused it, not to the change that later hits the gate.

Where I disagree on the remedy: when there is no documentId there is no GraphDocument for what the canvas is showing, so minting root-scoped ops into the agent's bound document would be minting into a document the canvas does not hold. Dropping is the correct outcome; being quiet about it was the bug. Same for superseded, which means a newer load won and will publish its own binding. !app.isGraphReady stays a silent no-op because there is no canvas and therefore no layout changes to drop.

The rejected path also got narrower rather than just louder: the load path now marks the document loaded itself (see the documentActivationHost.ts thread), so not-loaded can no longer fire for a workflow document a load produced. Test: workflowService.test.ts "reports a load that ends with no document holding the canvas" (red before).

* rather than the workflow's serialized `activeState`, because that is the
* graph every layout change will name.
*/
const activateLoadedDocument = async (): Promise<void> => {

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.

🟠 High — The "all three graph-load paths funnel through afterLoadNewGraph" premise misses Clear Workflow: runMintPortsIntentionalClear(() => app.clean()) reaches LGraph.clear(), which remints the root graph's id without any load and therefore without re-activating. The host keeps publishing the pre-clear id, so every subsequent human create/delete fails isForActivatedDocument and is dropped until the next workflow load, while widget and link mints keep flowing into the same document and reference nodes that were never added. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed in 08e3674.

LGraph.clear() does remint (this.id = createUuidv4() for a root graph), and Clear Workflow reaches no load path, so the binding kept naming the pre-clear graph and every later create/delete was dropped as foreign.

What changed: the host gained rebindActiveScope(scope) (same document, same canvas, new id, so no detach/attach and no generation race), and app.clean() calls it right after ensureNonZeroUuid(this.rootGraph). It returns false during a load, which already retracted the binding, so the load path is untouched.

One wrinkle worth naming: the store's own clearGraph change carries the pre-clear id and drains a microtask later, so a naive rebind would have made the human clear op itself fail the targeting check. runIntentionalClear now captures the activated root graph id alongside the pre-clear node set, and a clear inside that window is validated against the captured id.

Tests (both red before): app.test.ts "republishes the activated document on the reminted root graph id" and tabSwitchActivation.test.ts "keeps minting after a clear reminted the root graph id in place". The "all three graph-load paths funnel through here" comment now says loads funnel through afterLoadNewGraph and names the clear path as the one swap that does not. The widget/link half of your note is fixed in the mintPortWiring thread.

return {
activate(documentId, scope) {
requested = documentId
deps.bindScope(documentId, scope)

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.

🟠 High — bindScope runs before coordinator.activate() evaluates its isLoaded precondition, and the store's implementation calls hydrateDocument, which itself transitions a document created -> loaded; requesting activation therefore promotes the document and the not-loaded rejection becomes unreachable in production (the host test passes only because its isLoaded Set double is untouched by the bindScope recorder). The registry scope is also written for activations that are later rejected or superseded, so a losing request can leave getDocument(id).scope naming a graph that document never held — commit the scope from the winning attach instead. Raised by 5 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max adversarial, kimi-k3-max adversarial, kimi-k3-max edge-case).

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.

Both halves confirmed and fixed in 08e3674. This was the most useful finding of the set.

Scope commit: the dep is renamed commitScope and is called only when the coordinator returns activated. A rejected or superseded request no longer stamps its document, which matters exactly as you describe: the loser read app.rootGraph.id before the winner reconfigured, so its "own" scope can name the winner's graph. Host tests: "never records the scope of an activation it rejected" and "never records the scope of a superseded activation".

The precondition: rather than commit scope from inside attach (activation is presentation per the ADR, and attach/detach must not touch semantic document state), the created -> loaded promotion moved to the loader. graphDocumentStore gained markLoaded(documentId), a phase-only transition with no scope, and workflowService.activateLoadedDocument calls it before requesting the canvas. Loading a document is the load path's step; the coordinator's isLoaded is now a real check that rejects a document no load produced (unknown or closed).

Pinned against the real registry, not a double: tabSwitchActivation.test.ts "refuses the canvas to a document no load path ever loaded" asserts the not-loaded outcome, a null binding and a null registry scope. It fails on the old code, which activated because the request hydrated the document on its way in.

// the shared root graph (ADR-GRAPH-DOCUMENT-0024). Synchronous on
// purpose: from here until the incoming document is activated, no
// consumer can observe a binding naming a graph this load overwrites.
useDocumentActivationStore().deactivate()

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.

🟠 High — This deactivation is unconditional, but nothing restores the binding on load paths that bail before afterLoadNewGraph — loadGraphData returning false when rootGraph.configure() throws, the A1111 core-nodes-unavailable/not-a1111 early returns, or a throw in the pre-load work such as changeTracker.deactivate(). The canvas still shows an editable graph while activeRootGraphId() stays null, so the fail-closed gate drops every root-scoped edit until the next successful load. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed for the pre-load throw, fixed in 08e3674. The other two cases I checked and they do not reach this line.

Fix: deactivate() is now the last statement of beforeLoadNewGraph instead of the first. Nothing in the body touches the shared root graph (draft persistence, warning caching, preview stashing, thumbnail, viewport save), so retracting after it is just as safe, and a throw in there aborts the load with the outgoing graph still on the canvas, where its binding is still the honest one. Test: workflowService.test.ts "keeps the outgoing binding when the pre-load capture throws" (red before), plus "retracts the outgoing binding before the shared graph is touched" so the ordering stays pinned.

A1111: importA1111 returns not-a1111 and core-nodes-unavailable before it invokes beforeGraphClear, which is the callback that runs beforeLoadNewGraph (see pnginfo.ts, the early returns are above the await beforeGraphClear?.() call site, and every outcome after it is imported or imported-without-embeddings, both of which reach afterLoadNewGraph). So those returns never retract anything.

rootGraph.configure() throwing: real, but the consequence is not specific to activation. That path never fires afterConfigureGraph, so the mint load bracket stays open and session.inTeardown() suppresses every mint, root-scoped or not, until the next load's paired hook closes it. That is the documented pre-existing fail-closed posture of the bracket, and the next successful load re-activates. I left it as is rather than inventing a recovery activation, because on that path the canvas holds a partially configured graph whose identity nobody has established.

operation: LayoutChangeView['operation'],
action: 'create' | 'delete' | 'clear'
): boolean {
if (operation.graphId === undefined) return 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.

🟡 Medium — A change with no graphId returns true and bypasses activation targeting entirely, including during the no-document handoff window this guard exists to close. The comment defers such changes to the root-vs-subgraph classifier above, but that classifier also returns false for graphId === undefined (it compares equal to an undefined ownerGraphId), so nothing rejects it — the new leaves a change with no graph id to the root-vs-subgraph classifier test pins the bypass. Given the stated fail-closed policy, the unclassifiable case should be the one that drops and reports. Raised by 6 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial, gemini-3.1-pro edge-case, gpt-5.6-sol-max adversarial, kimi-k3-max adversarial).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed as a fail-open hole in the port, fixed in 08e3674, with the caveat that it was not reachable from production.

You are right that the two gates together let it through: the classifier returns false for an undefined graphId and the targeting rule returned true, so an unattributable change minted into whatever document was bound. The reason it never bit is that graphId is required on the store's OperationMeta, so every real LayoutOperation carries one. The optionality lived only in this port's structural view of the change.

So rather than add a third drop branch, I made the view mirror the contract: LayoutChangeView.operation.graphId is now string, not string?. Both undefined branches are gone (isForActivatedDocument and reportUnrepresentableInteriorChange), the compiler enforces it at the seam, and the "leaves a change with no graph id to the root-vs-subgraph classifier" test is deleted rather than inverted. The fixtures across layoutMintPort.test.ts and mintPortWiring.test.ts now carry real graph ids, which also makes them faithful to what the store emits.

Related ordering change in the same commit: for createNode/deleteNode the activation check now runs before the root-vs-subgraph classification. A change for a graph the activated document does not own should be reported as that, not as a subgraph divergence, and it stops a tab switch away from a subgraph-heavy tab from reporting false divergence.

localActorPrefix: deps.localActorPrefix,
isEnabled: deps.isEnabled,
isDocBound: deps.isDocBound,
activeRootGraphId: deps.activeRootGraphId,

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.

🟡 Medium — activeRootGraphId is threaded only into the layout port: attachWidgetMintPort still re-derives its scope from the live canvas graph via deps.getGraph() — the exact re-derivation the new dep's doc comment calls unsafe across an in-place reconfigure — and attachLinkMintPort has no graph check at all. The asymmetry is worse than the prior uniform behavior: node creates are now dropped while set_widget and connect still mint, producing ops that reference nodes absent from that document. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed, and the asymmetry argument is what convinced me to fix it here rather than defer. Fixed in 08e3674.

Widget port: rootGraphId is now deps.activeRootGraphId, so it no longer re-derives from deps.getGraph(). A root-scoped write still mints the root form, an interior write still resolves its path over the live graph, and a write whose owner cannot be resolved against the activated root surfaces instead of minting.

Link port: it takes activeRootGraphId() and drops a connect whose scope.rootGraphId is not the activated root, surfacing it the same way it surfaces a subgraph-interior connect. onDeleted folds the same check into mintable, so a foreign severance is captured but never handed to a delete_node as removed_links and never surfaced as this document's divergence.

The window this actually closes is the one in the afterLoadNewGraph thread: between afterConfigureGraph (bracket open again) and workflowStore.openWorkflow resolving, the canvas holds the incoming graph while the outgoing workflow is still the active and bound one. Layout creates were already failing closed there; connect and set_widget were minting into the outgoing document with the incoming graph's node ids.

Test: mintPortWiring.test.ts "every port targets the activated document, not the live canvas graph" drives the real link and widget stores with the live graph still on ROOT_ID and nothing activated, and asserts zero mints from all three ports. Red before. Link port also has unit coverage for the foreign scope, the null activation and the non-mintable severance.

if (!gate(change, inTeardown || captured === null)) return
// clearGraph is root-scoped by construction (layoutStore.clearGraph
// takes a root graph id), so its own graphId classifies it.
if (!isForActivatedDocument(operation, 'clear')) return

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.

🟡 Medium — intentionalClearNodes is read and nulled at lines 251-252, before this drop, so a stale or foreign clearGraph dropped here still consumes the intentional-clear capture; the genuine clear that follows sees captured === null, is treated as teardown by gate, and never reaches the wire. Move the activation check above the capture consumption — and note that dropping a clear leaves the entire previous node set resident in the document, a far larger divergence than dropping a single node op. Raised by 2 of 8 reviewers (kimi-k3-max adversarial, claude-opus-5-thinking-max adversarial).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed in 08e3674, including the "a dropped clear is a bigger divergence" point.

The clearGraph case now decides targeting before it consumes anything. Order is: local-human provenance, then the targeting check, then consume the capture, then the flag/teardown gate. A stale or foreign clear now returns with the capture intact, so the genuine clear that follows still sees its pre-clear node set and mints.

Splitting the gate was needed to get that order right: gate() mixed provenance with shouldMint, and shouldMint needs captured === null to compute teardown, so the provenance half is now isLocalHumanChange(), checked first. That also keeps a remote apply or another actor's clear from reporting a targeting drop it was never eligible for.

Test: "a foreign clear never consumes the intentional-clear capture" delivers the foreign clear and then the genuine one inside one runIntentionalClear window and asserts the clear mints with the captured nodes. Red before, green after. The same restructure carries the pre-clear root graph id in the window, which is what makes the Clear Workflow rebind work (see the workflowService.ts Clear Workflow thread).

): boolean {
if (operation.graphId === undefined) return true
const activeRootGraphId = deps.activeRootGraphId()
if (operation.graphId === activeRootGraphId) return 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.

🟡 Medium — This treats the persisted root graph UUID as document identity, but LGraph.configure() adopts the workflow file's serialized id and a Save-As or externally duplicated workflow keeps it, so two tabs can carry identical root graph ids. A change queued before a switch between such tabs compares equal here and is enqueued into the other tab's document — the cross-document corruption this gate exists to prevent. Compare document identity or a stamped activation generation rather than the persisted graph id alone. Raised by 3 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, kimi-k3-max edge-case).

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.

Pushing back on this one, so no code change. The mechanism you describe is real, but the named reproduction is not, and the remedy belongs elsewhere.

LGraph.configure() does adopt the file's serialized id, but both duplication paths remint before the load: workflowStore.saveAs generates a fresh id and writes it into the copied state ("Generate new id when saving existing workflow as a new file"), and duplicateWorkflow does state.id = generateUUID() for the same reason. Same-path reopens are deduped by getWorkflowByPath, so two tabs sharing a root graph id needs files that were copied outside the app and still carry the same serialized id.

In that state the collision is much deeper than op targeting. The root graph id is the ECS scope key: layout entries are keyed by makeScopedLayoutKey(graphId, nodeId), and widgetValueStore, linkStore, linkPresentationStore, rerouteStore, nodeDataStore, executionOrderStore and layoutStore are all cleared and addressed by that id. Two open tabs with the same id already share and clear each other's state, so tightening this one comparison would hide a broken state rather than fix it. The fix is at load-time identity: remint when the incoming workflow's id is already held by another open tab. That is a behavior change to workflow loading, outside this PR, and I would rather file it than smuggle it in here.

On the suggested alternative: a stamped activation generation cannot be compared here either, because the change carries no stamp. LayoutChange is queued with operation.graphId and nothing else identifying when it was enqueued, so the port only ever sees ids. Stamping would have to happen in the layout store at applyOperation time, which means teaching the renderer about activation.

Happy to file the load-time dedupe ticket if you agree with that split.

shareId?: string
) => {
await activateLoadedWorkflow(value, workflowData, shareId)
await activateLoadedDocument()

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.

🟡 Medium — Activation lands after activateLoadedWorkflow's awaits (which include workflowStore.openWorkflow I/O), but the mint teardown bracket has already reopened from the afterConfigureGraph hook via notifyMintPortsAfterGraphConfigure(). Layout changes delivered in that window see mints enabled and activeRootGraphId() === null, so they are silently dropped, and if activateLoadedWorkflow throws, activation never runs at all. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).

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.

Window confirmed, and it is now fail-closed everywhere instead of asymmetric. The throw half I read the other way.

The window: 08e3674 makes all three ports apply the same targeting rule, so nothing mints into the outgoing document between the bracket reopening and activation landing. Layout already dropped there; connect and set_widget were the leak (see the mintPortWiring.ts thread). A load that ends with nothing activated now reports rather than going quiet.

Closing the window entirely means closing the mint bracket after activation instead of on the afterConfigureGraph extension hook. I did not do that here: the bracket is driven from extensions/core/agentPanel.ts precisely so platform/workflow does not import the workbench mint wiring, and moving the call into afterLoadNewGraph crosses that boundary (import-x/no-restricted-paths). Activating earlier is not available either, because the incoming documentId comes from activeWorkflow, which activateLoadedWorkflow's openWorkflow is what sets. Follow-up candidate, and worth doing as its own change.

The throw: activating in a finally would be a mispairing, not a recovery. If activateLoadedWorkflow throws, activeWorkflow can still be the outgoing workflow while app.rootGraph already carries the incoming graph, so the fallback would publish {outgoing document, incoming graph} and every change on the new graph would mint into the old document. That is the exact corruption this seam exists to prevent, so leaving the binding retracted is the correct outcome, and the throw itself propagates out of loadGraphData to the caller's error handling.

view = { documentId, rootGraphId }
},
detach(documentId) {
if (view?.documentId === documentId) view = null

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.

🟢 Low — detach compares only documentId while attach captures rootGraphId, so if a document is re-activated with a rotated graph id and a stale binding's detach runs after the new attach, it nullifies the freshly published view and activeRootGraphId() goes null while that document is still active. Compare the captured rootGraphId too, so a binding can only retract what it published. Raised by 2 of 8 reviewers (gemini-3.1-pro adversarial, gemini-3.1-pro edge-case).

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.

Right invariant, and fixed in 08e3674, but with binding identity rather than the captured rootGraphId.

Comparing the captured id would have broken the rebind added for Clear Workflow: rebindActiveScope republishes the same document on a reminted root id while the coordinator still holds the binding that attached with the old one, so the stored binding's captured id would no longer match the published view and a later deactivate() would leave a stale binding published forever. That is a worse failure than the one being fixed.

So the view now records the binding that published it, and detach clears only its own: if (view?.documentId === documentId && view.binding === binding). That is the invariant you were reaching for ("a binding can only retract what it published") and it survives an in-place rebind.

Honest about the evidence: I could not construct a reachable sequence on the current coordinator, so there is no red-before test. Every detach call site uses the binding stored with the active entry (previous.binding.detach in activate, previous.binding.detach in deactivate), and this host's attach is a plain assignment that cannot re-enter, so the stale-detach path needs a future binding that can. The guard costs one reference comparison and the DocumentViewBinding contract explicitly allows the coordinator to detach a superseded binding, so it is worth having regardless. Pinned in the other direction by the host test "still retracts on the next load after a rebind", which fails if the identity check strands a rebound view.

Activation targeting was reachable only through the load path, and three
graph swaps do not go through it.

- Clear Workflow remints the root graph id in place (LGraph.clear), so the
  activated document kept naming the pre-clear graph and every later op was
  dropped as foreign. app.clean() now republishes the same document on the
  reminted id, and an intentional-clear window validates the clearGraph
  change against the id captured when it opened (the clear remints under it).
- beforeLoadNewGraph retracts last, not first: a throw while capturing tab
  state aborts the load with the outgoing graph still on the canvas, where
  its binding is still the honest one.
- The load path declares the document loaded before asking for the canvas,
  so the coordinator's isLoaded precondition is a real check instead of one
  the request itself satisfied, and scope is committed only by the handoff
  that won - a superseded activation no longer stamps its document with a
  graph id the winner already owns.
- A load that ends with no activation reports instead of leaving op
  targeting silently fail-closed until the next load.
- A layout change with no graphId can no longer bypass targeting: the view
  type now requires it, as the store's own LayoutOperation does.
- The link and widget ports target the activated document too, instead of
  re-deriving scope from the live canvas graph. Node creates failing closed
  while connect and set_widget kept minting was the asymmetry.
- Only the binding that published a view may retract it, so a stale detach
  cannot nullify a freshly published one.

Claude-Session: https://claude.ai/code/session_01U73XrPUkU81hiq71XZY4mr
…t guard

Covers the activation guard with the graph UUIDs from a 2026-09-22
cloud-frontend-staging Sentry report (createNode targeting a foreign
graph while a different root graph is bound/activated), instead of
only synthetic placeholder ids.
@claude

claude Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Added a regression test using real production data: commit 8abb84baf, in src/workbench/extensions/agent/crdt/layoutMintPort.test.ts (new it block right after "drops a root-scoped %s naming a graph the activated document does not own", inside the activation-scoped targeting describe).

The UUIDs are from an actual cloud-frontend-staging Sentry alert (2026-09-22): a createNode op targeting graph 84826d7d-1b25-4cfb-9d59-2747a4b09a19 while 27ca8666-fa2b-4ef9-99bc-e005182fadc6 was the bound/activated root graph — the exact scenario reportOpForUnboundGraph() (from #18109) refused to mint, and that this branch's isForActivatedDocument() guard now covers. The new test asserts the op is dropped (minted stays empty) and reportError fires with errorType: 'agent_crdt_op_for_inactive_document'.

All 41 tests in the file pass, along with pnpm lint, pnpm format --check, and pnpm typecheck.


Generated by Claude Code

@dante01yoon dante01yoon 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 8abb84ba. Stacked PR — base is feat/graph-document-activation-seam (#16375), so I diffed against that branch, not main.

The design reads well: one owner for "which document holds the canvas", consumers reading instead of re-deriving, and the handoff window made explicitly empty rather than racy. The adversarial panel's findings were answered substantively, and the fixes are real rather than cosmetic — I checked them rather than taking the replies at face value.

What I verified in a worktree at the PR head

  • 94 tests pass across the five new/changed test files I could execute (documentActivationHost, tabSwitchActivation, layoutMintPort, linkMintPort, mintPortWiring).
  • Mutation-tested five of the new guards rather than trusting green. Load-bearing: the targeting rule (11 tests red), the clearGraph order fix (1), commitScope only on activated (2), and deactivate()'s in-flight cancellation (5). The one mutation that survives is dropping view.binding === binding from detach — which is exactly what you said in that thread ("I could not construct a reachable sequence on the current coordinator, so there is no red-before test"). I agree the guard is worth keeping; the mutation just confirms your own account, it isn't a new ask.
  • Your pushback on the rootGraph.configure() throw holds. afterConfigureGraph is invoked at app.ts:1566, after the return false at app.ts:1505, so the bracket never closes on that path and inTeardown() suppresses every mint regardless of activation. The deactivation is not the operative cause there.
  • The required-graphId narrowing mirrors the real contract: OperationMeta.graphId: UUID is non-optional at src/renderer/core/layout/types.ts:124.
  • commitScope after markLoaded does land the scope: the reducer's hydrated only moves created → loaded, so hydrateDocument no-ops and rebindScope performs the write.
  • The Clear Workflow rebind is inert during loads, as documented: both in-load clean() calls (app.ts:1322, app.ts:2341) run after beforeLoadNewGraph has retracted.
  • vue-tsc --noEmit: 28 errors, all TS2307 missing-module (vuefire, jsonata) from an incomplete node_modules in my environment, none in any changed file, and no other error class. CI's typecheck gate is green.

What I could not run, and why it matters for how much weight to give the above: the same missing modules meant workflowService.test.ts and app.test.ts would not load (they fail identically on the stack base, so it is environmental). I read both diffs instead — they do cover the Clear Workflow rebind and the four load-path endings, and they look well-pinned — but I have not executed them.

One item inline that blocks the stack rather than this merge, plus two non-blocking notes.

// The activation host, not a second derivation off the live canvas graph:
// the shared `LGraph` already carries the incoming tab's id while the
// outgoing document is still the bound one.
rootGraphId: deps.activeRootGraphId,

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.

issue: #18109 merged into main on 2026-09-22 04:10 UTC and this branch does not contain it, so as written, landing this stack reverts a shipped fix for the same bug.

What I checked:

The three production files this PR rewrites are exactly the three #18109 changed, and it rewrites the same functions, so this is the shape of conflict that tends to get resolved wholesale in one direction.

The PR body already anticipates this — "Whichever lands second should do that collapse" — and it was accurate when written. #18109 has since landed, and the newest commit here (8abb84ba, 2026-09-23) came about 22 hours after that merge without integrating it.

To be clear about severity: this does not block merging into feat/graph-document-activation-seam, since nothing reaches main yet. It blocks the stack. Could we either do the collapse here, or state where it will happen — a rebase of #16375 onto post-#18109 main? My concern is that otherwise the reconciliation gets decided by whoever resolves the conflict, and the dedupe is the easy half to drop silently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed both halves of this, collapse done in 3283a84 (pushed to this branch).

What I checked against main's current layoutMintPort.ts (git show origin/main:src/workbench/extensions/agent/crdt/layoutMintPort.ts, at f664247):

  • Targeting: boundRootGraphId() is fully subsumed here, not just replaced. main's foreignBoundRootGraphId/reportOpForUnboundGraph reject an op whose graphId doesn't match the bound document's stored root id; this branch's isForActivatedDocument/activeRootGraphId() does the same comparison through the activation coordinator instead of a workflow-store accessor, and is strictly stricter (fails closed on null where main's boundRootGraphId() === null lets an unclassifiable op through — see the separate thread on that). So no gap there.
  • Dedupe: genuinely missing, exactly as you found. mintedNodeIdsByRoot/mintedNodeIdsForRoot (main:119-127) is a Map<graphId, Set<nodeId>> that: (1) in handleCreateNode, skips a create whose id is already in that graph's set (a redo, or a create replaying while switching between two tabs bound to the same root graph) and adds the id once minted; (2) in handleDeleteNode, evicts the id from its own graph's set on any root-owned delete, unconditionally, before any gating — so a later replay can re-mint; (3) in handleClearGraph, forgets the whole bucket only on an intentional (human-confirmed) clear, never on an incidental one (a tab switch reconfiguring the shared canvas graph in place). I grepped this branch for mintedNodeIds/dedupe — nothing, confirming it isn't just renamed.

Ported into layoutMintPort.ts (not pasted — adapted to this branch's mechanism):

  • Same Map<string, Set<string>>, but keyed by operation.graphId directly rather than a boundRootGraphId()-style accessor read. That's a deliberate simplification, not a shortcut: by the time createNode/deleteNode reach the bucket lookup, isForActivatedDocument has already guaranteed operation.graphId === activeRootGraphId(), and graphId is string (required) on this branch's LayoutChangeView, not string | null as on main. So the "two graphs share the null-keyed bucket while the accessor is unresolved" edge case main's tests guard against can't arise here — activation fails closed instead of returning an ambiguous key.
  • createNode: dedupe check placed after gate/isForActivatedDocument/reportUnrepresentableInteriorChange, same ordering as main.
  • deleteNode: eviction moved to the top of the case, unconditional on ownerGraphId === graphId, same as main's placement relative to its own gate/targeting checks.
  • clearGraph: bucket forgotten only when captured !== null (inside runIntentionalClear), placed right after the capture is consumed and before the final gate call.

Tests added to layoutMintPort.test.ts (all red before this commit, green after):

  • skips a redo that recreates an already-minted node instead of re-minting add_node
  • mints add_node again for the same id after a delete_node clears the dedupe entry
  • forgets the dedupe bucket on an intentional clear, so a later create re-mints
  • does not let an incidental clearGraph forget the dedupe bucket (regression)
  • does not re-mint a root graph replay after switching away and back to it (regression) — the actual two-tabs-same-root-graph scenario fix(agent-crdt): scope layout mint ops to the bound document's root graph #18109 was fixed for, ported to this branch's activeRootGraphId fixture (switch ACTIVATED → OTHER → back to ACTIVATED, assert the replay on return mints nothing while OTHER's own create for the same colliding node id still mints from its own bucket)

45/45 tests pass in layoutMintPort.test.ts; pnpm typecheck and pnpm lint are clean. mintPortWiring.ts/AgentPanelRoot.vue needed no changes — on main those two files only pass boundRootGraphId through as a wiring dependency, the dedupe itself lives entirely in layoutMintPort.ts, and the same is true here with activeRootGraphId.

(AgentPanelRoot.test.ts has 3 pre-existing, unrelated failures on this branch — media-card attachment/upload tests failing on a Blob.stream is not a function environment issue — confirmed present on the pre-fix commit too via git stash, not something this change touches.)


Generated by Claude Code

* reads as "the agent quietly stopped seeing my edits".
*/
const activateLoadedDocument = async (): Promise<void> => {
if (!app.isGraphReady) return

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.

suggestion: this is the one ending that leaves nothing activated and reports nothing, which reads against the invariant the doc comment just above states — "A load that ends without an activation leaves op targeting fail-closed until the next load, so every such ending is reported: silence there reads as 'the agent quietly stopped seeing my edits'." The documentId branch below and the rejected branch both report; this one returns bare.

I believe it is unreachable in practice: every afterLoadNewGraph call site runs after rootGraph.configure(), so rootGraphInternal is set by then, and I could not find a path that reaches here with it unset. So this is about keeping the stated invariant true rather than closing a live gap — a reportError here (or a comment saying why this ending is exempt) would make the comment and the code agree.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed unreachable in production: rootGraphInternal is assigned exactly once, at app.ts:1009 during initial setup(), and never reset anywhere else. Every afterLoadNewGraph call site is a method invoked on an already-set-up app instance, so isGraphReady is always true by the time this runs.

Went with the comment option rather than reportError, since adding telemetry for a branch that can't fire would just be noise. Added in 6514962:

// Exempt from the invariant above: `rootGraphInternal` is set once at
// app setup, before any load path can reach here, so this never fires.
if (!app.isGraphReady) return

Generated by Claude Code

if (!gateOpen()) return
if (!isForActivatedDocument(scope)) {
surfaceUnrepresentable(
'connect on a graph the activated document does not own',

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.

suggestion: this new drop path logs one undeduped console.error per link, while the layout port's equivalent new drop path goes through createOncePerTickReporter — added in this same PR, with the comment "a tab switch emits a change per node, and each would otherwise report separately". Link placement has the same burst shape: onPlaced fires per registerLink/replaceLink, and a reconfigure registers every link in the workflow.

Honest caveat on how much this matters: I could not demonstrate the burst. Configure-time registerLink calls land inside the still-open mint bracket, so gateOpen() is false and nothing surfaces; the exposed window is only the narrow one between afterConfigureGraph closing the bracket and activation landing. So this may stay theoretical. It is cheap to make symmetric, though, and the helper is right there.

Related and smaller, in the same spirit: widgetMintPort's console.error now also fires with root === null during a handoff, where its message ("set_widget with an unresolvable owner ... the bound doc diverges from the local graph") names the wrong cause — mid-handoff is not divergence.

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.

Both fixed in 6514962.

Link port: added a local createOncePerTickReporter mirroring the layout port's, and wired it around the new isForActivatedDocument drop in onPlaced, keyed by `connect:${scope.rootGraphId}:${deps.activeRootGraphId()}` so a burst on the same graph pair reports once, same as the layout port's reportInactiveChangeOnce.

widgetMintPort: the console.error now distinguishes the two causes instead of always blaming divergence:

console.error(
  root === null
    ? '[agent-crdt] set_widget with no activated document (load handoff in progress); not minted'
    : '[agent-crdt] set_widget with an unresolvable owner not minted; the bound doc diverges from the local graph',
  `${set.graphId}:${String(set.nodeId)}:${set.name}`
)

The actual-divergence message (resolveInteriorPath returning null/empty for a real graph) is unchanged.


Generated by Claude Code

}
)

it('refuses a createNode targeting a foreign graph (real cloud-frontend-staging Sentry data)', () => {

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.

nit-pick (non-blocking): this case asserts exactly what the it.for immediately above it already asserts for createNode — same activeRootGraphId, same rootScoped(...) delivery, same two expectations. Only the id strings differ, and the guard is a === string comparison, so UUID-shaped ids exercise no path the placeholder ids miss. As the whole content of its own commit, it adds a maintenance point without adding coverage.

The provenance is genuinely worth keeping. Could the Sentry reference live as a comment on the existing parametrized case ("real ids from a 2026-09-22 cloud-frontend-staging report: …") rather than as a separate case?

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.

Agreed, done in 6514962. Removed the separate it block and moved the Sentry provenance onto the it.for case as a comment instead:

// ACTIVATED/OTHER stand in for real UUIDs seen in a 2026-09-22
// cloud-frontend-staging Sentry report (27ca8666-fa2b-4ef9-99bc-e005182fadc6 /
// 84826d7d-1b25-4cfb-9d59-2747a4b09a19); the guard is a plain string
// comparison, so the placeholders exercise the same path.
it.for(['createNode', 'deleteNode', 'clearGraph'] as const)(
  'drops a root-scoped %s naming a graph the activated document does not own',
  ...

Generated by Claude Code

@dante01yoon dante01yoon removed their assignment Sep 23, 2026
- workflowService.ts: document why activateLoadedDocument's
  isGraphReady guard is unreachable in production (rootGraphInternal
  is set once at app setup, before any load path can reach it),
  rather than adding a reportError to an invariant-only branch.
- layoutMintPort.test.ts: drop the duplicate real-UUID test case for
  the foreign-graph mint guard; the real Sentry ids now live as a
  provenance comment on the existing parametrized case instead.
- linkMintPort.ts: dedupe the new foreign-graph connect drop with the
  same createOncePerTickReporter pattern the layout port uses, so a
  burst of drops on the same graph pair reports once.
- widgetMintPort.ts: distinguish the mid-handoff (root === null) case
  from actual doc divergence in the unresolvable-owner console.error.
…ased targeting

#18109 landed on main after this branch forked, adding boundRootGraphId()
targeting plus a mintedNodeIdsByRoot dedupe to stop a replayed createNode
(litegraph undo/redo, or a create op replaying across two tabs bound to the
same root graph) from minting a second add_node for a node the doc already
has. This branch's rewrite replaced boundRootGraphId() with the activation
coordinator's isForActivatedDocument()/activeRootGraphId(), which subsumes
#18109's targeting check, but carried none of its dedupe forward.

Port the dedupe into attachLayoutMintPort, keyed by the operation's own
graphId (guaranteed to be the activated document's by the time a create or
delete reaches the bucket, since isForActivatedDocument already filtered):
- createNode skips a replay for an id this port already relayed, and
  records newly-minted ids in that graph's bucket
- deleteNode evicts the id from its own-graph bucket whenever a root-owned
  delete fires, independent of gating, so a later replay can re-mint
- an intentional (human-confirmed) clear forgets the whole bucket; an
  incidental clearGraph (tab-switch reconfiguring the shared canvas graph in
  place) leaves it alone

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

Re-reviewed the delta 8abb84ba..3283a842 (5 files, +159/-25) rather than the whole PR. All four items from my last review are addressed, and I checked each rather than reading the commit messages:

  • #18109's dedupe (the one that blocked the stack) — ported. mintedNodeIdsByRoot/mintedNodeIdsForRoot are present (5× / 2×, against main's 6× / 2×), with five new regression tests. Keying on operation.graphId instead of main's boundRootGraphId is a genuine improvement, not just a transcription: by the time a create reaches the bucket lookup, isForActivatedDocument has already established that the key names the activated document, so the ambiguous "activation unresolved" case main had to special-case can't arise. The comment says exactly this, and it's right.
  • workflowService.ts:696 — took the comment option I offered; the stated invariant and the code now agree.
  • linkMintPort.ts — now routed through a once-per-tick reporter, symmetric with the layout port.
  • widgetMintPort.ts — the message now distinguishes root === null (handoff in progress) from a genuinely diverged doc.
  • The test nit — handled better than I asked: the redundant case is gone, the Sentry provenance survives as a comment on the parametrized case, and the slot now holds a real switch-away-and-back regression test.

Validation (isolated worktree at 3283a842):

What Result
5 runnable suites (documentActivationHost, tabSwitchActivation, layoutMintPort, linkMintPort, mintPortWiring) 98 passed (was 94)
Mutation test, 3 new dedupe guards 2 load-bearing (3 red / 1 red), 1 survives
Probe: delete while deactivated, then reactivate fails on the current head

Two findings inline, both in the deleteNode forget block. The first is a correctness gap I'd like resolved before this lands — it narrows, but does not close, the hole #18109 fixed, which makes it worth flagging given preserving that fix is exactly what the newest commit set out to do. I've included the probe and what I think is a one-line fix, plus an honest note on how far I could establish reachability.

What I still could not run, unchanged from last time and still environmental: workflowService.test.ts and app.test.ts fail to load with Failed to resolve import "vuefire" — that package is genuinely absent from my node_modules, and both files fail identically on the stack base. I read both diffs again; they cover the Clear Workflow rebind and the four load-path endings and look well-pinned, but I have not executed them. CI's gates are green on this SHA.

// so it must not forget an entry from the root's bucket for what is
// really a different node's namespace.
if (operation.nodeId === undefined) return
if (operation.ownerGraphId === operation.graphId) {

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.

issue: the forget runs before the targeting check, which reintroduces #18109's double-mint when a root-owned delete names a graph that is not the activated document.

The comment above argues the forget must be unconditional because "the document lost this id the moment a same-graph, root-owned deleteNode change fired, regardless of whether this port also gates the delete_node op for echo-suppression, targeting, or teardown". That holds for echo-suppression and teardown — but not for targeting. Targeting drops the op precisely because the op belongs to a different document, so the doc named by operation.graphId is never written and does not lose the node. The bucket forgets an id the doc still holds.

I probed it at the port's own boundary, in the activation-scoped targeting describe:

it('PROBE2: delete while deactivated then reactivate', () => {
  activeRootGraphId = ACTIVATED
  deliver(rootScoped('createNode', ACTIVATED, '1'))
  expect(minted).toHaveLength(1)

  activeRootGraphId = OTHER
  minted.length = 0
  deliver(rootScoped('deleteNode', ACTIVATED, '1'))
  expect(minted).toEqual([])          // passes: delete_node correctly dropped

  activeRootGraphId = ACTIVATED
  minted.length = 0
  deliver(rootScoped('createNode', ACTIVATED, '1'))
  expect(minted).toEqual([])          // FAILS on the current head
})

Last assertion on 3283a84:

AssertionError: expected [ { op: 'add_node', …(4) } ] to deeply equal []

A second add_node for a node the doc already has — the exact shape #18109 fixed.

The fix looks like one line of movement: put the forget after isForActivatedDocument on line 297 and leave it above the gate on line 296. That keeps your stated reasoning intact — echo-suppression and teardown still don't block the forget — and only lets targeting, the one gate that means "this write isn't happening", condition it.

Reachability caveat, so you can weigh this properly: I demonstrated the gap at the port's API, not through the app. For a real sequence you need a root-owned per-node deleteNode to fire while a different root graph is activated. A tab switch reconfiguring the shared graph in place goes through the incidental clearGraph path instead, which you deliberately keep bucket-preserving — so it may be that nothing currently emits a root-owned per-node delete against a non-activated root. You know the change sources here far better than I do. I'd still move the line: it costs nothing and removes the need to keep that argument true as more root graphs become independently activatable, which is the whole direction of this stack.

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 the probe, fixed. In the deleteNode case, gated and forActivatedDocument are each computed exactly once now: gated = gate(change, inTeardown), then forActivatedDocument = !gated || isForActivatedDocument(operation, 'delete'). The || short-circuits, so isForActivatedDocument is never called once gated is already false, which avoids spurious op_for_inactive_document reports during ordinary echo/teardown gating.

The forget is now conditioned on operation.ownerGraphId === operation.graphId && forActivatedDocument, instead of running unconditionally on the ownership check alone, so a root-owned delete naming a graph that isn't the activated document no longer forgets the bucket. The enqueue path reuses the same two values rather than recomputing them.

Your probe is now 'does not re-mint a node whose delete was dropped for naming a non-activated graph (regression)' in layoutMintPort.test.ts, in the activation-scoped targeting describe block. Confirmed it fails red against the pre-fix code and passes green now.


Generated by Claude Code

mintedNodeIdsByRoot
.get(operation.graphId)
?.delete(String(operation.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.

suggestion (non-blocking): this condition is the one new guard in the commit that survives mutation — no test goes red without it.

I mutation-tested the three guards added here, the same way as last time:

Mutation Result
drop if (mintedNodeIds.has(nodeIdKey)) return (line 259) 3 tests red
replace this condition with if (true) 45 passed — survives
make the clear forget unconditional (drop captured !== null, line 325) 1 test red

Unlike the surviving mutation in my last review, this one is cheaply constructible — the file already builds interior-scoped ops with ownerGraphId: 'subgraph' (lines 123, 143, 157). This passes on the current head and goes red under the mutation:

it('does not let an interior delete forget the root bucket', () => {
  activeRootGraphId = ACTIVATED
  deliver(rootScoped('createNode', ACTIVATED, '1'))
  expect(minted).toHaveLength(1)
  minted.length = 0

  // Same root graphId, owned by a subgraph: a different node's namespace
  // that happens to reuse the id string '1'.
  deliver({
    operation: {
      type: 'deleteNode',
      actor: LOCAL_ACTOR,
      graphId: ACTIVATED,
      ownerGraphId: 'subgraph',
      nodeId: '1',
      layout: { position: { x: 1, y: 2 } }
    }
  } as unknown as LayoutChangeView)

  minted.length = 0
  deliver(rootScoped('createNode', ACTIVATED, '1'))
  expect(minted).toEqual([])
})

Without the guard it fails with expected [ { op: 'add_node', …(4) } ] to deeply equal []. Your comment already states this invariant precisely; this just stops a later simplification from quietly deleting it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added essentially as suggested: an interior delete on the same root graphId, with a node id that collides with one minted at the root, exercising the operation.ownerGraphId === operation.graphId guard on its own. Test is 'does not let an interior delete forget the root bucket' in layoutMintPort.test.ts, same describe block as the other new test.

Confirmed it fails under the if (true) mutation of that guard (the interior delete wrongly forgets the root's bucket) and passes against current code.


Generated by Claude Code

@dante01yoon dante01yoon removed their assignment Sep 23, 2026
@claude
claude Bot requested a review from dante01yoon September 23, 2026 11:06
@claude
claude Bot force-pushed the agent/tab-switch-activation-hooks branch from cf2ed3a to 14ed1dc Compare September 23, 2026 11:09
@DrJKL DrJKL added agent Comfy Agent product, integration, tests or product documentation agent-crdt Agent document synchronization, graph projection or CRDT operations agent-test-unit Touches Agent-related unit/component tests or their support agent-ui Agent panel, composer, transcript or other user-interface components labels Sep 24, 2026

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

Re-reviewed the current head after the follow-up. The blocking delete/dedupe path is fixed: a foreign root-owned delete no longer evicts the activated document’s dedupe entry, and the added regression reproduces the prior second-add_node failure. The interior-delete guard is now pinned as well. The activation-scoped targeting, clear rebind, and #18109 dedupe reconciliation remain coherent at this head. Hosted typecheck, lint, unit, E2E, and matrix gates are green; the cancelled snapshot/merge jobs are non-required workflow artifacts.

@DrJKL DrJKL left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did a fresh deep pass at 14ed1dc5 against the effective stacked base, including the load/activation interleavings and all three mint ports. Reluctant approval: I found no issue that should block this PR. The two concrete correctness gaps below are narrow enough to follow up without holding the stack, but they are real and have focused red probes.

Findings without a clean inline anchor
  • P2, concurrent direct loads remain completion-ordered. A focused workflow-service probe that starts A, starts B, resolves B, then resolves A leaves A active. Normal openWorkflow() calls are serialized, so this does not defeat the common tab-switch path. Several direct app.loadGraphData() callers remain outside that queue, though. An app-level test with two real overlapping loads would settle production reachability. I would keep the PR's existing explicit tradeoff, but narrow the body claim that common interleavings converge.
  • P3, duplicate serialized root IDs remain a systemic identity hole. Save As and in-app duplicate both remint IDs, so the earlier Save-As reproduction is false. Externally copied files can still collide, but the existing ECS stores already key by root ID and alias in that state. This PR should not grow a local activation-generation protocol to hide that broader load-time identity bug. The body should say the guard rejects differing root IDs, not that wrong-document mints are unrepresentable.
  • P3, targeting policy now has three owners. Layout, link, and widget ports independently compare activation state and report mismatches; layout and link also copy the same once-per-tick reporter. The behavior is coherent at this head, but the next targeting change has to land three times. A shared predicate/reporter at the wiring seam would reduce that drift.
  • P3, the PR description is stale. app.ts is touched, winner-only scope commit fixed the stated bindScope tradeoff, #18109's dedupe is now integrated, and the stated test counts/results no longer match this head. Please refresh it before the stack lands.
Existing findings checked
  • Missing graphId, rejected/superseded scope writes, stale detach, Clear Workflow rebind, foreign-clear capture consumption, layout/link/widget targeting asymmetry, link-report bursts, and the interior-delete dedupe guard are fixed at this head.
  • The post-deactivation failed-load state is intentional and already documented. openWorkflow() restores the retained workflow after a configure failure; direct/import failure paths can remain fail-closed. The pre-existing mint teardown bracket also suppresses the configure-throw path, so activation is not the operative cause there.
  • The duplicate-root-ID thread identifies a real system-wide limitation, but Save As and in-app duplicate remint IDs, and this PR does not own external-copy identity repair.
  • #18109's per-root dedupe is present and its previously reported foreign-delete and interior-delete regressions are covered.
Checked and cleared
  • The reproduced foreign-severance and disabled-delete probes were audited against the current source rather than accepted from green tests alone.
  • The widened local LayoutChangeView predates this PR; this diff makes graphId stricter, so I am not charging the existing structural type copy to this change.
  • Fallow's only new scoped hotspot is the 96-line layout onChange branch. It is hard to read, but the current sequencing is pinned by focused tests and does not justify blocking this behavior change.
  • The activation host's published view and registry scope have different lifetimes; they are not redundant sources of truth.
Coverage and verification
  • Deep lanes: correctness, maintainability, TypeScript/Vue idioms, tests, and documentation, split across activation-lifecycle and mint-delivery ownership shards.
  • Focused baseline: 9 files, 339 passed, 1 skipped.
  • pnpm typecheck: passed.
  • Focused red probes reproduced the two P2 inline defects. Mutation testing also showed the new link-report coalescing branch has no regression assertion.
  • CI is green for this head; cancelled snapshot/merge jobs are non-required workflow artifacts.

const forActivatedDocument =
!gated || isForActivatedDocument(operation, 'delete')
if (
operation.ownerGraphId === operation.graphId &&

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.

P2, non-blocking: !gated covers more than echo/teardown: it also covers isEnabled() === false, isDocBound() === false, and an unrecognized actor. Those cases do not prove this CRDT document lost the node, but this branch still forgets its dedupe entry. A focused create → disabled delete → re-enable/recreate probe produces two add_node mints for the same still-present document node. Please split the reasons that reconcile document membership from product/binding eligibility instead of treating every closed gate as a removal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3986119: layoutMintPort.ts#L296-L302.``

Split the two reasons apart as you suggested: forActivatedDocument is now only gated && isForActivatedDocument(...) (computed, with its side-effecting report, only once the gate is actually open), and a new docLostNode = forActivatedDocument || operation.source === 'agent-remote' is what gates forgetting the dedupe entry. Only an actual mint to the wire, or the local echo of a remote-applied removal (KA-6: remote applies never re-mint, so the doc already reflects them), counts as the doc losing the node. The product flag being off, no doc bound, teardown, or an actor this port doesn't recognize as local now leave the entry alone.

Added your exact probe as a regression: create → disable the flag → delete (dropped) → re-enable → recreate now mints once total, not twice. Also added the same case for isDocBound() === false, and a control test confirming a genuinely remote-echoed delete still forgets the entry (so a later create still mints, as it should). I confirmed the disabled-delete test fails against the pre-fix !gated || isForActivatedDocument(...) and passes after.


Generated by Claude Code

const entry: SeveranceEntry = {
linkId: topology.id,
mintable: gateOpen() && isRootScope(scope)
mintable:

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.

P2, non-blocking: this correctly marks a foreign severance non-mintable, but severances.take() below ignores mintable. Before the double-microtask sweep, take() returns that foreign link ID and a local delete_node can carry it in removed_links. The focused port probe receives [41] where [] is required. Either do not capture inactive severances or filter/consume non-mintable entries in take(). The existing test only checks that the delayed divergence logger stays quiet, so it misses this path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3986119: linkMintPort.ts#L226 — take() now skips an entry with !entry.mintable before it is ever considered against consumedLinkIds, so a foreign severance is neither returned nor marked consumed (the sweep already skipped it via mintable, so its behavior there is unchanged).

Added a regression to the existing 'never carries a foreign severance into a delete_node mint' test (linkMintPort.test.ts): after a FOREIGN_SCOPE removal, port.severances.take('2') / take('1') now assert []. I confirmed that assertion fails against the pre-fix take() — it returns [41], exactly the probe you described — and passes after this change.


Generated by Claude Code

deps: DocumentActivationHostDeps
): DocumentActivationHost {
let view: ActiveDocumentView | null = null
let requested: DocumentId | null = null

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.

P3: requested mirrors the coordinator's own pending request only because deactivate() is document-targeted. It remains set after settlement, and the host has to issue two deactivations to mean "cancel whatever may hold the canvas." Letting the coordinator cancel its own pending and active bindings would delete this second state machine and the synchronization proof around it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed this is real duplication, deferring rather than fixing here.

Letting the coordinator cancel its own pending-and-active bindings (so deactivate() no longer needs the host's separate requested tracking to mean "cancel whatever may hold the canvas") is a change to activationCoordinator.ts's own cancellation API, one layer down from this host. That's a good simplification, but it touches the coordinator #16375 shipped and this PR's host wraps, rather than being local to the file this thread is on. Leaving it as a follow-up.


Generated by Claude Code

isLoaded: (documentId) =>
documents.getDocument(documentId)?.state.phase === 'loaded',
commitScope: (documentId, scope) => {
if (!documents.hydrateDocument(documentId, scope))

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.

P3: this hydration branch is unreachable under the new contract. The coordinator calls commitScope only after isLoaded succeeded, and the workflow path calls markLoaded before activation, so hydrateDocument must return false here. A direct rebindScope(documentId, scope) would match the actual invariant and avoid suggesting activation can promote a created document.

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.

Agreed the branch is unreachable under the current contract, deferring rather than changing here.

Replacing if (!documents.hydrateDocument(documentId, scope)) documents.rebindScope(documentId, scope) with a direct rebindScope(documentId, scope) would match the actual invariant (commitScope only runs after isLoaded/markLoaded, so hydrateDocument can't still be looking at a created document here) and stop implying activation can promote one. It's a one-line change, but it's in src/stores/, a frozen directory per this PR's own tradeoffs list, so I'd rather have a human sign off on touching it than fold it into an already-large diff. Leaving it as a follow-up.


Generated by Claude Code

documentId: DocumentId,
scope: GraphScope
): Promise<ActivationOutcome>
/**

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.

P3: the root-canvas host accepts a general GraphScope, so the type permits rootGraphId !== owningGraphId. The host publishes the first value while committing both, which would make targeting and registry ownership disagree. Current callers preserve equality manually. Accepting a RootGraphId and deriving the owning ID here would encode the host's actual invariant.

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.

Agreed on the invariant, deferring the change rather than doing it here.

Narrowing activate's scope: GraphScope parameter to RootGraphId and deriving the owning id inside the host would encode rootGraphId === owningGraphId structurally instead of relying on every caller to construct the pair correctly by convention. But that's a signature change to DocumentActivationHost.activate (and to GraphScope construction at both call sites in workflowService.ts and app.ts's Clear Workflow rebind), on top of an already large diff that's had three rounds of review. Leaving it as a follow-up rather than adding another surface change to this PR.


Generated by Claude Code

function addNode(id: string): void {
nodes.set(id, {
id: toNodeId(id),
serialize: () => ({ id: Number(id), type: 'TestNode' })

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.

P3: this double assertion lets a two-field object impersonate LGraphNode, so changes to real node serialization cannot invalidate the integration fixture. LGraphNode is constructible in tests; using a real node or the repository's typed fixture would keep this test attached to the production contract.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3986119: tabSwitchActivation.test.ts#L96-L103.``

Used the repository's existing typed fixture helper — createMockLGraphNode from src/utils/__tests__/litegraphTestUtils.ts (backed by @total-typescript/shoehorn's fromPartial) — instead of the double as unknown as LGraphNode assertion. addNode now builds a real, type-checked partial LGraphNode with just id and serialize overridden, so it stays attached to the production shape instead of impersonating it.


Generated by Claude Code

const outcome = await useDocumentActivationStore().activate(
documentId,
scope
)

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.

P3: ActivationOutcome is a discriminated union, but this consumer only names rejected; activated, superseded, and any future status fall through as equivalent. An exhaustive switch would make a new terminal outcome fail typecheck here instead of silently restoring previews as if activation succeeded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3986119: workflowService.ts#L720-L739.``

The bare if (outcome.status === 'rejected') is now a switch that enumerates 'activated'/'superseded' (no-op) and 'rejected' (the existing reportError), with a default: outcome satisfies never. A future ActivationOutcome variant now fails typecheck here instead of silently falling through as a success. Ran pnpm typecheck clean and workflowService.test.ts (107 tests) still passes.


Generated by Claude Code

* Collapses a burst of identical drops into one signal: a tab switch emits a
* change per link, and each would otherwise report separately.
*/
function createOncePerTickReporter(): (

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.

P3: the new coalescer has no burst/reset assertion. Replacing the duplicate-key guard with a no-op leaves all 14 link-port tests green. A compact test should send two same-key drops in one tick, then one after a microtask, and assert report counts 1 then 2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3986119: linkMintPort.test.ts#L245-L261.``

Added the compact test as described: two same-key FOREIGN_SCOPE drops synchronously (consoleError called once), then a third after await Promise.resolve() (consoleError called twice total). I mutation-checked it by replacing the coalescer's duplicate-key guard with a no-op (return (key, report) => { report() }) — the new test fails (2 calls instead of 1 before the tick boundary) while it and the rest of the suite pass unmodified.


Generated by Claude Code

@DrJKL

DrJKL commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I want to record how unusually difficult this has been to review, because the difficulty is itself evidence about the code we are building on.

The patch is trying to make one fairly simple statement true: an operation produced for one workflow must never be written into another workflow's document. In a healthier design, that would be enforced by a document-scoped operation queue or an activation token carried with the operation. Here, establishing the same fact requires reconstructing several overlapping state machines spread across the app:

  1. One mutable LGraph instance is reused for every workflow and reconfigured in place.
  2. The workflow store separately decides which tab is active.
  3. The document registry separately records document lifecycle and graph scope.
  4. The activation coordinator separately decides which document currently owns the canvas.
  5. The agent panel separately decides whether its bound workflow is active by comparing tab paths.
  6. The layout, link, and widget mint ports separately decide whether an event belongs to the activated graph.
  7. The mint session separately brackets graph teardown.
  8. A per-root set separately remembers which node IDs were already minted.
  9. The link port separately captures severances for later consumption by the layout port.
  10. Clear Workflow bypasses the normal load lifecycle, remints the root graph ID, and needs a special rebind path.

None of those statements is merely background context. A reviewer has to hold all ten in mind at once to determine whether moving one line is correct.

The delete path is the clearest example. Whether deleting one entry from mintedNodeIdsByRoot is correct depends on all of the following:

  • whether the event came from the local actor;
  • whether it was a remote echo;
  • whether the agent feature flag is enabled;
  • whether the agent document is bound;
  • whether graph teardown is in progress;
  • whether the operation targets the activated root graph;
  • whether the operation is root-owned or belongs to an interior subgraph;
  • whether the CRDT document has already observed the deletion through another path; and
  • whether a later create is a replay, redo, or genuinely new node reusing the same ID.

That is why a condition which looks reasonable in isolation, !gated || isForActivatedDocument(...), still required a focused red probe to show that a disabled delete can discard dedupe state for a node the document never lost. The comment above the branch says a gated deletion means "an echo or teardown no-op," but gate() also includes the product flag, binding state, and actor classification. The prose describes a narrower state space than the function implements. Reviewing this is less like reviewing application logic and more like manually model-checking an undocumented protocol.

The link path has the same problem in a different form. The new targeting condition correctly marks a foreign severance as non-mintable. That looks fixed until the reviewer follows the entry into the transient severance map, follows the double-microtask cleanup schedule, notices that take() ignores mintable, and constructs the same-tick sequence in which a local delete_node consumes the foreign link ID before cleanup. The unit test named "never carries a foreign severance into a delete_node mint" does not call take(), so it passes while the behavior in its title is false. That is not a normal local review. It requires tracing one store event through two ports and three scheduling phases.

The workflow side is no easier. The activation lifecycle is split between beforeLoadNewGraph, afterLoadNewGraph, afterConfigureGraph, the workflow load queue, several direct app.loadGraphData() callers, loadApiJson, A1111 import, retained-workflow recovery, and the special app.clean() rebind. To decide whether a failed load is safe, a reviewer must distinguish at least these cases:

  • failure before deactivation, where retaining the outgoing binding is correct;
  • failure after deactivation but before graph mutation;
  • failure after cleaning the shared graph;
  • failure during configure() while the mint teardown bracket remains open;
  • failure after afterConfigureGraph closes that bracket but before document activation;
  • failure through serialized openWorkflow(), which attempts retained-workflow recovery; and
  • failure through a direct load/import caller, which may not recover.

Again, comments flatten these cases into claims such as "a failed load leaves nothing activated" or "every graph load funnels through here." Those claims are close enough to sound useful and broad enough to be wrong at important boundaries. The PR description itself became stale while the review was in progress: it says app.ts is untouched, says losing activations still commit scope, says #18109 is not integrated, and reports test counts that no longer match the head. That is understandable given how many follow-up fixes landed, but it further raises the review cost because the description cannot be trusted as a current map.

The types do not provide much relief. LayoutChangeView is a hand-written structural copy with a string discriminator and optional variant fields instead of the authoritative LayoutOperation union. DocumentActivationHost.activate() accepts a general GraphScope even though this host only makes sense when rootGraphId === owningGraphId. Tests use as unknown as LGraphNode for objects that are not real nodes. The type checker therefore cannot establish several of the invariants a reviewer actually cares about. We prove them by searching every caller and reading comments.

The tests also mirror the architecture instead of exercising it. The large tab-switch integration suite manually performs deactivate, graph mutation, mark-loaded, and activate steps. It is useful for the host and mint boundary, but it does not execute the workflow adapter whose ordering it is supposed to represent. The host's rapid-switch test proves that the coordinator chooses the newest request presented to it. It does not prove that concurrent workflow loads present requests in user-intent order rather than completion order. A focused probe can resolve B and then A and leave A active, while all of the existing rapid-switch tests remain green.

This is the recurring pattern throughout the patch: a local fix is often reasonable, but determining whether it is correct requires reconstructing hidden coupling elsewhere.

  • Adding an activation check to layout is insufficient until link and widget paths are audited.
  • Adding an activation check to link deletion is insufficient until severance consumption is audited.
  • Moving dedupe deletion below targeting is insufficient until every other reason the combined gate can close is separated.
  • Rebinding after clear() is insufficient until the intentional-clear capture retains the pre-clear ID.
  • Deferring scope commit until activation wins is insufficient until document loading is separated from scope hydration.
  • Protecting detach by document ID is insufficient once the same document can be rebound to a new graph ID, which then requires binding identity.

Each fix exposes the next hidden dependency. That is a strong sign that we are treating architectural problems with increasingly careful local patches.

I am approving because the common tab-switch path is materially safer, the known high-severity review findings were addressed, the focused suite is strong, and the remaining reproduced defects are narrow. This should not be read as confidence that the underlying design is now easy to reason about. It is not. The code currently demands that every reviewer rediscover the same distributed protocol and manually check its interleavings.

The follow-up work I would most like to see is not another guard. It is a reduction in the number of independent facts:

  1. Put graph replacement and document activation behind one transaction-like owner. Callers should not manually pair before/after hooks.
  2. Carry document identity or an activation generation with queued operations. A persisted graph UUID is scope, not document identity.
  3. Centralize the targeting predicate and mismatch reporting used by layout, link, and widget ports.
  4. Replace the panel-lifetime mintedNodeIdsByRoot mirror with authoritative document membership, or at minimum scope and retire it by document lifecycle.
  5. Make severance capture graph-scoped and make consumption honor the same eligibility rule as capture.
  6. Derive the mint-port operation type from the authoritative discriminated union.
  7. Drive at least one integration test through the real workflow load entry point, including reversed async completion and post-deactivation failure.

Until those ownership problems are fixed, reviews in this area will remain disproportionately expensive. Small diffs will continue to require large proofs, comments will continue to encode invariants the types cannot express, and apparently harmless line movement will continue to reopen bugs in another state machine. The patch is doing serious work to contain that situation. It is also a vivid demonstration that containment is not the same thing as repair.

Two review-flagged correctness gaps in the tab-switch activation mint ports:

- linkMintPort's severance take() ignored the mintable flag, so a foreign
  (non-activated-document) severance could still be handed back and carried
  into a local delete_node's removed_links. take() now skips non-mintable
  entries.
- layoutMintPort's deleteNode branch forgot the mint-dedupe entry on every
  closed gate, including the product flag being off, no doc bound, or an
  unrecognized actor - none of which mean the CRDT document actually lost
  the node. Forgetting is now gated on either an actual mint to the wire or
  a local echo of a remote-applied removal.

Also:
- workflowService's document-activation outcome switch is now exhaustive
  over ActivationOutcome instead of only checking for 'rejected'.
- tabSwitchActivation.test.ts builds its LGraphNode test fixture through
  the existing createMockLGraphNode helper instead of a double type
  assertion.
- linkMintPort's once-per-tick drop coalescer now has a regression test
  pinning its burst/reset behavior.

Regression tests included for all of the above; the new layoutMintPort and
linkMintPort cases fail against the pre-fix code and pass after.
@christian-byrne

Copy link
Copy Markdown
Contributor

Flagging rather than blocking, found tracing the hook pair: the activation is retracted and republished on every undo and redo. Still true at 3986119ac7.

beforeLoadNewGraph calls useDocumentActivationStore().deactivate() outside the if (activeWorkflow) guard and ungated by suppressWorkflowReset. ChangeTracker.updateState calls app.loadGraphData(prevState, false, false, this.workflow, …), which reaches beforeLoadNewGraph(false) at app.ts:1298 and afterLoadNewGraph at app.ts:1584. So an undo runs the full retract/activate pair.

In that window activeRootGraphId() is null and layoutMintPort drops root-scoped ops fail-closed. That's right for a tab switch, where no document owns the canvas. It's less obviously right for an undo, where the same document owns the canvas before and after and the op is dropped rather than applied. The window spans two invokeExtensionsAsync calls and a graph configure, so it isn't a microtask.

The endpoints are fine: clean = false on that path means this.clean() is skipped, the root graph id doesn't rotate, and the same documentId is re-activated. The gap is the defect, not the endpoints.

ADR-GRAPH-DOCUMENT-0026's Phase 1 calls out this exact hook pair — "cannot simply be renamed into Deactivate/Activate because they also fire on undo/redo … the bus must gate on document-identity change, not on graph load". This PR is the first to hook them.

There's no test for it. undo, redo and changeTracker appear in none of the three test files this PR adds or changes, except as a mock fixture. That lines up with @DrJKL's follow-up 7 above: drive at least one integration test through the real workflow load entry point.

Three ways to go:

  1. Gate on identity change, retracting only when the incoming document differs. What the ADR actually asks for. The caller doesn't know the incoming document at that point, so it means threading it down or deferring the retraction — a real design change, and presumably why this PR didn't do it.
  2. Gate on suppressWorkflowReset. Undo passes clean = false, as do loadApiJson and the path at app.ts:2338. Cheap, but it couples "don't reset the workflow" to "don't retract the binding", which are different questions that happen to coincide today.
  3. Accept and cover: keep the retraction unconditional, add a test asserting the undo/redo round trip republishes the same {documentId, rootGraphId}, and record the in-window drop as a known limitation with a sunset tied to the lifecycle bus.

I'd take 3. It matches how this PR already handles its other four tradeoffs, named in the body rather than left to be found, and 1 belongs with the phase that actually builds the bus.

What I have not established: whether a user can actually lose an agent edit this way. That needs the CRDT follower proven to be delivering during a loadGraphData, which depends on isDocBound and is out of scope here. So this is "ops are dropped by construction, untested, and contradicts the ADR constraint written for this hook pair", not "this loses user data".

beforeLoadNewGraph/afterLoadNewGraph also fire on undo and redo
(ChangeTracker.updateState -> app.loadGraphData with
suppressWorkflowReset = false), not just tab switches, and nothing
previously exercised that path. Add a regression asserting the same
{documentId, rootGraphId} is republished at the end of the round trip.
@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

@christian-byrne re #18326 (comment) — went with option 3, as you suggested.

  • Added workflowService.test.ts > "document activation" > "republishes the same document and root graph id across an undo/redo round trip" — activates a document, runs beforeLoadNewGraph(false) (the suppressWorkflowReset = false shape ChangeTracker.updateState uses), asserts the binding is retracted (activeRootGraphId() null) in that window, then runs afterLoadNewGraph again and asserts the same {documentId, rootGraphId} comes back. Commit 0242867.
  • Added a known-limitation bullet to the PR body's Tradeoffs section describing the in-window drop during undo/redo and pointing at ADR-GRAPH-DOCUMENT-0026 Phase 1 as where the real fix (gating on document-identity change) belongs, matching how the other four tradeoffs are already documented there.

No change to the retraction itself — it stays unconditional, per option 3.


Generated by Claude Code

@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Replying to the three "findings without a clean inline anchor" from @DrJKL's review (#pullrequestreview-5312863565), plus confirming the fourth (stale PR description). Individual inline replies to the two correctness bugs and the smaller nits are posted on their respective threads; commit 3986119.

Concurrent direct loads (P2). Not fixing the underlying gap here — narrowed the PR body's tradeoffs bullet instead: it now says plainly that openWorkflow()'s serialization covers the common tab-switch path, but some direct app.loadGraphData() callers remain outside that queue, rather than implying all interleavings converge.

Duplicate serialized root IDs (P3). Not growing a local activation-generation protocol for this. Added a tradeoffs bullet noting it's a broader, pre-existing load-time identity issue outside this PR's scope — Save As and in-app duplicate already remint IDs, so the residual case is an externally copied file colliding on id, which the existing ECS stores already key around.

Targeting policy duplicated across mint ports (P3). Agreed, and left as a follow-up rather than fixed here — added a tradeoffs bullet naming a shared predicate/reporter at the wiring seam as the right next step, since the layout/link/widget ports each independently compare activation state today.

PR description staleness (P3, 9d). Refreshed. app.ts is now called out as carrying the Clear Workflow rebind (it's no longer described as untouched); the bindScope-before-generation-race tradeoff bullet is removed since commitScope now only runs on a winning activated outcome; the "Compared with #18109" section now says the dedupe is integrated (operation.graphId-keyed, per your delta review) instead of "not yet merged"; and the Tests section's counts/descriptions match the current head (documentActivationHost 17, tabSwitchActivation 8, layoutMintPort 50, linkMintPort 15, plus the new workflowService.ts undo/redo regression from @christian-byrne's follow-up finding).


Generated by Claude Code

@claude
claude Bot requested review from DrJKL and dante01yoon September 25, 2026 03:49
@christian-byrne

Copy link
Copy Markdown
Contributor

Closing per the call on this: close it and re-derive the fix later.

The behaviour it fixes is real and still wanted — switching tabs should not stack duplicate copies of your nodes. What does not survive is the branch. Its base (feat/graph-document-activation-search) was never merged, so the two approvals on this PR never moved it any closer to landing; approving a PR whose base is unmerged changes nothing about what ships.

Re-deriving against current main will also be cheaper than rebasing this, because the activation-coordinator seam it is built on is part of what the remote-apply rewrite replaces.

Not a rejection of the fix. Reopen or re-author when the duplicate-nodes bug is picked up against a base that can actually land.

This branch had an error being deployed

1 failed deployment
Preview – billing-web-test — 02428672 Deployed Sep 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Comfy Agent product, integration, tests or product documentation agent-crdt Agent document synchronization, graph projection or CRDT operations agent-test-unit Touches Agent-related unit/component tests or their support agent-ui Agent panel, composer, transcript or other user-interface components cloud/1.54 Backport PRs for cloud 1.54 core/1.54 Backport PRs for core 1.54 cursor-review Trigger multi-model Cursor agent review on this PR needs-backport Fix/change that needs to be cherry-picked to the current feature freeze branch risk:xhigh PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants