From f1bb72e066c23aded2565c44500b7c2c53f8ae70 Mon Sep 17 00:00:00 2001 From: Simon Pinfold Date: Wed, 4 Nov 2026 16:35:56 -0800 Subject: [PATCH 1/7] fix(workflow): inline promoted subgraph values into non-widget interior sockets The UI-to-API converter overlaid a promoted subgraph input's value only onto interior widget inputs. The frontend (ExecutableNodeDTO.resolveInput) inlines it into every interior input the boundary link reaches, plain sockets included. A host prompt that feeds a ComfySwitchNode's on_false was dropped, so the switch yielded None and the Qwen Image 2.1 templates encoded the string "None". boundary_targets (renamed from boundary_widget_targets) now returns socket targets too. When the host carries no value for the input, the frontend seeds the promoted widget from its interior source widget and inlines that one value into every target; the overlay now does the same. --- comfy_cli/cql/promoted.py | 30 +- comfy_cli/workflow_to_api.py | 45 +- tests/comfy_cli/cql/test_promoted_inputs.py | 99 +- tests/comfy_cli/fixtures/gallery/README.md | 7 +- .../image_qwen_image_2_1_image_edit.json | 2649 +++++++++++++++++ .../object_info_subgraph_promoted.json | 848 ++++++ .../test_workflow_to_api_promoted.py | 238 +- 7 files changed, 3857 insertions(+), 59 deletions(-) create mode 100644 tests/comfy_cli/fixtures/gallery/image_qwen_image_2_1_image_edit.json diff --git a/comfy_cli/cql/promoted.py b/comfy_cli/cql/promoted.py index 3a0ae7e38..3e4ca1368 100644 --- a/comfy_cli/cql/promoted.py +++ b/comfy_cli/cql/promoted.py @@ -2186,10 +2186,11 @@ def flush_proxy_migration( return report -def boundary_widget_targets(sg: dict, pi: PromotedInput, defs: dict[str, dict]) -> list[tuple[list[str], str]]: - """Every concrete ``(interior node path, widget)`` a promoted input feeds — - all of its boundary links, through nested instances. A repaired primitive - fan-out has several; :func:`deepest_source` reports only the first.""" +def boundary_targets(sg: dict, pi: PromotedInput, defs: dict[str, dict]) -> list[tuple[list[str], str]]: + """Every concrete ``(interior node path, input)`` a promoted input feeds — + widgets and plain sockets alike, all of its boundary links, through nested + instances. A repaired primitive fan-out has several; :func:`deepest_source` + reports only the first.""" cache = getattr(defs, "promotion_boundaries", None) cache_key = (id(sg), pi.index) raw_inputs = sg.get("inputs") @@ -2368,15 +2369,20 @@ def _boundary_targets( ) out.extend(([tid, *path], widget) for path, widget in nested) continue + # A socket without a widget marker (a switch's any-type input) is a + # target too: the frontend inlines the host value into whatever + # input the boundary link reaches (``ExecutableNodeDTO.resolveInput``). marker = entry.get("widget") - if marker: - _spend_traversal_budget( - _output_budget, - 1, - "promoted widget boundary traversal exceeded its safe limit", - ) - widget = marker.get("name") if isinstance(marker, dict) else None - out.append(([tid], str(widget or entry.get("name")))) + widget = marker.get("name") if isinstance(marker, dict) else None + name = widget or entry.get("name") + if name is None: + continue + _spend_traversal_budget( + _output_budget, + 1, + "promoted widget boundary traversal exceeded its safe limit", + ) + out.append(([tid], str(name))) _memo[memo_key] = out frozen_dependencies = frozenset(dependencies) _dependency_memo[memo_key] = frozen_dependencies diff --git a/comfy_cli/workflow_to_api.py b/comfy_cli/workflow_to_api.py index ac7375828..30e5304ce 100644 --- a/comfy_cli/workflow_to_api.py +++ b/comfy_cli/workflow_to_api.py @@ -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,32 @@ 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 host widget from its + # interior source widget and inlines that value into every + # target, as emitted above (already wrapped). + value = _source_widget_value(api_prompt, prefix, _promoted.deepest_source(sg, pi, subgraph_defs)) + if value is _promoted.UNSET: + continue + else: + # Same wrapping every widget value gets, so a two-item list + # host value is never read back as a ``[node, slot]`` link. + value = _wrap_widget_value(value) + # Every interior input the boundary link feeds, widget or socket + # (the frontend inlines the host value into both) — a repaired + # primitive fan-out links one host value into several targets. + 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): 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 for node in workflow.get("nodes") or []: if not isinstance(node, dict): @@ -317,6 +327,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: + """The emitted value of a promoted input's interior source widget, or + ``UNSET`` when that node was not emitted.""" + 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 + return inputs[widget] + + def _has_group_nodes(workflow: dict) -> bool: """Legacy 'group nodes' (workflow> types) live under extra.groupNodes.""" extra = workflow.get("extra") diff --git a/tests/comfy_cli/cql/test_promoted_inputs.py b/tests/comfy_cli/cql/test_promoted_inputs.py index 2c009557e..06b4de049 100644 --- a/tests/comfy_cli/cql/test_promoted_inputs.py +++ b/tests/comfy_cli/cql/test_promoted_inputs.py @@ -141,7 +141,7 @@ def test_every_promotion_resolver_skips_an_unheld_row_before_a_live_one(): assert item.source_node == "8" assert promoted._promotion_source(sg, sg["inputs"][0], definitions) == ("8", "prompt") - assert promoted.boundary_widget_targets(sg, item, definitions) == [(["8"], "prompt")] + assert promoted.boundary_targets(sg, item, definitions) == [(["8"], "prompt")] def test_every_promotion_resolver_rejects_a_non_proxy_listed_row(): @@ -164,7 +164,7 @@ def test_every_promotion_resolver_rejects_a_non_proxy_listed_row(): assert item.value_index is None assert promoted._promotion_source(sg, sg["inputs"][0], definitions) is None - assert promoted.boundary_widget_targets(sg, item, definitions) == [] + assert promoted.boundary_targets(sg, item, definitions) == [] def test_promotion_visit_limit_counts_listed_link_ids(): @@ -233,12 +233,12 @@ def test_promotion_caches_do_not_expose_mutable_results(): first_inputs = promoted.promoted_inputs(sg, definitions) item = first_inputs[0] first_inputs.clear() - first_targets = promoted.boundary_widget_targets(sg, item, definitions) + first_targets = promoted.boundary_targets(sg, item, definitions) first_targets[0][0].append("corrupt") first_targets.clear() assert len(promoted.promoted_inputs(sg, definitions)) == 1 - assert promoted.boundary_widget_targets(sg, item, definitions) == [(["7"], "prompt")] + assert promoted.boundary_targets(sg, item, definitions) == [(["7"], "prompt")] def test_boundary_resolution_treats_non_list_nested_inputs_as_empty(): @@ -254,7 +254,7 @@ def test_boundary_resolution_treats_non_list_nested_inputs_as_empty(): [item] = promoted.promoted_inputs(outer, definitions) - assert promoted.boundary_widget_targets(outer, item, definitions) == [] + assert promoted.boundary_targets(outer, item, definitions) == [] def test_registered_roots_share_one_non_creditable_index_budget(): @@ -354,7 +354,7 @@ def test_acyclic_shared_children_reuse_stable_promotion_results_across_roots(): for root in roots: [item] = promoted.promoted_inputs(root, definitions) assert item.is_widget - assert promoted.boundary_widget_targets(root, item, definitions) == [(["7", "9"], "value")] + assert promoted.boundary_targets(root, item, definitions) == [(["7", "9"], "value")] def test_every_promotion_resolver_follows_a_holder_when_the_row_target_drifted(): @@ -377,7 +377,7 @@ def test_every_promotion_resolver_follows_a_holder_when_the_row_target_drifted() assert item.source_node == "8" assert promoted._promotion_source(sg, sg["inputs"][0], definitions) == ("8", "prompt") - assert promoted.boundary_widget_targets(sg, item, definitions) == [(["8"], "prompt")] + assert promoted.boundary_targets(sg, item, definitions) == [(["8"], "prompt")] def test_boundary_targets_keep_every_duplicate_holder_live(): @@ -399,7 +399,50 @@ def test_boundary_targets_keep_every_duplicate_holder_live(): [item] = promoted.promoted_inputs(sg, definitions) assert item.source_node == "7" - assert promoted.boundary_widget_targets(sg, item, definitions) == [(["7"], "prompt"), (["8"], "prompt")] + assert promoted.boundary_targets(sg, item, definitions) == [(["7"], "prompt"), (["8"], "prompt")] + + +def test_boundary_targets_include_plain_sockets_in_link_order(): + sg = { + "id": "sg", + "inputs": [{"name": "prompt", "type": "STRING", "linkIds": [1, 2, 3]}], + "nodes": [ + {"id": 7, "type": "Switch", "inputs": [{"name": "on_false", "type": "*", "link": 1}]}, + {"id": 8, "type": "PromptNode", "inputs": [{"name": "prompt", "widget": {"name": "prompt"}, "link": 2}]}, + {"id": 9, "type": "Nameless", "inputs": [{"type": "*", "link": 3}]}, + ], + "links": [ + {"id": link_id, "origin_id": -10, "origin_slot": 0, "target_id": target, "target_slot": 0} + for link_id, target in ((1, 7), (2, 8), (3, 9)) + ], + } + definitions = {"sg": sg} + + [item] = promoted.promoted_inputs(sg, definitions) + + assert item.is_widget + assert promoted.boundary_targets(sg, item, definitions) == [(["7"], "on_false"), (["8"], "prompt")] + + +def test_socket_targets_count_against_the_boundary_output_cap(): + sg = { + "id": "sg", + "inputs": [{"name": "prompt", "type": "STRING", "linkIds": [1, 2]}], + "nodes": [ + {"id": 7, "type": "PromptNode", "inputs": [{"name": "prompt", "widget": {"name": "prompt"}, "link": 1}]}, + {"id": 8, "type": "Switch", "inputs": [{"name": "on_false", "type": "*", "link": 2}]}, + ], + "links": [ + {"id": 1, "origin_id": -10, "origin_slot": 0, "target_id": 7, "target_slot": 0}, + {"id": 2, "origin_id": -10, "origin_slot": 0, "target_id": 8, "target_slot": 0}, + ], + } + definitions = {"sg": sg} + + assert len(promoted._boundary_targets(sg, sg["inputs"][0], definitions, 0, _output_budget=[2])) == 2 + # Two targets, room for one: the socket must be charged like the widget. + with pytest.raises(promoted.PromotionTraversalLimitError, match="boundary traversal"): + promoted._boundary_targets(sg, sg["inputs"][0], {"sg": sg}, 0, _output_budget=[1]) def test_shared_definition_input_membership_is_not_promoted_or_resolved(): @@ -423,7 +466,7 @@ def test_shared_definition_input_membership_is_not_promoted_or_resolved(): assert [item.value_index for item in items] == [None, None] assert promoted._promotion_source(sg, shared_input, definitions) is None - assert promoted.boundary_widget_targets(sg, items[0], definitions) == [] + assert promoted.boundary_targets(sg, items[0], definitions) == [] def test_promoted_name_index_keeps_the_first_duplicate(): @@ -440,8 +483,8 @@ def test_synthetic_boundary_targets_do_not_share_the_minus_one_cache_key(): second = promoted.PromotedInput("second", "STRING", -1, 0, source_node="b", source_widget="y") with mock.patch.object(promoted, "deepest_source", side_effect=[(["a"], "x"), (["b"], "y")]) as deepest: - assert promoted.boundary_widget_targets(sg, first, definitions) == [(["a"], "x")] - assert promoted.boundary_widget_targets(sg, second, definitions) == [(["b"], "y")] + assert promoted.boundary_targets(sg, first, definitions) == [(["a"], "x")] + assert promoted.boundary_targets(sg, second, definitions) == [(["b"], "y")] assert deepest.call_count == 2 @@ -559,7 +602,7 @@ def test_duplicate_holder_fanout_fits_the_serialized_traversal_budget(): [item] = promoted.promoted_inputs(sg, definitions) - assert len(promoted.boundary_widget_targets(sg, item, definitions)) == 66 + assert len(promoted.boundary_targets(sg, item, definitions)) == 66 @pytest.mark.parametrize("malformed_slot", [True, False, 0.0]) @@ -584,7 +627,7 @@ def test_malformed_target_slot_does_not_exact_match_a_holder(malformed_slot): [item] = promoted.promoted_inputs(sg, definitions) assert item.source_widget == "first" - assert promoted.boundary_widget_targets(sg, item, definitions) == [(["7"], "first"), (["7"], "second")] + assert promoted.boundary_targets(sg, item, definitions) == [(["7"], "first"), (["7"], "second")] def test_promotion_resolvers_ignore_unhashable_link_ids(): @@ -608,7 +651,7 @@ def test_promotion_resolvers_ignore_unhashable_link_ids(): [item] = promoted.promoted_inputs(sg, definitions) assert promoted._promotion_source(sg, sg["inputs"][0], definitions) == ("8", "prompt") - assert promoted.boundary_widget_targets(sg, item, definitions) == [(["8"], "prompt")] + assert promoted.boundary_targets(sg, item, definitions) == [(["8"], "prompt")] def test_promotion_resolvers_do_not_alias_boolean_link_ids_to_integers(): @@ -630,7 +673,7 @@ def test_promotion_resolvers_do_not_alias_boolean_link_ids_to_integers(): assert item.value_index is None assert promoted._promotion_source(sg, sg["inputs"][0], definitions) is None - assert promoted.boundary_widget_targets(sg, item, definitions) == [] + assert promoted.boundary_targets(sg, item, definitions) == [] def test_promotion_resolvers_treat_non_list_link_ids_as_empty(): @@ -651,7 +694,7 @@ def test_promotion_resolvers_treat_non_list_link_ids_as_empty(): assert item.value_index is None assert promoted._promotion_source(sg, sg["inputs"][0], {"sg": sg}) is None - assert promoted.boundary_widget_targets(sg, item, {"sg": sg}) == [] + assert promoted.boundary_targets(sg, item, {"sg": sg}) == [] def test_primitive_targets_ignore_unhashable_listed_link_ids(): @@ -793,7 +836,7 @@ def test_reused_nested_boundary_paths_charge_each_materialized_copy(): pi = promoted.PromotedInput("value", "STRING", index=0, value_index=0) with pytest.raises(promoted.PromotionTraversalLimitError, match="boundary traversal"): - promoted.boundary_widget_targets(definitions["level-0"], pi, definitions) + promoted.boundary_targets(definitions["level-0"], pi, definitions) def test_valid_six_level_four_way_boundary_fanout_uses_the_output_budget(): @@ -818,7 +861,7 @@ def test_valid_six_level_four_way_boundary_fanout_uses_the_output_budget(): "links": [{"id": index + 1, "origin_id": -10, "target_id": index, "target_slot": 0} for index in range(4)], } - targets = promoted.boundary_widget_targets( + targets = promoted.boundary_targets( definitions["level-0"], promoted.PromotedInput("value", "STRING", 0, 0), definitions, @@ -849,7 +892,7 @@ def test_valid_ten_level_three_way_boundary_fanout_stays_below_output_cap(): "links": [{"id": index + 1, "origin_id": -10, "target_id": index, "target_slot": 0} for index in range(3)], } - targets = promoted.boundary_widget_targets( + targets = promoted.boundary_targets( definitions["level-0"], promoted.PromotedInput("value", "STRING", 0, 0), definitions, @@ -958,7 +1001,7 @@ def test_falsy_boundary_name_stays_cacheable_and_preserves_fanout(): definitions["root"] = root [item] = promoted.promoted_inputs(root, definitions) - assert promoted.boundary_widget_targets(root, item, definitions) == [(["7"], "0"), (["8"], "0")] + assert promoted.boundary_targets(root, item, definitions) == [(["7"], "0"), (["8"], "0")] def test_boundary_materialization_has_an_absolute_cap(monkeypatch): @@ -981,7 +1024,7 @@ def test_boundary_materialization_has_an_absolute_cap(monkeypatch): monkeypatch.setattr(promoted, "_MAX_BOUNDARY_MATERIALIZATIONS", 2) with pytest.raises(promoted.PromotionTraversalLimitError, match="safe limit"): - promoted.boundary_widget_targets(root, item, definitions) + promoted.boundary_targets(root, item, definitions) def test_boundary_output_allowance_does_not_accumulate_across_roots(monkeypatch): @@ -1007,10 +1050,10 @@ def root(name: str, width: int) -> dict: monkeypatch.setattr(promoted, "_MAX_BOUNDARY_MATERIALIZATIONS", 2) [small_item] = promoted.promoted_inputs(small, definitions) - assert len(promoted.boundary_widget_targets(small, small_item, definitions)) == 1 + assert len(promoted.boundary_targets(small, small_item, definitions)) == 1 [wide_item] = promoted.promoted_inputs(wide, definitions) with pytest.raises(promoted.PromotionTraversalLimitError, match="safe limit"): - promoted.boundary_widget_targets(wide, wide_item, definitions) + promoted.boundary_targets(wide, wide_item, definitions) def test_boundary_cache_hits_do_not_spend_the_distinct_materialization_budget(monkeypatch): @@ -1024,7 +1067,7 @@ def test_boundary_cache_hits_do_not_spend_the_distinct_materialization_budget(mo ) monkeypatch.setattr(promoted, "_MAX_BOUNDARY_MATERIALIZATIONS", 2) - assert promoted.boundary_widget_targets(root, item, definitions) == [ + assert promoted.boundary_targets(root, item, definitions) == [ (["1"], "value"), (["2"], "value"), (["3"], "value"), @@ -1363,8 +1406,8 @@ def test_boundary_targets_are_cached_for_the_definition_index(): item = promoted.PromotedInput("value", "STRING", 0, 0) with mock.patch.object(promoted, "_boundary_targets", wraps=promoted._boundary_targets) as resolver: - first = promoted.boundary_widget_targets(definition, item, definitions) - second = promoted.boundary_widget_targets(definition, item, definitions) + first = promoted.boundary_targets(definition, item, definitions) + second = promoted.boundary_targets(definition, item, definitions) assert second == first assert second is not first @@ -1386,7 +1429,7 @@ def test_definition_repairs_invalidate_cached_limits_and_holders(): original_links = promoted._cached_link_rows(definition, definitions) promoted.promoted_inputs(definition, definitions) promoted.promoted_inputs(other, definitions) - promoted.boundary_widget_targets(definition, promoted.PromotedInput("value", "STRING", 0, 0), definitions) + promoted.boundary_targets(definition, promoted.PromotedInput("value", "STRING", 0, 0), definitions) assert promoted._promotion_visit_limit(definitions, definition) > 0 assert len(definitions.promotion_inputs) == 2 assert definitions.promotion_boundaries @@ -1460,7 +1503,7 @@ def test_boundary_target_fanout_is_bounded_by_definition_graph_size(): item = promoted.PromotedInput("value", "STRING", 0, 0) with pytest.raises(promoted.PromotionTraversalLimitError, match="boundary traversal"): - promoted.boundary_widget_targets(root, item, definitions) + promoted.boundary_targets(root, item, definitions) # --------------------------------------------------------------------------- # diff --git a/tests/comfy_cli/fixtures/gallery/README.md b/tests/comfy_cli/fixtures/gallery/README.md index 802f9b2fc..947a5a547 100644 --- a/tests/comfy_cli/fixtures/gallery/README.md +++ b/tests/comfy_cli/fixtures/gallery/README.md @@ -11,7 +11,7 @@ Refresh with: ```bash cd tests/comfy_cli/fixtures/gallery -for f in 02_qwen_Image_edit_subgraphed 05_audio_ace_step_1_t2a_song_subgraphed image_z_image_turbo audio_minimax_music_3 api_seedance2_5_video_extend templates_graphic_design_recomposer template_horizontal_vertical_extension flux_dev_checkpoint_example; do +for f in 02_qwen_Image_edit_subgraphed 05_audio_ace_step_1_t2a_song_subgraphed image_z_image_turbo audio_minimax_music_3 api_seedance2_5_video_extend templates_graphic_design_recomposer template_horizontal_vertical_extension flux_dev_checkpoint_example image_qwen_image_2_1_image_edit; do curl -sfL "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/${f}.json" -o "${f}.json" done ``` @@ -31,6 +31,11 @@ promoted-widget tests (`tests/comfy_cli/cql/test_promoted_inputs.py`, covered by `../object_info_subgraph_promoted.json`, a trimmed copy of the cloud catalog entries (tooltips stripped, structure verbatim). +`image_qwen_image_2_1_image_edit.json` (one promoted `prompt` feeding both a +`TextGenerate` widget and a `ComfySwitchNode` `on_false` socket) backs the +socket-target tests in `tests/comfy_cli/test_workflow_to_api_promoted.py`; its +node classes were added to `../object_info_subgraph_promoted.json` the same way. + `templates_graphic_design_recomposer.json` (two `PrimitiveNode` fan-outs and a labelled value widget promoted only through legacy `proxyWidgets`), `template_horizontal_vertical_extension.json` (three `$$canvas-image-preview` diff --git a/tests/comfy_cli/fixtures/gallery/image_qwen_image_2_1_image_edit.json b/tests/comfy_cli/fixtures/gallery/image_qwen_image_2_1_image_edit.json new file mode 100644 index 000000000..f6c9b7bc5 --- /dev/null +++ b/tests/comfy_cli/fixtures/gallery/image_qwen_image_2_1_image_edit.json @@ -0,0 +1,2649 @@ +{ + "id": "54bb395d-3e60-4c94-b525-85523901575b", + "revision": 0, + "last_node_id": 501, + "last_link_id": 903, + "nodes": [ + { + "id": 459, + "type": "bc1c967a-7f6a-4be9-a372-dad16e4f28e3", + "pos": [ + 480, + 2420 + ], + "size": [ + 420, + 760 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "label": "positive_prompt", + "name": "prompt", + "type": "STRING", + "widget": { + "name": "prompt" + }, + "link": null + }, + { + "label": "refine_prompt", + "name": "switch_1", + "type": "BOOLEAN", + "widget": { + "name": "switch_1" + }, + "link": null + }, + { + "label": "steps", + "name": "steps", + "type": "INT", + "widget": { + "name": "steps" + }, + "link": null + }, + { + "label": "custom_size", + "name": "switch", + "type": "BOOLEAN", + "widget": { + "name": "switch" + }, + "link": null + }, + { + "label": "sampler", + "name": "scheduler", + "type": "COMBO", + "widget": { + "name": "scheduler" + }, + "link": null + }, + { + "label": "scheduler", + "name": "scheduler_1", + "type": "COMBO", + "widget": { + "name": "scheduler_1" + }, + "link": null + }, + { + "label": "cache_device", + "name": "device", + "type": "COMBO", + "widget": { + "name": "device" + }, + "link": null + }, + { + "label": "dtype", + "name": "dtype", + "type": "COMBO", + "widget": { + "name": "dtype" + }, + "link": null + }, + { + "label": "PE_model", + "name": "clip_name_1", + "type": "COMBO", + "widget": { + "name": "clip_name_1" + }, + "link": null + }, + { + "label": "image_1", + "name": "images.image_1", + "type": "IMAGE", + "link": 704 + }, + { + "label": "image_2", + "name": "images.image_2", + "shape": 7, + "type": "IMAGE", + "link": 728 + }, + { + "label": "image_3", + "name": "images.image_3", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "label": "image_4", + "name": "images.image_4", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "label": "image_5", + "name": "images.image_5_1", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "label": "image_6", + "name": "images.image_6", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "label": "image_7", + "name": "images.image_7", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "label": "image_8", + "name": "images.image_8", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "label": "image_9", + "name": "images.image_9", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "label": "image_10", + "name": "images.image_10", + "shape": 7, + "type": "IMAGE", + "link": null + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 672 + ] + } + ], + "properties": { + "previewExposures": [] + }, + "widgets_values": [ + 0, + "Replace costumes for the character", + false, + false, + 4096, + "", + 1, + 25, + false, + 1024, + 1024, + "euler", + "simple", + 891836227295375, + "qwen_image_2.1_int8_convrot.safetensors", + "qwen3vl_8b_int8_convrot.safetensors", + "qwen_image_2.1_vae_bf16.safetensors", + "auto", + "default", + "qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors" + ], + "widgets_values_named": { + "resolution": 0, + "prompt": "Replace costumes for the character", + "switch_1": false, + "thinking": false, + "max_length": 4096, + "negative_prompt": "", + "cfg": 1, + "steps": 25, + "switch": false, + "width": 1024, + "height": 1024, + "scheduler": "euler", + "scheduler_1": "simple", + "seed": 891836227295375, + "unet_name": "qwen_image_2.1_int8_convrot.safetensors", + "clip_name": "qwen3vl_8b_int8_convrot.safetensors", + "vae_name": "qwen_image_2.1_vae_bf16.safetensors", + "device": "auto", + "dtype": "default", + "clip_name_1": "qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors" + } + }, + { + "id": 461, + "type": "SaveImageAdvanced", + "pos": [ + 1410, + 2420 + ], + "size": [ + 710, + 760 + ], + "flags": {}, + "order": 6, + "mode": 0, + "showAdvanced": true, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 672 + } + ], + "outputs": [ + { + "name": "images", + "type": "IMAGE", + "links": [ + 708 + ] + } + ], + "properties": {}, + "widgets_values": [ + "Qwen_image_2.1", + "png", + "8-bit", + "sRGB" + ], + "widgets_values_named": { + "filename_prefix": "Qwen_image_2.1", + "format": "png", + "format.bit_depth": "8-bit", + "format.input_color_space": "sRGB" + } + }, + { + "id": 463, + "type": "MarkdownNote", + "pos": [ + -360, + 2410 + ], + "size": [ + 420, + 620 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [], + "title": "Note: Usage", + "properties": {}, + "widgets_values": [ + "## Size\nQwen Image 2.1 has native 2K (2048*2048) support for direct output.\n\n- resolution is a total pixel budget (not width or height). Aspect ratio is preserved.\n- Official default is 1024. The model supports up to 2048.\n- This template starts at 0: no resize beyond a multiple of 32.\n- Output follows image_1. Extra refs can differ in size or aspect.\n- custom_size off: canvas comes from the encode latent (image_1).\n- custom_size on: use ResolutionSelector width/height. Keep it close to the resized image_1 size, or the edit can shift.\n\n## Reference images\n- Up to 10 reference images (image_1 to image_10).\n- Mention them in the prompt as ``, ``, ...\n- image_1 is the edit target. The rest are references.\n\n## Custom settings\nIf you need custom settings, enter or unpack the subgraph to edit it. See the [Subgraph](https://docs.comfy.org/interface/features/subgraph) guide.\n\n## Parameters\n- prompt: edit instruction. Use `` ... ``.\n- negative_prompt: unused while cfg is 1.\n- cfg: keep 1 for the Qwen Image 2.1 official path. Raise it only if you use a negative prompt.\n- steps: Qwen Image 2.1 official pipeline uses about 40-50 with euler. This template starts at 25. More advanced samplers need fewer steps." + ], + "widgets_values_named": { + "text": "## Size\nQwen Image 2.1 has native 2K (2048*2048) support for direct output.\n\n- resolution is a total pixel budget (not width or height). Aspect ratio is preserved.\n- Official default is 1024. The model supports up to 2048.\n- This template starts at 0: no resize beyond a multiple of 32.\n- Output follows image_1. Extra refs can differ in size or aspect.\n- custom_size off: canvas comes from the encode latent (image_1).\n- custom_size on: use ResolutionSelector width/height. Keep it close to the resized image_1 size, or the edit can shift.\n\n## Reference images\n- Up to 10 reference images (image_1 to image_10).\n- Mention them in the prompt as ``, ``, ...\n- image_1 is the edit target. The rest are references.\n\n## Custom settings\nIf you need custom settings, enter or unpack the subgraph to edit it. See the [Subgraph](https://docs.comfy.org/interface/features/subgraph) guide.\n\n## Parameters\n- prompt: edit instruction. Use `` ... ``.\n- negative_prompt: unused while cfg is 1.\n- cfg: keep 1 for the Qwen Image 2.1 official path. Raise it only if you use a negative prompt.\n- steps: Qwen Image 2.1 official pipeline uses about 40-50 with euler. This template starts at 25. More advanced samplers need fewer steps." + }, + "color": "#222", + "bgcolor": "#000" + }, + { + "id": 470, + "type": "LoadImage", + "pos": [ + 140, + 2420 + ], + "size": [ + 290, + 110 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 704, + 707 + ] + }, + { + "name": "MASK", + "type": "MASK", + "links": null + } + ], + "properties": { + "Node name for S&R": "LoadImage" + }, + "widgets_values": [ + "portrait_model_denim.png", + "image" + ], + "widgets_values_named": { + "image": "portrait_model_denim.png", + "upload": "image" + } + }, + { + "id": 472, + "type": "ImageCompare", + "pos": [ + 2160, + 2420 + ], + "size": [ + 660, + 760 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "image_a", + "shape": 7, + "type": "IMAGE", + "link": 707 + }, + { + "name": "image_b", + "shape": 7, + "type": "IMAGE", + "link": 708 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "ImageCompare" + }, + "widgets_values": [], + "widgets_values_named": {} + }, + { + "id": 475, + "type": "LoadImage", + "pos": [ + 140, + 2810 + ], + "size": [ + 290, + 110 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 728 + ] + }, + { + "name": "MASK", + "type": "MASK", + "links": [] + } + ], + "properties": { + "Node name for S&R": "LoadImage" + }, + "widgets_values": [ + "clothing_light_blue_denim_shirt.png", + "image" + ], + "widgets_values_named": { + "image": "clothing_light_blue_denim_shirt.png", + "upload": "image" + } + }, + { + "id": 476, + "type": "MarkdownNote", + "pos": [ + -840, + 2410 + ], + "size": [ + 420, + 620 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [], + "outputs": [], + "title": "Note: Model links", + "properties": {}, + "widgets_values": [ + "Guide: [Subgraph](https://docs.comfy.org/interface/features/subgraph)\n\n## Input Assets\n\n- [portrait_model_denim.png](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/input/portrait_model_denim.png)\n- [clothing_light_blue_denim_shirt.png](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/input/clothing_light_blue_denim_shirt.png)\n\n\n## Model Links\n\n- [Hugging Face:Comfy-Org/Qwen-Image-2.1](https://huggingface.co/Comfy-Org/Qwen-Image-2.1)\n- [ModelScope:Comfy-Org/Qwen-Image-2.1](https://modelscope.cn/models/Comfy-Org/Qwen-Image-2.1)\n\n**diffusion_models**\n\n- [qwen_image_2.1_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_bf16.safetensors) (13.25 GB)\n- [qwen_image_2.1_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_int8_convrot.safetensors) (6.76 GB)\n\n**text_encoders**\n\n- [qwen3vl_8b_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_bf16.safetensors) (16.33 GB)\n- [qwen3vl_8b_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_int8_convrot.safetensors) (8.71 GB) \n- [qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors) (8.82 GB)\n\n**vae**\n\n- [qwen_image_2.1_vae_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/vae/qwen_image_2.1_vae_bf16.safetensors) (644.2 MB)\n\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ ├── 📂 diffusion_models/\n│ │ ├── qwen_image_2.1_bf16.safetensors\n│ │ └── qwen_image_2.1_int8_convrot.safetensors\n│ ├── 📂 text_encoders/\n│ │ ├── qwen3vl_8b_bf16.safetensors\n│ │ ├── qwen3vl_8b_int8_convrot.safetensors\n│ │ └── qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors│ └── 📂 vae/\n│ └── qwen_image_2.1_vae_bf16.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n" + ], + "widgets_values_named": { + "text": "Guide: [Subgraph](https://docs.comfy.org/interface/features/subgraph)\n\n## Input Assets\n\n- [portrait_model_denim.png](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/input/portrait_model_denim.png)\n- [clothing_light_blue_denim_shirt.png](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/input/clothing_light_blue_denim_shirt.png)\n\n\n## Model Links\n\n- [Hugging Face:Comfy-Org/Qwen-Image-2.1](https://huggingface.co/Comfy-Org/Qwen-Image-2.1)\n- [ModelScope:Comfy-Org/Qwen-Image-2.1](https://modelscope.cn/models/Comfy-Org/Qwen-Image-2.1)\n\n**diffusion_models**\n\n- [qwen_image_2.1_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_bf16.safetensors) (13.25 GB)\n- [qwen_image_2.1_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_int8_convrot.safetensors) (6.76 GB)\n\n**text_encoders**\n\n- [qwen3vl_8b_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_bf16.safetensors) (16.33 GB)\n- [qwen3vl_8b_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_int8_convrot.safetensors) (8.71 GB) \n- [qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors) (8.82 GB)\n\n**vae**\n\n- [qwen_image_2.1_vae_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/vae/qwen_image_2.1_vae_bf16.safetensors) (644.2 MB)\n\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ ├── 📂 diffusion_models/\n│ │ ├── qwen_image_2.1_bf16.safetensors\n│ │ └── qwen_image_2.1_int8_convrot.safetensors\n│ ├── 📂 text_encoders/\n│ │ ├── qwen3vl_8b_bf16.safetensors\n│ │ ├── qwen3vl_8b_int8_convrot.safetensors\n│ │ └── qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors│ └── 📂 vae/\n│ └── qwen_image_2.1_vae_bf16.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n" + }, + "color": "#222", + "bgcolor": "#000" + }, + { + "id": 501, + "type": "MarkdownNote", + "pos": [ + 920, + 2730 + ], + "size": [ + 420, + 480 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [], + "outputs": [], + "title": "Note: PE", + "properties": {}, + "widgets_values": [ + "## Prompt Enhancer\n\nThe prompt enhancer rewrites your instruction with the Qwen 3.5 prompt enhancer model before the edit model sees it. These settings follow the official prompt enhancer release, and the ones you are most likely to change are exposed on the node.\n\n- `refine_prompt`: on runs the rewrite and feeds it to the edit model, off passes your instruction through as written. On gives the edit model a fuller prompt and usually better results; off skips the rewrite pass and the run finishes faster. This template starts with it off.\n- `thinking`: turn this on together with the enhancer. The checkpoint was trained with a reasoning block and loses quality without it.\n- `max_length`: the token budget for the reasoning block plus the rewritten prompt, 4096 here. The official setting is 24000; this template caps it lower so a single rewrite cannot run for many minutes.\n- `sampling_mode`: the sampling values live inside the subgraph. They follow the official ones: `temperature` 1.0, `top_p` 0.95, `top_k` 20, `min_p` 0, `presence_penalty` 0, `repetition_penalty` 1.0.\n\nThe enhancer checkpoint and its system prompt live inside the subgraph." + ], + "widgets_values_named": { + "text": "## Prompt Enhancer\n\nThe prompt enhancer rewrites your instruction with the Qwen 3.5 prompt enhancer model before the edit model sees it. These settings follow the official prompt enhancer release, and the ones you are most likely to change are exposed on the node.\n\n- `refine_prompt`: on runs the rewrite and feeds it to the edit model, off passes your instruction through as written. On gives the edit model a fuller prompt and usually better results; off skips the rewrite pass and the run finishes faster. This template starts with it off.\n- `thinking`: turn this on together with the enhancer. The checkpoint was trained with a reasoning block and loses quality without it.\n- `max_length`: the token budget for the reasoning block plus the rewritten prompt, 4096 here. The official setting is 24000; this template caps it lower so a single rewrite cannot run for many minutes.\n- `sampling_mode`: the sampling values live inside the subgraph. They follow the official ones: `temperature` 1.0, `top_p` 0.95, `top_k` 20, `min_p` 0, `presence_penalty` 0, `repetition_penalty` 1.0.\n\nThe enhancer checkpoint and its system prompt live inside the subgraph." + }, + "color": "#222", + "bgcolor": "#000" + } + ], + "links": [ + [ + 707, + 470, + 0, + 472, + 0, + "IMAGE" + ], + [ + 708, + 461, + 0, + 472, + 1, + "IMAGE" + ], + [ + 704, + 470, + 0, + 459, + 9, + "IMAGE" + ], + [ + 728, + 475, + 0, + 459, + 10, + "IMAGE" + ], + [ + 672, + 459, + 0, + 461, + 0, + "IMAGE" + ] + ], + "groups": [], + "definitions": { + "subgraphs": [ + { + "id": "bc1c967a-7f6a-4be9-a372-dad16e4f28e3", + "version": 1, + "state": { + "lastGroupId": 38, + "lastNodeId": 501, + "lastLinkId": 903, + "lastRerouteId": 9 + }, + "revision": 0, + "config": {}, + "name": "Image Edit (Qwen Image 2.1)", + "inputNode": { + "id": -10, + "bounding": [ + -720, + 630, + 143.044921875, + 648 + ] + }, + "outputNode": { + "id": -20, + "bounding": [ + 1960, + 640, + 128, + 68 + ] + }, + "inputs": [ + { + "id": "1f3911c3-71b5-45b7-9a0e-4ac7285069dc", + "name": "resolution", + "type": "INT", + "linkIds": [ + 725 + ], + "pos": [ + -600.955078125, + 654 + ] + }, + { + "id": "6a73de3b-f4cd-43a4-9076-76648c6902f0", + "name": "prompt", + "type": "STRING", + "linkIds": [ + 739, + 802 + ], + "localized_name": "prompt", + "label": "positive_prompt", + "pos": [ + -600.955078125, + 674 + ] + }, + { + "id": "57887da4-f3f5-41b1-9fce-a7292abaef6a", + "name": "switch_1", + "type": "BOOLEAN", + "linkIds": [ + 741 + ], + "label": "refine_prompt", + "pos": [ + -600.955078125, + 694 + ] + }, + { + "id": "cd079967-6ff0-46d9-8b58-d52c2cdc5de5", + "name": "thinking", + "type": "BOOLEAN", + "linkIds": [ + 902 + ], + "pos": [ + -600.955078125, + 714 + ] + }, + { + "id": "d98ec6b1-9955-48e0-874d-b99d10218329", + "name": "max_length", + "type": "INT", + "linkIds": [ + 903 + ], + "pos": [ + -600.955078125, + 734 + ] + }, + { + "id": "d4c1377f-7fbc-4519-b83c-9a3b9c2de104", + "name": "negative_prompt", + "type": "STRING", + "linkIds": [ + 727 + ], + "pos": [ + -600.955078125, + 754 + ] + }, + { + "id": "420ee896-17c3-4e07-95fc-0ff309a6b836", + "name": "cfg", + "type": "FLOAT", + "linkIds": [ + 658 + ], + "pos": [ + -600.955078125, + 774 + ] + }, + { + "id": "349c3f72-ba7a-4277-84ff-8029faa16019", + "name": "steps", + "type": "INT", + "linkIds": [ + 659 + ], + "label": "steps", + "pos": [ + -600.955078125, + 794 + ] + }, + { + "id": "60df426d-f8ab-4ce2-8c82-42dc7cbf19d0", + "name": "switch", + "type": "BOOLEAN", + "linkIds": [ + 703 + ], + "label": "custom_size", + "pos": [ + -600.955078125, + 814 + ] + }, + { + "id": "91c96cf8-057b-4da2-b71e-305541a3527e", + "name": "width", + "type": "INT", + "linkIds": [ + 660 + ], + "localized_name": "width", + "pos": [ + -600.955078125, + 834 + ] + }, + { + "id": "661cc520-6bd0-4925-90ec-cecaa188b57d", + "name": "height", + "type": "INT", + "linkIds": [ + 661 + ], + "localized_name": "height", + "pos": [ + -600.955078125, + 854 + ] + }, + { + "id": "9f0e91b8-5a4a-4f5a-a2a4-4ddc180df0fd", + "name": "scheduler", + "type": "COMBO", + "linkIds": [ + 662 + ], + "label": "sampler", + "pos": [ + -600.955078125, + 874 + ] + }, + { + "id": "4710583f-3cb0-4091-87ab-dadd8a2e657c", + "name": "scheduler_1", + "type": "COMBO", + "linkIds": [ + 668 + ], + "label": "scheduler", + "pos": [ + -600.955078125, + 894 + ] + }, + { + "id": "977ce57d-3764-491c-8d2d-543754cfbaf1", + "name": "seed", + "type": "INT", + "linkIds": [ + 667, + 804 + ], + "pos": [ + -600.955078125, + 914 + ] + }, + { + "id": "143494fb-a40e-423f-be3b-ecc808b408b0", + "name": "unet_name", + "type": "COMBO", + "linkIds": [ + 663 + ], + "pos": [ + -600.955078125, + 934 + ] + }, + { + "id": "d8528289-e121-45ed-9c31-e6370ce4ba5e", + "name": "clip_name", + "type": "COMBO", + "linkIds": [ + 664 + ], + "pos": [ + -600.955078125, + 954 + ] + }, + { + "id": "f03d1fb0-d592-4997-b55e-e7a2549c36e5", + "name": "vae_name", + "type": "COMBO", + "linkIds": [ + 665 + ], + "pos": [ + -600.955078125, + 974 + ] + }, + { + "id": "c2d95dbf-7f92-4c0b-a138-b9b5d1472e7f", + "name": "device", + "type": "COMBO", + "linkIds": [ + 729 + ], + "label": "cache_device", + "pos": [ + -600.955078125, + 994 + ] + }, + { + "id": "974d6751-be03-4afc-911f-a0d43f7cb906", + "name": "dtype", + "type": "COMBO", + "linkIds": [ + 730 + ], + "label": "dtype", + "pos": [ + -600.955078125, + 1014 + ] + }, + { + "id": "c11b216a-e05d-49a4-b776-293022d01a52", + "name": "clip_name_1", + "type": "COMBO", + "linkIds": [ + 746 + ], + "label": "PE_model", + "pos": [ + -600.955078125, + 1034 + ] + }, + { + "id": "6bbe4c8a-0ce9-4576-9468-697a165b98b4", + "name": "images.image_1", + "type": "IMAGE", + "linkIds": [ + 710, + 750 + ], + "label": "image_1", + "pos": [ + -600.955078125, + 1054 + ] + }, + { + "id": "5e9080e7-bbd0-4363-9e25-aaa201f9ff01", + "name": "images.image_2", + "type": "IMAGE", + "linkIds": [ + 711, + 779 + ], + "label": "image_2", + "pos": [ + -600.955078125, + 1074 + ] + }, + { + "id": "29bd6732-17d4-4ca7-aa9f-dc118c6c008a", + "name": "images.image_3", + "type": "IMAGE", + "linkIds": [ + 712, + 780 + ], + "label": "image_3", + "pos": [ + -600.955078125, + 1094 + ] + }, + { + "id": "c0899e22-8834-4c49-b0ec-5d2e1c9a4f9d", + "name": "images.image_4", + "type": "IMAGE", + "linkIds": [ + 713, + 781 + ], + "label": "image_4", + "pos": [ + -600.955078125, + 1114 + ] + }, + { + "id": "f4bb2fe2-583b-429d-83dc-0af6d4d3fdf8", + "name": "images.image_5_1", + "type": "IMAGE", + "linkIds": [ + 714, + 782 + ], + "label": "image_5", + "pos": [ + -600.955078125, + 1134 + ] + }, + { + "id": "4dc8dcc5-da5f-4dd4-82f4-479dabed8567", + "name": "images.image_6", + "type": "IMAGE", + "linkIds": [ + 715, + 783 + ], + "label": "image_6", + "pos": [ + -600.955078125, + 1154 + ] + }, + { + "id": "58ac7e94-91ff-4992-9022-fd67902782eb", + "name": "images.image_7", + "type": "IMAGE", + "linkIds": [ + 716, + 784 + ], + "label": "image_7", + "pos": [ + -600.955078125, + 1174 + ] + }, + { + "id": "b736a3f9-62a7-4b77-ad2b-9ed40a482949", + "name": "images.image_8", + "type": "IMAGE", + "linkIds": [ + 717, + 785 + ], + "label": "image_8", + "pos": [ + -600.955078125, + 1194 + ] + }, + { + "id": "79883453-5e79-4003-a7ef-8d9156cffcc4", + "name": "images.image_9", + "type": "IMAGE", + "linkIds": [ + 718, + 786 + ], + "label": "image_9", + "pos": [ + -600.955078125, + 1214 + ] + }, + { + "id": "68c8b3fa-d3fd-4281-82ba-09030a9918dc", + "name": "images.image_10", + "type": "IMAGE", + "linkIds": [ + 719, + 787 + ], + "label": "image_10", + "pos": [ + -600.955078125, + 1234 + ] + } + ], + "outputs": [ + { + "id": "f6f3effc-0961-4c17-b52c-a77c16ca6aa4", + "name": "IMAGE", + "type": "IMAGE", + "linkIds": [ + 650 + ], + "localized_name": "IMAGE", + "pos": [ + 1984, + 664 + ] + } + ], + "widgets": [], + "nodes": [ + { + "id": 451, + "type": "UNETLoader", + "pos": [ + -190, + 410 + ], + "size": [ + 510, + 90 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { + "localized_name": "unet_name", + "name": "unet_name", + "type": "COMBO", + "widget": { + "name": "unet_name" + }, + "link": 663 + } + ], + "outputs": [ + { + "localized_name": "MODEL", + "name": "MODEL", + "type": "MODEL", + "links": [ + 688 + ] + } + ], + "properties": { + "Node name for S&R": "UNETLoader", + "models": [ + { + "name": "qwen_image_2.1_int8_convrot.safetensors", + "url": "https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_int8_convrot.safetensors", + "directory": "diffusion_models" + } + ] + }, + "widgets_values": [ + "qwen_image_2.1_int8_convrot.safetensors", + "default" + ], + "widgets_values_named": { + "unet_name": "qwen_image_2.1_int8_convrot.safetensors", + "weight_dtype": "default" + } + }, + { + "id": 453, + "type": "CLIPLoader", + "pos": [ + -190, + 570 + ], + "size": [ + 510, + 120 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "localized_name": "clip_name", + "name": "clip_name", + "type": "COMBO", + "widget": { + "name": "clip_name" + }, + "link": 664 + } + ], + "outputs": [ + { + "localized_name": "CLIP", + "name": "CLIP", + "type": "CLIP", + "links": [ + 721 + ] + } + ], + "properties": { + "Node name for S&R": "CLIPLoader", + "models": [ + { + "name": "qwen3vl_8b_int8_convrot.safetensors", + "url": "https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_int8_convrot.safetensors", + "directory": "text_encoders" + } + ] + }, + "widgets_values": [ + "qwen3vl_8b_int8_convrot.safetensors", + "qwen_image", + "default" + ], + "widgets_values_named": { + "clip_name": "qwen3vl_8b_int8_convrot.safetensors", + "type": "qwen_image", + "device": "default" + } + }, + { + "id": 454, + "type": "VAELoader", + "pos": [ + -190, + 770 + ], + "size": [ + 510, + 70 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "localized_name": "vae_name", + "name": "vae_name", + "type": "COMBO", + "widget": { + "name": "vae_name" + }, + "link": 665 + } + ], + "outputs": [ + { + "localized_name": "VAE", + "name": "VAE", + "type": "VAE", + "links": [ + 649, + 720 + ] + } + ], + "properties": { + "Node name for S&R": "VAELoader", + "models": [ + { + "name": "qwen_image_2.1_vae_bf16.safetensors", + "url": "https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/vae/qwen_image_2.1_vae_bf16.safetensors", + "directory": "vae" + } + ] + }, + "widgets_values": [ + "qwen_image_2.1_vae_bf16.safetensors" + ], + "widgets_values_named": { + "vae_name": "qwen_image_2.1_vae_bf16.safetensors" + } + }, + { + "id": 456, + "type": "EmptyLatentImage", + "pos": [ + -70, + 1010 + ], + "size": [ + 300, + 120 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "localized_name": "width", + "name": "width", + "type": "INT", + "widget": { + "name": "width" + }, + "link": 660 + }, + { + "localized_name": "height", + "name": "height", + "type": "INT", + "widget": { + "name": "height" + }, + "link": 661 + } + ], + "outputs": [ + { + "localized_name": "LATENT", + "name": "LATENT", + "type": "LATENT", + "links": [ + 684 + ] + } + ], + "properties": { + "Node name for S&R": "EmptyLatentImage" + }, + "widgets_values": [ + 1024, + 1024, + 1 + ], + "widgets_values_named": { + "width": 1024, + "height": 1024, + "batch_size": 1 + } + }, + { + "id": 457, + "type": "VAEDecode", + "pos": [ + 1620, + 660 + ], + "size": [ + 230, + 60 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "localized_name": "samples", + "name": "samples", + "type": "LATENT", + "link": 651 + }, + { + "localized_name": "vae", + "name": "vae", + "type": "VAE", + "link": 649 + } + ], + "outputs": [ + { + "localized_name": "IMAGE", + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 650 + ] + } + ], + "properties": { + "Node name for S&R": "VAEDecode" + } + }, + { + "id": 458, + "type": "KSampler", + "pos": [ + 1180, + 640 + ], + "size": [ + 270, + 270 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "localized_name": "model", + "name": "model", + "type": "MODEL", + "link": 689 + }, + { + "localized_name": "positive", + "name": "positive", + "type": "CONDITIONING", + "link": 722 + }, + { + "localized_name": "negative", + "name": "negative", + "type": "CONDITIONING", + "link": 723 + }, + { + "localized_name": "latent_image", + "name": "latent_image", + "type": "LATENT", + "link": 682 + }, + { + "localized_name": "seed", + "name": "seed", + "type": "INT", + "widget": { + "name": "seed" + }, + "link": 667 + }, + { + "localized_name": "steps", + "name": "steps", + "type": "INT", + "widget": { + "name": "steps" + }, + "link": 659 + }, + { + "localized_name": "cfg", + "name": "cfg", + "type": "FLOAT", + "widget": { + "name": "cfg" + }, + "link": 658 + }, + { + "localized_name": "sampler_name", + "name": "sampler_name", + "type": "COMBO", + "widget": { + "name": "sampler_name" + }, + "link": 662 + }, + { + "localized_name": "scheduler", + "name": "scheduler", + "type": "COMBO", + "widget": { + "name": "scheduler" + }, + "link": 668 + } + ], + "outputs": [ + { + "localized_name": "LATENT", + "name": "LATENT", + "type": "LATENT", + "links": [ + 651 + ] + } + ], + "properties": { + "Node name for S&R": "KSampler" + }, + "widgets_values": [ + 0, + "randomize", + 25, + 1, + "euler", + "simple", + 1 + ], + "widgets_values_named": { + "seed": 0, + "control_after_generate": "randomize", + "steps": 25, + "cfg": 1, + "sampler_name": "euler", + "scheduler": "simple", + "denoise": 1 + } + }, + { + "id": 468, + "type": "ComfySwitchNode", + "pos": [ + 570, + 1040 + ], + "size": [ + 270, + 80 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "localized_name": "on_false", + "name": "on_false", + "shape": 7, + "type": "LATENT", + "link": 724 + }, + { + "localized_name": "on_true", + "name": "on_true", + "shape": 7, + "type": "LATENT", + "link": 684 + }, + { + "localized_name": "switch", + "name": "switch", + "type": "BOOLEAN", + "widget": { + "name": "switch" + }, + "link": 703 + } + ], + "outputs": [ + { + "localized_name": "output", + "name": "output", + "type": "LATENT", + "links": [ + 682 + ] + } + ], + "properties": { + "Node name for S&R": "ComfySwitchNode" + }, + "widgets_values": [ + false + ], + "widgets_values_named": { + "switch": false + } + }, + { + "id": 469, + "type": "QwenImage21Cache", + "pos": [ + 1180, + 460 + ], + "size": [ + 270, + 90 + ], + "flags": {}, + "order": 8, + "mode": 0, + "inputs": [ + { + "localized_name": "model", + "name": "model", + "type": "MODEL", + "link": 688 + }, + { + "localized_name": "device", + "name": "device", + "type": "COMBO", + "widget": { + "name": "device" + }, + "link": 729 + }, + { + "localized_name": "dtype", + "name": "dtype", + "type": "COMBO", + "widget": { + "name": "dtype" + }, + "link": 730 + } + ], + "outputs": [ + { + "localized_name": "MODEL", + "name": "MODEL", + "type": "MODEL", + "links": [ + 689 + ] + } + ], + "properties": { + "Node name for S&R": "QwenImage21Cache" + }, + "widgets_values": [ + "auto", + "default" + ], + "widgets_values_named": { + "device": "auto", + "dtype": "default" + } + }, + { + "id": 474, + "type": "TextEncodeQwenImage21", + "pos": [ + 500, + 430 + ], + "size": [ + 460, + 520 + ], + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "localized_name": "clip", + "name": "clip", + "type": "CLIP", + "link": 721 + }, + { + "localized_name": "image_1", + "name": "images.image_1", + "shape": 7, + "type": "IMAGE", + "link": 710 + }, + { + "localized_name": "vae", + "name": "vae", + "shape": 7, + "type": "VAE", + "link": 720 + }, + { + "localized_name": "prompt", + "name": "prompt", + "type": "STRING", + "widget": { + "name": "prompt" + }, + "link": 743 + }, + { + "localized_name": "negative_prompt", + "name": "negative_prompt", + "type": "STRING", + "widget": { + "name": "negative_prompt" + }, + "link": 727 + }, + { + "localized_name": "resolution", + "name": "resolution", + "type": "INT", + "widget": { + "name": "resolution" + }, + "link": 725 + }, + { + "localized_name": "image_12", + "name": "images.image_12", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "localized_name": "image_7", + "name": "images.image_7", + "shape": 7, + "type": "IMAGE", + "link": 716 + }, + { + "localized_name": "image_8", + "name": "images.image_8", + "shape": 7, + "type": "IMAGE", + "link": 717 + }, + { + "localized_name": "image_9", + "name": "images.image_9", + "shape": 7, + "type": "IMAGE", + "link": 718 + }, + { + "localized_name": "image_10", + "name": "images.image_10", + "shape": 7, + "type": "IMAGE", + "link": 719 + }, + { + "localized_name": "image_11", + "name": "images.image_11", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "localized_name": "image_2", + "name": "images.image_2", + "shape": 7, + "type": "IMAGE", + "link": 711 + }, + { + "localized_name": "image_3", + "name": "images.image_3", + "shape": 7, + "type": "IMAGE", + "link": 712 + }, + { + "localized_name": "image_4", + "name": "images.image_4", + "shape": 7, + "type": "IMAGE", + "link": 713 + }, + { + "localized_name": "image_5", + "name": "images.image_5", + "shape": 7, + "type": "IMAGE", + "link": 714 + }, + { + "localized_name": "image_6", + "name": "images.image_6", + "shape": 7, + "type": "IMAGE", + "link": 715 + } + ], + "outputs": [ + { + "localized_name": "positive", + "name": "positive", + "type": "CONDITIONING", + "links": [ + 722 + ] + }, + { + "localized_name": "negative", + "name": "negative", + "type": "CONDITIONING", + "links": [ + 723 + ] + }, + { + "localized_name": "latent", + "name": "latent", + "type": "LATENT", + "links": [ + 724 + ] + } + ], + "properties": { + "Node name for S&R": "TextEncodeQwenImage21" + }, + "widgets_values": [ + "", + "", + 1024 + ], + "widgets_values_named": { + "prompt": "", + "negative_prompt": "", + "resolution": 1024 + } + }, + { + "id": 477, + "type": "CLIPLoader", + "pos": [ + -180, + -480 + ], + "size": [ + 530, + 120 + ], + "flags": {}, + "order": 10, + "mode": 0, + "inputs": [ + { + "localized_name": "clip_name", + "name": "clip_name", + "type": "COMBO", + "widget": { + "name": "clip_name" + }, + "link": 746 + } + ], + "outputs": [ + { + "localized_name": "CLIP", + "name": "CLIP", + "type": "CLIP", + "links": [ + 800 + ] + } + ], + "properties": { + "Node name for S&R": "CLIPLoader", + "models": [ + { + "name": "qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors", + "url": "https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors", + "directory": "text_encoders" + } + ] + }, + "widgets_values": [ + "qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors", + "qwen_image", + "default" + ], + "widgets_values_named": { + "clip_name": "qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors", + "type": "qwen_image", + "device": "default" + } + }, + { + "id": 479, + "type": "PrimitiveStringMultiline", + "pos": [ + -180, + 10 + ], + "size": [ + 620, + 240 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "localized_name": "STRING", + "name": "STRING", + "type": "STRING", + "links": [ + 901 + ] + } + ], + "title": "Text (System Prompt)", + "properties": { + "Node name for S&R": "PrimitiveStringMultiline" + }, + "widgets_values": [ + "# Edit Prompt Enhancer — General (v2, 精简版)\n\n**FIRST — there are TWO separate language decisions. Do NOT conflate them.**\n\n**(A) Language of the rewritten prompt's DESCRIPTIVE prose — every word OUTSIDE double quotes (the description you write for the diffusion model, NOT the text painted into the image). This decision is final and non-negotiable:**\n- User instruction is in Chinese → write the description in Chinese.\n- User instruction is in English → write the description in English.\n- User instruction is in ANY other language (Japanese, Korean, French, Spanish, Thai, etc.) → write the description in English.\n\n**(B) Language of the TEXT THAT WILL BE RENDERED INTO THE OUTPUT IMAGE — the content INSIDE double quotes. Decide it in this strict priority order:**\n1. If the user's instruction gives the exact text to write, OR names a target language for the text (e.g. \"改成'夏日特惠'\", \"把标题写成英文\", \"add a Japanese title\", \"write the caption in Thai\") → render exactly that text / in exactly that specified language.\n2. Otherwise, if the input image already contains text → render in the DOMINANT language of the image's existing text — even when the instruction is written in a different language.\n3. Otherwise (the image contains no text AND the instruction names no target language) → render in the language of the user's instruction itself — including Japanese, Korean, Thai, Arabic, French, etc. Do NOT force it to English.\nWorked example: image is mostly Thai, instruction is in English asking to add/redesign a title without giving the exact words or a language → the rendered (quoted) text must be **Thai** (the image's dominant language), while the surrounding description (A) is still written in English.\n\nTwo reinforcements on decision (B): all rendered (quoted) text must be **monolingual** — do not mix Chinese and English inside the quotes and do not emit a bilingual pair unless the user explicitly asks for one. And **genre never overrides input language**: a \"spec sheet / cinematic data-document / storyboard / technical parameter\" look is achieved through layout and typography, NOT by switching rendered labels to English — every header, label, and caption stays in the decided language (standardized units and user-given proper nouns may remain Latin).\n\nYou are an expert at clarifying image editing instructions. Given a user's vague or ambiguous edit instruction and the input image(s), rewrite it into a precise, unambiguous, actionable editing directive. An input image is ALWAYS present — this is always an image-editing task, never text-to-image from nothing.\n\n## Core Objective\n\nRewrite the instruction so a downstream image-editing model can execute it without guessing — anchored on what the input image(s) actually show, faithful to the user's intent, inventing nothing.\n\n**How much you build is intent-branched.** When the user wants *this picture changed* (a local object/attribute/background edit, a text or UI edit, a quality or style change, a viewpoint/canvas transform), clarify and constrain: say exactly what changes, and let everything else stand. When the user wants *a new picture of this subject* (placing a subject in a new scene, compositing across images, a photo-shoot or poster or infographic built from a reference), construct actively: design the scene, lighting, composition and layout to a professional standard. Scale the elaboration to what was asked — a plain placement stays restrained, a styled shoot or a publication-grade poster is built out fully.\n\n## The Governing Principle — Attribute Disentanglement at Full Strength\n\n**Edit exactly the attribute(s) the user named, push each to a strong and unmistakable degree, and hold everything else at input fidelity.**\n\nBoth halves matter, and the two failure modes are symmetric:\n\n- **Leakage** — touching what the user did not name (a sharpen that re-grades color, an upscale that reframes, a style change that drifts a face, an outfit swap that drops an accessory, a background change that \"helpfully\" cleans up something unmentioned).\n- **Under-editing** — an output a viewer could mistake for the unedited input, because the requested change was applied faintly.\n\nPreservation locks **content, never edit strength**. Recognizability is bought by naming what stays fixed, not by holding the effect back.\n\n## What to Anchor, What to Decide\n\n**Anchor on the image.** Every spatial, tonal and contextual claim comes from what is visibly there. If you are unsure a detail exists, leave it out — a preserved element described at a higher level of abstraction is always safer than an invented specific.\n\n**Say what stays, without repainting it.** Name the untargeted content by type, position and role rather than describing its appearance, and prefer one blanket preservation clause over walking the frame. A preservation description reads to the model as a generation instruction: the more concretely you describe something you meant to keep, the more likely it drifts. Describe appearance concretely only for what you are actually changing, or when it is the only way to disambiguate between similar objects.\n\n**Identity is the hardest invariant.** A person's facial identity and the personal accessories that make them recognizable; a product's exact design, markings and count; and the input's rendering medium (photograph, anime, illustration, sketch, 3D render, painting) all survive every edit unless the user explicitly targets them. When identity comes from a reference image, point at that image rather than describing features in words — verbal descriptions make the model regenerate and degrade the likeness.\n\n**Resolve ambiguity, then commit.** Turn vague intent, imprecise spatial reference and unparameterized style words into something concrete and observable. Translate abstract quality language into the visual properties it implies. Where the instruction offers alternatives or contradicts itself, pick the most reasonable reading and state it as a decision. Keep the user's own action verb, spatial relations and described state intact, and treat anything they asked to preserve as absolute. Preserve creative or physically impossible intent rather than correcting it.\n\n**Only what was asked.** Do not add operations the user did not request, and do not clean up unmentioned defects, overlays or clutter however prominent they look. When an edit removes, moves or reveals something, say enough about the newly exposed region that the result stays physically coherent.\n\n**Text in the image is literal.** Whenever readable text will appear in the output, commit to the exact characters — every element, quoted, nothing summarized or abbreviated away. Text you cannot commit to should not be added at all. Match the typography and language the input establishes unless the user asks otherwise. When the operation extends the canvas outward, name it as outpainting explicitly.\n\n**Write it as an instruction.** Lead with the operation, not a description of the finished picture, and write from the perspective of someone holding only the input image(s).\n\n## Thinking Process\n\nBefore emitting the final prompt, reason through: what the image(s) actually contain (including a complete reading of any text present); what the user is asking for and which attributes that names; what must therefore stay fixed; and finally the composed directive. Close with a check that every visible element is either the target of the edit or covered by what stays fixed, that the requested change is unmistakable, that nothing outside the target was touched, and that every quoted string obeys language decision (B).\n\n## Image Reference Rules\n\nFor Multi-Image Input (N >= 2), the rewritten instruction MUST use ``, ``, ... to refer to each input image. Do not use natural language references like \"图1\", \"第一张图\", \"the first image\", or \"image A\". This tagging format is mandatory and non-negotiable. For single-image input (N = 1), do NOT use tags — refer to the image naturally (\"图像\", \"图片中\", \"the image\").\n\nState each image's role explicitly — which one is the canvas whose composition and untargeted content survive, and which supply material to transfer — and say what is taken from each. For scene generation with no canvas (合影/合照 and the like), all images serve as identity sources. Describe every referenced image individually; never compress several into a range or a group to avoid describing them one by one.\n\n## Output Format\nOutput ONLY the rewritten editing instruction itself: one single continuous paragraph of plain text.\n\nFormatting rules:\n- The entire rewritten prompt must be a single continuous paragraph with NO line breaks or newline characters.\n- The response must contain nothing except the instruction itself: no object or array wrapper, no field names or key-value pairs, no headings, labels, or prefaces, no greetings, explanations, or commentary, no markdown, and no code fences. Begin with the first word of the instruction and end with its last word.\n- Do not wrap the whole instruction in quotes: double quotes are reserved for text that will be RENDERED in the image (next rule).\n- All text that should appear as visible, readable content in the output image must be enclosed in double quotes (\"\"). Descriptive or structural language that does not appear as rendered text should NOT be quoted.\n- **Never include any resolution or aspect ratio information** (e.g., \"2:3\", \"16:9\", \"1920x1080\", \"2K\", \"4K\"). Output size is decided downstream, not by you.\n- Write it out in full — no ellipsis, no truncation.\n- State requirements affirmatively (\"保持背景与输入图完全一致\") rather than as prohibitions (\"禁止改变背景\"). Standard preservation phrasing \"保持/保留[X]不变\" is fine.\n- Be precise and decisive: no hedging, no unresolved alternatives, no vague degree words left unresolved.\n- The descriptive prose (outside double quotes) follows language decision (A); the text rendered inside the image (inside double quotes) follows language decision (B). Retain proper nouns and domain-specific terms in their original language, placed in English double quotes.\n- **Language-purge self-check (do this last)**: re-scan every double-quoted string — the text that will be RENDERED in the image — and enforce language decision (B). No quoted string may mix Chinese and English, form a bilingual pair, or carry a parenthetical translation gloss unless the user explicitly asked. Standardized units and user-given proper nouns may remain Latin.\n\nThe user's edit instruction to rewrite is:" + ], + "widgets_values_named": { + "value": "# Edit Prompt Enhancer — General (v2, 精简版)\n\n**FIRST — there are TWO separate language decisions. Do NOT conflate them.**\n\n**(A) Language of the rewritten prompt's DESCRIPTIVE prose — every word OUTSIDE double quotes (the description you write for the diffusion model, NOT the text painted into the image). This decision is final and non-negotiable:**\n- User instruction is in Chinese → write the description in Chinese.\n- User instruction is in English → write the description in English.\n- User instruction is in ANY other language (Japanese, Korean, French, Spanish, Thai, etc.) → write the description in English.\n\n**(B) Language of the TEXT THAT WILL BE RENDERED INTO THE OUTPUT IMAGE — the content INSIDE double quotes. Decide it in this strict priority order:**\n1. If the user's instruction gives the exact text to write, OR names a target language for the text (e.g. \"改成'夏日特惠'\", \"把标题写成英文\", \"add a Japanese title\", \"write the caption in Thai\") → render exactly that text / in exactly that specified language.\n2. Otherwise, if the input image already contains text → render in the DOMINANT language of the image's existing text — even when the instruction is written in a different language.\n3. Otherwise (the image contains no text AND the instruction names no target language) → render in the language of the user's instruction itself — including Japanese, Korean, Thai, Arabic, French, etc. Do NOT force it to English.\nWorked example: image is mostly Thai, instruction is in English asking to add/redesign a title without giving the exact words or a language → the rendered (quoted) text must be **Thai** (the image's dominant language), while the surrounding description (A) is still written in English.\n\nTwo reinforcements on decision (B): all rendered (quoted) text must be **monolingual** — do not mix Chinese and English inside the quotes and do not emit a bilingual pair unless the user explicitly asks for one. And **genre never overrides input language**: a \"spec sheet / cinematic data-document / storyboard / technical parameter\" look is achieved through layout and typography, NOT by switching rendered labels to English — every header, label, and caption stays in the decided language (standardized units and user-given proper nouns may remain Latin).\n\nYou are an expert at clarifying image editing instructions. Given a user's vague or ambiguous edit instruction and the input image(s), rewrite it into a precise, unambiguous, actionable editing directive. An input image is ALWAYS present — this is always an image-editing task, never text-to-image from nothing.\n\n## Core Objective\n\nRewrite the instruction so a downstream image-editing model can execute it without guessing — anchored on what the input image(s) actually show, faithful to the user's intent, inventing nothing.\n\n**How much you build is intent-branched.** When the user wants *this picture changed* (a local object/attribute/background edit, a text or UI edit, a quality or style change, a viewpoint/canvas transform), clarify and constrain: say exactly what changes, and let everything else stand. When the user wants *a new picture of this subject* (placing a subject in a new scene, compositing across images, a photo-shoot or poster or infographic built from a reference), construct actively: design the scene, lighting, composition and layout to a professional standard. Scale the elaboration to what was asked — a plain placement stays restrained, a styled shoot or a publication-grade poster is built out fully.\n\n## The Governing Principle — Attribute Disentanglement at Full Strength\n\n**Edit exactly the attribute(s) the user named, push each to a strong and unmistakable degree, and hold everything else at input fidelity.**\n\nBoth halves matter, and the two failure modes are symmetric:\n\n- **Leakage** — touching what the user did not name (a sharpen that re-grades color, an upscale that reframes, a style change that drifts a face, an outfit swap that drops an accessory, a background change that \"helpfully\" cleans up something unmentioned).\n- **Under-editing** — an output a viewer could mistake for the unedited input, because the requested change was applied faintly.\n\nPreservation locks **content, never edit strength**. Recognizability is bought by naming what stays fixed, not by holding the effect back.\n\n## What to Anchor, What to Decide\n\n**Anchor on the image.** Every spatial, tonal and contextual claim comes from what is visibly there. If you are unsure a detail exists, leave it out — a preserved element described at a higher level of abstraction is always safer than an invented specific.\n\n**Say what stays, without repainting it.** Name the untargeted content by type, position and role rather than describing its appearance, and prefer one blanket preservation clause over walking the frame. A preservation description reads to the model as a generation instruction: the more concretely you describe something you meant to keep, the more likely it drifts. Describe appearance concretely only for what you are actually changing, or when it is the only way to disambiguate between similar objects.\n\n**Identity is the hardest invariant.** A person's facial identity and the personal accessories that make them recognizable; a product's exact design, markings and count; and the input's rendering medium (photograph, anime, illustration, sketch, 3D render, painting) all survive every edit unless the user explicitly targets them. When identity comes from a reference image, point at that image rather than describing features in words — verbal descriptions make the model regenerate and degrade the likeness.\n\n**Resolve ambiguity, then commit.** Turn vague intent, imprecise spatial reference and unparameterized style words into something concrete and observable. Translate abstract quality language into the visual properties it implies. Where the instruction offers alternatives or contradicts itself, pick the most reasonable reading and state it as a decision. Keep the user's own action verb, spatial relations and described state intact, and treat anything they asked to preserve as absolute. Preserve creative or physically impossible intent rather than correcting it.\n\n**Only what was asked.** Do not add operations the user did not request, and do not clean up unmentioned defects, overlays or clutter however prominent they look. When an edit removes, moves or reveals something, say enough about the newly exposed region that the result stays physically coherent.\n\n**Text in the image is literal.** Whenever readable text will appear in the output, commit to the exact characters — every element, quoted, nothing summarized or abbreviated away. Text you cannot commit to should not be added at all. Match the typography and language the input establishes unless the user asks otherwise. When the operation extends the canvas outward, name it as outpainting explicitly.\n\n**Write it as an instruction.** Lead with the operation, not a description of the finished picture, and write from the perspective of someone holding only the input image(s).\n\n## Thinking Process\n\nBefore emitting the final prompt, reason through: what the image(s) actually contain (including a complete reading of any text present); what the user is asking for and which attributes that names; what must therefore stay fixed; and finally the composed directive. Close with a check that every visible element is either the target of the edit or covered by what stays fixed, that the requested change is unmistakable, that nothing outside the target was touched, and that every quoted string obeys language decision (B).\n\n## Image Reference Rules\n\nFor Multi-Image Input (N >= 2), the rewritten instruction MUST use ``, ``, ... to refer to each input image. Do not use natural language references like \"图1\", \"第一张图\", \"the first image\", or \"image A\". This tagging format is mandatory and non-negotiable. For single-image input (N = 1), do NOT use tags — refer to the image naturally (\"图像\", \"图片中\", \"the image\").\n\nState each image's role explicitly — which one is the canvas whose composition and untargeted content survive, and which supply material to transfer — and say what is taken from each. For scene generation with no canvas (合影/合照 and the like), all images serve as identity sources. Describe every referenced image individually; never compress several into a range or a group to avoid describing them one by one.\n\n## Output Format\nOutput ONLY the rewritten editing instruction itself: one single continuous paragraph of plain text.\n\nFormatting rules:\n- The entire rewritten prompt must be a single continuous paragraph with NO line breaks or newline characters.\n- The response must contain nothing except the instruction itself: no object or array wrapper, no field names or key-value pairs, no headings, labels, or prefaces, no greetings, explanations, or commentary, no markdown, and no code fences. Begin with the first word of the instruction and end with its last word.\n- Do not wrap the whole instruction in quotes: double quotes are reserved for text that will be RENDERED in the image (next rule).\n- All text that should appear as visible, readable content in the output image must be enclosed in double quotes (\"\"). Descriptive or structural language that does not appear as rendered text should NOT be quoted.\n- **Never include any resolution or aspect ratio information** (e.g., \"2:3\", \"16:9\", \"1920x1080\", \"2K\", \"4K\"). Output size is decided downstream, not by you.\n- Write it out in full — no ellipsis, no truncation.\n- State requirements affirmatively (\"保持背景与输入图完全一致\") rather than as prohibitions (\"禁止改变背景\"). Standard preservation phrasing \"保持/保留[X]不变\" is fine.\n- Be precise and decisive: no hedging, no unresolved alternatives, no vague degree words left unresolved.\n- The descriptive prose (outside double quotes) follows language decision (A); the text rendered inside the image (inside double quotes) follows language decision (B). Retain proper nouns and domain-specific terms in their original language, placed in English double quotes.\n- **Language-purge self-check (do this last)**: re-scan every double-quoted string — the text that will be RENDERED in the image — and enforce language decision (B). No quoted string may mix Chinese and English, form a bilingual pair, or carry a parenthetical translation gloss unless the user explicitly asked. Standardized units and user-given proper nouns may remain Latin.\n\nThe user's edit instruction to rewrite is:" + } + }, + { + "id": 480, + "type": "PreviewAny", + "pos": [ + 1040, + -480 + ], + "size": [ + 470, + 680 + ], + "flags": {}, + "order": 11, + "mode": 0, + "inputs": [ + { + "localized_name": "source", + "name": "source", + "type": "*", + "link": 791 + } + ], + "outputs": [ + { + "localized_name": "STRING", + "name": "STRING", + "type": "STRING", + "links": [ + 743 + ] + } + ], + "properties": { + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [], + "widgets_values_named": {} + }, + { + "id": 484, + "type": "ComfySwitchNode", + "pos": [ + 620, + 120 + ], + "size": [ + 270, + 80 + ], + "flags": {}, + "order": 12, + "mode": 0, + "inputs": [ + { + "localized_name": "on_false", + "name": "on_false", + "shape": 7, + "type": "STRING", + "link": 739 + }, + { + "localized_name": "on_true", + "name": "on_true", + "shape": 7, + "type": "STRING", + "link": 806 + }, + { + "localized_name": "switch", + "name": "switch", + "type": "BOOLEAN", + "widget": { + "name": "switch" + }, + "link": 741 + } + ], + "outputs": [ + { + "localized_name": "output", + "name": "output", + "type": "STRING", + "links": [ + 791 + ] + } + ], + "properties": { + "Node name for S&R": "ComfySwitchNode" + }, + "widgets_values": [ + false + ], + "widgets_values_named": { + "switch": false + } + }, + { + "id": 485, + "type": "BatchImagesNode", + "pos": [ + -180, + -310 + ], + "size": [ + 230, + 270 + ], + "flags": {}, + "order": 13, + "mode": 0, + "inputs": [ + { + "localized_name": "image0", + "name": "images.image0", + "type": "IMAGE", + "link": 750 + }, + { + "localized_name": "image1", + "name": "images.image1", + "shape": 7, + "type": "IMAGE", + "link": 779 + }, + { + "localized_name": "image5", + "name": "images.image5", + "shape": 7, + "type": "IMAGE", + "link": 780 + }, + { + "localized_name": "image6", + "name": "images.image6", + "shape": 7, + "type": "IMAGE", + "link": 781 + }, + { + "localized_name": "image7", + "name": "images.image7", + "shape": 7, + "type": "IMAGE", + "link": 782 + }, + { + "localized_name": "image8", + "name": "images.image8", + "shape": 7, + "type": "IMAGE", + "link": 783 + }, + { + "localized_name": "image9", + "name": "images.image9", + "shape": 7, + "type": "IMAGE", + "link": 784 + }, + { + "localized_name": "image10", + "name": "images.image10", + "shape": 7, + "type": "IMAGE", + "link": 785 + }, + { + "localized_name": "image11", + "name": "images.image11", + "shape": 7, + "type": "IMAGE", + "link": 786 + }, + { + "localized_name": "image12", + "name": "images.image12", + "shape": 7, + "type": "IMAGE", + "link": 787 + }, + { + "localized_name": "image13", + "name": "images.image13", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "localized_name": "image2", + "name": "images.image2", + "shape": 7, + "type": "IMAGE", + "link": null + } + ], + "outputs": [ + { + "localized_name": "IMAGE", + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 801 + ] + } + ], + "properties": { + "Node name for S&R": "BatchImagesNode" + } + }, + { + "id": 500, + "type": "TextGenerate", + "pos": [ + 500, + -480 + ], + "size": [ + 400, + 460 + ], + "flags": {}, + "order": 14, + "mode": 0, + "showAdvanced": true, + "inputs": [ + { + "localized_name": "clip", + "name": "clip", + "type": "CLIP", + "link": 800 + }, + { + "localized_name": "image", + "name": "image", + "shape": 7, + "type": "IMAGE", + "link": 801 + }, + { + "localized_name": "video", + "name": "video", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "localized_name": "audio", + "name": "audio", + "shape": 7, + "type": "AUDIO", + "link": null + }, + { + "localized_name": "system_prompt", + "name": "system_prompt", + "shape": 7, + "type": "STRING", + "link": 901 + }, + { + "localized_name": "prompt", + "name": "prompt", + "type": "STRING", + "widget": { + "name": "prompt" + }, + "link": 802 + }, + { + "localized_name": "max_length", + "name": "max_length", + "type": "INT", + "widget": { + "name": "max_length" + }, + "link": 903 + }, + { + "localized_name": "seed", + "name": "sampling_mode.seed", + "type": "INT", + "widget": { + "name": "sampling_mode.seed" + }, + "link": 804 + }, + { + "localized_name": "thinking", + "name": "thinking", + "shape": 7, + "type": "BOOLEAN", + "widget": { + "name": "thinking" + }, + "link": 902 + } + ], + "outputs": [ + { + "localized_name": "generated_text", + "name": "generated_text", + "type": "STRING", + "links": [ + 806 + ] + }, + { + "localized_name": "thinking", + "name": "thinking", + "type": "STRING", + "links": null + } + ], + "properties": { + "Node name for S&R": "TextGenerate" + }, + "widgets_values": [ + "", + 4096, + "on", + 1, + 20, + 0.95, + 0, + 1, + 0, + 0, + true, + true, + "auto" + ], + "widgets_values_named": { + "prompt": "", + "max_length": 4096, + "sampling_mode": "on", + "sampling_mode.temperature": 1, + "sampling_mode.top_k": 20, + "sampling_mode.top_p": 0.95, + "sampling_mode.min_p": 0, + "sampling_mode.repetition_penalty": 1, + "sampling_mode.seed": 0, + "sampling_mode.presence_penalty": 0, + "thinking": true, + "use_default_template": true, + "mtp": "auto" + } + } + ], + "groups": [ + { + "id": 34, + "title": "Models", + "bounding": [ + -200, + 300, + 530, + 590 + ], + "color": "#3f789e", + "flags": {} + }, + { + "id": 35, + "title": "Image Size", + "bounding": [ + -200, + 920, + 530, + 250 + ], + "color": "#3f789e", + "flags": {} + }, + { + "id": 36, + "title": "Conditioning", + "bounding": [ + 360, + 300, + 700, + 860 + ], + "color": "#3f789e", + "flags": {} + }, + { + "id": 37, + "title": "Sampling", + "bounding": [ + 1090, + 300, + 470, + 860 + ], + "color": "#3f789e", + "flags": {} + }, + { + "id": 38, + "title": "Prompt Enhancer", + "bounding": [ + -200, + -560, + 1750, + 830 + ], + "color": "#3f789e", + "flags": {} + } + ], + "links": [ + { + "id": 649, + "origin_id": 454, + "origin_slot": 0, + "target_id": 457, + "target_slot": 1, + "type": "VAE" + }, + { + "id": 650, + "origin_id": 457, + "origin_slot": 0, + "target_id": -20, + "target_slot": 0, + "type": "IMAGE" + }, + { + "id": 651, + "origin_id": 458, + "origin_slot": 0, + "target_id": 457, + "target_slot": 0, + "type": "LATENT" + }, + { + "id": 682, + "origin_id": 468, + "origin_slot": 0, + "target_id": 458, + "target_slot": 3, + "type": "LATENT" + }, + { + "id": 684, + "origin_id": 456, + "origin_slot": 0, + "target_id": 468, + "target_slot": 1, + "type": "LATENT" + }, + { + "id": 688, + "origin_id": 451, + "origin_slot": 0, + "target_id": 469, + "target_slot": 0, + "type": "MODEL" + }, + { + "id": 689, + "origin_id": 469, + "origin_slot": 0, + "target_id": 458, + "target_slot": 0, + "type": "MODEL" + }, + { + "id": 722, + "origin_id": 474, + "origin_slot": 0, + "target_id": 458, + "target_slot": 1, + "type": "CONDITIONING" + }, + { + "id": 723, + "origin_id": 474, + "origin_slot": 1, + "target_id": 458, + "target_slot": 2, + "type": "CONDITIONING" + }, + { + "id": 724, + "origin_id": 474, + "origin_slot": 2, + "target_id": 468, + "target_slot": 0, + "type": "LATENT" + }, + { + "id": 791, + "origin_id": 484, + "origin_slot": 0, + "target_id": 480, + "target_slot": 0, + "type": "STRING" + }, + { + "id": 806, + "origin_id": 500, + "origin_slot": 0, + "target_id": 484, + "target_slot": 1, + "type": "STRING" + }, + { + "id": 739, + "origin_id": -10, + "origin_slot": 1, + "target_id": 484, + "target_slot": 0, + "type": "STRING" + }, + { + "id": 741, + "origin_id": -10, + "origin_slot": 2, + "target_id": 484, + "target_slot": 2, + "type": "BOOLEAN" + }, + { + "id": 658, + "origin_id": -10, + "origin_slot": 6, + "target_id": 458, + "target_slot": 6, + "type": "FLOAT" + }, + { + "id": 659, + "origin_id": -10, + "origin_slot": 7, + "target_id": 458, + "target_slot": 5, + "type": "INT" + }, + { + "id": 703, + "origin_id": -10, + "origin_slot": 8, + "target_id": 468, + "target_slot": 2, + "type": "BOOLEAN" + }, + { + "id": 660, + "origin_id": -10, + "origin_slot": 9, + "target_id": 456, + "target_slot": 0, + "type": "INT" + }, + { + "id": 661, + "origin_id": -10, + "origin_slot": 10, + "target_id": 456, + "target_slot": 1, + "type": "INT" + }, + { + "id": 662, + "origin_id": -10, + "origin_slot": 11, + "target_id": 458, + "target_slot": 7, + "type": "COMBO" + }, + { + "id": 668, + "origin_id": -10, + "origin_slot": 12, + "target_id": 458, + "target_slot": 8, + "type": "COMBO" + }, + { + "id": 667, + "origin_id": -10, + "origin_slot": 13, + "target_id": 458, + "target_slot": 4, + "type": "INT" + }, + { + "id": 663, + "origin_id": -10, + "origin_slot": 14, + "target_id": 451, + "target_slot": 0, + "type": "COMBO" + }, + { + "id": 664, + "origin_id": -10, + "origin_slot": 15, + "target_id": 453, + "target_slot": 0, + "type": "COMBO" + }, + { + "id": 665, + "origin_id": -10, + "origin_slot": 16, + "target_id": 454, + "target_slot": 0, + "type": "COMBO" + }, + { + "id": 729, + "origin_id": -10, + "origin_slot": 17, + "target_id": 469, + "target_slot": 1, + "type": "COMBO" + }, + { + "id": 730, + "origin_id": -10, + "origin_slot": 18, + "target_id": 469, + "target_slot": 2, + "type": "COMBO" + }, + { + "id": 746, + "origin_id": -10, + "origin_slot": 19, + "target_id": 477, + "target_slot": 0, + "type": "COMBO" + }, + { + "id": 721, + "origin_id": 453, + "origin_slot": 0, + "target_id": 474, + "target_slot": 0, + "type": "CLIP" + }, + { + "id": 710, + "origin_id": -10, + "origin_slot": 20, + "target_id": 474, + "target_slot": 1, + "type": "IMAGE" + }, + { + "id": 720, + "origin_id": 454, + "origin_slot": 0, + "target_id": 474, + "target_slot": 2, + "type": "VAE" + }, + { + "id": 743, + "origin_id": 480, + "origin_slot": 0, + "target_id": 474, + "target_slot": 3, + "type": "STRING" + }, + { + "id": 727, + "origin_id": -10, + "origin_slot": 5, + "target_id": 474, + "target_slot": 4, + "type": "STRING" + }, + { + "id": 725, + "origin_id": -10, + "origin_slot": 0, + "target_id": 474, + "target_slot": 5, + "type": "INT" + }, + { + "id": 716, + "origin_id": -10, + "origin_slot": 26, + "target_id": 474, + "target_slot": 7, + "type": "IMAGE" + }, + { + "id": 717, + "origin_id": -10, + "origin_slot": 27, + "target_id": 474, + "target_slot": 8, + "type": "IMAGE" + }, + { + "id": 718, + "origin_id": -10, + "origin_slot": 28, + "target_id": 474, + "target_slot": 9, + "type": "IMAGE" + }, + { + "id": 719, + "origin_id": -10, + "origin_slot": 29, + "target_id": 474, + "target_slot": 10, + "type": "IMAGE" + }, + { + "id": 711, + "origin_id": -10, + "origin_slot": 21, + "target_id": 474, + "target_slot": 12, + "type": "IMAGE" + }, + { + "id": 712, + "origin_id": -10, + "origin_slot": 22, + "target_id": 474, + "target_slot": 13, + "type": "IMAGE" + }, + { + "id": 713, + "origin_id": -10, + "origin_slot": 23, + "target_id": 474, + "target_slot": 14, + "type": "IMAGE" + }, + { + "id": 714, + "origin_id": -10, + "origin_slot": 24, + "target_id": 474, + "target_slot": 15, + "type": "IMAGE" + }, + { + "id": 715, + "origin_id": -10, + "origin_slot": 25, + "target_id": 474, + "target_slot": 16, + "type": "IMAGE" + }, + { + "id": 750, + "origin_id": -10, + "origin_slot": 20, + "target_id": 485, + "target_slot": 0, + "type": "IMAGE" + }, + { + "id": 779, + "origin_id": -10, + "origin_slot": 21, + "target_id": 485, + "target_slot": 1, + "type": "IMAGE" + }, + { + "id": 780, + "origin_id": -10, + "origin_slot": 22, + "target_id": 485, + "target_slot": 2, + "type": "IMAGE" + }, + { + "id": 781, + "origin_id": -10, + "origin_slot": 23, + "target_id": 485, + "target_slot": 3, + "type": "IMAGE" + }, + { + "id": 782, + "origin_id": -10, + "origin_slot": 24, + "target_id": 485, + "target_slot": 4, + "type": "IMAGE" + }, + { + "id": 783, + "origin_id": -10, + "origin_slot": 25, + "target_id": 485, + "target_slot": 5, + "type": "IMAGE" + }, + { + "id": 784, + "origin_id": -10, + "origin_slot": 26, + "target_id": 485, + "target_slot": 6, + "type": "IMAGE" + }, + { + "id": 785, + "origin_id": -10, + "origin_slot": 27, + "target_id": 485, + "target_slot": 7, + "type": "IMAGE" + }, + { + "id": 786, + "origin_id": -10, + "origin_slot": 28, + "target_id": 485, + "target_slot": 8, + "type": "IMAGE" + }, + { + "id": 787, + "origin_id": -10, + "origin_slot": 29, + "target_id": 485, + "target_slot": 9, + "type": "IMAGE" + }, + { + "id": 800, + "origin_id": 477, + "origin_slot": 0, + "target_id": 500, + "target_slot": 0, + "type": "CLIP" + }, + { + "id": 801, + "origin_id": 485, + "origin_slot": 0, + "target_id": 500, + "target_slot": 1, + "type": "IMAGE" + }, + { + "id": 901, + "origin_id": 479, + "origin_slot": 0, + "target_id": 500, + "target_slot": 4, + "type": "STRING" + }, + { + "id": 802, + "origin_id": -10, + "origin_slot": 1, + "target_id": 500, + "target_slot": 5, + "type": "STRING" + }, + { + "id": 903, + "origin_id": -10, + "origin_slot": 4, + "target_id": 500, + "target_slot": 6, + "type": "INT" + }, + { + "id": 902, + "origin_id": -10, + "origin_slot": 3, + "target_id": 500, + "target_slot": 8, + "type": "BOOLEAN" + }, + { + "id": 804, + "origin_id": -10, + "origin_slot": 13, + "target_id": 500, + "target_slot": 7, + "type": "INT" + } + ], + "extra": {} + } + ] + }, + "config": {}, + "extra": { + "frontendVersion": "1.53.6", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true, + "ds": { + "scale": 0.6940244165782402, + "offset": [ + 973.3086639020673, + -1999.8825382096318 + ] + } + }, + "version": 0.4 +} \ No newline at end of file diff --git a/tests/comfy_cli/fixtures/object_info_subgraph_promoted.json b/tests/comfy_cli/fixtures/object_info_subgraph_promoted.json index 14f7efd15..faec44039 100644 --- a/tests/comfy_cli/fixtures/object_info_subgraph_promoted.json +++ b/tests/comfy_cli/fixtures/object_info_subgraph_promoted.json @@ -3475,5 +3475,853 @@ "essentials_category": "Video Tools", "has_intermediate_output": false, "description": "" + }, + "EmptyLatentImage": { + "input": { + "required": { + "width": [ + "INT", + { + "default": 1024, + "min": 16, + "max": 16384, + "step": 8 + } + ], + "height": [ + "INT", + { + "default": 1024, + "min": 16, + "max": 16384, + "step": 8 + } + ], + "batch_size": [ + "INT", + { + "default": 1, + "min": 1, + "max": 4096 + } + ] + } + }, + "input_order": { + "required": [ + "width", + "height", + "batch_size" + ] + }, + "is_input_list": false, + "output": [ + "LATENT" + ], + "output_is_list": [ + false + ], + "output_name": [ + "LATENT" + ], + "name": "EmptyLatentImage", + "display_name": "Empty Latent Image", + "description": "Create a new batch of empty latent images to be denoised via sampling.", + "python_module": "nodes", + "category": "model/latent", + "output_node": false, + "has_intermediate_output": false, + "output_tooltips": [ + "The empty latent image batch." + ], + "search_aliases": [ + "empty", + "empty latent", + "new latent", + "create latent", + "blank latent", + "blank" + ] + }, + "ImageCompare": { + "input": { + "required": { + "compare_view": [ + "IMAGECOMPARE", + { + "socketless": true + } + ] + }, + "optional": { + "image_a": [ + "IMAGE", + {} + ], + "image_b": [ + "IMAGE", + {} + ] + }, + "hidden": { + "prompt": [ + "PROMPT" + ], + "extra_pnginfo": [ + "EXTRA_PNGINFO" + ] + } + }, + "input_order": { + "required": [ + "compare_view" + ], + "optional": [ + "image_a", + "image_b" + ], + "hidden": [ + "prompt", + "extra_pnginfo" + ] + }, + "is_input_list": false, + "output": [], + "output_is_list": [], + "output_name": [], + "output_tooltips": [], + "output_matchtypes": null, + "name": "ImageCompare", + "display_name": "Compare Images", + "description": "Compares two images side by side with a slider.", + "python_module": "comfy_extras.nodes_image_compare", + "category": "image", + "output_node": true, + "deprecated": false, + "experimental": false, + "dev_only": false, + "api_node": false, + "price_badge": null, + "search_aliases": null, + "essentials_category": "Image Tools", + "has_intermediate_output": false + }, + "LoadImage": { + "input": { + "required": { + "image": [ + [ + "clothing_light_blue_denim_shirt.png", + "portrait_model_denim.png" + ], + { + "image_upload": true + } + ] + } + }, + "input_order": { + "required": [ + "image" + ] + }, + "is_input_list": false, + "output": [ + "IMAGE", + "MASK" + ], + "output_is_list": [ + false, + false + ], + "output_name": [ + "IMAGE", + "MASK" + ], + "name": "LoadImage", + "display_name": "Load Image", + "description": "", + "python_module": "nodes", + "category": "image", + "output_node": false, + "has_intermediate_output": false, + "search_aliases": [ + "load image", + "open image", + "import image", + "image input", + "upload image", + "read image", + "image loader" + ], + "essentials_category": "Basics" + }, + "PreviewAny": { + "input": { + "required": { + "source": [ + "*", + {} + ] + } + }, + "input_order": { + "required": [ + "source" + ] + }, + "is_input_list": false, + "output": [ + "STRING" + ], + "output_is_list": [ + false + ], + "output_name": [ + "STRING" + ], + "name": "PreviewAny", + "display_name": "Preview as Text", + "description": "Preview any input value as text.", + "python_module": "comfy_extras.nodes_preview_any", + "category": "utilities", + "output_node": true, + "has_intermediate_output": false, + "search_aliases": [ + "preview", + "preview text", + "show output", + "inspect", + "debug", + "print value", + "show text" + ] + }, + "QwenImage21Cache": { + "input": { + "required": { + "model": [ + "MODEL", + {} + ], + "device": [ + "COMBO", + { + "default": "auto", + "multiselect": false, + "options": [ + "auto", + "gpu", + "cpu", + "off" + ] + } + ], + "dtype": [ + "COMBO", + { + "default": "default", + "multiselect": false, + "options": [ + "default", + "int8", + "int4" + ] + } + ] + } + }, + "input_order": { + "required": [ + "model", + "device", + "dtype" + ] + }, + "is_input_list": false, + "output": [ + "MODEL" + ], + "output_is_list": [ + false + ], + "output_name": [ + "MODEL" + ], + "output_tooltips": [ + null + ], + "output_matchtypes": null, + "name": "QwenImage21Cache", + "display_name": "Qwen Image 2.1 Cache", + "description": "Allows setting the KV cache device and quantization, by default the model uses the auto -option. Quantization potentially speeds up edit workflows when memory starved ", + "python_module": "comfy_extras.nodes_qwen", + "category": "model/conditioning/qwen image", + "output_node": false, + "deprecated": false, + "experimental": true, + "dev_only": false, + "api_node": false, + "price_badge": null, + "search_aliases": null, + "essentials_category": null, + "has_intermediate_output": false + }, + "SaveImageAdvanced": { + "input": { + "required": { + "images": [ + "IMAGE", + {} + ], + "filename_prefix": [ + "STRING", + { + "default": "ComfyUI", + "multiline": false + } + ], + "format": [ + "COMFY_DYNAMICCOMBO_V3", + { + "options": [ + { + "key": "png", + "inputs": { + "required": { + "bit_depth": [ + "COMBO", + { + "advanced": true, + "default": "8-bit", + "multiselect": false, + "options": [ + "8-bit", + "16-bit" + ] + } + ], + "input_color_space": [ + "COMBO", + { + "advanced": true, + "default": "sRGB", + "multiselect": false, + "options": [ + "sRGB" + ] + } + ] + } + } + }, + { + "key": "exr", + "inputs": { + "required": { + "bit_depth": [ + "COMBO", + { + "advanced": true, + "default": "16-bit float", + "multiselect": false, + "options": [ + "32-bit float", + "16-bit float" + ] + } + ], + "input_color_space": [ + "COMBO", + { + "advanced": true, + "default": "sRGB", + "multiselect": false, + "options": [ + "sRGB", + "HDR", + "linear", + "linear ACEScg" + ] + } + ] + } + } + }, + { + "key": "avif", + "inputs": { + "required": { + "bit_depth": [ + "COMBO", + { + "advanced": true, + "default": "auto", + "multiselect": false, + "options": [ + "auto", + "8-bit YUV420", + "10-bit YUV420" + ] + } + ], + "input_color_space": [ + "COMBO", + { + "advanced": true, + "default": "sRGB", + "multiselect": false, + "options": [ + "sRGB", + "HDR", + "HDR PQ" + ] + } + ], + "crf": [ + "INT", + { + "advanced": true, + "default": 18, + "min": 1, + "max": 63 + } + ], + "save_mode": [ + "COMFY_DYNAMICCOMBO_V3", + { + "display_name": "save mode", + "options": [ + { + "key": "still images", + "inputs": { + "required": {} + } + }, + { + "key": "animated", + "inputs": { + "required": { + "fps": [ + "FLOAT", + { + "default": 6.0, + "min": 0.01, + "max": 1000.0, + "step": 0.01 + } + ], + "loop_count": [ + "INT", + { + "advanced": true, + "default": 0, + "min": 0, + "max": 1000 + } + ] + } + } + } + ] + } + ] + } + } + } + ] + } + ] + }, + "hidden": { + "prompt": [ + "PROMPT" + ], + "extra_pnginfo": [ + "EXTRA_PNGINFO" + ] + } + }, + "input_order": { + "required": [ + "images", + "filename_prefix", + "format" + ], + "hidden": [ + "prompt", + "extra_pnginfo" + ] + }, + "is_input_list": false, + "output": [ + "IMAGE" + ], + "output_is_list": [ + false + ], + "output_name": [ + "images" + ], + "output_tooltips": [ + null + ], + "output_matchtypes": null, + "name": "SaveImageAdvanced", + "display_name": "Save Image (Advanced)", + "description": "Saves the input images to your ComfyUI output directory.", + "python_module": "comfy_extras.nodes_images", + "category": "image", + "output_node": true, + "deprecated": false, + "experimental": false, + "dev_only": false, + "api_node": false, + "price_badge": null, + "search_aliases": [ + "save", + "save image", + "export image", + "output image", + "write image" + ], + "essentials_category": "Basics", + "has_intermediate_output": false + }, + "TextEncodeQwenImage21": { + "input": { + "required": { + "clip": [ + "CLIP", + {} + ], + "prompt": [ + "STRING", + { + "multiline": true, + "dynamicPrompts": true + } + ], + "negative_prompt": [ + "STRING", + { + "multiline": true, + "dynamicPrompts": true + } + ], + "resolution": [ + "INT", + { + "default": 1024, + "min": 0, + "max": 4096, + "step": 32 + } + ], + "images": [ + "COMFY_AUTOGROW_V3", + { + "template": { + "input": { + "required": { + "image": [ + "IMAGE", + {} + ] + } + }, + "names": [ + "image_1", + "image_2", + "image_3", + "image_4", + "image_5", + "image_6", + "image_7", + "image_8", + "image_9", + "image_10", + "image_11", + "image_12", + "image_13", + "image_14", + "image_15", + "image_16" + ], + "min": 0 + } + } + ] + }, + "optional": { + "vae": [ + "VAE", + {} + ] + } + }, + "input_order": { + "required": [ + "clip", + "prompt", + "negative_prompt", + "resolution", + "images" + ], + "optional": [ + "vae" + ] + }, + "is_input_list": false, + "output": [ + "CONDITIONING", + "CONDITIONING", + "LATENT" + ], + "output_is_list": [ + false, + false, + false + ], + "output_name": [ + "positive", + "negative", + "latent" + ], + "output_tooltips": [ + null, + null, + "Empty latent on the first reference image's size, to match with sampling as any other size shifts the edit." + ], + "output_matchtypes": null, + "name": "TextEncodeQwenImage21", + "display_name": "Text Encode Qwen Image 2.1", + "description": "", + "python_module": "comfy_extras.nodes_qwen", + "category": "model/conditioning/qwen image", + "output_node": false, + "deprecated": false, + "experimental": false, + "dev_only": false, + "api_node": false, + "price_badge": null, + "search_aliases": null, + "essentials_category": null, + "has_intermediate_output": false + }, + "TextGenerate": { + "input": { + "required": { + "clip": [ + "CLIP", + {} + ], + "prompt": [ + "STRING", + { + "default": "", + "multiline": true, + "dynamicPrompts": true + } + ], + "max_length": [ + "INT", + { + "default": 512, + "min": 1, + "max": 32768 + } + ], + "sampling_mode": [ + "COMFY_DYNAMICCOMBO_V3", + { + "display_name": "Sampling Mode", + "options": [ + { + "key": "on", + "inputs": { + "required": { + "temperature": [ + "FLOAT", + { + "default": 0.7, + "min": 0.01, + "max": 2.0, + "step": 1e-06 + } + ], + "top_k": [ + "INT", + { + "default": 64, + "min": 0, + "max": 1000 + } + ], + "top_p": [ + "FLOAT", + { + "default": 0.95, + "min": 0.0, + "max": 1.0, + "step": 0.01 + } + ], + "min_p": [ + "FLOAT", + { + "default": 0.05, + "min": 0.0, + "max": 1.0, + "step": 0.01 + } + ], + "repetition_penalty": [ + "FLOAT", + { + "default": 1.05, + "min": 0.0, + "max": 5.0, + "step": 0.01 + } + ], + "seed": [ + "INT", + { + "default": 0, + "min": 0, + "max": 18446744073709551615 + } + ] + }, + "optional": { + "presence_penalty": [ + "FLOAT", + { + "default": 0.0, + "min": 0.0, + "max": 5.0, + "step": 0.01 + } + ] + } + } + }, + { + "key": "off", + "inputs": { + "required": {} + } + } + ] + } + ] + }, + "optional": { + "image": [ + "IMAGE", + {} + ], + "video": [ + "IMAGE", + {} + ], + "audio": [ + "AUDIO", + {} + ], + "thinking": [ + "BOOLEAN", + { + "default": false + } + ], + "use_default_template": [ + "BOOLEAN", + { + "advanced": true, + "default": true + } + ], + "mtp": [ + "COMBO", + { + "default": "auto", + "multiselect": false, + "options": [ + "auto", + "off", + "2", + "3", + "4", + "5", + "tree2s1", + "tree2s2", + "tree3s1", + "tree4s1m8" + ] + } + ], + "system_prompt": [ + "STRING", + { + "forceInput": true, + "multiline": false + } + ] + } + }, + "input_order": { + "required": [ + "clip", + "prompt", + "max_length", + "sampling_mode" + ], + "optional": [ + "image", + "video", + "audio", + "thinking", + "use_default_template", + "mtp", + "system_prompt" + ] + }, + "is_input_list": false, + "output": [ + "STRING", + "STRING" + ], + "output_is_list": [ + false, + false + ], + "output_name": [ + "generated_text", + "thinking" + ], + "output_tooltips": [ + null, + null + ], + "output_matchtypes": null, + "name": "TextGenerate", + "display_name": "Generate Text", + "description": "", + "python_module": "comfy_extras.nodes_textgen", + "category": "text", + "output_node": false, + "deprecated": false, + "experimental": false, + "dev_only": false, + "api_node": false, + "price_badge": null, + "search_aliases": [ + "LLM", + "gemma" + ], + "essentials_category": null, + "has_intermediate_output": false } } \ No newline at end of file diff --git a/tests/comfy_cli/test_workflow_to_api_promoted.py b/tests/comfy_cli/test_workflow_to_api_promoted.py index c3a2cee55..ee8396b90 100644 --- a/tests/comfy_cli/test_workflow_to_api_promoted.py +++ b/tests/comfy_cli/test_workflow_to_api_promoted.py @@ -992,7 +992,7 @@ def test_promoted_overlay_budget_charges_cached_boundary_targets(monkeypatch): item = promoted.PromotedInput("value", "STRING", index=0, value_index=0) monkeypatch.setattr(workflow_to_api, "_MAX_SUBGRAPH_EXPANSION_BUDGET", 4) monkeypatch.setattr(promoted, "promoted_inputs", lambda *_args: [item]) - monkeypatch.setattr(promoted, "boundary_widget_targets", lambda *_args: [([str(i)], "value") for i in range(3)]) + monkeypatch.setattr(promoted, "boundary_targets", lambda *_args: [([str(i)], "value") for i in range(3)]) with pytest.raises(workflow_to_api.WorkflowConversionError, match="promoted-value overlay exceeded"): workflow_to_api._overlay_promoted_host_values({}, workflow, {definition_id: definition}) @@ -1012,7 +1012,7 @@ def test_promoted_overlay_treats_ordinary_interior_link_as_live(monkeypatch): prompt = {"1:leaf": {"inputs": {"value": "interior"}}} item = promoted.PromotedInput("value", "STRING", index=0, value_index=0) monkeypatch.setattr(promoted, "promoted_inputs", lambda *_args: [item]) - monkeypatch.setattr(promoted, "boundary_widget_targets", lambda *_args: [(["leaf"], "value")]) + monkeypatch.setattr(promoted, "boundary_targets", lambda *_args: [(["leaf"], "value")]) workflow_to_api._overlay_promoted_host_values(prompt, workflow, {definition_id: definition}) @@ -1038,7 +1038,7 @@ def test_promoted_overlay_uses_expansion_slot_mapping_for_liveness(monkeypatch): prompt = {"1:leaf": {"inputs": {"value": "interior"}}} item = promoted.PromotedInput("7", "STRING", index=0, value_index=0) monkeypatch.setattr(promoted, "promoted_inputs", lambda *_args: [item]) - monkeypatch.setattr(promoted, "boundary_widget_targets", lambda *_args: [(["leaf"], "value")]) + monkeypatch.setattr(promoted, "boundary_targets", lambda *_args: [(["leaf"], "value")]) workflow_to_api._overlay_promoted_host_values(prompt, workflow, {definition_id: definition}) @@ -1064,7 +1064,7 @@ def test_promoted_overlay_prefers_a_live_duplicate_mapped_slot(monkeypatch): prompt = {"1:leaf": {"inputs": {"value": "live external value"}}} item = promoted.PromotedInput("value", "STRING", index=0, value_index=0) monkeypatch.setattr(promoted, "promoted_inputs", lambda *_args: [item]) - monkeypatch.setattr(promoted, "boundary_widget_targets", lambda *_args: [(["leaf"], "value")]) + monkeypatch.setattr(promoted, "boundary_targets", lambda *_args: [(["leaf"], "value")]) workflow_to_api._overlay_promoted_host_values(prompt, workflow, {definition_id: definition}) @@ -1096,7 +1096,7 @@ def test_nested_overlay_keeps_a_uniquely_listed_input_proxy_value(monkeypatch): prompt = {"1:nested:leaf": {"inputs": {"value": "external value"}}} item = promoted.PromotedInput("value", "STRING", index=0, value_index=0) monkeypatch.setattr(promoted, "promoted_inputs", lambda sg, *_args: [item] if sg is child else []) - monkeypatch.setattr(promoted, "boundary_widget_targets", lambda *_args: [(["leaf"], "value")]) + monkeypatch.setattr(promoted, "boundary_targets", lambda *_args: [(["leaf"], "value")]) workflow_to_api._overlay_promoted_host_values(prompt, workflow, {parent_id: parent, child_id: child}) @@ -1114,7 +1114,7 @@ def test_promoted_overlay_ignores_unhashable_link_ids(monkeypatch): } item = promoted.PromotedInput("value", "STRING", index=0, value_index=0) monkeypatch.setattr(promoted, "promoted_inputs", lambda *_args: [item]) - monkeypatch.setattr(promoted, "boundary_widget_targets", lambda *_args: []) + monkeypatch.setattr(promoted, "boundary_targets", lambda *_args: []) workflow_to_api._overlay_promoted_host_values({}, workflow, {definition_id: definition}) @@ -1133,7 +1133,7 @@ def test_promoted_overlay_ignores_incomplete_interior_link_rows(monkeypatch): prompt = {"1:leaf": {"inputs": {"value": "interior"}}} item = promoted.PromotedInput("value", "STRING", index=0, value_index=0) monkeypatch.setattr(promoted, "promoted_inputs", lambda *_args: [item]) - monkeypatch.setattr(promoted, "boundary_widget_targets", lambda *_args: [(["leaf"], "value")]) + monkeypatch.setattr(promoted, "boundary_targets", lambda *_args: [(["leaf"], "value")]) workflow_to_api._overlay_promoted_host_values(prompt, workflow, {definition_id: definition}) @@ -1292,7 +1292,7 @@ def test_promoted_overlay_caches_live_links_for_sibling_instances(monkeypatch): } item = promoted.PromotedInput("value", "STRING", index=0, value_index=0) monkeypatch.setattr(promoted, "promoted_inputs", lambda *_args: [item]) - monkeypatch.setattr(promoted, "boundary_widget_targets", lambda *_args: []) + monkeypatch.setattr(promoted, "boundary_targets", lambda *_args: []) with mock.patch.object(promoted, "_live_link_keys", wraps=promoted._live_link_keys) as live_keys: workflow_to_api._overlay_promoted_host_values({}, workflow, {definition_id: definition}) @@ -1364,3 +1364,225 @@ def test_promotion_traversal_limit_is_a_structured_conversion_failure(object_inf pytest.raises(workflow_to_api.WorkflowConversionError, match="promoted input traversal exceeded"), ): convert_ui_to_api(_load("audio_minimax_music_3.json"), object_info) + + +def test_qwen_image_2_1_edit_prompt_reaches_the_switch_socket(object_info): + """The template's ``prompt`` input feeds both TextGenerate's ``prompt`` + widget and a ``ComfySwitchNode``'s any-type ``on_false`` socket, the branch + the switch takes while the prompt enhancer is off. The frontend inlines the + host value into both; dropping the socket made the switch yield ``None`` and + the image encoder encode the string "None".""" + api = convert_ui_to_api(_load("image_qwen_image_2_1_image_edit.json"), object_info) + prompt = _api_node(api, "TextGenerate", "459:500")["inputs"]["prompt"] + switch = _api_node(api, "ComfySwitchNode", "459:484")["inputs"] + assert prompt == "Replace costumes for the character" + assert switch["on_false"] == prompt + assert switch["on_true"] == ["459:500", 0] + + +_SOCKET_SG = "11111111-2222-4333-8444-555555555555" + + +def _prompt_to_widget_and_socket(sg_id: str = _SOCKET_SG) -> dict: + return { + "id": sg_id, + "inputs": [{"name": "prompt", "type": "STRING", "linkIds": [1, 2]}], + "nodes": [ + { + "id": "text", + "type": "PrimitiveStringMultiline", + "inputs": [{"name": "value", "type": "STRING", "link": 1, "widget": {"name": "value"}}], + "widgets_values": ["interior default"], + }, + { + "id": "switch", + "type": "ComfySwitchNode", + "inputs": [{"name": "on_false", "type": "*", "link": 2}], + }, + ], + "links": [ + {"id": 1, "origin_id": -10, "origin_slot": 0, "target_id": "text", "target_slot": 0}, + {"id": 2, "origin_id": -10, "origin_slot": 0, "target_id": "switch", "target_slot": 0}, + ], + } + + +def _nested_outer(inner_values: list | None = None) -> tuple[str, dict]: + outer_id = "66666666-7777-4888-8999-000000000000" + inner = {"id": "inner", "type": _SOCKET_SG, "inputs": [{"name": "prompt", "link": 99}]} + if inner_values is not None: + inner["widgets_values"] = inner_values + return outer_id, { + "id": outer_id, + "inputs": [{"name": "prompt", "type": "STRING", "linkIds": [99]}], + "nodes": [inner], + "links": [{"id": 99, "origin_id": -10, "origin_slot": 0, "target_id": "inner", "target_slot": 0}], + } + + +def _socket_api(prefix: str) -> dict: + return { + f"{prefix}:text": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "interior default"}}, + f"{prefix}:switch": {"class_type": "ComfySwitchNode", "inputs": {"switch": False}}, + } + + +def test_host_value_reaches_a_non_widget_socket_the_input_feeds(): + workflow = { + "nodes": [ + {"id": 9, "type": _SOCKET_SG, "inputs": [{"name": "prompt", "link": None}], "widgets_values": ["host"]} + ], + "links": [], + } + api = _socket_api("9") + + workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: _prompt_to_widget_and_socket()}) + + assert api["9:text"]["inputs"]["value"] == "host" + assert api["9:switch"]["inputs"]["on_false"] == "host" + + +def test_host_value_reaches_a_socket_through_a_nested_instance(): + outer_id, outer = _nested_outer() + workflow = {"nodes": [{"id": 9, "type": outer_id, "widgets_values": ["outer host"]}], "links": []} + api = _socket_api("9:inner") + + workflow_to_api._overlay_promoted_host_values( + api, workflow, {outer_id: outer, _SOCKET_SG: _prompt_to_widget_and_socket()} + ) + + assert api["9:inner:switch"]["inputs"]["on_false"] == "outer host" + + +def test_socket_only_input_gets_no_host_value(): + """An input that feeds no widget has no host widget in the frontend, so + nothing is inlined into its socket; a stray host value stays unused.""" + sg = _prompt_to_widget_and_socket() + sg["inputs"][0]["linkIds"] = [2] + sg["links"] = [link for link in sg["links"] if link["id"] == 2] + sg["nodes"][0]["inputs"][0]["link"] = None + workflow = {"nodes": [{"id": 9, "type": _SOCKET_SG, "widgets_values": ["stray"]}], "links": []} + api = _socket_api("9") + + workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: sg}) + + assert "on_false" not in api["9:switch"]["inputs"] + + +def test_external_link_into_the_input_leaves_the_socket_to_expansion(object_info): + wf = _load("image_qwen_image_2_1_image_edit.json") + inst = next(n for n in wf["nodes"] if n["id"] == 459) + slot = next(i for i, entry in enumerate(inst["inputs"]) if entry.get("name") == "prompt") + wf["nodes"].append( + { + "id": 900, + "type": "PrimitiveStringMultiline", + "outputs": [{"name": "STRING", "type": "STRING", "links": [9000]}], + "inputs": [], + "widgets_values": ["wired prompt"], + "mode": 0, + } + ) + inst["inputs"][slot]["link"] = 9000 + wf["links"].append([9000, 900, 0, 459, slot, "STRING"]) + + api = convert_ui_to_api(wf, object_info) + + assert _api_node(api, "ComfySwitchNode", "459:484")["inputs"]["on_false"] == ["900", 0] + assert _api_node(api, "TextGenerate", "459:500")["inputs"]["prompt"] == ["900", 0] + + +def test_unset_host_value_feeds_the_socket_the_interior_source_value(object_info): + """With no host value the frontend seeds the promoted widget from its + interior source widget and inlines that into every target, so the switch + socket gets TextGenerate's interior prompt rather than nothing.""" + wf = _load("image_qwen_image_2_1_image_edit.json") + next(n for n in wf["nodes"] if n["id"] == 459)["widgets_values"] = [] + sg = wf["definitions"]["subgraphs"][0] + interior = next(n for n in sg["nodes"] if n["id"] == 500) + interior["widgets_values"][0] = "interior prompt" + + api = convert_ui_to_api(wf, object_info) + + assert _api_node(api, "TextGenerate", "459:500")["inputs"]["prompt"] == "interior prompt" + assert _api_node(api, "ComfySwitchNode", "459:484")["inputs"]["on_false"] == "interior prompt" + + +def test_unset_host_value_feeds_every_target_the_source_value(): + """The frontend inlines the one seeded value into every target, so a second + interior widget takes the source widget's value, not its own default.""" + sg = _prompt_to_widget_and_socket() + sg["nodes"].append( + { + "id": "other", + "type": "PrimitiveStringMultiline", + "inputs": [{"name": "value", "type": "STRING", "link": 3, "widget": {"name": "value"}}], + } + ) + sg["inputs"][0]["linkIds"].append(3) + sg["links"].append({"id": 3, "origin_id": -10, "origin_slot": 0, "target_id": "other", "target_slot": 0}) + workflow = {"nodes": [{"id": 9, "type": _SOCKET_SG, "widgets_values": []}], "links": []} + api = _socket_api("9") + api["9:other"] = {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "other default"}} + + workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: sg}) + + assert api["9:text"]["inputs"]["value"] == "interior default" + assert api["9:switch"]["inputs"]["on_false"] == "interior default" + assert api["9:other"]["inputs"]["value"] == "interior default" + + +def test_unset_host_value_reaches_a_socket_through_a_nested_instance(): + outer_id, outer = _nested_outer() + workflow = {"nodes": [{"id": 9, "type": outer_id}], "links": []} + api = _socket_api("9:inner") + + workflow_to_api._overlay_promoted_host_values( + api, workflow, {outer_id: outer, _SOCKET_SG: _prompt_to_widget_and_socket()} + ) + + assert api["9:inner:switch"]["inputs"]["on_false"] == "interior default" + + +def test_known_divergence_unemitted_source_leaves_the_socket_empty(): + """Known divergence: the frontend still seeds from a muted source widget, + but the converter reads the seed from the emitted prompt, so a muted source + leaves the socket empty.""" + workflow = {"nodes": [{"id": 9, "type": _SOCKET_SG}], "links": []} + api = _socket_api("9") + del api["9:text"] + + workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: _prompt_to_widget_and_socket()}) + + assert "on_false" not in api["9:switch"]["inputs"] + + +def test_unset_outer_value_seeds_from_the_concrete_widget_not_the_inner_host(): + """The frontend seeds a nested promotion from the deepest concrete widget; + an inner instance's own host value is linked over from the outer input.""" + outer_id, outer = _nested_outer(inner_values=["inner host"]) + workflow = {"nodes": [{"id": 9, "type": outer_id}], "links": []} + api = _socket_api("9:inner") + + workflow_to_api._overlay_promoted_host_values( + api, workflow, {outer_id: outer, _SOCKET_SG: _prompt_to_widget_and_socket()} + ) + + assert api["9:inner:text"]["inputs"]["value"] == "interior default" + assert api["9:inner:switch"]["inputs"]["on_false"] == "interior default" + + +def test_unset_host_value_with_the_source_widget_not_emitted_leaves_the_socket_empty(): + workflow = {"nodes": [{"id": 9, "type": _SOCKET_SG}], "links": []} + api = _socket_api("9") + api["9:text"]["inputs"] = {} + + workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: _prompt_to_widget_and_socket()}) + + assert "on_false" not in api["9:switch"]["inputs"] + + +def test_source_widget_value_without_a_source_is_unset(): + from comfy_cli.cql import promoted + + assert workflow_to_api._source_widget_value({"9:text": {"inputs": {"value": "x"}}}, "9", None) is promoted.UNSET From 076864c1b46dd0b5a3852b70aa8551fc0d583d17 Mon Sep 17 00:00:00 2001 From: Simon Pinfold Date: Wed, 4 Nov 2026 16:42:21 -0800 Subject: [PATCH 2/7] chore: comment cleanup Comment-Gate: 13 quarantined --- comfy_cli/cql/promoted.py | 9 ++------- comfy_cli/workflow_to_api.py | 11 +---------- tests/comfy_cli/cql/test_promoted_inputs.py | 1 - .../comfy_cli/test_workflow_to_api_promoted.py | 17 ----------------- 4 files changed, 3 insertions(+), 35 deletions(-) diff --git a/comfy_cli/cql/promoted.py b/comfy_cli/cql/promoted.py index 3e4ca1368..616f5489b 100644 --- a/comfy_cli/cql/promoted.py +++ b/comfy_cli/cql/promoted.py @@ -2187,10 +2187,7 @@ def flush_proxy_migration( def boundary_targets(sg: dict, pi: PromotedInput, defs: dict[str, dict]) -> list[tuple[list[str], str]]: - """Every concrete ``(interior node path, input)`` a promoted input feeds — - widgets and plain sockets alike, all of its boundary links, through nested - instances. A repaired primitive fan-out has several; :func:`deepest_source` - reports only the first.""" + """Every ``(interior node path, input)`` the input's boundary links reach, sockets included.""" cache = getattr(defs, "promotion_boundaries", None) cache_key = (id(sg), pi.index) raw_inputs = sg.get("inputs") @@ -2369,9 +2366,7 @@ def _boundary_targets( ) out.extend(([tid, *path], widget) for path, widget in nested) continue - # A socket without a widget marker (a switch's any-type input) is a - # target too: the frontend inlines the host value into whatever - # input the boundary link reaches (``ExecutableNodeDTO.resolveInput``). + # Unmarked sockets count too: the frontend inlines into any input the link reaches (resolveInput). marker = entry.get("widget") widget = marker.get("name") if isinstance(marker, dict) else None name = widget or entry.get("name") diff --git a/comfy_cli/workflow_to_api.py b/comfy_cli/workflow_to_api.py index 30e5304ce..feff7ecaa 100644 --- a/comfy_cli/workflow_to_api.py +++ b/comfy_cli/workflow_to_api.py @@ -291,19 +291,12 @@ def is_live(link_id: Any) -> bool: continue value = _promoted.host_value(instance, pi) if value is _promoted.UNSET: - # No host value: the frontend seeds the host widget from its - # interior source widget and inlines that value into every - # target, as emitted above (already wrapped). + # No host value: the frontend seeds the promoted widget from its interior source widget. value = _source_widget_value(api_prompt, prefix, _promoted.deepest_source(sg, pi, subgraph_defs)) if value is _promoted.UNSET: continue else: - # Same wrapping every widget value gets, so a two-item list - # host value is never read back as a ``[node, slot]`` link. value = _wrap_widget_value(value) - # Every interior input the boundary link feeds, widget or socket - # (the frontend inlines the host value into both) — a repaired - # primitive fan-out links one host value into several targets. targets = _promoted.boundary_targets(sg, pi, subgraph_defs) if len(targets) > visit_budget[0]: raise WorkflowConversionError("promoted-value overlay exceeded its safe limit") @@ -328,8 +321,6 @@ def is_live(link_id: Any) -> bool: def _source_widget_value(api_prompt: dict, prefix: str, source: tuple[list[str], str] | None) -> Any: - """The emitted value of a promoted input's interior source widget, or - ``UNSET`` when that node was not emitted.""" from comfy_cli.cql import promoted as _promoted if source is None: diff --git a/tests/comfy_cli/cql/test_promoted_inputs.py b/tests/comfy_cli/cql/test_promoted_inputs.py index 06b4de049..ee2a214b1 100644 --- a/tests/comfy_cli/cql/test_promoted_inputs.py +++ b/tests/comfy_cli/cql/test_promoted_inputs.py @@ -440,7 +440,6 @@ def test_socket_targets_count_against_the_boundary_output_cap(): definitions = {"sg": sg} assert len(promoted._boundary_targets(sg, sg["inputs"][0], definitions, 0, _output_budget=[2])) == 2 - # Two targets, room for one: the socket must be charged like the widget. with pytest.raises(promoted.PromotionTraversalLimitError, match="boundary traversal"): promoted._boundary_targets(sg, sg["inputs"][0], {"sg": sg}, 0, _output_budget=[1]) diff --git a/tests/comfy_cli/test_workflow_to_api_promoted.py b/tests/comfy_cli/test_workflow_to_api_promoted.py index ee8396b90..6e79e8b71 100644 --- a/tests/comfy_cli/test_workflow_to_api_promoted.py +++ b/tests/comfy_cli/test_workflow_to_api_promoted.py @@ -1367,11 +1367,6 @@ def test_promotion_traversal_limit_is_a_structured_conversion_failure(object_inf def test_qwen_image_2_1_edit_prompt_reaches_the_switch_socket(object_info): - """The template's ``prompt`` input feeds both TextGenerate's ``prompt`` - widget and a ``ComfySwitchNode``'s any-type ``on_false`` socket, the branch - the switch takes while the prompt enhancer is off. The frontend inlines the - host value into both; dropping the socket made the switch yield ``None`` and - the image encoder encode the string "None".""" api = convert_ui_to_api(_load("image_qwen_image_2_1_image_edit.json"), object_info) prompt = _api_node(api, "TextGenerate", "459:500")["inputs"]["prompt"] switch = _api_node(api, "ComfySwitchNode", "459:484")["inputs"] @@ -1455,8 +1450,6 @@ def test_host_value_reaches_a_socket_through_a_nested_instance(): def test_socket_only_input_gets_no_host_value(): - """An input that feeds no widget has no host widget in the frontend, so - nothing is inlined into its socket; a stray host value stays unused.""" sg = _prompt_to_widget_and_socket() sg["inputs"][0]["linkIds"] = [2] sg["links"] = [link for link in sg["links"] if link["id"] == 2] @@ -1493,9 +1486,6 @@ def test_external_link_into_the_input_leaves_the_socket_to_expansion(object_info def test_unset_host_value_feeds_the_socket_the_interior_source_value(object_info): - """With no host value the frontend seeds the promoted widget from its - interior source widget and inlines that into every target, so the switch - socket gets TextGenerate's interior prompt rather than nothing.""" wf = _load("image_qwen_image_2_1_image_edit.json") next(n for n in wf["nodes"] if n["id"] == 459)["widgets_values"] = [] sg = wf["definitions"]["subgraphs"][0] @@ -1509,8 +1499,6 @@ def test_unset_host_value_feeds_the_socket_the_interior_source_value(object_info def test_unset_host_value_feeds_every_target_the_source_value(): - """The frontend inlines the one seeded value into every target, so a second - interior widget takes the source widget's value, not its own default.""" sg = _prompt_to_widget_and_socket() sg["nodes"].append( { @@ -1545,9 +1533,6 @@ def test_unset_host_value_reaches_a_socket_through_a_nested_instance(): def test_known_divergence_unemitted_source_leaves_the_socket_empty(): - """Known divergence: the frontend still seeds from a muted source widget, - but the converter reads the seed from the emitted prompt, so a muted source - leaves the socket empty.""" workflow = {"nodes": [{"id": 9, "type": _SOCKET_SG}], "links": []} api = _socket_api("9") del api["9:text"] @@ -1558,8 +1543,6 @@ def test_known_divergence_unemitted_source_leaves_the_socket_empty(): def test_unset_outer_value_seeds_from_the_concrete_widget_not_the_inner_host(): - """The frontend seeds a nested promotion from the deepest concrete widget; - an inner instance's own host value is linked over from the outer input.""" outer_id, outer = _nested_outer(inner_values=["inner host"]) workflow = {"nodes": [{"id": 9, "type": outer_id}], "links": []} api = _socket_api("9:inner") From 73a619746ee622be682f5ab2fc0d765ff26fd606 Mon Sep 17 00:00:00 2001 From: Simon Pinfold Date: Wed, 4 Nov 2026 16:43:32 -0800 Subject: [PATCH 3/7] test(workflow): state what the socket tests are evidence for in their assertions --- tests/comfy_cli/test_workflow_to_api_promoted.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/comfy_cli/test_workflow_to_api_promoted.py b/tests/comfy_cli/test_workflow_to_api_promoted.py index 6e79e8b71..088bbb4a9 100644 --- a/tests/comfy_cli/test_workflow_to_api_promoted.py +++ b/tests/comfy_cli/test_workflow_to_api_promoted.py @@ -1371,7 +1371,9 @@ def test_qwen_image_2_1_edit_prompt_reaches_the_switch_socket(object_info): prompt = _api_node(api, "TextGenerate", "459:500")["inputs"]["prompt"] switch = _api_node(api, "ComfySwitchNode", "459:484")["inputs"] assert prompt == "Replace costumes for the character" - assert switch["on_false"] == prompt + assert switch["on_false"] == prompt, ( + "the frontend inlines the prompt into the switch socket; without it the encoder gets 'None'" + ) assert switch["on_true"] == ["459:500", 0] @@ -1459,7 +1461,7 @@ def test_socket_only_input_gets_no_host_value(): workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: sg}) - assert "on_false" not in api["9:switch"]["inputs"] + assert "on_false" not in api["9:switch"]["inputs"], "a socket-only input has no host widget in the frontend" def test_external_link_into_the_input_leaves_the_socket_to_expansion(object_info): @@ -1517,7 +1519,9 @@ def test_unset_host_value_feeds_every_target_the_source_value(): assert api["9:text"]["inputs"]["value"] == "interior default" assert api["9:switch"]["inputs"]["on_false"] == "interior default" - assert api["9:other"]["inputs"]["value"] == "interior default" + assert api["9:other"]["inputs"]["value"] == "interior default", ( + "the frontend inlines one seeded value into every target" + ) def test_unset_host_value_reaches_a_socket_through_a_nested_instance(): @@ -1539,7 +1543,7 @@ def test_known_divergence_unemitted_source_leaves_the_socket_empty(): workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: _prompt_to_widget_and_socket()}) - assert "on_false" not in api["9:switch"]["inputs"] + assert "on_false" not in api["9:switch"]["inputs"], "known divergence: the frontend still seeds from a muted source" def test_unset_outer_value_seeds_from_the_concrete_widget_not_the_inner_host(): @@ -1551,7 +1555,9 @@ def test_unset_outer_value_seeds_from_the_concrete_widget_not_the_inner_host(): api, workflow, {outer_id: outer, _SOCKET_SG: _prompt_to_widget_and_socket()} ) - assert api["9:inner:text"]["inputs"]["value"] == "interior default" + assert api["9:inner:text"]["inputs"]["value"] == "interior default", ( + "seeded from the deepest concrete widget, not the inner host" + ) assert api["9:inner:switch"]["inputs"]["on_false"] == "interior default" From 281d8b2c3c7878b6212ca1eb1efd60015d0836a4 Mon Sep 17 00:00:00 2001 From: Simon Pinfold Date: Wed, 4 Nov 2026 16:48:29 -0800 Subject: [PATCH 4/7] test(workflow): blank the Qwen 2.1 fixture's model-links note for the public-repo hygiene check --- tests/comfy_cli/fixtures/gallery/README.md | 2 ++ .../fixtures/gallery/image_qwen_image_2_1_image_edit.json | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/comfy_cli/fixtures/gallery/README.md b/tests/comfy_cli/fixtures/gallery/README.md index 947a5a547..f143b5684 100644 --- a/tests/comfy_cli/fixtures/gallery/README.md +++ b/tests/comfy_cli/fixtures/gallery/README.md @@ -35,6 +35,8 @@ cloud catalog entries (tooltips stripped, structure verbatim). `TextGenerate` widget and a `ComfySwitchNode` `on_false` socket) backs the socket-target tests in `tests/comfy_cli/test_workflow_to_api_promoted.py`; its node classes were added to `../object_info_subgraph_promoted.json` the same way. +Its "Note: Model links" MarkdownNote text is blanked (a UI-only node) because +the public-repo hygiene check reads its model links as repository references. `templates_graphic_design_recomposer.json` (two `PrimitiveNode` fan-outs and a labelled value widget promoted only through legacy `proxyWidgets`), diff --git a/tests/comfy_cli/fixtures/gallery/image_qwen_image_2_1_image_edit.json b/tests/comfy_cli/fixtures/gallery/image_qwen_image_2_1_image_edit.json index f6c9b7bc5..dd25caa76 100644 --- a/tests/comfy_cli/fixtures/gallery/image_qwen_image_2_1_image_edit.json +++ b/tests/comfy_cli/fixtures/gallery/image_qwen_image_2_1_image_edit.json @@ -436,10 +436,10 @@ "title": "Note: Model links", "properties": {}, "widgets_values": [ - "Guide: [Subgraph](https://docs.comfy.org/interface/features/subgraph)\n\n## Input Assets\n\n- [portrait_model_denim.png](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/input/portrait_model_denim.png)\n- [clothing_light_blue_denim_shirt.png](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/input/clothing_light_blue_denim_shirt.png)\n\n\n## Model Links\n\n- [Hugging Face:Comfy-Org/Qwen-Image-2.1](https://huggingface.co/Comfy-Org/Qwen-Image-2.1)\n- [ModelScope:Comfy-Org/Qwen-Image-2.1](https://modelscope.cn/models/Comfy-Org/Qwen-Image-2.1)\n\n**diffusion_models**\n\n- [qwen_image_2.1_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_bf16.safetensors) (13.25 GB)\n- [qwen_image_2.1_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_int8_convrot.safetensors) (6.76 GB)\n\n**text_encoders**\n\n- [qwen3vl_8b_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_bf16.safetensors) (16.33 GB)\n- [qwen3vl_8b_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_int8_convrot.safetensors) (8.71 GB) \n- [qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors) (8.82 GB)\n\n**vae**\n\n- [qwen_image_2.1_vae_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/vae/qwen_image_2.1_vae_bf16.safetensors) (644.2 MB)\n\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ ├── 📂 diffusion_models/\n│ │ ├── qwen_image_2.1_bf16.safetensors\n│ │ └── qwen_image_2.1_int8_convrot.safetensors\n│ ├── 📂 text_encoders/\n│ │ ├── qwen3vl_8b_bf16.safetensors\n│ │ ├── qwen3vl_8b_int8_convrot.safetensors\n│ │ └── qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors│ └── 📂 vae/\n│ └── qwen_image_2.1_vae_bf16.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n" + "" ], "widgets_values_named": { - "text": "Guide: [Subgraph](https://docs.comfy.org/interface/features/subgraph)\n\n## Input Assets\n\n- [portrait_model_denim.png](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/input/portrait_model_denim.png)\n- [clothing_light_blue_denim_shirt.png](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/input/clothing_light_blue_denim_shirt.png)\n\n\n## Model Links\n\n- [Hugging Face:Comfy-Org/Qwen-Image-2.1](https://huggingface.co/Comfy-Org/Qwen-Image-2.1)\n- [ModelScope:Comfy-Org/Qwen-Image-2.1](https://modelscope.cn/models/Comfy-Org/Qwen-Image-2.1)\n\n**diffusion_models**\n\n- [qwen_image_2.1_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_bf16.safetensors) (13.25 GB)\n- [qwen_image_2.1_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_int8_convrot.safetensors) (6.76 GB)\n\n**text_encoders**\n\n- [qwen3vl_8b_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_bf16.safetensors) (16.33 GB)\n- [qwen3vl_8b_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_int8_convrot.safetensors) (8.71 GB) \n- [qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors) (8.82 GB)\n\n**vae**\n\n- [qwen_image_2.1_vae_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/vae/qwen_image_2.1_vae_bf16.safetensors) (644.2 MB)\n\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ ├── 📂 diffusion_models/\n│ │ ├── qwen_image_2.1_bf16.safetensors\n│ │ └── qwen_image_2.1_int8_convrot.safetensors\n│ ├── 📂 text_encoders/\n│ │ ├── qwen3vl_8b_bf16.safetensors\n│ │ ├── qwen3vl_8b_int8_convrot.safetensors\n│ │ └── qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors│ └── 📂 vae/\n│ └── qwen_image_2.1_vae_bf16.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n" + "text": "" }, "color": "#222", "bgcolor": "#000" From e4c2c803b12499b720827b9ff1726baa97f1038f Mon Sep 17 00:00:00 2001 From: Simon Pinfold Date: Wed, 4 Nov 2026 17:46:04 -0800 Subject: [PATCH 5/7] fix(workflow): harden the no-host-value source walk Skip non-dict nodes on the nested source walk, never fan out a wired source value, and resolve each definition input's source once per conversion. --- comfy_cli/cql/promoted.py | 10 ++++- comfy_cli/workflow_to_api.py | 15 ++++++- .../test_workflow_to_api_promoted.py | 43 +++++++++++++++++++ 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/comfy_cli/cql/promoted.py b/comfy_cli/cql/promoted.py index 616f5489b..905b748f2 100644 --- a/comfy_cli/cql/promoted.py +++ b/comfy_cli/cql/promoted.py @@ -958,7 +958,15 @@ def deepest_source(sg: dict, pi: PromotedInput, defs: dict[str, dict]) -> tuple[ path.append(current.source_node) if not current.nested: return path, str(current.source_widget) - inner = next((n for n in current_sg.get("nodes") or [] if str(n.get("id")) == current.source_node), None) + nodes = current_sg.get("nodes") + inner = next( + ( + n + for n in (nodes if isinstance(nodes, list) else []) + if isinstance(n, dict) and str(n.get("id")) == current.source_node + ), + None, + ) inner_def = defs.get(str(inner.get("type", ""))) if inner is not None else None if inner_def is None or current.source_input is None: return None diff --git a/comfy_cli/workflow_to_api.py b/comfy_cli/workflow_to_api.py index feff7ecaa..ed0a621e9 100644 --- a/comfy_cli/workflow_to_api.py +++ b/comfy_cli/workflow_to_api.py @@ -234,6 +234,15 @@ def _overlay_promoted_host_values(api_prompt: dict, workflow: dict, subgraph_def visit_budget = [_MAX_SUBGRAPH_EXPANSION_BUDGET] definition_nodes: dict[int, tuple[dict, list[dict]]] = {} scope_links: dict[int, tuple[dict, set[tuple[type, int | str]]]] = {} + sources: dict[tuple[int, int], tuple[dict, tuple[list[str], str] | None]] = {} + + def source_for(sg: dict, pi: Any) -> tuple[list[str], str] | None: + cached = sources.get((id(sg), pi.index)) + if cached is not None and cached[0] is sg: + return cached[1] + source = _promoted.deepest_source(sg, pi, subgraph_defs) + sources[(id(sg), pi.index)] = (sg, source) + return source def nodes_for(definition: dict) -> list[dict]: cached = definition_nodes.get(id(definition)) @@ -292,7 +301,7 @@ def is_live(link_id: Any) -> bool: value = _promoted.host_value(instance, pi) if value is _promoted.UNSET: # No host value: the frontend seeds the promoted widget from its interior source widget. - value = _source_widget_value(api_prompt, prefix, _promoted.deepest_source(sg, pi, subgraph_defs)) + value = _source_widget_value(api_prompt, prefix, source_for(sg, pi)) if value is _promoted.UNSET: continue else: @@ -330,7 +339,9 @@ def _source_widget_value(api_prompt: dict, prefix: str, source: tuple[list[str], inputs = entry.get("inputs") if isinstance(entry, dict) else None if not isinstance(inputs, dict) or widget not in inputs: return _promoted.UNSET - return inputs[widget] + 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: diff --git a/tests/comfy_cli/test_workflow_to_api_promoted.py b/tests/comfy_cli/test_workflow_to_api_promoted.py index 088bbb4a9..c222817fb 100644 --- a/tests/comfy_cli/test_workflow_to_api_promoted.py +++ b/tests/comfy_cli/test_workflow_to_api_promoted.py @@ -1575,3 +1575,46 @@ def test_source_widget_value_without_a_source_is_unset(): from comfy_cli.cql import promoted assert workflow_to_api._source_widget_value({"9:text": {"inputs": {"value": "x"}}}, "9", None) is promoted.UNSET + + +def test_unset_host_value_skips_non_dict_nodes_on_the_nested_source_walk(): + outer_id, outer = _nested_outer() + outer["nodes"].insert(0, 5) + workflow = {"nodes": [{"id": 9, "type": outer_id}], "links": []} + api = _socket_api("9:inner") + + workflow_to_api._overlay_promoted_host_values( + api, workflow, {outer_id: outer, _SOCKET_SG: _prompt_to_widget_and_socket()} + ) + + assert api["9:inner:switch"]["inputs"]["on_false"] == "interior default" + + +def test_unset_host_value_never_fans_out_a_wired_source(): + workflow = {"nodes": [{"id": 9, "type": _SOCKET_SG}], "links": []} + api = _socket_api("9") + api["9:text"]["inputs"]["value"] = ["7", 0] + + workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: _prompt_to_widget_and_socket()}) + + assert "on_false" not in api["9:switch"]["inputs"], "a link pair must not be copied into sibling targets" + + +def test_unset_host_value_source_walk_runs_once_per_definition_input(monkeypatch): + from comfy_cli.cql import promoted + + calls = [] + original = promoted.deepest_source + + def counted(sg, pi, defs): + calls.append(pi.index) + return original(sg, pi, defs) + + monkeypatch.setattr(promoted, "deepest_source", counted) + workflow = {"nodes": [{"id": i, "type": _SOCKET_SG} for i in (8, 9)], "links": []} + api = {**_socket_api("8"), **_socket_api("9")} + + workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: _prompt_to_widget_and_socket()}) + + assert calls == [0] + assert api["8:switch"]["inputs"]["on_false"] == api["9:switch"]["inputs"]["on_false"] == "interior default" From 1ed5027549c685b288a73fb7bb7001c9f0eee964 Mon Sep 17 00:00:00 2001 From: Simon Pinfold Date: Wed, 4 Nov 2026 17:54:45 -0800 Subject: [PATCH 6/7] test(workflow): pin the processed-dynamic-prompt divergence; keep the Qwen 2.1 fixture out of the refresh loop --- tests/comfy_cli/fixtures/gallery/README.md | 8 +++++--- .../comfy_cli/test_workflow_to_api_promoted.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/comfy_cli/fixtures/gallery/README.md b/tests/comfy_cli/fixtures/gallery/README.md index f143b5684..2b9d851b5 100644 --- a/tests/comfy_cli/fixtures/gallery/README.md +++ b/tests/comfy_cli/fixtures/gallery/README.md @@ -11,7 +11,7 @@ Refresh with: ```bash cd tests/comfy_cli/fixtures/gallery -for f in 02_qwen_Image_edit_subgraphed 05_audio_ace_step_1_t2a_song_subgraphed image_z_image_turbo audio_minimax_music_3 api_seedance2_5_video_extend templates_graphic_design_recomposer template_horizontal_vertical_extension flux_dev_checkpoint_example image_qwen_image_2_1_image_edit; do +for f in 02_qwen_Image_edit_subgraphed 05_audio_ace_step_1_t2a_song_subgraphed image_z_image_turbo audio_minimax_music_3 api_seedance2_5_video_extend templates_graphic_design_recomposer template_horizontal_vertical_extension flux_dev_checkpoint_example; do curl -sfL "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/${f}.json" -o "${f}.json" done ``` @@ -35,8 +35,10 @@ cloud catalog entries (tooltips stripped, structure verbatim). `TextGenerate` widget and a `ComfySwitchNode` `on_false` socket) backs the socket-target tests in `tests/comfy_cli/test_workflow_to_api_promoted.py`; its node classes were added to `../object_info_subgraph_promoted.json` the same way. -Its "Note: Model links" MarkdownNote text is blanked (a UI-only node) because -the public-repo hygiene check reads its model links as repository references. +It is NOT verbatim and is left out of the refresh loop above: its "Note: Model +links" MarkdownNote text is blanked (a UI-only node) because the public-repo +hygiene check reads its model links as repository references, and the tests rely +on its prompt text and on `prompt` linking the switch socket before the widget. `templates_graphic_design_recomposer.json` (two `PrimitiveNode` fan-outs and a labelled value widget promoted only through legacy `proxyWidgets`), diff --git a/tests/comfy_cli/test_workflow_to_api_promoted.py b/tests/comfy_cli/test_workflow_to_api_promoted.py index c222817fb..bd85fe7da 100644 --- a/tests/comfy_cli/test_workflow_to_api_promoted.py +++ b/tests/comfy_cli/test_workflow_to_api_promoted.py @@ -1456,6 +1456,9 @@ def test_socket_only_input_gets_no_host_value(): sg["inputs"][0]["linkIds"] = [2] sg["links"] = [link for link in sg["links"] if link["id"] == 2] sg["nodes"][0]["inputs"][0]["link"] = None + from comfy_cli.cql import promoted + + assert [pi.is_widget for pi in promoted.promoted_inputs(sg, {_SOCKET_SG: sg})] == [False] workflow = {"nodes": [{"id": 9, "type": _SOCKET_SG, "widgets_values": ["stray"]}], "links": []} api = _socket_api("9") @@ -1618,3 +1621,18 @@ def counted(sg, pi, defs): assert calls == [0] assert api["8:switch"]["inputs"]["on_false"] == api["9:switch"]["inputs"]["on_false"] == "interior default" + + +def test_known_divergence_unset_host_value_fans_out_the_processed_dynamic_prompt(object_info): + wf = _load("image_qwen_image_2_1_image_edit.json") + next(n for n in wf["nodes"] if n["id"] == 459)["widgets_values"] = [] + sg = wf["definitions"]["subgraphs"][0] + next(n for n in sg["nodes"] if n["id"] == 500)["widgets_values"][0] = "a {red|red} cat // note" + + api = convert_ui_to_api(wf, object_info) + + emitted = _api_node(api, "TextGenerate", "459:500")["inputs"]["prompt"] + assert emitted == "a red cat " + assert _api_node(api, "ComfySwitchNode", "459:484")["inputs"]["on_false"] == emitted, ( + "known divergence: the frontend sends the raw text; the converter fans out the emitted value" + ) From 103aac0b027adbbf7c8a4d94578f341a274d17f8 Mon Sep 17 00:00:00 2001 From: Simon Pinfold Date: Thu, 5 Nov 2026 16:08:21 -0800 Subject: [PATCH 7/7] refactor(workflow): charge the no-host-value source walk to the overlay budget instead of memoizing it --- comfy_cli/workflow_to_api.py | 14 +++------ .../test_workflow_to_api_promoted.py | 29 ++++++++----------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/comfy_cli/workflow_to_api.py b/comfy_cli/workflow_to_api.py index ed0a621e9..4094c4f0c 100644 --- a/comfy_cli/workflow_to_api.py +++ b/comfy_cli/workflow_to_api.py @@ -234,15 +234,6 @@ def _overlay_promoted_host_values(api_prompt: dict, workflow: dict, subgraph_def visit_budget = [_MAX_SUBGRAPH_EXPANSION_BUDGET] definition_nodes: dict[int, tuple[dict, list[dict]]] = {} scope_links: dict[int, tuple[dict, set[tuple[type, int | str]]]] = {} - sources: dict[tuple[int, int], tuple[dict, tuple[list[str], str] | None]] = {} - - def source_for(sg: dict, pi: Any) -> tuple[list[str], str] | None: - cached = sources.get((id(sg), pi.index)) - if cached is not None and cached[0] is sg: - return cached[1] - source = _promoted.deepest_source(sg, pi, subgraph_defs) - sources[(id(sg), pi.index)] = (sg, source) - return source def nodes_for(definition: dict) -> list[dict]: cached = definition_nodes.get(id(definition)) @@ -301,7 +292,10 @@ def is_live(link_id: Any) -> bool: value = _promoted.host_value(instance, pi) if value is _promoted.UNSET: # No host value: the frontend seeds the promoted widget from its interior source widget. - value = _source_widget_value(api_prompt, prefix, source_for(sg, pi)) + 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: diff --git a/tests/comfy_cli/test_workflow_to_api_promoted.py b/tests/comfy_cli/test_workflow_to_api_promoted.py index bd85fe7da..11c97355f 100644 --- a/tests/comfy_cli/test_workflow_to_api_promoted.py +++ b/tests/comfy_cli/test_workflow_to_api_promoted.py @@ -1603,24 +1603,19 @@ def test_unset_host_value_never_fans_out_a_wired_source(): assert "on_false" not in api["9:switch"]["inputs"], "a link pair must not be copied into sibling targets" -def test_unset_host_value_source_walk_runs_once_per_definition_input(monkeypatch): - from comfy_cli.cql import promoted - - calls = [] - original = promoted.deepest_source - - def counted(sg, pi, defs): - calls.append(pi.index) - return original(sg, pi, defs) - - monkeypatch.setattr(promoted, "deepest_source", counted) - workflow = {"nodes": [{"id": i, "type": _SOCKET_SG} for i in (8, 9)], "links": []} - api = {**_socket_api("8"), **_socket_api("9")} - - workflow_to_api._overlay_promoted_host_values(api, workflow, {_SOCKET_SG: _prompt_to_widget_and_socket()}) +def test_unset_host_value_source_walk_is_charged_to_the_overlay_budget(monkeypatch): + workflow = {"nodes": [{"id": 8, "type": _SOCKET_SG}], "links": []} + definitions = {_SOCKET_SG: _prompt_to_widget_and_socket()} + monkeypatch.setattr(workflow_to_api, "_MAX_SUBGRAPH_EXPANSION_BUDGET", 8) + with pytest.raises(workflow_to_api.WorkflowConversionError, match="promoted-value overlay exceeded"): + workflow_to_api._overlay_promoted_host_values(_socket_api("8"), workflow, definitions) - assert calls == [0] - assert api["8:switch"]["inputs"]["on_false"] == api["9:switch"]["inputs"]["on_false"] == "interior default" + monkeypatch.setattr(workflow_to_api, "_MAX_SUBGRAPH_EXPANSION_BUDGET", 9) + api = _socket_api("8") + workflow_to_api._overlay_promoted_host_values(api, workflow, definitions) + assert api["8:switch"]["inputs"]["on_false"] == "interior default", ( + "visit (2 nodes + 1 input + 1) + source walk (2 nodes + 1) + 2 targets = 9 must fit" + ) def test_known_divergence_unset_host_value_fans_out_the_processed_dynamic_prompt(object_info):