diff --git a/src/lib/components/ComfyApp.svelte b/src/lib/components/ComfyApp.svelte
index 777030f..9a87049 100644
--- a/src/lib/components/ComfyApp.svelte
+++ b/src/lib/components/ComfyApp.svelte
@@ -55,19 +55,38 @@
let graphResizeTimer: typeof Timer = -1;
- function doAutosave(graph: LGraph): void {
- // We will merge in the state of the frontend instead of what's inside the
- // LGraph structure.
+ function serializeAppState(graph: LGraph): SerializedAppState {
const frontendState = get(widgetState);
const serializedGraph = graph.serialize()
const serializedPaneOrder = uiPane.serialize()
- const savedWorkflow = {
- graph: serializedGraph,
- panes: serializedPaneOrder
+ // Override the saved graph widget state with the properties set in the
+ // frontend panels.
+ for (let i = 0; i < serializedGraph.nodes.length; i++) {
+ let serializedNode = serializedGraph.nodes[i];
+ let frontendWidgetStates = frontendState[serializedNode.id];
+ if (frontendWidgetStates) {
+ for (let j = 0; j < serializedNode.widgets_values.length; j++) {
+ let frontendWidgetState = frontendWidgetStates[j];
+
+ // Virtual widgets always come after real widgets in the current design
+ if (frontendWidgetState && !frontendWidgetState.isVirtual) {
+ serializedNode.widgets_values[j] = frontendWidgetState.value;
+ }
+ }
+ }
}
+ return {
+ version: 1,
+ workflow: serializedGraph,
+ panes: serializedPaneOrder
+ }
+ }
+
+ function doAutosave(graph: LGraph): void {
+ const savedWorkflow = serializeAppState(graph);
localStorage.setItem("workflow", JSON.stringify(savedWorkflow))
}
@@ -136,6 +155,9 @@
+
diff --git a/src/lib/components/ComfyApp.ts b/src/lib/components/ComfyApp.ts
index 40e4b0e..3dbb880 100644
--- a/src/lib/components/ComfyApp.ts
+++ b/src/lib/components/ComfyApp.ts
@@ -30,6 +30,7 @@ export type SerializedPanes = {
}
export type SerializedAppState = {
+ version: number,
panes: SerializedPanes,
workflow: SerializedLGraph
}