From c73056d399c5f63c8a5cb13ddda56171071496cf Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Tue, 6 Oct 2026 15:33:11 -0700 Subject: [PATCH 1/7] Add load time optimizations --- src/components/graph/GraphCanvas.vue | 3 ++ src/platform/distribution/types.ts | 5 ++ src/schemas/nodeDef/inputSpecTree.ts | 73 +++++++++++++--------------- src/scripts/app.ts | 3 -- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 1189f3fe2e7..b4623f47415 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -212,6 +212,7 @@ import { useAgentNodeSelectionStore } from '@/stores/agentNodeSelectionStore' import { useNodeDefStore } from '@/stores/nodeDefStore' import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore' import { useSearchBoxStore } from '@/stores/workspace/searchBoxStore' +import { useSubgraphStore } from '@/stores/subgraphStore' import { useAppMode } from '@/composables/useAppMode' import { useWorkspaceStore } from '@/stores/workspaceStore' import { forEachNode } from '@/utils/graphTraversalUtil' @@ -607,6 +608,8 @@ onMounted(async () => { emit('ready') + void useSubgraphStore().fetchSubgraphs() + // The tour draws into an overlay that only mounts once `ready` has flushed. await nextTick() try { diff --git a/src/platform/distribution/types.ts b/src/platform/distribution/types.ts index fb6f4e2f152..c0dfceb91b5 100644 --- a/src/platform/distribution/types.ts +++ b/src/platform/distribution/types.ts @@ -20,3 +20,8 @@ export const isCloud = DISTRIBUTION === 'cloud' * Nightly builds may show experimental features and surveys. */ export const isNightly = __IS_NIGHTLY__ + +/** + * Whether `/object_info` can be used without runtime schema validation. + */ +export const isTrustedObjectInfo = DISTRIBUTION === 'cloud' diff --git a/src/schemas/nodeDef/inputSpecTree.ts b/src/schemas/nodeDef/inputSpecTree.ts index 0abf8e599bd..40e546fa41d 100644 --- a/src/schemas/nodeDef/inputSpecTree.ts +++ b/src/schemas/nodeDef/inputSpecTree.ts @@ -1,5 +1,6 @@ -import type { ZodError } from 'zod' +import type { ZodError, z } from 'zod' +import { isTrustedObjectInfo } from '@/platform/distribution/types' import { reportError } from '@/platform/telemetry/reportError' import { transformInputSpecV1ToV2 } from '@/schemas/nodeDef/migration' import type { InputSpec as InputSpecV2 } from '@/schemas/nodeDef/nodeDefSchemaV2' @@ -66,6 +67,24 @@ function warnSpecDrift( }) } +/** + * `value` read through `schema`, or undefined when it does not match. Skips + * validation when `/object_info` is trusted; it dominates node registration. + */ +function parseSpec( + schema: z.ZodType, + value: unknown, + spec: InputSpecV2, + optionIndex?: number +): T | undefined { + if (isTrustedObjectInfo) return value as T + + const parsed = schema.safeParse(value) + if (parsed.success) return parsed.data + warnSpecDrift(spec, parsed.error, optionIndex) + return undefined +} + /** * Split a possibly comma-composite slot type into its parts. * @@ -86,42 +105,27 @@ export function splitSlotTypes(type: unknown): string[] { function parseDynamicComboOptions( spec: InputSpecV2 ): { key: string; inputs: ComfyInputsSpec }[] { - const parsed = zDynamicComboSpecV2.safeParse(spec) - if (!parsed.success) { - warnSpecDrift(spec, parsed.error) - return [] - } + const parsed = parseSpec(zDynamicComboSpecV2, spec, spec) + if (!parsed) return [] - return parsed.data.options.flatMap((option, index) => { - const parsedOption = zDynamicComboOption.safeParse(option) - if (!parsedOption.success) { - warnSpecDrift(spec, parsedOption.error, index) - return [] - } - return [parsedOption.data] + return parsed.options.flatMap((option, index) => { + const parsedOption = parseSpec(zDynamicComboOption, option, spec, index) + return parsedOption ? [parsedOption] : [] }) } const dynamicControls = { COMFY_DYNAMICGROUP_V3: { nestedInputs: (spec) => { - const parsed = zDynamicGroupInputSpec.safeParse([spec.type, spec]) - if (!parsed.success) { - warnSpecDrift(spec, parsed.error) - return [] - } - return [parsed.data[1].template] + const parsed = parseSpec(zDynamicGroupInputSpec, [spec.type, spec], spec) + return parsed ? [parsed[1].template] : [] }, ownTypes: none }, COMFY_AUTOGROW_V3: { nestedInputs: (spec) => { - const parsed = zAutogrowOptions.safeParse(spec) - if (!parsed.success) { - warnSpecDrift(spec, parsed.error) - return [] - } - return [parsed.data.template.input] + const parsed = parseSpec(zAutogrowOptions, spec, spec) + return parsed ? [parsed.template.input] : [] }, ownTypes: none }, @@ -133,12 +137,8 @@ const dynamicControls = { COMFY_MATCHTYPE_V3: { nestedInputs: none, ownTypes: (spec) => { - const parsed = zMatchTypeOptions.safeParse(spec) - if (!parsed.success) { - warnSpecDrift(spec, parsed.error) - return [] - } - return splitSlotTypes(parsed.data.template.allowed_types) + const parsed = parseSpec(zMatchTypeOptions, spec, spec) + return parsed ? splitSlotTypes(parsed.template.allowed_types) : [] } } } satisfies Record @@ -241,14 +241,11 @@ export function matchTypeTemplate( ): { templateId: string; allowedTypes: string[] } | undefined { if (spec.type !== 'COMFY_MATCHTYPE_V3') return undefined - const parsed = zMatchTypeOptions.safeParse(spec) - if (!parsed.success) { - warnSpecDrift(spec, parsed.error) - return undefined - } + const parsed = parseSpec(zMatchTypeOptions, spec, spec) + if (!parsed) return undefined return { - templateId: parsed.data.template.template_id, - allowedTypes: splitSlotTypes(parsed.data.template.allowed_types) + templateId: parsed.template.template_id, + allowedTypes: splitSlotTypes(parsed.template.allowed_types) } } diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 1dd5f95483c..35a381dc8b7 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -111,7 +111,6 @@ import { SYSTEM_NODE_DEFS, useNodeDefStore } from '@/stores/nodeDefStore' import { useNodeReplacementStore } from '@/platform/nodeReplacement/nodeReplacementStore' import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore' -import { useSubgraphStore } from '@/stores/subgraphStore' import { useWidgetStore } from '@/stores/widgetStore' import { useWidgetValueStore } from '@/stores/widgetValueStore' import { useWorkspaceStore } from '@/stores/workspaceStore' @@ -998,8 +997,6 @@ export class ComfyApp { this.canvasElRef.value = canvasEl await useWorkspaceStore().workflow.syncWorkflows() - //Doesn't need to block. Blueprints will load async - void useSubgraphStore().fetchSubgraphs() await bootstrapTracer.settle('bootstrap/extensions-load', () => useExtensionService().loadExtensions() ) From 10d6be064f2c256f7a8369dc1a4c311418bca7a0 Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Wed, 7 Oct 2026 16:14:42 -0700 Subject: [PATCH 2/7] Slight refactoring of overloads --- src/platform/distribution/types.ts | 3 -- src/schemas/nodeDef/inputSpecTree.ts | 65 ++++++++++++---------------- 2 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/platform/distribution/types.ts b/src/platform/distribution/types.ts index c0dfceb91b5..dee4d58ce0c 100644 --- a/src/platform/distribution/types.ts +++ b/src/platform/distribution/types.ts @@ -21,7 +21,4 @@ export const isCloud = DISTRIBUTION === 'cloud' */ export const isNightly = __IS_NIGHTLY__ -/** - * Whether `/object_info` can be used without runtime schema validation. - */ export const isTrustedObjectInfo = DISTRIBUTION === 'cloud' diff --git a/src/schemas/nodeDef/inputSpecTree.ts b/src/schemas/nodeDef/inputSpecTree.ts index 40e546fa41d..bd47c9d4a5e 100644 --- a/src/schemas/nodeDef/inputSpecTree.ts +++ b/src/schemas/nodeDef/inputSpecTree.ts @@ -67,22 +67,18 @@ function warnSpecDrift( }) } -/** - * `value` read through `schema`, or undefined when it does not match. Skips - * validation when `/object_info` is trusted; it dominates node registration. - */ function parseSpec( schema: z.ZodType, - value: unknown, spec: InputSpecV2, - optionIndex?: number -): T | undefined { - if (isTrustedObjectInfo) return value as T + option?: { option: unknown; index: number } +): T[] { + const value = option ? option.option : spec + if (isTrustedObjectInfo) return [value as T] const parsed = schema.safeParse(value) - if (parsed.success) return parsed.data - warnSpecDrift(spec, parsed.error, optionIndex) - return undefined + if (parsed.success) return [parsed.data] + warnSpecDrift(spec, parsed.error, option?.index) + return [] } /** @@ -105,28 +101,24 @@ export function splitSlotTypes(type: unknown): string[] { function parseDynamicComboOptions( spec: InputSpecV2 ): { key: string; inputs: ComfyInputsSpec }[] { - const parsed = parseSpec(zDynamicComboSpecV2, spec, spec) - if (!parsed) return [] - - return parsed.options.flatMap((option, index) => { - const parsedOption = parseSpec(zDynamicComboOption, option, spec, index) - return parsedOption ? [parsedOption] : [] - }) + return parseSpec(zDynamicComboSpecV2, spec).flatMap(({ options }) => + options.flatMap((option, index) => + parseSpec(zDynamicComboOption, spec, { option, index }) + ) + ) } const dynamicControls = { COMFY_DYNAMICGROUP_V3: { - nestedInputs: (spec) => { - const parsed = parseSpec(zDynamicGroupInputSpec, [spec.type, spec], spec) - return parsed ? [parsed[1].template] : [] - }, + nestedInputs: (spec) => + parseSpec(zDynamicGroupInputSpec.items[1], spec).map( + ({ template }) => template + ), ownTypes: none }, COMFY_AUTOGROW_V3: { - nestedInputs: (spec) => { - const parsed = parseSpec(zAutogrowOptions, spec, spec) - return parsed ? [parsed.template.input] : [] - }, + nestedInputs: (spec) => + parseSpec(zAutogrowOptions, spec).map(({ template }) => template.input), ownTypes: none }, COMFY_DYNAMICCOMBO_V3: { @@ -136,10 +128,10 @@ const dynamicControls = { }, COMFY_MATCHTYPE_V3: { nestedInputs: none, - ownTypes: (spec) => { - const parsed = parseSpec(zMatchTypeOptions, spec, spec) - return parsed ? splitSlotTypes(parsed.template.allowed_types) : [] - } + ownTypes: (spec) => + parseSpec(zMatchTypeOptions, spec).flatMap(({ template }) => + splitSlotTypes(template.allowed_types) + ) } } satisfies Record @@ -241,11 +233,10 @@ export function matchTypeTemplate( ): { templateId: string; allowedTypes: string[] } | undefined { if (spec.type !== 'COMFY_MATCHTYPE_V3') return undefined - const parsed = parseSpec(zMatchTypeOptions, spec, spec) - if (!parsed) return undefined - - return { - templateId: parsed.template.template_id, - allowedTypes: splitSlotTypes(parsed.template.allowed_types) - } + return parseSpec(zMatchTypeOptions, spec) + .map(({ template }) => ({ + templateId: template.template_id, + allowedTypes: splitSlotTypes(template.allowed_types) + })) + .at(0) } From 2079fe5a2ed314badebf30d4c8b6e7acf3d7d6d7 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Wed, 11 Nov 2026 11:49:17 -0800 Subject: [PATCH 3/7] Apply suggestion from @mrseek-reviews[bot] Co-authored-by: mrseek-reviews[bot] <337131926+mrseek-reviews[bot]@users.noreply.github.com> --- src/platform/distribution/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/distribution/types.ts b/src/platform/distribution/types.ts index 3fd6044dc58..2c7a535a307 100644 --- a/src/platform/distribution/types.ts +++ b/src/platform/distribution/types.ts @@ -21,4 +21,4 @@ export const isCloud = DISTRIBUTION === 'cloud' */ export const isNightly = __IS_NIGHTLY__ -export const isTrustedObjectInfo = DISTRIBUTION === 'cloud' +export const isTrustedObjectInfo = isCloud From 313d998389d7627daf32f717d39db1db663e7647 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Wed, 11 Nov 2026 20:11:05 +0000 Subject: [PATCH 4/7] fix: validate blueprint inputs and isolate loading failures Keep synthesized blueprint definitions on the validated interpreter while preserving the Cloud fast path for server definitions. Load user and installed blueprint sources independently and report listing failures without suppressing successful registrations. Remove the duplicate distribution export flagged by Knip. Amp-Thread-ID: https://ampcode.com/threads/T-904567e6-6bc7-4bc3-b950-50acf2c20326 --- src/core/graph/nodeDef/ComfyNodeDefImpl.ts | 20 ++--- .../graph/nodeDef/inputSpecInterpreter.ts | 14 ++-- .../core/agentPanel.historyIdentity.test.ts | 3 +- src/platform/distribution/types.ts | 2 - src/stores/subgraphStore.test.ts | 75 +++++++++++++++++++ src/stores/subgraphStore.ts | 25 ++++--- 6 files changed, 108 insertions(+), 31 deletions(-) diff --git a/src/core/graph/nodeDef/ComfyNodeDefImpl.ts b/src/core/graph/nodeDef/ComfyNodeDefImpl.ts index a7c43f3ceb1..382c1393719 100644 --- a/src/core/graph/nodeDef/ComfyNodeDefImpl.ts +++ b/src/core/graph/nodeDef/ComfyNodeDefImpl.ts @@ -2,8 +2,8 @@ import { cloneDeep, uniq } from 'es-toolkit/compat' import { resolveNodeDefText } from '@/i18n' import { - collectSearchableInputTypes, - collectSearchableOutputTypes + inputSpecInterpreter, + validatedInputSpecInterpreter } from '@/core/graph/nodeDef/inputSpecInterpreter' import { transformNodeDefV1ToV2 } from '@comfyorg/object-info-parser/migration' import type { @@ -138,19 +138,15 @@ export class ComfyNodeDefImpl return def } - constructor(def: ComfyNodeDefV1) { + constructor( + def: ComfyNodeDefV1, + { validateInputs = false }: { validateInputs?: boolean } = {} + ) { const obj = ComfyNodeDefImpl._migrateDefaultInput(def) - /** - * Copy fields that are declared on this class but not explicitly assigned - * below (e.g. `search_aliases`) straight from the source definition. - * `display_name` and `description` are held out: they are accessors with no - * setter, so assigning them here would throw. - */ const { display_name, description, ...assignable } = obj Object.assign(this, assignable) - // Initialize V1 fields this.name = obj.name this.backendDisplayName = display_name || undefined this.backendDescription = description || undefined @@ -178,14 +174,14 @@ export class ComfyNodeDefImpl this.python_module.split('.')[0] ) - // Initialize V2 fields const defV2 = transformNodeDefV1ToV2(obj) this.inputs = defV2.inputs this.outputs = defV2.outputs this.hidden = defV2.hidden - // Initialize node source this.nodeSource = getNodeSource(obj.python_module, this.essentials_category) + const { collectSearchableInputTypes, collectSearchableOutputTypes } = + validateInputs ? validatedInputSpecInterpreter : inputSpecInterpreter this.inputTypes = uniq( Object.values(this.inputs).flatMap(collectSearchableInputTypes) ) diff --git a/src/core/graph/nodeDef/inputSpecInterpreter.ts b/src/core/graph/nodeDef/inputSpecInterpreter.ts index d95b5480ce8..d30b2b60d6a 100644 --- a/src/core/graph/nodeDef/inputSpecInterpreter.ts +++ b/src/core/graph/nodeDef/inputSpecInterpreter.ts @@ -1,4 +1,4 @@ -import { isTrustedObjectInfo } from '@/platform/distribution/types' +import { isCloud } from '@/platform/distribution/types' import { reportError } from '@comfyorg/telemetry/reportError' import { createInputSpecInterpreter } from '@comfyorg/object-info-parser/inputSpecInterpreter' import type { InputSpecDiagnosticSink } from '@comfyorg/object-info-parser/inputSpecInterpreter' @@ -34,14 +34,18 @@ const warnSpecDrift: InputSpecDiagnosticSink = (spec, error, optionIndex) => { }) } +export const validatedInputSpecInterpreter = + createInputSpecInterpreter(warnSpecDrift) + +export const inputSpecInterpreter = createInputSpecInterpreter(warnSpecDrift, { + skipValidation: () => isCloud +}) + export const { inputSpecTree, ownSlotTypes, dynamicComboOptionKeys, dynamicComboOptionTypes, flattenInputSpecs, - collectSearchableInputTypes, collectSearchableOutputTypes -} = createInputSpecInterpreter(warnSpecDrift, { - skipValidation: () => isTrustedObjectInfo -}) +} = inputSpecInterpreter diff --git a/src/extensions/core/agentPanel.historyIdentity.test.ts b/src/extensions/core/agentPanel.historyIdentity.test.ts index 5fa68bb14f2..244704dbacf 100644 --- a/src/extensions/core/agentPanel.historyIdentity.test.ts +++ b/src/extensions/core/agentPanel.historyIdentity.test.ts @@ -30,8 +30,7 @@ vi.mock( DISTRIBUTION: 'cloud', isCloud: true, isDesktop: false, - isNightly: false, - isTrustedObjectInfo: true + isNightly: false }) ) vi.mock( diff --git a/src/platform/distribution/types.ts b/src/platform/distribution/types.ts index 2c7a535a307..1faceda680e 100644 --- a/src/platform/distribution/types.ts +++ b/src/platform/distribution/types.ts @@ -20,5 +20,3 @@ export const isCloud = DISTRIBUTION === 'cloud' * Nightly builds may show experimental features and surveys. */ export const isNightly = __IS_NIGHTLY__ - -export const isTrustedObjectInfo = isCloud diff --git a/src/stores/subgraphStore.test.ts b/src/stores/subgraphStore.test.ts index 7a98b72412a..91192990b46 100644 --- a/src/stores/subgraphStore.test.ts +++ b/src/stores/subgraphStore.test.ts @@ -142,6 +142,40 @@ describe('useSubgraphStore', () => { await mockFetch({ 'test.json': mockGraph }) expect(userBlueprintNames()).toEqual(['SubgraphBlueprint.test']) }) + it.for([false, true])( + 'loads blueprint boundary inputs when object info is trusted: %s', + async (isTrusted) => { + mockDistributionTypes.isCloud = isTrusted + + await mockFetch({ + 'dynamic-boundaries.json': { + ...mockGraph, + nodes: [ + { + type: '123', + inputs: [ + { name: 'autogrow', type: 'COMFY_AUTOGROW_V3', link: null }, + { name: 'match', type: 'COMFY_MATCHTYPE_V3', link: null }, + { name: 'group', type: 'COMFY_DYNAMICGROUP_V3', link: null }, + { name: 'image', type: 'IMAGE', link: null } + ], + outputs: [ + { name: 'matched', type: 'COMFY_MATCHTYPE_V3', links: null }, + { name: 'image', type: 'IMAGE', links: null } + ] + } + ] + } + }) + + const blueprintDef = useNodeDefStore().nodeDefs.find( + (def) => def.name === 'SubgraphBlueprint.dynamic-boundaries' + ) + expect(blueprintDef).toBeDefined() + expect(blueprintDef?.inputTypes).toEqual(['IMAGE']) + expect(blueprintDef?.outputTypes).toEqual(['IMAGE']) + } + ) it('should remove deleted blueprints from the node library', async () => { await mockFetch({ 'test.json': mockGraph }) await store.deleteBlueprint('SubgraphBlueprint.test') @@ -289,6 +323,47 @@ describe('useSubgraphStore', () => { expect(useNodeDefStore().blueprintNodeDefsByName.size).toBe(0) }) + it.for([ + { + source: 'user', + failedListing: 'listUserDataFullInfo', + survivingBlueprint: 'SubgraphBlueprint.installed_test' + }, + { + source: 'installed', + failedListing: 'getGlobalSubgraphs', + survivingBlueprint: 'SubgraphBlueprint.user_test' + } + ] as const)( + 'loads the other blueprint source and reports a failed $source listing', + async ({ failedListing, survivingBlueprint }) => { + vi.mocked(api[failedListing]).mockRejectedValueOnce( + new Error('Listing failed') + ) + + await mockFetch( + { 'user_test.json': mockGraph }, + { + installed_test: { + name: 'Installed Test', + info: { node_pack: 'test_pack' }, + data: JSON.stringify(mockGraph) + } + } + ) + + expect([...useNodeDefStore().blueprintNodeDefsByName.keys()]).toEqual([ + survivingBlueprint + ]) + expect(useToast().toasts).toEqual([ + expect.objectContaining({ + description: 'Listing failed', + kind: 'error' + }) + ]) + } + ) + it('should handle global blueprint with rejected data promise gracefully', async () => { await mockFetch( {}, diff --git a/src/stores/subgraphStore.ts b/src/stores/subgraphStore.ts index 8c89814f489..5a9efbb9f19 100644 --- a/src/stores/subgraphStore.ts +++ b/src/stores/subgraphStore.ts @@ -245,16 +245,20 @@ export const useSubgraphStore = defineStore('subgraph', () => { return Promise.allSettled(filteredEntries.map(loadGlobalBlueprint)) } - const userSubs = ( - await api.listUserDataFullInfo(SubgraphBlueprint.basePath) - ).filter((f) => f.path.endsWith('.json')) - const [globalResult, ...userResults] = await Promise.allSettled([ + async function loadUserBlueprints() { + const userSubs = ( + await api.listUserDataFullInfo(SubgraphBlueprint.basePath) + ).filter((f) => f.path.endsWith('.json')) + return Promise.allSettled(userSubs.map(loadBlueprint)) + } + + const results = await Promise.allSettled([ loadInstalledBlueprints(), - ...userSubs.map(loadBlueprint) + loadUserBlueprints() ]) - const globalResults = - globalResult.status === 'fulfilled' ? globalResult.value : [] - const settled = [...globalResults, ...userResults] + const settled = results.flatMap((result) => + result.status === 'fulfilled' ? result.value : [result] + ) const errors = settled.filter((i) => 'reason' in i).map((i) => i.reason) errors.forEach((e) => console.error('Failed to load subgraph blueprint', e)) @@ -277,7 +281,6 @@ export const useSubgraphStore = defineStore('subgraph', () => { const subgraphNode = workflow.changeTracker.initialState.nodes[0] subgraphNode.inputs ??= [] subgraphNode.outputs ??= [] - //NOTE: Types are cast to string. This is only used for input coloring on previews const inputs = Object.fromEntries( subgraphNode.inputs.map((i) => [ i.name, @@ -311,7 +314,9 @@ export const useSubgraphStore = defineStore('subgraph', () => { essentials_category: subgraphDefEssentialsCategory, ...overrides } - nodeDefStore.registerBlueprintNodeDef(new ComfyNodeDefImpl(nodedefv1)) + nodeDefStore.registerBlueprintNodeDef( + new ComfyNodeDefImpl(nodedefv1, { validateInputs: true }) + ) subgraphCache[name] = workflow } async function publishSubgraph(providedName?: string) { From 9312cc13a2666fcf8db754369f30dcb8c3ad23a1 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 20:10:46 +0000 Subject: [PATCH 5/7] test: isolate blueprint requests during canvas startup Amp-Thread-ID: https://ampcode.com/threads/T-904567e6-6bc7-4bc3-b950-50acf2c20326 --- src/components/graph/GraphCanvas.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/graph/GraphCanvas.test.ts b/src/components/graph/GraphCanvas.test.ts index 735cbc3c36d..26848ffe0df 100644 --- a/src/components/graph/GraphCanvas.test.ts +++ b/src/components/graph/GraphCanvas.test.ts @@ -217,6 +217,11 @@ vi.mock( () => ({ useWorkflowAutoSave: vi.fn() }) ) +beforeEach(() => { + vi.spyOn(api, 'listUserDataFullInfo').mockResolvedValue([]) + vi.spyOn(api, 'getGlobalSubgraphs').mockResolvedValue({}) +}) + /** * Installs (or clears) the mock app's root graph, standing in for the * assignment `ComfyApp.setup()` makes. The real class exposes no setter, so the From a91f2401754b4468c7cee8da54ba824bc5d5cfa3 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 20:42:57 +0000 Subject: [PATCH 6/7] fix: protect deferred blueprint publishing and previews Amp-Thread-ID: https://ampcode.com/threads/T-904567e6-6bc7-4bc3-b950-50acf2c20326 --- src/components/node/NodePreviewCard.test.ts | 35 ++++++++++++++++ .../graph/nodeDef/inputSpecInterpreter.ts | 2 +- src/stores/subgraphStore.test.ts | 41 ++++++++++++++++++- src/stores/subgraphStore.ts | 21 ++++++---- 4 files changed, 89 insertions(+), 10 deletions(-) diff --git a/src/components/node/NodePreviewCard.test.ts b/src/components/node/NodePreviewCard.test.ts index 660df75afbe..4c7e6de8f71 100644 --- a/src/components/node/NodePreviewCard.test.ts +++ b/src/components/node/NodePreviewCard.test.ts @@ -7,6 +7,13 @@ import { ComfyNodeDefImpl } from '@/core/graph/nodeDef/ComfyNodeDefImpl' import NodePreviewCard from './NodePreviewCard.vue' +vi.mock(import('@/platform/distribution/types'), () => ({ + DISTRIBUTION: 'cloud' as const, + isCloud: true, + isDesktop: false, + isNightly: false +})) + vi.mock( import('@/renderer/extensions/vueNodes/components/LGraphNodePreview.vue'), @@ -88,6 +95,34 @@ describe('NodePreviewCard', () => { expect(screen.getByText('sync_mode')).toBeInTheDocument() }) + it('renders blueprint boundary inputs on Cloud without dynamic templates', () => { + const nodeDef = new ComfyNodeDefImpl( + { + name: 'SubgraphBlueprint.boundaries', + display_name: 'Blueprint boundaries', + category: 'Subgraph Blueprints', + python_module: 'blueprint', + description: '', + input: { + required: { + autogrow: ['COMFY_AUTOGROW_V3', undefined], + group: ['COMFY_DYNAMICGROUP_V3', undefined], + match: ['COMFY_MATCHTYPE_V3', undefined] + } + }, + output: [], + output_node: false + }, + { validateInputs: true } + ) + + renderComponent(nodeDef) + + expect(screen.getByText('autogrow')).toBeInTheDocument() + expect(screen.getByText('group')).toBeInTheDocument() + expect(screen.getByText('match')).toBeInTheDocument() + }) + it('renders no inputs section when the node has no inputs', () => { const nodeDefImpl = new ComfyNodeDefImpl({ name: 'NoInputsNode', diff --git a/src/core/graph/nodeDef/inputSpecInterpreter.ts b/src/core/graph/nodeDef/inputSpecInterpreter.ts index d30b2b60d6a..042942e5f41 100644 --- a/src/core/graph/nodeDef/inputSpecInterpreter.ts +++ b/src/core/graph/nodeDef/inputSpecInterpreter.ts @@ -48,4 +48,4 @@ export const { dynamicComboOptionTypes, flattenInputSpecs, collectSearchableOutputTypes -} = inputSpecInterpreter +} = validatedInputSpecInterpreter diff --git a/src/stores/subgraphStore.test.ts b/src/stores/subgraphStore.test.ts index 91192990b46..9ff87113add 100644 --- a/src/stores/subgraphStore.test.ts +++ b/src/stores/subgraphStore.test.ts @@ -123,11 +123,16 @@ describe('useSubgraphStore', () => { { confirmed: true, storeCalls: 1 }, { confirmed: false, storeCalls: 0 } ])( - 'should publish over an existing blueprint only when overwrite is confirmed (confirmed: $confirmed)', + 'requires confirmation before replacing an unloaded blueprint (confirmed: $confirmed)', async ({ confirmed, storeCalls }) => { selectSubgraphNodeToPublish() vi.mocked(useDialogService().confirm).mockResolvedValue(confirmed) - await mockFetch({ 'testname.json': mockGraph }) + vi.mocked(api.listUserDataFullInfo).mockResolvedValue([ + { path: 'testname.json', modified: 1, size: 1 } + ]) + vi.mocked(api.getUserData).mockImplementation(async () => + Response.json(mockGraph) + ) await store.publishSubgraph() expect(useDialogService().confirm).toHaveBeenCalledWith( expect.objectContaining({ @@ -138,6 +143,38 @@ describe('useSubgraphStore', () => { expect(api.storeUserData).toHaveBeenCalledTimes(storeCalls) } ) + it('publishes a new filename without overwrite confirmation', async () => { + selectSubgraphNodeToPublish() + vi.mocked(api.listUserDataFullInfo).mockResolvedValue([ + { path: 'another-blueprint.json', modified: 1, size: 1 } + ]) + vi.mocked(api.getUserData).mockImplementation(async () => + Response.json(mockGraph) + ) + + await store.publishSubgraph() + + expect(useDialogService().confirm).not.toHaveBeenCalled() + expect(api.storeUserData).toHaveBeenCalledTimes(1) + }) + + it('does not publish when existing filenames cannot be checked', async () => { + selectSubgraphNodeToPublish() + vi.mocked(api.listUserDataFullInfo).mockRejectedValue( + new Error('Blueprint listing unavailable') + ) + + await store.publishSubgraph() + + expect(api.storeUserData).not.toHaveBeenCalled() + expect(useToast().toasts).toEqual([ + expect.objectContaining({ + kind: 'error', + description: 'Blueprint listing unavailable' + }) + ]) + }) + it('should display published nodes in the node library', async () => { await mockFetch({ 'test.json': mockGraph }) expect(userBlueprintNames()).toEqual(['SubgraphBlueprint.test']) diff --git a/src/stores/subgraphStore.ts b/src/stores/subgraphStore.ts index 5a9efbb9f19..4ec4f22209b 100644 --- a/src/stores/subgraphStore.ts +++ b/src/stores/subgraphStore.ts @@ -1,6 +1,7 @@ import { defineStore } from 'pinia' import { t } from '@/i18n' +import { reportError } from '@comfyorg/telemetry/reportError' import { SubgraphNode } from '@/lib/litegraph/src/litegraph' import { useSettingStore } from '@/platform/settings/settingStore' import { useToast } from '@/components/ui/toast/toastStore' @@ -335,7 +336,6 @@ export const useSubgraphStore = defineStore('subgraph', () => { throw new TypeError('Must have single SubgraphNode selected to publish') } - //create minimal workflow const workflowData = { revision: 0, last_node_id: subgraphNode.id, @@ -345,7 +345,6 @@ export const useSubgraphStore = defineStore('subgraph', () => { version: 0.4, definitions: { subgraphs } } - //prompt name const name = providedName ?? (await useDialogService().prompt({ @@ -354,14 +353,24 @@ export const useSubgraphStore = defineStore('subgraph', () => { defaultValue: subgraphNode.title })) if (!name) return + const savedBlueprints = await api + .listUserDataFullInfo(SubgraphBlueprint.basePath) + .catch((error: unknown) => { + reportError(error, { + errorType: 'error_checking_blueprint_overwrite', + surface: 'graph' + }) + useToast().error(t('subgraphStore.loadFailure'), { + description: getErrorMessage(error) ?? t('g.unknownError') + }) + }) + if (!savedBlueprints) return if ( - nodeDefStore.blueprintNodeDefsByName.has(BLUEPRINT_TYPE_PREFIX + name) && + savedBlueprints.some((file) => file.path === `${name}.json`) && !(await confirmOverwrite(name)) ) - //User has chosen not to overwrite. return - //upload file const path = SubgraphBlueprint.basePath + name + '.json' const workflow = new SubgraphBlueprint({ path, @@ -370,10 +379,8 @@ export const useSubgraphStore = defineStore('subgraph', () => { }) workflow.originalContent = JSON.stringify(workflowData) const loadedWorkflow = await workflow.load() - //Mark non-temporary workflow.size = 1 await workflow.save() - //add to files list? useWorkflowStore().attachWorkflow(loadedWorkflow) useToast().success(t('subgraphStore.publishSuccess'), { description: t('subgraphStore.publishSuccessMessage'), From 9f3bdce8ac1ddc2f39ab5176128fcd1a9d8676c8 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Thu, 12 Nov 2026 21:07:16 +0000 Subject: [PATCH 7/7] test: assert blueprint overwrite check failure reporting Amp-Thread-ID: https://ampcode.com/threads/T-904567e6-6bc7-4bc3-b950-50acf2c20326 --- src/stores/subgraphStore.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/stores/subgraphStore.test.ts b/src/stores/subgraphStore.test.ts index 9ff87113add..41f2796337c 100644 --- a/src/stores/subgraphStore.test.ts +++ b/src/stores/subgraphStore.test.ts @@ -9,6 +9,7 @@ import { createTestSubgraphNode } from '@/lib/litegraph/src/subgraph/__fixtures__/subgraphHelpers' import { useToast } from '@/components/ui/toast/toastStore' +import { reportError } from '@comfyorg/telemetry/reportError' import type { ExportedSubgraph } from '@comfyorg/graph-model/serialisation' import { TemplateIncludeOnDistributionEnum } from '@comfyorg/api-client/templateTypes' import type { ComfyNodeDef as ComfyNodeDefV1 } from '@comfyorg/object-info-parser' @@ -160,12 +161,15 @@ describe('useSubgraphStore', () => { it('does not publish when existing filenames cannot be checked', async () => { selectSubgraphNodeToPublish() - vi.mocked(api.listUserDataFullInfo).mockRejectedValue( - new Error('Blueprint listing unavailable') - ) + const listingError = new Error('Blueprint listing unavailable') + vi.mocked(api.listUserDataFullInfo).mockRejectedValue(listingError) await store.publishSubgraph() + expect(reportError).toHaveBeenCalledExactlyOnceWith(listingError, { + errorType: 'error_checking_blueprint_overwrite', + surface: 'graph' + }) expect(api.storeUserData).not.toHaveBeenCalled() expect(useToast().toasts).toEqual([ expect.objectContaining({