From 938095c6ce53000d93e71236abd9f51a199ea844 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 25 Sep 2025 19:13:44 -0700 Subject: [PATCH 1/2] fix restoring outputs in vue nodes --- src/scripts/app.ts | 5 ++--- src/scripts/changeTracker.ts | 5 ++--- src/stores/imagePreviewStore.ts | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/scripts/app.ts b/src/scripts/app.ts index cd085eead4..d7583724aa 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -1778,9 +1778,8 @@ export class ComfyApp { * Clean current state */ clean() { - this.nodeOutputs = {} - const { revokeAllPreviews } = useNodeOutputStore() - revokeAllPreviews() + const nodeOutputStore = useNodeOutputStore() + nodeOutputStore.resetAllOutputsAndPreviews() const executionStore = useExecutionStore() executionStore.lastNodeErrors = null executionStore.lastExecutionError = null diff --git a/src/scripts/changeTracker.ts b/src/scripts/changeTracker.ts index 1b5f9c88e9..5924b513b4 100644 --- a/src/scripts/changeTracker.ts +++ b/src/scripts/changeTracker.ts @@ -10,6 +10,7 @@ import { import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema' import type { ExecutedWsMessage } from '@/schemas/apiSchema' import { useExecutionStore } from '@/stores/executionStore' +import { useNodeOutputStore } from '@/stores/imagePreviewStore' import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore' import { api } from './api' @@ -85,9 +86,7 @@ export class ChangeTracker { app.canvas.ds.scale = this.ds.scale app.canvas.ds.offset = this.ds.offset } - if (this.nodeOutputs) { - app.nodeOutputs = this.nodeOutputs - } + useNodeOutputStore().restoreOutputs(this.nodeOutputs ?? {}) if (this.subgraphState) { const { navigation } = this.subgraphState useSubgraphNavigationStore().restoreState(navigation) diff --git a/src/stores/imagePreviewStore.ts b/src/stores/imagePreviewStore.ts index 7cf8b2f5d5..aebc23810a 100644 --- a/src/stores/imagePreviewStore.ts +++ b/src/stores/imagePreviewStore.ts @@ -328,6 +328,19 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => { return hadOutputs } + function restoreOutputs( + outputs: Record + ) { + app.nodeOutputs = outputs + nodeOutputs.value = outputs + } + + function resetAllOutputsAndPreviews() { + app.nodeOutputs = {} + nodeOutputs.value = {} + revokeAllPreviews() + } + return { // Getters getNodeOutputs, @@ -346,6 +359,8 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => { revokeAllPreviews, revokeSubgraphPreviews, removeNodeOutputs, + restoreOutputs, + resetAllOutputsAndPreviews, // State nodeOutputs, From bf464cf460183fd59b038f4f11419c875818f9ef Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 25 Sep 2025 19:27:13 -0700 Subject: [PATCH 2/2] only restore if outputs are available --- src/scripts/changeTracker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scripts/changeTracker.ts b/src/scripts/changeTracker.ts index 5924b513b4..f2b2afc30b 100644 --- a/src/scripts/changeTracker.ts +++ b/src/scripts/changeTracker.ts @@ -86,7 +86,9 @@ export class ChangeTracker { app.canvas.ds.scale = this.ds.scale app.canvas.ds.offset = this.ds.offset } - useNodeOutputStore().restoreOutputs(this.nodeOutputs ?? {}) + if (this.nodeOutputs) { + useNodeOutputStore().restoreOutputs(this.nodeOutputs) + } if (this.subgraphState) { const { navigation } = this.subgraphState useSubgraphNavigationStore().restoreState(navigation)