Skip to content

Commit 228ea20

Browse files
authored
Merge pull request #120 from space-nuko/previews
Minor fixes
2 parents f24eb23 + 334692e commit 228ea20

File tree

8 files changed

+37
-23
lines changed

8 files changed

+37
-23
lines changed

src/lib/components/ComfyQueue.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import { type WorkflowError } from "$lib/stores/workflowState";
1616
import ComfyQueueListDisplay from "./ComfyQueueListDisplay.svelte";
1717
import ComfyQueueGridDisplay from "./ComfyQueueGridDisplay.svelte";
18-
import { WORKFLOWS_VIEW } from "./ComfyBoxWorkflowsView.svelte";
19-
import uiQueueState, { type QueueUIEntry } from "$lib/stores/uiQueueState";
18+
import { WORKFLOWS_VIEW } from "./ComfyBoxWorkflowsView.svelte";
19+
import uiQueueState, { type QueueUIEntry } from "$lib/stores/uiQueueState";
2020
2121
export let app: ComfyApp;
2222

src/lib/nodes/actions/ComfySetNodeModeAdvancedAction.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ export default class ComfySetNodeModeAdvancedAction extends ComfyGraphNode {
7373

7474
if (hasTag) {
7575
let newMode: NodeMode;
76-
if (enable && action.enable) {
77-
newMode = NodeMode.ALWAYS;
76+
if (action.enable) {
77+
newMode = enable ? NodeMode.ALWAYS : NodeMode.NEVER;
7878
} else {
79-
newMode = NodeMode.NEVER;
79+
newMode = enable ? NodeMode.NEVER : NodeMode.ALWAYS;
8080
}
8181
nodeChanges[node.id] = newMode
8282
}
@@ -88,7 +88,12 @@ export default class ComfySetNodeModeAdvancedAction extends ComfyGraphNode {
8888
const container = entry.dragItem;
8989
const hasTag = container.attrs.tags.indexOf(action.tag) != -1;
9090
if (hasTag) {
91-
const hidden = !(enable && action.enable)
91+
let hidden: boolean;
92+
if (action.enable) {
93+
hidden = !enable
94+
} else {
95+
hidden = enable;
96+
}
9297
widgetChanges[container.id] = hidden
9398
}
9499
}

src/lib/nodes/widgets/ComfyComboNode.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export default class ComfyComboNode extends ComfyWidgetNode<string> {
170170
super.stripUserState(o);
171171
o.properties.values = []
172172
o.properties.defaultValue = null;
173-
(o as any).comfyValue = null
174173
}
175174
}
176175

src/lib/nodes/widgets/ComfyWidgetNode.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,4 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
357357
this.value.set(value);
358358
this.shownOutputProperties = (o as any).shownOutputProperties;
359359
}
360-
361-
override stripUserState(o: SerializedLGraphNode) {
362-
super.stripUserState(o);
363-
(o as any).comfyValue = LiteGraph.cloneObject(this.properties.defaultValue);
364-
}
365360
}

src/lib/widgets/GalleryWidget.svelte

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
$: {
4343
previewURL = $queueState.previewURL;
4444
45-
if (previewURL && $queueState.runningPromptID != null && !$uiState.hidePreviews && node.properties.showPreviews) {
45+
if (previewURL && $queueState.runningPromptID && !$uiState.hidePreviews && node.properties.showPreviews) {
4646
const queueEntry = queueState.getQueueEntry($queueState.runningPromptID)
4747
if (queueEntry != null) {
4848
const tags = queueEntry.extraData?.extra_pnginfo?.comfyBoxPrompt?.subgraphs;
@@ -51,12 +51,6 @@
5151
previewImage = img;
5252
})
5353
}
54-
else {
55-
previewImage = null;
56-
}
57-
}
58-
else {
59-
previewImage = null;
6054
}
6155
}
6256
else {
@@ -155,7 +149,7 @@
155149
<div class="wrapper comfy-gallery-widget gradio-gallery" style={widget.attrs.style || ""}>
156150
<Block variant="solid" padding={false}>
157151
<div class="padding">
158-
{#if previewImage}
152+
{#if previewImage && $queueState.runningPromptID != null}
159153
<div class="comfy-gallery-preview" on:mouseover={hidePreview} on:mouseout={showPreview} >
160154
<img src={previewImage.src} bind:this={previewElem} on:mouseout={showPreview} />
161155
</div>

src/lib/widgets/ImageUploadWidget.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
/>
231231
{:else}
232232
<div class="comfy-image-editor-panel">
233-
{#if _value && canMask}
233+
{#if _value && _value.length > 0 && canMask}
234234
{@const comfyURL = convertComfyOutputToComfyURL(_value[0])}
235235
<div class="mask-canvas-wrapper" style:display={editMask ? "block" : "none"}>
236236
<MaskCanvas bind:this={maskCanvasComp} fileURL={comfyURL} on:release={onMaskReleased} on:loaded={onMaskReleased} />

src/tests/ComfyGraphTests.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import ComfyGraph from "$lib/ComfyGraph";
2-
import { ComfyNumberNode } from "$lib/nodes/widgets";
2+
import { ComfyNumberNode, ComfyComboNode } from "$lib/nodes/widgets";
33
import { ComfyBoxWorkflow } from "$lib/stores/workflowState";
44
import { LiteGraph, Subgraph } from "@litegraph-ts/core";
55
import { get } from "svelte/store";
66
import { expect } from 'vitest';
77
import UnitTest from "./UnitTest";
88
import { Watch } from "@litegraph-ts/nodes-basic";
9+
import type { SerializedComfyWidgetNode } from "$lib/nodes/widgets/ComfyWidgetNode";
910

1011
export default class ComfyGraphTests extends UnitTest {
1112
test__onNodeAdded__updatesLayoutState() {
@@ -107,4 +108,24 @@ export default class ComfyGraphTests extends UnitTest {
107108

108109
expect(serNode.outputs[0]._data).toBeUndefined()
109110
}
111+
112+
test__serialize__savesComboData() {
113+
const [{ graph }, layoutState] = ComfyBoxWorkflow.create()
114+
layoutState.initDefaultLayout()
115+
116+
const widget = LiteGraph.createNode(ComfyComboNode);
117+
const watch = LiteGraph.createNode(Watch);
118+
graph.add(widget)
119+
graph.add(watch)
120+
121+
widget.connect(0, watch, 0)
122+
widget.properties.values = ["A", "B", "C"]
123+
widget.setValue("B");
124+
125+
const result = graph.serialize();
126+
127+
const serNode = result.nodes.find(n => n.id === widget.id) as SerializedComfyWidgetNode;
128+
129+
expect(serNode.comfyValue).toBe("B")
130+
}
110131
}

0 commit comments

Comments
 (0)