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..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' @@ -123,11 +124,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 +144,41 @@ 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() + 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({ + 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'),