From a25a78305b5a52c2d0bf37d114c67db2dded47f8 Mon Sep 17 00:00:00 2001 From: space-nuko <24979496+space-nuko@users.noreply.github.com> Date: Thu, 18 May 2023 02:12:42 -0500 Subject: [PATCH] Fixes for combo node default value --- src/lib/components/ComfyApp.ts | 6 ++++-- src/lib/nodes/ComfyValueControl.ts | 2 +- src/lib/nodes/widgets/ComfyComboNode.ts | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/components/ComfyApp.ts b/src/lib/components/ComfyApp.ts index 2793de8..295f112 100644 --- a/src/lib/components/ComfyApp.ts +++ b/src/lib/components/ComfyApp.ts @@ -821,13 +821,15 @@ export default class ComfyApp { .flatMap(i => node.getInputSlotsConnectedTo(i)) .find(inp => "config" in inp && Array.isArray((inp.config as any).values)) + let defaultValue = null; if (foundInput != null) { const comfyInput = foundInput as IComfyInputSlot; console.warn("[refreshComboInNodes] found frontend config:", node.title, node.type, comfyInput.config.values) values = comfyInput.config.values; + defaultValue = comfyInput.config.defaultValue; } - comboNode.formatValues(values); + comboNode.formatValues(values, defaultValue); } await tick(); @@ -842,7 +844,7 @@ export default class ComfyApp { comboNode.formatValues(rawValues as string[], true) if (!rawValues?.includes(get(comboNode.value))) { - comboNode.setValue(rawValues[0]) + comboNode.setValue(rawValues[0], comfyInput.config.defaultValue) } } } diff --git a/src/lib/nodes/ComfyValueControl.ts b/src/lib/nodes/ComfyValueControl.ts index 95e2fc5..f0d476b 100644 --- a/src/lib/nodes/ComfyValueControl.ts +++ b/src/lib/nodes/ComfyValueControl.ts @@ -19,7 +19,7 @@ export default class ComfyValueControl extends ComfyGraphNode { override properties: ComfyValueControlProperties = { tags: [], value: null, - action: "fixed", + action: "randomize", min: -INT_MAX, max: INT_MAX, step: 1, diff --git a/src/lib/nodes/widgets/ComfyComboNode.ts b/src/lib/nodes/widgets/ComfyComboNode.ts index 6912ef9..bb8b5f9 100644 --- a/src/lib/nodes/widgets/ComfyComboNode.ts +++ b/src/lib/nodes/widgets/ComfyComboNode.ts @@ -55,7 +55,7 @@ export default class ComfyComboNode extends ComfyWidgetNode { } } - formatValues(values: string[], lightUp: boolean = false) { + formatValues(values: string[], defaultValue?: string, lightUp: boolean = false) { if (values == null) return; @@ -65,7 +65,7 @@ export default class ComfyComboNode extends ComfyWidgetNode { const oldValue = get(this.value) if (this.properties.values.indexOf(oldValue) === -1) { changed = true; - this.value.set(this.properties.values[0]) + this.value.set(defaultValue || this.properties.values[0]) } if (lightUp && get(this.firstLoad) && changed) @@ -129,7 +129,7 @@ export default class ComfyComboNode extends ComfyWidgetNode { thisProps.values = Array.from(otherProps.values); const value = get(this.value) if (thisProps.values.indexOf(value) === -1) - this.setValue(thisProps.values[0]) + this.setValue(otherProps.defaultValue || thisProps.values[0]) console.warn("PASSED")