The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Composer: Inpaint asks to paint the area once its image is in; promptless models get no prompt suggestions
Claudec214f2029f02
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsxindex fe8f7f8c..23ab52db 100644--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@ -12,7 +12,7 @@ import type { GenerationRequest, MediaKind, ModelDef, Operation, Preset } from "import { enhance, useCreateGeneration, useElements, useEngine, useHydrated, useStatus } from "@/lib/api";import { applyMentions, type StudioElement } from "@/lib/catalog/elements";import { applySketch, stripMotionPaths } from "@/lib/catalog/sketch";-import { blockerFor, costLabel, filterModels, firstMissingSlot, namedImageSlots, PLACEHOLDER, pushRecent, settingsShape } from "@/lib/composer";+import { blockerFor, costLabel, filterModels, firstMissingSlot, namedImageSlots, needsMask, PLACEHOLDER, promptShown, pushRecent, settingsShape } from "@/lib/composer";import { formatCost } from "@/lib/format";import { cn } from "@/lib/utils";import { AttachMenu } from "./attach-menu";@@ -245,6 +245,7 @@ export function Composer({ docked }: { docked: boolean }) {engineError,missing,uploading,+ maskMissing: needsMask(model, config.sketch, draft.slots),planError,promptMissing,});@@ -305,7 +306,7 @@ export function Composer({ docked }: { docked: boolean }) {// Studios with the Moodboard chip pick Soul's styles there (its Curated tab), not in a second Style chip.const soulStyles = !!config.signature && (opts.presets?.source === "soul-v1" || opts.presets?.source === "soul-v2");const opNote = op && model ? routesFor(model, op)[0]?.note : undefined;- const showPrompt = !config.hidePrompt && preset?.userPrompt !== "none" && !opts.promptless;+ const showPrompt = promptShown(config.hidePrompt, preset?.userPrompt, model?.options.promptless);const effectiveOp = studioOp ?? op;const shape = settingsShape(model, effectiveOp, config.kind, showPrompt, p, config.ops);const demo = !!(model && status && status.demoMode !== "off" && !model.routes.some((r) => status.providers[r.provider]?.configured));diff --git a/src/components/studio/sketch-tools.tsx b/src/components/studio/sketch-tools.tsxindex 6912b3d8..60e4bfbd 100644--- a/src/components/studio/sketch-tools.tsx+++ b/src/components/studio/sketch-tools.tsx@@ -62,6 +62,8 @@ export function SketchTools({ modes, image, autoOpen }: { modes: SketchMode[]; i<TooltipTrigger asChild><buttononClick={() => setEditing(m)}+ // Generate points here when the painted area is what it's waiting for.+ data-slot-key={m === "mask" ? "mask" : "sketch"}className="flex size-14 shrink-0 flex-col items-center justify-center gap-0.5 rounded-xl border border-dashed border-primary/50 bg-brand-faint text-brand-text transition-colors hover:border-primary">{m === "mask" ? <Brush className="size-4" /> : <PenLine className="size-4" />}diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsxindex d42741ce..72c45052 100644--- a/src/components/studio/studio-page.tsx+++ b/src/components/studio/studio-page.tsx@@ -9,7 +9,7 @@ import { toast } from "sonner";import { SidebarTrigger } from "@/components/ui/sidebar";import type { Generation, MediaKind, ModelDef, Preset } from "@/lib/catalog/types";import { useEngine, useGenerations } from "@/lib/api";-import { handoffKey, mergeHandoff } from "@/lib/composer";+import { handoffKey, mergeHandoff, promptShown } from "@/lib/composer";import { reuseSignature, withSignatureWords } from "@/lib/catalog/palettes";import { SoulPresetCards } from "@/components/moodboards/soul-preset-cards";import type { StudioCatalog } from "@/lib/studio-catalog";@@ -178,6 +178,31 @@ function ActivePresetHeader() {);}+/**+ * Example prompts under the hero. Its own component: it follows the picked model (a model that+ * takes no prompt, like FASHN try-on, gets none), so it re-renders with the draft, not the page.+ */+function PromptSuggestions({ suggestions }: { suggestions: string[] }) {+ const { config, draft, setDraft } = useStudio();+ const catalog = useCatalog();+ const preset = draft.presetId ? catalog.getPreset(draft.presetId) : config.preset;+ const model = catalog.getModel(draft.modelId);+ if (!promptShown(config.hidePrompt, preset?.userPrompt, model?.options.promptless)) return null;+ return (+ <div className="mx-auto mt-4 flex max-w-[760px] flex-wrap justify-center gap-2 px-3 pb-10">+ {suggestions.map((s) => (+ <button+ key={s}+ onClick={() => setDraft({ prompt: s })}+ className="h-8 max-w-full truncate rounded-full border bg-background px-3 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"+ >+ {s.length > 48 ? `${s.slice(0, 46)}…` : s}+ </button>+ ))}+ </div>+ );+}+/** Sticky page header (title + engine), with an optional row of mode tabs under it. */function StudioHeader({ title, header, tabs }: { title: string; header?: React.ReactNode; tabs?: React.ReactNode }) {const [engine, setEngine] = useEngine();@@ -282,19 +307,7 @@ function StudioBody({ header, tabs }: { header?: React.ReactNode; tabs?: React.R</div></div>- {!hasItems && config.suggestions && (- <div className="mx-auto mt-4 flex max-w-[760px] flex-wrap justify-center gap-2 px-3 pb-10">- {config.suggestions.map((s) => (- <button- key={s}- onClick={() => setDraft({ prompt: s })}- className="h-8 max-w-full truncate rounded-full border bg-background px-3 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"- >- {s.length > 48 ? `${s.slice(0, 46)}…` : s}- </button>- ))}- </div>- )}+ {!hasItems && config.suggestions && <PromptSuggestions suggestions={config.suggestions} />}{!hasItems && config.signature && <SoulPresetCards />}{dragging && (diff --git a/src/lib/composer.ts b/src/lib/composer.tsindex 01ac129f..96b146a0 100644--- a/src/lib/composer.ts+++ b/src/lib/composer.ts@@ -3,7 +3,7 @@* blocker messages, attachment placement and model-picker grouping. No catalog import here, so* nothing in this file pulls the model list into the browser bundle.*/-import type { Engine, GenParams, InputSlot, MediaKind, ModelDef, Operation } from "./catalog/types";+import type { Engine, GenParams, InputSlot, MediaKind, ModelDef, Operation, Preset } from "./catalog/types";// ---------------------------------------------------------------------------// Settings summary ("16:9 · 720p · 5s · ×1")@@ -157,14 +157,30 @@ export function missingMessage(m: MissingSlot): string {export interface Blocker {message: string;- /** The attachment to point at (pulse) when Generate is pressed. */+ /** The attachment to point at (pulse) when Generate is pressed ("mask": the Paint area tile). */slot?: InputSlot["key"];}+/**+ * Whether Generate is waiting for a painted area: the studio offers the mask brush, its image is+ * in (or uploading), nothing is painted yet, and the model only changes a picture through a mask+ * (FLUX Fill: an inpaint route and no instruction edit to fall back on). The planner's own message+ * names both inputs ("Add an image and paint the area to change"), which reads wrong with the image+ * right there, and comes after its prompt check, though Inpaint asks for the painting first.+ */+export function needsMask(model: Pick<ModelDef, "routes"> | undefined, sketch: ("mask" | "draw")[] | undefined, slots: SlotValues): boolean {+ if (!model || !sketch?.includes("mask")) return false;+ const image = slots.image;+ if (!image?.ref && !image?.uploading) return false;+ if (slots.mask?.ref) return false;+ const ops = new Set(model.routes.map((r) => r.op));+ return ops.has("inpaint") && !ops.has("edit");+}+/*** What stops Generate, most actionable first: missing model, missing attachment (named with the- * studio's own slot label, not the planner's generic message), uploads in flight, then whatever- * the planner says (prompt, voice, language…).+ * studio's own slot label, not the planner's generic message), uploads in flight, the area to+ * paint (needsMask), then whatever the planner says (prompt, voice, language…).*/export function blockerFor(s: {loading?: string | null;@@ -172,6 +188,7 @@ export function blockerFor(s: {engineError?: string | null;missing?: MissingSlot;uploading: boolean;+ maskMissing?: boolean;planError?: string | null;promptMissing: boolean;}): Blocker | null {@@ -180,11 +197,20 @@ export function blockerFor(s: {if (s.engineError) return { message: s.engineError };if (s.missing) return { message: missingMessage(s.missing), slot: s.missing.key };if (s.uploading) return { message: "Uploading…" };+ if (s.maskMissing) return { message: "Paint the area to change", slot: "mask" };if (s.planError) return { message: s.planError };if (s.promptMissing) return { message: "Write a prompt first" };return null;}+/**+ * Whether the composer shows a prompt box (and the studio its prompt suggestions): not when the+ * studio or app has none, nor for a model that takes no prompt (try-on, upscalers, 3D, transcription).+ */+export function promptShown(hidePrompt: boolean | undefined, userPrompt: Preset["userPrompt"] | undefined, promptless: boolean | undefined): boolean {+ return !hidePrompt && userPrompt !== "none" && !promptless;+}+/** Placeholder refs for empty required slots, so cost and plan can be computed before anything is attached. */export const PLACEHOLDER: Record<MediaKind, string> = {image: "/api/files/placeholder.png",diff --git a/tests/composer-fixes.test.ts b/tests/composer-fixes.test.tsindex 2539e21f..a6608f6f 100644--- a/tests/composer-fixes.test.ts+++ b/tests/composer-fixes.test.ts@@ -10,14 +10,16 @@ import {fitAttachments,handoffKey,mergeHandoff,+ needsMask,noRoomMessage,onImageChange,+ promptShown,type Attachment,type DraftShape,} from "@/lib/composer";import { HUB_MODES, modeHref } from "@/lib/hubs";import { outputActions } from "@/lib/output-actions";-import { AUDIO_STUDIO, IMAGE_STUDIO, LIPSYNC_STUDIO, VIDEO_STUDIO, VOICE_CHANGE_STUDIO } from "@/lib/studios";+import { AUDIO_STUDIO, EDIT_STUDIO, IMAGE_STUDIO, INPAINT_STUDIO, LIPSYNC_STUDIO, VIDEO_STUDIO, VOICE_CHANGE_STUDIO } from "@/lib/studios";const att = (id: string, kind: Attachment["kind"] = "image", extra: Partial<Attachment> = {}): Attachment => ({ id, ref: `/api/files/${id}`, preview: `/api/files/${id}`, kind, ...extra });@@ -182,3 +184,45 @@ describe("studio hubs", () => {expect(href(audio, "voice-change")).toMatch(/^\/audio\/voice-change\?audio=/);});});++describe("Inpaint asks for the painted area once the image is in", () => {+ const fill = getModel("oss-flux-fill")!;+ const sketch = INPAINT_STUDIO.sketch;++ it("knows a mask-only model (FLUX Fill) is waiting for the painting", () => {+ expect(needsMask(fill, sketch, { image: att("a") })).toBe(true);+ // Still uploading: the same (Uploading… comes first in the blocker).+ expect(needsMask(fill, sketch, { image: att("a", "image", { ref: "", uploading: true }) })).toBe(true);+ // Painted, or no image yet (the image's own blocker says what to add).+ expect(needsMask(fill, sketch, { image: att("a"), mask: att("m") })).toBe(false);+ expect(needsMask(fill, sketch, {})).toBe(false);+ // A model with an instruction edit runs without a mask; a studio without the brush never asks.+ expect(needsMask(getModel(INPAINT_STUDIO.defaultModels.cloud), sketch, { image: att("a") })).toBe(false);+ expect(needsMask(fill, undefined, { image: att("a") })).toBe(false);+ });++ it("says “Paint the area to change” and points at the brush, not “Add an image…”", () => {+ // A new image dropped the old painting (onImageChange): the planner's message names both inputs.+ const after = onImageChange({ slots: { image: att("a"), mask: att("m"), sketch: att("s") }, params: {} }, { image: att("b"), mask: att("m"), sketch: att("s") });+ const maskMissing = needsMask(fill, sketch, after.slots);+ expect(maskMissing).toBe(true);+ const planError = "Add an image and paint the area to change";+ expect(blockerFor({ model: true, uploading: false, maskMissing, planError, promptMissing: false })).toEqual({ message: "Paint the area to change", slot: "mask" });+ // Inpaint asks for the painting before the prompt; an image still missing or uploading comes first.+ expect(blockerFor({ model: true, uploading: false, maskMissing, planError: "Write a prompt first", promptMissing: true })?.message).toBe("Paint the area to change");+ expect(blockerFor({ model: true, uploading: true, maskMissing, promptMissing: false })?.message).toBe("Uploading…");+ const image = firstMissingSlot(INPAINT_STUDIO.slots, {});+ expect(blockerFor({ model: true, missing: image, uploading: false, maskMissing: false, promptMissing: true })).toEqual({ message: "Add an image", slot: "image" });+ });+});++describe("prompt suggestions follow the prompt box", () => {+ it("hides them for models that take no prompt (FASHN try-on in Edit) and for prompt-less studios", () => {+ expect(EDIT_STUDIO.suggestions?.length).toBeGreaterThan(0);+ expect(promptShown(EDIT_STUDIO.hidePrompt, undefined, getModel(EDIT_STUDIO.defaultModels.cloud)?.options.promptless)).toBe(true);+ expect(promptShown(EDIT_STUDIO.hidePrompt, undefined, getModel("fashn-tryon")?.options.promptless)).toBe(false);+ expect(promptShown(true, undefined, false)).toBe(false);+ expect(promptShown(false, "none", false)).toBe(false);+ expect(promptShown(false, "optional", false)).toBe(true);+ });+});