Bugfix node widgets wrongly being prepared for qeueing on saving the workflow (#1331)

- calling graphToPrompt() invokes beforeQueued() which should not happen when saving the workflow
This commit is contained in:
Zoltán Dócs
2024-10-27 14:59:27 +01:00
committed by GitHub
parent 8861492655
commit 7729611a2a
2 changed files with 16 additions and 8 deletions

View File

@@ -1910,8 +1910,7 @@ export class ComfyApp {
// Save current workflow automatically
setInterval(() => {
const sortNodes = useSettingStore().get('Comfy.Workflow.SortNodeIdOnSave')
const workflow = JSON.stringify(this.graph.serialize({ sortNodes }))
const workflow = JSON.stringify(this.serializeGraph())
localStorage.setItem('workflow', workflow)
if (api.clientId) {
sessionStorage.setItem(`workflow:${api.clientId}`, workflow)
@@ -2445,7 +2444,18 @@ export class ComfyApp {
}
/**
* Converts the current graph workflow for sending to the API
* Serializes a graph using preferred user settings.
* @param graph The litegraph to serialize.
* @returns A serialized graph (aka workflow) with preferred user settings.
*/
serializeGraph(graph: LGraph = this.graph) {
const sortNodes = useSettingStore().get('Comfy.Workflow.SortNodeIdOnSave')
return graph.serialize({ sortNodes })
}
/**
* Converts the current graph workflow for sending to the API.
* Note: Node widgets are updated before serialization to prepare queueing.
* @returns The workflow and node links
*/
async graphToPrompt(graph = this.graph, clean = true) {
@@ -2471,9 +2481,7 @@ export class ComfyApp {
}
}
const sortNodes = useSettingStore().get('Comfy.Workflow.SortNodeIdOnSave')
const workflow = graph.serialize({ sortNodes })
const workflow = this.serializeGraph(graph)
const output = {}
// Process nodes in order of execution
for (const outerNode of graph.computeExecutionOrder(false)) {

View File

@@ -380,8 +380,8 @@ export class ComfyWorkflow {
path = appendJsonExt(path)
const p = await this.manager.app.graphToPrompt()
const json = JSON.stringify(p.workflow, null, 2)
const workflow = this.manager.app.serializeGraph()
const json = JSON.stringify(workflow, null, 2)
let resp = await api.storeUserData('workflows/' + path, json, {
stringify: false,
throwOnError: false,