-
diff --git a/src/lib/components/ComfyApp.ts b/src/lib/components/ComfyApp.ts
index 589b18c..671987c 100644
--- a/src/lib/components/ComfyApp.ts
+++ b/src/lib/components/ComfyApp.ts
@@ -131,6 +131,10 @@ export default class ComfyApp {
LiteGraph.release_link_on_empty_shows_menu = true;
LiteGraph.alt_drag_do_clone_nodes = true;
+ const uiUnlocked = get(uiState).uiUnlocked;
+ this.lCanvas.allow_dragnodes = uiUnlocked;
+ this.lCanvas.allow_interaction = uiUnlocked;
+
(window as any).LiteGraph = LiteGraph;
// await this.#invokeExtensionsAsync("init");
@@ -542,6 +546,11 @@ export default class ComfyApp {
// nodes have conditional logic that determines which link
// to follow backwards.
while (isFrontendParent(parent)) {
+ if (!("getUpstreamLink" in parent)) {
+ console.warn("[graphToPrompt] Node does not support getUpstreamLink", parent.type)
+ break;
+ }
+
const nextLink = parent.getUpstreamLink()
if (nextLink == null) {
console.warn("[graphToPrompt] No upstream link found in frontend node", parent)
diff --git a/src/lib/components/gradio/gallery/Gallery.svelte b/src/lib/components/gradio/gallery/Gallery.svelte
index cf27d43..5643dd0 100644
--- a/src/lib/components/gradio/gallery/Gallery.svelte
+++ b/src/lib/components/gradio/gallery/Gallery.svelte
@@ -48,7 +48,7 @@
);
let prevValue: string[] | FileData[] | null = value;
- let selected_image: number | null = null;
+ export let selected_image: number | null = null;
let old_selected_image: number | null = null;
$: if (prevValue !== value) {
diff --git a/src/lib/nodes/ComfyWidgetNodes.ts b/src/lib/nodes/ComfyWidgetNodes.ts
index e813932..8a5d78e 100644
--- a/src/lib/nodes/ComfyWidgetNodes.ts
+++ b/src/lib/nodes/ComfyWidgetNodes.ts
@@ -283,7 +283,8 @@ export abstract class ComfyWidgetNode
extends ComfyGraphNode {
}
override onConfigure(o: SerializedLGraphNode) {
- this.value.set((o as any).comfyValue);
+ const value = (o as any).comfyValue || LiteGraph.cloneObject(this.defaultValue);
+ this.value.set(value);
this.shownOutputProperties = (o as any).shownOutputProperties;
}
@@ -537,6 +538,7 @@ export class ComfyGalleryNode extends ComfyWidgetNode {
{ name: "selected_index", type: "number" },
{ name: "width", type: "number" },
{ name: "height", type: "number" },
+ { name: "any_selected", type: "boolean" },
]
}
@@ -551,6 +553,8 @@ export class ComfyGalleryNode extends ComfyWidgetNode {
override outputIndex = null;
override changedIndex = null;
+ anyImageSelected: boolean = false;
+
modeWidget: IComboWidget;
constructor(name?: string) {
@@ -570,6 +574,7 @@ export class ComfyGalleryNode extends ComfyWidgetNode {
this.setOutputData(0, this.properties.index)
this.setOutputData(1, this.imageSize[0])
this.setOutputData(2, this.imageSize[1])
+ this.setOutputData(3, this.anyImageSelected)
}
override onAction(action: any, param: any, options: { action_call?: string }) {
@@ -592,6 +597,7 @@ export class ComfyGalleryNode extends ComfyWidgetNode {
}
}
this.setProperty("index", 0)
+ this.anyImageSelected = false;
}
}
@@ -608,6 +614,9 @@ export class ComfyGalleryNode extends ComfyWidgetNode {
super.setValue([])
}
+ if (!get(this.value))
+ this.anyImageSelected = false
+
const len = get(this.value).length
if (this.properties.index < 0 || this.properties.index >= len) {
this.setProperty("index", clamp(this.properties.index, 0, len))
@@ -793,9 +802,10 @@ export class ComfyImageUploadNode extends ComfyWidgetNode>
}
override svelteComponentType = ImageUploadWidget;
- override defaultValue = null;
+ override defaultValue = [];
override outputIndex = null;
override changedIndex = 3;
+ override saveUserState = false;
imageSize: Vector2 = [1, 1];
@@ -820,7 +830,7 @@ export class ComfyImageUploadNode extends ComfyWidgetNode>
}
override formatValue(value: GradioFileData[]): string {
- return `Images: ${value.length}`
+ return `Images: ${value?.length || 0}`
}
}
diff --git a/src/lib/stores/layoutState.ts b/src/lib/stores/layoutState.ts
index 85a58b8..a73093b 100644
--- a/src/lib/stores/layoutState.ts
+++ b/src/lib/stores/layoutState.ts
@@ -424,6 +424,13 @@ const ALL_ATTRIBUTES: AttributesSpecList = [
serialize: (s) => s === NodeMode.ALWAYS ? "ALWAYS" : "NEVER",
deserialize: (m) => m === "ALWAYS" ? NodeMode.ALWAYS : NodeMode.NEVER
},
+ {
+ name: "horizontal",
+ type: "boolean",
+ location: "nodeVars",
+ editable: true,
+ defaultValue: false
+ },
// Node properties
{
diff --git a/src/lib/widgets/GalleryWidget.svelte b/src/lib/widgets/GalleryWidget.svelte
index e5f0ab6..e611291 100644
--- a/src/lib/widgets/GalleryWidget.svelte
+++ b/src/lib/widgets/GalleryWidget.svelte
@@ -21,6 +21,7 @@
let option: number | null = null;
let imageWidth: number = 1;
let imageHeight: number = 1;
+ let selected_image: number | null = null;
$: widget && setNodeValue(widget);
@@ -29,6 +30,7 @@
node = widget.node as ComfyGalleryNode
nodeValue = node.value;
propsChanged = node.propsChanged;
+ node.anyImageSelected = false;
if ($nodeValue != null) {
if (node.properties.index < 0 || node.properties.index >= $nodeValue.length) {
@@ -132,7 +134,22 @@
// Update index
node.setProperty("index", e.detail.index as number)
+ node.anyImageSelected = true;
}
+
+ $: if ($propsChanged > -1 && widget && $nodeValue) {
+ if (widget.attrs.variant === "image") {
+ selected_image = $nodeValue.length - 1
+ node.setProperty("index", selected_image)
+ node.anyImageSelected = true;
+ }
+ }
+ else {
+ node.setProperty("index", null)
+ node.anyImageSelected = false;
+ }
+
+ $: node.anyImageSelected = selected_image != null;
{#if widget && node && nodeValue}
@@ -166,6 +183,7 @@
on:select={onSelect}
bind:imageWidth
bind:imageHeight
+ bind:selected_image
/>
diff --git a/src/mobile/GenToolbar.svelte b/src/mobile/GenToolbar.svelte
index 6cf0258..2b1577f 100644
--- a/src/mobile/GenToolbar.svelte
+++ b/src/mobile/GenToolbar.svelte
@@ -51,7 +51,6 @@
{/if}