Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ history.

## [Unreleased]

### Changed

- A `connect` into a widget input of an agent-built node is now type-checked.
`comfy workflow add-node` gives every widget input a socket entry (see Fixed
below), so a link into one is an ordinary connect to an existing slot rather
than a `grow` that minted a new slot and took the source's type unchecked. A
mismatched scalar — `INT` into a `FLOAT` widget such as `force_rate`, or
`IMAGE` into a `COMBO` — now fails the existing type check instead of being
accepted silently. A `COMBO` widget socket still accepts `COMBO`, `STRING`,
`INT` and `FLOAT`, because that is how a computed file name or a numeric
option reaches a combo; every other source type is refused.

### Fixed

- `comfy validate` no longer lets a dotted key left over from another
Expand All @@ -35,6 +47,25 @@ history.
same two values adjacently and is now keyword-only for the same reason, before
anything is inserted into it.

- `comfy workflow add-node` writes a socket entry for every widget input of the
new node — `INT`, `FLOAT`, `STRING`, `BOOLEAN` and `COMBO` — in the same
`{"name", "type", "widget": {"name"}, "link": null}` shape the frontend
serializes, placed after the link inputs so existing link indices do not move.
Before this, an agent-built node carried no `inputs[]` entry for its widgets,
so a link a human drew into a widget socket on the canvas named a slot the
shared document did not have and was dropped. Sockets are written all or none
per node: a node with a widget that cannot have an entry of its own — a
dynamic combo, a union type such as `FLOAT,INT`, a socketless widget — keeps
the previous convert-on-connect behaviour unchanged. Nodes already present in
existing documents are not migrated.

- The save-to-API converter no longer drops a `COMBO` value that happens to read
like a control marker. When a node's widget sockets account for every saved
widget value there is no room for a trailing `control_after_generate` marker,
so the positional marker filter is skipped and a value of `"fixed"` stays a
value. Saves with a real marker have one more value than sockets and still go
through the filter.

## [1.24.0] - 2026-10-29

[Full notes](https://github.com/Comfy-Org/comfy-cli/releases/tag/v1.24.0) · 25 commits since v1.23.0.
Expand Down
4 changes: 2 additions & 2 deletions comfy_cli/link_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _rows(links: Any) -> list[list]:


def _scope_findings(nodes: list, links: Any, prefix: str | None) -> tuple[list[dict], list[dict]]:
from comfy_cli.workflow_ops import _types_compatible
from comfy_cli.workflow_ops import _input_accepts

def addr(nid: Any) -> str:
return f"{prefix}/{nid}" if prefix else str(nid)
Expand Down Expand Up @@ -143,7 +143,7 @@ def fed_from(node: dict, src: Any, slot: Any, except_id: Any) -> str | None:
candidates = [
str(i.get("name"))
for i in inputs
if i.get("link") is None and i.get("name") and _types_compatible(source_type, i.get("type"))
if i.get("link") is None and i.get("name") and _input_accepts(source_type, i)
]
where = (
f"link {link_id} from {'the subgraph input' if src_is_proxy else f'node {addr(src_id)} output {src_slot}'} "
Expand Down
47 changes: 45 additions & 2 deletions comfy_cli/workflow_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,21 @@ def _slot_types(t: Any) -> set[str]:
return {p.strip() for p in str(t or "").split(",") if p.strip()}


_COMBO_SOCKET_SOURCE_TYPES = frozenset({"STRING", "INT", "FLOAT"})


def _input_accepts(link_type: Any, input_entry: dict) -> bool:
"""Whether an output of ``link_type`` may drive ``input_entry``.

A COMBO widget socket also takes a scalar: that is how a computed file name
or option reaches a combo, and a combo's options can be numbers.
"""
dst_type = input_entry.get("type")
if dst_type == "COMBO" and input_entry.get("widget") and link_type in _COMBO_SOCKET_SOURCE_TYPES:
return True
return _types_compatible(link_type, dst_type)


def _types_compatible(link_type: Any, dst_type: Any) -> bool:
"""Whether an output of ``link_type`` may drive an input of ``dst_type``.

Expand Down Expand Up @@ -2301,7 +2316,7 @@ def _connect_impl(
# link.
if in_idx is not None:
dst_type = (dst.get("inputs") or [])[in_idx].get("type")
if not _types_compatible(link_type, dst_type):
if not _input_accepts(link_type, (dst.get("inputs") or [])[in_idx]):
raise ValueError(
f"type mismatch: {link_type} output of node {from_node} cannot connect to "
f"{dst_type} input {(dst.get('inputs') or [])[in_idx].get('name')!r} of node {to_node}"
Expand Down Expand Up @@ -2571,7 +2586,7 @@ def _connect_interior(
"the node lists; inside a subgraph connect can only wire an existing input"
)
dst_type = (dst.get("inputs") or [])[in_idx].get("type")
if not _types_compatible(link_type, dst_type):
if not _input_accepts(link_type, (dst.get("inputs") or [])[in_idx]):
raise ValueError(
f"type mismatch: {link_type} output of node {'/'.join(scope['path'])}/{src.get('id')} cannot connect "
f"to {dst_type} input {(dst.get('inputs') or [])[in_idx].get('name')!r} of node "
Expand Down Expand Up @@ -4890,7 +4905,34 @@ def strip_internal(workflow: dict) -> dict:
# ---------------------------------------------------------------------------


# Widget input types a fresh node gets a socket entry for. The frontend gives
# every non-socketless widget input a socket and serializes it as
# ``{"name", "type", "widget": {"name"}}``; without the entry the shared document
# has no slot for a link a human draws into that socket, so the link never
# reaches the document.
_SOCKETED_WIDGET_TYPES = frozenset({"INT", "FLOAT", "STRING", "BOOLEAN", "COMBO"})


def _widget_input_entries(m, order: list[str]) -> list[dict]:
"""Socket entries for every widget in ``order``, or none.

Without object_info the converter names saved values from these entries by
position, so sockets for only some widgets would misname the rest. A node
with a widget that has no entry of its own (a dynamic combo, a union type, a
socketless widget) keeps the convert-on-connect path instead.
"""
entries = [
{"name": p.name, "type": p.type, "widget": {"name": p.name}, "link": None}
for p in m.inputs
if not p.is_link and not p.is_socketless and p.type in _SOCKETED_WIDGET_TYPES
]
if [e["name"] for e in entries] != [name for name in order if name != "control_after_generate"]:
return []
return entries


def _build_node(node_id: int, class_type: str, m, graph, pos: list, size: list, title: str | None = None) -> dict:
# Link inputs first, so their indices are unchanged; widget sockets after.
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
inputs = [{"name": p.name, "type": p.type, "link": None} for p in m.inputs if p.is_link]
outputs = [{"name": p.name, "type": p.type, "links": []} for p in m.outputs]
# Widget values in positional order, including dynamic-combo selectors and
Expand All @@ -4902,6 +4944,7 @@ def _build_node(node_id: int, class_type: str, m, graph, pos: list, size: list,
# it, so neither does a fresh node — no phantom trailing ``null``.
while order and order[-1] not in defaults:
order = order[:-1]
inputs += _widget_input_entries(m, order)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
widgets = [defaults.get(name) for name in order]
node = {
"id": node_id,
Expand Down
8 changes: 7 additions & 1 deletion comfy_cli/workflow_to_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2510,7 +2510,13 @@ def emit(name: str, value: Any) -> Any:
# No schema, or the schema declares no widget inputs: fall back to the
# positional control-marker heuristic + node-input name inspection, which
# matches the reference behavior for unknown node types.
filtered = _filter_control_values(widget_values, node_type=node_type, node=node, object_info=object_info)
# A socket for every value leaves no room for a control marker, so a COMBO
# value that reads "fixed" stays a value.
sockets = [i for i in node.get("inputs") or [] if isinstance(i, dict) and i.get("widget")]
if len(sockets) == len(widget_values):
filtered = widget_values
else:
filtered = _filter_control_values(widget_values, node_type=node_type, node=node, object_info=object_info)
names = _fallback_widget_names(node, filtered)
if not names:
if filtered:
Expand Down
30 changes: 25 additions & 5 deletions tests/comfy_cli/command/test_workflow_edit_nested_autogrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ def _node(wf: dict, node_id: Any) -> dict:
return next(n for n in wf["nodes"] if n["id"] == node_id)


def _is_widget_socket(entry: dict) -> bool:
return "widget" in entry and "grow_id" not in entry


def _inputs(wf: dict, node_id: Any) -> list[str]:
return [i["name"] for i in _node(wf, node_id).get("inputs") or []]
return [i["name"] for i in _node(wf, node_id).get("inputs") or [] if not _is_widget_socket(i)]


def _link_of(wf: dict, node_id: Any, name: str):
Expand Down Expand Up @@ -152,7 +156,7 @@ def _add_loader(wf: dict, graph: Graph, class_type: str) -> tuple[dict, int]:
def test_add_node_writes_frontend_width_widgets_and_no_group_inputs(graph):
wf, _ = workflow_ops.add_node(_empty(), graph, "MinimaxHailuo03ReferenceNode")
node = wf["nodes"][0]
assert node["inputs"] == []
assert [i for i in node["inputs"] if not _is_widget_socket(i)] == []
order = graph.widget_order_default("MinimaxHailuo03ReferenceNode")
assert len(node["widgets_values"]) == len(order) == 8
by_name = dict(zip(order, node["widgets_values"]))
Expand All @@ -171,7 +175,7 @@ def test_connect_grows_first_nested_slot_by_its_schema_name(graph):
wf, b = _add_loader(wf, graph, "GeminiNanoBanana2V2")
widgets_before = list(_node(wf, b)["widgets_values"])
wf, op = workflow_ops.connect(wf, graph, a, "IMAGE", b, "model.images.image_1")
grown = _node(wf, b)["inputs"]
grown = [i for i in _node(wf, b)["inputs"] if not _is_widget_socket(i)]
assert [i["name"] for i in grown] == ["model.images.image_1"]
assert grown[0]["type"] == "IMAGE"
assert grown[0]["link"] == op["link_id"]
Expand Down Expand Up @@ -446,13 +450,29 @@ def test_full_group_reports_full_before_the_next_key_hint(graph):

def test_a_real_widget_name_outranks_the_bare_element_guess():
"""A node whose group's bare element vocabulary collides with a real
widget name keeps the widget→input conversion (the existing precedence)."""
widget name resolves to that widget's own input, never the group guess."""
oi = json.loads(FIXTURE.read_text())
oi["BatchImagesNode"]["input"]["required"]["image0"] = ["STRING", {"default": ""}]
oi["BatchImagesNode"]["input_order"]["required"].append("image0")
g = Graph.from_object_info(oi)
wf, batch = _add_loader(_empty(), g, "BatchImagesNode")
_idx, grow = workflow_ops._resolve_input_target(_node(wf, batch), g, "image0", "STRING")
node = _node(wf, batch)
idx, grow = workflow_ops._resolve_input_target(node, g, "image0", "STRING")
assert grow is None
assert node["inputs"][idx] == {"name": "image0", "type": "STRING", "widget": {"name": "image0"}, "link": None}


def test_a_real_combo_widget_name_outranks_the_bare_element_guess():
"""A node saved before COMBO widgets had socket entries takes the
widget→input conversion, still ahead of the group's element guess."""
oi = json.loads(FIXTURE.read_text())
oi["BatchImagesNode"]["input"]["required"]["image0"] = [["a", "b"]]
oi["BatchImagesNode"]["input_order"]["required"].append("image0")
g = Graph.from_object_info(oi)
wf, batch = _add_loader(_empty(), g, "BatchImagesNode")
node = _node(wf, batch)
node["inputs"] = [i for i in node["inputs"] if i["name"] != "image0"]
_idx, grow = workflow_ops._resolve_input_target(node, g, "image0", "STRING")
assert grow == {"name": "image0", "type": "STRING", "widget": "image0"}


Expand Down
Loading
Loading