From 909866fd1d9af28567faac0e72e72ccd9ca1dfee Mon Sep 17 00:00:00 2001 From: Comfy Org PR Bot Date: Fri, 19 Sep 2025 08:07:16 +0800 Subject: [PATCH] [backport 1.27] Fix SaveAs (#5644) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport of #5643 to `core/1.27` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5644-backport-1-27-Fix-SaveAs-2726d73d3650815dbaefe7090ee2ffde) by [Unito](https://www.unito.io) Co-authored-by: AustinMroz --- .../workflow/core/services/workflowService.ts | 9 +-------- .../workflow/management/stores/workflowStore.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/platform/workflow/core/services/workflowService.ts b/src/platform/workflow/core/services/workflowService.ts index cc41f971e..e5dad1a4a 100644 --- a/src/platform/workflow/core/services/workflowService.ts +++ b/src/platform/workflow/core/services/workflowService.ts @@ -17,7 +17,7 @@ import { downloadBlob } from '@/scripts/utils' import { useDialogService } from '@/services/dialogService' import { useDomWidgetStore } from '@/stores/domWidgetStore' import { useWorkspaceStore } from '@/stores/workspaceStore' -import { appendJsonExt, generateUUID } from '@/utils/formatUtil' +import { appendJsonExt } from '@/utils/formatUtil' export const useWorkflowService = () => { const settingStore = useSettingStore() @@ -112,13 +112,6 @@ export const useWorkflowService = () => { await renameWorkflow(workflow, newPath) await workflowStore.saveWorkflow(workflow) } else { - // Generate new id when saving existing workflow as a new file - const id = generateUUID() - const state = JSON.parse( - JSON.stringify(workflow.activeState) - ) as ComfyWorkflowJSON - state.id = id - const tempWorkflow = workflowStore.saveAs(workflow, newPath) await openWorkflow(tempWorkflow) await workflowStore.saveWorkflow(tempWorkflow) diff --git a/src/platform/workflow/management/stores/workflowStore.ts b/src/platform/workflow/management/stores/workflowStore.ts index 254698b66..f18d13c43 100644 --- a/src/platform/workflow/management/stores/workflowStore.ts +++ b/src/platform/workflow/management/stores/workflowStore.ts @@ -20,7 +20,7 @@ import { parseNodeExecutionId, parseNodeLocatorId } from '@/types/nodeIdentification' -import { getPathDetails } from '@/utils/formatUtil' +import { generateUUID, getPathDetails } from '@/utils/formatUtil' import { syncEntities } from '@/utils/syncUtil' import { isSubgraph } from '@/utils/typeGuardUtil' @@ -320,12 +320,19 @@ export const useWorkflowStore = defineStore('workflow', () => { existingWorkflow: ComfyWorkflow, path: string ): ComfyWorkflow => { + // Generate new id when saving existing workflow as a new file + const id = generateUUID() + const state = JSON.parse( + JSON.stringify(existingWorkflow.activeState) + ) as ComfyWorkflowJSON + state.id = id + const workflow: ComfyWorkflow = new (existingWorkflow.constructor as any)({ path, modified: Date.now(), size: -1 }) - workflow.originalContent = workflow.content = existingWorkflow.content + workflow.originalContent = workflow.content = JSON.stringify(state) workflowLookup.value[workflow.path] = workflow return workflow }