Skip to content

feat(workflow): agent-first workflow editing — CRDT edit primitives, recipes, offline catalog, cloud run association#511

Open
skishore23 wants to merge 6 commits into
mainfrom
fix/validate-lowers-ui-to-api
Open

feat(workflow): agent-first workflow editing — CRDT edit primitives, recipes, offline catalog, cloud run association#511
skishore23 wants to merge 6 commits into
mainfrom
fix/validate-lowers-ui-to-api

Conversation

@skishore23

@skishore23 skishore23 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

Consolidates the agent-workflow track into a single change on top of main. It gives agents a structured, convergence-safe way to build and edit ComfyUI workflows, a reuse model that replaces raw fragments, an offline node catalog so edits and validation work without a live server, and the cloud plumbing to associate and run those workflows against Comfy Cloud.

Why

The agent field test surfaced that raw-JSON/fragment editing was error-prone and non-convergent, and that edits/validation broke whenever no live ComfyUI server was reachable. This lands the structured-edit + offline-catalog + recipe model as one reviewable unit.

Highlights

Structured (CRDT-ready) workflow edits

  • workflow_ops.py: convergence-safe op model — converge-or-flag invariant and canonical-form soundness are proven in tests.
  • New workflow edit command surface over those primitives; set-widget resolves subgraph promoted inputs the same way it resolves slots.
  • edit/recipe commands registered in COMMAND_SCHEMAS for discovery.

Recipes replace fragments

  • Parameterized recipes + capture as the reuse path; foreach bulk-instantiates a recipe over N param-sets.
  • Legacy fragments un-surfaced from agents; comfy-fragments SKILL removed; skills docs point at recipes.

Offline node catalog + validation

  • COMFY_OBJECT_INFO_FILE default offline catalog, honored in the shared CQL loader with a cache-first TTL for object_info.
  • validate lowers frontend/canvas graphs to API before validating; generate emits complete node inputs and validate flags missing required inputs.
  • Actionable rejections: normalize mangled model values + nearest-COMBO suggestion; real id/address suggestion on a not-found edit; drop the seed control_after_generate marker for partner nodes.

Cloud run association

  • comfy run --workflow-id associates a cloud job with a workflow.
  • Forwarded Bearer token via COMFY_CLOUD_AUTH_TOKEN.
  • New assets library ls / ensure; shared cloud-HTTP helpers extracted to cloud_http.py.

Agentic run ergonomics + perf

  • Suppress the detached watcher for agentic callers (COMFY_NO_WATCH / --no-watch).
  • Kill the telemetry exit hang; defer heavy imports at startup.
  • preview renders headless via bundled ffmpeg.

Test plan

  • pytest --collect-only — 2749 tests, no import/collection errors.
  • Focused suites green (219 passed, 2 skipped): test_run_prompt, test_run_watcher, test_workflow_edit, test_workflow_edit_cloud, test_validate_lowers_ui, test_workflow_to_api, cql/test_loader_ttl, generate/test_emit.

🤖 Generated with Claude Code

…recipes, offline catalog, cloud run association

Consolidates the agent-workflow track into one change on top of main. It gives
agents a structured, convergence-safe way to build and edit ComfyUI workflows,
a reuse model that replaces raw fragments, an offline node catalog so edits and
validation work without a live server, and the cloud plumbing to associate and
run those workflows against Comfy Cloud.

Structured (CRDT-ready) workflow edits
  - New workflow_ops.py: convergence-safe op model for graph mutation, with the
    converge-or-flag invariant and canonical-form soundness proven in tests.
  - New `workflow edit` command surface (workflow_edit.py) over those primitives;
    set-widget resolves subgraph promoted inputs the same way it resolves slots.
  - edit/recipe commands registered in COMMAND_SCHEMAS for discovery.

Recipes replace fragments
  - Parameterized recipes + capture as the reuse path; `foreach` bulk-instantiates
    a recipe over N param-sets.
  - Legacy fragments un-surfaced from agents; comfy-fragments SKILL removed and
    skills docs point at recipes as the supported path.

Offline node catalog + validation
  - COMFY_OBJECT_INFO_FILE provides a default offline node catalog, honored in the
    shared CQL loader (not per-command) with a cache-first TTL for object_info.
  - validate lowers frontend/canvas graphs to API before validating; generate emits
    complete node inputs and validate flags missing required inputs.
  - Rejected values get actionable feedback: normalize mangled model values and
    suggest the nearest COMBO; suggest the real id/address on a not-found edit;
    drop the seed control_after_generate marker for partner nodes.

Cloud run association
  - `comfy run --workflow-id` associates a cloud job with a workflow.
  - Accept a forwarded Bearer token via COMFY_CLOUD_AUTH_TOKEN.
  - New `assets library ls` / `ensure`; shared cloud-HTTP helpers extracted to
    cloud_http.py.
  - Cloud object_info loads route through the offline catalog.

Agentic run ergonomics + perf
  - Suppress the detached watcher for agentic callers (COMFY_NO_WATCH / --no-watch).
  - Kill the telemetry exit hang and defer heavy imports at startup.
  - preview renders headless via bundled ffmpeg.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f79d2ed6-64c8-4942-8959-55a11ff38bb2

📥 Commits

Reviewing files that changed from the base of the PR and between 6513fa2 and 0c37bd0.

📒 Files selected for processing (6)
  • comfy_cli/cmdline.py
  • comfy_cli/command/workflow_edit.py
  • comfy_cli/skills/comfy/SKILL.md
  • comfy_cli/workflow_ops.py
  • tests/comfy_cli/command/test_workflow_edit.py
  • tests/comfy_cli/test_run_execution_lifecycle.py

📝 Walkthrough

Walkthrough

This PR adds structured frontend workflow editing and recipes, cloud execution and asset integrations, frontend-to-API validation, object-info caching, dynamic-combo handling, media preview fallbacks, lazy imports, telemetry initialization changes, and updated skills, schemas, and tests.

Changes

Workflow editing and validation

Layer / File(s) Summary
Structured workflow operations and recipes
comfy_cli/workflow_ops.py, comfy_cli/command/workflow_edit.py, comfy_cli/command/workflow.py
Adds replayable graph operations, recipe capture/apply/foreach commands, deterministic replay, structured envelopes, and graph-address validation.
Graph conversion and object-info handling
comfy_cli/cql/engine.py, comfy_cli/cql/loader.py, comfy_cli/cmdline.py, comfy_cli/workflow_to_api.py
Adds dynamic-combo expansion, required-input validation, suggestions, deterministic subgraph forks, TTL cache reads, and frontend graph conversion during validation.

Cloud and runtime integrations

Layer / File(s) Summary
Cloud execution and assets
comfy_cli/command/run/*, comfy_cli/comfy_client.py, comfy_cli/command/assets_library.py, comfy_cli/command/cloud_http.py, comfy_cli/credentials.py
Adds workflow association, bearer-token resolution, watcher suppression, shared cloud HTTP errors, and comfy assets library ls/ensure.
Generated workflows and previews
comfy_cli/command/generate/emit.py, comfy_cli/command/preview.py, pyproject.toml, tests/comfy_cli/command/generate/*
Expands partner-node defaults and mappings, fixes widget alignment, and supports bundled ffmpeg with ffprobe-independent fallback classification.
Deferred imports and telemetry
comfy_cli/tracking.py, comfy_cli/ui.py, comfy_cli/command/*, comfy_cli/utils.py, comfy_cli/standalone.py
Moves optional dependencies into execution paths and lazily constructs telemetry providers.

Skills and validation coverage

Layer / File(s) Summary
Skills, discovery, and error contracts
comfy_cli/skills/*, comfy_cli/discovery.py, comfy_cli/schemas/assets_library.json, comfy_cli/error_codes.py
Removes the bundled fragments skill, documents recipe-based editing, registers command schemas, and adds workflow/cloud error codes.
Regression coverage
tests/comfy_cli/*, tests/e2e/verify_tracking_live.py
Adds tests for workflow operations, cloud conversion, object-info caching, credentials, watcher behavior, validation, converter alignment, lazy providers, and updated import behavior.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant WorkflowEdit
  participant WorkflowOps
  participant Renderer
  CLI->>WorkflowEdit: invoke workflow edit command
  WorkflowEdit->>WorkflowOps: apply graph operation or recipe
  WorkflowOps-->>WorkflowEdit: return workflow and operation metadata
  WorkflowEdit->>Renderer: emit structured envelope
Loading

Possibly related PRs

Suggested reviewers: mattmillerai

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/validate-lowers-ui-to-api
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/validate-lowers-ui-to-api

Comment @coderabbitai help to get the list of available commands.

@socket-security

socket-security Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedimageio-ffmpeg@​0.6.099100100100100

View full report

Comment thread comfy_cli/cql/engine.py Fixed
@skishore23 skishore23 added the cursor-review Request Cursor bot review label Jul 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
comfy_cli/cmdline.py (1)

934-1034: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

validate has grown past comfortable size; extract the UI→API lowering into a helper.

The new object_info-load + convert_ui_to_api block (1003-1034) pushes validate to 26 locals / 18 branches / 61 statements per Pylint. A small _ensure_api_format(wf_data, mode, input_path, host, port, renderer) helper (returning the possibly-converted dict, or raising/exiting on failure) would isolate this logic and make both validate and any future reuse (e.g. a run --print-prompt style pre-check) easier to test in isolation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@comfy_cli/cmdline.py` around lines 934 - 1034, Extract the non-API workflow
lowering block from validate into an _ensure_api_format helper accepting
wf_data, mode, input_path, host, port, and renderer. Keep the existing
resilient_load_object_info and convert_ui_to_api behavior, including
cql_no_graph and conversion_error reporting with typer.Exit on failure, and
return the original dict unchanged when is_api_format is true. Replace the
inline block in validate with the helper result.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@comfy_cli/cmdline.py`:
- Around line 810-817: Extract the UI-to-API load and conversion logic currently
handled by validate() into a focused helper, then have validate() call that
helper while retaining its existing validation and tracking behavior. Keep the
helper responsible only for the lowering path and preserve the current inputs,
outputs, and error handling.

In `@comfy_cli/command/assets_library.py`:
- Around line 30-39: Run Ruff formatting on the Python file and ensure the long
Typer option declarations, especially the tags option near the limit definition,
comply with Ruff’s line-length formatting and enabled import-sorting rules;
preserve the existing option behavior and values.

In `@comfy_cli/command/workflow_edit.py`:
- Around line 84-96: Define shared Annotated aliases for the repeated
options—where, input_path, host, port, actor, base_version, and
stdout/in-place—near the command declarations, preserving their existing flags,
help text, and defaults. Replace the duplicated option annotations in
add_node_cmd, set_widget_cmd, connect_cmd, delete_cmd, capture_cmd, apply_cmd,
and foreach_cmd with those aliases.
- Around line 507-521: Update the foreach batch handling around the param_sets
loop and its workflow_edit_invalid exception path so failures after earlier
iterations explicitly surface the paths in written, rather than silently
reporting only the error. Preserve successful atomic writes per file, but
include partial-output details in the error reporting and ensure the caller can
determine which files were already produced.

In `@comfy_cli/skills/comfy/SKILL.md`:
- Around line 399-400: Update the subgraph guidance in the structured-edit
primitives section to state that set-widget supports both flat promoted and
nested subgraph addresses directly. Remove the instruction to use set-slot
nested addresses or decompose for values inside subgraphs, while preserving any
accurate limitations for primitives that do not support subgraph edits.

In `@comfy_cli/workflow_ops.py`:
- Around line 704-1103: Run Ruff formatting on comfy_cli/workflow_ops.py lines
704-1103, comfy_cli/command/workflow_edit.py lines 93-485, and
tests/comfy_cli/command/test_workflow_edit.py lines 145-920; commit the
resulting formatting changes and preserve Ruff’s import-sorting rules.
- Around line 715-718: Update the alias assignment in apply_specs for add_node
so a non-empty spec["as"] is rejected when the alias already exists in the
current aliases mapping, rather than overwriting the previous node ID. Raise the
established validation/error type with a clear duplicate-alias message, while
preserving normal assignment for unique aliases.
- Around line 711-732: Update the operation-dispatch loop around add_node,
connect, set_widget, and delete_node so required spec fields are validated or
accessed within error handling that preserves spec index context. Convert
missing-field KeyErrors for class_type, from, to, node, widget, and value into
ValueErrors identifying spec #{i} and the missing field, while preserving the
existing validation and unknown-operation messages.

In `@tests/comfy_cli/cql/test_object_info_env.py`:
- Around line 22-28: Format the monkeypatch.setattr call for
engine._load_from_target in the test according to Ruff’s formatter, including
the lambda and AssertionError expression, and ensure the file’s imports remain
Ruff/isort compliant. Run Ruff formatting to verify no diff remains.

---

Outside diff comments:
In `@comfy_cli/cmdline.py`:
- Around line 934-1034: Extract the non-API workflow lowering block from
validate into an _ensure_api_format helper accepting wf_data, mode, input_path,
host, port, and renderer. Keep the existing resilient_load_object_info and
convert_ui_to_api behavior, including cql_no_graph and conversion_error
reporting with typer.Exit on failure, and return the original dict unchanged
when is_api_format is true. Replace the inline block in validate with the helper
result.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 71e9d8dd-710c-4f12-9331-4dde45b613f6

📥 Commits

Reviewing files that changed from the base of the PR and between a732f5c and f795e39.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (61)
  • comfy_cli/cmdline.py
  • comfy_cli/comfy_client.py
  • comfy_cli/command/assets_library.py
  • comfy_cli/command/cloud_http.py
  • comfy_cli/command/code_search.py
  • comfy_cli/command/generate/emit.py
  • comfy_cli/command/install.py
  • comfy_cli/command/models/models.py
  • comfy_cli/command/preview.py
  • comfy_cli/command/project.py
  • comfy_cli/command/run/__init__.py
  • comfy_cli/command/run/watcher.py
  • comfy_cli/command/workflow.py
  • comfy_cli/command/workflow_edit.py
  • comfy_cli/cql/engine.py
  • comfy_cli/cql/loader.py
  • comfy_cli/credentials.py
  • comfy_cli/discovery.py
  • comfy_cli/env_checker.py
  • comfy_cli/error_codes.py
  • comfy_cli/file_utils.py
  • comfy_cli/registry/api.py
  • comfy_cli/schemas/assets_library.json
  • comfy_cli/skills/__init__.py
  • comfy_cli/skills/comfy-director/SKILL.md
  • comfy_cli/skills/comfy-fragments/SKILL.md
  • comfy_cli/skills/comfy-relay/SKILL.md
  • comfy_cli/skills/comfy/SKILL.md
  • comfy_cli/skills/command.py
  • comfy_cli/standalone.py
  • comfy_cli/tracking.py
  • comfy_cli/ui.py
  • comfy_cli/utils.py
  • comfy_cli/where.py
  • comfy_cli/workflow_ops.py
  • comfy_cli/workflow_to_api.py
  • comfy_cli/workspace_manager.py
  • pyproject.toml
  • tests/comfy_cli/command/generate/fixtures/partner_nodes_object_info.json
  • tests/comfy_cli/command/generate/test_emit.py
  • tests/comfy_cli/command/github/test_pr.py
  • tests/comfy_cli/command/test_code_search.py
  • tests/comfy_cli/command/test_run.py
  • tests/comfy_cli/command/test_run_watcher.py
  • tests/comfy_cli/command/test_workflow_edit.py
  • tests/comfy_cli/command/test_workflow_edit_cloud.py
  • tests/comfy_cli/conftest.py
  • tests/comfy_cli/cql/test_engine.py
  • tests/comfy_cli/cql/test_loader_resilient.py
  • tests/comfy_cli/cql/test_loader_ttl.py
  • tests/comfy_cli/cql/test_object_info_env.py
  • tests/comfy_cli/skills/test_installer.py
  • tests/comfy_cli/test_credentials.py
  • tests/comfy_cli/test_env_checker.py
  • tests/comfy_cli/test_standalone.py
  • tests/comfy_cli/test_tracking.py
  • tests/comfy_cli/test_tracking_providers.py
  • tests/comfy_cli/test_utils.py
  • tests/comfy_cli/test_validate_lowers_ui.py
  • tests/comfy_cli/test_workflow_to_api.py
  • tests/e2e/verify_tracking_live.py
💤 Files with no reviewable changes (3)
  • comfy_cli/skills/comfy-fragments/SKILL.md
  • comfy_cli/skills/command.py
  • comfy_cli/skills/init.py

Comment thread comfy_cli/cmdline.py
Comment thread comfy_cli/command/assets_library.py
Comment thread comfy_cli/command/workflow_edit.py Outdated
Comment thread comfy_cli/command/workflow_edit.py
Comment thread comfy_cli/skills/comfy/SKILL.md Outdated
Comment thread comfy_cli/workflow_ops.py
Comment thread comfy_cli/workflow_ops.py
Comment thread comfy_cli/workflow_ops.py Outdated
Comment thread tests/comfy_cli/cql/test_object_info_env.py
…branch

Fixes the two correctness bugs and the offline-catalog/validate contract
regressions surfaced by the high-effort review. Each fix carries a regression
test. The two intentional features flagged (env-catalog precedence; cache-first
TTL) are addressed by scoping the TTL, not removing it.

Widget indexing — node-aware, not first-key (silent corruption)
  Dynamic-combo (COMFY_DYNAMICCOMBO_V3) widget order was expanded from the
  schema's FIRST key, but widgets_values is laid out by the node's SELECTED key.
  When the selection expands to a different sub-widget count, set-widget/slots
  mis-indexed every widget after the combo (e.g. set-widget <id>.seed writing
  into model.resolution). Add Graph.widget_order_for_node(class, widgets_values)
  which expands by the actual selection, and route every consumer that indexes
  into a real node's widgets_values through it (_widget_index + its callers,
  engine slots, subgraph interior read/write, recipe capture). It delegates to
  the static order when there's no dynamic combo or no selection.

UI→API converter — don't steal the next COMBO's value (dropped widget value)
  The implicit seed companion heuristic consumed the next value for ANY
  seed-substring INT whenever that value equaled a control keyword, dropping a
  legitimate widget value. Peek at the next widget input: when it's a COMBO that
  legitimately lists the value as an option, it's that combo's value, not a
  phantom control_after_generate marker — keep it.

validate — build the graph from the SAME env-aware catalog it lowers with
  validate built its Graph via Graph.load (live fetch, ignored
  COMFY_OBJECT_INFO_FILE) while canvas-lowering used resilient_load_object_info
  (which honors it). Resolve object_info ONCE through the shared loader, build the
  graph from it, and reuse it for lowering — consistent catalog, no double fetch.

workflow edit — bad --where returns an envelope, not a traceback
  resolve_default(where) raises ValueError on a bad --where, but _get_graph only
  caught LoadError, so it escaped as a raw traceback out of every edit command.
  Catch it and emit the where_invalid envelope.

preview — classify unknown media as unknown, not video
  With only imageio-ffmpeg's static ffmpeg (no ffprobe), _classify_by_ext
  defaulted every unrecognized extension to "video" and handed it to ffmpeg. Add
  a video-extension set so non-media returns "unknown" → the clean
  preview_unsupported_media envelope, matching the ffprobe path.

object_info cache — cache-first TTL is cloud-only
  A cached local catalog hid a just-installed node for the whole TTL. The cloud
  catalog is stable and its fetch is slow (real cache win); the localhost fetch
  is cheap and freshness matters, so local always fetches live. The stale-cache
  failure fallback still applies to both.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@skishore23

Copy link
Copy Markdown
Contributor Author

Addressed high/medium review findings (baf71ad)

A high-effort multi-agent review flagged findings on this branch. The two correctness bugs and the offline-catalog/validate contract issues are fixed here, each with a regression test.

# Sev Finding Fix
1 High Dynamic-combo widget order expanded by the schema's first key, so set-widget/slots mis-indexed widgets after the combo (e.g. <id>.seedmodel.resolution) New Graph.widget_order_for_node(class, widgets_values) expands by the node's selected key; routed every consumer that indexes into a real node's widgets_values through it
2 High UI→API converter consumed the next value for any seed-substring INT whenever it equaled a control keyword, dropping a legitimate widget value Peek at the next widget input — when it's a COMBO that legitimately lists the value as an option, keep it (not a phantom control_after_generate marker)
5 Med validate built its graph via Graph.load (ignored COMFY_OBJECT_INFO_FILE) while lowering honored it Resolve object_info once through the shared env-aware loader, build the graph from it, reuse it for lowering
6 Med Bad --where raised an uncaught ValueError out of every edit command Catch it in _get_graph and emit the where_invalid envelope
7 Med With only imageio-ffmpeg (no ffprobe), _classify_by_ext defaulted non-media to "video" → raw ffmpeg error Added a video-extension set; unrecognized → "unknown" → clean preview_unsupported_media
4 Med Cache-first TTL served a stale local catalog for up to 10 min, hiding just-installed nodes Cache-first TTL is now cloud-only (stable catalog, slow fetch); local always fetches live. Stale-cache failure fallback still applies to both

#3 (COMFY_OBJECT_INFO_FILE precedence) intentionally left as-is — it's the documented explicit-override behavior for agent hosts, like --input.

The Low papercuts (malformed --at, delete-node envelope command field) and cleanup findings (cloud-HTTP duplication, apply_cmd serialize duplication, O(N²) op replay) are not addressed here.

@coderabbitai coderabbitai Bot requested a review from mattmillerai July 14, 2026 07:14
skishore23 and others added 3 commits July 14, 2026 00:15
CI pins ruff==0.15.15, which line-wraps a few long signatures/comprehensions
differently than the locally-installed 0.15.12. Purely cosmetic; no logic change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CodeQL (py/weak-sensitive-data-hashing) flags SHA-1 hashing of an id. The fork
id is a deterministic derivation, not a security boundary, but SHA-256 is an
equally deterministic drop-in and clears the alert.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
test_every_raised_code_is_registered failed: workflow_ops.py raises the
normalized_value warning code (nearest-COMBO match in set-widget) but it was
never added to error_codes.REGISTRY. This was already red on the feature commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
comfy_cli/cql/loader.py (1)

417-435: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Docstring's "Resolution order" step 2 doesn't mention the cloud-only restriction.

The public docstring says the cache-first TTL gate applies generically, but the code right below (458-469) restricts it to mode == "cloud". A reader skimming just the docstring (the contract most callers/maintainers will read) would miss that local always fetches live.

📝 Proposed docstring tweak
-    2. Cache-first TTL gate: a per-host cache entry younger than the TTL
-       (default 10 minutes; ``COMFY_OBJECT_INFO_TTL`` seconds to override,
-       ``0`` to always fetch live) is returned with NO network call.
+    2. Cache-first TTL gate (CLOUD ONLY): a per-host cache entry younger than
+       the TTL (default 10 minutes; ``COMFY_OBJECT_INFO_TTL`` seconds to
+       override, ``0`` to always fetch live) is returned with NO network
+       call. Local mode always fetches live so newly-installed nodes are
+       visible immediately.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@comfy_cli/cql/loader.py` around lines 417 - 435, The docstring for the
object-info loading function should state that the cache-first TTL gate applies
only when mode == "cloud"; clarify that local mode always performs a live fetch
while preserving the existing cache behavior for cloud mode.
comfy_cli/cmdline.py (1)

981-1009: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Validate explicit --where before loading

  • mode = where bypasses the resolve_default() / ValueError handling used in comfy_cli/command/workflow.py, so a bad --where still bubbles up from resolve_target() as a raw traceback. Route this through the same where_invalid envelope path to keep the typo gremlin from making a mess.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@comfy_cli/cmdline.py` around lines 981 - 1009, Validate an explicit --where
value before calling resilient_load_object_info in the mode-selection block.
Reuse the existing where resolution and where_invalid error-envelope behavior
from workflow.py, ensuring invalid values produce the structured renderer error
and exit instead of allowing resolve_target() to raise a raw traceback; preserve
default resolution for omitted --where values.
♻️ Duplicate comments (1)
comfy_cli/command/workflow_edit.py (1)

520-535: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

foreach still isn't atomic on partial failure — written files aren't surfaced.

If param-set #i (i>0) fails, workflows for #0..i-1 are already on disk in out_dir, but the except block still only reports the failure message, not written. Same gap flagged previously — a caller can't tell partial output exists without ls-ing the directory themselves. A rhyme to remember it by: fail midway, and files still stay — but no hint tells the caller today.

🛡️ Proposed fix — surface partial progress on failure
     except (workflow_ops.RecipeError, ValueError, KeyError) as e:
-        renderer.error(code="workflow_edit_invalid", message=f"foreach failed: {e}")
+        renderer.error(
+            code="workflow_edit_invalid",
+            message=f"foreach failed: {e}",
+            hint=f"{len(written)} workflow(s) were already written to {out} before the failure: {written}",
+        )
         raise typer.Exit(code=1) from e
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@comfy_cli/command/workflow_edit.py` around lines 520 - 535, Update the
foreach exception handler around written and the
workflow_ops.RecipeError/ValueError/KeyError catch to include the
already-written output paths in the rendered error message when partial progress
exists. Preserve the existing failure exit behavior and clearly indicate that
the listed files remain on disk.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@comfy_cli/command/workflow_edit.py`:
- Around line 93-98: Introduce shared Annotated option aliases near the command
definitions for the duplicated where, input, host, port, and actor options,
following the proposed WhereOpt, InputOpt, HostOpt, PortOpt, and ActorOpt
symbols. Replace the repeated declarations across add_node_cmd, set_widget_cmd,
connect_cmd, delete_cmd, capture_cmd, apply_cmd, and foreach_cmd with those
aliases, while preserving each option’s existing names, defaults, and help text;
include equivalent aliases for the remaining duplicated base-version and
stdout/in-place options.

---

Outside diff comments:
In `@comfy_cli/cmdline.py`:
- Around line 981-1009: Validate an explicit --where value before calling
resilient_load_object_info in the mode-selection block. Reuse the existing where
resolution and where_invalid error-envelope behavior from workflow.py, ensuring
invalid values produce the structured renderer error and exit instead of
allowing resolve_target() to raise a raw traceback; preserve default resolution
for omitted --where values.

In `@comfy_cli/cql/loader.py`:
- Around line 417-435: The docstring for the object-info loading function should
state that the cache-first TTL gate applies only when mode == "cloud"; clarify
that local mode always performs a live fetch while preserving the existing cache
behavior for cloud mode.

---

Duplicate comments:
In `@comfy_cli/command/workflow_edit.py`:
- Around line 520-535: Update the foreach exception handler around written and
the workflow_ops.RecipeError/ValueError/KeyError catch to include the
already-written output paths in the rendered error message when partial progress
exists. Preserve the existing failure exit behavior and clearly indicate that
the listed files remain on disk.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b8d5ccaf-0850-4ed6-8940-e3a12592cb0e

📥 Commits

Reviewing files that changed from the base of the PR and between f795e39 and e24be64.

📒 Files selected for processing (17)
  • comfy_cli/cmdline.py
  • comfy_cli/command/assets_library.py
  • comfy_cli/command/preview.py
  • comfy_cli/command/workflow.py
  • comfy_cli/command/workflow_edit.py
  • comfy_cli/cql/engine.py
  • comfy_cli/cql/loader.py
  • comfy_cli/workflow_ops.py
  • comfy_cli/workflow_to_api.py
  • tests/comfy_cli/command/test_preview.py
  • tests/comfy_cli/command/test_run.py
  • tests/comfy_cli/command/test_workflow_edit.py
  • tests/comfy_cli/command/test_workflow_edit_cloud.py
  • tests/comfy_cli/cql/test_engine.py
  • tests/comfy_cli/cql/test_loader_ttl.py
  • tests/comfy_cli/cql/test_object_info_env.py
  • tests/comfy_cli/test_workflow_to_api.py

Comment thread comfy_cli/command/workflow_edit.py Outdated
Telemetry (comfy run):
- Successful CLOUD submissions never emitted execution_success: the cloud branch
  `return`ed after execute_cloud, skipping the try's `else`. Fall through instead
  so cloud matches local (execution_start → execution_success). Local unaffected.
- Record the RESOLVED routing target (cloud|local) on the execution events so a
  submission is attributable even when --where was defaulted (PostHog already
  tags source=cli; this adds which backend the workflow was submitted to).

CodeRabbit findings:
- apply_specs: reject a duplicate `as` alias instead of silently clobbering the
  earlier node; wrap a missing-field KeyError as "spec #i (op) is missing <field>".
- foreach: surface files already written (hint + details.written) on a mid-batch
  failure instead of leaving the caller blind to partial output.
- workflow_edit: extract the 7-way-duplicated Annotated option boilerplate
  (--where/--input/host/port/--actor/--base-version/--stdout) into shared aliases.
- SKILL.md: fix contradictory guidance — set-widget DOES resolve subgraph values
  (flat 57.text / nested 57/27.text); stop sending agents to set-slot/decompose.

Regression tests added for each behavioral change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor-review Request Cursor bot review enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants