ComfyUI connection, preflight and status panel (#34) #86

Merged
crowmaki merged 6 commits from issue-34-comfyui-preflight into main 2026-10-08 03:34:07 +00:00
Owner

Closes #34. Part of #24.

What

  • crates/fake-comfy (new dev-only crate): a scriptable in-process ComfyUI on a loopback port.
    • Speaks /system_stats, /object_info, /models and /models/<folder> (each also under /api) and WS /ws?clientId (a status greeting, plus send_event to push scripted frames).
    • Scripted from tests: version, node classes, combo inputs in either encoding ([[...]] or ["COMBO", {options}]), model files per folder, offline, and an unused address for a ComfyUI that was never started. It records every request.
    • Job endpoints join route later. It is a separate crate so src-tauri tests can use it too.
  • studio-core:
    • ComfyClient (comfy_client.rs): version, object_info, model folders over HTTP (ureq, no TLS).
    • ComfySettings (comfy_settings.rs): the address is an app setting in <config_dir>/comfyui.json, default http://127.0.0.1:8188. It is normalized (scheme added, trailing slash dropped) and refused when it is not http(s). This adds no migration.
    • preflight (preflight.rs): checks reachability, version >= 0.39.0, every template class_type, every fixed model file in its /api/models/<folder>, and every fixed combo value of the templates (model files and per-job bindings excluded). It returns Connection plus a WorkflowStatus per shipped workflow with NotReadyReasons. Missing nodes and models carry the manifest's pack/model name and download URL. A missing core node says to update ComfyUI. Path separators are normalized, because manifests use \. It only issues GETs and installs nothing.
  • Adapter: comfyui_address, set_comfyui_address, comfyui_preflight (run in spawn_blocking).
  • UI: the ComfyUI Section replaces its placeholder with the address field, "Check now", the connection line and a table of the five workflows as Ready or Not ready with reasons and download links. The status bar LED and popover show the same state. Preflight runs when a window starts, when the address is saved and on demand.
  • Not built here: the WebSocket client and the job's profile-file check. Both arrive with the queue (#18 and later). Preflight "before each submission" is the queue's call into preflight.

Tests

  • crates/studio-core/tests/comfyui_preflight.rs (13): Ready, missing node pack (name and URL), missing core node, missing model (folder, name, URL), missing combo value, old version (and newer or suffixed versions pass), offline and recovery, never started, read-only requests, separator normalization.
  • comfyui_settings.rs (3), unit tests for version parsing and both combo encodings, crates/fake-comfy/tests/protocol.rs (5, including the WebSocket), an adapter smoke test, and src/lib/comfyui/summary.test.ts (4).
  • cargo test --workspace --all-features, bun run test and bun run check pass. The UI has been type-checked only, not run in the app.

Notes

  • No DB migration, so there is nothing to renumber on merge.
  • cargo clippy -- -D warnings currently fails on main too (type_complexity at Hooks.open_window), and cargo fmt --check flags src-tauri/src/lib.rs. I left both alone.
Closes #34. Part of #24. ## What - `crates/fake-comfy` (new dev-only crate): a scriptable in-process ComfyUI on a loopback port. - Speaks `/system_stats`, `/object_info`, `/models` and `/models/<folder>` (each also under `/api`) and `WS /ws?clientId` (a status greeting, plus `send_event` to push scripted frames). - Scripted from tests: version, node classes, combo inputs in either encoding (`[[...]]` or `["COMBO", {options}]`), model files per folder, offline, and an unused address for a ComfyUI that was never started. It records every request. - Job endpoints join `route` later. It is a separate crate so `src-tauri` tests can use it too. - `studio-core`: - `ComfyClient` (`comfy_client.rs`): version, `object_info`, model folders over HTTP (ureq, no TLS). - `ComfySettings` (`comfy_settings.rs`): the address is an **app setting** in `<config_dir>/comfyui.json`, default `http://127.0.0.1:8188`. It is normalized (scheme added, trailing slash dropped) and refused when it is not http(s). This adds no migration. - `preflight` (`preflight.rs`): checks reachability, version >= 0.39.0, every template `class_type`, every fixed model file in its `/api/models/<folder>`, and every fixed combo value of the templates (model files and per-job bindings excluded). It returns Connection plus a `WorkflowStatus` per shipped workflow with `NotReadyReason`s. Missing nodes and models carry the manifest's pack/model name and download URL. A missing core node says to update ComfyUI. Path separators are normalized, because manifests use `\`. It only issues GETs and installs nothing. - Adapter: `comfyui_address`, `set_comfyui_address`, `comfyui_preflight` (run in `spawn_blocking`). - UI: the ComfyUI Section replaces its placeholder with the address field, "Check now", the connection line and a table of the five workflows as Ready or Not ready with reasons and download links. The status bar LED and popover show the same state. Preflight runs when a window starts, when the address is saved and on demand. - Not built here: the WebSocket client and the job's profile-file check. Both arrive with the queue (#18 and later). Preflight "before each submission" is the queue's call into `preflight`. ## Tests - `crates/studio-core/tests/comfyui_preflight.rs` (13): Ready, missing node pack (name and URL), missing core node, missing model (folder, name, URL), missing combo value, old version (and newer or suffixed versions pass), offline and recovery, never started, read-only requests, separator normalization. - `comfyui_settings.rs` (3), unit tests for version parsing and both combo encodings, `crates/fake-comfy/tests/protocol.rs` (5, including the WebSocket), an adapter smoke test, and `src/lib/comfyui/summary.test.ts` (4). - `cargo test --workspace --all-features`, `bun run test` and `bun run check` pass. The UI has been type-checked only, not run in the app. ## Notes - No DB migration, so there is nothing to renumber on merge. - `cargo clippy -- -D warnings` currently fails on `main` too (`type_complexity` at `Hooks.open_window`), and `cargo fmt --check` flags `src-tauri/src/lib.rs`. I left both alone.
# Conflicts:
#	crates/studio-core/src/lib.rs
#	src-tauri/src/api.rs
#	src-tauri/src/dto.rs
#	src/lib/bindings.ts
crowmaki deleted branch issue-34-comfyui-preflight 2026-10-08 03:34:07 +00:00
Sign in to join this conversation.
No description provided.