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
feat(create): the Start ComfyUI card carries "Start ComfyUI when LU starts" (C50)
purplea9572203955b
diff --git a/src/components/create/experimental/ComfyAutostartToggle.tsx b/src/components/create/experimental/ComfyAutostartToggle.tsxnew file mode 100644index 00000000..ff7cb569--- /dev/null+++ b/src/components/create/experimental/ComfyAutostartToggle.tsx@@ -0,0 +1,52 @@+import { useEffect, useState } from 'react'+import { backendCall } from '../../../api/backend'++interface ComfyAutostartStatus {+ found?: boolean+ isLocal?: boolean+ autostart?: boolean+}++/**+ * C50 (3.1.0, Discord 06.11.): since 3.0.9 LU only starts ComfyUI at launch+ * when the user said so, and the switch for that sat folded away in Settings+ * → AI Backends → ComfyUI. The Create card that says "Start ComfyUI" carries+ * the same switch, so the person who just had to start it by hand finds it+ * where the question comes up. Same command and config key as Settings+ * (`set_comfyui_autostart`), so both always show the same answer.+ *+ * Shown only for a ComfyUI LU can start on this machine: none for a remote+ * host or before LU knows the install, and none on a Mac (MLX only, the+ * card never asks to start ComfyUI there).+ */+export function ComfyAutostartToggle() {+ const [status, setStatus] = useState<ComfyAutostartStatus | null>(null)+ useEffect(() => {+ let live = true+ backendCall<ComfyAutostartStatus>('comfyui_status')+ .then((st) => { if (live) setStatus(st ?? null) })+ .catch(() => {})+ return () => { live = false }+ }, [])+ if (!status || !status.found || status.isLocal === false || typeof status.autostart !== 'boolean') return null+ return (+ <label className="flex items-center gap-2 t-control text-gray-400 cursor-pointer select-none" title="Also in Settings → AI Backends → ComfyUI">+ <input+ type="checkbox"+ aria-label="Start ComfyUI when LU starts"+ checked={status.autostart}+ onChange={async (e) => {+ const enabled = e.target.checked+ setStatus((prev) => prev ? { ...prev, autostart: enabled } : prev)+ try {+ await backendCall('set_comfyui_autostart', { enabled })+ } catch {+ setStatus((prev) => prev ? { ...prev, autostart: !enabled } : prev)+ }+ }}+ className="accent-emerald-500"+ />+ <span>Start ComfyUI when LU starts</span>+ </label>+ )+}diff --git a/src/components/create/experimental/Stage.tsx b/src/components/create/experimental/Stage.tsxindex 63008b13..6539dea8 100644--- a/src/components/create/experimental/Stage.tsx+++ b/src/components/create/experimental/Stage.tsx@@ -46,6 +46,7 @@ import { describeAvailability, describeTrainPhoto, type DescribeAvailability } fimport { MAC_IMAGE_SETUP_SIZE, macVideoSetupCopy } from '../../../lib/mac-setup-sizes'import { macVideoSetupPlan, type MacVideoSetupPlan } from '../../../api/mlx-starter'import { HowItWorks } from '../../ui/HowItWorks'+import { ComfyAutostartToggle } from './ComfyAutostartToggle'import { stageHowtoTopic } from '../../../lib/howto'interface Props {@@ -679,7 +680,10 @@ function InstallCardBody({ run, installing, status, err, onDismiss, onCancel, ca</div>) : (startOnly- ? <Button variant="primary" icon={Play} onClick={run}>Start ComfyUI</Button>+ ? <>+ <Button variant="primary" icon={Play} onClick={run}>Start ComfyUI</Button>+ <ComfyAutostartToggle />+ </>: <Button variant="primary" icon={Download} onClick={run}>Download & install</Button>)}{err && (diff --git a/src/components/create/experimental/__tests__/comfy-autostart-auf-der-startkarte.test.tsx b/src/components/create/experimental/__tests__/comfy-autostart-auf-der-startkarte.test.tsxnew file mode 100644index 00000000..777c148f--- /dev/null+++ b/src/components/create/experimental/__tests__/comfy-autostart-auf-der-startkarte.test.tsx@@ -0,0 +1,118 @@+// @vitest-environment jsdom+/**+ * C50 (3.1.0, Discord 06.11.): "Start ComfyUI when LU starts"+ * was only in Settings → AI Backends → ComfyUI, folded away under the port.+ * The Create card that offers "Start ComfyUI" now carries the same switch,+ * reading and writing the setting Settings uses.+ *+ * Run: npx vitest run src/components/create/experimental/__tests__/comfy-autostart-auf-der-startkarte.test.tsx+ */+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'+import { render, cleanup, screen, act, fireEvent } from '@testing-library/react'++let connected: boolean | null = false+vi.mock('../CreateContext', () => ({+ useCreateExp: () => ({+ generate: vi.fn(), cancel: vi.fn(), makeVoice: vi.fn(), quota: null,+ samplerList: [], schedulerList: [], loraList: [], vaeList: [], refreshModelLists: vi.fn(),+ connected, modelsLoaded: true, modelLoadError: null, mlxMissing: null,+ installCapability: vi.fn(), installModelBundle: vi.fn(),+ }),+}))+vi.mock('../../../../api/mlx-image', () => ({ isMlxImageHost: () => false }))++let onDisk = true+vi.mock('../../../../api/discover', async (orig) => ({+ ...((await orig()) as Record<string, unknown>),+ checkBundlesOnDisk: vi.fn(async (bundles: Array<{ name: string }>) =>+ ({ installed: Object.fromEntries(bundles.map((b) => [b.name, onDisk])), files: new Set<string>() })),+}))++let comfy: Record<string, unknown> = {}+let failWrite = false+const calls: Array<[string, unknown]> = []+vi.mock('../../../../api/backend', async (orig) => ({+ ...((await orig()) as Record<string, unknown>),+ backendCall: vi.fn(async (cmd: string, args?: unknown) => {+ calls.push([cmd, args])+ if (cmd === 'comfyui_status') return comfy+ if (cmd === 'set_comfyui_autostart') {+ if (failWrite) throw new Error('no')+ return { status: 'saved' }+ }+ return null+ }),+}))++import { Stage } from '../Stage'+import { useCreateStore } from '../../../../stores/createStore'++const stage = () => render(<Stage onOpenMaskEditor={() => {}} onFullscreen={() => {}} />)+const settle = () => act(async () => { for (let i = 0; i < 12; i++) await Promise.resolve() })+const box = () => screen.queryByRole('checkbox', { name: 'Start ComfyUI when LU starts' }) as HTMLInputElement | null++beforeEach(() => {+ connected = false+ onDisk = true+ failWrite = false+ calls.length = 0+ comfy = { found: true, running: false, isLocal: true, autostart: false }+ useCreateStore.setState({+ backend: 'local', isGenerating: false, error: null, gallery: [], source: null,+ upscaleModelList: [], imageModelList: [],+ } as never)+ useCreateStore.getState().setIntent('image')+})+afterEach(cleanup)++describe('C50: the Start ComfyUI card carries the autostart switch', () => {+ it('shows it under Start ComfyUI, with the saved answer', async () => {+ stage()+ await settle()+ expect(screen.getByRole('button', { name: /Start ComfyUI/ })).toBeTruthy()+ expect(box()?.checked).toBe(false)+ cleanup()+ comfy = { ...comfy, autostart: true }+ stage()+ await settle()+ expect(box()?.checked).toBe(true)+ })++ it('a click saves it the way Settings does', async () => {+ stage()+ await settle()+ fireEvent.click(box()!)+ await settle()+ expect(calls).toContainEqual(['set_comfyui_autostart', { enabled: true }])+ expect(box()?.checked).toBe(true)+ })++ it('a failed save puts the box back', async () => {+ failWrite = true+ stage()+ await settle()+ fireEvent.click(box()!)+ await settle()+ expect(box()?.checked).toBe(false)+ })++ it('not for a remote ComfyUI, an unknown install, or the download card', async () => {+ comfy = { found: true, isLocal: false, autostart: false }+ stage()+ await settle()+ expect(screen.getByRole('button', { name: /Start ComfyUI/ })).toBeTruthy()+ expect(box()).toBeNull()+ cleanup()+ comfy = { found: false, isLocal: true, autostart: false }+ stage()+ await settle()+ expect(box()).toBeNull()+ cleanup()+ comfy = { found: true, isLocal: true, autostart: false }+ onDisk = false+ stage()+ await settle()+ expect(screen.getByRole('button', { name: /Download & install/ })).toBeTruthy()+ expect(box()).toBeNull()+ })+})