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(onboarding): ComfyStep klopft an den laufenden Port, wenn die Plattensuche leer bleibt (aq)
purpledff47de09de0
diff --git a/src/components/onboarding/ComfyStep.tsx b/src/components/onboarding/ComfyStep.tsxindex e7fe9938..0cf74531 100644--- a/src/components/onboarding/ComfyStep.tsx+++ b/src/components/onboarding/ComfyStep.tsx@@ -27,9 +27,10 @@ import { withInstallerOutput, withDetail } from '../../lib/error-text'import { ICON_LG } from '../ui/icon-size'import { Hinweis } from '../ui/Hinweis'import { ProgressBar } from '../ui/ProgressBar'-import { backendCall, isMacOS, isWindows } from '../../api/backend'+import { backendCall, isMacOS, isWindows, localFetch, comfyuiUrl } from '../../api/backend'import { comfyPathPlaceholder } from '../../lib/comfy-path-placeholder'import { formatBytes } from '../../lib/formatters'+import { probeRunningComfyPort } from './comfyPortProbe'import { isRunning, formatElapsed, lastLog, type InstallerStatusResponse } from './installer-state'import type { Step } from './wizard-steps'import type { OnboardingSkin } from './onboarding-skin'@@ -138,16 +139,32 @@ export function ComfyStep({ skin, fleet, step, setStep }: ComfyStepProps) {// Zero matches — fall back to legacy find_comfyui (env var, config// file overrides that aren't on the scan list).const legacy = await backendCall<{ found: boolean; path?: string; complete?: boolean }>('find_comfyui')- setComfyFound(legacy)- if (legacy.found && legacy.complete !== false) setComfyReady(true)+ if (legacy.found) {+ setComfyFound(legacy)+ if (legacy.complete !== false) setComfyReady(true)+ return+ }+ // aq: both scans reason from disk paths and still found nothing —+ // one last knock on the configured port before calling it not+ // found, in case ComfyUI is already running from a place neither+ // scan looks (a hand-launched venv, a network path, ...).+ const running = await probeRunningComfyPort(localFetch, comfyuiUrl('/internal/folder_paths'))+ setComfyFound({ found: running, complete: running })+ if (running) setComfyReady(true)}).catch(async () => {// Older builds without detect_all_comfyui_installs — degrade// gracefully to the previous single-pick API.try {const legacy = await backendCall<{ found: boolean; path?: string; complete?: boolean }>('find_comfyui')- setComfyFound(legacy)- if (legacy.found && legacy.complete !== false) setComfyReady(true)+ if (legacy.found) {+ setComfyFound(legacy)+ if (legacy.complete !== false) setComfyReady(true)+ return+ }+ const running = await probeRunningComfyPort(localFetch, comfyuiUrl('/internal/folder_paths'))+ setComfyFound({ found: running, complete: running })+ if (running) setComfyReady(true)} catch {setComfyFound({ found: false, complete: false })}diff --git a/src/components/onboarding/__tests__/comfy-port-probe.test.ts b/src/components/onboarding/__tests__/comfy-port-probe.test.tsnew file mode 100644index 00000000..8765d3a3--- /dev/null+++ b/src/components/onboarding/__tests__/comfy-port-probe.test.ts@@ -0,0 +1,61 @@+/**+ * aq (3.0.1) — `detect_all_comfyui_installs` and the legacy `find_comfyui`+ * both reason from disk paths and can both come back empty even while+ * ComfyUI is genuinely running (a hand-launched venv, a network path,+ * anything the scan heuristics do not look at). `probeRunningComfyPort` is+ * the one further fallback: knock on the configured port's own HTTP+ * endpoint before calling it not found.+ *+ * Run: npx vitest run src/components/onboarding/__tests__/comfy-port-probe.test.ts+ */+import { describe, it, expect, vi } from 'vitest'+import { readFileSync } from 'node:fs'+import { fileURLToPath } from 'node:url'+import { dirname, resolve } from 'node:path'+import { probeRunningComfyPort } from '../comfyPortProbe'++describe('aq: probeRunningComfyPort', () => {+ it('a responding port reads as found', async () => {+ const fetchFn = vi.fn(async () => ({ ok: true }))+ expect(await probeRunningComfyPort(fetchFn, 'http://127.0.0.1:8188/internal/folder_paths')).toBe(true)+ expect(fetchFn).toHaveBeenCalledWith('http://127.0.0.1:8188/internal/folder_paths', { timeoutMs: 2000 })+ })++ it('NEGATIVE CONTROL: a non-OK response reads as not found', async () => {+ const fetchFn = vi.fn(async () => ({ ok: false }))+ expect(await probeRunningComfyPort(fetchFn, 'http://127.0.0.1:8188/internal/folder_paths')).toBe(false)+ })++ it('NEGATIVE CONTROL: a refused connection (throws) reads as not found, not as an error', async () => {+ const fetchFn = vi.fn(async () => { throw new Error('ECONNREFUSED') })+ await expect(probeRunningComfyPort(fetchFn, 'http://127.0.0.1:8188/internal/folder_paths')).resolves.toBe(false)+ })++ it('NEGATIVE CONTROL: a timeout (the caller aborts) reads as not found', async () => {+ const fetchFn = vi.fn(async () => { throw new DOMException('aborted', 'AbortError') })+ await expect(probeRunningComfyPort(fetchFn, 'http://127.0.0.1:8188/internal/folder_paths')).resolves.toBe(false)+ })+})++describe('aq: ComfyStep.tsx wires the probe into the zero-match branch of both paths', () => {+ const here = dirname(fileURLToPath(import.meta.url))+ const src = readFileSync(resolve(here, '../ComfyStep.tsx'), 'utf8')++ it('imports probeRunningComfyPort', () => {+ expect(src).toContain("import { probeRunningComfyPort } from './comfyPortProbe'")+ })++ it('calls it after BOTH detect_all_comfyui_installs and legacy find_comfyui come back empty', () => {+ // Once for the detect_all_comfyui_installs success path, once for the+ // catch() degrade path (older builds without that command).+ const hits = src.split("probeRunningComfyPort(localFetch, comfyuiUrl('/internal/folder_paths'))").length - 1+ expect(hits).toBe(2)+ })++ it('a positive probe sets both found and ready', () => {+ const at = src.indexOf('const running = await probeRunningComfyPort')+ const block = src.slice(at, at + 200)+ expect(block).toContain('setComfyFound({ found: running, complete: running })')+ expect(block).toContain('if (running) setComfyReady(true)')+ })+})diff --git a/src/components/onboarding/__tests__/installer-state.test.ts b/src/components/onboarding/__tests__/installer-state.test.tsindex 5719e85d..9101f436 100644--- a/src/components/onboarding/__tests__/installer-state.test.ts+++ b/src/components/onboarding/__tests__/installer-state.test.ts@@ -77,7 +77,7 @@ const ASSISTENT = []/** Liegt im selben Ordner, ist aber kein Schritt des Assistenten. */-const NICHT_DER_ASSISTENT = ['BackendSelector.tsx']+const NICHT_DER_ASSISTENT = ['BackendSelector.tsx', 'comfyPortProbe.ts']/** Der ganze Assistent als ein Text — die Sperrklinke zaehlt darauf. */const SRC = ASSISTENT.map(lies).join('\n')diff --git a/src/components/onboarding/comfyPortProbe.ts b/src/components/onboarding/comfyPortProbe.tsnew file mode 100644index 00000000..259de8d2--- /dev/null+++ b/src/components/onboarding/comfyPortProbe.ts@@ -0,0 +1,29 @@+// aq (3.0.1) — `detect_all_comfyui_installs` walks known install locations on+// disk; it finds nothing when ComfyUI lives somewhere the scan never looks+// (a custom venv launched by hand, a network drive, a path the scan's+// heuristics miss) even though the user already has it running. The legacy+// `find_comfyui` fallback has the same blind spot: it also reasons from disk+// paths and env vars, never from "is anything actually listening".+//+// This is the one further fallback: knock on the configured ComfyUI port's+// `/internal/folder_paths` (the same endpoint `comfy_folders::folders_of`+// reads on the Rust side for a running-instance probe) directly from the+// renderer, the same way the rest of this file already talks to a live+// ComfyUI once it knows where one is. No new Rust command needed — `fetchFn`+// is `localFetch` in production, which already proxies localhost requests+// through Tauri where the webview's own fetch cannot reach them.+//+// Short-circuits to false on any error (network refused, timeout, non-OK+// status): a probe that cannot tell is not a positive result, and the+// existing "not found" UI is the correct honest state for that case.+export async function probeRunningComfyPort(+ fetchFn: (url: string, opts?: { timeoutMs?: number }) => Promise<{ ok: boolean }>,+ url: string,+): Promise<boolean> {+ try {+ const res = await fetchFn(url, { timeoutMs: 2000 })+ return res.ok+ } catch {+ return false+ }+}