Repository navigation
fix: decouple subgraph preview/output display from the promotion system - #14569
claude[bot] wants to merge 28 commits into
Conversation
…or preview Two KSamplers in one subgraph, only one wired into previewExposureStore (the other simulates a node added after the subgraph's one-shot auto-expose already ran). The unit test targets the not-yet-existing useAmbientSubgraphPreviews composable; the e2e spec drives two live b_preview WS frames at distinct interior execution IDs and asserts both show on the collapsed SubgraphNode host.
…t exposures Subgraph previews were 1:1 with previewExposureStore, so a second interior node producing output concurrently (e.g. a 2nd KSampler with no exposure) had nowhere to render and stayed invisible on the collapsed host. Add useAmbientSubgraphPreviews, a computed rollup that mirrors how executionStore's nodeLocationProgressStates bubbles up progress regardless of promotion: it reads each direct interior node's own output/preview state from nodeOutputStore, independent of exposures. LGraphNode.vue merges it underneath the existing exposure-driven promotedPreviews (an explicit exposure still wins for that node), so every concurrently-executing interior node shows and updates on its own, not just the promoted one.
🎭 Playwright: ✅ 1917 passed, 0 failed · 1 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook📦 Bundle: 9.68 MB gzip 🔴 +2 kBDetailsSummary
Category Glance App Entry Points — 3.74 kB (baseline 3.74 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.43 MB (baseline 1.42 MB) • 🔴 +4.89 kBGraph editor runtime, canvas, workflow orchestration
Status: 2 added / 2 removed / 1 unchanged Views & Navigation — 124 kB (baseline 124 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 13 added / 13 removed / 4 unchanged Panels & Settings — 621 kB (baseline 621 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 10 added / 10 removed / 17 unchanged User & Accounts — 27.8 kB (baseline 27.8 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 6 added / 6 removed / 5 unchanged Editors & Dialogs — 126 kB (baseline 126 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 7 added / 7 removed / 1 unchanged UI Components — 117 kB (baseline 117 kB) • ⚪ 0 BReusable component library chunks
Status: 7 added / 7 removed / 8 unchanged Data & Services — 3.59 MB (baseline 3.59 MB) • 🔴 +2.61 kBStores, services, APIs, and repositories
Status: 13 added / 13 removed / 3 unchanged Utilities & Hooks — 560 kB (baseline 560 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 18 added / 18 removed / 18 unchanged Vendor & Third-Party — 18.1 MB (baseline 18.1 MB) • ⚪ 0 BExternal libraries and shared vendor chunks Status: 18 unchanged Other — 16.4 MB (baseline 16.4 MB) • ⚪ 0 BBundles that do not match a named category
Status: 72 added / 72 removed / 223 unchanged ⚡ Performance
|
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #14569 +/- ##
==========================================
+ Coverage 80.89% 82.48% +1.59%
==========================================
Files 2450 2034 -416
Lines 125020 117636 -7384
Branches 31558 32843 +1285
==========================================
- Hits 101133 97035 -4098
+ Misses 23374 20423 -2951
+ Partials 513 178 -335
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 426 files with indirect coverage changes 🚀 New features to boost your workflow:
|
useAmbientSubgraphPreviews treated any interior node with images in nodeOutputStore as a live preview candidate, including nodes whose only "output" is an input-type reference (e.g. an unpromoted LoadImage node's own selected file). That made every such node's thumbnail always visible on the collapsed subgraph host regardless of promotion state, breaking promotion exclusivity. CI caught this: browser_tests/tests/subgraph/subgraphPromotion.spec.ts "Can promote multiple previews" > "Promote both image previews" failed consistently (all 4 attempts) on PR #14569 - after promoting only one of two Load Image previews, the host showed 2 preview elements instead of 1, because the unpromoted node's own file leaked in via the new ambient rollup. Export isInputPreviewOutput from nodeOutputStore and use it to skip input-only outputs in the ambient computed, so only genuine live execution results (or streaming preview frames) surface ambiently - matching the feature's stated intent (a second concurrently-executing node with no exposure), not static input previews. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FCL4Meqh8o8VYh9xV1h1Ky
📄 Knowledge reviewDosu skipped reviewing this PR because your organization has used its |
|
Ported the three artifacts from #14551 per Christian's closing comment (commit 42b7c92):
Generated by Claude Code |
|
Hey, that sounds like an elegant solution. Is there any news on when this could be merged ? |
christian-byrne
left a comment
There was a problem hiding this comment.
Multi-agent review: 10 reviewer agents, a verification gate over the compiled findings, and an adversarial cut pass. Re-verified against 62b52fd after the two commits that landed mid-review; the SamplerCustomAdvanced port from #14551 is here and appreciated, and the comment cleanup did not change any of the findings below.
One item that does not anchor to a line, and one correction of my own:
Scope. This changes the Vue node renderer only. The classic litegraph canvas resolves host previews from previewExposureStore alone (litegraphService.ts:193), and Comfy.VueNodes.Enabled is defaultValue: false with defaultsByInstallVersion: { '1.41.0': isCloud || isDesktop }, so OSS local installs are still on the unfixed path. Classic-canvas parity is the other half of this incident.
Correction, mine. I added Fixes #9859 to this PR body earlier and have since downgraded it. #9859 says verbatim "In LG mode, live previews ... can no longer be shown ... In nodes 2.0 it works" — it is a classic-mode report that this PR provably does not fix, and the keyword would have auto-closed it. #14597 does not state its renderer either, so it is now Refs as well. Worth confirming the renderer on both before closing anything.
Follow-ups worth their own PRs rather than changes here: previews are keyed by subgraph definition id throughout nodeOutputStore, so two host instances of one definition share previews (pre-existing, and not fixed by the change suggested below either); nested subgraph hosts never bubble to an outer host even though the ancestor fan-out at app.ts:861 already writes that data to the nested host's locator.
|
Addressed all 8 line-level findings from the latest review round:
Also saw your scope note on classic-canvas parity and the Generated by Claude Code |
|
Status for whoever picks this up next. @DrJKL adding you as co-assignee since you own this area ( Two things worth deciding before this merges, both of which outlive this PR: Bug 2a is still unowned. The Classic canvas was scoped out on 2026-08-04 and never revisited. Also worth linking, both unfiled against this incident: https://linear.app/comfyorg/issue/FE-616 ("Multiple subgraphs on one canvas get same previews from each other", closed as Duplicate with no target) is the same definition-scoped locator bleed that still exists in |
|
Per Christian's Slack ask, expanded e2e (+1 unit) coverage for pathways beyond the two original specs. Summary of what I audited and added: New e2e specs (
Unit: Audited, not covered (flagging rather than guessing):
|
…-preview-outputs # Conflicts: # src/stores/nodeOutputStore.ts
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I'm in favor of this PR's direction. Deriving host previews from live execution state is additive, leaves the promotion path untouched, and carries a far smaller regression surface than introducing a registry concept this codebase has no precedent for. It also matches a shape that already exists here: values pushed up from the backend behave much more like execution progress, which nodeLocationProgressStates already bubbles to a host regardless of promotion, than like a promoted widget.
On graph:previews — I only have the one line to go on, so correct me if I'm reading it wrong. What I take it to mean is that previews stop being derived at render time and become something producers write into and the renderer simply reads. If that's roughly it, the part I find most appealing is that it removes the merge: today LGraphNode.vue reconciles two independently derived lists itself, and an ambient entry has to masquerade as a promoted one to get there — same PromotedPreview type, a synthetic $$ambient-preview name standing in for a widget nobody promoted, and an exposure winning whenever both cover the same node. That end state does read cleaner to me than what we have.
Whichever shape it actually takes, though, I don't think it should be this PR, and the reason is everything below. What I ran into is not about which mechanism delivers a preview; it is about how a preview is identified once it arrives — leaf-local ids in places that need root-relative execution paths. Any design still has to key its entries on those identifiers, so a rewrite would inherit all of it, in new and less-tested code. Settling identity first makes that rewrite smaller if it happens; doing it in the other order carries these bugs into it.
While thinking that through I ran into a few concerns, one behavior I'd call a bug in this PR, and two issues that predate it. Sharing them here.
1. The ambient rollup never fires for a host that is itself nested
useAmbientSubgraphPreviews.ts:77 builds hostExecutionId from tryNormalizeNodeExecutionId(node.id) — the host's local id — then appends the interior id at :85. nodePreviewImagesByExecutionId is keyed by the root-relative path the backend sends (display_node_id), so the two only line up when the host sits directly in the root graph.
Fixture: root node 9 = Outer Host → node 10 = Inner Host → KSampler 11. Driving a frame at the correct full path 9:10:11, instrumented:
{ nodeId: "10", title: "Inner Host", hostExecutionId: "10" }
{ host: "10", interior: "11", executionId: "10:11", hit: false }
The composable looks up 10:11 while the frame is stored at 9:10:11, and the host renders nothing. The root-level control in the same suite passes, so this is specifically the nesting case.
The inverse — a nested host picking up an unrelated node whose root-relative path equals its truncated key — I could not provoke, and one of the green scenarios pins that (with an anchor assertion proving the frame had landed first). So: miss confirmed, false-positive not demonstrated.
Is depth-1 scope intended to the point of "a nested host shows nothing ambiently"? If so, an explicit bail when the host's graph isn't the root would state it, and the docblock's nodeLocationProgressStates analogy (that store bubbles at every path prefix) is worth softening.
2. Load-time id dedup does not remap previewExposures
Not this PR's doing, but it changes how I read the original report.
LGraph.configure runs normalizeSubgraphDefinitions → deduplicateSubgraphNodeIds (subgraphDeduplication.ts:175), which renumbers interior node ids that collide across subgraph definitions (Comfy.Graph.DeduplicateSubgraphNodeIds, default on). It patches links, promoted widgets and legacy proxyWidgets — but nothing in that file touches previewExposures. A remapPreviewExposures helper does exist at LGraphCanvas.ts:9023, wired only into the clipboard path.
Loading a workflow with two definitions that both use interior id 3, the second host declaring previewExposures: [{ sourceNodeId: "3", ... }]:
Host A previewExposures: [{ sourceNodeId: "3" }] interior: [{ id: "4", title: "A Sampler" }]
Host B (none) interior: [{ id: "3", title: "B Sampler" }]
The interior node became 4; the exposure still points at 3. usePromotedPreviews then hits leafHost.subgraph.getNodeById(3) → undefined and returns [], so the promoted preview is silently gone after a reload. Same result from a unit-level repro against deduplicateSubgraphNodeIds directly (expected "4", received "3").
Driving a frame at the real path 1:4 on that fixture: 1 preview with this PR's ambient path, 0 with the ambient computed stubbed to []. So this PR incidentally repairs the user-visible symptom for root-level hosts, and I suspect this is one of the mechanisms behind the original "only one of my two KSamplers previews" report — the surviving one being whichever definition kept its ids.
Worth its own issue: patch previewExposures in deduplicateClonedSubgraphNodeIds the way patchProxyWidgets already handles host-side references, reusing the clipboard helper.
3. Two of the four new e2e specs pass with the ambient path entirely removed
Stubbing useAmbientSubgraphPreviews's computed to return []:
| spec | ambient disabled | promoted disabled |
|---|---|---|
subgraphConcurrentPreviews (2 tests) |
fail | — |
subgraphPreviewAllowlistGap |
fail | — |
subgraphNestedAmbientPreviewScope |
pass | fail |
subgraphAmbientCommittedOutputIsolation |
pass | fail |
The first two genuinely pin this PR's behavior. The last two are carried entirely by the promotion path: LGraph.configure calls LGraph.autoExposePreviewNodes (LGraph.ts:2989) on load, neither fixture declares a previewExposures property so the one-shot gate doesn't block, and the interior KSampler is allowlisted — so those hosts acquire an exposure at load time and usePromotedPreviews satisfies the assertions.
subgraphNestedAmbientPreviewScope states in a comment that the fixture "only passes if the ambient rollup — not the exposure/promotion system — is what surfaces the preview", which the mutation contradicts. Given (1), it cannot be exercising ambient at that depth at all.
The fix is two lines: add "previewExposures": [] to the hosts in both fixtures, which trips the one-shot gate and stops auto-promotion from satisfying the assertion, and the specs start testing what they claim.
4. A chained exposure is dropped when its leaf shares a local id with a sibling
usePromotedPreviews.ts:156 labels each display item with the chain-resolved leaf id, which lives in the nested subgraph's id space, while sibling entries use the host's own id space.
Fixture: Host A (root node 1) exposes its own sampler (node 3) and, through Nested B (node 5), that subgraph's sampler — also numbered 3. Frames at 1:3 and 1:5:3:
| frames sent | previews rendered |
|---|---|
1:3 only |
1 |
1:5:3 only |
0 |
| both | 1 |
both, control fixture with the leaf renumbered to 7 (1:5:7) |
2 |
So the chained entry is lost specifically because of the shared local id. It is dropped before render, not by the v-for key — no Vue duplicate-key warning appears, so usePromotedPreviews is emitting one entry rather than two colliding ones. I did not isolate which step inside the chain resolution swallows it.
Reachability caveat: colliding interior ids only survive a load with Comfy.Graph.DeduplicateSubgraphNodeIds off, so this is a narrower path than (1) or (2) — but it is the same identifier-shape problem behind the first-hop exclusion-set workaround in mergeSubgraphPreviews.
leafExecutionId is computed at usePromotedPreviews.ts:140 and discarded one line later, and useAmbientSubgraphPreviews likewise already has its appended execution id. If the field carried that instead (renamed accordingly), identifiers would be unique by construction and deduping ambient against promoted's own execution ids would become correct on its own. PromotedPreview is runtime-only, so the persisted previewExposures shape is unaffected, and the only consumers are the render key and mergeSubgraphPreviews; NodeContent reads just type/urls.
5. LGraphNode.vue:644 uses the legacy exposure key form
Code reading only — it is unobservable while (1) holds, since ambient produces nothing for a nested host to dedup against.
It passes String(node.id); every other getExposures call site uses getPreviewExposureHostLocator, and SubgraphNode.ts:531-539 migrates plain-id keys to locator keys and then clears the legacy entry. For a nested host the exclusion set is therefore always empty. mergeSubgraphPreviews's own docblock asks for getExposures(rootGraphId, hostLocator), so the call site and the contract disagree. It stops being benign the moment (1) is fixed.
None of this reads to me as a case for redesigning the PR — I'm offering it as a different lens on it. (2) is if anything an argument for landing it sooner. (5) is a one-liner. (3) I'd like fixed here, since it's two fixture lines and without them the nested and committed-output cases are pinned by the old code path rather than the new one. (1) mainly needs an explicit decision — scope it deliberately with a guard, or file it — rather than being left to be found later. (2) and (4) are separate issues that predate this PR.
I tried to reproduce what I've described above as e2e scenarios, against 52f6404d3 with a live backend. Six of them, three red and three green, where the green ones exist to isolate the cause of each red one:
✓ a root-level host surfaces every unexposed interior node that is live
✘ a host nested inside another subgraph surfaces its own interior live preview → 0, want 1
✓ a nested host ignores an unrelated node whose path equals its truncated key
✘ load-time subgraph id dedup keeps previewExposures pointing at a node that exists → "3" vs interior ["4"]
✘ a chained exposure still renders when its leaf shares a local id with a sibling → 1, want 2
✓ control: the same chain renders both previews once the leaf id is unique
Every fixture declares an explicit previewExposures on its hosts, which trips the properties.previewExposures !== undefined gate in autoExposeKnownPreviewNodes and stops load-time auto-promotion from quietly satisfying the assertion — the same point as (3).
I've put those up as a stacked PR on this branch: #16654. It is verification only, not for merging — no production code, and three of its scenarios plus one unit test are expected to fail, which is the evidence. Its description walks through all six scenarios and what each one establishes.
DrJKL
left a comment
There was a problem hiding this comment.
Review: read through the ECS lens
Short version: the symptom in #14597 / #9859 is real, but I don't think this PR is the right shape for it. The data the host needs is already in nodeOutputStore today; the bug is a one-line render guard in LGraphNode.vue, not a missing data path. The PR instead adds a second preview map to the store, a consumer-side graph walk, a callback monkey-patch on Subgraph, and a three-way merge in the component. Each of those moves us away from where we're trying to go (stores as component registries keyed by stable entity ids; systems as pure functions; no callback growth on litegraph classes).
I'd recommend: ship the small guard fix (Design A below, ~10 lines, one file, flips the PR's two it.fails / test.fail() tests green), decide the ADR 0009 removal question explicitly, and track the execution-id re-key of nodePreviewImages (Design B) as a separate follow-up that starts with the navigation store.
Not assuming any of this is settled; happy to be argued out of it in the threads.
1. The host already has the frame. The bug is the guard, not the data.
app.ts writes every b_preview_with_metadata frame to every ancestor execution id. For an interior sampler 11:10, that means setNodePreviewsByExecutionId('11', …) and setNodePreviewsByExecutionId('11:10', …). The host's own locator ("11") in nodeOutputStore.nodePreviewImages therefore already holds the latest live frame, and because the host lives in the parent graph, that locator is per-instance: hosts 11 and 12 sharing one definition each get their own frame. I verified this against main with a throwaway vitest probe; only the interior locator <uuid>:10 collapses (last writer wins).
What stops the frame from rendering is LGraphNode.vue:172:
<LivePreview v-if="shouldShowPreviewImg && !lgraphNode?.isSubgraphNode()" />That guard came in with #12197 (ADR 0009), presumably to avoid showing the same sampler twice when it is also promoted. The PR's own expected-fail tests (LGraphNode.test.ts:559, imagePreview.spec.ts:192) assert exactly this: relax the guard and the host renders.
Current data flow on main (mermaid)
flowchart LR
WS["b_preview_with_metadata<br/>displayNodeId = 11:10"] --> APP["app.ts handler"]
APP -->|"getAncestorExecutionIds → ['11', '11:10']"| STORE
subgraph STORE["nodeOutputStore.nodePreviewImages (keyed by NodeLocatorId)"]
H11["'11' → [frame]"]
I10["'<uuid>:10' → [frame]"]
end
H11 --> HPS["useNodePreviewState(host 11)<br/>latestPreviewUrl = frame"]
HPS --> GUARD{{"LGraphNode.vue:172<br/>!isSubgraphNode()"}}
GUARD -->|"false → suppressed"| X["nothing rendered"]
I10 --> PP["usePromotedPreviews(host 11)<br/>only if exposure exists"]
PP --> NC["NodeContent v-for"]
The frame reaches the host; the guard throws it away. Nothing in the PR's new machinery is needed to get a frame onto the host.
Why "two concurrent interior previews" isn't the requirement
Both linked issues describe one sampler's preview not showing on the host. The backend executes nodes within a prompt sequentially, so at any instant there is at most one live frame per prompt. The e2e specs in this PR push two WebSocket frames for two different samplers back to back to exercise the multi-preview path; that is a synthetic scenario. It is a reasonable thing to support eventually, but it is not what the bug reports ask for, and it is what most of the added code exists to serve.
2. nodePreviewImagesByExecutionId is a second source of truth for the same fact
The store change adds a parallel Record<string, string[]> with its own retain/release, its own scheduledRevokeByExecutionId, its own loop in revokeAllPreviews, while setNodePreviewsByExecutionId still writes the locator map too. Every frame is now stored twice, refcounted twice, and revoked twice, and the two maps can drift (a caller of setNodePreviewsByLocatorId writes one and not the other).
In ECS terms: a component should have one registry keyed by one entity id. If the locator key is wrong for interior previews (it is, for cloned subgraphs), the fix is to re-key the registry, not to add a sibling registry and hope every consumer picks the right one.
What re-keying would touch, and why it's a separate PR
Readers of nodePreviewImages on main that would need to move to an execution-id key:
src/composables/node/useVideoSourceUrl.ts:146src/composables/widgets/useImageCrop.ts:599src/composables/widgets/usePainter.ts:725src/composables/widgets/useBoundingBoxes.ts:746src/renderer/extensions/vueNodes/widgets/components/WidgetCompositor.vue:110src/renderer/extensions/vueNodes/glsl/useGLSLPreview.ts:271src/composables/node/useNodeImage.ts:71src/composables/node/usePromotedPreviews.ts:46-76src/services/litegraphService.ts:805-811app.nodePreviewImagesmirror (app.ts:336, 492), which is extension-facing
That's a real migration and belongs in its own PR with its own migration note. It should not ride along with a bug fix, and the bug fix should not pre-commit us to a parallel-map shape in the meantime.
3. useAmbientSubgraphPreviews is consumer-side enumeration plus a callback monkey-patch
The composable walks host.subgraph.nodes from inside a computed, and to make that reactive it installs subgraph.onNodeAdded = useChainCallback(...) (and onNodeRemoved) via a module-level WeakMap<Subgraph, Ref<number>>. Concerns, in order of weight:
- It mutates a litegraph callback from render-time code. ADR 0003/0008 push us away from callback growth on
LGraph/Subgraph; this is the same pattern wearing a WeakMap. - Reactive membership already exists:
graph.eventsemits'node:added'/'node:removed', andnodeDataStore.getGraphNodesFor(rootGraphId, owningGraphId)is a reactive query over the node component registry. Neither is used. - The host doesn't need to enumerate interior nodes at all to render the live frame (finding 1). The walk exists only to produce the
PromotedPreviewshape so the result can be merged with real promoted previews. hostExecutionId = tryNormalizeNodeExecutionId(node.id)uses the host's barenode.id. For a host that is itself inside a subgraph (11:5, interior11:5:10), this looks up5:10, which is the wrong execution id and collides across parents.usePromotedPreviewsavoids this by usinggetPreviewExposureHostLocator(<graphId>:5, definition-scoped, so it collapses across clones of the outer subgraph instead). Neither is instance-correct for nested hosts; the PR's own comment says the two constructions are "identical" when they are not.- Per-node cost: every mounted
SubgraphNodenow owns a computed that walks its full interior on each invalidation. Coderabbit flagged this; the cheap answer is not to have the walk.
The PR's shape (mermaid)
flowchart TB
WS["b_preview_with_metadata 11:10"] --> APP["app.ts"]
APP --> LOC["nodePreviewImages<br/>'11', '<uuid>:10'"]
APP --> EXEC["nodePreviewImagesByExecutionId<br/>'11', '11:10' (new, parallel)"]
SG["Subgraph.onNodeAdded /<br/>onNodeRemoved (monkey-patched)"] -.->|"version++"| TV["WeakMap<Subgraph, Ref<number>>"]
TV --> AMB
subgraph HOST["LGraphNode.vue (host 11)"]
PP["usePromotedPreviews"] --> MERGE["mergeSubgraphPreviews<br/>(dedupe by sourceNodeId)"]
AMB["useAmbientSubgraphPreviews<br/>walk subgraph.nodes → '11:<id>'"] --> MERGE
EXPO["previewExposureStore.getExposures"] --> MERGE
MERGE --> NC["NodeContent v-for"]
LP["LivePreview<br/>(still guarded off)"]
end
LOC --> PP
EXEC --> AMB
Three inputs, two store maps, one patched callback, one still-dead render path, to display a frame the host already has under key '11'.
4. This changes ADR 0009 semantics without amending it
ADR 0009 (L79-86) says exposures are persisted user choices and users may remove them. With this PR, removing a live-executing sampler's exposure is a no-op: the ambient path resurfaces it. The tombstone commit (b6bc646) was added and then reverted (94e525e) with "intentional" in the commit message. That may be the right product call, but it is a policy change and should land as an ADR amendment (or a note in 0009) so the next reader doesn't rediscover it from a revert.
Design A below has the same wrinkle for the transient live frame only (not for persisted outputs), so the question needs an answer either way. I'd lean toward: the live frame is ephemeral status, not an exposed output, and showing it on the host regardless of exposure is fine; persisted outputs continue to follow exposures.
5. mergeSubgraphPreviews only exists because of the ambient shape
The three-way merge (promoted, ambient, first-hop exposures) dedupes by sourceNodeId because ambient previews are forced into the PromotedPreview shape with the synthetic sourceWidgetName = '$$ambient-preview'. If the ambient path goes away, so does the merge, the sentinel, and the getPreviewMediaType export.
6. Tests
useAmbientSubgraphPreviews.test.ts mocks nodeOutputStore and backs getNodePreviewImagesByExecutionId with nodePreviewImages, so it tests the composable's plumbing against a fake that collapses the very distinction the composable exists to preserve. useAmbientSubgraphPreviews.sharedInstance.test.ts uses the real store and is the one worth keeping in some form (its assertion, "two hosts of one definition show their own frames", is the actual invariant). The two expected-fail tests are useful and should flip to passing with the guard fix. I didn't run the Playwright specs (no backend in my environment).
Smaller notes
existing?.[Symbol.iterator]checks insetInstancePreviewImages/revokeInstancePreviewImagesare copied from the locator path; if the store's own types are right these are unreachable and just hide a type lie.String(node.id)forgetExposuresin the component vstryNormalizeNodeExecutionId(node.id)in the composable: two spellings of "the host's id" for the same lookup.- The
/* TODO: Surface subgraph info more cleanly in NodeState */comment above the new code is the right instinct; the PR adds more reaching-through instead.
Alternatives
Two independent takes on "what else could fix #14597 / #9859", with the cloned-subgraph constraint (one interior node, many hosts, frame goes to the rendered instance only) as a hard requirement.
The cloned-subgraph configuration the fix has to survive (mermaid)
flowchart LR
subgraph ROOT["root graph"]
H11["SubgraphNode 11"]
H12["SubgraphNode 12"]
end
subgraph DEF["Subgraph <uuid> (one definition)"]
K10["KSampler 10"]
end
H11 -.->|instance of| DEF
H12 -.->|instance of| DEF
F1["frame for 11:10"] -->|"ancestors: 11, 11:10"| M
F2["frame for 12:10"] -->|"ancestors: 12, 12:10"| M
subgraph M["nodePreviewImages (locator keys)"]
L11["'11' → frame A ✔ per instance"]
L12["'12' → frame B ✔ per instance"]
LI["'<uuid>:10' → last writer ✘ collapses"]
end
Host-level keys are already instance-correct. Only the interior key collapses, and the interior view has a second problem: subgraphNavigationStore.navigationStack holds Subgraph definitions, not host instances, so when you are inside a cloned subgraph nothing today records which instance you entered through. Any interior-correct design has to fix that first.
Design A: fix the guard, dedupe against promoted URLs (recommended now)
One file, LGraphNode.vue. Replace the isSubgraphNode() guard with "don't show the host's live frame if a promoted preview is already showing that same URL":
const promotedPreviewUrls = computed(
() => new Set(promotedPreviews.value.flatMap(({ urls }) => urls))
)
const shouldShowHostPreview = computed(
() =>
shouldShowPreviewImg.value &&
!promotedPreviewUrls.value.has(latestPreviewUrl.value)
)<LivePreview v-if="shouldShowHostPreview" :image-url="latestPreviewUrl" />Because app.ts fans each frame out to the host's own execution id, latestPreviewUrl on host 11 is already the frame for 11:*, and on host 12 the frame for 12:*. The URL-set dedupe handles the case the original guard was protecting against (same sampler also promoted) without needing to know which interior node produced the frame.
Design A data flow (mermaid), coverage, and what it does not do
flowchart LR
APP["app.ts fan-out"] --> LOC["nodePreviewImages<br/>'11' → frame"]
LOC --> HPS["useNodePreviewState(host)<br/>latestPreviewUrl"]
LOC --> PP["usePromotedPreviews<br/>(if exposed)"]
PP --> SET["Set(promoted urls)"]
HPS --> DEC{{"shouldShowPreviewImg &&<br/>!set.has(latestPreviewUrl)"}}
SET --> DEC
DEC -->|true| LP["LivePreview on host"]
DEC -->|false| NC["NodeContent (promoted) only"]
Handles:
- sampler added to the subgraph after
autoExposeKnownPreviewNodesran (the PR's stated root cause; no exposure needed) - two hosts of one definition, each shows its own frame
- sampler both live and promoted: shown once, via the promoted path
- a promoted
SaveImageplus an unpromoted live sampler: both shown, no collision
Does not handle:
- explicit exposure removal for a live sampler: the transient frame still shows on the host while it executes (persisted outputs are unaffected). This is the ADR 0009 question in finding 4 and needs a decision, not code.
- nested hosts:
latestPreviewUrlfor a host at11:5resolves throughnodeIdToNodeLocatorIdto<graphId>:5, which is definition-scoped, so two clones of the outer subgraph would share the inner host's frame. Same limitation asusePromotedPreviewstoday. Not a regression; Design B is where it gets fixed. - classic canvas:
litegraphService.unsafeUpdatePreviewsreadsgetNodePreviews(host)directly; whether it draws the host frame today is unverified (#9859 says LG mode is also broken). Worth a separate look; not blocked on this.
I also considered making autoExposeKnownPreviewNodes incremental (run on node:added). It is larger, writes to persisted properties.previewExposures on the user's behalf every time the graph changes, and still leaves the guard suppressing the frame. Rejected.
Design B: one execution-id-keyed preview registry (tracked follow-up)
The ECS-shaped version of what this PR is reaching for. One registry, Record<NodeExecutionId, PreviewComponent>, owns the URLs and refcounts. app.ts stops doing ancestor fan-out; a store action recordLivePreview(displayNodeExecutionId, url) writes the frame once at the producing id and maintains a routing index hostExecutionId → producingDescendantExecutionId. Hosts read their routed frame; interior nodes read their own id; promoted previews resolve by execution id so host-vs-promoted dedupe is by identity, not by URL.
Design B shape (mermaid) and sequencing
flowchart LR
WS["b_preview_with_metadata 11:10"] --> ACT["nodeOutputStore.recordLivePreview()"]
ACT --> REG["previewByExecutionId<br/>'11:10' → {urls, refs}"]
ACT --> IDX["latestDescendantPreview<br/>'11' → '11:10'"]
REG --> HOST["host 11 view<br/>reads IDX['11'] → REG['11:10']"]
REG --> INT["interior view<br/>reads REG[activeExecutionPath + ':10']"]
NAV["subgraphNavigationStore<br/>+ activeExecutionPath (captured on enter)"] --> INT
REG --> PROM["usePromotedPreviews<br/>resolves exposure → executionId"]
PROM -->|"same executionId as IDX['11']?"| DEDUPE{{"dedupe by identity"}}
HOST --> DEDUPE
Sequencing:
- Add
activeExecutionPathtosubgraphNavigationStore, captured when entering a host (needed before any interior view can be instance-correct for clones; today it holds definitions only). - Re-key
nodePreviewImagesto execution ids; migrate the readers listed in finding 2. - Move fan-out from
app.tsinto the store; delete the locator map. app.nodePreviewImagesbecomes a documented, root-only projection (extension-facing change; needs a migration note).
Rough size is 150-250 source lines plus migrations; not something to fold into this fix.
Assumptions behind this review
- Treated "two samplers previewing at once" as a synthetic scenario, not a requirement, based on the linked issues and sequential backend execution. If there is a product requirement for it, Design B is the path, not the ambient walk.
- Did not run the Playwright specs; unit tests on the PR head: 7 files, 106 passed, 1 expected fail.
- Did not verify classic-canvas runtime behavior for the host frame; the code path exists but I only read it.
- The "host already has the frame" claim was checked against
mainwith a throwaway store-level test, not in a browser.
| * each other's frame — so `getNodePreviewImagesByExecutionId` reads this | ||
| * map instead. | ||
| */ | ||
| const nodePreviewImagesByExecutionId = ref<Record<string, string[]>>({}) |
There was a problem hiding this comment.
This is a second registry for the same component (preview URLs) keyed by a different id, while setNodePreviewsByExecutionId still writes the locator map too. Every frame is stored, refcounted, and revoked twice, and setNodePreviewsByLocatorId callers only write one of them, so the two can drift.
If the locator key is wrong for interior previews (it is, for cloned subgraphs), the fix is to re-key nodePreviewImages and migrate its readers in a dedicated PR, not to add a sibling map. See finding 2 and Design B in the review body.
| subgraph.onNodeAdded = useChainCallback(subgraph.onNodeAdded, () => { | ||
| version.value++ | ||
| }) | ||
| subgraph.onNodeRemoved = useChainCallback(subgraph.onNodeRemoved, () => { | ||
| version.value++ | ||
| }) |
There was a problem hiding this comment.
This reassigns Subgraph.onNodeAdded / onNodeRemoved from inside a render-time computed, cached in a module-level WeakMap. That is callback growth on a litegraph class by another route (ADR 0003/0008), and it runs on first render of whichever host happens to mount first.
Reactive membership already exists without patching: graph.events emits 'node:added' / 'node:removed' (see useErrorClearingHooks.ts), and nodeDataStore.getGraphNodesFor(rootGraphId, owningGraphId) is a reactive query over the node registry. That said, per finding 1 the host doesn't need to enumerate interior nodes at all to render the live frame, so I'd drop the walk rather than re-wire it.
| // interior lookups to this instance's own execution path, rather than | ||
| // the subgraph definition's shared `NodeLocatorId`, is what keeps two | ||
| // hosts of the same definition from displaying each other's preview. | ||
| const hostExecutionId = tryNormalizeNodeExecutionId(node.id) |
There was a problem hiding this comment.
The comment above says this is identical to usePromotedPreviews' hostLocator, but it isn't. usePromotedPreviews uses getPreviewExposureHostLocator(node) → <graphId>:<id> for nested hosts. This uses the bare node.id.
For a host nested inside another subgraph (host at 11:5, interior sampler at 11:5:10), this constructs 5:10, which is the wrong execution id and collides with any other parent that also has a node 5. The locator version has its own problem (definition-scoped, so collapses across clones of the outer subgraph), but at least it doesn't produce an id that belongs to a different node.
| const { ambientPreviews } = useAmbientSubgraphPreviews(lgraphNode) | ||
| const previewExposureStore = usePreviewExposureStore() | ||
|
|
||
| const subgraphPreviews = computed(() => { |
There was a problem hiding this comment.
Three sources merged in the component (promotedPreviews, ambientPreviews, first-hop getExposures) to display a frame that useNodePreviewState(host) already exposes as latestPreviewUrl a few lines up. The only thing suppressing it is the !lgraphNode?.isSubgraphNode() guard on <LivePreview> at L172.
Minimal alternative, one file:
const promotedPreviewUrls = computed(
() => new Set(promotedPreviews.value.flatMap(({ urls }) => urls))
)
const shouldShowHostPreview = computed(
() =>
shouldShowPreviewImg.value &&
!promotedPreviewUrls.value.has(latestPreviewUrl.value)
)<LivePreview v-if="shouldShowHostPreview" :image-url="latestPreviewUrl" />This handles samplers added after auto-expose, two hosts of one definition (host-level keys are already per instance thanks to the ancestor fan-out in app.ts), and the same-sampler-also-promoted case the guard was protecting against. It also flips the two expected-fail tests in this PR to passing. Full reasoning in the review body (finding 1, Design A).
| // nodes. Keep this test (don't delete) so it flips green automatically | ||
| // once that guard changes. | ||
| // incident-94: waiting on LGraphNode.vue:172's `!lgraphNode?.isSubgraphNode()` guard. | ||
| it.fails('renders the live preview image on a subgraph node with a populated preview', () => { |
There was a problem hiding this comment.
Worth keeping: this is the test that describes the actual bug. With the guard replaced by URL-dedupe against promoted previews (Design A), this flips to it(...) and the rest of the ambient machinery isn't needed to make it pass.
Loading a workflow with two subgraph definitions that collide on an interior node id renumbers the colliding node via deduplicateSubgraphNodeIds, but properties.previewExposures on the host was never patched to follow — same as patchProxyWidgets already does for legacy proxyWidgets. The stale sourceNodeId then resolves to nothing, so the promoted preview silently disappears after reload. Adds patchPreviewExposures, applied alongside patchProxyWidgets for both interior and root-level hosts, plus a regression test. Claude-Session: https://claude.ai/code/session_011BPhqLweRXNznT3YWP9Mx5
useAmbientSubgraphPreviews built its interior-node lookup key from the host's own bare local id (e.g. "10"), not its root-relative execution id (e.g. "9:10" for a host nested one level deep). For any host that is itself nested inside another subgraph, that means the ambient rollup never finds the frames app.ts's ancestor fan-out already wrote for it, so a live interior preview never renders on a nested host. Reuses the existing getExecutionIdByNode graph-traversal helper (already used the same way by error reporting, missing-node/model scanning, etc.) instead of the bare-id normalization, plus a regression test with a host nested inside another subgraph. Claude-Session: https://claude.ai/code/session_011BPhqLweRXNznT3YWP9Mx5
LGraphNode.vue's subgraphPreviews merge excluded a host's own exposed nodes from its ambient previews by querying previewExposureStore.getExposures(rootGraphId, String(node.id)) — the node's bare id. SubgraphNode._hydratePreviewExposures always stores a nested host's exposures under its instance-scoped locator (definition UUID + bare id) instead, so for any host nested inside another subgraph this lookup silently found nothing, leaving the exclusion set empty. Extracts the lookup into getHostExposedSourceNodeIds (colocated with mergeSubgraphPreviews, which already documents this exact contract), using getPreviewExposureHostLocator like every other read/write site for this data. Root-level hosts are unaffected, since their instance locator and bare id already coincide. Claude-Session: https://claude.ai/code/session_011BPhqLweRXNznT3YWP9Mx5
subgraphNestedAmbientPreviewScope.spec.ts and subgraphAmbientCommittedOutputIsolation.spec.ts both assert a live preview appears on a subgraph host with no promoted exposure for it, to pin the ambient-rollup code path specifically. Neither fixture's host node declares a persisted `previewExposures` property, so LGraph.configure's one-shot autoExposeKnownPreviewNodes pass runs on load and auto-promotes the interior KSampler via the ordinary promotion path instead — the e2e assertion is satisfied either way, so stubbing the ambient composable out entirely still leaves both specs green. Adds a unit-level guard reading the two fixture JSON files directly and asserting each host already declares an empty `previewExposures: []`, which is what actually trips the one-shot gate. Confirmed red against the current (undefined-property) fixtures before the next commit sets it. Claude-Session: https://claude.ai/code/session_011BPhqLweRXNznT3YWP9Mx5
Sets `properties.previewExposures: []` on the subgraph hosts in subgraph-nested-with-live-sampler.json and subgraph-with-live-sampler-and-committed-output.json. Both fixtures' hosts previously left `previewExposures` undefined, so autoExposeKnownPreviewNodes' one-shot gate (`if (subgraphNode.properties.previewExposures !== undefined) return`) ran on load and auto-promoted the interior KSampler through the ordinary exposure path — the same path the ambient rollup exists to supplement, not replace, for these fixtures. An explicit empty array trips the gate so it no longer runs, leaving the host with no promoted exposure and forcing subgraphNestedAmbientPreviewScope.spec.ts and subgraphAmbientCommittedOutputIsolation.spec.ts to actually exercise the ambient composable to pass. Claude-Session: https://claude.ai/code/session_011BPhqLweRXNznT3YWP9Mx5
|
Addressed the 5 bugs from jaeone94's review. All 5 reproduced as described. Status, using their numbering:
All 5 commits pass Generated by Claude Code |
|
@claude drjkl's point seems valid. I, too, am somewhat skeptical about whether it's really necessary to display previews of all internal nodes individually. |
|
@DrJKL Is there a way to use your version of minimal patch and manually patch this in local ComfyUI install? I'm struggling with missing Subgraph previews for month. Had to flatten most of the Subgraphs in WFs to make it usable. Missing all image previews and video previews - not a single preview from Subgraph shows on top in main canvas, even when promoted on the Subgraph. I just can't find the src/renderer/extensions/vueNodes/components/LGraphNode.vue in local install to patch. This: |
d26a569 to
f789cda
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Requested by Christian Byrne · Slack thread
Summary
Fixes incident-94 bug #3: when a subgraph host has multiple interior nodes producing live previews concurrently (e.g. two
KSamplers in one subgraph), only one of them showed on the host, and it could go stale.Before: the only path from an interior node's live output to the
SubgraphNodehost waspreviewExposureStore. The root cause is not the exposure record itself but how exposures get created: a one-shotautoExposeKnownPreviewNodespass that runs once, the first time the subgraph'spreviewExposuresproperty is undefined. If a second interior node (a secondKSampler, or one added after that one-shot pass already ran) never got an exposure, its live preview had nowhere to render on the host — invisible, even while executing.After: the host also derives an ambient rollup, independent of promotion, by reading each direct interior node's own output/preview state straight from
nodeOutputStore— the same store every regular node's own preview already reads from. Any interior node currently producing output shows on the host, whether or not anyone promoted it. An explicit exposure for a node still wins (keeps its promoted name/ordering); the ambient rollup only fills in nodes that have live output but no exposure. Two concurrently-executingKSamplers in one subgraph now both show and update independently instead of one overwriting/hiding the other.How
src/composables/node/useAmbientSubgraphPreviews.ts(new): acomputedthat mirrors the shape ofexecutionStore'snodeLocationProgressStates— which already bubbles up execution progress to a subgraph host independent of promotion — but for preview images. For aSubgraphNodehost it walkshost.subgraph.nodes(direct interior nodes only; nestedSubgraphNodes derive their own previews independently) and, for each one with live output/preview data innodeOutputStore, builds a preview entry via the samegetNodeImageUrlsa regular node's own preview already uses. Deliberately acomputed, not awatch(), per this repo's existing review pushback on watcher-based state derivation.src/composables/node/usePromotedPreviews.ts: exported the existingPromotedPreviewtype andgetPreviewMediaTypehelper (previously private) so the new ambient composable can share them — no behavior change to the exposure-driven path itself.src/renderer/extensions/vueNodes/components/LGraphNode.vue: addeduseAmbientSubgraphPreviewsalongside the existingusePromotedPreviews, merged into asubgraphPreviewscomputed (exposure-driven entries first, then any ambient entries for interior nodes not already exposed, deduped by source node id), and swapped the renderv-for/hasCustomContentcheck frompromotedPreviewstosubgraphPreviews. The render list already supported an arbitrary number of previews — no new render component needed.previewExposureStore's schema, the promotion/exposure mechanism, and thecanvasImagePreviewTypes.tsallowlist are untouched — this is purely additive.Test plan
src/composables/node/useAmbientSubgraphPreviews.test.ts(new, red→green): unit tests the new rollup directly — empty/detached/no-output cases, a single exposed-free interior node with live output, and the core regression case of two concurrently-executing interior nodes producing distinct previews without either being registered as an exposure.browser_tests/tests/subgraph/subgraphConcurrentPreviews.spec.ts+browser_tests/assets/subgraphs/subgraph-with-two-live-samplers.json(new): e2e regression with twoKSamplers in one subgraph where only one has a baked-inpreviewExposuresentry (simulating a node added after the subgraph's one-shot auto-expose already ran). Drives two liveb_previewWS frames at distinct interior execution IDs and asserts both show on the host, and that each updates independently as new frames arrive.main: before the fix, the unit test fails becauseuseAmbientSubgraphPreviewsdoesn't exist yet (module-not-found), and the e2e scenario only shows the exposed sampler's preview.usePromotedPreviews,previewExposureStore,nodeOutputStore,executionStore,nodeIdentification,LGraphNode/LGraphNode.subgraph,promotionUtils— 31 files / 550 tests) all pass, so single-KSampler-in-subgraph and the SamplerCustomAdvanced allowlist-gap fix (fix: derive subgraph preview promotion for any interior node type #14551) are unaffected.pnpm typecheck,pnpm typecheck:browser, andoxlint/eslint/oxfmton all touched files are clean.comfyanonymous/ComfyUIalongside this session'sComfy-Orgsources) — the e2e spec was verified viaplaywright test --list(compiles, discovers under@vue-nodes/@subgraph) andvue-tsc --project browser_tests/tsconfig.json, but not executed end-to-end. Recommend running it in CI/a full local checkout before merge.Linked issues
This PR changes only the Vue nodes renderer. The classic litegraph canvas still resolves host previews from
previewExposureStorealone (litegraphService.ts:193), andComfy.VueNodes.Enableddefaults tofalsefor OSS local installs, so classic-canvas parity is the other half of this incident and is not addressed here.Note: #14551 was closed in favour of this PR (same mechanism, this one better guarded). Its
SamplerCustomAdvancede2e fixture and spec still need porting here so the non-allowlisted node type stays pinned.Generated by Claude Code