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(create): needsMask haelt den Create-Knopf aus, statt in einen Serverfehler zu laufen (R5-66)
purple87221f8408f4
diff --git a/src/components/create/experimental/Composer.tsx b/src/components/create/experimental/Composer.tsxindex 2c1e4a0a..cdfb0763 100644--- a/src/components/create/experimental/Composer.tsx+++ b/src/components/create/experimental/Composer.tsx@@ -18,6 +18,7 @@ import { INTENT_MAP } from './intents'import { subscribeInstallRuns, getInstallRun } from '../../../lib/model-install-runs'import { useWorkflowStore, shouldShowManagerNotice } from '../../../stores/workflowStore'import { noPromptHint, shouldShowLaneHint } from './laneHint'+import { needsMaskFor } from './maskGate'import { ModelChip } from './ModelChip'import { PromptHistory } from './PromptHistory'import { SpecialControls } from './SpecialIntentControls'@@ -44,6 +45,7 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {const showNegative = useCreateStore((s) => s.showNegative)const toggleNegative = useCreateStore((s) => s.toggleNegative)const source = useCreateStore((s) => s.source)+ const mask = useCreateStore((s) => s.mask)const isGenerating = useCreateStore((s) => s.isGenerating)const backend = useCreateStore((s) => s.backend)const targetResolution = useCreateStore((s) => s.targetResolution)@@ -132,6 +134,8 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {// hide the toggle (and the collapsed field) where it would be silently// dropped, like the other dead knobs on cloud.const negSupported = backend !== 'cloud' || cloudModelById(runModel)?.negative_prompt === true+ // R5-66: see maskGate.ts for the full rule and why 'edit' differs from Web.+ const needsMask = needsMaskFor(intent, backend, cloudModelById(runModel)?.maskless)// Per-intent readiness for the 2.5.8 categories (mirrors the submit-time// checks of BOTH lanes so the button never invites a doomed run). The// local lanes always speak from a portrait (no hosted resync endpoints)@@ -164,6 +168,7 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {const canGenerate =(!needPrompt || prompt.trim().length > 0) &&(!meta.needsSource || !!source) &&+ (!needsMask || !!mask) &&specialReady &&creditsOk &&!installing@@ -192,7 +197,16 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {<PromptFieldvalue={prompt}onChange={setPrompt}- placeholder={characterUse ? 'Describe the scene for your character…' : meta.placeholder}+ placeholder={+ characterUse+ ? 'Describe the scene for your character…'+ // R5-66: the shared 'edit' placeholder promises a maskless+ // restyle that only the local lane actually allows once a+ // cloud model requires a mask.+ : (intent === 'edit' && needsMask+ ? 'Describe the new look. Paint an area first to tell it what to change…'+ : meta.placeholder)+ }onSubmit={() => canGenerate && !isGenerating && guardedGenerate()}/></div>diff --git a/src/components/create/experimental/__tests__/mask-gate.test.ts b/src/components/create/experimental/__tests__/mask-gate.test.tsnew file mode 100644index 00000000..7313e189--- /dev/null+++ b/src/components/create/experimental/__tests__/mask-gate.test.ts@@ -0,0 +1,55 @@+/**+ * R5-66 — before this fix, `Composer.tsx`'s `canGenerate` never looked at+ * `useCreateStore.mask` at all: a cloud edit or an eraser run with no mask+ * painted was submitted anyway and came back as a server error, instead of+ * the Create button simply staying off. `needsMaskFor` (maskGate.ts) is the+ * pure rule `canGenerate` now folds in via `!needsMask || !!mask`.+ *+ * Run: npx vitest run src/components/create/experimental/__tests__/mask-gate.test.ts+ */+import { describe, it, expect } from 'vitest'+import { readFileSync } from 'node:fs'+import { fileURLToPath } from 'node:url'+import { dirname, resolve } from 'node:path'+import { needsMaskFor } from '../maskGate'++describe('R5-66: needsMaskFor', () => {+ it('eraser always needs a mask, on every backend', () => {+ expect(needsMaskFor('eraser', 'cloud', undefined)).toBe(true)+ expect(needsMaskFor('eraser', 'local', undefined)).toBe(true)+ })++ it('cloud edit needs a mask unless the resolved model is maskless', () => {+ expect(needsMaskFor('edit', 'cloud', undefined)).toBe(true)+ expect(needsMaskFor('edit', 'cloud', false)).toBe(true)+ expect(needsMaskFor('edit', 'cloud', true)).toBe(false)+ })++ it('NEGATIVE CONTROL: local edit never needs a mask, matching the maskless restyle design', () => {+ expect(needsMaskFor('edit', 'local', undefined)).toBe(false)+ expect(needsMaskFor('edit', 'local', false)).toBe(false)+ expect(needsMaskFor('edit', 'local', true)).toBe(false)+ })++ it('every other intent never needs a mask', () => {+ for (const id of ['image', 'video', 'animate', 'removebg', 'upscale', 'character', 'lipsync', 'music', 'extend', 'motion'] as const) {+ expect(needsMaskFor(id, 'cloud', undefined)).toBe(false)+ expect(needsMaskFor(id, 'local', undefined)).toBe(false)+ }+ })+})++describe('R5-66: Composer.tsx actually wires needsMaskFor into canGenerate', () => {+ const here = dirname(fileURLToPath(import.meta.url))+ const src = readFileSync(resolve(here, '../Composer.tsx'), 'utf8')++ it('reads the mask from the store', () => {+ expect(src).toContain("const mask = useCreateStore((s) => s.mask)")+ })++ it('calls needsMaskFor and folds the result into canGenerate', () => {+ expect(src).toContain('needsMaskFor(intent, backend,')+ const canGenerateBlock = src.slice(src.indexOf('const canGenerate ='), src.indexOf('const canGenerate =') + 400)+ expect(canGenerateBlock).toContain('!needsMask || !!mask')+ })+})diff --git a/src/components/create/experimental/maskGate.ts b/src/components/create/experimental/maskGate.tsnew file mode 100644index 00000000..fa956837--- /dev/null+++ b/src/components/create/experimental/maskGate.ts@@ -0,0 +1,24 @@+// R5-66 — whether the current lane needs a painted mask before Create can run.+// Pure and testable on its own, same pattern as stageGate.ts / laneHint.ts.+//+// Web gates 'edit' on `meta.needsMask` unconditionally (its edit intent has+// no maskless model at all). Desktop's local 'edit' lane is different by+// design: an empty mask restyles the whole image (VAEEncode at denoise 0.7,+// see the comment on the 'edit' entry in intents.ts), so only the CLOUD lane+// needs a mask, and only when the resolved model is not an instruction-based,+// maskless endpoint (qwen-image-edit). Before this fix nothing gated 'edit' on+// the mask at all, so a cloud edit without one ran the pick-a-model default+// and came back with a server error instead of the button staying off.+import type { CreateBackend, CreateIntent } from '../../../stores/createStore'++export function needsMaskFor(+ intent: CreateIntent,+ backend: CreateBackend,+ /** Whether the model the run will actually use is maskless (undefined = no+ * catalog entry found, treated as NOT maskless — the safer default). */+ runModelMaskless: boolean | undefined,+): boolean {+ if (intent === 'eraser') return true+ if (intent === 'edit') return backend === 'cloud' && runModelMaskless !== true+ return false+}