Workflow serialization fix
ensure user data for values in workflow isn't stripped
This commit is contained in:
Submodule litegraph updated: 7c38fa4aed...29a7877f59
@@ -357,9 +357,4 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
|||||||
this.value.set(value);
|
this.value.set(value);
|
||||||
this.shownOutputProperties = (o as any).shownOutputProperties;
|
this.shownOutputProperties = (o as any).shownOutputProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
override stripUserState(o: SerializedLGraphNode) {
|
|
||||||
super.stripUserState(o);
|
|
||||||
(o as any).comfyValue = LiteGraph.cloneObject(this.properties.defaultValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
$: {
|
$: {
|
||||||
previewURL = $queueState.previewURL;
|
previewURL = $queueState.previewURL;
|
||||||
|
|
||||||
if (previewURL && $queueState.runningPromptID != null && !$uiState.hidePreviews && node.properties.showPreviews) {
|
if (previewURL && $queueState.runningPromptID && !$uiState.hidePreviews && node.properties.showPreviews) {
|
||||||
const queueEntry = queueState.getQueueEntry($queueState.runningPromptID)
|
const queueEntry = queueState.getQueueEntry($queueState.runningPromptID)
|
||||||
if (queueEntry != null) {
|
if (queueEntry != null) {
|
||||||
const tags = queueEntry.extraData?.extra_pnginfo?.comfyBoxPrompt?.subgraphs;
|
const tags = queueEntry.extraData?.extra_pnginfo?.comfyBoxPrompt?.subgraphs;
|
||||||
@@ -51,12 +51,6 @@
|
|||||||
previewImage = img;
|
previewImage = img;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
previewImage = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
previewImage = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -155,7 +149,7 @@
|
|||||||
<div class="wrapper comfy-gallery-widget gradio-gallery" style={widget.attrs.style || ""}>
|
<div class="wrapper comfy-gallery-widget gradio-gallery" style={widget.attrs.style || ""}>
|
||||||
<Block variant="solid" padding={false}>
|
<Block variant="solid" padding={false}>
|
||||||
<div class="padding">
|
<div class="padding">
|
||||||
{#if previewImage}
|
{#if previewImage && $queueState.runningPromptID != null}
|
||||||
<div class="comfy-gallery-preview" on:mouseover={hidePreview} on:mouseout={showPreview} >
|
<div class="comfy-gallery-preview" on:mouseover={hidePreview} on:mouseout={showPreview} >
|
||||||
<img src={previewImage.src} bind:this={previewElem} on:mouseout={showPreview} />
|
<img src={previewImage.src} bind:this={previewElem} on:mouseout={showPreview} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import ComfyGraph from "$lib/ComfyGraph";
|
import ComfyGraph from "$lib/ComfyGraph";
|
||||||
import { ComfyNumberNode } from "$lib/nodes/widgets";
|
import { ComfyNumberNode, ComfyComboNode } from "$lib/nodes/widgets";
|
||||||
import { ComfyBoxWorkflow } from "$lib/stores/workflowState";
|
import { ComfyBoxWorkflow } from "$lib/stores/workflowState";
|
||||||
import { LiteGraph, Subgraph } from "@litegraph-ts/core";
|
import { LiteGraph, Subgraph } from "@litegraph-ts/core";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { expect } from 'vitest';
|
import { expect } from 'vitest';
|
||||||
import UnitTest from "./UnitTest";
|
import UnitTest from "./UnitTest";
|
||||||
import { Watch } from "@litegraph-ts/nodes-basic";
|
import { Watch } from "@litegraph-ts/nodes-basic";
|
||||||
|
import type { SerializedComfyWidgetNode } from "$lib/nodes/widgets/ComfyWidgetNode";
|
||||||
|
|
||||||
export default class ComfyGraphTests extends UnitTest {
|
export default class ComfyGraphTests extends UnitTest {
|
||||||
test__onNodeAdded__updatesLayoutState() {
|
test__onNodeAdded__updatesLayoutState() {
|
||||||
@@ -107,4 +108,24 @@ export default class ComfyGraphTests extends UnitTest {
|
|||||||
|
|
||||||
expect(serNode.outputs[0]._data).toBeUndefined()
|
expect(serNode.outputs[0]._data).toBeUndefined()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test__serialize__savesComboData() {
|
||||||
|
const [{ graph }, layoutState] = ComfyBoxWorkflow.create()
|
||||||
|
layoutState.initDefaultLayout()
|
||||||
|
|
||||||
|
const widget = LiteGraph.createNode(ComfyComboNode);
|
||||||
|
const watch = LiteGraph.createNode(Watch);
|
||||||
|
graph.add(widget)
|
||||||
|
graph.add(watch)
|
||||||
|
|
||||||
|
widget.connect(0, watch, 0)
|
||||||
|
widget.properties.values = ["A", "B", "C"]
|
||||||
|
widget.setValue("B");
|
||||||
|
|
||||||
|
const result = graph.serialize();
|
||||||
|
|
||||||
|
const serNode = result.nodes.find(n => n.id === widget.id) as SerializedComfyWidgetNode;
|
||||||
|
|
||||||
|
expect(serNode.comfyValue).toBe("B")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user