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): Deckel auch fuer die Python-Schleife, Hinweiszeile und Linux-Spiegelung

purplee932a70955e4
diff --git a/src/api/__tests__/custom-model-folder.test.ts b/src/api/__tests__/custom-model-folder.test.ts
index efd60862..6f32d645 100644
--- a/src/api/__tests__/custom-model-folder.test.ts
+++ b/src/api/__tests__/custom-model-folder.test.ts
@@ -25,6 +25,7 @@ vi.mock('../backend', () => ({
isTauri: () => true,
isMacOS: () => platform === 'macos',
isWindows: () => platform === 'windows',
+ isLinux: () => platform === 'linux',
}))
import { customModelDirs, listBundledModels, bundledToAIModels, lastScanDirs, lastCustomScanDir } from '../engine'
diff --git a/src/api/engine.ts b/src/api/engine.ts
index e52e25c9..219edf51 100644
--- a/src/api/engine.ts
+++ b/src/api/engine.ts
@@ -11,7 +11,7 @@
* `backendCall` maps camelCase args → snake_case Rust params (Tauri).
*/
-import { backendCall, isMacOS, isWindows } from './backend'
+import { backendCall, isLinux } from './backend'
import { syncBuiltinEnginePort } from './builtin-ensure'
import { trackEngineSwap } from './engine-swap-gate'
import { prefixModelName } from './providers'
@@ -283,7 +283,9 @@ export function lastScanDirs(): ScannedDir[] {
* folders on ext4, and folding them here would let this answer a question
* about one folder with the verdict about the other. */
function samePath(a: string, b: string): boolean {
- const fold = isWindows() || isMacOS()
+ // The mirror of Rust's `!cfg!(target_os = "linux")` in bundled_scan_dirs,
+ // spelled the same way round so the two cannot drift apart.
+ const fold = !isLinux()
const key = (p: string) => {
const normalised = String(p ?? '').replace(/\\/g, '/').replace(/\/+$/, '')
return fold ? normalised.toLowerCase() : normalised
diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsx
index 8e8a078f..9616a9eb 100644
--- a/src/components/settings/SettingsPage.tsx
+++ b/src/components/settings/SettingsPage.tsx
@@ -819,7 +819,7 @@ export function ComfyUISettings() {
Update ComfyUI
</button>
)}
- {(!status?.found || status?.complete === false) && installPhase === 'idle' && (
+ {(!status?.found || status?.complete === false) && installIdle && (
<p className="w-full text-[0.55rem] text-gray-600">
Installs to your home folder by default. Set Path above (e.g. D:\ComfyUI) to install on another drive.
</p>
diff --git a/src/components/settings/__tests__/comfy-install-survives-remount.test.ts b/src/components/settings/__tests__/comfy-install-survives-remount.test.ts
index f54f4899..b87fad39 100644
--- a/src/components/settings/__tests__/comfy-install-survives-remount.test.ts
+++ b/src/components/settings/__tests__/comfy-install-survives-remount.test.ts
@@ -158,3 +158,31 @@ describe('a failed run stays escapable', () => {
expect(comfyInstallPolling()).toBe(false)
})
})
+
+/**
+ * Review 2026-09-02: the hint under the install button ("Installs to your home
+ * folder by default…") still hung on `idle` after the buttons were opened up
+ * for `error`, so a failed run showed the button without the sentence that
+ * says where it installs to.
+ */
+describe('the install hint keeps the button company', () => {
+ it('stays next to the button after a failed install', async () => {
+ vi.useFakeTimers({ shouldAdvanceTime: true })
+ backendCall.mockImplementation(async (cmd: string) => {
+ if (cmd === 'comfyui_status') return { running: false, found: false, isLocal: true }
+ if (cmd === 'python_check') return { available: true }
+ if (cmd === 'install_comfyui') return {}
+ if (cmd === 'install_comfyui_status') return installStatus
+ return {}
+ })
+ await mountPanel()
+ await act(async () => { fireEvent.click(screen.getByText('Install ComfyUI')) })
+
+ installStatus = { status: 'error', logs: ['ERROR: git clone failed'] }
+ await act(async () => { await vi.advanceTimersByTimeAsync(2000) })
+
+ expect(screen.getByText('Install failed')).toBeTruthy()
+ expect(screen.getByText('Install ComfyUI')).toBeTruthy()
+ expect(screen.getByText(/Installs to your home folder by default/)).toBeTruthy()
+ })
+})
diff --git a/src/stores/__tests__/comfy-install-phases.test.ts b/src/stores/__tests__/comfy-install-phases.test.ts
index 5a8d9bcd..10e6b4d8 100644
--- a/src/stores/__tests__/comfy-install-phases.test.ts
+++ b/src/stores/__tests__/comfy-install-phases.test.ts
@@ -20,7 +20,8 @@ vi.mock('../../api/backend', () => ({
isWindows: () => true,
}))
-const { useComfyInstallStore, comfyInstallPolling, LOST_CONTACT } = await import('../comfyInstallStore')
+const { useComfyInstallStore, comfyInstallPolling, LOST_CONTACT, LOST_CONTACT_PYTHON } =
+ await import('../comfyInstallStore')
const store = () => useComfyInstallStore.getState()
@@ -115,3 +116,104 @@ describe('a poll that never gets an answer gives up and says so', () => {
expect(store().phase).toBe('repair')
})
})
+
+/**
+ * Review 2026-09-02, second round: the Python status loop had no cap of its
+ * own. Its catch only returned, so the promise `runInstall` awaits never
+ * settled: the run hung in phase `python` for ever, with no Cancel, no
+ * Dismiss and no buttons, because every one of those hangs on a phase that
+ * never came.
+ */
+describe('the Python status loop gives up too', () => {
+ async function installWithBrokenPythonStatus(ticks: number) {
+ vi.useFakeTimers({ shouldAdvanceTime: true })
+ backendCall.mockImplementation(async (cmd: string) => {
+ if (cmd === 'python_check') return { available: false }
+ if (cmd === 'install_python') return {}
+ if (cmd === 'install_python_status') throw new Error('IPC is gone')
+ return {}
+ })
+ // Wrapped, so `await` on this helper cannot chain onto a run that is
+ // meant to still be in flight.
+ const running = store().runInstall('')
+ await vi.advanceTimersByTimeAsync(2000 * ticks)
+ return { running }
+ }
+
+ it('keeps waiting through a long run of failures', async () => {
+ await installWithBrokenPythonStatus(29)
+ expect(store().phase).toBe('python')
+ expect(comfyInstallPolling()).toBe(true)
+ })
+
+ it('settles the run instead of hanging in phase python for ever', async () => {
+ const { running } = await installWithBrokenPythonStatus(30)
+ // The promise really resolves: without the cap this await never returns.
+ await running
+ expect(store().phase).toBe('error')
+ expect(store().error).toBe(LOST_CONTACT_PYTHON)
+ expect(comfyInstallPolling()).toBe(false)
+ // And it never went on to install ComfyUI on a box with no Python.
+ expect(backendCall.mock.calls.some(([cmd]) => cmd === 'install_comfyui')).toBe(false)
+ })
+
+ 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 === 'python_check') return { available: false }
+ if (cmd === 'install_python') return {}
+ if (cmd === 'install_python_status') {
+ if (broken) throw new Error('IPC is gone')
+ return { status: 'installing', logs: ['winget is working'] }
+ }
+ return {}
+ })
+ const running = store().runInstall('')
+ await vi.advanceTimersByTimeAsync(2000 * 29)
+ broken = false
+ await vi.advanceTimersByTimeAsync(2000)
+ broken = true
+ await vi.advanceTimersByTimeAsync(2000 * 29)
+ expect(store().phase).toBe('python')
+ expect(comfyInstallPolling()).toBe(true)
+ // Let the run finish so no timer outlives the test.
+ broken = false
+ backendCall.mockImplementation(async (cmd: string) => {
+ if (cmd === 'install_python_status') return { status: 'complete', logs: ['done'] }
+ return {}
+ })
+ await vi.advanceTimersByTimeAsync(2000)
+ await running
+ })
+})
+
+/**
+ * A status read that was already on the wire when the run ended still resolves
+ * afterwards. Without a generation on each tick it wrote its answer into a run
+ * that is over: a dismissed failure coming back on its own, or a fresh run
+ * wearing the previous one's log lines.
+ */
+describe('a late answer from a finished run is ignored', () => {
+ it('does not resurrect a dismissed failure', async () => {
+ vi.useFakeTimers({ shouldAdvanceTime: true })
+ let answer: (v: unknown) => void = () => {}
+ backendCall.mockImplementation(async (cmd: string) => {
+ if (cmd === 'repair_comfyui_env') return { status: 'installing' }
+ if (cmd === 'install_comfyui_status') return new Promise((resolve) => { answer = resolve })
+ return {}
+ })
+ await store().runRepair()
+ await vi.advanceTimersByTimeAsync(2000)
+
+ // The user presses Dismiss while that read is still on the wire.
+ store().reset()
+ answer({ status: 'error', logs: ['ERROR: pip could not build wheels'] })
+ await vi.advanceTimersByTimeAsync(10)
+
+ expect(store().phase).toBe('idle')
+ expect(store().error).toBe('')
+ expect(store().logs).toEqual([])
+ expect(comfyInstallPolling()).toBe(false)
+ })
+})
diff --git a/src/stores/comfyInstallStore.ts b/src/stores/comfyInstallStore.ts
index c8b92349..fa8395d3 100644
--- a/src/stores/comfyInstallStore.ts
+++ b/src/stores/comfyInstallStore.ts
@@ -54,10 +54,22 @@ 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 same for the winget step that runs before it. */
+export const LOST_CONTACT_PYTHON = 'Lost contact with the Python 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
+/** Which poll is the current one. A status read that was already in flight
+ * when the poll was stopped still resolves afterwards, and without this it
+ * would write its answer into a run that is over: a dismissed failure coming
+ * back by itself, or a fresh run wearing the old one's log lines. Every tick
+ * carries the generation it was born in and drops out when that is no longer
+ * the current one. */
+let generation = 0
+
function stopTimer() {
+ generation++
if (timer) {
clearInterval(timer)
timer = null
@@ -116,12 +128,15 @@ export const useComfyInstallStore = create<ComfyInstallState>()((set, get) => {
* says which one it was. */
const watch = (kind: ComfyInstallKind) => {
stopTimer()
+ const mine = generation
let misses = 0
timer = setInterval(async () => {
+ if (generation !== mine) return
let data: InstallStatusPayload
try {
data = (await backendCall<InstallStatusPayload>('install_comfyui_status')) ?? {}
} catch {
+ if (generation !== mine) return
// Transient, the next tick asks again. Not transient any more once it
// has been a minute of nothing.
if (++misses >= MAX_POLL_MISSES) {
@@ -130,6 +145,8 @@ export const useComfyInstallStore = create<ComfyInstallState>()((set, get) => {
}
return
}
+ // The answer took a while; the run it belongs to may be over by now.
+ if (generation !== mine) return
misses = 0
set({
logs: data.logs ?? [],
@@ -194,13 +211,32 @@ export const useComfyInstallStore = create<ComfyInstallState>()((set, get) => {
}
pythonOk = await new Promise<boolean>((resolve) => {
stopTimer()
+ const mine = generation
+ let misses = 0
timer = setInterval(async () => {
+ // A run that was reset or replaced does not get to answer any
+ // more, but the promise must still settle or runInstall hangs.
+ if (generation !== mine) { resolve(false); return }
let data: InstallStatusPayload
try {
data = (await backendCall<InstallStatusPayload>('install_python_status')) ?? {}
} catch {
+ if (generation !== mine) { resolve(false); return }
+ // Review 2026-09-02: without this the promise never settled. A
+ // Python status channel that stopped answering left runInstall
+ // waiting for ever in phase `python`, with no Cancel, no Dismiss
+ // and no buttons. It resolves false rather than rejecting, since
+ // the caller is a fire-and-forget click and a rejection here
+ // would only become an unhandled one.
+ if (++misses >= MAX_POLL_MISSES) {
+ stopTimer()
+ set({ error: LOST_CONTACT_PYTHON })
+ resolve(false)
+ }
return
}
+ if (generation !== mine) { resolve(false); return }
+ misses = 0
set({ logs: data.logs ?? [] })
if (data.status === 'complete' || data.status === 'already_installed') {
stopTimer()