Repository navigation
fix(workflow): inline promoted subgraph values into non-widget interior sockets #1115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f1bb72e
076864c
73a6197
281d8b2
e4c2c80
1ed5027
103aac0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -223,7 +223,9 @@ def _overlay_promoted_host_values(api_prompt: dict, workflow: dict, subgraph_def | |
| default, so a post-migration save (host prompt filled in, interior | ||
| ``caption`` still ``''``) would submit the wrong prompt. Precedence, as the | ||
| frontend serializes it: a link feeding the instance input wins (already | ||
| reattached), else the host value when materialized, else the interior. | ||
| reattached), else the host value when materialized, else the interior | ||
| source widget's value. The chosen value goes to every interior input the | ||
| input feeds, plain sockets included (``ExecutableNodeDTO.resolveInput``). | ||
| Inner instances are visited first so an outer host wins over an inner one; | ||
| an inner input promoted further (linked from ``-10``) is left to the outer. | ||
| """ | ||
|
|
@@ -289,24 +291,28 @@ def is_live(link_id: Any) -> bool: | |
| continue | ||
| value = _promoted.host_value(instance, pi) | ||
| if value is _promoted.UNSET: | ||
| continue | ||
| # Every interior widget the input feeds — a repaired primitive | ||
| # fan-out links one host value into several targets. | ||
| targets = _promoted.boundary_widget_targets(sg, pi, subgraph_defs) | ||
| # No host value: the frontend seeds the promoted widget from its interior source widget. | ||
| if len(inner_nodes) + 1 > visit_budget[0]: | ||
| raise WorkflowConversionError("promoted-value overlay exceeded its safe limit") | ||
| visit_budget[0] -= len(inner_nodes) + 1 | ||
| value = _source_widget_value(api_prompt, prefix, _promoted.deepest_source(sg, pi, subgraph_defs)) | ||
| if value is _promoted.UNSET: | ||
| continue | ||
| else: | ||
| value = _wrap_widget_value(value) | ||
| targets = _promoted.boundary_targets(sg, pi, subgraph_defs) | ||
| if len(targets) > visit_budget[0]: | ||
| raise WorkflowConversionError("promoted-value overlay exceeded its safe limit") | ||
| visit_budget[0] -= len(targets) | ||
| for path, widget in targets: | ||
| for path, input_name in targets: | ||
| entry = api_prompt.get(":".join([prefix, *path])) | ||
| if not isinstance(entry, dict): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟢 Low — Socket targets on interior nodes that aren't emitted are skipped silently. That covers a bypassed target (e.g. a bypassed Raised by 1 of 6 reviewers (claude-opus-5-5-xhigh edge-case). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, a remaining gap rather than something this change introduces: widget targets on a bypassed or Reroute hop behaved the same before it. Listed as a Known limitation in the PR body; it will be tracked as a follow-up rather than widening this change into boundary traversal. |
||
| continue | ||
| inputs = entry.setdefault("inputs", {}) | ||
| current = inputs.get(widget) | ||
| current = inputs.get(input_name) | ||
| if isinstance(current, list) and len(current) == 2: | ||
| continue # wired from inside the definition: the link wins | ||
| # Same wrapping every widget value gets, so a two-item list | ||
| # host value is never read back as a ``[node, slot]`` link. | ||
| inputs[widget] = _wrap_widget_value(value) | ||
| inputs[input_name] = value | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Nit — The host value is now wrapped once outside the loop, and the fallback reuses the source entry's own object. As a result every target, and on the fallback path the source node itself, shares one dict or list. Any later in-place edit of one node's input would silently change its siblings. Wrapping or copying per target, as the old per-iteration Raised by 1 of 6 reviewers (kimi-k3-high adversarial). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Declining. The overlay is the converter's last step, and nothing mutates input values after it: the prompt is serialized as-is. Sharing one wrapped value across targets is therefore observable only through in-place edits, and no such edit exists. Copying per target would add work on every fan-out for no behavioural difference. |
||
|
|
||
| for node in workflow.get("nodes") or []: | ||
| if not isinstance(node, dict): | ||
|
|
@@ -317,6 +323,21 @@ def is_live(link_id: Any) -> bool: | |
| visit(node, sg, workflow, str(node.get("id")), 0) | ||
|
|
||
|
|
||
| def _source_widget_value(api_prompt: dict, prefix: str, source: tuple[list[str], str] | None) -> Any: | ||
| from comfy_cli.cql import promoted as _promoted | ||
|
|
||
| if source is None: | ||
| return _promoted.UNSET | ||
| path, widget = source | ||
| entry = api_prompt.get(":".join([prefix, *path])) | ||
| inputs = entry.get("inputs") if isinstance(entry, dict) else None | ||
| if not isinstance(inputs, dict) or widget not in inputs: | ||
| return _promoted.UNSET | ||
| value = inputs[widget] | ||
| # Emitted widget values are wrapped, so a bare pair is a link: never fan it out. | ||
| return _promoted.UNSET if isinstance(value, list) and len(value) == 2 else value | ||
|
|
||
|
|
||
| def _has_group_nodes(workflow: dict) -> bool: | ||
| """Legacy 'group nodes' (workflow> types) live under extra.groupNodes.""" | ||
| extra = workflow.get("extra") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium — When the host has no value, the fallback reads the seed only from the already-emitted
api_prompt. So if the source node is muted, bypassed, or failed_build_api_node, the value comes backUNSETand every plain-socket target (e.g.ComfySwitchNode.on_false) is left empty. That is the same 'encoder gets None' failure this PR fixes, andtest_known_divergence_unemitted_source_leaves_the_socket_emptylocks it in. Reading the emitted value also means adynamicPromptssource likeTextGenerate.prompthas already been throughprocess_dynamic_prompt, so sockets get the processed string while the host branch writes the raw value. Seeding from the definition's interiorwidgets_values(aspromoted.source_valuedoes) would avoid both problems.Raised by 3 of 6 reviewers (claude-opus-5-5-xhigh adversarial, claude-opus-5-5-xhigh edge-case, gpt-5.6-sol-xhigh edge-case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that this diverges from the frontend; it is the Known limitation listed in the PR body. It needs both no saved instance value and a muted or bypassed source (or dynamic-prompt syntax in the source). Across the 735 shipped templates, all 15 socket-feeding inputs without a saved value resolve correctly through the emitted source. Seeding from the definition's raw widget value means threading object_info into the overlay to map widgets_values positionally. That is held for the maintainers' call rather than added here; it will be tracked if they keep it as a limitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping this as a known limitation, now listed in the PR description: with no saved instance value, a muted or bypassed source leaves sibling sockets empty, and a dynamic-prompt source reaches them processed. Neither occurs in any of the 735 templates, and before this change those sockets got nothing. Two
test_known_divergence_*tests pin the current behaviour so a future fix shows up as a deliberate test change.