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): ops start empty + explicit gallery/desktop source, cloud-only gating (David-Durchklick 10.7)
purple620309f02f4d
diff --git a/e2e/cloud-create.spec.ts b/e2e/cloud-create.spec.tsindex e4391c36..5124dc11 100644--- a/e2e/cloud-create.spec.ts+++ b/e2e/cloud-create.spec.ts@@ -45,6 +45,48 @@ test('cloud render: submit → poll → gallery, meter + utility intents presentawait expect(page.locator('img[src*="/e2e/result.png"]').first()).toBeVisible({ timeout: 30_000 })})+test('ops start EMPTY and adopt a gallery image only on explicit pick', async ({ page }) => {+ await bootIntoCloudCreate(page, { license: 'active', access: true, mediaLive: true })++ // Render once so the gallery holds an image the old auto-adopt would grab.+ const composer = page.locator('textarea').first()+ await composer.fill('a lighthouse at dusk, cinematic')+ await page.getByRole('button', { name: /^Create$/ }).last().click()+ await expect(page.locator('img[src*="/e2e/result.png"]').first()).toBeVisible({ timeout: 30_000 })++ // Switching to Edit must NOT auto-adopt the gallery image (David 2026-07-10):+ // the stage shows the empty input slot with the explicit gallery pick strip.+ await page.getByRole('radio', { name: /Edit Image/i }).click()+ await expect(page.getByText(/Drop an image to edit/i)).toBeVisible({ timeout: 15_000 })+ await expect(page.getByText(/or pick from your gallery/i)).toBeVisible()++ // Explicit pick adopts the image as the op source (source preview appears).+ await page.getByRole('button', { name: /Use this gallery image as the source/i }).first().click()+ await expect(page.getByRole('button', { name: /Paint mask/i })).toBeVisible({ timeout: 15_000 })+})++test('local mode offers only the local lane (no cloud-only ops)', async ({ page }) => {+ await page.addInitScript(tauriMockInit, {+ assistantReply: DEFAULT_ASSISTANT_REPLY,+ modelName: DEFAULT_MODEL_NAME,+ })+ await seedOnboardingDone(page)+ await routeCloud(page, { license: 'active', access: true, mediaLive: true })+ await page.goto('/')+ await expect(page.getByRole('radio', { name: /Local/i })).toBeVisible({ timeout: 20_000 })+ await page.getByRole('button', { name: /^Create$/ }).click()++ await expect(page.getByRole('radio', { name: /^Image$/i })).toBeVisible({ timeout: 15_000 })+ await expect(page.getByRole('radio', { name: /^Video$/i })).toBeVisible()+ // David 2026-07-10: edit/animate/upscale/eraser have no local models — they+ // exist only on the cloud backend. removebg keeps its local RMBG lane.+ await expect(page.getByRole('radio', { name: /Remove Background/i })).toBeVisible()+ await expect(page.getByRole('radio', { name: /Edit Image/i })).toHaveCount(0)+ await expect(page.getByRole('radio', { name: /Animate Image/i })).toHaveCount(0)+ await expect(page.getByRole('radio', { name: /Upscale/i })).toHaveCount(0)+ await expect(page.getByRole('radio', { name: /Erase Object/i })).toHaveCount(0)+})+test('media_live=false: generate shows the honest coming-soon message', async ({ page }) => {await bootIntoCloudCreate(page, { license: 'active', access: true, mediaLive: false })diff --git a/src/components/create/experimental/CreateExperimental.tsx b/src/components/create/experimental/CreateExperimental.tsxindex eebd4055..0b4c0785 100644--- a/src/components/create/experimental/CreateExperimental.tsx+++ b/src/components/create/experimental/CreateExperimental.tsx@@ -12,7 +12,7 @@ import { AdvancedDrawer } from './AdvancedDrawer'import { MaskEditor } from './MaskEditor'import { VhsInstallModal } from './VhsInstallModal'import { INTENT_MAP } from './intents'-import { galleryItemUrl } from './galleryUrl'+import { fetchGalleryItemBlob } from './galleryUrl'import { loadImageRef } from './loadImage'/** The redesigned Create surface. Mounted by AppShell for currentView==='create'. */@@ -52,8 +52,7 @@ function CreateExperimentalInner() {// with mask" on a result and switching to Edit/Upscale/Eraser/Animate were// no-ops that demanded a download + re-upload of the app's own output.const adoptResult = useCallback(async (item: GalleryItem) => {- const res = await fetch(galleryItemUrl(item))- const blob = await res.blob()+ const blob = await fetchGalleryItemBlob(item)const file = new File([blob], item.filename || 'result.png', { type: blob.type || 'image/png' })return loadImageRef(file)}, [])@@ -68,23 +67,18 @@ function CreateExperimentalInner() {}}, [adoptResult, setError])- // Switching to a source-needing intent while an image result is in the- // gallery adopts the newest image as the input instead of demanding a- // re-upload. Every source-needing intent takes an *image* input, so always- // pull the newest image — never a video.+ // David 2026-07-10: source-needing ops must start EMPTY — never silently+ // adopt a gallery image as the input. Adoption is always explicit: the+ // InputSlot's "pick from gallery" strip, drag&drop, the file picker, or a+ // result's "Edit" action. While an op intent owns the stage, clicking a+ // gallery tile opens the Lightbox (view it, videos play) instead of+ // pinning into a stage that can't display it.const intent = useCreateStore((s) => s.intent())- const source = useCreateStore((s) => s.source)- useEffect(() => {- const meta = INTENT_MAP[intent]- if (!meta.needsSource || source) return- const img = gallery.find((g) => g.type === 'image')- if (!img) return- let cancelled = false- adoptResult(img)- .then((ref) => { if (!cancelled) useCreateStore.getState().setSource(ref) })- .catch(() => { /* upload slot stays — user can drop a file */ })- return () => { cancelled = true }- // eslint-disable-next-line react-hooks/exhaustive-deps+ const openGalleryItem = useCallback((id: string) => {+ const item = useCreateStore.getState().gallery.find((g) => g.id === id)+ if (!item) return+ if (INTENT_MAP[intent].needsSource) setLightbox(item)+ else setPinnedId(id)}, [intent])return (@@ -134,7 +128,7 @@ function CreateExperimentalInner() {onEditResult={(it) => { void editResultWithMask(it) }}onFullscreen={(it) => setLightbox(it)}/>- <GalleryStrip activeId={pinnedId} onSelect={setPinnedId} />+ <GalleryStrip activeId={pinnedId} onSelect={openGalleryItem} /><Composer onOpenAdvanced={() => setAdvancedOpen(true)} /><AdvancedDrawer open={advancedOpen} onClose={() => setAdvancedOpen(false)} />diff --git a/src/components/create/experimental/Stage.tsx b/src/components/create/experimental/Stage.tsxindex ede2677e..8e0a17ec 100644--- a/src/components/create/experimental/Stage.tsx+++ b/src/components/create/experimental/Stage.tsx@@ -9,6 +9,7 @@ import { EmptyState } from '../ui/EmptyState'import { Button } from '../ui/Button'import { cn } from '../ui/cn'import { loadImageRef } from './loadImage'+import { galleryItemUrl, fetchGalleryItemBlob, recoverGalleryUrl } from './galleryUrl'interface Props {displayed?: GalleryItem@@ -107,11 +108,31 @@ function InputSlot() {const setSource = useCreateStore((s) => s.setSource)const setError = useCreateStore((s) => s.setError)const intent = useCreateStore((s) => s.intent())+ const gallery = useCreateStore((s) => s.gallery)const meta = INTENT_MAP[intent]const inputRef = useRef<HTMLInputElement>(null)const [drag, setDrag] = useState(false)const [loading, setLoading] = useState(false)+ // David 2026-07-10: ops never auto-adopt a gallery image — instead the slot+ // offers the recent gallery images as an EXPLICIT pick, next to drag&drop+ // and the file picker ("aus Galerie ODER vom Desktop").+ const galleryImages = gallery.filter((g) => g.type === 'image' && !g.unavailable).slice(0, 8)++ const adoptFromGallery = async (item: GalleryItem) => {+ setLoading(true)+ setError(null)+ try {+ const blob = await fetchGalleryItemBlob(item)+ const file = new File([blob], item.filename || 'source.png', { type: blob.type || 'image/png' })+ setSource(await loadImageRef(file))+ } catch (err) {+ setError(`Could not load that gallery image: ${err instanceof Error ? err.message : String(err)}`)+ } finally {+ setLoading(false)+ }+ }+const handleFile = async (file: File) => {// Drag&drop bypasses the input's accept filter — validate here so a// stray .txt/.pdf gets a message instead of a silent no-op. Exotic image@@ -153,6 +174,24 @@ function InputSlot() {</div><input ref={inputRef} type="file" accept="image/*" className="hidden" onChange={(e) => { const f = e.target.files?.[0]; if (f) handleFile(f) }} /></div>+ {galleryImages.length > 0 && (+ <div className="mt-4 w-full max-w-sm">+ <div className="t-label text-gray-600 mb-2 text-center">or pick from your gallery</div>+ <div className="flex justify-center gap-1.5 overflow-x-auto pb-1">+ {galleryImages.map((g) => (+ <button+ key={g.id}+ onClick={() => { if (!loading) void adoptFromGallery(g) }}+ className="shrink-0 w-12 h-12 rounded-md overflow-hidden border border-white/10 hover:border-white/30 transition-colors"+ title="Use this image as the source"+ aria-label="Use this gallery image as the source"+ >+ <img src={galleryItemUrl(g)} alt="" className="w-full h-full object-cover" onError={() => recoverGalleryUrl(g)} />+ </button>+ ))}+ </div>+ </div>+ )}</div>)}diff --git a/src/components/create/experimental/__tests__/galleryUrl.test.ts b/src/components/create/experimental/__tests__/galleryUrl.test.tsnew file mode 100644index 00000000..c1da03a7--- /dev/null+++ b/src/components/create/experimental/__tests__/galleryUrl.test.ts@@ -0,0 +1,78 @@+import { describe, it, expect, vi, beforeEach } from 'vitest'++// zustand persist reads window.localStorage at store-module load (node env+// has no DOM) — same hoisted Map shim as createStore.test.ts.+vi.hoisted(() => {+ const map = new Map<string, string>()+ const ls = {+ getItem: (k: string) => (map.has(k) ? map.get(k)! : null),+ setItem: (k: string, v: string) => { map.set(k, String(v)) },+ removeItem: (k: string) => { map.delete(k) },+ clear: () => { map.clear() },+ key: (i: number) => [...map.keys()][i] ?? null,+ get length() { return map.size },+ }+ ;(globalThis as unknown as { localStorage: unknown }).localStorage = ls+ const g = globalThis as unknown as { window?: Record<string, unknown> }+ g.window = Object.assign(g.window ?? {}, { localStorage: ls })+})++vi.mock('../../../../api/comfyui', () => ({+ getImageUrl: vi.fn((filename: string, subfolder?: string) => `http://127.0.0.1:8188/view?filename=${filename}&subfolder=${subfolder ?? ''}`),+ classifyModel: vi.fn(() => 'unknown'),+}))+vi.mock('../../../../api/cloud/jobs', () => ({+ refreshResultUrl: vi.fn(),+}))++import { fetchGalleryItemBlob } from '../galleryUrl'+import { refreshResultUrl } from '../../../../api/cloud/jobs'+import { useCreateStore, type GalleryItem } from '../../../../stores/createStore'++const baseItem: GalleryItem = {+ id: 'g1', filename: 'out.png', subfolder: '', type: 'image', prompt: '',+ negativePrompt: '', model: 'm', modelType: 'unknown', seed: 1, steps: 1,+ cfgScale: 1, sampler: 's', scheduler: 's', width: 8, height: 8,+ batchSize: 1, createdAt: 1,+} as GalleryItem++describe('fetchGalleryItemBlob', () => {+ beforeEach(() => {+ vi.restoreAllMocks()+ useCreateStore.setState({ gallery: [] })+ })++ it('returns the blob when the primary URL answers', async () => {+ const blob = new Blob(['x'], { type: 'image/png' })+ vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, blob: async () => blob })))+ await expect(fetchGalleryItemBlob({ ...baseItem, remoteUrl: 'https://cdn/x.png' })).resolves.toBe(blob)+ })++ it('re-signs an expired cloud URL once and retries (the "failed to fetch" ops bug)', async () => {+ const blob = new Blob(['y'], { type: 'image/png' })+ const fetchMock = vi.fn()+ .mockRejectedValueOnce(new TypeError('Failed to fetch'))+ .mockResolvedValueOnce({ ok: true, blob: async () => blob })+ vi.stubGlobal('fetch', fetchMock)+ vi.mocked(refreshResultUrl).mockResolvedValueOnce('https://cdn/fresh.png')+ const item = { ...baseItem, remoteUrl: 'https://cdn/expired.png', jobId: 'job-1' }+ useCreateStore.setState({ gallery: [item] })++ await expect(fetchGalleryItemBlob(item)).resolves.toBe(blob)+ expect(fetchMock).toHaveBeenLastCalledWith('https://cdn/fresh.png')+ // The gallery entry is patched so every surface re-renders with the fresh URL.+ expect(useCreateStore.getState().gallery[0].remoteUrl).toBe('https://cdn/fresh.png')+ })++ it('reports an honest error when the cloud copy is gone for good', async () => {+ vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new TypeError('Failed to fetch')))+ vi.mocked(refreshResultUrl).mockResolvedValueOnce(null as unknown as string)+ await expect(fetchGalleryItemBlob({ ...baseItem, remoteUrl: 'https://cdn/x.png', jobId: 'job-2' }))+ .rejects.toThrow(/no longer available/)+ })++ it('explains the dead local ComfyUI /view URL instead of a bare TypeError', async () => {+ vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new TypeError('Failed to fetch')))+ await expect(fetchGalleryItemBlob(baseItem)).rejects.toThrow(/ComfyUI/)+ })+})diff --git a/src/components/create/experimental/__tests__/intents.test.ts b/src/components/create/experimental/__tests__/intents.test.tsnew file mode 100644index 00000000..7a05adf4--- /dev/null+++ b/src/components/create/experimental/__tests__/intents.test.ts@@ -0,0 +1,24 @@+import { describe, it, expect } from 'vitest'+import { INTENTS, INTENT_MAP } from '../intents'++// David 2026-07-10: the advanced ops have no local models — they exist only on+// the cloud backend. Only plain generation and removebg (local RMBG node,+// rhodium92/e9aab21) keep a local lane.+describe('intent cloud gating', () => {+ it('edit, animate, upscale and eraser are cloud-only', () => {+ for (const id of ['edit', 'animate', 'upscale', 'eraser'] as const) {+ expect(INTENT_MAP[id].cloudOnly, id).toBe(true)+ }+ })++ it('image, video and removebg stay available locally', () => {+ for (const id of ['image', 'video', 'removebg'] as const) {+ expect(INTENT_MAP[id].cloudOnly, id).toBeUndefined()+ }+ })++ it('the local IntentBar filter keeps exactly the local lane', () => {+ const local = INTENTS.filter((m) => !m.cloudOnly).map((m) => m.id)+ expect(local).toEqual(['image', 'removebg', 'video'])+ })+})diff --git a/src/components/create/experimental/galleryUrl.ts b/src/components/create/experimental/galleryUrl.tsindex 038a1766..ae16a4df 100644--- a/src/components/create/experimental/galleryUrl.ts+++ b/src/components/create/experimental/galleryUrl.ts@@ -47,3 +47,35 @@ export function recoverGalleryUrl(item: GalleryItem): void {export function markGalleryItemAvailable(item: GalleryItem): void {if (item.unavailable) useCreateStore.getState().updateGalleryItem(item.id, { unavailable: undefined })}++/** Fetch a gallery item's media bytes for adoption as an op source.+ *+ * The naive `fetch(galleryItemUrl(item))` was the "failed to fetch" behind+ * every source-needing op in cloud mode (David 2026-07-10): a cloud item's+ * signed URL expires ~1 h after issue, and a local ComfyUI item's /view URL+ * is dead whenever the local engine isn't running — both surface as a bare+ * TypeError. Re-sign expired cloud media once via the job id, and turn the+ * unrecoverable cases into actionable messages. */+export async function fetchGalleryItemBlob(item: GalleryItem): Promise<Blob> {+ const tryFetch = async (url: string) => {+ const res = await fetch(url)+ if (!res.ok) throw new Error(`media request failed (${res.status})`)+ return res.blob()+ }+ try {+ return await tryFetch(galleryItemUrl(item))+ } catch (err) {+ if (item.jobId) {+ const fresh = await refreshResultUrl(item.jobId).catch(() => null)+ if (fresh) {+ useCreateStore.getState().updateGalleryItem(item.id, { remoteUrl: fresh, unavailable: undefined })+ return tryFetch(fresh)+ }+ throw new Error('The cloud copy of this render is no longer available — pick another image or upload one from disk.')+ }+ if (!item.remoteUrl && !item.dataUrl) {+ throw new Error('This image lives in your local ComfyUI output, which is not running right now — switch to Local (or start ComfyUI) to use it, or upload the file from disk.')+ }+ throw err+ }+}diff --git a/src/components/create/experimental/intents.ts b/src/components/create/experimental/intents.tsindex 46c38c9a..4d6f8346 100644--- a/src/components/create/experimental/intents.ts+++ b/src/components/create/experimental/intents.ts@@ -34,6 +34,7 @@ export const INTENTS: IntentMeta[] = [id: 'edit', label: 'Edit Image', short: 'Edit', icon: Wand2,placeholder: 'Describe the edit — what should change in the painted area…',needsSource: true, needsPrompt: true, allowsMask: true, isVideo: false,+ cloudOnly: true,examples: ['replace the sky with a starry night', 'add a leather jacket', 'remove the person on the left'],},{@@ -67,6 +68,7 @@ export const INTENTS: IntentMeta[] = [id: 'animate', label: 'Animate Image', short: 'Animate', icon: Film,placeholder: 'Describe how the image should move…',needsSource: true, needsPrompt: true, allowsMask: false, isVideo: true,+ cloudOnly: true,examples: ['slow zoom in, subtle parallax', 'hair and clothes moving in the wind'],},]diff --git a/src/stores/__tests__/createStore.test.ts b/src/stores/__tests__/createStore.test.tsindex 42acc5ca..764d18bf 100644--- a/src/stores/__tests__/createStore.test.ts+++ b/src/stores/__tests__/createStore.test.ts@@ -719,4 +719,67 @@ describe('createStore', () => {expect(useCreateStore.getState().progressText).toBe('')})})++ // David 2026-07-10: edit/animate/upscale/eraser are cloud-only — flipping+ // the backend to local must clear every cloud-only intent (the IntentBar no+ // longer shows them) so the surface never strands on a hidden op.+ describe('setBackend local-flip clears cloud-only intents', () => {+ const ref = { filename: 'src.png', url: 'data:image/png;base64,x', width: 8, height: 8 }++ it('clears a utility op (upscale) with its mask', () => {+ const s = useCreateStore.getState()+ s.setBackend('cloud')+ s.setIntent('upscale')+ s.setSource(ref)+ useCreateStore.getState().setBackend('local')+ const after = useCreateStore.getState()+ expect(after.utilityOp).toBeNull()+ expect(after.intent()).not.toBe('upscale')+ })++ it('clears edit (img2img falls back to text2img, source dropped)', () => {+ const s = useCreateStore.getState()+ s.setBackend('cloud')+ s.setIntent('edit')+ s.setSource(ref)+ useCreateStore.getState().setBackend('local')+ const after = useCreateStore.getState()+ expect(after.imageSubMode).toBe('text2img')+ expect(after.source).toBeNull()+ expect(after.intent()).toBe('image')+ })++ it('clears animate (i2v falls back to t2v)', () => {+ const s = useCreateStore.getState()+ s.setBackend('cloud')+ s.setIntent('animate')+ s.setSource(ref)+ useCreateStore.getState().setBackend('local')+ const after = useCreateStore.getState()+ expect(after.videoSubMode).toBe('t2v')+ expect(after.source).toBeNull()+ expect(after.intent()).toBe('video')+ })++ it('keeps removebg — it has a local lane via the RMBG node', () => {+ const s = useCreateStore.getState()+ s.setBackend('cloud')+ s.setIntent('removebg')+ s.setSource(ref)+ useCreateStore.getState().setBackend('local')+ const after = useCreateStore.getState()+ expect(after.intent()).toBe('removebg')+ expect(after.source).not.toBeNull()+ })++ it('flipping to cloud never resets anything', () => {+ const s = useCreateStore.getState()+ s.setBackend('local')+ s.setIntent('removebg')+ s.setSource(ref)+ useCreateStore.getState().setBackend('cloud')+ expect(useCreateStore.getState().intent()).toBe('removebg')+ expect(useCreateStore.getState().source).not.toBeNull()+ })+ })})diff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex 6f7be55d..dba6791b 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -444,12 +444,23 @@ export const useCreateStore = create<CreateState>()(setTargetResolution: (targetResolution) => set({ targetResolution }),setSource: (source) => set({ source, sourceSetAt: source ? Date.now() : 0, ...(source ? {} : { mask: null }) }),setMask: (mask) => set({ mask }),- // Flipping to local clears a cloud-only utility intent (upscale/eraser- // have no local lane) so the surface never strands on a dead op.+ // Flipping to local clears every cloud-only intent (edit/animate/+ // upscale/eraser have no local lane — David 2026-07-10: advanced ops are+ // cloud-only; only removebg keeps a local lane via the RMBG node) so the+ // surface never strands on a dead op the IntentBar no longer shows.setBackend: (backend) =>- set((s) =>- backend === 'local' && s.utilityOp ? { backend, utilityOp: null, mask: null, error: null } : { backend },- ),+ set((s) => {+ if (backend !== 'local') return { backend }+ const patch: Record<string, unknown> = { backend }+ if (s.utilityOp) Object.assign(patch, { utilityOp: null, mask: null, error: null })+ if (s.imageSubMode === 'img2img' && !s.removebg) {+ Object.assign(patch, { imageSubMode: 'text2img', source: null, mask: null, sourceSetAt: 0, error: null })+ }+ if (s.videoSubMode === 'i2v') {+ Object.assign(patch, { videoSubMode: 't2v', source: null, mask: null, sourceSetAt: 0, error: null })+ }+ return patch+ }),setCloudImageModel: (cloudImageModel) => set({ cloudImageModel }),setCloudVideoModel: (cloudVideoModel) => set({ cloudVideoModel }),setCaps: (caps) => set({ caps }),