diff --git a/src/platform/remote/comfyui/execution/types.ts b/src/platform/remote/comfyui/execution/types.ts index 47a099c217a..6c078700512 100644 --- a/src/platform/remote/comfyui/execution/types.ts +++ b/src/platform/remote/comfyui/execution/types.ts @@ -69,6 +69,7 @@ export interface ExecutedWsMessage extends ExecutingWsMessage { display_node: NodeId output: NodeExecutionOutput merge?: boolean + workflow_id?: string } interface ExecutionWsMessageBase { prompt_id: JobId diff --git a/src/scripts/app.test.ts b/src/scripts/app.test.ts index 67600e4160c..ebfe5630d84 100644 --- a/src/scripts/app.test.ts +++ b/src/scripts/app.test.ts @@ -3636,6 +3636,42 @@ describe('ComfyApp', () => { ).toEqual(['blob:1']) }) + it.for([ + { label: 'shows', workflowId: workflowAId, expected: { text: ['out'] } }, + { label: 'hides', workflowId: workflowBId, expected: undefined } + ])( + '$label an unowned output by whether its workflow_id matches the visible workflow', + ({ workflowId, expected }) => { + useNodeOutputStore().resetAllOutputsAndPreviews() + const graph = new LGraph() + graph.configure(serialisedGraph(workflowAId)) + Reflect.set(app, 'rootGraphInternal', graph) + const addEventListener = vi.spyOn(api, 'addEventListener') + Reflect.apply(Reflect.get(app, 'addApiUpdateHandlers'), app, []) + const executedHandler = addEventListener.mock.calls.find( + ([name]) => name === 'executed' + )?.[1] as EventListener | undefined + + executedHandler?.( + new CustomEvent('executed', { + detail: { + node: '1', + display_node: '1', + prompt_id: 'unowned-job', + workflow_id: workflowId, + output: { text: ['out'] } + } + }) + ) + + expect( + useNodeOutputStore().getNodeOutputByExecutionId( + createNodeExecutionId([1]) + ) + ).toEqual(expected) + } + ) + it('restores the failed run state when returning to a workflow tab', async () => { const workflowService = await useRealWorkflowService() const graph = new LGraph() diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 3436e031636..c7812aa9585 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -786,6 +786,7 @@ export class ComfyApp implements IComfyApp { api.addEventListener('executed', ({ detail }) => { if (!useExecutionStore().belongsToActiveWorkflow(detail.prompt_id)) return + if (detail.workflow_id && detail.workflow_id !== this.rootGraph.id) return const nodeOutputStore = useNodeOutputStore() const executionId = tryNormalizeNodeExecutionId( detail.display_node || detail.node