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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(comfyui): an update starts ComfyUI again when it is done
purple7a71709b46d1
diff --git a/src-tauri/src/commands/install/comfy_job.rs b/src-tauri/src/commands/install/comfy_job.rsindex 0379bdc8..41c9b3c5 100644--- a/src-tauri/src/commands/install/comfy_job.rs+++ b/src-tauri/src/commands/install/comfy_job.rs@@ -344,7 +344,7 @@ mod tests {for done in ["Install finished. ComfyUI is ready to start.","Repair finished. ComfyUI is ready.",- "Update finished. Restart ComfyUI to load the new nodes.",+ "Update finished. ComfyUI is starting again with the new nodes.",] {let (line, kind) = finished_notice(done, None);assert_eq!(line, done);diff --git a/src-tauri/src/commands/install/comfy_repair.rs b/src-tauri/src/commands/install/comfy_repair.rsindex d31af491..7c478a0c 100644--- a/src-tauri/src/commands/install/comfy_repair.rs+++ b/src-tauri/src/commands/install/comfy_repair.rs@@ -1267,23 +1267,39 @@ pub fn update_comfyui(state: State<'_, AppState>, app: tauri::AppHandle) -> Resu}println!("[Update] ComfyUI update complete");+ // The box, 03.10.2026: the guard at the top stopped LU's own ComfyUI,+ // and the run ended on "Restart ComfyUI to load the new nodes" with+ // the status on Stopped. It comes back up here, before `complete`:+ // the panel and a render that asked for this update both stop+ // watching on that word, and the render goes on as soon as the port+ // answers. A start that fails does not undo the update, it is said in+ // the closing line with its reason.+ update("installing", "Starting ComfyUI again...");+ let restarted = crate::commands::process::start_comfyui_blocking(&state).map(|_| ());+ let (done, restart_failed) = update_finished_line(&restarted);if let Ok(mut s) = install_status.lock() {- let (line, kind) = finished_notice(- "Update finished. Restart ComfyUI to load the new nodes.",- requirements_fallback.as_ref(),- );+ let (line, kind) = finished_notice(&done, requirements_fallback.as_ref());s.notice = line;- s.notice_kind = kind.to_string();+ s.notice_kind = if restart_failed { "warn" } else { kind }.to_string();}- update(- "complete",- "ComfyUI updated. Restart ComfyUI to load the new nodes.",- );+ update("complete", &done);});Ok(serde_json::json!({"status": "installing"}))}+/// The closing line of an update, and whether it is a warning: ComfyUI is on+/// its way up again, or it did not start and here is why.+fn update_finished_line(restarted: &Result<(), String>) -> (String, bool) {+ match restarted {+ Ok(()) => ("Update finished. ComfyUI is starting again with the new nodes.".to_string(), false),+ Err(reason) => (+ format!("Update finished, but ComfyUI did not start again. Press Start to try again.\n\n{reason}"),+ true,+ ),+ }+}+/// LU's own throwaway siblings inside a ComfyUI checkout, none of them named/// in ComfyUI's own `.gitignore`.///@@ -1920,7 +1936,7 @@ mod tests {{let mut install = state.install_status.lock().unwrap();install.status = "complete".to_string();- install.notice = "Update finished. Restart ComfyUI to load the new nodes.".to_string();+ install.notice = "Update finished. ComfyUI is starting again with the new nodes.".to_string();install.notice_kind = "ok".to_string();install.logs.push("a line from the run before this one".to_string());}@@ -2009,6 +2025,43 @@ mod tests {);}+ /// The box, 03.10.2026: the update stops LU's own ComfyUI before it+ /// touches the checkout and then ended on "Restart ComfyUI to load the+ /// new nodes" with the status on Stopped. Nothing restarted it, so the+ /// customer had to find the Start button, and a render that had asked for+ /// the update had nothing to continue on. Whoever stops it starts it+ /// again: after the environment check passed, before the run reports+ /// `complete` (the panel and Create stop watching on that word).+ #[test]+ fn a_finished_update_starts_comfyui_again_before_it_reports_complete() {+ let src = include_str!("comfy_repair.rs");+ let needle = |head: &str, tail: &str| format!("{head}{tail}");+ let body_start = src.find("pub fn update_comfyui(").expect("update_comfyui is gone");+ let body = &src[body_start..];+ let body = &body[..body.find("\n}\n").expect("update_comfyui has no end")];++ let at_check = body.find("verify_and_heal_environment(").expect("the update no longer checks the environment");+ let at_start = body+ .find(&needle("process::start_comfyui_bloc", "king(&state)"))+ .expect("the update does not start ComfyUI again");+ let at_complete = body.rfind(&needle("\"comp", "lete\"")).expect("the update never reports complete");+ assert!(at_check < at_start, "ComfyUI must not be started on an environment nobody checked");+ assert!(at_start < at_complete, "ComfyUI must be on its way up before the run reports complete");+ }++ #[test]+ fn the_closing_line_of_an_update_says_whether_comfyui_came_back() {+ let (line, warn) = update_finished_line(&Ok(()));+ assert_eq!(line, "Update finished. ComfyUI is starting again with the new nodes.");+ assert!(!warn);++ let (line, warn) = update_finished_line(&Err("ModuleNotFoundError: No module named 'av'".to_string()));+ assert!(line.starts_with("Update finished, but ComfyUI did not start again. Press Start to try again."), "got: {line}");+ assert!(line.ends_with("ModuleNotFoundError: No module named 'av'"), "the reason is missing: {line}");+ assert!(warn, "a ComfyUI that stayed down is not good news");+ assert!(!line.contains("Restart ComfyUI"), "the customer is no longer the one who restarts it: {line}");+ }+#[test]fn the_queue_is_checked_before_anything_is_stopped() {// box-gruen/n9 punkt 87, final review (B3): a check that runs AFTERdiff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rsindex 528be79f..be537f02 100644--- a/src-tauri/src/commands/process.rs+++ b/src-tauri/src/commands/process.rs@@ -1620,7 +1620,7 @@ pub async fn start_comfyui(app: tauri::AppHandle) -> Result<serde_json::Value, S.map_err(|e| format!("start_comfyui task: {e}"))?}-fn start_comfyui_blocking(state: &AppState) -> Result<serde_json::Value, String> {+pub(crate) fn start_comfyui_blocking(state: &AppState) -> Result<serde_json::Value, String> {let _gate = start_gate(&COMFY_START);// If user pointed LU at a remote ComfyUI, we have no local process to spawn.// Just report status — the remote side is responsible for running ComfyUI.diff --git a/src/api/__tests__/render-fixup-deps-update.test.ts b/src/api/__tests__/render-fixup-deps-update.test.tsnew file mode 100644index 00000000..c7fb31e2--- /dev/null+++ b/src/api/__tests__/render-fixup-deps-update.test.ts@@ -0,0 +1,71 @@+/**+ * The update a render asked for (lib/render-fixups.ts): the update itself+ * brings ComfyUI back up (update_comfyui in Rust starts it before it reports+ * complete), so the render only waits for the port and goes on. It never+ * needed a click on Start, and it does not start a second copy.+ *+ * Run: npx vitest run src/api/__tests__/render-fixup-deps-update.test.ts+ */+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'++const backendCall = vi.fn()+const checkComfyConnection = vi.fn()+const install = vi.hoisted(() => ({+ state: { phase: 'idle', logs: [] as string[], error: '', runUpdate: async () => undefined },+}))++vi.mock('../backend', async (orig) => ({+ ...((await orig()) as Record<string, unknown>),+ backendCall: (...a: unknown[]) => backendCall(...a),+}))+vi.mock('../comfyui', async (orig) => ({+ ...((await orig()) as Record<string, unknown>),+ checkComfyConnection: (...a: unknown[]) => checkComfyConnection(...a),+}))+vi.mock('../../stores/comfyInstallStore', () => ({+ useComfyInstallStore: { getState: () => install.state },+}))++import { renderFixupDeps } from '../render-fixup-deps'++beforeEach(() => {+ vi.useFakeTimers()+ backendCall.mockReset()+ checkComfyConnection.mockReset()+ install.state = { phase: 'idle', logs: [], error: '', runUpdate: async () => undefined }+})+afterEach(() => { vi.useRealTimers() })++describe('the update a render asked for', () => {+ it('goes on as soon as the updated ComfyUI answers, without starting it a second time', async () => {+ const lines: string[] = []+ // Still importing on the first two probes, then up.+ checkComfyConnection.mockResolvedValueOnce(false).mockResolvedValueOnce(false).mockResolvedValue(true)+ install.state.runUpdate = async () => { install.state.phase = 'comfyui'; install.state.logs = ['Step 1/3: Pulling the latest ComfyUI...'] }+ const done = renderFixupDeps((line) => lines.push(line)).updateComfy()+ await vi.advanceTimersByTimeAsync(2000)+ expect(lines).toContain('Step 1/3: Pulling the latest ComfyUI...')+ install.state.phase = 'idle'+ await vi.advanceTimersByTimeAsync(10_000)+ await expect(done).resolves.toBeUndefined()+ expect(checkComfyConnection).toHaveBeenCalledTimes(3)+ expect(backendCall.mock.calls.map((c) => c[0])).not.toContain('start_comfyui')+ })++ it('an update that failed ends the run with its reason', async () => {+ install.state.runUpdate = async () => { install.state.phase = 'error'; install.state.error = 'Updating ComfyUI did not finish. git pull failed.' }+ const done = renderFixupDeps(() => undefined).updateComfy()+ const failed = expect(done).rejects.toThrow('Updating ComfyUI did not finish. git pull failed.')+ await vi.advanceTimersByTimeAsync(2000)+ await failed+ expect(checkComfyConnection).not.toHaveBeenCalled()+ })++ it('a ComfyUI that never comes back is said, with where to start it', async () => {+ checkComfyConnection.mockResolvedValue(false)+ const done = renderFixupDeps(() => undefined).updateComfy()+ const failed = expect(done).rejects.toThrow('ComfyUI was updated but did not come back up. Start it from Settings and hit Create again.')+ await vi.advanceTimersByTimeAsync(200_000)+ await failed+ })+})diff --git a/src/api/render-fixup-deps.ts b/src/api/render-fixup-deps.tsindex 69fe318d..cf9fb578 100644--- a/src/api/render-fixup-deps.ts+++ b/src/api/render-fixup-deps.ts@@ -3,7 +3,6 @@// prompt enhancer) and the agent's image and video tool (api/vram-handoff.ts).// The question itself is drawn by RenderFixupModal in the app shell.-import { backendCall } from './backend'import { checkComfyConnection, refreshComfyModels } from './comfyui'import { clearNodeCache } from './comfyui-nodes'import { startModelDownload, getDownloadProgress, modelsNotVisibleInComfy, comfyModelTarget, catalogDigestFor } from './discover'@@ -13,7 +12,9 @@ import { useCreateStore } from '../stores/createStore'import { useDownloadStore } from '../stores/downloadStore'import { useComfyInstallStore } from '../stores/comfyInstallStore'-/** How long the updated ComfyUI gets to answer. */+/** How long the updated ComfyUI gets to answer. The update starts it again+ * itself (update_comfyui in Rust, before it reports complete), so this only+ * waits for the port. */const COMFY_BACK_UP_TRIES = 90const POLL_MS = 2000@@ -67,8 +68,6 @@ export function renderFixupDeps(onStatus: (line: string) => void, signal?: Abortconst last = st.logs[st.logs.length - 1]if (last) onStatus(String(last))}- onStatus('Starting the updated ComfyUI…')- await backendCall('start_comfyui').catch(() => undefined)for (let i = 0; i < COMFY_BACK_UP_TRIES; i++) {if (await checkComfyConnection()) returnonStatus(`Starting the updated ComfyUI… ${i * 2}s`)diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsxindex 6b56d315..d21dccbe 100644--- a/src/components/settings/SettingsPage.tsx+++ b/src/components/settings/SettingsPage.tsx@@ -770,7 +770,7 @@ function ComfyUpdateConfirmModal({<Modal open={open} onClose={onClose} title="Update ComfyUI?"><div className="space-y-4 text-sm text-gray-200"><p className="t-body leading-relaxed text-gray-300">- This pulls the latest ComfyUI and reinstalls its Python packages. It can take a few minutes. If ComfyUI is running and this app started it, it will be stopped first; a ComfyUI this app did not start blocks the update instead.+ This pulls the latest ComfyUI and reinstalls its Python packages. It can take a few minutes. If ComfyUI is running and this app started it, it will be stopped first; a ComfyUI this app did not start blocks the update instead. ComfyUI starts again when the update is done.</p>{path && <p className="t-label text-gray-500 text-center">ComfyUI folder: {path}</p>}<div className="flex flex-col gap-2 pt-1">diff --git a/src/components/settings/__tests__/comfy-update-confirm-dialog.test.ts b/src/components/settings/__tests__/comfy-update-confirm-dialog.test.tsindex dc0d5dca..f347b950 100644--- a/src/components/settings/__tests__/comfy-update-confirm-dialog.test.ts+++ b/src/components/settings/__tests__/comfy-update-confirm-dialog.test.ts@@ -245,7 +245,7 @@ describe('R4-1 (final review Runde 4): a stale status from an earlier run must n// click, if the Rust side did not reset it.let installStatus: Record<string, unknown> = {status: 'complete',- logs: ['Update finished. Restart ComfyUI to load the new nodes.'],+ logs: ['Update finished. ComfyUI is starting again with the new nodes.'],}let pollsSinceUpdateClicked = 0backendCall.mockImplementation(async (cmd: string) => {@@ -304,7 +304,7 @@ describe('R4-1 (final review Runde 4): a stale status from an earlier run must nlet installStatus: Record<string, unknown> = {status: 'complete',- logs: ['Update finished. Restart ComfyUI to load the new nodes.'],+ logs: ['Update finished. ComfyUI is starting again with the new nodes.'],}let pollsSinceUpdateClicked = 0backendCall.mockImplementation(async (cmd: string) => {diff --git a/src/lib/render-fixups.ts b/src/lib/render-fixups.tsindex c67ac4f3..96cbdd74 100644--- a/src/lib/render-fixups.ts+++ b/src/lib/render-fixups.ts@@ -22,7 +22,7 @@ export interface FixupDeps {ask: (prompt: FixupPrompt) => Promise<boolean>/** Download these files and wait until ComfyUI lists them. */download: (files: Array<ComponentSpec & { downloadUrl: string; subfolder: string }>) => Promise<void>- /** Update ComfyUI, start it again, and wait until it answers. */+ /** Update ComfyUI (the update starts it again) and wait until it answers. */updateComfy: () => Promise<void>/** Drop the cached node catalogue so the next build reads the new state. */refresh: () => Promise<void>