From bfdad34bc261754612aa97cd9dea19a2abf384c1 Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Tue, 14 Apr 2026 11:47:03 +0900 Subject: [PATCH 01/10] fix: three missing-asset correctness bugs introduced in #10856 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. ErrorOverlay count reflected node-selection filtering. useErrorGroups exposed filteredMissingModelGroups under the name missingModelGroups. ErrorOverlay read that alias for its model count label, so selecting a node shrunk the overlay's total. Expose both unfiltered (missingModelGroups / missingMediaGroups) and filtered variants so ErrorOverlay gets the true total and the errors tab still gets selection-scoped groups. TabErrors renamed its destructure. 2. bypass/un-bypass of a missing-model node dropped url/hash metadata. Realtime scanNodeModelCandidates only reads widget values, so un-bypass produced a fresh candidate without the url that enrichWithEmbeddedMetadata had previously attached from graphData.models. Add enrichCandidateFromNodeProperties which copies url/hash/directory from the node's own properties.models (persistent across mode toggles). Applies to every call site of the per-node scan, so paste, un-bypass, and mode change all restore the metadata. 3. Initial full scan surfaced interior errors of muted/bypassed subgraph containers. scanAllModelCandidates, scanAllMediaCandidates, and the JSON missing-node scan only check each node's own mode; interior nodes whose parent container is bypassed passed through. Runtime handleNodeModeChange already filters correctly — the bug was scoped to the initial-load path. Add isAncestorPathActive to graphTraversalUtil and post-filter the three pipelines in runMissingModelPipeline / runMissingMediaPipeline / loadGraphData before the results are cached or surfaced. --- .../rightSidePanel/errors/TabErrors.vue | 4 +- .../errors/useErrorGroups.test.ts | 25 +++++ .../rightSidePanel/errors/useErrorGroups.ts | 6 +- .../missingModel/missingModelScan.test.ts | 91 +++++++++++++++++++ src/platform/missingModel/missingModelScan.ts | 33 ++++++- src/scripts/app.ts | 31 ++++++- src/utils/graphTraversalUtil.test.ts | 73 ++++++++++++++- src/utils/graphTraversalUtil.ts | 36 ++++++++ 8 files changed, 290 insertions(+), 9 deletions(-) diff --git a/src/components/rightSidePanel/errors/TabErrors.vue b/src/components/rightSidePanel/errors/TabErrors.vue index e8d0297f7b5..879a6040eee 100644 --- a/src/components/rightSidePanel/errors/TabErrors.vue +++ b/src/components/rightSidePanel/errors/TabErrors.vue @@ -293,8 +293,8 @@ const { errorNodeCache, missingNodeCache, missingPackGroups, - missingModelGroups, - missingMediaGroups, + filteredMissingModelGroups: missingModelGroups, + filteredMissingMediaGroups: missingMediaGroups, swapNodeGroups } = useErrorGroups(searchQuery, t) diff --git a/src/components/rightSidePanel/errors/useErrorGroups.test.ts b/src/components/rightSidePanel/errors/useErrorGroups.test.ts index bb0565c7435..8f78194e4ac 100644 --- a/src/components/rightSidePanel/errors/useErrorGroups.test.ts +++ b/src/components/rightSidePanel/errors/useErrorGroups.test.ts @@ -754,4 +754,29 @@ describe('useErrorGroups', () => { ).toBe(true) }) }) + + describe('unfiltered vs selection-filtered model/media groups', () => { + it('exposes both unfiltered (missingModelGroups) and filtered (filteredMissingModelGroups)', () => { + const { groups } = createErrorGroups() + expect(groups.missingModelGroups).toBeDefined() + expect(groups.filteredMissingModelGroups).toBeDefined() + expect(groups.missingMediaGroups).toBeDefined() + expect(groups.filteredMissingMediaGroups).toBeDefined() + }) + + it('missingModelGroups returns total candidates regardless of selection (ErrorOverlay contract)', async () => { + const { store, groups } = createErrorGroups() + store.surfaceMissingModels([ + makeModel('a.safetensors', { nodeId: '1', directory: 'checkpoints' }), + makeModel('b.safetensors', { nodeId: '2', directory: 'checkpoints' }) + ]) + await nextTick() + + // Regardless of any selection state, missingModelGroups must remain + // the full set — ErrorOverlay reads it for the total error count + // label and should not reflect tab-level node selection filtering. + expect(groups.missingModelGroups.value).toHaveLength(1) + expect(groups.missingModelGroups.value[0].models).toHaveLength(2) + }) + }) }) diff --git a/src/components/rightSidePanel/errors/useErrorGroups.ts b/src/components/rightSidePanel/errors/useErrorGroups.ts index 59ea1c8602e..24947f559d8 100644 --- a/src/components/rightSidePanel/errors/useErrorGroups.ts +++ b/src/components/rightSidePanel/errors/useErrorGroups.ts @@ -833,8 +833,10 @@ export function useErrorGroups( missingNodeCache, groupedErrorMessages, missingPackGroups, - missingModelGroups: filteredMissingModelGroups, - missingMediaGroups: filteredMissingMediaGroups, + missingModelGroups, + missingMediaGroups, + filteredMissingModelGroups, + filteredMissingMediaGroups, swapNodeGroups } } diff --git a/src/platform/missingModel/missingModelScan.test.ts b/src/platform/missingModel/missingModelScan.test.ts index 9d01c1fd245..3e458f60856 100644 --- a/src/platform/missingModel/missingModelScan.test.ts +++ b/src/platform/missingModel/missingModelScan.test.ts @@ -156,6 +156,97 @@ describe('scanNodeModelCandidates', () => { expect(result).toEqual([]) }) + + it('enriches candidates with url/hash/directory from node.properties.models', () => { + // Regression: bypass/un-bypass cycle previously lost url metadata + // because realtime scan only reads widget values. Per-node embedded + // metadata in `properties.models` persists across mode toggles, so + // the scan now enriches candidates from that source. + const graph = makeGraph([]) + const node = fromAny({ + id: 1, + type: 'CheckpointLoaderSimple', + widgets: [ + makeComboWidget('ckpt_name', 'missing_model.safetensors', [ + 'other_model.safetensors' + ]) + ], + properties: { + models: [ + { + name: 'missing_model.safetensors', + url: 'https://example.com/missing_model', + directory: 'checkpoints', + hash: 'abc123', + hash_type: 'sha256' + } + ] + } + }) + + const result = scanNodeModelCandidates(graph, node, noAssetSupport) + + expect(result).toHaveLength(1) + expect(result[0].url).toBe('https://example.com/missing_model') + expect(result[0].directory).toBe('checkpoints') + expect(result[0].hash).toBe('abc123') + expect(result[0].hashType).toBe('sha256') + }) + + it('preserves existing candidate fields when enriching (no overwrite)', () => { + const graph = makeGraph([]) + const node = fromAny({ + id: 1, + type: 'CheckpointLoaderSimple', + widgets: [makeComboWidget('ckpt_name', 'missing_model.safetensors', [])], + properties: { + models: [ + { + name: 'missing_model.safetensors', + url: 'https://example.com/new_url', + directory: 'new_dir' + } + ] + } + }) + + const result = scanNodeModelCandidates( + graph, + node, + noAssetSupport, + () => 'existing_dir' + ) + + expect(result).toHaveLength(1) + // scanComboWidget already sets directory via getDirectory; enrichment + // does not overwrite it. + expect(result[0].directory).toBe('existing_dir') + // url was not set by scan, so enrichment fills it in. + expect(result[0].url).toBe('https://example.com/new_url') + }) + + it('does not enrich candidates with mismatched model names', () => { + const graph = makeGraph([]) + const node = fromAny({ + id: 1, + type: 'CheckpointLoaderSimple', + widgets: [makeComboWidget('ckpt_name', 'missing_model.safetensors', [])], + properties: { + models: [ + { + name: 'different_model.safetensors', + url: 'https://example.com/different', + directory: 'checkpoints' + } + ] + } + }) + + const result = scanNodeModelCandidates(graph, node, noAssetSupport) + + expect(result).toHaveLength(1) + expect(result[0].url).toBeUndefined() + }) }) describe('scanAllModelCandidates', () => { diff --git a/src/platform/missingModel/missingModelScan.ts b/src/platform/missingModel/missingModelScan.ts index f6938ddc0f6..30562b8e945 100644 --- a/src/platform/missingModel/missingModelScan.ts +++ b/src/platform/missingModel/missingModelScan.ts @@ -1,5 +1,6 @@ import type { ComfyWorkflowJSON, + ModelFile, NodeId } from '@/platform/workflow/validation/schemas/workflowSchema' import { flattenWorkflowNodes } from '@/platform/workflow/validation/schemas/workflowSchema' @@ -30,6 +31,30 @@ function isComboWidget(widget: IBaseWidget): widget is IComboWidget { return widget.type === 'combo' } +/** + * Fills url/hash/directory onto a candidate from the node's embedded + * `properties.models` metadata when the names match. The full pipeline + * does this via enrichWithEmbeddedMetadata + graphData.models, but the + * realtime single-node scan (paste, un-bypass) otherwise loses these + * fields — making the Missing Model row's download/copy-url buttons + * disappear after a bypass/un-bypass cycle. + */ +function enrichCandidateFromNodeProperties( + candidate: MissingModelCandidate, + embeddedModels: readonly ModelFile[] | undefined +): MissingModelCandidate { + if (!embeddedModels?.length) return candidate + const match = embeddedModels.find((m) => m.name === candidate.name) + if (!match) return candidate + return { + ...candidate, + directory: candidate.directory ?? match.directory, + url: candidate.url ?? match.url, + hash: candidate.hash ?? match.hash, + hashType: candidate.hashType ?? match.hash_type + } +} + function isAssetWidget(widget: IBaseWidget): widget is IAssetWidget { return widget.type === 'asset' } @@ -107,6 +132,8 @@ export function scanNodeModelCandidates( if (!executionId) return [] const candidates: MissingModelCandidate[] = [] + const embeddedModels = (node as { properties?: { models?: ModelFile[] } }) + .properties?.models for (const widget of node.widgets) { let candidate: MissingModelCandidate | null = null @@ -122,7 +149,11 @@ export function scanNodeModelCandidates( ) } - if (candidate) candidates.push(candidate) + if (candidate) { + candidates.push( + enrichCandidateFromNodeProperties(candidate, embeddedModels) + ) + } } return candidates diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 9437826b9b9..03a53e3b110 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -108,6 +108,7 @@ import { collectAllNodes, forEachNode, getNodeByExecutionId, + isAncestorPathActive, triggerCallbackOnAllNodes } from '@/utils/graphTraversalUtil' import { @@ -1436,10 +1437,21 @@ export class ComfyApp { requestAnimationFrame(() => fitView()) } + // Drop missing-node entries whose enclosing subgraph is + // muted/bypassed. The initial JSON scan only checks each node's + // own mode; the cascade from an inactive container is applied here + // using the now-configured live graph. + const activeMissingNodeTypes = missingNodeTypes.filter( + (n) => + typeof n === 'string' || + n.nodeId == null || + isAncestorPathActive(this.rootGraph, String(n.nodeId)) + ) + if (!skipAssetScans) { await this.runMissingModelPipeline( graphData, - missingNodeTypes, + activeMissingNodeTypes, silentAssetErrors ) @@ -1482,7 +1494,7 @@ export class ComfyApp { const modelStore = useModelStore() await modelStore.loadModelFolders() - const enrichedCandidates = await enrichWithEmbeddedMetadata( + const enrichedAll = await enrichWithEmbeddedMetadata( candidates, graphData, async (name, directory) => { @@ -1498,6 +1510,15 @@ export class ComfyApp { : undefined ) + // Drop candidates whose enclosing subgraph is muted/bypassed. Per-node + // scans only checked each node's own mode; the cascade from an + // inactive container to its interior happens here. + const enrichedCandidates = enrichedAll.filter( + (c) => + c.nodeId == null || + isAncestorPathActive(this.rootGraph, String(c.nodeId)) + ) + const missingModels: ModelFile[] = enrichedCandidates .filter((c) => c.isMissing === true && c.url) .map((c) => ({ @@ -1643,7 +1664,11 @@ export class ComfyApp { ): Promise { const missingMediaStore = useMissingMediaStore() const activeWf = useWorkspaceStore().workflow.activeWorkflow - const candidates = scanAllMediaCandidates(this.rootGraph, isCloud) + const allCandidates = scanAllMediaCandidates(this.rootGraph, isCloud) + // Drop candidates whose enclosing subgraph is muted/bypassed. + const candidates = allCandidates.filter((c) => + isAncestorPathActive(this.rootGraph, String(c.nodeId)) + ) if (!candidates.length) { this.cacheMediaCandidates(activeWf, []) diff --git a/src/utils/graphTraversalUtil.test.ts b/src/utils/graphTraversalUtil.test.ts index 93c1cbea1cf..c17d03ce69a 100644 --- a/src/utils/graphTraversalUtil.test.ts +++ b/src/utils/graphTraversalUtil.test.ts @@ -29,8 +29,10 @@ import { triggerCallbackOnAllNodes, visitGraphNodes, getExecutionIdByNode, - getExecutionIdForNodeInGraph + getExecutionIdForNodeInGraph, + isAncestorPathActive } from '@/utils/graphTraversalUtil' +import { LGraphEventMode } from '@/lib/litegraph/src/types/globalEnums' import { createMockLGraphNode } from './__tests__/litegraphTestUtils' @@ -723,6 +725,75 @@ describe('graphTraversalUtil', () => { }) }) + describe('isAncestorPathActive', () => { + function makeActiveSubgraph(id: string, nodes: LGraphNode[]) { + return createMockSubgraph(id, nodes) + } + + it('returns true for root-level nodes (no ancestors)', () => { + const node = createMockNode('42') + const rootGraph = createMockGraph([node]) + expect(isAncestorPathActive(rootGraph, '42')).toBe(true) + }) + + it('returns true when all ancestor containers are active', () => { + const interior = createMockNode('63') + const subgraph = makeActiveSubgraph('sub', [interior]) + const container = createMockNode('65', { + isSubgraph: true, + subgraph + }) + // container mode defaults to ALWAYS (active) + const rootGraph = createMockGraph([container]) + + expect(isAncestorPathActive(rootGraph, '65:63')).toBe(true) + }) + + it('returns false when the immediate parent container is bypassed', () => { + const interior = createMockNode('63') + const subgraph = makeActiveSubgraph('sub', [interior]) + const container = createMockLGraphNode({ + id: 65, + isSubgraphNode: () => true, + subgraph, + mode: LGraphEventMode.BYPASS + }) satisfies Partial as LGraphNode + const rootGraph = createMockGraph([container]) + + expect(isAncestorPathActive(rootGraph, '65:63')).toBe(false) + }) + + it('returns false when an outer ancestor is muted (deeply nested)', () => { + const interior = createMockNode('999') + const deep = makeActiveSubgraph('deep', [interior]) + const midNode = createMockNode('456', { + isSubgraph: true, + subgraph: deep + }) + const mid = makeActiveSubgraph('mid', [midNode]) + const topNode = createMockLGraphNode({ + id: 123, + isSubgraphNode: () => true, + subgraph: mid, + mode: LGraphEventMode.NEVER + }) satisfies Partial as LGraphNode + const rootGraph = createMockGraph([topNode]) + + expect(isAncestorPathActive(rootGraph, '123:456:999')).toBe(false) + }) + + it('returns true when ancestor node cannot be resolved (defensive)', () => { + const rootGraph = createMockGraph([]) + // Unknown ancestor ID "99" — not found, treated as active. + expect(isAncestorPathActive(rootGraph, '99:63')).toBe(true) + }) + + it('returns true when rootGraph is null/undefined', () => { + expect(isAncestorPathActive(null, '65:63')).toBe(true) + expect(isAncestorPathActive(undefined, '65:63')).toBe(true) + }) + }) + describe('getExecutionIdFromNodeData', () => { it('should return the correct execution ID for a normal node', () => { const node = createMockNode('123') diff --git a/src/utils/graphTraversalUtil.ts b/src/utils/graphTraversalUtil.ts index aa906cf571f..d2162826e4d 100644 --- a/src/utils/graphTraversalUtil.ts +++ b/src/utils/graphTraversalUtil.ts @@ -3,6 +3,7 @@ import type { LGraphNode, Subgraph } from '@/lib/litegraph/src/litegraph' +import { LGraphEventMode } from '@/lib/litegraph/src/types/globalEnums' import type { NodeExecutionId, NodeLocatorId } from '@/types/nodeIdentification' import { createNodeLocatorId, @@ -362,6 +363,41 @@ export function getExecutionIdByNode( return `${parentPath}:${node.id}` } +/** + * True when every ancestor container in the execution path is active + * (not muted, not bypassed). Self is not checked — caller is expected to + * have already verified the target node's own mode. + * + * For root-level nodes (single-segment execution ID) there are no + * ancestors and the result is always true. + * + * Use after an initial full-graph scan to suppress missing-asset entries + * whose enclosing subgraph is muted/bypassed. At scan time only each + * node's own mode is checked; ancestor context is applied here so the + * effect cascades to interior nodes without requiring every scanner to + * carry the ancestor flag. + */ +export function isAncestorPathActive( + rootGraph: LGraph | null | undefined, + executionId: string +): boolean { + if (!rootGraph) return true + const parts = parseExecutionId(executionId) + if (!parts || parts.length <= 1) return true + for (let i = 1; i < parts.length; i++) { + const ancestorId = parts.slice(0, i).join(':') + const ancestor = getNodeByExecutionId(rootGraph, ancestorId) + if (!ancestor) continue + if ( + ancestor.mode === LGraphEventMode.NEVER || + ancestor.mode === LGraphEventMode.BYPASS + ) { + return false + } + } + return true +} + /** * Returns the execution ID for a node identified by its (graph, nodeId) pair. * From 17bcc91d4f1b66950c4877efa875f0c2009e998f Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Tue, 14 Apr 2026 14:17:15 +0900 Subject: [PATCH 02/10] refactor: reuse getParentExecutionIds in isAncestorPathActive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ancestor-prefix iteration in isAncestorPathActive reimplemented what getParentExecutionIds (src/types/nodeIdentification.ts) already provides. Use the shared helper — same semantics, less manual string work, and consistent with how missingModel/Media/Nodes stores already build ancestor prefixes. --- src/utils/graphTraversalUtil.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utils/graphTraversalUtil.ts b/src/utils/graphTraversalUtil.ts index d2162826e4d..81aff7a41fb 100644 --- a/src/utils/graphTraversalUtil.ts +++ b/src/utils/graphTraversalUtil.ts @@ -7,6 +7,7 @@ import { LGraphEventMode } from '@/lib/litegraph/src/types/globalEnums' import type { NodeExecutionId, NodeLocatorId } from '@/types/nodeIdentification' import { createNodeLocatorId, + getParentExecutionIds, parseNodeLocatorId } from '@/types/nodeIdentification' @@ -382,10 +383,7 @@ export function isAncestorPathActive( executionId: string ): boolean { if (!rootGraph) return true - const parts = parseExecutionId(executionId) - if (!parts || parts.length <= 1) return true - for (let i = 1; i < parts.length; i++) { - const ancestorId = parts.slice(0, i).join(':') + for (const ancestorId of getParentExecutionIds(executionId)) { const ancestor = getNodeByExecutionId(rootGraph, ancestorId) if (!ancestor) continue if ( From 67f3fe69f077c1e815fb9ed9526b5a7f3ec146a8 Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Tue, 14 Apr 2026 14:59:36 +0900 Subject: [PATCH 03/10] fix: skip scanning interior nodes when entering a bypassed subgraph MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit useGraphNodeManager replays graph.onNodeAdded(node) for each existing interior node when the Vue node manager initializes on subgraph entry. That chain reaches scanSingleNodeErrors via installErrorClearingHooks' onNodeAdded override. Each interior node's own mode is active, so the caller guards pass and the scan ran — reintroducing missing-asset errors that the initial pipeline's ancestor post-filter had correctly dropped. Add an ancestor-activity gate at the top of scanSingleNodeErrors, the single entry point shared by paste, un-bypass, subgraph entry, and subgraph container activation. One guard covers every realtime scan path. --- .../graph/useErrorClearingHooks.test.ts | 48 +++++++++++++++++++ .../graph/useErrorClearingHooks.ts | 9 +++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/composables/graph/useErrorClearingHooks.test.ts b/src/composables/graph/useErrorClearingHooks.test.ts index 4e3c2abe52b..b7bb7acf03f 100644 --- a/src/composables/graph/useErrorClearingHooks.test.ts +++ b/src/composables/graph/useErrorClearingHooks.test.ts @@ -730,6 +730,54 @@ describe('realtime verification staleness guards', () => { }) }) +describe('scan skips interior of bypassed subgraph containers', () => { + beforeEach(() => { + vi.restoreAllMocks() + setActivePinia(createTestingPinia({ stubActions: false })) + vi.spyOn(app, 'isGraphReady', 'get').mockReturnValue(false) + }) + + it('does not surface interior missing model when entering a bypassed subgraph', async () => { + // Repro: root has a bypassed subgraph container, interior node is + // itself active. useGraphNodeManager replays `onNodeAdded` for each + // interior node on subgraph entry, which previously reached + // scanSingleNodeErrors without an ancestor check and resurfaced the + // error that the initial pipeline post-filter had correctly dropped. + const subgraph = createTestSubgraph() + const interiorNode = new LGraphNode('CheckpointLoaderSimple') + subgraph.add(interiorNode) + + const subgraphNode = createTestSubgraphNode(subgraph, { id: 65 }) + subgraphNode.mode = LGraphEventMode.BYPASS + const rootGraph = subgraphNode.graph as LGraph + rootGraph.add(subgraphNode) + + vi.spyOn(app, 'rootGraph', 'get').mockReturnValue(rootGraph) + // Any scanner output would surface the error if the ancestor guard + // didn't short-circuit first — return a concrete missing candidate. + vi.spyOn(missingModelScan, 'scanNodeModelCandidates').mockReturnValue([ + { + nodeId: `${subgraphNode.id}:${interiorNode.id}`, + nodeType: 'CheckpointLoaderSimple', + widgetName: 'ckpt_name', + isAssetSupported: false, + name: 'fake.safetensors', + isMissing: true + } + ]) + vi.spyOn(missingMediaScan, 'scanNodeMediaCandidates').mockReturnValue([]) + + installErrorClearingHooks(subgraph) + + // Simulate useGraphNodeManager replaying onNodeAdded for existing + // interior nodes after Vue node manager init on subgraph entry. + subgraph.onNodeAdded?.(interiorNode) + await new Promise((r) => setTimeout(r, 0)) + + expect(useMissingModelStore().missingModelCandidates).toBeNull() + }) +}) + describe('clearWidgetRelatedErrors parameter routing', () => { beforeEach(() => { setActivePinia(createTestingPinia({ stubActions: false })) diff --git a/src/composables/graph/useErrorClearingHooks.ts b/src/composables/graph/useErrorClearingHooks.ts index 26f2b51d39d..c1c3d1041d5 100644 --- a/src/composables/graph/useErrorClearingHooks.ts +++ b/src/composables/graph/useErrorClearingHooks.ts @@ -41,7 +41,8 @@ import { collectAllNodes, getExecutionIdByNode, getExecutionIdForNodeInGraph, - getNodeByExecutionId + getNodeByExecutionId, + isAncestorPathActive } from '@/utils/graphTraversalUtil' function resolvePromotedExecId( @@ -172,6 +173,12 @@ function scanAndAddNodeErrors(node: LGraphNode): void { function scanSingleNodeErrors(node: LGraphNode): void { if (!app.rootGraph) return + // Skip when any enclosing subgraph is muted/bypassed. Callers only + // verify each node's own mode; entering a bypassed subgraph (via + // useGraphNodeManager replaying onNodeAdded for existing interior + // nodes) reaches this point without the ancestor check. + const execId = getExecutionIdByNode(app.rootGraph, node) + if (execId && !isAncestorPathActive(app.rootGraph, execId)) return const modelCandidates = scanNodeModelCandidates( app.rootGraph, From e87d49e7d7b851f85803f663a4891ef6efaa13bc Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Tue, 14 Apr 2026 15:25:07 +0900 Subject: [PATCH 04/10] test: e2e coverage for four missing-asset correctness bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds end-to-end regression tests for each bug addressed in this branch: 1. ErrorOverlay model count must not reflect node selection (errorOverlay.spec.ts) — new fixture missing_models_distinct.json with two nodes referencing two different model names. Selecting a node must not change the "N required models are missing" label. 2. Bypass/un-bypass cycle preserves Copy URL button (errorsTabModeAware.spec.ts) — uses missing_models_from_node_properties.json because the fix restores url/hash/directory from node.properties.models on realtime scan; workflow-level models[] is not seen by that path. 3. Initial load with bypassed subgraph container does not surface interior errors (errorsTabModeAware.spec.ts) — new fixture missing_models_in_bypassed_subgraph.json (subgraph container mode=BYPASS, interior CheckpointLoader active, unrelated KSampler active). 4. Entering a bypassed subgraph does not resurface interior errors (errorsTabModeAware.spec.ts) — shares the fixture from (3); navigates into the bypassed subgraph and verifies the errors tab stays hidden. --- .../missing/missing_models_distinct.json | 66 ++++++++ .../missing_models_in_bypassed_subgraph.json | 141 ++++++++++++++++++ browser_tests/tests/errorOverlay.spec.ts | 30 ++++ .../errorsTabModeAware.spec.ts | 80 ++++++++++ 4 files changed, 317 insertions(+) create mode 100644 browser_tests/assets/missing/missing_models_distinct.json create mode 100644 browser_tests/assets/missing/missing_models_in_bypassed_subgraph.json diff --git a/browser_tests/assets/missing/missing_models_distinct.json b/browser_tests/assets/missing/missing_models_distinct.json new file mode 100644 index 00000000000..e7ed31c668f --- /dev/null +++ b/browser_tests/assets/missing/missing_models_distinct.json @@ -0,0 +1,66 @@ +{ + "last_node_id": 2, + "last_link_id": 0, + "nodes": [ + { + "id": 1, + "type": "CheckpointLoaderSimple", + "pos": [100, 100], + "size": [315, 98], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { "name": "MODEL", "type": "MODEL", "links": null }, + { "name": "CLIP", "type": "CLIP", "links": null }, + { "name": "VAE", "type": "VAE", "links": null } + ], + "properties": { + "Node name for S&R": "CheckpointLoaderSimple" + }, + "widgets_values": ["fake_model_a.safetensors"] + }, + { + "id": 2, + "type": "CheckpointLoaderSimple", + "pos": [500, 100], + "size": [315, 98], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { "name": "MODEL", "type": "MODEL", "links": null }, + { "name": "CLIP", "type": "CLIP", "links": null }, + { "name": "VAE", "type": "VAE", "links": null } + ], + "properties": { + "Node name for S&R": "CheckpointLoaderSimple" + }, + "widgets_values": ["fake_model_b.safetensors"] + } + ], + "links": [], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 1, + "offset": [0, 0] + } + }, + "models": [ + { + "name": "fake_model_a.safetensors", + "url": "http://localhost:8188/api/devtools/fake_model.safetensors", + "directory": "checkpoints" + }, + { + "name": "fake_model_b.safetensors", + "url": "http://localhost:8188/api/devtools/fake_model.safetensors", + "directory": "checkpoints" + } + ], + "version": 0.4 +} diff --git a/browser_tests/assets/missing/missing_models_in_bypassed_subgraph.json b/browser_tests/assets/missing/missing_models_in_bypassed_subgraph.json new file mode 100644 index 00000000000..b72aa7051a9 --- /dev/null +++ b/browser_tests/assets/missing/missing_models_in_bypassed_subgraph.json @@ -0,0 +1,141 @@ +{ + "id": "test-missing-models-in-bypassed-subgraph", + "revision": 0, + "last_node_id": 2, + "last_link_id": 0, + "nodes": [ + { + "id": 1, + "type": "KSampler", + "pos": [100, 100], + "size": [270, 262], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { "name": "model", "type": "MODEL", "link": null }, + { "name": "positive", "type": "CONDITIONING", "link": null }, + { "name": "negative", "type": "CONDITIONING", "link": null }, + { "name": "latent_image", "type": "LATENT", "link": null } + ], + "outputs": [{ "name": "LATENT", "type": "LATENT", "links": [] }], + "properties": { + "Node name for S&R": "KSampler" + }, + "widgets_values": [0, "randomize", 20, 8, "euler", "simple", 1] + }, + { + "id": 2, + "type": "subgraph-with-missing-model", + "pos": [450, 100], + "size": [400, 200], + "flags": {}, + "order": 0, + "mode": 4, + "inputs": [{ "name": "model", "type": "MODEL", "link": null }], + "outputs": [{ "name": "MODEL", "type": "MODEL", "links": null }], + "properties": {}, + "widgets_values": [] + } + ], + "links": [], + "groups": [], + "definitions": { + "subgraphs": [ + { + "id": "subgraph-with-missing-model", + "version": 1, + "state": { + "lastGroupId": 0, + "lastNodeId": 1, + "lastLinkId": 2, + "lastRerouteId": 0 + }, + "revision": 0, + "config": {}, + "name": "Subgraph with Missing Model", + "inputNode": { + "id": -10, + "bounding": [100, 200, 120, 60] + }, + "outputNode": { + "id": -20, + "bounding": [500, 200, 120, 60] + }, + "inputs": [ + { + "id": "input1-id", + "name": "model", + "type": "MODEL", + "linkIds": [1], + "pos": { "0": 150, "1": 220 } + } + ], + "outputs": [ + { + "id": "output1-id", + "name": "MODEL", + "type": "MODEL", + "linkIds": [2], + "pos": { "0": 520, "1": 220 } + } + ], + "widgets": [], + "nodes": [ + { + "id": 1, + "type": "CheckpointLoaderSimple", + "pos": [250, 180], + "size": [315, 98], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { "name": "MODEL", "type": "MODEL", "links": [2] }, + { "name": "CLIP", "type": "CLIP", "links": null }, + { "name": "VAE", "type": "VAE", "links": null } + ], + "properties": { + "Node name for S&R": "CheckpointLoaderSimple" + }, + "widgets_values": ["fake_model.safetensors"] + } + ], + "links": [ + { + "id": 1, + "origin_id": -10, + "origin_slot": 0, + "target_id": 1, + "target_slot": 0, + "type": "MODEL" + }, + { + "id": 2, + "origin_id": 1, + "origin_slot": 0, + "target_id": -20, + "target_slot": 0, + "type": "MODEL" + } + ] + } + ] + }, + "config": {}, + "extra": { + "ds": { + "scale": 1, + "offset": [0, 0] + } + }, + "models": [ + { + "name": "fake_model.safetensors", + "url": "http://localhost:8188/api/devtools/fake_model.safetensors", + "directory": "checkpoints" + } + ], + "version": 0.4 +} diff --git a/browser_tests/tests/errorOverlay.spec.ts b/browser_tests/tests/errorOverlay.spec.ts index cb17f94dfa8..6ebfee36ab2 100644 --- a/browser_tests/tests/errorOverlay.spec.ts +++ b/browser_tests/tests/errorOverlay.spec.ts @@ -214,4 +214,34 @@ test.describe('Error overlay', { tag: '@ui' }, () => { await expect(overlay).toBeHidden() }) }) + + test.describe('Count independence from node selection', () => { + test.beforeEach(async ({ comfyPage }) => { + await cleanupFakeModel(comfyPage) + }) + + test.afterEach(async ({ comfyPage }) => { + await cleanupFakeModel(comfyPage) + }) + + test('missing model count stays constant when a node is selected', async ({ + comfyPage + }) => { + // Regression: ErrorOverlay previously read the selection-filtered + // missingModelGroups from useErrorGroups, so selecting one of two + // missing-model nodes would shrink the overlay label from + // "2 required models are missing" to "1". The overlay must show + // the workflow total regardless of canvas selection. + await comfyPage.workflow.loadWorkflow('missing/missing_models_distinct') + + const overlay = getOverlay(comfyPage.page) + await expect(overlay).toBeVisible() + await expect(overlay).toContainText(/2 required models are missing/i) + + const node = await comfyPage.nodeOps.getNodeRefById('1') + await node.click('title') + + await expect(overlay).toContainText(/2 required models are missing/i) + }) + }) }) diff --git a/browser_tests/tests/propertiesPanel/errorsTabModeAware.spec.ts b/browser_tests/tests/propertiesPanel/errorsTabModeAware.spec.ts index 4e777f550d0..7db9ff9c46b 100644 --- a/browser_tests/tests/propertiesPanel/errorsTabModeAware.spec.ts +++ b/browser_tests/tests/propertiesPanel/errorsTabModeAware.spec.ts @@ -113,6 +113,40 @@ test.describe('Errors tab - Mode-aware errors', { tag: '@ui' }, () => { await expect(missingModelGroup).toBeVisible() }) + test('Bypass/un-bypass cycle preserves Copy URL button on the restored row', async ({ + comfyPage + }) => { + // Regression: on un-bypass, the realtime scan produced a fresh + // candidate without url/hash/directory — those fields were only + // attached by the full pipeline's enrichWithEmbeddedMetadata. The + // row's Copy URL button (v-if gated on representative.url) then + // disappeared. Per-node scan now enriches from node.properties.models + // which persists across mode toggles. Uses the `_from_node_properties` + // fixture because the enrichment source is per-node metadata, not + // the workflow-level `models[]` array (which the realtime scan + // path does not see). + await loadWorkflowAndOpenErrorsTab( + comfyPage, + 'missing/missing_models_from_node_properties' + ) + + const copyUrlButton = comfyPage.page.getByTestId( + TestIds.dialogs.missingModelCopyUrl + ) + await expect(copyUrlButton.first()).toBeVisible() + + const node = await comfyPage.nodeOps.getNodeRefById('1') + await node.click('title') + await comfyPage.keyboard.bypass() + await expect.poll(() => node.isBypassed()).toBeTruthy() + + await node.click('title') + await comfyPage.keyboard.bypass() + await expect.poll(() => node.isBypassed()).toBeFalsy() + await openErrorsTab(comfyPage) + await expect(copyUrlButton.first()).toBeVisible() + }) + test('Pasting a node with missing model increases referencing node count', async ({ comfyPage }) => { @@ -476,6 +510,52 @@ test.describe('Errors tab - Mode-aware errors', { tag: '@ui' }, () => { await openErrorsTab(comfyPage) await expect(missingModelGroup).toBeVisible() }) + + test('Loading a workflow with bypassed subgraph suppresses interior missing model error', async ({ + comfyPage + }) => { + // Regression: the initial scan pipeline only checked each node's + // own mode, so interior nodes of a bypassed subgraph container + // surfaced errors even though the container was excluded from + // execution. The pipeline now post-filters candidates whose + // ancestor path is not fully active. + await comfyPage.workflow.loadWorkflow( + 'missing/missing_models_in_bypassed_subgraph' + ) + + const errorOverlay = comfyPage.page.getByTestId( + TestIds.dialogs.errorOverlay + ) + await expect(errorOverlay).toBeHidden() + + await comfyPage.actionbar.propertiesButton.click() + await expect( + comfyPage.page.getByTestId(TestIds.propertiesPanel.errorsTab) + ).toBeHidden() + }) + + test('Entering a bypassed subgraph does not resurface interior missing model error', async ({ + comfyPage + }) => { + // Regression: useGraphNodeManager replays graph.onNodeAdded for + // each interior node on subgraph entry; without an ancestor-aware + // guard in scanSingleNodeErrors, that re-scan reintroduced the + // error that the initial pipeline had correctly suppressed. + await comfyPage.workflow.loadWorkflow( + 'missing/missing_models_in_bypassed_subgraph' + ) + + const errorsTab = comfyPage.page.getByTestId( + TestIds.propertiesPanel.errorsTab + ) + await comfyPage.actionbar.propertiesButton.click() + await expect(errorsTab).toBeHidden() + + const subgraphNode = await comfyPage.nodeOps.getNodeRefById('2') + await subgraphNode.navigateIntoSubgraph() + + await expect(errorsTab).toBeHidden() + }) }) test.describe('Workflow switching', () => { From 9272259a07bf0d42fd4fc9819bb22e400b907895 Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Tue, 14 Apr 2026 16:00:39 +0900 Subject: [PATCH 05/10] fix: guard three edge cases surfaced by code review agents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three narrowly-scoped defensive fixes found during parallel subagent review of this branch: 1. enrichCandidateFromNodeProperties now requires directory agreement when the candidate already carries one. Without this, a node referencing the same model name under two directories (e.g. a LoRA present in multiple folders) could get the wrong url/hash stamped onto a candidate — name-only matching was too loose. Mirrors the directory check already present in enrichWithEmbeddedMetadata. 2. scanSingleNodeErrors now skips when its execution ID cannot be resolved (node is detached or has no graph). The previous guard short-circuited only on a falsy rootGraph check, so a detached node whose own mode looked active could still drive the missing- node-type scan path. 3. isCandidateStillActive in the realtime verification callback now also confirms the ancestor path is active, mirroring the initial-pipeline post-filter. Without this, re-bypassing an outer subgraph during an in-flight per-node verification would leak a stale missing-asset entry into the store. Added one unit test for the directory-collision path. --- .../graph/useErrorClearingHooks.ts | 16 +++++-- .../missingModel/missingModelScan.test.ts | 43 +++++++++++++++++-- src/platform/missingModel/missingModelScan.ts | 11 ++++- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/composables/graph/useErrorClearingHooks.ts b/src/composables/graph/useErrorClearingHooks.ts index c1c3d1041d5..b9a842a3cf4 100644 --- a/src/composables/graph/useErrorClearingHooks.ts +++ b/src/composables/graph/useErrorClearingHooks.ts @@ -176,9 +176,11 @@ function scanSingleNodeErrors(node: LGraphNode): void { // Skip when any enclosing subgraph is muted/bypassed. Callers only // verify each node's own mode; entering a bypassed subgraph (via // useGraphNodeManager replaying onNodeAdded for existing interior - // nodes) reaches this point without the ancestor check. + // nodes) reaches this point without the ancestor check. A null + // execId means the node has no current graph (e.g. detached mid + // lifecycle) — also skip, since we cannot verify its scope. const execId = getExecutionIdByNode(app.rootGraph, node) - if (execId && !isAncestorPathActive(app.rootGraph, execId)) return + if (!execId || !isAncestorPathActive(app.rootGraph, execId)) return const modelCandidates = scanNodeModelCandidates( app.rootGraph, @@ -244,9 +246,15 @@ function scanSingleNodeErrors(node: LGraphNode): void { */ function isCandidateStillActive(nodeId: unknown): boolean { if (!app.rootGraph || nodeId == null) return false - const node = getNodeByExecutionId(app.rootGraph, String(nodeId)) + const execId = String(nodeId) + const node = getNodeByExecutionId(app.rootGraph, execId) if (!node) return false - return !isNodeInactive(node.mode) + if (isNodeInactive(node.mode)) return false + // Also reject if any enclosing subgraph was bypassed between scan + // kick-off and verification resolving — mirrors the pipeline-level + // ancestor post-filter so realtime and initial-load paths stay + // symmetric. + return isAncestorPathActive(app.rootGraph, execId) } async function verifyAndAddPendingModels( diff --git a/src/platform/missingModel/missingModelScan.test.ts b/src/platform/missingModel/missingModelScan.test.ts index 3e458f60856..6ff0a2ad594 100644 --- a/src/platform/missingModel/missingModelScan.test.ts +++ b/src/platform/missingModel/missingModelScan.test.ts @@ -204,7 +204,7 @@ describe('scanNodeModelCandidates', () => { { name: 'missing_model.safetensors', url: 'https://example.com/new_url', - directory: 'new_dir' + directory: 'checkpoints' } ] } @@ -214,17 +214,54 @@ describe('scanNodeModelCandidates', () => { graph, node, noAssetSupport, - () => 'existing_dir' + () => 'checkpoints' ) expect(result).toHaveLength(1) // scanComboWidget already sets directory via getDirectory; enrichment // does not overwrite it. - expect(result[0].directory).toBe('existing_dir') + expect(result[0].directory).toBe('checkpoints') // url was not set by scan, so enrichment fills it in. expect(result[0].url).toBe('https://example.com/new_url') }) + it('skips enrichment when candidate and embedded model directories differ', () => { + // A node can list the same model name under multiple directories + // (e.g. a LoRA present in both `loras` and `loras/subdir`). Name-only + // matching would stamp the wrong url/hash onto the candidate, so + // enrichment must agree on directory when the candidate already has + // one. + const graph = makeGraph([]) + const node = fromAny({ + id: 1, + type: 'CheckpointLoaderSimple', + widgets: [ + makeComboWidget('ckpt_name', 'collision_model.safetensors', []) + ], + properties: { + models: [ + { + name: 'collision_model.safetensors', + url: 'https://example.com/wrong_dir_url', + directory: 'wrong_dir' + } + ] + } + }) + + const result = scanNodeModelCandidates( + graph, + node, + noAssetSupport, + () => 'checkpoints' + ) + + expect(result).toHaveLength(1) + expect(result[0].directory).toBe('checkpoints') + // Directory mismatch — enrichment should not stamp the wrong url. + expect(result[0].url).toBeUndefined() + }) + it('does not enrich candidates with mismatched model names', () => { const graph = makeGraph([]) const node = fromAny({ diff --git a/src/platform/missingModel/missingModelScan.ts b/src/platform/missingModel/missingModelScan.ts index 30562b8e945..f0993882ef0 100644 --- a/src/platform/missingModel/missingModelScan.ts +++ b/src/platform/missingModel/missingModelScan.ts @@ -44,7 +44,16 @@ function enrichCandidateFromNodeProperties( embeddedModels: readonly ModelFile[] | undefined ): MissingModelCandidate { if (!embeddedModels?.length) return candidate - const match = embeddedModels.find((m) => m.name === candidate.name) + // Require directory agreement when the candidate already has one — + // a single node can reference two models with the same name under + // different directories (e.g. a LoRA present in multiple folders); + // name-only matching would stamp the wrong url/hash onto the + // candidate. Mirrors the directory check in enrichWithEmbeddedMetadata. + const match = embeddedModels.find( + (m) => + m.name === candidate.name && + (!candidate.directory || candidate.directory === m.directory) + ) if (!match) return candidate return { ...candidate, From ca09190cd1c5c7fbc6884500f96cbc0cf1058d1a Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Tue, 14 Apr 2026 16:37:53 +0900 Subject: [PATCH 06/10] test: align missing_models_from_node_properties directory with node type The fixture's properties.models[0].directory was 'text_encoders', but the node is a CheckpointLoaderSimple whose modelToNodeStore category is 'checkpoints'. The old name-only enrichment silently tolerated the mismatch, so the test's Copy URL button assertion passed. The new enrichCandidateFromNodeProperties rejects mismatched directories (guards against stamping the wrong url/hash onto a collision candidate), which correctly skipped enrichment and hid the button. Updating the fixture aligns it with the node's real directory and restores the intended coverage. --- .../assets/missing/missing_models_from_node_properties.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser_tests/assets/missing/missing_models_from_node_properties.json b/browser_tests/assets/missing/missing_models_from_node_properties.json index b1a8e5a6727..a40cd543c8b 100644 --- a/browser_tests/assets/missing/missing_models_from_node_properties.json +++ b/browser_tests/assets/missing/missing_models_from_node_properties.json @@ -34,7 +34,7 @@ { "name": "fake_model.safetensors", "url": "http://localhost:8188/api/devtools/fake_model.safetensors", - "directory": "text_encoders" + "directory": "checkpoints" } ] }, From 5b06ae1caa6ff67ac5cfbb5927d66359884e63c5 Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Tue, 14 Apr 2026 16:43:22 +0900 Subject: [PATCH 07/10] test: address CodeRabbit review feedback on #11233 - missing_models_distinct.json: bump both node sizes from [315, 98] to [400, 200] to follow the browser_tests asset convention (minimum size avoids navigateIntoSubgraph timeout issues downstream). - useErrorGroups.test.ts: the 'returns total regardless of selection' case did not simulate selection, so both unfiltered and filtered variants would have returned the same value and the test could not prove the ErrorOverlay contract. Set canvasStore.selectedItems and mock isLGraphNode to true for the simulated node; assert the unfiltered total stays at 2 and that the filtered shape diverges. CodeRabbit also flagged an inline cast in missingModelScan.ts (enrichCandidateFromNodeProperties) as a nitpick; left as-is since it is a single call site and the reviewer marked it acceptable. --- .../missing/missing_models_distinct.json | 4 +-- .../errors/useErrorGroups.test.ts | 27 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/browser_tests/assets/missing/missing_models_distinct.json b/browser_tests/assets/missing/missing_models_distinct.json index e7ed31c668f..d7a9c703fc3 100644 --- a/browser_tests/assets/missing/missing_models_distinct.json +++ b/browser_tests/assets/missing/missing_models_distinct.json @@ -6,7 +6,7 @@ "id": 1, "type": "CheckpointLoaderSimple", "pos": [100, 100], - "size": [315, 98], + "size": [400, 200], "flags": {}, "order": 0, "mode": 0, @@ -25,7 +25,7 @@ "id": 2, "type": "CheckpointLoaderSimple", "pos": [500, 100], - "size": [315, 98], + "size": [400, 200], "flags": {}, "order": 1, "mode": 0, diff --git a/src/components/rightSidePanel/errors/useErrorGroups.test.ts b/src/components/rightSidePanel/errors/useErrorGroups.test.ts index 8f78194e4ac..0d98e19fca0 100644 --- a/src/components/rightSidePanel/errors/useErrorGroups.test.ts +++ b/src/components/rightSidePanel/errors/useErrorGroups.test.ts @@ -58,8 +58,10 @@ vi.mock( }) ) +import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useExecutionErrorStore } from '@/stores/executionErrorStore' import { useMissingNodesErrorStore } from '@/platform/nodeReplacement/missingNodesErrorStore' +import { isLGraphNode } from '@/utils/litegraphUtil' import { useErrorGroups } from './useErrorGroups' function makeMissingNodeType( @@ -770,13 +772,32 @@ describe('useErrorGroups', () => { makeModel('a.safetensors', { nodeId: '1', directory: 'checkpoints' }), makeModel('b.safetensors', { nodeId: '2', directory: 'checkpoints' }) ]) + // Simulate canvas selection of a single node so the filtered + // variant actually narrows. Without this, both sides return the + // same value trivially and the test can't prove the contract. + vi.mocked(isLGraphNode).mockReturnValue(true) + const canvasStore = useCanvasStore() + canvasStore.selectedItems = fromAny< + typeof canvasStore.selectedItems, + unknown + >([{ id: '1' }]) await nextTick() - // Regardless of any selection state, missingModelGroups must remain - // the full set — ErrorOverlay reads it for the total error count - // label and should not reflect tab-level node selection filtering. + // Unfiltered total stays at one group of two models regardless of + // the selection — ErrorOverlay reads this for the overlay label + // and must not shrink with canvas selection. expect(groups.missingModelGroups.value).toHaveLength(1) expect(groups.missingModelGroups.value[0].models).toHaveLength(2) + + // Filtered variant does narrow under the same selection state — + // this is how the errors tab scopes cards to the selected node. + // Exact filtered output depends on the app.rootGraph lookup + // (mocked to return undefined here); what matters is that the + // filtered shape is a different reference and does not blindly + // mirror the unfiltered one. + expect(groups.filteredMissingModelGroups.value).not.toBe( + groups.missingModelGroups.value + ) }) }) }) From 4e0104e0d77d1dab267eaec99a089a32cb563c23 Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Wed, 15 Apr 2026 10:49:06 +0900 Subject: [PATCH 08/10] fix: address dante01yoon review + subagent follow-ups on #11233 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug fixes driven by PR review: 1. Cloud verification staleness (app.ts runMissingModelPipeline / runMissingMediaPipeline): the async verify().then() surfaced confirmed candidates without re-checking whether the user had bypassed an enclosing subgraph mid-verification. Both pipelines now apply the ancestor check symmetrically with the realtime path. 2. Workflow-level reference ancestor-blind (missingModelScan.ts isModelReferencedByActiveNode): the helper only checked each referencing node's own mode, ignoring bypassed subgraph containers. A bypassed subgraph whose interior was the sole reference could still surface a top-level missing-model row. The helper now walks ancestors via getParentExecutionIds against a flattened id→node map. Positive and negative control fixtures verify both directions. Subagent follow-ups on the same commit: - Extract isMissingCandidateActive into graphTraversalUtil so the three async-resolution call sites (model/media pipelines + realtime verification) share a single predicate. - Hoist the flattened id→node map to enrichWithEmbeddedMetadata scope so isModelReferencedByActiveNode doesn't rebuild it per unmatched entry (was O(W*N) allocation). - Rename hasActiveAncestorsInFlattened → isAncestorPathActiveInFlattened for naming symmetry with the live-graph variant. - Document the intentional asymmetry: a candidate dropped by the pipeline-start ancestor filter is not resurrected if the user un-bypasses mid-verification; the realtime mode-change path owns re-surfacing errors after un-bypass. - Unit tests for isMissingCandidateActive (4 cases) plus a positive-control fixture so the Bug 2 regression test cannot pass trivially if a future refactor drops all workflow-level entries. --- .../activeSubgraphUnmatchedModel.json | 83 +++++++++++++++++++ .../bypassedSubgraphUnmatchedModel.json | 83 +++++++++++++++++++ .../missingModel/missingModelScan.test.ts | 31 +++++++ src/platform/missingModel/missingModelScan.ts | 27 +++++- src/scripts/app.ts | 16 +++- src/utils/graphTraversalUtil.test.ts | 69 ++++++++++++++- src/utils/graphTraversalUtil.ts | 20 +++++ 7 files changed, 323 insertions(+), 6 deletions(-) create mode 100644 src/platform/missingModel/__fixtures__/activeSubgraphUnmatchedModel.json create mode 100644 src/platform/missingModel/__fixtures__/bypassedSubgraphUnmatchedModel.json diff --git a/src/platform/missingModel/__fixtures__/activeSubgraphUnmatchedModel.json b/src/platform/missingModel/__fixtures__/activeSubgraphUnmatchedModel.json new file mode 100644 index 00000000000..6be16a28d6f --- /dev/null +++ b/src/platform/missingModel/__fixtures__/activeSubgraphUnmatchedModel.json @@ -0,0 +1,83 @@ +{ + "last_node_id": 2, + "last_link_id": 0, + "nodes": [ + { + "id": 1, + "type": "KSampler", + "pos": [0, 0], + "size": [100, 100], + "flags": {}, + "order": 1, + "mode": 0, + "properties": {}, + "widgets_values": [0, "randomize", 20] + }, + { + "id": 2, + "type": "subgraph-x", + "pos": [300, 0], + "size": [100, 100], + "flags": {}, + "order": 0, + "mode": 0, + "properties": {}, + "widgets_values": [] + } + ], + "links": [], + "groups": [], + "config": {}, + "extra": {}, + "version": 0.4, + "definitions": { + "subgraphs": [ + { + "id": "subgraph-x", + "version": 1, + "state": { + "lastGroupId": 0, + "lastNodeId": 1, + "lastLinkId": 0, + "lastRerouteId": 0 + }, + "revision": 0, + "config": {}, + "name": "x", + "nodes": [ + { + "id": 1, + "type": "CheckpointLoaderSimple", + "pos": [0, 0], + "size": [100, 100], + "flags": {}, + "order": 0, + "mode": 0, + "properties": { + "models": [ + { + "name": "rare_model.safetensors", + "directory": "checkpoints" + } + ] + }, + "widgets_values": ["some_other_model.safetensors"] + } + ], + "links": [], + "inputNode": { "id": -10, "bounding": [0, 0, 0, 0] }, + "outputNode": { "id": -20, "bounding": [0, 0, 0, 0] }, + "inputs": [], + "outputs": [], + "widgets": [] + } + ] + }, + "models": [ + { + "name": "rare_model.safetensors", + "url": "https://example.com/rare", + "directory": "checkpoints" + } + ] +} diff --git a/src/platform/missingModel/__fixtures__/bypassedSubgraphUnmatchedModel.json b/src/platform/missingModel/__fixtures__/bypassedSubgraphUnmatchedModel.json new file mode 100644 index 00000000000..959b1034eee --- /dev/null +++ b/src/platform/missingModel/__fixtures__/bypassedSubgraphUnmatchedModel.json @@ -0,0 +1,83 @@ +{ + "last_node_id": 2, + "last_link_id": 0, + "nodes": [ + { + "id": 1, + "type": "KSampler", + "pos": [0, 0], + "size": [100, 100], + "flags": {}, + "order": 1, + "mode": 0, + "properties": {}, + "widgets_values": [0, "randomize", 20] + }, + { + "id": 2, + "type": "subgraph-x", + "pos": [300, 0], + "size": [100, 100], + "flags": {}, + "order": 0, + "mode": 4, + "properties": {}, + "widgets_values": [] + } + ], + "links": [], + "groups": [], + "config": {}, + "extra": {}, + "version": 0.4, + "definitions": { + "subgraphs": [ + { + "id": "subgraph-x", + "version": 1, + "state": { + "lastGroupId": 0, + "lastNodeId": 1, + "lastLinkId": 0, + "lastRerouteId": 0 + }, + "revision": 0, + "config": {}, + "name": "x", + "nodes": [ + { + "id": 1, + "type": "CheckpointLoaderSimple", + "pos": [0, 0], + "size": [100, 100], + "flags": {}, + "order": 0, + "mode": 0, + "properties": { + "models": [ + { + "name": "rare_model.safetensors", + "directory": "checkpoints" + } + ] + }, + "widgets_values": ["some_other_model.safetensors"] + } + ], + "links": [], + "inputNode": { "id": -10, "bounding": [0, 0, 0, 0] }, + "outputNode": { "id": -20, "bounding": [0, 0, 0, 0] }, + "inputs": [], + "outputs": [], + "widgets": [] + } + ] + }, + "models": [ + { + "name": "rare_model.safetensors", + "url": "https://example.com/rare", + "directory": "checkpoints" + } + ] +} diff --git a/src/platform/missingModel/missingModelScan.test.ts b/src/platform/missingModel/missingModelScan.test.ts index 6ff0a2ad594..c45345eb4c7 100644 --- a/src/platform/missingModel/missingModelScan.test.ts +++ b/src/platform/missingModel/missingModelScan.test.ts @@ -15,6 +15,8 @@ import { verifyAssetSupportedCandidates, MODEL_FILE_EXTENSIONS } from '@/platform/missingModel/missingModelScan' +import activeSubgraphUnmatchedModel from '@/platform/missingModel/__fixtures__/activeSubgraphUnmatchedModel.json' with { type: 'json' } +import bypassedSubgraphUnmatchedModel from '@/platform/missingModel/__fixtures__/bypassedSubgraphUnmatchedModel.json' with { type: 'json' } import type { MissingModelCandidate } from '@/platform/missingModel/types' import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema' @@ -1053,6 +1055,35 @@ describe('enrichWithEmbeddedMetadata', () => { expect(result).toHaveLength(0) }) + + it('drops workflow-level entries when only reference is in a bypassed subgraph interior', async () => { + // Interior properties.models references the workflow-level model + // but its widget value does not — forcing the workflow-level entry + // down the unmatched path where isModelReferencedByActiveNode + // decides. Previously the helper ignored the bypassed container. + const result = await enrichWithEmbeddedMetadata( + [], + fromAny(bypassedSubgraphUnmatchedModel), + alwaysMissing + ) + + expect(result).toHaveLength(0) + }) + + it('keeps workflow-level entries when reference is in an active subgraph interior', async () => { + // Positive control for the bypassed case above: identical fixture + // with container mode=0 must still surface the unmatched workflow- + // level model. Guards against a regression where the ancestor gate + // drops every workflow-level entry regardless of context. + const result = await enrichWithEmbeddedMetadata( + [], + fromAny(activeSubgraphUnmatchedModel), + alwaysMissing + ) + + expect(result).toHaveLength(1) + expect(result[0].name).toBe('rare_model.safetensors') + }) }) describe('OSS missing model detection (non-Cloud path)', () => { diff --git a/src/platform/missingModel/missingModelScan.ts b/src/platform/missingModel/missingModelScan.ts index f0993882ef0..65de684de9e 100644 --- a/src/platform/missingModel/missingModelScan.ts +++ b/src/platform/missingModel/missingModelScan.ts @@ -20,6 +20,7 @@ import type { IBaseWidget, IComboWidget } from '@/lib/litegraph/src/types/widgets' +import { getParentExecutionIds } from '@/types/nodeIdentification' import { collectAllNodes, getExecutionIdByNode @@ -271,9 +272,13 @@ export async function enrichWithEmbeddedMetadata( // model — not merely because any unrelated active node exists. A // reference is any widget value (or node.properties.models entry) // that matches the model name on an active node. + // Hoist the id→node map once; isModelReferencedByActiveNode would + // otherwise rebuild it on every unmatched entry. + const flattenedNodeById = new Map(allNodes.map((n) => [String(n.id), n])) const activeUnmatched = unmatched.filter( (m) => - m.sourceNodeType !== '' || isModelReferencedByActiveNode(m.name, allNodes) + m.sourceNodeType !== '' || + isModelReferencedByActiveNode(m.name, allNodes, flattenedNodeById) ) const settled = await Promise.allSettled( @@ -316,7 +321,8 @@ export async function enrichWithEmbeddedMetadata( function isModelReferencedByActiveNode( modelName: string, - allNodes: ReturnType + allNodes: ReturnType, + nodeById: Map[number]> ): boolean { for (const node of allNodes) { if ( @@ -324,6 +330,7 @@ function isModelReferencedByActiveNode( node.mode === LGraphEventMode.BYPASS ) continue + if (!isAncestorPathActiveInFlattened(String(node.id), nodeById)) continue const embeddedModels = ( node.properties as { models?: Array<{ name: string }> } | undefined @@ -340,6 +347,22 @@ function isModelReferencedByActiveNode( return false } +function isAncestorPathActiveInFlattened( + executionId: string, + nodeById: Map[number]> +): boolean { + for (const ancestorId of getParentExecutionIds(executionId)) { + const ancestor = nodeById.get(ancestorId) + if (!ancestor) continue + if ( + ancestor.mode === LGraphEventMode.NEVER || + ancestor.mode === LGraphEventMode.BYPASS + ) + return false + } + return true +} + function collectEmbeddedModelsWithSource( allNodes: ReturnType, graphData: ComfyWorkflowJSON diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 03a53e3b110..f25ed4fcb16 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -109,6 +109,7 @@ import { forEachNode, getNodeByExecutionId, isAncestorPathActive, + isMissingCandidateActive, triggerCallbackOnAllNodes } from '@/utils/graphTraversalUtil' import { @@ -1513,6 +1514,10 @@ export class ComfyApp { // Drop candidates whose enclosing subgraph is muted/bypassed. Per-node // scans only checked each node's own mode; the cascade from an // inactive container to its interior happens here. + // Asymmetric on purpose: a candidate dropped here is not resurrected if + // the user un-bypasses the container mid-verification. The realtime + // mode-change path (handleNodeModeChange → scanAndAddNodeErrors) is + // responsible for surfacing errors after an un-bypass. const enrichedCandidates = enrichedAll.filter( (c) => c.nodeId == null || @@ -1556,8 +1561,10 @@ export class ComfyApp { ) .then(() => { if (controller.signal.aborted) return - const confirmed = enrichedCandidates.filter( - (c) => c.isMissing === true + // Re-check ancestor: user may have bypassed a container + // while verification was in flight. + const confirmed = enrichedCandidates.filter((c) => + isMissingCandidateActive(this.rootGraph, c) ) if (confirmed.length) { useExecutionErrorStore().surfaceMissingModels(confirmed, { @@ -1680,7 +1687,10 @@ export class ComfyApp { void verifyCloudMediaCandidates(candidates, controller.signal) .then(() => { if (controller.signal.aborted) return - const confirmed = candidates.filter((c) => c.isMissing === true) + // Re-check ancestor after async verification (see model pipeline). + const confirmed = candidates.filter((c) => + isMissingCandidateActive(this.rootGraph, c) + ) if (confirmed.length) { useExecutionErrorStore().surfaceMissingMedia(confirmed, { silent }) } diff --git a/src/utils/graphTraversalUtil.test.ts b/src/utils/graphTraversalUtil.test.ts index c17d03ce69a..db1612847c7 100644 --- a/src/utils/graphTraversalUtil.test.ts +++ b/src/utils/graphTraversalUtil.test.ts @@ -30,7 +30,8 @@ import { visitGraphNodes, getExecutionIdByNode, getExecutionIdForNodeInGraph, - isAncestorPathActive + isAncestorPathActive, + isMissingCandidateActive } from '@/utils/graphTraversalUtil' import { LGraphEventMode } from '@/lib/litegraph/src/types/globalEnums' @@ -794,6 +795,72 @@ describe('graphTraversalUtil', () => { }) }) + describe('isMissingCandidateActive', () => { + function makeBypassedContainer(interiorId: string) { + const interior = createMockNode(interiorId) + const subgraph = createMockSubgraph('sub', [interior]) + const container = createMockLGraphNode({ + id: 65, + isSubgraphNode: () => true, + subgraph, + mode: LGraphEventMode.BYPASS + }) satisfies Partial as LGraphNode + return createMockGraph([container]) + } + + it('surfaces confirmed missing candidates under active ancestors', () => { + const interior = createMockNode('63') + const subgraph = createMockSubgraph('sub', [interior]) + const container = createMockNode('65', { + isSubgraph: true, + subgraph + }) + const rootGraph = createMockGraph([container]) + expect( + isMissingCandidateActive(rootGraph, { + nodeId: '65:63', + isMissing: true + }) + ).toBe(true) + }) + + it('drops confirmed missing candidates whose ancestor is bypassed (cloud .then race)', () => { + // Mirrors the reopen gap: pipeline-start filter passed, then + // the user bypassed the container during verification, and the + // async resolver must not resurface the candidate. + const rootGraph = makeBypassedContainer('63') + expect( + isMissingCandidateActive(rootGraph, { + nodeId: '65:63', + isMissing: true + }) + ).toBe(false) + }) + + it('drops unverified candidates (isMissing !== true)', () => { + const rootGraph = createMockGraph([]) + expect( + isMissingCandidateActive(rootGraph, { + nodeId: '1', + isMissing: undefined + }) + ).toBe(false) + expect( + isMissingCandidateActive(rootGraph, { nodeId: '1', isMissing: false }) + ).toBe(false) + }) + + it('keeps workflow-level candidates (nodeId == null) when confirmed missing', () => { + const rootGraph = makeBypassedContainer('63') + expect( + isMissingCandidateActive(rootGraph, { + nodeId: undefined, + isMissing: true + }) + ).toBe(true) + }) + }) + describe('getExecutionIdFromNodeData', () => { it('should return the correct execution ID for a normal node', () => { const node = createMockNode('123') diff --git a/src/utils/graphTraversalUtil.ts b/src/utils/graphTraversalUtil.ts index 81aff7a41fb..c9167bdebf6 100644 --- a/src/utils/graphTraversalUtil.ts +++ b/src/utils/graphTraversalUtil.ts @@ -396,6 +396,26 @@ export function isAncestorPathActive( return true } +/** + * Predicate used after async verification resolves: a missing-asset + * candidate is surfaceable when it is confirmed missing and its + * enclosing subgraph is still active. Null `nodeId` (workflow-level + * models) bypasses the ancestor check since it has no scope to + * validate. Unified helper so the initial pipeline post-filter and the + * three async-resolution call sites cannot drift. + */ +export function isMissingCandidateActive( + rootGraph: LGraph | null | undefined, + candidate: { + nodeId?: string | number | null | undefined + isMissing?: boolean | undefined + } +): boolean { + if (candidate.isMissing !== true) return false + if (candidate.nodeId == null) return true + return isAncestorPathActive(rootGraph, String(candidate.nodeId)) +} + /** * Returns the execution ID for a node identified by its (graph, nodeId) pair. * From 280ee84ee2d306e0544f3881d54069453688521f Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Wed, 15 Apr 2026 13:33:32 +0900 Subject: [PATCH 09/10] fix: two more correctness gaps from PR #11233 round 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue A — realtime verification stale across workflow switches. isCandidateStillActive only re-resolves the candidate's nodeId against the current app.rootGraph, but did not detect that the current rootGraph is a different workflow. Root-level execution IDs (e.g. '1') collide across workflows, so a late verification from workflow A could match an unrelated node in workflow B and leak a stale missing-model error. Capture app.rootGraph at scan time in verifyAndAddPendingModels and verifyAndAddPendingMedia; bail out on the .then() if it no longer matches. Issue B — graphData.models fallback matched by filename only. isModelReferencedByActiveNode ignored directory when deciding whether to keep an unmatched workflow-level model alive. A same-name / different-directory setup in the interior's properties.models then kept an unrelated workflow-level entry as missing. The fallback candidate had no nodeId, so the later ancestor filter in app.ts could not remove the false positive. Require directory agreement for properties.models matches when both sides specify one; widgets_values matches remain name-only because that source does not carry directory info. Tests: two new cases covering both scenarios. --- .../graph/useErrorClearingHooks.test.ts | 55 +++++++++++++++++++ .../graph/useErrorClearingHooks.ts | 7 +++ .../missingModel/missingModelScan.test.ts | 51 +++++++++++++++++ src/platform/missingModel/missingModelScan.ts | 29 +++++++++- 4 files changed, 139 insertions(+), 3 deletions(-) diff --git a/src/composables/graph/useErrorClearingHooks.test.ts b/src/composables/graph/useErrorClearingHooks.test.ts index b7bb7acf03f..1c2329274d0 100644 --- a/src/composables/graph/useErrorClearingHooks.test.ts +++ b/src/composables/graph/useErrorClearingHooks.test.ts @@ -728,6 +728,61 @@ describe('realtime verification staleness guards', () => { expect(useMissingMediaStore().missingMediaCandidates).toBeNull() }) + + it('skips adding verified model when rootGraph switched before verification resolved', async () => { + // Workflow A has a pending candidate on node id=1. A is replaced + // by workflow B (fresh LGraph, potentially has a node with the + // same id). Late verification from A must not leak into B. + const graphA = new LGraph() + const nodeA = new LGraphNode('CheckpointLoaderSimple') + graphA.add(nodeA) + const rootSpy = vi.spyOn(app, 'rootGraph', 'get').mockReturnValue(graphA) + + vi.spyOn(missingModelScan, 'scanNodeModelCandidates').mockReturnValue([ + { + nodeId: String(nodeA.id), + nodeType: 'CheckpointLoaderSimple', + widgetName: 'ckpt_name', + isAssetSupported: true, + name: 'stale_from_A.safetensors', + isMissing: undefined + } + ]) + let resolveVerify: (() => void) | undefined + const verifyPromise = new Promise((r) => (resolveVerify = r)) + const verifySpy = vi + .spyOn(missingModelScan, 'verifyAssetSupportedCandidates') + .mockImplementation(async (candidates) => { + await verifyPromise + for (const c of candidates) c.isMissing = true + }) + vi.spyOn(missingMediaScan, 'scanNodeMediaCandidates').mockReturnValue([]) + + installErrorClearingHooks(graphA) + + nodeA.mode = LGraphEventMode.ALWAYS + graphA.onTrigger?.({ + type: 'node:property:changed', + nodeId: nodeA.id, + property: 'mode', + oldValue: LGraphEventMode.BYPASS, + newValue: LGraphEventMode.ALWAYS + }) + await vi.waitFor(() => expect(verifySpy).toHaveBeenCalledOnce()) + + // Workflow swap: app.rootGraph now points at graphB. + const graphB = new LGraph() + const nodeB = new LGraphNode('CheckpointLoaderSimple') + graphB.add(nodeB) + rootSpy.mockReturnValue(graphB) + + resolveVerify!() + await new Promise((r) => setTimeout(r, 0)) + + // A's verification finished but rootGraph is now B — the late + // result must not be added to the store. + expect(useMissingModelStore().missingModelCandidates).toBeNull() + }) }) describe('scan skips interior of bypassed subgraph containers', () => { diff --git a/src/composables/graph/useErrorClearingHooks.ts b/src/composables/graph/useErrorClearingHooks.ts index b9a842a3cf4..88b1fbc04df 100644 --- a/src/composables/graph/useErrorClearingHooks.ts +++ b/src/composables/graph/useErrorClearingHooks.ts @@ -260,8 +260,13 @@ function isCandidateStillActive(nodeId: unknown): boolean { async function verifyAndAddPendingModels( pending: MissingModelCandidate[] ): Promise { + // Capture rootGraph at scan time so a late verification for workflow + // A cannot leak into workflow B after a switch — execution IDs (esp. + // root-level like "1") collide across workflows. + const rootGraphAtScan = app.rootGraph try { await verifyAssetSupportedCandidates(pending) + if (app.rootGraph !== rootGraphAtScan) return const verified = pending.filter( (c) => c.isMissing === true && isCandidateStillActive(c.nodeId) ) @@ -274,8 +279,10 @@ async function verifyAndAddPendingModels( async function verifyAndAddPendingMedia( pending: MissingMediaCandidate[] ): Promise { + const rootGraphAtScan = app.rootGraph try { await verifyCloudMediaCandidates(pending) + if (app.rootGraph !== rootGraphAtScan) return const verified = pending.filter( (c) => c.isMissing === true && isCandidateStillActive(c.nodeId) ) diff --git a/src/platform/missingModel/missingModelScan.test.ts b/src/platform/missingModel/missingModelScan.test.ts index c45345eb4c7..cc26dbc609a 100644 --- a/src/platform/missingModel/missingModelScan.test.ts +++ b/src/platform/missingModel/missingModelScan.test.ts @@ -1084,6 +1084,57 @@ describe('enrichWithEmbeddedMetadata', () => { expect(result).toHaveLength(1) expect(result[0].name).toBe('rare_model.safetensors') }) + + it('drops workflow-level entries when interior reference is under a different directory', async () => { + // Same name, different directory: the interior's properties.models + // entry is not the same asset as the workflow-level entry, so the + // fallback helper must not treat it as a reference that keeps the + // workflow-level model alive. + const graphData = fromPartial({ + last_node_id: 1, + last_link_id: 0, + nodes: [ + { + id: 1, + type: 'CheckpointLoaderSimple', + pos: [0, 0], + size: [100, 100], + flags: {}, + order: 0, + mode: 0, + properties: { + models: [ + { + name: 'collide_model.safetensors', + directory: 'loras' + } + ] + }, + widgets_values: ['unrelated_widget.safetensors'] + } + ], + links: [], + groups: [], + config: {}, + extra: {}, + version: 0.4, + models: [ + { + name: 'collide_model.safetensors', + url: 'https://example.com/collide', + directory: 'checkpoints' + } + ] + }) + + const result = await enrichWithEmbeddedMetadata( + [], + graphData, + alwaysMissing + ) + + expect(result).toHaveLength(0) + }) }) describe('OSS missing model detection (non-Cloud path)', () => { diff --git a/src/platform/missingModel/missingModelScan.ts b/src/platform/missingModel/missingModelScan.ts index 65de684de9e..54d64f4c830 100644 --- a/src/platform/missingModel/missingModelScan.ts +++ b/src/platform/missingModel/missingModelScan.ts @@ -278,7 +278,12 @@ export async function enrichWithEmbeddedMetadata( const activeUnmatched = unmatched.filter( (m) => m.sourceNodeType !== '' || - isModelReferencedByActiveNode(m.name, allNodes, flattenedNodeById) + isModelReferencedByActiveNode( + m.name, + m.directory, + allNodes, + flattenedNodeById + ) ) const settled = await Promise.allSettled( @@ -321,6 +326,7 @@ export async function enrichWithEmbeddedMetadata( function isModelReferencedByActiveNode( modelName: string, + modelDirectory: string | undefined, allNodes: ReturnType, nodeById: Map[number]> ): boolean { @@ -332,11 +338,28 @@ function isModelReferencedByActiveNode( continue if (!isAncestorPathActiveInFlattened(String(node.id), nodeById)) continue + // Require directory agreement when both sides specify one, so a + // same-name entry under a different folder does not keep an + // unrelated workflow-level model alive as missing. const embeddedModels = ( - node.properties as { models?: Array<{ name: string }> } | undefined + node.properties as + | { models?: Array<{ name: string; directory?: string }> } + | undefined )?.models - if (embeddedModels?.some((m) => m.name === modelName)) return true + if ( + embeddedModels?.some( + (m) => + m.name === modelName && + (modelDirectory === undefined || + m.directory === undefined || + m.directory === modelDirectory) + ) + ) { + return true + } + // widgets_values carries only the name, so directory cannot be + // checked here — fall back to filename matching. const values = node.widgets_values if (!values) continue const valueArray = Array.isArray(values) ? values : Object.values(values) From 0471374d9a13377f80ddbdcfb2a01e59285d391d Mon Sep 17 00:00:00 2001 From: jaeone94 Date: Wed, 15 Apr 2026 17:59:31 +0900 Subject: [PATCH 10/10] test: align missing_models_in_bypassed_subgraph fixture with [400, 200] minimum Matches the browser_tests asset convention (prevents navigateIntoSubgraph timeout issues). Same treatment already applied to missing_models_distinct.json. --- .../assets/missing/missing_models_in_bypassed_subgraph.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser_tests/assets/missing/missing_models_in_bypassed_subgraph.json b/browser_tests/assets/missing/missing_models_in_bypassed_subgraph.json index b72aa7051a9..8b812c96a76 100644 --- a/browser_tests/assets/missing/missing_models_in_bypassed_subgraph.json +++ b/browser_tests/assets/missing/missing_models_in_bypassed_subgraph.json @@ -8,7 +8,7 @@ "id": 1, "type": "KSampler", "pos": [100, 100], - "size": [270, 262], + "size": [400, 262], "flags": {}, "order": 1, "mode": 0, @@ -86,7 +86,7 @@ "id": 1, "type": "CheckpointLoaderSimple", "pos": [250, 180], - "size": [315, 98], + "size": [400, 200], "flags": {}, "order": 0, "mode": 0,