Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(comfy): connect to a running ComfyUI at launch, start one only when asked; follow Comfy Desktop on 8000

purple66bef9687baf
diff --git a/docs/guide/settings-and-troubleshooting/index.html b/docs/guide/settings-and-troubleshooting/index.html
index 648b51e5..c24e7a59 100644
--- a/docs/guide/settings-and-troubleshooting/index.html
+++ b/docs/guide/settings-and-troubleshooting/index.html
@@ -99,7 +99,7 @@
<tr><td>Model Storage</td><td>Three rows. "LU Engine folder" with "Browse…" and "Reset": the app downloads GGUF files here and reads every .gguf in a folder you set, up to four levels down. "LM Studio folder" (read only, shown when LM Studio is installed). "Ollama" keeps its own model store. "Scan for local models" finds files from other tools and "Import" links them into LU's own model folder without copying, also when you set another LU Engine folder.</td></tr>
<tr><td>CivitAI API key, Hugging Face token</td><td>Keys for downloads those sites refuse without a login ("a gated repository refuses the download with HTTP 401. A free read token is enough").</td></tr>
<tr><td>LU Engine (expert)</td><td>"Context length (tokens)" (0 = default 8192), "Flash attention" (auto, on, off), "KV cache" K and V types, "CPU threads" (-1 = auto), "GPU layers" ("-1 = all layers on GPU · 0 = CPU only · N = partial offload for models bigger than your VRAM."), "Lock model in RAM (mlock)", "Load fully into RAM (disable mmap)", and "Apply &amp; Restart Engine". The line under the heading shows "Port: 8127", "Port: 8130 (8127 was taken)" or "Engine not running".</td></tr>
-<tr><td>ComfyUI (Image &amp; Video)</td><td>Status (Running, Not responding, Starting, Stopped, Not Installed), Host and Path with "Connect", Port with "Set" (8188 by default; "Port saved. Restart ComfyUI to apply."), and the buttons "Start", "Stop", "Restart", "Repair environment", "Install ComfyUI" or "Re-install ComfyUI", "Update ComfyUI" and "Cancel" while a job runs. The note "Installs to your home folder by default. Set Path above (e.g. D:\ComfyUI) to install on another drive." Chapter 7.</td></tr>
+<tr><td>ComfyUI (Image &amp; Video)</td><td>Status (Running, Not responding, Starting, Stopped, Not Installed), Host and Path with "Connect", Port with "Set" (8188 by default; "Port saved. Restart ComfyUI to apply."; with no port saved, LU follows a ComfyUI Desktop that answers on 8000), the switch "Start ComfyUI when LU starts" (off unless LU installed this ComfyUI itself: at launch LU only connects to a ComfyUI that is already running and starts one only on Start or when you create something), and the buttons "Start", "Stop", "Restart", "Repair environment", "Install ComfyUI" or "Re-install ComfyUI", "Update ComfyUI" and "Cancel" while a job runs. The note "Installs to your home folder by default. Set Path above (e.g. D:\ComfyUI) to install on another drive." Chapter 7.</td></tr>
</table>
<h3>Agent</h3>
diff --git a/src-tauri/src/commands/install/comfy_install.rs b/src-tauri/src/commands/install/comfy_install.rs
index 71ad3a70..60d62953 100644
--- a/src-tauri/src/commands/install/comfy_install.rs
+++ b/src-tauri/src/commands/install/comfy_install.rs
@@ -746,6 +746,9 @@ pub fn install_comfyui(
.and_then(|s| serde_json::from_str(&s).ok())
.unwrap_or_else(|| serde_json::json!({}));
config["comfyui_path"] = serde_json::json!(dir_str);
+ // An install the user asked LU to make is one LU may start with
+ // itself (comfy_boot_plan). A ComfyUI LU merely found is not.
+ config["comfyui_autostart"] = serde_json::json!(true);
let _ = std::fs::write(
&config_file,
serde_json::to_string_pretty(&config).unwrap_or_default(),
diff --git a/src-tauri/src/commands/mobile_guard.rs b/src-tauri/src/commands/mobile_guard.rs
index 0d0c1b93..f84ffdb3 100644
--- a/src-tauri/src/commands/mobile_guard.rs
+++ b/src-tauri/src/commands/mobile_guard.rs
@@ -139,6 +139,7 @@ pub const ALLOWED: &[&str] = &[
"set_comfy_gpu_mode",
"get_comfy_gpu_status",
"set_comfyui_port",
+ "set_comfyui_autostart",
"set_comfyui_host",
"set_ollama_host",
"get_ollama_host",
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index c0c0ae51..db7ac086 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -2730,7 +2730,9 @@ pub fn comfyui_last_output(state: State<'_, AppState>) -> Result<serde_json::Val
#[tauri::command]
pub async fn comfyui_status(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
- let port = *state.comfy_port.lock().unwrap();
+ // B9: a Comfy Desktop that came up after LU is found on the panel's next
+ // poll, not only at the next launch.
+ let port = follow_comfy_port_async(&state).await;
let host = state.comfy_host.lock().unwrap().clone();
let is_local = is_local_host(&host);
@@ -2847,6 +2849,8 @@ pub async fn comfyui_status(state: State<'_, AppState>) -> Result<serde_json::Va
// tell an LU-owned ComfyUI (this run's, or an earlier run's orphan)
// from one this app never started -- see `classify_comfyui_ownership`.
"ownedByApp": owned_by_app,
+ // The "Start ComfyUI when LU starts" switch (comfy_boot_plan).
+ "autostart": comfy_autostart_enabled(),
}))
}
@@ -3230,7 +3234,189 @@ pub fn auto_start_ollama(state: &AppState) {
}
}
-/// Auto-start ComfyUI on app launch (called from setup)
+/// What the boot path does with the local ComfyUI.
+///
+/// Until 3.0.9 the boot path started whatever ComfyUI the disk search found,
+/// unasked. The search finds the user's own installs too (`~/ComfyUI`, Comfy
+/// Desktop, Stability Matrix), and on the box click-through of 27.10.2026 LU
+/// brought up the owner's own ComfyUI from his home folder unasked. A
+/// ComfyUI that already answers is used as it is; one that does not is only
+/// started when the user said so (`comfyui_autostart` in config.json, the
+/// "Start ComfyUI when LU starts" switch, which LU's own installer turns on).
+/// Everything else waits for a click: Start in Settings, or the first job in
+/// Create, which starts it on demand.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub(crate) enum ComfyBootPlan {
+ /// Something answers on the port: connect, start nothing.
+ Connect,
+ /// Installed, not running, and the user wants it started with LU.
+ Start,
+ /// Installed and not running, and nobody asked for a start.
+ LeaveStopped,
+ /// No install found: nothing to start.
+ NoInstall,
+}
+
+pub(crate) fn comfy_boot_plan(running: bool, install_found: bool, autostart: bool) -> ComfyBootPlan {
+ if running {
+ ComfyBootPlan::Connect
+ } else if !install_found {
+ ComfyBootPlan::NoInstall
+ } else if autostart {
+ ComfyBootPlan::Start
+ } else {
+ ComfyBootPlan::LeaveStopped
+ }
+}
+
+/// The user's "Start ComfyUI when LU starts" switch. Off unless set: a missing
+/// key is an install nobody has told LU anything about.
+pub(crate) fn comfy_autostart_enabled() -> bool {
+ read_app_config()
+ .and_then(|c| c.get("comfyui_autostart").and_then(|v| v.as_bool()))
+ .unwrap_or(false)
+}
+
+/// Whether the user ever saved a ComfyUI port. Only an unset port may follow
+/// a ComfyUI that answers somewhere else (Comfy Desktop, port 8000).
+fn comfy_port_user_set() -> bool {
+ read_app_config().is_some_and(|c| c.get("comfyui_port").is_some())
+}
+
+fn read_app_config() -> Option<serde_json::Value> {
+ let raw = fs::read_to_string(crate::os_paths::app_config_json()).ok()?;
+ serde_json::from_str(&raw).ok()
+}
+
+/// Write one key into config.json, keeping the rest.
+pub(crate) fn write_app_config_key(key: &str, value: serde_json::Value) {
+ let app_config = crate::os_paths::app_config_dir();
+ let _ = fs::create_dir_all(&app_config);
+ let config_file = app_config.join("config.json");
+ let mut config = read_app_config().unwrap_or_else(|| serde_json::json!({}));
+ config[key] = value;
+ let _ = fs::write(&config_file, serde_json::to_string_pretty(&config).unwrap_or_default());
+}
+
+/// ComfyUI's default port, and the one Comfy Desktop serves on.
+pub(crate) const COMFY_DEFAULT_PORT: u16 = 8188;
+pub(crate) const COMFY_DESKTOP_PORT: u16 = 8000;
+
+/// Which port the app should talk to ComfyUI on.
+///
+/// Comfy Desktop (Comfy-Org/desktop) runs its server on 8000, not 8188 (B9).
+/// A user who never saved a port and runs Desktop got "ComfyUI not running"
+/// next to a ComfyUI that was running. A saved port is never second-guessed,
+/// and 8000 only wins when 8188 is silent and 8000 answers like a ComfyUI.
+pub(crate) fn pick_comfy_port(current: u16, user_set: bool, answers: impl Fn(u16) -> bool) -> u16 {
+ if user_set {
+ return current;
+ }
+ if answers(current) {
+ return current;
+ }
+ for candidate in [COMFY_DEFAULT_PORT, COMFY_DESKTOP_PORT] {
+ if candidate != current && answers(candidate) {
+ return candidate;
+ }
+ }
+ // Neither answers: back to the default, so a start LU makes itself does
+ // not land on Desktop's port after Desktop was closed.
+ COMFY_DEFAULT_PORT
+}
+
+/// `/system_stats` answers AND looks like ComfyUI's. Port 8000 is every dev
+/// server's favourite, and a 200 from one of them is not a ComfyUI.
+pub(crate) fn looks_like_comfyui_on_port(port: u16) -> bool {
+ let Ok(client) = reqwest::blocking::Client::builder()
+ .timeout(std::time::Duration::from_secs(2))
+ .build()
+ else {
+ return false;
+ };
+ client
+ .get(format!("http://localhost:{port}/system_stats"))
+ .send()
+ .ok()
+ .filter(|r| r.status().is_success())
+ .and_then(|r| r.json::<serde_json::Value>().ok())
+ .is_some_and(|v| is_comfy_system_stats(&v))
+}
+
+pub(crate) fn is_comfy_system_stats(v: &serde_json::Value) -> bool {
+ v.get("system").is_some_and(|s| s.is_object()) && v.get("devices").is_some_and(|d| d.is_array())
+}
+
+/// Follow a ComfyUI that answers on the other well-known port, for a local
+/// host with no saved port. Returns the port now in use.
+pub(crate) fn follow_comfy_port(state: &AppState) -> u16 {
+ let current = *state.comfy_port.lock().unwrap();
+ let host = state.comfy_host.lock().unwrap().clone();
+ if !is_local_host(&host) {
+ return current;
+ }
+ let picked = pick_comfy_port(current, comfy_port_user_set(), looks_like_comfyui_on_port);
+ if picked != current {
+ println!("[ComfyUI] Answers on port {picked}, not {current} (no port saved) — following it");
+ *state.comfy_port.lock().unwrap() = picked;
+ crate::commands::comfy_folders::forget();
+ }
+ picked
+}
+
+/// `follow_comfy_port` for the async status poll: the same decision, the
+/// probes over the async client, and only one probe while the current port
+/// answers.
+async fn follow_comfy_port_async(state: &AppState) -> u16 {
+ let current = *state.comfy_port.lock().unwrap();
+ let host = state.comfy_host.lock().unwrap().clone();
+ if !is_local_host(&host) || comfy_port_user_set() {
+ return current;
+ }
+ let Ok(client) = reqwest::Client::builder().timeout(std::time::Duration::from_secs(2)).build() else {
+ return current;
+ };
+ let probe = |port: u16| {
+ let client = client.clone();
+ async move {
+ match client.get(format!("http://localhost:{port}/system_stats")).send().await {
+ Ok(r) if r.status().is_success() => {
+ r.json::<serde_json::Value>().await.is_ok_and(|v| is_comfy_system_stats(&v))
+ }
+ _ => false,
+ }
+ }
+ };
+ let mut answering: Vec<u16> = Vec::new();
+ if probe(current).await {
+ answering.push(current);
+ } else {
+ for candidate in [COMFY_DEFAULT_PORT, COMFY_DESKTOP_PORT] {
+ if candidate != current && probe(candidate).await {
+ answering.push(candidate);
+ break;
+ }
+ }
+ }
+ let picked = pick_comfy_port(current, false, |p| answering.contains(&p));
+ if picked != current {
+ println!("[ComfyUI] Answers on port {picked}, not {current} (no port saved) — following it");
+ *state.comfy_port.lock().unwrap() = picked;
+ crate::commands::comfy_folders::forget();
+ }
+ picked
+}
+
+/// The "Start ComfyUI when LU starts" switch in Settings.
+#[tauri::command]
+pub fn set_comfyui_autostart(enabled: bool) -> Result<serde_json::Value, String> {
+ write_app_config_key("comfyui_autostart", serde_json::json!(enabled));
+ println!("[ComfyUI] Start with LU: {}", if enabled { "on" } else { "off" });
+ Ok(serde_json::json!({"status": "saved", "autostart": enabled}))
+}
+
+/// Boot path for ComfyUI on app launch (called from setup). Connects to a
+/// running one, starts one only per `comfy_boot_plan`.
pub fn auto_start_comfyui(state: &AppState) {
// Hard rule: macOS local media is MLX only, NEVER ComfyUI (see
// commands::mlx / commands::video). Auto-starting ComfyUI on Mac violated
@@ -3258,9 +3444,12 @@ pub fn auto_start_comfyui(state: &AppState) {
}
}
- let port = *state.comfy_port.lock().unwrap();
+ let port = follow_comfy_port(state);
+ let running = is_comfyui_running_on_port(port);
+ let found = if running { None } else { find_comfyui_path() };
+ let plan = comfy_boot_plan(running, found.is_some(), comfy_autostart_enabled());
- if is_comfyui_running_on_port(port) {
+ if plan == ComfyBootPlan::Connect {
// T-68: a ComfyUI on our port at launch is either the user's own or an
// orphan this app left behind when it was killed. Naming which one in
// the log is what makes a later "Stop did nothing" diagnosable.
@@ -3272,8 +3461,15 @@ pub fn auto_start_comfyui(state: &AppState) {
}
return;
}
+ if plan == ComfyBootPlan::LeaveStopped {
+ println!(
+ "[ComfyUI] Found at {}, not running — not started (Start ComfyUI when LU starts is off)",
+ found.as_deref().unwrap_or("?")
+ );
+ return;
+ }
- match find_comfyui_path() {
+ match found {
Some(path) => {
let port_str = port.to_string();
println!("[ComfyUI] Auto-starting from: {} on port {}", path, port);
@@ -3427,6 +3623,107 @@ pub fn auto_start_comfyui(state: &AppState) {
}
}
+#[cfg(test)]
+mod comfy_boot_tests {
+ use super::*;
+
+ /// Box click-through 27.10.2026: David's own ComfyUI, found by the disk
+ /// search and not running, was started by LU at launch. Found but not
+ /// asked for is LeaveStopped now.
+ #[test]
+ fn a_found_comfyui_is_not_started_unasked() {
+ assert_eq!(comfy_boot_plan(false, true, false), ComfyBootPlan::LeaveStopped);
+ }
+
+ #[test]
+ fn a_running_comfyui_is_used_and_never_started() {
+ assert_eq!(comfy_boot_plan(true, true, false), ComfyBootPlan::Connect);
+ assert_eq!(comfy_boot_plan(true, true, true), ComfyBootPlan::Connect);
+ assert_eq!(comfy_boot_plan(true, false, false), ComfyBootPlan::Connect);
+ }
+
+ #[test]
+ fn the_switch_starts_it_and_nothing_to_start_stays_nothing() {
+ assert_eq!(comfy_boot_plan(false, true, true), ComfyBootPlan::Start);
+ assert_eq!(comfy_boot_plan(false, false, true), ComfyBootPlan::NoInstall);
+ }
+
+ /// The boot path has to ask the plan before it spawns. A plan nobody
+ /// calls would leave these tests green over the old behaviour.
+ #[test]
+ fn the_boot_path_asks_the_plan_before_any_spawn() {
+ let src = include_str!("process.rs");
+ let body = &src[src.find("pub fn auto_start_comfyui(").unwrap()..];
+ let body = &body[..body.find("\n}\n").unwrap()];
+ let plan = body.find("comfy_boot_plan(").expect("auto_start_comfyui does not ask comfy_boot_plan");
+ let leave = body.find("ComfyBootPlan::LeaveStopped").expect("LeaveStopped is not handled");
+ let spawn = body.find(".spawn()").expect("no spawn in auto_start_comfyui");
+ assert!(plan < spawn && leave < spawn);
+ assert!(body.contains("comfy_autostart_enabled()"));
+ }
+
+ #[test]
+ fn lus_own_installer_turns_the_switch_on() {
+ let src = include_str!("install/comfy_install.rs");
+ assert!(src.contains(r#"config["comfyui_autostart"] = serde_json::json!(true)"#));
+ }
+
+ /// B9: Comfy Desktop serves on 8000.
+ #[test]
+ fn desktop_on_8000_is_followed_when_no_port_is_saved() {
+ assert_eq!(pick_comfy_port(8188, false, |p| p == 8000), 8000);
+ }
+
+ #[test]
+ fn a_saved_port_is_never_second_guessed() {
+ assert_eq!(pick_comfy_port(8188, true, |p| p == 8000), 8188);
+ assert_eq!(pick_comfy_port(9000, true, |_| false), 9000);
+ }
+
+ #[test]
+ fn the_default_wins_when_both_answer_and_silence_goes_back_to_8188() {
+ assert_eq!(pick_comfy_port(8188, false, |_| true), 8188);
+ assert_eq!(pick_comfy_port(8000, false, |p| p == 8188), 8188);
+ assert_eq!(pick_comfy_port(8000, false, |_| false), 8188);
+ assert_eq!(pick_comfy_port(8000, false, |p| p == 8000), 8000);
+ }
+
+ /// One HTTP answer on a free local port, the way a server would give it.
+ fn answer_once(body: &'static str) -> u16 {
+ use std::io::{Read, Write};
+ let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
+ let port = listener.local_addr().unwrap().port();
+ std::thread::spawn(move || {
+ if let Ok((mut s, _)) = listener.accept() {
+ let mut buf = [0u8; 2048];
+ let _ = s.read(&mut buf);
+ let _ = write!(s, "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}", body.len(), body);
+ }
+ });
+ port
+ }
+
+ /// Over a real socket: a ComfyUI's /system_stats counts, another server's
+ /// 200 on the same path does not, and a silent port is no ComfyUI.
+ #[test]
+ fn the_probe_tells_a_comfyui_from_another_server_over_http() {
+ let comfy = answer_once(r#"{"system":{"os":"posix","comfyui_version":"0.3.60"},"devices":[{"name":"mps"}]}"#);
+ assert!(looks_like_comfyui_on_port(comfy));
+ let other = answer_once(r#"{"status":"ok"}"#);
+ assert!(!looks_like_comfyui_on_port(other));
+ let silent = std::net::TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap().port();
+ assert!(!looks_like_comfyui_on_port(silent));
+ }
+
+ #[test]
+ fn only_a_comfyui_shaped_answer_counts() {
+ let comfy = serde_json::json!({"system": {"os": "nt", "comfyui_version": "0.3.60"}, "devices": []});
+ assert!(is_comfy_system_stats(&comfy));
+ assert!(!is_comfy_system_stats(&serde_json::json!({"status": "ok"})));
+ assert!(!is_comfy_system_stats(&serde_json::json!({"system": "x", "devices": []})));
+ }
+}
+
#[cfg(test)]
mod utf8_start_waechter {
/// Dieselbe Regel wie in install.rs, eine Datei weiter.
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 83f5d4ed..0153e0ee 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -676,6 +676,7 @@ pub fn run() {
commands::process::get_comfy_gpu_status,
commands::process::comfy_torch_plan,
commands::process::set_comfyui_port,
+ commands::process::set_comfyui_autostart,
commands::process::set_comfyui_host,
commands::process::set_ollama_host,
commands::process::get_ollama_host,
diff --git a/src/api/backend.ts b/src/api/backend.ts
index 54b2e177..f3a32d8a 100644
--- a/src/api/backend.ts
+++ b/src/api/backend.ts
@@ -506,6 +506,7 @@ export async function backendCall<T = unknown>(
install_ollama: { path: "/local-api/install-ollama", method: "POST" },
install_ollama_status: { path: "/local-api/install-ollama-status" },
set_comfyui_port: { path: "/local-api/set-comfyui-port", method: "POST" },
+ set_comfyui_autostart: { path: "/local-api/set-comfyui-autostart", method: "POST" },
set_comfyui_host: { path: "/local-api/set-comfyui-host", method: "POST" },
set_ollama_host: { path: "/local-api/set-ollama-host", method: "POST" },
get_ollama_host: { path: "/local-api/get-ollama-host" },
diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsx
index 75322d20..9bf7b36d 100644
--- a/src/components/settings/SettingsPage.tsx
+++ b/src/components/settings/SettingsPage.tsx
@@ -757,6 +757,11 @@ interface ComfyStatusResponse {
* read as foreign after a restart, blocking Update on the customer's own
* process). */
ownedByApp?: boolean
+ /** 3.0.9: the "Start ComfyUI when LU starts" switch (`comfy_boot_plan` in
+ * `process.rs`). Off unless the user turned it on or LU installed this
+ * ComfyUI itself; a ComfyUI LU only found is no longer started at launch.
+ * The dev server does not send it. */
+ autostart?: boolean
}
/** Antwort von `comfyui_last_output` (`process.rs`). Alle vier Schluessel
@@ -1276,6 +1281,34 @@ export function ComfyUISettings() {
)}
</div>
+ {/* 3.0.9: at launch LU only connects to a ComfyUI that already runs.
+ Box click-through 27.10.2026: it used to start whatever install the
+ disk search found, the user's own included, without asking. */}
+ {status?.isLocal !== false && status?.found && (
+ <label className="flex items-start justify-between gap-3 cursor-pointer">
+ <span>
+ <span className="block t-micro text-gray-300">Start ComfyUI when LU starts</span>
+ <span className={`block t-micro leading-relaxed ${HINWEIS_TEXT.ruhig}`}>
+ Off: LU uses a ComfyUI that is already running and starts this one only when you click Start or create something.
+ </span>
+ </span>
+ <input
+ type="checkbox"
+ aria-label="Start ComfyUI when LU starts"
+ checked={status?.autostart === true}
+ onChange={async (e) => {
+ const enabled = e.target.checked
+ const { backendCall } = await import('../../api/backend')
+ try {
+ await backendCall('set_comfyui_autostart', { enabled })
+ setStatus(prev => prev ? { ...prev, autostart: enabled } : prev)
+ } catch { /* the next status poll shows what was actually saved */ }
+ }}
+ className="mt-0.5 accent-emerald-500"
+ />
+ </label>
+ )}
+
{/* Controls, local host only (can't manage a remote process) */}
{status?.isLocal !== false && (
<div className="flex items-center gap-1.5">
diff --git a/src/components/settings/__tests__/comfy-start-with-lu-switch.test.ts b/src/components/settings/__tests__/comfy-start-with-lu-switch.test.ts
new file mode 100644
index 00000000..05f046eb
--- /dev/null
+++ b/src/components/settings/__tests__/comfy-start-with-lu-switch.test.ts
@@ -0,0 +1,29 @@
+/**
+ * B12, box click-through 27.10.2026: LU started the user's own ComfyUI
+ * (his own install in the home folder) at launch without asking. The boot path now only
+ * connects (process.rs, comfy_boot_plan); starting with LU is a switch the
+ * user sets, and the panel has to offer it and send what it saves.
+ *
+ * Run: npx vitest run src/components/settings/__tests__/comfy-start-with-lu-switch.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { resolve } from 'node:path'
+
+const lies = (...teile: string[]) => readFileSync(resolve(__dirname, '..', '..', '..', '..', ...teile), 'utf8')
+
+describe('the switch for starting ComfyUI with LU', () => {
+ it('the panel has it and saves through the command Rust registers', () => {
+ const ui = lies('src', 'components', 'settings', 'SettingsPage.tsx')
+ expect(ui).toContain('Start ComfyUI when LU starts')
+ expect(ui).toMatch(/backendCall\('set_comfyui_autostart', \{ enabled \}\)/)
+ expect(ui).toMatch(/checked=\{status\?\.autostart === true\}/)
+ const lib = lies('src-tauri', 'src', 'lib.rs')
+ expect(lib).toContain('commands::process::set_comfyui_autostart')
+ })
+
+ it('the status reports it, so the switch shows what is saved', () => {
+ const rs = lies('src-tauri', 'src', 'commands', 'process.rs')
+ expect(rs).toMatch(/"autostart": comfy_autostart_enabled\(\)/)
+ })
+})