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
Cinema: a project starts with a name, and the phone prompt bar is two rows
Claude9520bb1e8a5f
diff --git a/src/components/cinema/draft.ts b/src/components/cinema/draft.tsindex a4919019..afb2ade4 100644--- a/src/components/cinema/draft.ts+++ b/src/components/cinema/draft.ts@@ -86,3 +86,14 @@ export function draftToInput(d: CinemaDraft, engine: Engine, settings: DirectorSgrid: action === "grid" ? d.grid : undefined,};}++/**+ * How many of the Director's Panel groups are set (film setup, camera, palette, lighting, emotions),+ * for the phone's folded "Director" chip. Tempo counts in video mode only, as the panel shows it.+ */+export function directorPicks(s: DirectorSettings, mode: CinemaMode): number {+ const film = !!(s.genre || s.era || (mode === "video" && s.tempo));+ const camera = !!(s.camera || s.lens || s.focal || s.aperture);+ const emotions = Object.keys(s.emotions ?? {}).length > 0;+ return [film, camera, !!s.palette, !!s.lighting, emotions].filter(Boolean).length;+}diff --git a/src/components/cinema/project-settings.tsx b/src/components/cinema/project-settings.tsxindex 510563f7..b6067f1c 100644--- a/src/components/cinema/project-settings.tsx+++ b/src/components/cinema/project-settings.tsx@@ -1,7 +1,7 @@"use client";import { Loader2, Trash2 } from "lucide-react";-import { useState } from "react";+import { useEffect, useRef, useState } from "react";import { toast } from "sonner";import { Button } from "@/components/ui/button";import {@@ -20,8 +20,9 @@ import { Label } from "@/components/ui/label";import { Textarea } from "@/components/ui/textarea";import { MediaSlot, type SlotValue } from "@/components/studio/media-slot";import type { CinemaProject } from "@/lib/catalog/cinema";+import { untitledName } from "@/lib/format";import { formatUsd } from "./money";-import { useCreateProject, useDeleteProject, useUpdateProject } from "./hooks";+import { useCinemaProjects, useCreateProject, useDeleteProject, useUpdateProject } from "./hooks";const MAX_DESC = 140;@@ -37,7 +38,14 @@ function ProjectForm({ project, spentUsd, onDone, onDeleted }: FormProps) {const create = useCreateProject();const update = useUpdateProject(project?.id ?? "");const del = useDeleteProject();- const [name, setName] = useState(project?.name ?? "");+ const projects = useCinemaProjects();+ // A new project starts with a name (selected, so typing replaces it and Enter creates it).+ const [name, setName] = useState(() => project?.name ?? untitledName((projects.data ?? []).map((p) => p.name)));+ const nameRef = useRef<HTMLInputElement>(null);+ const [tried, setTried] = useState(false);+ useEffect(() => {+ if (!project) nameRef.current?.select();+ }, [project]);const [description, setDescription] = useState(project?.description ?? "");const [cover, setCover] = useState<SlotValue | null>(project?.cover ? { ref: project.cover, preview: project.cover, kind: "image" } : null);const [cap, setCap] = useState(project?.costCapUsd != null ? String(project.costCapUsd) : "");@@ -45,11 +53,14 @@ function ProjectForm({ project, spentUsd, onDone, onDeleted }: FormProps) {const pending = create.isPending || update.isPending;const capValue = cap.trim() === "" ? null : Number(cap);const capBad = capValue !== null && (!Number.isFinite(capValue) || capValue < 0);+ // Said next to the field (not in a toast that covers the next screen on phones), once Create was pressed.+ const nameError = tried && !name.trim() ? "Give the project a name" : null;const submit = () => {- if (!name.trim()) return toast.error("Give the project a name");+ setTried(true);+ if (!name.trim()) return nameRef.current?.focus();if (cover?.uploading) return toast.error("The cover is still uploading");- if (capBad) return toast.error("The limit must be a positive amount in dollars");+ if (capBad) return document.getElementById("cinema-cap")?.focus();const body = { name: name.trim(), description: description.trim() || null, cover: cover?.ref || null, costCapUsd: capValue };if (project)update.mutate(body, {@@ -77,7 +88,22 @@ function ProjectForm({ project, spentUsd, onDone, onDeleted }: FormProps) {><div className="space-y-1.5"><Label htmlFor="cinema-name">Project name</Label>- <Input id="cinema-name" value={name} onChange={(e) => setName(e.target.value)} placeholder="e.g. “Night Shift”" autoFocus maxLength={80} />+ <Input+ ref={nameRef}+ id="cinema-name"+ value={name}+ onChange={(e) => setName(e.target.value)}+ placeholder="e.g. “Night Shift”"+ autoFocus+ maxLength={80}+ aria-invalid={!!nameError}+ aria-describedby={nameError ? "cinema-name-error" : undefined}+ />+ {nameError && (+ <p id="cinema-name-error" className="text-[12px] text-destructive">+ {nameError}+ </p>+ )}</div><div className="space-y-1.5"><div className="flex items-center justify-between">@@ -104,8 +130,22 @@ function ProjectForm({ project, spentUsd, onDone, onDeleted }: FormProps) {<Label htmlFor="cinema-cap">Spending limit</Label><div className="relative"><span className="pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-[13px] text-muted-foreground">$</span>- <Input id="cinema-cap" inputMode="decimal" value={cap} onChange={(e) => setCap(e.target.value.replace(/[^\d.]/g, ""))} placeholder="No limit" className="pl-6 font-mono" aria-invalid={capBad} />+ <Input+ id="cinema-cap"+ inputMode="decimal"+ value={cap}+ onChange={(e) => setCap(e.target.value.replace(/[^\d.]/g, ""))}+ placeholder="No limit"+ className="pl-6 font-mono"+ aria-invalid={capBad}+ aria-describedby={capBad ? "cinema-cap-error" : undefined}+ /></div>+ {capBad && (+ <p id="cinema-cap-error" className="text-[12px] text-destructive">+ Enter an amount in dollars, like 25 or 7.50+ </p>+ )}<p className="text-[12px] leading-snug text-muted-foreground">An estimate guard: Generate stops before the project's estimated spend would pass it.{project && spentUsd != null ? ` Spent so far ≈ ${formatUsd(spentUsd)}.` : ""}diff --git a/src/components/cinema/prompt-bar.tsx b/src/components/cinema/prompt-bar.tsxindex 1774d423..67dd4f09 100644--- a/src/components/cinema/prompt-bar.tsx+++ b/src/components/cinema/prompt-bar.tsx@@ -41,6 +41,7 @@ import { Slider } from "@/components/ui/slider";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { PromptInput, ELEMENT_ICONS, type PromptInputHandle } from "@/components/studio/prompt-input";import { ShotsEditor } from "@/components/studio/shots-editor";+import { ResponsivePanel } from "@/components/studio/responsive-panel";import { useEdgeFade } from "@/components/studio/use-edge-fade";import { uploadFile, useAssets, useStatus } from "@/lib/api";import { getModel } from "@/lib/catalog";@@ -66,7 +67,7 @@ import { modKey } from "@/lib/keys";import { cn } from "@/lib/utils";import { MoveChips, MovePicker } from "./camera-moves";import { CameraChip, EmotionChip, FilmSetupChip, LightingChip, PaletteChip } from "./director-panel";-import { draftToInput, type BarAction, type CinemaDraft, type RefItem } from "./draft";+import { directorPicks, draftToInput, type BarAction, type CinemaDraft, type RefItem } from "./draft";import { useCinemaGenerate } from "./hooks";import { firstFrame, mediaDuration } from "./media";import { formatUsd } from "./money";@@ -367,6 +368,8 @@ export function PromptBar(props: PromptBarProps) {const quietBlocker = !draft.prompt.trim() && !draft.refs.length && blocker === plan.blocker && /^Describe/.test(blocker ?? "");const blockerId = useId();const [directorRow, directorFade] = useEdgeFade<HTMLDivElement>();+ const [settingsRow, settingsFade] = useEdgeFade<HTMLDivElement>();+ const [directorOpen, setDirectorOpen] = useState(false);// Reference clips make the take reference-to-video: the first image is then a reference, not the start frame.const refMode = plan.steps.find((s) => s.key === "main")?.request.op === "ref2v";const video = draft.mode === "video";@@ -520,8 +523,51 @@ export function PromptBar(props: PromptBarProps) {const costShort = demo ? "Demo" : cost === 0 ? "Free" : cost != null ? `≈ ${formatCost(cost)}` : "≈ ?";const costLong = demo ? "Demo · free" : cost === 0 ? "Free" : cost != null ? `≈ ${formatCost(cost)}` : "Price unknown";- return (+ // The Director's Panel chips: their own row from sm up; on phones one "Director" chip opens them in a sheet.+ const directorChips = (+ <>+ <FilmSetupChip settings={settings} onChange={onSettings} mode={draft.mode} />+ <CameraChip+ settings={settings}+ onChange={onSettings}+ mode={draft.mode}+ engine={engine}+ moves={draft.moves}+ onMovesChange={(moves) => setDraft({ moves })}+ required={draft.mode === "image" && draft.imageTool === "still"}+ />+ <PaletteChip settings={settings} onChange={onSettings} engine={engine} saved={props.palettes} onSave={props.onPalettes} />+ <LightingChip settings={settings} onChange={onSettings} />+ <EmotionChip settings={settings} onChange={onSettings} characters={characters} />+ <span className="mx-0.5 h-5 w-px shrink-0 bg-border" aria-hidden />+ {/* Cast and Location open their own dialog: the phone sheet closes first. */}+ <Tooltip>+ <TooltipTrigger asChild>+ <button type="button" onClick={() => {+ setDirectorOpen(false);+ props.onCast();+ }} className={cn(chip, chipIdle)} aria-label="Soul Cast: build a character">+ <UserRoundPlus className="size-3.5" /> Cast+ </button>+ </TooltipTrigger>+ <TooltipContent>Soul Cast: build an AI actor and save it as a character</TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger asChild>+ <button type="button" onClick={() => {+ setDirectorOpen(false);+ props.onLocation();+ }} className={cn(chip, chipIdle)} aria-label="Soul Location: build a location">+ <MapPin className="size-3.5" /> Location+ </button>+ </TooltipTrigger>+ <TooltipContent>Soul Location: keep every scene in the same world</TooltipContent>+ </Tooltip>+ </>+ );+ const picks = directorPicks(settings, draft.mode);+ return (<divclassName="group/composer @container w-full rounded-[20px] border bg-background p-2.5 shadow-normal transition-[border-color,box-shadow] focus-within:border-primary focus-within:ring-4 focus-within:ring-brand-faint sm:rounded-composer"onKeyDown={(e) => {@@ -626,45 +672,34 @@ export function PromptBar(props: PromptBarProps) {)}{/* Director's Panel */}- {/* Narrow bars scroll this row (with faded edges where more chips hide); wide ones wrap it. */}- <div ref={directorRow} style={directorFade} className="scrollbar-none -mx-0.5 flex items-center gap-1.5 overflow-x-auto px-1 pb-1.5 @min-[760px]:flex-wrap @min-[760px]:overflow-visible" role="group" aria-label="Director's Panel">-- <FilmSetupChip settings={settings} onChange={onSettings} mode={draft.mode} />- <CameraChip- settings={settings}- onChange={onSettings}- mode={draft.mode}- engine={engine}- moves={draft.moves}- onMovesChange={(moves) => setDraft({ moves })}- required={draft.mode === "image" && draft.imageTool === "still"}- />- <PaletteChip settings={settings} onChange={onSettings} engine={engine} saved={props.palettes} onSave={props.onPalettes} />- <LightingChip settings={settings} onChange={onSettings} />- <EmotionChip settings={settings} onChange={onSettings} characters={characters} />- <span className="mx-0.5 h-5 w-px shrink-0 bg-border" aria-hidden />- <Tooltip>- <TooltipTrigger asChild>- <button type="button" onClick={props.onCast} className={cn(chip, chipIdle)} aria-label="Soul Cast: build a character">- <UserRoundPlus className="size-3.5" /> Cast- </button>- </TooltipTrigger>- <TooltipContent>Soul Cast: build an AI actor and save it as a character</TooltipContent>- </Tooltip>- <Tooltip>- <TooltipTrigger asChild>- <button type="button" onClick={props.onLocation} className={cn(chip, chipIdle)} aria-label="Soul Location: build a location">- <MapPin className="size-3.5" /> Location- </button>- </TooltipTrigger>- <TooltipContent>Soul Location: keep every scene in the same world</TooltipContent>- </Tooltip>+ {/* Narrow bars scroll this row (with faded edges where more chips hide); wide ones wrap it. Phones fold it into the Director chip below. */}+ <div ref={directorRow} style={directorFade} className="scrollbar-none -mx-0.5 flex items-center gap-1.5 overflow-x-auto px-1 pb-1.5 max-sm:hidden @min-[760px]:flex-wrap @min-[760px]:overflow-visible" role="group" aria-label="Director's Panel">+ {directorChips}</div>{/* Generation settings. Narrow bars (phones, a bar squeezed by the side panel) wrap this row andfold the secondary settings into one Settings popover, so nothing hides off-screen. */}<div className="flex items-end gap-2">- <div className="flex min-w-0 flex-1 flex-wrap items-center gap-1.5">+ {/* Phones: one row that scrolls (faded at the edge), so the bar is the prompt plus one line of chips. */}+ <div ref={settingsRow} style={settingsFade} className="scrollbar-none -my-1 flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto py-1 sm:flex-wrap sm:overflow-visible">+ <span className="contents sm:hidden">+ <ResponsivePanel+ open={directorOpen}+ onOpenChange={setDirectorOpen}+ title="Director's Panel"+ description="Film setup, camera, palette, light and emotion: every shot follows them."+ trigger={+ <button type="button" className={cn(chip, picks ? chipOn : chipIdle)} aria-label={picks ? `Director's Panel: ${picks} set` : "Director's Panel"}>+ <Clapperboard className="size-3.5" /> Director+ {picks > 0 && <span className="font-mono text-[11px] tabular-nums">{picks}</span>}+ </button>+ }+ >+ <div role="group" aria-label="Director's Panel" className="flex flex-wrap gap-1.5">+ {directorChips}+ </div>+ </ResponsivePanel>+ </span><Segmentedlabel="Mode"value={draft.mode}@@ -792,7 +827,7 @@ export function PromptBar(props: PromptBarProps) {aria-label={plan.outputs > 1 ? `Generate ${plan.outputs}` : "Generate"}aria-disabled={!!blocker || undefined}aria-describedby={blocker ? blockerId : undefined}- className={cn("size-10 shrink-0 rounded-full", blocker && "bg-muted text-subtle-foreground hover:bg-muted")}+ className={cn("size-10 shrink-0 rounded-full", blocker && "bg-primary/55 hover:bg-primary/65")}>{busy ? <Loader2 className="size-4 animate-spin" /> : <ArrowUp className="size-4" />}</Button>diff --git a/src/lib/format.ts b/src/lib/format.tsindex a8a0b995..e5c940dd 100644--- a/src/lib/format.ts+++ b/src/lib/format.ts@@ -26,3 +26,10 @@ export function elapsed(from: number, to = Date.now()): string {const s = Math.max(0, Math.round((to - from) / 1000));return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${s % 60}s`;}++/** The first of "Untitled project", "Untitled project 2", "Untitled project 3"… that isn't taken (case-insensitive). */+export function untitledName(taken: readonly string[], base = "Untitled project"): string {+ const used = new Set(taken.map((n) => n.trim().toLowerCase()));+ if (!used.has(base.toLowerCase())) return base;+ for (let i = 2; ; i++) if (!used.has(`${base} ${i}`.toLowerCase())) return `${base} ${i}`;+}diff --git a/tests/ux-flows.test.ts b/tests/ux-flows.test.tsnew file mode 100644index 00000000..f90e5500--- /dev/null+++ b/tests/ux-flows.test.ts@@ -0,0 +1,23 @@+import { describe, expect, it } from "vitest";+import { directorPicks } from "@/components/cinema/draft";+import { untitledName } from "@/lib/format";++describe("a new Cinema project starts with a name", () => {+ it("takes the first free Untitled project", () => {+ expect(untitledName([])).toBe("Untitled project");+ expect(untitledName(["Night Shift"])).toBe("Untitled project");+ expect(untitledName(["untitled project ", "Untitled project 2"])).toBe("Untitled project 3");+ expect(untitledName(["Untitled project 2"])).toBe("Untitled project");+ });+});++describe("the phone's folded Director chip", () => {+ it("counts the panel groups that are set", () => {+ expect(directorPicks({}, "video")).toBe(0);+ expect(directorPicks({ genre: "noir", era: "1970s", lens: "anamorphic" }, "video")).toBe(2);+ expect(directorPicks({ palette: { slug: "teal-orange" } as never, lighting: { preset: "golden" } as never, emotions: { mara: { family: "joy" } as never } }, "image")).toBe(3);+ // Tempo shapes video cuts only: a still ignores it, and so does the count.+ expect(directorPicks({ tempo: "fast" }, "image")).toBe(0);+ expect(directorPicks({ tempo: "fast" }, "video")).toBe(1);+ });+});