diff --git a/browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts b/browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts index 62ddaa0c9a9..e5a106d3bf4 100644 --- a/browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts +++ b/browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts @@ -30,6 +30,32 @@ test.describe('Errors tab - Missing nodes', { tag: ['@ui', '@canvas'] }, () => { ).toHaveText(/\S/) }) + test('Should keep the missing node pack card after submitting a prompt', async ({ + comfyPage + }) => { + test.info().annotations.push({ + type: 'regression', + description: + 'Submitting a prompt cleared missing-node state, emptying the Errors tab' + }) + + await loadWorkflowAndOpenErrorsTab(comfyPage, 'missing/missing_nodes') + + const missingNodeCard = comfyPage.page.getByTestId( + TestIds.dialogs.missingNodeCard + ) + await expect(missingNodeCard).toBeVisible() + + const prompted = comfyPage.page.waitForResponse((response) => + response.url().includes('/api/prompt') + ) + await comfyPage.runButton.click() + await prompted + + await expect(missingNodeCard).toBeVisible() + await expect(missingNodeCard.getByText('Unknown pack')).toBeVisible() + }) + test('Should show unknown pack node rows by default', async ({ comfyPage }) => { diff --git a/src/scripts/app.test.ts b/src/scripts/app.test.ts index 134c28fec6e..32685607755 100644 --- a/src/scripts/app.test.ts +++ b/src/scripts/app.test.ts @@ -312,6 +312,34 @@ describe('ComfyApp', () => { vi.spyOn(api, 'dispatchCustomEvent').mockImplementation(() => true) } + it('preserves missing node packs when submitting a prompt', async () => { + prepareEmptyPromptQueue() + const missingNodesStore = useMissingNodesErrorStore() + const executionErrorStore = useExecutionErrorStore() + missingNodesStore.setMissingNodeTypes(['test/UninstalledLiveNode']) + executionErrorStore.recordExecutionError({ + prompt_id: 'previous-run', + timestamp: 0, + node_id: '1', + node_type: 'Test', + executed: [], + exception_message: 'fail', + exception_type: 'RuntimeError', + traceback: [] + }) + vi.spyOn(api, 'queuePrompt').mockResolvedValue({ + prompt_id: 'job-1', + error: '' + }) + + await app.queuePrompt(0) + + expect(missingNodesStore.missingNodesError?.nodeTypes).toEqual([ + 'test/UninstalledLiveNode' + ]) + expect(executionErrorStore.lastExecutionError).toBeNull() + }) + it('shows the error overlay for successful prompt responses with node errors', async () => { const graph = new LGraph() const workflow = new ComfyWorkflow({ @@ -1036,6 +1064,73 @@ describe('ComfyApp', () => { ]) }) }) + describe('A1111 import', () => { + it('clears missing node packs, which its graph swap skips clean() for', async () => { + const graph = new LGraph() + Reflect.set(app, 'rootGraphInternal', graph) + const missingNodesStore = useMissingNodesErrorStore() + missingNodesStore.setMissingNodeTypes(['OutgoingMissingNode']) + vi.mocked(getWorkflowDataFromFile).mockResolvedValue({ + parameters: 'positive\nNegative prompt: negative\nSteps: 20' + }) + mockImportA1111.mockImplementation( + async (_graph, _parameters, beforeGraphClear) => { + beforeGraphClear?.() + return 'imported' + } + ) + + await app.handleFile(createTestFile('a1111.png', 'image/png')) + + expect(missingNodesStore.missingNodesError).toBeNull() + }) + + it.for(['not-a1111', 'core-nodes-unavailable'] as const)( + 'keeps missing node packs when the import fails with %s', + async (outcome) => { + const graph = new LGraph() + Reflect.set(app, 'rootGraphInternal', graph) + const missingNodesStore = useMissingNodesErrorStore() + missingNodesStore.setMissingNodeTypes(['OutgoingMissingNode']) + vi.mocked(getWorkflowDataFromFile).mockResolvedValue({ + parameters: 'positive\nNegative prompt: negative\nSteps: 20' + }) + mockImportA1111.mockResolvedValue(outcome) + + await app.handleFile(createTestFile('a1111.png', 'image/png')) + + expect(missingNodesStore.missingNodesError?.nodeTypes).toEqual([ + 'OutgoingMissingNode' + ]) + } + ) + }) + + describe('clean', () => { + it('clears missing node packs when the graph is discarded', () => { + const graph = new LGraph() + Reflect.set(app, 'rootGraphInternal', graph) + const missingNodesStore = useMissingNodesErrorStore() + const executionErrorStore = useExecutionErrorStore() + missingNodesStore.setMissingNodeTypes(['MissingGroupNode']) + executionErrorStore.recordExecutionError({ + prompt_id: 'previous-run', + timestamp: 0, + node_id: '1', + node_type: 'Test', + executed: [], + exception_message: 'fail', + exception_type: 'RuntimeError', + traceback: [] + }) + + app.clean() + + expect(missingNodesStore.missingNodesError).toBeNull() + expect(executionErrorStore.lastExecutionError).toBeNull() + }) + }) + describe('refreshComboInNodes', () => { it('shows success toast and removes the pending toast after node defs reload', async () => { app.vueAppReady = true diff --git a/src/scripts/app.ts b/src/scripts/app.ts index c71c185db83..9731e1d59b2 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -113,6 +113,7 @@ import { normalizePromptError } from '@/utils/executionErrorUtil' import { graphToPrompt } from '@/utils/executionUtil' import { parseJsonWithNonFinite } from '@/utils/jsonUtil' import { getCnrIdFromProperties } from '@/platform/nodeReplacement/cnrIdUtil' +import { useMissingNodesErrorStore } from '@/platform/nodeReplacement/missingNodesErrorStore' import { rescanAndSurfaceMissingNodes } from '@/platform/nodeReplacement/missingNodeScan' import { refreshMissingModelPipeline, @@ -1645,7 +1646,7 @@ export class ComfyApp { const executionStore = useExecutionStore() const executionErrorStore = useExecutionErrorStore() const telemetry = useTelemetry() - executionErrorStore.clearAllErrors() + executionErrorStore.clearRunErrors() let queueResultOverride: boolean | null = null // Get auth token for backend nodes - uses workspace token if enabled, otherwise Firebase token @@ -2019,7 +2020,11 @@ export class ComfyApp { // Use parameters strictly as the final fallback if (parameters && typeof parameters === 'string') { const outcome = await importA1111(this.rootGraph, parameters, () => { - useWorkflowService().beforeLoadNewGraph() + try { + useWorkflowService().beforeLoadNewGraph() + } finally { + useMissingNodesErrorStore().setMissingNodeTypes([]) + } this.canvas.setGraph(this.rootGraph) }) if (outcome === 'core-nodes-unavailable') { @@ -2430,7 +2435,8 @@ export class ComfyApp { const nodeOutputStore = useNodeOutputStore() nodeOutputStore.resetAllOutputsAndPreviews() const executionErrorStore = useExecutionErrorStore() - executionErrorStore.clearAllErrors() + executionErrorStore.clearRunErrors() + useMissingNodesErrorStore().setMissingNodeTypes([]) useDomWidgetStore().clear() diff --git a/src/stores/executionErrorStore.test.ts b/src/stores/executionErrorStore.test.ts index 220a23cb69e..e66e028c19b 100644 --- a/src/stores/executionErrorStore.test.ts +++ b/src/stores/executionErrorStore.test.ts @@ -3,7 +3,6 @@ import { createPinia, setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { nodeError, validationError } from '@/utils/__tests__/nodeErrorHelpers' -import type { MissingNodeType } from '@/types/comfy' import { createBoundaryLinkedSubgraph, createTestRootGraph, @@ -797,7 +796,9 @@ describe('hasMissingError', () => { { type: 'nodes', seedMissingError: () => { - useMissingNodesErrorStore().missingNodesError = fromAny({}) + useMissingNodesErrorStore().setMissingNodeTypes([ + { type: 'TestNode', hint: '' } + ]) } }, { @@ -822,7 +823,7 @@ describe('hasMissingError', () => { expect(executionErrorStore.hasMissingError).toBe(true) }) - it('excludes node validation errors', () => { + it('returns false when only node validation errors exist', () => { const executionErrorStore = useExecutionErrorStore() executionErrorStore.recordNodeErrors({ '1': nodeError([validationError('required_input_missing', 'input')]) @@ -832,7 +833,7 @@ describe('hasMissingError', () => { }) }) -describe('clearAllErrors', () => { +describe('clearRunErrors', () => { let executionErrorStore: ReturnType let missingNodesStore: ReturnType @@ -843,7 +844,7 @@ describe('clearAllErrors', () => { missingNodesStore = useMissingNodesErrorStore() }) - it('resets all error categories and closes error overlay', () => { + it('resets run errors and closes the overlay, leaving missing resources', () => { executionErrorStore.recordExecutionError({ prompt_id: 'test', timestamp: 0, @@ -873,18 +874,18 @@ describe('clearAllErrors', () => { class_type: 'Test' } }) - missingNodesStore.setMissingNodeTypes( - fromAny([{ type: 'MissingNode', hint: '' }]) - ) + missingNodesStore.setMissingNodeTypes([{ type: 'MissingNode', hint: '' }]) executionErrorStore.showErrorOverlay() - executionErrorStore.clearAllErrors() + executionErrorStore.clearRunErrors() expect(executionErrorStore.lastExecutionError).toBeNull() expect(executionErrorStore.lastPromptError).toBeNull() expect(executionErrorStore.lastNodeErrors).toBeNull() - expect(missingNodesStore.missingNodesError).toBeNull() expect(executionErrorStore.isErrorOverlayOpen).toBe(false) - expect(executionErrorStore.hasAnyError).toBe(false) + expect(missingNodesStore.missingNodesError?.nodeTypes).toEqual([ + { type: 'MissingNode', hint: '' } + ]) + expect(executionErrorStore.hasAnyError).toBe(true) }) }) diff --git a/src/stores/executionErrorStore.ts b/src/stores/executionErrorStore.ts index 920d6c962f2..ac790a813fc 100644 --- a/src/stores/executionErrorStore.ts +++ b/src/stores/executionErrorStore.ts @@ -83,15 +83,13 @@ export const useExecutionErrorStore = defineStore('executionError', () => { isErrorOverlayOpen.value = false } - /** Clear all error state. - * Missing model state is intentionally preserved here to avoid wiping - * in-progress model repairs (importTaskIds, URL inputs, etc.). - * Missing models are cleared separately during workflow load/clean paths. */ - function clearAllErrors() { + /** Clear error state produced by a run. Missing-resource state describes the + * loaded graph rather than the run, so only replacing or discarding the + * graph invalidates it. */ + function clearRunErrors() { lastExecutionError.value = null lastPromptError.value = null lastNodeErrors.value = null - missingNodesStore.setMissingNodeTypes([]) isErrorOverlayOpen.value = false } @@ -550,7 +548,7 @@ export const useExecutionErrorStore = defineStore('executionError', () => { recordPromptError, // Clearing - clearAllErrors, + clearRunErrors, clearExecutionStartErrors, clearPromptError,