Add Comfy.Workflow.SortNodeIdOnSave setting (#502)

* Update litegraph (Sort order)

* nit

* Add sort node on save setting

* nit
This commit is contained in:
Chenlei Hu
2024-08-17 23:23:40 -04:00
committed by GitHub
parent 9d3ca763d0
commit d8887a434d
6 changed files with 25 additions and 11 deletions

View File

@@ -1925,7 +1925,10 @@ export class ComfyApp {
// Save current workflow automatically
setInterval(() => {
const workflow = JSON.stringify(this.graph.serialize())
const sortNodes =
this.vueAppReady &&
useSettingStore().get('Comfy.Workflow.SortNodeIdOnSave')
const workflow = JSON.stringify(this.graph.serialize({ sortNodes }))
localStorage.setItem('workflow', workflow)
if (api.clientId) {
sessionStorage.setItem(`workflow:${api.clientId}`, workflow)
@@ -2396,7 +2399,10 @@ export class ComfyApp {
}
}
const workflow = graph.serialize()
const sortNodes =
this.vueAppReady &&
useSettingStore().get('Comfy.Workflow.SortNodeIdOnSave')
const workflow = graph.serialize({ sortNodes })
const output = {}
// Process nodes in order of execution
for (const outerNode of graph.computeExecutionOrder(false)) {

View File

@@ -117,6 +117,13 @@ export const useSettingStore = defineStore('setting', {
max: 24
}
})
app.ui.settings.addSetting({
id: 'Comfy.Workflow.SortNodeIdOnSave',
name: 'Sort node IDs on save',
type: 'boolean',
defaultValue: false
})
},
set<K extends keyof Settings>(key: K, value: Settings[K]) {

View File

@@ -426,7 +426,8 @@ const zSettings = z.record(z.any()).and(
'Comfy.SnapToGrid.GridSize': z.number(),
'Comfy.TextareaWidget.FontSize': z.number(),
'Comfy.UseNewMenu': z.any(),
'Comfy.Validation.Workflows': z.boolean()
'Comfy.Validation.Workflows': z.boolean(),
'Comfy.Workflow.SortNodeIdOnSave': z.boolean()
})
.optional()
)