diff --git a/README.md b/README.md index 6727036..6e702ef 100644 --- a/README.md +++ b/README.md @@ -118,9 +118,9 @@ The modifier node takes an input value, passes it through to its output, and als ![Example workflow using Modifier Nodes](./assets/readme_modifier.png) -## Manual Value Entry ![New](https://img.shields.io/badge/NEW-green) +## User Value Entry ![New](https://img.shields.io/badge/NEW-green) -For `Subworkflow Input` nodes with primitive number types, you can now set their value directly in the `Subworkflow` node without needing to link a separate primitive number node. +For `Subworkflow Input` nodes with primitive number types, users can now set the value directly in the `Subworkflow` node without a link to separate node. This allows for more compact workflows when you simply want to set a number for the inner workflow. When an node is linked to the input of such a node, the linked node value will take precedence over the set value. The value input can also be disabled; the linked input of the inner input will use as fallback value. @@ -182,9 +182,10 @@ ComfyUI workflow JSON appears in a few different shapes depending on how it was ### Version History +- v1.2.3 - (re)loading an inner workflow with links updates no longer disconnects all input links; they are now preserved when possible. - v1.2.2 - Fixed a bug where inner node validation exception were raised due to removal of initial static output slots. - v1.2.1 - Removed the maximum number of inputs and outputs on the `Subworkflow` node (was previously set to 8). -- v1.2.0 - Added manual value entry for primitive `Subworkflow Input` input nodes on the `Subworkflow` node. Check README features section for details. +- v1.2.0 - Added value entry for primitive `Subworkflow Input` input nodes directly on the `Subworkflow` node. Check README features section for details. - v1.1.0 - Added `Subworkflow Modifier`, `Subworkflow Modifier Source` (+ from URL) nodes. Combining these nodes in inner and outer workflows allows for circular links between an inner workflow input and output, without circular reference problems. - v1.0.1 - UI only nodes are now supported in inner workflows, no longer raising and error when loading. - v1.0.0 - Initial release of the four custom nodes and workflow loading and execution behavior. diff --git a/js/subworkflow.js b/js/subworkflow.js index 600056b..8238002 100644 --- a/js/subworkflow.js +++ b/js/subworkflow.js @@ -528,8 +528,29 @@ function applyWorkflowInfoOnLoad(node, info, savedInputCount, savedSize, config, // Override widgets are not yet present even on the fast path — add them now. _syncOverrideWidgets(node, inputs, config, pendingOverrideValues); } else { - debugLog(`applyWorkflowInfoOnLoad: input count changed (${savedInputCount}->${inputs.length}), full refresh`); - updateInputSlots(node, inputs); + debugLog(`applyWorkflowInfoOnLoad: input count changed (${savedInputCount}->${inputs.length}), smart update`); + // Update existing slots in-place to preserve links, then add/remove only what changed. + let idx = 0; + for (const inp of (node.inputs || [])) { + if (inp.name?.startsWith("swf_in_") && idx < inputs.length) { + inp.label = inputs[idx].slot_name; + inp.type = swfSlotType(inputs[idx]); + idx++; + } + } + if (inputs.length > savedInputCount) { + for (let i = savedInputCount; i < inputs.length; i++) { + node.addInput(`swf_in_${i}`, swfSlotType(inputs[i]), { label: inputs[i].slot_name }); + } + } else { + if (node.inputs) { + for (let i = node.inputs.length - 1; i >= 0; i--) { + const nm = node.inputs[i].name; + if (!nm?.startsWith("swf_in_")) continue; + if (parseInt(nm.slice(7)) >= inputs.length) node.removeInput(i); + } + } + } _syncOverrideWidgets(node, inputs, config, pendingOverrideValues); } diff --git a/pyproject.toml b/pyproject.toml index a58058c..a080eae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "comfyui-subworkflow" -version = "1.2.2" +version = "1.2.3" description = "Use ComfyUI workflows as reusable subworkflows via Subworkflow Input, Subworkflow Output, and Subworkflow nodes" license = { file = "LICENSE" } requires-python = ">=3.10"