mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 22:39:39 +00:00
Fix SaveAs (#5643)
Implementing subgraph blueprints (#5139) included changes to saving to ensure that SaveAs generates a new workflow of the correct type. However this code failed to utilize the pre-prepared state when performing the actual save. This produced a couple of problems with both failing to detach the workflow and failing to apply the correct state This error is only encountered when using Save As from a non temporary workflow (one loaded from the workflows sidebar tab). As this state calculation code is only used in this code path, it has been moved into the saveAs function of the workflowStore. Resolves #5592 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5643-Fix-SaveAs-2726d73d3650818faa7af449d1f13c26) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user