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.

feat(create): local Edit tab — checkpoint mask inpaint + one-click install cards

purple93532b770cb6
diff --git a/src/api/__tests__/dynamic-workflow-inpaint.test.ts b/src/api/__tests__/dynamic-workflow-inpaint.test.ts
new file mode 100644
index 00000000..63724de0
--- /dev/null
+++ b/src/api/__tests__/dynamic-workflow-inpaint.test.ts
@@ -0,0 +1,130 @@
+/**
+ * Local Edit = mask inpaint (David 2026-07-12): with inputImage + maskImage on
+ * the checkpoint path, buildDynamicWorkflow must emit the inpaint pipeline —
+ * Path A (core VAEEncodeForInpaint) or Path B (InpaintModelConditioning) —
+ * instead of silently dropping the mask and repainting the whole image as
+ * plain img2img (the pre-2.5.7 behavior). Ported 1:1 from the web app's
+ * tested builder (create-workflows.ts).
+ *
+ * Run: npx vitest run src/api/__tests__/dynamic-workflow-inpaint.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+vi.mock('../comfyui-nodes', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('../comfyui-nodes')>()
+ return { ...actual, getAllNodeInfo: vi.fn() }
+})
+
+import { buildDynamicWorkflow, WorkflowUnavailableError } from '../dynamic-workflow'
+import { getAllNodeInfo } from '../comfyui-nodes'
+
+// Minimal live /object_info for an SDXL-checkpoint ComfyUI with core nodes.
+const CHECKPOINT_NODES: Record<string, unknown> = {
+ CheckpointLoaderSimple: { input: { required: { ckpt_name: [['sdxl.safetensors']] } } },
+ CLIPTextEncode: { input: { required: {} } },
+ KSampler: { input: { required: {} } },
+ EmptyLatentImage: { input: { required: {} } },
+ LoadImage: { input: { required: { image: [[]] } } },
+ LoadImageMask: { input: { required: { image: [[]] } } },
+ VAEEncode: { input: { required: {} } },
+ VAEEncodeForInpaint: { input: { required: {} } },
+ VAEDecode: { input: { required: {} } },
+ SaveImage: { input: { required: {} } },
+}
+
+const baseParams = {
+ model: 'sdxl.safetensors',
+ prompt: 'a red jacket', negativePrompt: 'blurry',
+ sampler: 'euler', scheduler: 'normal',
+ width: 1024, height: 1024, steps: 20, cfgScale: 7, seed: 1, batchSize: 1,
+} as never
+
+const node = (wf: Record<string, any>, type: string) =>
+ Object.entries(wf).find(([, n]) => n.class_type === type)
+
+describe('buildDynamicWorkflow — local Edit (mask inpaint, checkpoint path)', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ vi.mocked(getAllNodeInfo).mockResolvedValue(CHECKPOINT_NODES as never)
+ })
+
+ it('Path A: LoadImage + LoadImageMask(red) → VAEEncodeForInpaint → KSampler', async () => {
+ const wf = await buildDynamicWorkflow({
+ ...(baseParams as object),
+ inputImage: 'src.png', maskImage: 'mask.png', growMaskBy: 8,
+ } as never)
+
+ const types = Object.values(wf).map((n: any) => n.class_type)
+ expect(types).toContain('LoadImageMask')
+ expect(types).toContain('VAEEncodeForInpaint')
+ expect(types).not.toContain('EmptyLatentImage') // replaced by the inpaint latent
+ expect(types).not.toContain('VAEEncode') // NOT the plain-i2i encode
+
+ const [loadId, load] = node(wf, 'LoadImage')!
+ const [maskId, mask] = node(wf, 'LoadImageMask')!
+ const [encId, enc] = node(wf, 'VAEEncodeForInpaint')!
+ const [, sampler] = node(wf, 'KSampler')!
+ expect(load.inputs.image).toBe('src.png')
+ expect(mask.inputs).toEqual({ image: 'mask.png', channel: 'red' })
+ expect(enc.inputs.pixels).toEqual([loadId, 0])
+ expect(enc.inputs.mask).toEqual([maskId, 0])
+ expect(enc.inputs.grow_mask_by).toBe(8)
+ expect(sampler.inputs.latent_image).toEqual([encId, 0])
+ // Inpaint denoise default = 0.85 (web-builder parity)
+ expect(sampler.inputs.denoise).toBe(0.85)
+ })
+
+ it('Path B: InpaintModelConditioning rewires conditionings + latent slot 2', async () => {
+ vi.mocked(getAllNodeInfo).mockResolvedValue({
+ ...CHECKPOINT_NODES,
+ InpaintModelConditioning: { input: { required: {} } },
+ } as never)
+
+ const wf = await buildDynamicWorkflow({
+ ...(baseParams as object),
+ inputImage: 'src.png', maskImage: 'mask.png',
+ } as never)
+
+ const [condId, cond] = node(wf, 'InpaintModelConditioning')!
+ const [, sampler] = node(wf, 'KSampler')!
+ expect(cond.inputs.noise_mask).toBe(true)
+ expect(sampler.inputs.positive).toEqual([condId, 0])
+ expect(sampler.inputs.negative).toEqual([condId, 1])
+ expect(sampler.inputs.latent_image).toEqual([condId, 2])
+ expect(Object.values(wf).some((n: any) => n.class_type === 'VAEEncodeForInpaint')).toBe(false)
+ })
+
+ it('inpaint wins over plain i2i when both a mask and denoise<1 are present', async () => {
+ const wf = await buildDynamicWorkflow({
+ ...(baseParams as object),
+ inputImage: 'src.png', maskImage: 'mask.png', denoise: 0.6,
+ } as never)
+ expect(Object.values(wf).some((n: any) => n.class_type === 'VAEEncodeForInpaint')).toBe(true)
+ expect(Object.values(wf).some((n: any) => n.class_type === 'VAEEncode')).toBe(false)
+ expect(node(wf, 'KSampler')![1].inputs.denoise).toBe(0.6) // user strength honored
+ })
+
+ it('plain i2i without a mask still uses VAEEncode (no regression)', async () => {
+ const wf = await buildDynamicWorkflow({
+ ...(baseParams as object),
+ inputImage: 'src.png', denoise: 0.7,
+ } as never)
+ expect(Object.values(wf).some((n: any) => n.class_type === 'VAEEncode')).toBe(true)
+ expect(Object.values(wf).some((n: any) => n.class_type === 'VAEEncodeForInpaint')).toBe(false)
+ })
+
+ it('rejects a masked edit on a non-checkpoint strategy instead of dropping the mask', async () => {
+ vi.mocked(getAllNodeInfo).mockResolvedValue({
+ ...CHECKPOINT_NODES,
+ CheckpointLoaderSimple: { input: { required: { ckpt_name: [[]] } } },
+ UNETLoader: { input: { required: { unet_name: [['flux1-dev-fp8.safetensors']] } } },
+ DualCLIPLoader: { input: { required: {} } },
+ } as never)
+
+ await expect(buildDynamicWorkflow({
+ ...(baseParams as object),
+ model: 'flux1-dev-fp8.safetensors',
+ inputImage: 'src.png', maskImage: 'mask.png',
+ } as never)).rejects.toThrow(WorkflowUnavailableError)
+ })
+})
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 3b1d248f..b3075d54 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -37,6 +37,12 @@ export interface GenerateParams {
inputImage?: string // I2I source image filename (uploaded to ComfyUI)
denoise?: number // I2I denoise strength (0.0–1.0, default 1.0 = full txt2img)
removebg?: boolean // Background removal: LoadImage → RMBG → SaveImage cutout (no diffusion)
+ // Local Edit (mask inpaint): ComfyUI /upload/image filename of the painted
+ // mask (white = repaint). With inputImage set this selects the inpaint
+ // pipeline (VAEEncodeForInpaint / InpaintModelConditioning) on the
+ // SDXL/SD1.5 checkpoint path — same contract as the web app's builder.
+ maskImage?: string
+ growMaskBy?: number // Mask edge feather in pixels (VAEEncodeForInpaint grow_mask_by, default 6)
// F2 (cinemazverev GH#4), extended for multi-LoRA (konata 2026-06-09:
// "agent cannot load multiple loras"): one filename or an ordered list.
// Multiple LoRAs are CHAINED — LoraLoader N feeds (model, clip) into
diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.ts
index 63fba240..96f3a161 100644
--- a/src/api/dynamic-workflow.ts
+++ b/src/api/dynamic-workflow.ts
@@ -386,6 +386,17 @@ export async function buildDynamicWorkflow(
throw new WorkflowUnavailableError(reason, strategy, installHint)
}
+ // Local Edit (mask inpaint) runs on the SDXL/SD1.5 checkpoint pipeline only.
+ // Reject other strategies explicitly instead of silently dropping the mask —
+ // the pre-2.5.7 behavior was exactly that: a masked edit fell through to
+ // plain img2img and repainted the WHOLE image.
+ if (!isVideo && gp.inputImage && gp.maskImage && strategy !== 'checkpoint') {
+ throw new WorkflowUnavailableError(
+ 'Local image editing needs an SD 1.5 / SDXL checkpoint. Pick a checkpoint model for Edit — FLUX and video models are not wired for local inpaint.',
+ strategy,
+ )
+ }
+
const seed = params.seed === -1 ? Math.floor(Math.random() * 2147483647) : params.seed
// ─── Wrapper Strategies (custom node pipelines — completely different node chains) ───
@@ -672,8 +683,13 @@ export async function buildDynamicWorkflow(
}
// ─── Phase 3: Latent Initialization ───
+ // Inpaint mode (local Edit): source + painted mask on the checkpoint path.
+ // Takes precedence over plain I2I — a mask means "repaint THIS area", never
+ // "repaint everything". Ported 1:1 from the web app's tested builder
+ // (create-workflows.ts): same node classes, same defaults.
+ const isInpaint = !isVideo && !!gp.inputImage && !!gp.maskImage && strategy === 'checkpoint'
// I2I mode: LoadImage → VAEEncode instead of empty latent
- const isI2I = !isVideo && params.inputImage && (params.denoise ?? 1.0) < 1.0
+ const isI2I = !isVideo && !isInpaint && params.inputImage && (params.denoise ?? 1.0) < 1.0
const latentId = String(n++)
@@ -754,8 +770,12 @@ export async function buildDynamicWorkflow(
}
}
+ // The sampler consumes these refs; the I2I/inpaint overrides re-point them.
+ let latentRef: [string, number] = [latentId, 0]
+ let positiveRef: [string, number] = [posId, 0]
+ let negativeRef: [string, number] = [negId, 0]
+
// I2I override: replace empty latent with LoadImage → VAEEncode
- let latentSourceId = latentId
if (isI2I) {
const loadImageId = String(n++)
const vaeEncodeId = String(n++)
@@ -767,9 +787,53 @@ export async function buildDynamicWorkflow(
class_type: 'VAEEncode',
inputs: { pixels: [loadImageId, 0], vae: [vaeSourceId, vaeOutputSlot] },
}
- latentSourceId = vaeEncodeId
+ latentRef = [vaeEncodeId, 0]
// Remove the empty latent node since we're using the encoded image
delete workflow[latentId]
+ } else if (isInpaint) {
+ // Inpaint override: LoadImage + LoadImageMask (channel red — the mask
+ // editor exports white-where-painted on black), then:
+ // Path B (InpaintModelConditioning, FLUX-fill/SD3-style) when the node
+ // exists — rewrites BOTH conditionings and emits the latent on slot 2.
+ // Path A (core VAEEncodeForInpaint) — works with any SDXL/SD1.5
+ // checkpoint; grow_mask_by feathers the mask edge.
+ const loadImageId = String(n++)
+ const loadMaskId = String(n++)
+ workflow[loadImageId] = {
+ class_type: 'LoadImage',
+ inputs: { image: params.inputImage },
+ }
+ workflow[loadMaskId] = {
+ class_type: 'LoadImageMask',
+ inputs: { image: gp.maskImage, channel: 'red' },
+ }
+ if (allNodes['InpaintModelConditioning']) {
+ const condId = String(n++)
+ workflow[condId] = {
+ class_type: 'InpaintModelConditioning',
+ inputs: {
+ positive: positiveRef, negative: negativeRef,
+ vae: [vaeSourceId, vaeOutputSlot],
+ pixels: [loadImageId, 0], mask: [loadMaskId, 0], noise_mask: true,
+ },
+ _meta: { title: 'Inpaint Path B' },
+ }
+ positiveRef = [condId, 0]
+ negativeRef = [condId, 1]
+ latentRef = [condId, 2]
+ } else {
+ const encId = String(n++)
+ workflow[encId] = {
+ class_type: 'VAEEncodeForInpaint',
+ inputs: {
+ pixels: [loadImageId, 0], vae: [vaeSourceId, vaeOutputSlot],
+ mask: [loadMaskId, 0], grow_mask_by: gp.growMaskBy ?? 6,
+ },
+ _meta: { title: 'Inpaint Path A' },
+ }
+ latentRef = [encId, 0]
+ }
+ delete workflow[latentId]
}
// ─── Phase 4: Sampling ───
@@ -780,15 +844,15 @@ export async function buildDynamicWorkflow(
class_type: 'KSampler',
inputs: {
model: [samplerModelId, 0],
- positive: [posId, 0],
- negative: [negId, 0],
- latent_image: [latentSourceId, 0],
+ positive: positiveRef,
+ negative: negativeRef,
+ latent_image: latentRef,
seed,
steps: params.steps,
cfg: params.cfgScale,
sampler_name: params.sampler,
scheduler: params.scheduler,
- denoise: isI2I ? (params.denoise ?? 0.7) : 1.0,
+ denoise: isInpaint ? (params.denoise ?? 0.85) : isI2I ? (params.denoise ?? 0.7) : 1.0,
},
}
diff --git a/src/components/create/experimental/CreateContext.tsx b/src/components/create/experimental/CreateContext.tsx
index 78a34cda..f9dbd37a 100644
--- a/src/components/create/experimental/CreateContext.tsx
+++ b/src/components/create/experimental/CreateContext.tsx
@@ -3,9 +3,9 @@ import { useCreate } from '../../../hooks/useCreate'
import { useCloudCreate, hasActiveCloudRun } from '../../../hooks/useCloudCreate'
import { useCloudSession } from '../../../hooks/useCloudSession'
import { useCreateStore, type GalleryItem } from '../../../stores/createStore'
-import { getLoraModels, getVAEModels } from '../../../api/comfyui'
+import { getLoraModels, getVAEModels, checkComfyConnection, refreshComfyModels } from '../../../api/comfyui'
import { getAllNodeInfo, clearNodeCache } from '../../../api/comfyui-nodes'
-import { installCustomNodes } from '../../../api/discover'
+import { installCustomNodes, getImageBundles, getVideoBundles, startModelDownload, getDownloadProgress } from '../../../api/discover'
import { backendCall } from '../../../api/backend'
import { ensureLocalFilename } from './loadImage'
import type { CloudQuota } from '../../../lib/render/cloud-jobs'
@@ -34,11 +34,19 @@ interface CreateExpValue {
* RX 7900 XTX): surfaces the honest slow-mode warning instead of a silent
* 20-minute timeout. */
comfyOnCpu: boolean
- /** Install a missing capability in place: download the custom node, restart
- * ComfyUI, and re-probe until it's available. Reports progress via the
- * optional callback and throws on failure. Currently only background
- * removal (the RMBG node). */
- installCapability: (cap: 'rmbg', onProgress?: (msg: string) => void) => Promise<void>
+ /** Install a missing capability in place: ensure ComfyUI runs (installing it
+ * first if needed), download the custom node when one is required, restart,
+ * and re-probe until available. Reports progress via the optional callback
+ * and throws on failure. 'rmbg' = the RMBG cutout node; 'inpaint-nodes' =
+ * ComfyUI's core inpaint nodes (nothing to clone — present on any current
+ * install once ComfyUI is up). */
+ installCapability: (cap: 'rmbg' | 'inpaint-nodes', onProgress?: (msg: string) => void) => Promise<void>
+ /** One-click "everything you need" for a fresh PC: ensure ComfyUI runs
+ * (installing it first if needed), then download the default starter
+ * bundle for the intent kind (image → SDXL checkpoint, video → Wan 2.1)
+ * with streamed progress, refresh ComfyUI's model enums and re-fetch the
+ * model lists. Throws on failure. */
+ installModelBundle: (kind: 'image' | 'video', onProgress?: (msg: string) => void) => Promise<void>
/** Runtime backend axis: hosted rendering offered for this session? */
cloudAvailable: boolean
quota: CloudQuota | null
@@ -135,13 +143,63 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
return () => { cancelled = true }
}, [connected, setCaps])
- // Install background removal in place — mirrors the VHS one-click flow (#72):
- // clone the custom node + pip install, restart ComfyUI so it registers, then
- // poll /object_info (clearing the node cache each round so we don't read the
- // stale pre-install catalogue) until the RMBG node shows up. The BiRefNet /
- // RMBG-2.0 cutout model is fetched by the node itself on the first run.
- const installCapability = useCallback(async (cap: 'rmbg', onProgress?: (msg: string) => void) => {
- if (cap !== 'rmbg') return
+ // One-click prerequisite: make sure a local ComfyUI is actually running —
+ // start it if it's merely stopped, INSTALL it first if it's missing (the
+ // "complete noob PC" case: every Create tab's Download & install button must
+ // deliver a 100% functional run, not assume ComfyUI exists).
+ const ensureComfyRunning = useCallback(async (onProgress?: (msg: string) => void) => {
+ if (await checkComfyConnection()) return
+ onProgress?.('Starting ComfyUI…')
+ try { await backendCall('start_comfyui') } catch { /* not installed yet — handled below */ }
+ for (let i = 0; i < 15; i++) {
+ await new Promise((r) => setTimeout(r, 2000))
+ if (await checkComfyConnection()) { checkConnection(); return }
+ }
+ onProgress?.('ComfyUI is not installed — downloading & installing it now (one-time, a few GB)…')
+ await backendCall('install_comfyui')
+ // Poll the same status contract the Settings installer uses. Generous cap:
+ // a slow connection legitimately needs a while for the one-time install.
+ for (let i = 0; i < 2700; i++) {
+ await new Promise((r) => setTimeout(r, 2000))
+ const st = await backendCall<{ status?: string; logs?: string[] }>('install_comfyui_status').catch(() => null)
+ const lastLog = st?.logs?.length ? String(st.logs[st.logs.length - 1]) : ''
+ if (lastLog) onProgress?.(lastLog)
+ if (st?.status === 'complete') break
+ if (st?.status === 'error') {
+ throw new Error(lastLog || 'ComfyUI install failed — see Settings → AI Backends for details.')
+ }
+ }
+ onProgress?.('Starting ComfyUI…')
+ await backendCall('start_comfyui')
+ for (let i = 0; i < 30; i++) {
+ await new Promise((r) => setTimeout(r, 2000))
+ if (await checkComfyConnection()) { checkConnection(); return }
+ }
+ throw new Error('Installed ComfyUI but it did not come up — check Settings → AI Backends.')
+ }, [checkConnection])
+
+ // Install a capability in place — mirrors the VHS one-click flow (#72):
+ // ensure ComfyUI runs, clone the custom node + pip install where one is
+ // needed, restart ComfyUI so it registers, then poll /object_info (clearing
+ // the node cache each round so we don't read the stale pre-install
+ // catalogue) until the node shows up. The BiRefNet / RMBG-2.0 cutout model
+ // is fetched by the node itself on the first run.
+ const installCapability = useCallback(async (cap: 'rmbg' | 'inpaint-nodes', onProgress?: (msg: string) => void) => {
+ await ensureComfyRunning(onProgress)
+ if (cap === 'inpaint-nodes') {
+ // Core ComfyUI nodes — nothing to clone. If they're still missing after
+ // ComfyUI is up, the install is ancient; re-probe and say so honestly.
+ const nodes = await getAllNodeInfo()
+ const names = new Set(Object.keys(nodes))
+ const ok = names.has('VAEEncodeForInpaint') || names.has('InpaintModelConditioning')
+ setCaps({ rmbg: names.has('RMBG'), 'inpaint-nodes': ok })
+ if (!ok) {
+ throw new Error(
+ 'This ComfyUI is missing its core inpaint nodes (VAEEncodeForInpaint) — update ComfyUI to a current version.',
+ )
+ }
+ return
+ }
onProgress?.('Downloading & installing the background-removal node — this can take a minute…')
await installCustomNodes(['rmbg'])
onProgress?.('Restarting ComfyUI to register the node…')
@@ -168,7 +226,43 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
"Installed ComfyUI-RMBG and restarted ComfyUI, but it still isn't listing the RMBG node. " +
'Open the Model Manager to finish the install, or check the ComfyUI console for a pip error.',
)
- }, [setCaps])
+ }, [setCaps, ensureComfyRunning])
+
+ // One-click starter models for a fresh PC: ensure ComfyUI, then pull the
+ // default bundle for the intent kind (image → SDXL checkpoint, video →
+ // Wan 2.1 files) through the existing resumable downloader, streaming
+ // percent progress into the card, then refresh ComfyUI's model enums so the
+ // new files are pickable without a restart.
+ const installModelBundle = useCallback(async (kind: 'image' | 'video', onProgress?: (msg: string) => void) => {
+ await ensureComfyRunning(onProgress)
+ const bundle = (kind === 'image' ? getImageBundles() : getVideoBundles())[0]
+ if (!bundle) throw new Error('No starter bundle available for this intent.')
+ for (const file of bundle.files) {
+ if (!file.downloadUrl || !file.filename || !file.subfolder) continue
+ const size = file.sizeGB ? ` (${file.sizeGB} GB)` : ''
+ onProgress?.(`Downloading ${file.filename}${size}…`)
+ const expected = file.sizeGB ? Math.round(file.sizeGB * 1_073_741_824) : undefined
+ const start = await startModelDownload(file.downloadUrl, file.subfolder, file.filename, expected)
+ if (start.status === 'error') throw new Error(start.error || `Could not start the ${file.filename} download.`)
+ // 'exists' = already complete on disk — skip polling.
+ if (start.status !== 'exists') {
+ for (;;) {
+ await new Promise((r) => setTimeout(r, 1500))
+ const all = await getDownloadProgress()
+ const p = Object.values(all).find((d) => d.filename === file.filename)
+ if (!p || p.status === 'complete') break
+ if (p.status === 'error') throw new Error(p.error || `Download failed: ${file.filename}`)
+ if (p.total > 0) {
+ onProgress?.(`Downloading ${file.filename} — ${Math.round((p.progress / p.total) * 100)}%`)
+ }
+ }
+ }
+ }
+ onProgress?.('Refreshing the model list…')
+ await refreshComfyModels().catch(() => false)
+ clearNodeCache()
+ await fetchModels()
+ }, [ensureComfyRunning, fetchModels])
const value: CreateExpValue = {
generate: backend === 'cloud' ? cloud.generate : generate,
@@ -179,7 +273,7 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
cancel: () => (hasActiveCloudRun() ? cloud.cancel() : cancel()),
enhanceVideo: cloud.enhanceVideo,
samplerList, schedulerList, loraList, vaeList,
- connected, modelsLoaded, modelLoadError, comfyOnCpu, installCapability,
+ connected, modelsLoaded, modelLoadError, comfyOnCpu, installCapability, installModelBundle,
cloudAvailable, quota, refreshQuota,
}
return <Ctx.Provider value={value}>{children}</Ctx.Provider>
diff --git a/src/components/create/experimental/Stage.tsx b/src/components/create/experimental/Stage.tsx
index b17e1b8e..aab14abc 100644
--- a/src/components/create/experimental/Stage.tsx
+++ b/src/components/create/experimental/Stage.tsx
@@ -1,6 +1,6 @@
import { useRef, useState } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
-import { UploadCloud, ImagePlus, Scissors, Wand2, Sparkles, X, Loader2, Download, AlertTriangle } from 'lucide-react'
+import { UploadCloud, ImagePlus, Scissors, Wand2, Sparkles, X, Loader2, Download, AlertTriangle, Image as ImageIcon, Film } from 'lucide-react'
import { useCreateStore, type GalleryItem } from '../../../stores/createStore'
import { useCreateExp } from './CreateContext'
import { INTENT_MAP } from './intents'
@@ -29,12 +29,24 @@ export function Stage({ displayed, onOpenMaskEditor, onEditResult, onFullscreen
const setPrompt = useCreateStore((s) => s.setPrompt)
const caps = useCreateStore((s) => s.caps)
const backend = useCreateStore((s) => s.backend)
+ const imageModelList = useCreateStore((s) => s.imageModelList)
+ const videoModelList = useCreateStore((s) => s.videoModelList)
+ const { connected, modelsLoaded } = useCreateExp()
// On the cloud backend the utility ops (background removal, …) run on
// WaveSpeed's hosted endpoints — there's no local ComfyUI node to install,
// so the capability is always ready. Only the local backend gates on the
// node probe (which never runs without a local ComfyUI and would strand
// cloud users on a dead "Open Model Manager" card).
const capReady = !meta.capability || backend === 'cloud' || !!caps[meta.capability]
+ // Local model files missing for this intent (fresh PC): gate the stage on a
+ // one-click starter-bundle card. connected === false also gates — the same
+ // button installs ComfyUI itself first. connected === null (still probing)
+ // gates nothing, so the card never flashes during startup.
+ const modelsMissing = backend === 'local' && !!meta.requiresModels && (
+ connected === false ||
+ (connected === true && modelsLoaded &&
+ (meta.requiresModels === 'image' ? imageModelList.length === 0 : videoModelList.length === 0))
+ )
// A result counts for the current source only if it was generated after the
// source was loaded — otherwise an older gallery item would hijack the stage.
@@ -43,6 +55,8 @@ export function Stage({ displayed, onOpenMaskEditor, onEditResult, onFullscreen
let body: React.ReactNode
if (isGenerating) {
body = <GeneratingView />
+ } else if (modelsMissing) {
+ body = <ModelInstallCard kind={meta.requiresModels!} />
} else if (meta.capability && !capReady) {
body = <CapabilityCard cap={meta.capability} />
} else if (meta.needsSource && !source) {
@@ -279,17 +293,60 @@ function ChangeImageButton({ onChange }: { onChange: (r: Awaited<ReturnType<type
)
}
+// ── Shared install-card chrome: spinner + streamed status + dismissible error ──
+function InstallCardBody({ run, installing, status, err, onDismiss }: {
+ run: () => void; installing: boolean; status: string; err: string | null; onDismiss: () => void
+}) {
+ return (
+ <div className="flex flex-col items-center gap-2.5 pt-1">
+ {installing ? (
+ <div className="t-control text-gray-400 flex items-center gap-2">
+ <Loader2 size={14} className="animate-spin shrink-0" />
+ <span>{status || 'Installing…'}</span>
+ </div>
+ ) : (
+ <Button variant="primary" icon={Download} onClick={run}>Download &amp; install</Button>
+ )}
+ {err && (
+ <div className="relative t-control text-gray-300 bg-white/[0.03] rounded-[var(--radius-control)] px-2.5 py-2 pr-7 max-w-sm text-left">
+ <div className="flex items-start gap-2">
+ <AlertTriangle size={13} className="text-gray-400 shrink-0 mt-px" />
+ <span className="min-w-0 break-words">{err}</span>
+ </div>
+ <button onClick={onDismiss} className="absolute top-1.5 right-1.5 text-gray-500 hover:text-gray-300 transition-colors" title="Dismiss" aria-label="Dismiss">
+ <X size={12} />
+ </button>
+ </div>
+ )}
+ </div>
+ )
+}
+
// ── Capability missing → one-click install right here ──
-function CapabilityCard({ cap }: { cap: 'rmbg' }) {
+const CAP_COPY = {
+ rmbg: {
+ icon: Scissors,
+ title: 'Background removal needs a one-time download',
+ description: 'The AI cutout runs fully locally (ComfyUI-RMBG). This installs the node now — the ~300 MB cutout model downloads automatically on your first cutout.',
+ },
+ 'inpaint-nodes': {
+ icon: Wand2,
+ title: 'Image editing needs ComfyUI up and running',
+ description: 'Local Edit repaints the masked area with ComfyUI’s built-in inpaint nodes. This starts ComfyUI (installing it first if needed) and verifies the nodes.',
+ },
+} as const
+
+function CapabilityCard({ cap }: { cap: 'rmbg' | 'inpaint-nodes' }) {
const { installCapability } = useCreateExp()
const [installing, setInstalling] = useState(false)
const [status, setStatus] = useState('')
const [err, setErr] = useState<string | null>(null)
+ const copy = CAP_COPY[cap]
const run = async () => {
setInstalling(true); setErr(null); setStatus('Starting…')
try {
- // On success caps.rmbg flips true and Stage swaps this card for the input slot.
+ // On success the capability flips true and Stage swaps this card for the input slot.
await installCapability(cap, setStatus)
} catch (e) {
setErr(e instanceof Error ? e.message : String(e))
@@ -299,33 +356,48 @@ function CapabilityCard({ cap }: { cap: 'rmbg' }) {
}
return (
- <EmptyState
- icon={Scissors}
- tone="accent"
- title="Background removal needs a one-time download"
- description="The AI cutout runs fully locally (ComfyUI-RMBG). This installs the node now — the ~300 MB cutout model downloads automatically on your first cutout."
- >
- <div className="flex flex-col items-center gap-2.5 pt-1">
- {installing ? (
- <div className="t-control text-gray-400 flex items-center gap-2">
- <Loader2 size={14} className="animate-spin shrink-0" />
- <span>{status || 'Installing…'}</span>
- </div>
- ) : (
- <Button variant="primary" icon={Download} onClick={run}>Download &amp; install</Button>
- )}
- {err && (
- <div className="relative t-control text-gray-300 bg-white/[0.03] rounded-[var(--radius-control)] px-2.5 py-2 pr-7 max-w-sm text-left">
- <div className="flex items-start gap-2">
- <AlertTriangle size={13} className="text-gray-400 shrink-0 mt-px" />
- <span className="min-w-0 break-words">{err}</span>
- </div>
- <button onClick={() => setErr(null)} className="absolute top-1.5 right-1.5 text-gray-500 hover:text-gray-300 transition-colors" title="Dismiss" aria-label="Dismiss">
- <X size={12} />
- </button>
- </div>
- )}
- </div>
+ <EmptyState icon={copy.icon} tone="accent" title={copy.title} description={copy.description}>
+ <InstallCardBody run={run} installing={installing} status={status} err={err} onDismiss={() => setErr(null)} />
+ </EmptyState>
+ )
+}
+
+// ── Local model files missing → one-click starter bundle (fresh-PC path) ──
+const BUNDLE_COPY = {
+ image: {
+ icon: ImageIcon,
+ title: 'Local image generation needs a one-time download',
+ description: 'This sets up everything for a fully local run: ComfyUI itself if it’s missing, plus the Juggernaut XL starter checkpoint (~6.5 GB) — the same model also powers the local Edit tab.',
+ },
+ video: {
+ icon: Film,
+ title: 'Local video generation needs a one-time download',
+ description: 'This sets up everything for a fully local run: ComfyUI itself if it’s missing, plus the Wan 2.1 starter model files (~9.2 GB, 480p, light on VRAM).',
+ },
+} as const
+
+function ModelInstallCard({ kind }: { kind: 'image' | 'video' }) {
+ const { installModelBundle } = useCreateExp()
+ const [installing, setInstalling] = useState(false)
+ const [status, setStatus] = useState('')
+ const [err, setErr] = useState<string | null>(null)
+ const copy = BUNDLE_COPY[kind]
+
+ const run = async () => {
+ setInstalling(true); setErr(null); setStatus('Starting…')
+ try {
+ // On success the model lists refill and Stage swaps this card away.
+ await installModelBundle(kind, setStatus)
+ } catch (e) {
+ setErr(e instanceof Error ? e.message : String(e))
+ } finally {
+ setInstalling(false)
+ }
+ }
+
+ return (
+ <EmptyState icon={copy.icon} tone="accent" title={copy.title} description={copy.description}>
+ <InstallCardBody run={run} installing={installing} status={status} err={err} onDismiss={() => setErr(null)} />
</EmptyState>
)
}
diff --git a/src/components/create/experimental/__tests__/intents.test.ts b/src/components/create/experimental/__tests__/intents.test.ts
index 7a05adf4..d943b0fc 100644
--- a/src/components/create/experimental/__tests__/intents.test.ts
+++ b/src/components/create/experimental/__tests__/intents.test.ts
@@ -1,24 +1,34 @@
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.
+// David 2026-07-10 made the advanced ops cloud-only; David 2026-07-12 brought
+// Edit BACK to local as the 4th local tab (checkpoint mask inpaint —
+// VAEEncodeForInpaint / InpaintModelConditioning). Animate, upscale and eraser
+// remain hosted-endpoint-only.
describe('intent cloud gating', () => {
- it('edit, animate, upscale and eraser are cloud-only', () => {
- for (const id of ['edit', 'animate', 'upscale', 'eraser'] as const) {
+ it('animate, upscale and eraser are cloud-only', () => {
+ for (const id of ['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) {
+ it('image, edit, video and removebg stay available locally', () => {
+ for (const id of ['image', 'edit', 'video', 'removebg'] as const) {
expect(INTENT_MAP[id].cloudOnly, id).toBeUndefined()
}
})
- it('the local IntentBar filter keeps exactly the local lane', () => {
+ it('the local IntentBar filter keeps exactly the 4 local tabs', () => {
const local = INTENTS.filter((m) => !m.cloudOnly).map((m) => m.id)
- expect(local).toEqual(['image', 'removebg', 'video'])
+ expect(local).toEqual(['image', 'edit', 'removebg', 'video'])
+ })
+
+ it('local edit gates on the inpaint capability + image models', () => {
+ expect(INTENT_MAP.edit.capability).toBe('inpaint-nodes')
+ expect(INTENT_MAP.edit.requiresModels).toBe('image')
+ expect(INTENT_MAP.edit.allowsMask).toBe(true)
+ // The fresh-PC Download & install card also covers plain generation.
+ expect(INTENT_MAP.image.requiresModels).toBe('image')
+ expect(INTENT_MAP.video.requiresModels).toBe('video')
})
})
diff --git a/src/components/create/experimental/intents.ts b/src/components/create/experimental/intents.ts
index 4d6f8346..ea710dd5 100644
--- a/src/components/create/experimental/intents.ts
+++ b/src/components/create/experimental/intents.ts
@@ -12,10 +12,12 @@ export interface IntentMeta {
needsPrompt: boolean
allowsMask: boolean
isVideo: boolean
- /** Capability id (custom-node bundle) this intent depends on, if any. */
- capability?: 'rmbg'
+ /** Capability id (node probe) this intent depends on, if any. */
+ capability?: 'rmbg' | 'inpaint-nodes'
/** Single-purpose hosted endpoints — only offered on the cloud backend. */
cloudOnly?: true
+ /** Local model files this intent needs (gates the Download & install card). */
+ requiresModels?: 'image' | 'video'
examples: string[]
}
@@ -24,6 +26,7 @@ export const INTENTS: IntentMeta[] = [
id: 'image', label: 'Image', short: 'Image', icon: ImageIcon,
placeholder: 'Describe your image…',
needsSource: false, needsPrompt: true, allowsMask: false, isVideo: false,
+ requiresModels: 'image',
examples: [
'a lighthouse at dusk, dramatic storm clouds, cinematic',
'a neon-lit alley in the rain, reflections, moody',
@@ -31,10 +34,13 @@ export const INTENTS: IntentMeta[] = [
],
},
{
+ // Local lane since 2.5.7: mask inpaint on the SDXL/SD1.5 checkpoint path
+ // (VAEEncodeForInpaint / InpaintModelConditioning) — the 4th local tab.
+ // Cloud keeps its hosted edit endpoint; both share the MaskEditor.
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,
+ capability: 'inpaint-nodes', requiresModels: 'image',
examples: ['replace the sky with a starry night', 'add a leather jacket', 'remove the person on the left'],
},
{
@@ -62,6 +68,7 @@ export const INTENTS: IntentMeta[] = [
id: 'video', label: 'Video', short: 'Video', icon: Video,
placeholder: 'Describe the motion and the scene…',
needsSource: false, needsPrompt: true, allowsMask: false, isVideo: true,
+ requiresModels: 'video',
examples: ['a slow-motion wave breaking on rocks, cinematic', 'timelapse of clouds over a mountain range'],
},
{
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index fdb73c20..b49e9eec 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -287,6 +287,12 @@ export function useCreate() {
setError('Please add a source image first.')
return
}
+ // Local Edit is mask inpaint — without a painted mask it would silently
+ // degrade to plain img2img and repaint the WHOLE image.
+ if (intent === 'edit' && !maskFilename) {
+ setError('Paint a mask first — open the mask editor and mark the area to change.')
+ return
+ }
if (!isRemoveBg && !activeModel) {
setError(mode === 'image'
? 'No image model selected. Add checkpoints or FLUX models to ComfyUI.'
diff --git a/src/stores/__tests__/createStore.test.ts b/src/stores/__tests__/createStore.test.ts
index 764d18bf..7db2bbd7 100644
--- a/src/stores/__tests__/createStore.test.ts
+++ b/src/stores/__tests__/createStore.test.ts
@@ -737,16 +737,15 @@ describe('createStore', () => {
expect(after.intent()).not.toBe('upscale')
})
- it('clears edit (img2img falls back to text2img, source dropped)', () => {
+ it('keeps edit — it has a local lane via checkpoint inpaint (2.5.7)', () => {
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')
+ expect(after.intent()).toBe('edit')
+ expect(after.source).not.toBeNull()
})
it('clears animate (i2v falls back to t2v)', () => {
diff --git a/src/stores/createStore.ts b/src/stores/createStore.ts
index dba6791b..d994b961 100644
--- a/src/stores/createStore.ts
+++ b/src/stores/createStore.ts
@@ -444,18 +444,16 @@ 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 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.
+ // Flipping to local clears the intents that STILL have no local lane
+ // (upscale/eraser hosted endpoints, animate i2v) so the surface never
+ // strands on a dead op the IntentBar no longer shows. Edit keeps its
+ // state since 2.5.7 — it has a local lane now (checkpoint mask inpaint),
+ // exactly like removebg keeps its local RMBG lane.
setBackend: (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 })
}