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(settings): ehrliche Python-Sonde und ein Deckel fuer die Status-Schleife

purple81dde0784412
diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsx
index f7beebd6..8e8a078f 100644
--- a/src/components/settings/SettingsPage.tsx
+++ b/src/components/settings/SettingsPage.tsx
@@ -835,6 +835,7 @@ export function ComfyUISettings() {
{cancelling && installPhase !== 'error'
? 'Cancelling…'
: <>
+ {installPhase === 'checking' && 'Checking Python…'}
{installPhase === 'python' && 'Installing Python 3.12 (~30 MB)…'}
{installPhase === 'comfyui' && `Installing ComfyUI…${downloadSuffix(installDl)}`}
{installPhase === 'repair' && `Rebuilding the ComfyUI environment…${downloadSuffix(installDl)}`}
diff --git a/src/stores/__tests__/comfy-install-phases.test.ts b/src/stores/__tests__/comfy-install-phases.test.ts
new file mode 100644
index 00000000..5a8d9bcd
--- /dev/null
+++ b/src/stores/__tests__/comfy-install-phases.test.ts
@@ -0,0 +1,117 @@
+/**
+ * Review 2026-09-02, two findings on the run itself.
+ *
+ * 1. `runInstall` set the phase to `python` before `python_check` had
+ * answered, so a box that already has Python showed "Installing Python 3.12
+ * (~30 MB)" for an install that never happened.
+ * 2. The status poll swallowed every failure and retried forever. If
+ * `install_comfyui_status` stopped answering for good, the panel spun on a
+ * spinner with no end and no word.
+ *
+ * Run: npx vitest run src/stores/__tests__/comfy-install-phases.test.ts
+ */
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
+
+const backendCall = vi.fn()
+vi.mock('../../api/backend', () => ({
+ backendCall: (...args: unknown[]) => backendCall(...args),
+ isTauri: () => true,
+ isMacOS: () => false,
+ isWindows: () => true,
+}))
+
+const { useComfyInstallStore, comfyInstallPolling, LOST_CONTACT } = await import('../comfyInstallStore')
+
+const store = () => useComfyInstallStore.getState()
+
+beforeEach(() => {
+ store().reset()
+ backendCall.mockReset()
+})
+afterEach(() => { store().reset(); vi.useRealTimers() })
+
+describe('the Python probe is not a Python install', () => {
+ it('says it is checking while the probe runs, and never claims an install', async () => {
+ let answerProbe: (v: unknown) => void = () => {}
+ backendCall.mockImplementation(async (cmd: string) => {
+ if (cmd === 'python_check') return new Promise((resolve) => { answerProbe = resolve })
+ return {}
+ })
+ const running = store().runInstall('')
+ await Promise.resolve()
+ expect(store().phase).toBe('checking')
+ expect(store().logs.join(' ')).not.toContain('Installing Python')
+
+ // Python is there, so the winget step is skipped entirely.
+ answerProbe({ available: true })
+ await running
+ expect(store().phase).toBe('comfyui')
+ expect(backendCall.mock.calls.some(([cmd]) => cmd === 'install_python')).toBe(false)
+ })
+
+ it('still goes through the python phase on a box without one', async () => {
+ const seen: string[] = []
+ const unsub = useComfyInstallStore.subscribe((s) => { if (seen[seen.length - 1] !== s.phase) seen.push(s.phase) })
+ backendCall.mockImplementation(async (cmd: string) => {
+ if (cmd === 'python_check') return { available: false }
+ if (cmd === 'install_python_status') return { status: 'complete', logs: ['done'] }
+ return {}
+ })
+ vi.useFakeTimers({ shouldAdvanceTime: true })
+ const running = store().runInstall('')
+ await vi.advanceTimersByTimeAsync(2000)
+ await running
+ unsub()
+ expect(seen).toContain('checking')
+ expect(seen).toContain('python')
+ expect(store().phase).toBe('comfyui')
+ })
+})
+
+describe('a poll that never gets an answer gives up and says so', () => {
+ async function repairWithBrokenStatus(ticks: number) {
+ vi.useFakeTimers({ shouldAdvanceTime: true })
+ backendCall.mockImplementation(async (cmd: string) => {
+ if (cmd === 'repair_comfyui_env') return { status: 'installing' }
+ if (cmd === 'install_comfyui_status') throw new Error('IPC is gone')
+ return {}
+ })
+ await store().runRepair()
+ await vi.advanceTimersByTimeAsync(2000 * ticks)
+ }
+
+ it('keeps trying through a long run of failures', async () => {
+ await repairWithBrokenStatus(29)
+ expect(comfyInstallPolling()).toBe(true)
+ expect(store().phase).toBe('repair')
+ })
+
+ it('stops after the cap and names what happened', async () => {
+ await repairWithBrokenStatus(30)
+ expect(comfyInstallPolling()).toBe(false)
+ expect(store().phase).toBe('error')
+ expect(store().error).toBe(LOST_CONTACT)
+ })
+
+ it('forgets the failures as soon as one answer arrives', async () => {
+ vi.useFakeTimers({ shouldAdvanceTime: true })
+ let broken = true
+ backendCall.mockImplementation(async (cmd: string) => {
+ if (cmd === 'repair_comfyui_env') return { status: 'installing' }
+ if (cmd === 'install_comfyui_status') {
+ if (broken) throw new Error('IPC is gone')
+ return { status: 'installing', logs: ['pip install torch'] }
+ }
+ return {}
+ })
+ await store().runRepair()
+ await vi.advanceTimersByTimeAsync(2000 * 29)
+ broken = false
+ await vi.advanceTimersByTimeAsync(2000)
+ broken = true
+ // 29 more failures must not trip the cap, the counter started over.
+ await vi.advanceTimersByTimeAsync(2000 * 29)
+ expect(comfyInstallPolling()).toBe(true)
+ expect(store().phase).toBe('repair')
+ })
+})
diff --git a/src/stores/comfyInstallStore.ts b/src/stores/comfyInstallStore.ts
index 7ad276bb..c8b92349 100644
--- a/src/stores/comfyInstallStore.ts
+++ b/src/stores/comfyInstallStore.ts
@@ -16,8 +16,9 @@ import { create } from 'zustand'
import { backendCall } from '../api/backend'
import { withInstallerOutput } from '../lib/error-text'
-/** Which card the panel draws. `python` is the pre-flight winget step. */
-export type ComfyInstallPhase = 'idle' | 'python' | 'comfyui' | 'repair' | 'error'
+/** Which card the panel draws. `checking` is the Python probe, `python` the
+ * winget install that only some boxes need. */
+export type ComfyInstallPhase = 'idle' | 'checking' | 'python' | 'comfyui' | 'repair' | 'error'
/** Which long run is in flight. Install and update share the `comfyui` phase,
* and they need different sentences when they end. */
@@ -42,6 +43,17 @@ const FAILED: Record<ComfyInstallKind, string> = {
const POLL_MS = 2000
+/** How many status reads in a row may fail before the poll gives up.
+ *
+ * Review 2026-09-02: every failure was swallowed and retried forever, so a
+ * status channel that stopped answering for good left a spinner turning with
+ * no end and no word. Thirty ticks is a minute of silence, long enough to sit
+ * out a busy box and short enough that nobody watches a dead spinner. */
+const MAX_POLL_MISSES = 30
+
+/** What the panel says when the installer stopped answering. */
+export const LOST_CONTACT = 'Lost contact with the installer. Check the log and try again.'
+
/** The one poll in flight, module level so it outlives every mount. */
let timer: ReturnType<typeof setInterval> | null = null
@@ -104,13 +116,21 @@ export const useComfyInstallStore = create<ComfyInstallState>()((set, get) => {
* says which one it was. */
const watch = (kind: ComfyInstallKind) => {
stopTimer()
+ let misses = 0
timer = setInterval(async () => {
let data: InstallStatusPayload
try {
data = (await backendCall<InstallStatusPayload>('install_comfyui_status')) ?? {}
} catch {
- return // transient, the next tick asks again
+ // Transient, the next tick asks again. Not transient any more once it
+ // has been a minute of nothing.
+ if (++misses >= MAX_POLL_MISSES) {
+ stopTimer()
+ set({ phase: 'error', cancelling: false, error: LOST_CONTACT })
+ }
+ return
}
+ misses = 0
set({
logs: data.logs ?? [],
dl: {
@@ -148,10 +168,15 @@ export const useComfyInstallStore = create<ComfyInstallState>()((set, get) => {
...IDLE,
runInstall: async (installPath: string) => {
- begin('python', 'install', '')
// Pre-flight: pip needs a Python before ComfyUI can be installed. The
// carcass case lands here too, the previous run may have died on the
// Microsoft Store stub.
+ //
+ // Review 2026-09-02: the phase used to jump to `python` before the probe
+ // had answered, so a box that has Python flashed "Installing Python 3.12
+ // (~30 MB)" for an install that never happened. The probe gets its own
+ // neutral phase and `python` now means what it says.
+ begin('checking', 'install', '')
let pythonOk = false
try {
const probe = await backendCall<{ available?: boolean }>('python_check')
@@ -160,7 +185,7 @@ export const useComfyInstallStore = create<ComfyInstallState>()((set, get) => {
pythonOk = false
}
if (!pythonOk) {
- set({ logs: ['Installing Python 3.12 via winget…'] })
+ set({ phase: 'python', logs: ['Installing Python 3.12 via winget…'] })
try {
await backendCall('install_python')
} catch (err) {