Repository navigation
Fix automatic dynamic widget removal corrupting "create DICT" nodes (#65) - #66
Merged
Merged
Conversation
Removing an empty dynamic input pair spliced node.widgets directly, which
left the old entries in ComfyUI's widget value store. renumberDynamicInputs
then renamed the inputs, but renaming the widgets silently failed because
the target id was still taken by the orphaned entry. Input names and widget
names drifted apart: the prompt was built from the stale widget names
(key_1..value_2), so DictCreate.create() never found key_0 and returned {},
and the connected input link was drawn next to the wrong widget row.
Remove widgets through node.removeWidget() so the store entry is deleted
too, falling back to an array splice on older litegraph builds.
Verified in ComfyUI 0.43 (frontend 1.57.4): clearing a pair now keeps
inputs and widgets in sync, the link stays on its own row and the node
returns the remaining pairs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Clearing an empty dynamic input pair (e.g.
key_0/value_0of create DICT)while later pairs still hold values corrupts the node: the widgets disappear,
the remaining values are not moved up into the right slots, a connected input
link ends up next to the wrong widget row, and the node returns
{}eventhough a valid pair is still configured.
Fixes #65
Root cause
removeWidgetForInput()inweb/js/dynamicnode.jsremoved the widget with aplain
node.widgets.splice(). ComfyUI keeps widget values in a per-node storekeyed by widget name, and only
node.removeWidget()deletes that entry. Thesplice left the removed
key_0/value_0entries behind, so the subsequentrenumberDynamicInputs()could rename the inputs but not the widgets - theBaseWidget.namesetter found the new id still occupied and kept the old name.That desync caused both symptoms:
key_1..value_2;DictCreate.create()iterates fromkey_0and therefore returned{}input.widget.namepointed at a widget that no longer exists, so the linkwas rendered next to the wrong row
Change
Remove the widget via
node.removeWidget(), with the previous array splice keptas a fallback for older litegraph builds that lack the method. Only
web/js/dynamicnode.jsis touched.Verification
Reproduced and re-tested in a live ComfyUI 0.43 instance (frontend 1.57.4) by
scripting the exact sequence from the issue and inspecting
node.inputs,node.widgets, the link store andapp.graphToPrompt().Before the fix (clearing
key_0/value_0withkey_1="otherkey"wired):After the fix:
Also checked clearing a middle pair and refilling the placeholder pair
afterwards: names stay contiguous from 0 and inputs/widgets remain in sync.
node --check web/js/dynamicnode.jspasses; the change is JS-only, so thePython test suite is unaffected.