Skip to content

armgit / fuobe

Public Imported from GitHub
0

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.

Cinema Studio: polish from the browser pass

Claudee57589d0549a
diff --git a/src/components/cinema/camera-moves.tsx b/src/components/cinema/camera-moves.tsx
index 94e67145..94cdef05 100644
--- a/src/components/cinema/camera-moves.tsx
+++ b/src/components/cinema/camera-moves.tsx
@@ -9,6 +9,19 @@ import { CAMERA_MOVES, moveBySlug, openCameraRoute, type CameraMove } from "@/li
import type { Engine } from "@/lib/catalog/types";
import { cn } from "@/lib/utils";
+/** Name matches first (prefix, then word start, then anywhere), the slug and the hint after. */
+function moveScore(value: string, search: string, keywords?: string[]): number {
+ const q = search.trim().toLowerCase();
+ if (!q) return 1;
+ const name = value.toLowerCase();
+ if (name.startsWith(q)) return 1;
+ if (name.split(/\s+/).some((w) => w.startsWith(q))) return 0.9;
+ if (name.includes(q)) return 0.8;
+ const [slug = "", hint = ""] = (keywords ?? []).map((k) => k.toLowerCase());
+ if (slug.includes(q.replace(/\s+/g, "-"))) return 0.6;
+ return hint.includes(q) ? 0.2 : 0;
+}
+
/** How the open engine drives a move (shown as a small badge in the picker). */
function routeBadge(m: CameraMove, engine: Engine): string | null {
if (engine !== "open") return null;
@@ -34,7 +47,7 @@ export function MoveList({
const [query, setQuery] = useState(defaultQuery ?? "");
const moves = useMemo(() => (sort === "name" ? [...CAMERA_MOVES].sort((a, b) => a.name.localeCompare(b.name)) : CAMERA_MOVES), [sort]);
return (
- <Command loop className="bg-transparent" filter={(value, search) => (value.toLowerCase().includes(search.toLowerCase()) ? 1 : 0)}>
+ <Command loop className="bg-transparent" filter={moveScore}>
<div className="flex items-center gap-1 pr-1">
<div className="min-w-0 flex-1">
<CommandInput placeholder="Search camera moves…" value={query} onValueChange={setQuery} autoFocus={autoFocus} />
@@ -60,7 +73,7 @@ export function MoveList({
const badge = routeBadge(m, engine);
const n = selected.indexOf(m.slug);
return (
- <CommandItem key={m.slug} value={`${m.name} ${m.slug} ${m.hint}`} onSelect={() => onPick(m.slug)} className="group/move items-start gap-2.5 py-2">
+ <CommandItem key={m.slug} value={m.name} keywords={[m.slug, m.hint]} onSelect={() => onPick(m.slug)} className="group/move items-start gap-2.5 py-2">
<span className={cn("mt-0.5 grid size-6 shrink-0 place-items-center rounded-md text-[11px] font-semibold", n >= 0 ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground")}>
{n >= 0 ? n + 1 : <Hash className="size-3" />}
</span>
diff --git a/src/components/cinema/cinema-feed.tsx b/src/components/cinema/cinema-feed.tsx
index efb2903e..581dff07 100644
--- a/src/components/cinema/cinema-feed.tsx
+++ b/src/components/cinema/cinema-feed.tsx
@@ -20,6 +20,7 @@ import {
SlidersHorizontal,
Trash2,
UserRoundPlus,
+ Video,
X,
} from "lucide-react";
import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
@@ -274,8 +275,10 @@ function TileView({
) : g.status !== "succeeded" ? (
<FailedTile g={g} ratio={aspect} onRetry={() => void actions.retry(g.id).catch((e) => toast.error((e as Error).message))} />
) : (
- <div className={cn("size-full", fit && "bg-muted")}>
- <MediaThumb output={u.output!} className={fit ? "object-contain" : undefined} />
+ <div className={cn("relative size-full", fit && "bg-muted")}>
+ {/* Behind the video: visible until (or if) the browser can draw its first frame. */}
+ {u.output?.kind === "video" && <Video className="absolute top-1/2 left-1/2 size-6 -translate-1/2 text-subtle-foreground" aria-hidden />}
+ <MediaThumb output={u.output!} className={cn("relative", fit && "object-contain")} />
</div>
);
const clickable = g.status === "succeeded";
diff --git a/src/components/cinema/director-panel.tsx b/src/components/cinema/director-panel.tsx
index 6843473b..aef1c98a 100644
--- a/src/components/cinema/director-panel.tsx
+++ b/src/components/cinema/director-panel.tsx
@@ -178,6 +178,7 @@ export function CameraChip({
engine,
moves,
onMovesChange,
+ required,
}: {
settings: DirectorSettings;
onChange: Patch;
@@ -185,9 +186,11 @@ export function CameraChip({
engine: Engine;
moves: string[];
onMovesChange: (m: string[]) => void;
+ /** Cinematic stills: camera, lens and focal length must be set. */
+ required?: boolean;
}) {
const [tab, setTab] = useState<(typeof CAMERA_TABS)[number]["id"]>("camera");
- const still = mode === "image";
+ const still = !!required;
const missing = still && (!settings.camera || !settings.lens || !settings.focal);
const parts = [
settings.camera && optionName(CAMERA_BODIES, settings.camera),
@@ -195,7 +198,7 @@ export function CameraChip({
settings.focal && optionName(FOCAL_LENGTHS, settings.focal),
settings.aperture && optionName(APERTURES, settings.aperture).replace(/ .*/, ""),
].filter(Boolean);
- const required = (id: string) => still && ((id === "camera" && !settings.camera) || (id === "lens" && !settings.lens) || (id === "focal" && !settings.focal));
+ const needs = (id: string) => still && ((id === "camera" && !settings.camera) || (id === "lens" && !settings.lens) || (id === "focal" && !settings.focal));
return (
<Popover>
<Tooltip>
@@ -220,7 +223,7 @@ export function CameraChip({
)}
>
{t.label}
- {required(t.id) && <span className="size-1.5 rounded-full bg-warning" aria-label="required" />}
+ {needs(t.id) && <span className="size-1.5 rounded-full bg-warning" aria-label="required" />}
{t.id === "movement" && moves.length > 0 && <span className="font-mono text-[10px] text-brand-text">{moves.length}</span>}
</button>
))}
diff --git a/src/components/cinema/elements-panel.tsx b/src/components/cinema/elements-panel.tsx
index 5db45450..42da3b0a 100644
--- a/src/components/cinema/elements-panel.tsx
+++ b/src/components/cinema/elements-panel.tsx
@@ -15,7 +15,7 @@ export function ElementsPanel({ onMention, onCast, onLocation }: { onMention: (e
return (
<div className="space-y-6">
<div className="flex flex-wrap items-center gap-2">
- <h2 className="flex-1 font-heading text-[24px] leading-none">My Elements</h2>
+ <h2 className="flex-1 font-heading text-[24px] leading-none whitespace-nowrap">My Elements</h2>
<Button variant="secondary" size="sm" onClick={onCast}>
<UserRoundPlus /> New character
</Button>
diff --git a/src/components/cinema/projects-view.tsx b/src/components/cinema/projects-view.tsx
index a403f944..cc6d7260 100644
--- a/src/components/cinema/projects-view.tsx
+++ b/src/components/cinema/projects-view.tsx
@@ -58,8 +58,13 @@ function ProjectCard({ project, onSettings }: { project: CinemaProject; onSettin
<p className="mt-1 text-[12px] text-muted-foreground">
Updated {timeAgo(project.updatedAt)}
{project.stats ? ` · ${project.stats.items} take${project.stats.items === 1 ? "" : "s"}` : ""}
- {project.stats?.spentUsd ? <span className="font-mono"> · ≈ {formatCost(project.stats.spentUsd)}</span> : null}
- {project.costCapUsd != null ? <span className="font-mono"> / {formatCost(project.costCapUsd) || "$0"}</span> : null}
+ {project.stats?.spentUsd || project.costCapUsd != null ? (
+ <span className="font-mono">
+ {" "}
+ · ≈ {formatCost(project.stats?.spentUsd ?? 0) === "Free" ? "$0" : formatCost(project.stats?.spentUsd ?? 0)}
+ {project.costCapUsd != null ? ` of ${formatCost(project.costCapUsd) === "Free" ? "$0" : formatCost(project.costCapUsd)}` : ""}
+ </span>
+ ) : null}
</p>
</div>
</Link>
diff --git a/src/components/cinema/prompt-bar.tsx b/src/components/cinema/prompt-bar.tsx
index 06f04b73..89047068 100644
--- a/src/components/cinema/prompt-bar.tsx
+++ b/src/components/cinema/prompt-bar.tsx
@@ -94,7 +94,23 @@ function Segmented<T extends string>({ value, options, onChange, label }: { valu
);
}
-function PickChip<T extends string | number>({ icon: Icon, label, value, options, onChange, format }: { icon: typeof Video; label: string; value: T; options: T[]; onChange: (v: T) => void; format?: (v: T) => string }) {
+function PickChip<T extends string | number>({
+ icon: Icon,
+ label,
+ value,
+ options,
+ onChange,
+ format,
+ describe,
+}: {
+ icon: typeof Video;
+ label: string;
+ value: T;
+ options: T[];
+ onChange: (v: T) => void;
+ format?: (v: T) => string;
+ describe?: (v: T) => string;
+}) {
const f = format ?? ((v: T) => String(v));
return (
<DropdownMenu>
@@ -108,8 +124,15 @@ function PickChip<T extends string | number>({ icon: Icon, label, value, options
<DropdownMenuLabel>{label}</DropdownMenuLabel>
<DropdownMenuRadioGroup value={String(value)} onValueChange={(v) => onChange(options.find((o) => String(o) === v)!)}>
{options.map((o) => (
- <DropdownMenuRadioItem key={String(o)} value={String(o)}>
- {f(o)}
+ <DropdownMenuRadioItem key={String(o)} value={String(o)} className={describe ? "items-start" : undefined}>
+ {describe ? (
+ <span>
+ <span className="block">{f(o)}</span>
+ <span className="block text-[11.5px] text-muted-foreground">{describe(o)}</span>
+ </span>
+ ) : (
+ f(o)
+ )}
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
@@ -207,7 +230,7 @@ export function useAddRefs(setDraft: (fn: (d: CinemaDraft) => Partial<CinemaDraf
};
}
-function AddRef({ onFiles, onPick }: { onFiles: (f: FileList) => void; onPick: (r: RefItem) => void }) {
+function AddRef({ onFiles, onPick, compact }: { onFiles: (f: FileList) => void; onPick: (r: RefItem) => void; compact?: boolean }) {
const input = useRef<HTMLInputElement>(null);
const [open, setOpen] = useState(false);
const assets = useAssets(undefined, undefined);
@@ -216,14 +239,20 @@ function AddRef({ onFiles, onPick }: { onFiles: (f: FileList) => void; onPick: (
<Tooltip>
<TooltipTrigger asChild>
<PopoverTrigger asChild>
- <button
- type="button"
- className="flex size-14 shrink-0 flex-col items-center justify-center gap-0.5 rounded-xl border border-dashed border-border-strong text-muted-foreground transition-colors hover:border-primary hover:bg-brand-faint hover:text-brand-text"
- aria-label="Add references"
- >
- <Plus className="size-4" />
- <span className="text-[10px] font-medium">Add</span>
- </button>
+ {compact ? (
+ <button type="button" className={cn("grid size-8 shrink-0 place-items-center rounded-full", chipIdle)} aria-label="Add references">
+ <ImagePlus className="size-3.5" />
+ </button>
+ ) : (
+ <button
+ type="button"
+ className="flex size-14 shrink-0 flex-col items-center justify-center gap-0.5 rounded-xl border border-dashed border-border-strong text-muted-foreground transition-colors hover:border-primary hover:bg-brand-faint hover:text-brand-text"
+ aria-label="Add references"
+ >
+ <Plus className="size-4" />
+ <span className="text-[10px] font-medium">Add</span>
+ </button>
+ )}
</PopoverTrigger>
</TooltipTrigger>
<TooltipContent>Images, videos or audio as references · drop or paste anywhere</TooltipContent>
@@ -400,7 +429,7 @@ export function PromptBar(props: PromptBarProps) {
return (
<div
- className="group/composer 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"
+ className="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"
onPaste={(e) => {
const files = [...e.clipboardData.files];
if (files.length) {
@@ -447,7 +476,7 @@ export function PromptBar(props: PromptBarProps) {
)}
{/* References */}
- <div className="scrollbar-none flex items-center gap-2 overflow-x-auto px-1 pt-0.5 pb-2">
+ <div className={cn("scrollbar-none items-center gap-2 overflow-x-auto px-1 pt-0.5 pb-2", draft.refs.length ? "flex" : "hidden sm:flex")}>
{(() => {
const n: Record<string, number> = {};
return draft.refs.map((r) => {
@@ -456,7 +485,7 @@ export function PromptBar(props: PromptBarProps) {
});
})()}
<AddRef onFiles={addRefs} onPick={(r) => setDraft((d) => ({ refs: [...d.refs, r] }))} />
- {!draft.refs.length && <span className="text-[12px] text-subtle-foreground">Start frame, references, clips or audio — or @ a character</span>}
+ {!draft.refs.length && <span className="hidden text-[12px] text-subtle-foreground sm:inline">Start frame, references, clips or audio — or @ a character</span>}
</div>
{video && <MoveChips moves={draft.moves} onChange={(moves) => setDraft({ moves })} />}
@@ -495,17 +524,42 @@ export function PromptBar(props: PromptBarProps) {
)}
{/* Director's Panel */}
- <div className="scrollbar-none flex items-center gap-1.5 overflow-x-auto px-0.5 pb-1.5 sm:flex-wrap sm:overflow-visible">
+ <div className="scrollbar-none flex items-center gap-1.5 overflow-x-auto px-0.5 pb-1.5 @min-[760px]:flex-wrap @min-[760px]:overflow-visible">
<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 })} />
+ <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>
</div>
{/* Generation settings */}
<div className="flex items-end gap-2">
- <div className="scrollbar-none flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto sm:flex-wrap sm:overflow-visible">
+ <div className="scrollbar-none flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto @min-[760px]:flex-wrap @min-[760px]:overflow-visible">
<Segmented
label="Mode"
value={draft.mode}
@@ -529,7 +583,7 @@ export function PromptBar(props: PromptBarProps) {
{!video && draft.imageTool === "grid" && (
<>
<PickChip icon={Grid2x2} label="Grid size" value={draft.grid.size} options={GRID_SIZES.map((g) => g.id)} onChange={(size) => setDraft((d) => ({ grid: { ...d.grid, size } }))} format={(v) => GRID_SIZES.find((g) => g.id === v)!.name} />
- <PickChip icon={Clapperboard} label="Grid type" value={draft.grid.type} options={GRID_TYPES.map((g) => g.id)} onChange={(type) => setDraft((d) => ({ grid: { ...d.grid, type } }))} format={(v) => GRID_TYPES.find((g) => g.id === v)!.name} />
+ <PickChip icon={Clapperboard} label="Grid type" value={draft.grid.type} options={GRID_TYPES.map((g) => g.id)} onChange={(type) => setDraft((d) => ({ grid: { ...d.grid, type } }))} format={(v) => GRID_TYPES.find((g) => g.id === v)!.name} describe={(v) => GRID_TYPES.find((g) => g.id === v)!.description} />
</>
)}
@@ -568,6 +622,11 @@ export function PromptBar(props: PromptBarProps) {
</DropdownMenuContent>
</DropdownMenu>
+ {!draft.refs.length && (
+ <span className="sm:hidden">
+ <AddRef compact onFiles={addRefs} onPick={(r) => setDraft((d) => ({ refs: [...d.refs, r] }))} />
+ </span>
+ )}
<Tooltip>
<TooltipTrigger asChild>
<button type="button" onClick={() => promptRef.current?.startMention()} className={cn("grid size-8 shrink-0 place-items-center rounded-full", chipIdle)} aria-label="Add an element">
@@ -621,22 +680,6 @@ export function PromptBar(props: PromptBarProps) {
format={(v) => (v === "off" ? "Single shot" : v === "auto" ? "Multi-shot · Auto" : "Multi-shot · Manual")}
/>
)}
- <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>
</div>
<span className={cn("hidden shrink-0 font-mono text-[12px] sm:inline", overCap ? "text-destructive" : "text-muted-foreground")}>
{demo ? "Demo · free" : cost === 0 ? "Free" : cost != null ? `≈ ${formatCost(cost)}` : ""}
diff --git a/src/components/cinema/soul-builders.tsx b/src/components/cinema/soul-builders.tsx
index fae2a9c6..66d8eff1 100644
--- a/src/components/cinema/soul-builders.tsx
+++ b/src/components/cinema/soul-builders.tsx
@@ -54,7 +54,14 @@ function Field({ f, values, set }: { f: CastField; values: CastValues; set: (pat
<div className="space-y-1.5 px-1">
<div className="flex justify-between">
<span className="text-[11.5px] text-muted-foreground">{f.key === "budget" ? "Budget in millions" : f.label}</span>
- <span className="font-mono text-[13px]">{v !== undefined ? fmt(f, v as string | number) : "—"}</span>
+ <span className="flex items-center gap-2">
+ {v !== undefined && f.default === undefined && (
+ <button type="button" onClick={() => set({ [f.key]: undefined })} className="text-[11px] text-muted-foreground hover:text-foreground">
+ Clear
+ </button>
+ )}
+ <span className="font-mono text-[13px]">{v !== undefined ? fmt(f, v as string | number) : "Any"}</span>
+ </span>
</div>
<Slider
value={[Math.max(0, f.options.indexOf(v as string | number))]}
@@ -150,6 +157,12 @@ function Results({ items, picked, onPick }: { items: Generation[]; picked: strin
);
}
+/** "a marble perfume atelier at golden hour, …" → "Marble Perfume Atelier". */
+function locationName(prompt: string): string {
+ const words = prompt.split(/[,.;]/)[0].replace(/^(an?|the)\s+/i, "").split(/\s+/).filter((w) => w && !/^(at|in|on|of|with|by|under|near|and)$/i.test(w));
+ return words.slice(0, 3).map((w) => w[0].toUpperCase() + w.slice(1)).join(" ") || "Location";
+}
+
function useBuilderRun(projectId: string) {
const generate = useCinemaGenerate(projectId);
const items = useCinemaItems(projectId).data;
@@ -161,7 +174,7 @@ function useBuilderRun(projectId: string) {
function CostLabel({ plan, demoModel }: { plan: { costUsd: number | null }; demoModel: { routes: { provider: string }[] } }) {
const status = useStatus().data;
const demo = !!status && status.demoMode !== "off" && !demoModel.routes.some((r) => status.providers[r.provider]?.configured);
- return <span className="font-mono text-[12px] text-muted-foreground">{demo ? "Demo · free" : plan.costUsd === 0 ? "Free" : plan.costUsd != null ? `≈ ${formatCost(plan.costUsd)}` : ""}</span>;
+ return <span className="font-mono text-[12px] whitespace-nowrap text-muted-foreground">{demo ? "Demo · free" : plan.costUsd === 0 ? "Free" : plan.costUsd != null ? `≈ ${formatCost(plan.costUsd)}` : ""}</span>;
}
function SaveElement({ kind, defaultName, picked, description, onSaved }: { kind: "character" | "location"; defaultName: string; picked: string[]; description: string; onSaved: () => void }) {
@@ -266,7 +279,7 @@ function SoulCast({ projectId, folderId, engine, context, brief, onOpenChange }:
<Button variant="ghost" size="sm" onClick={() => setValues(castDefaults())}>
<RotateCcw /> Reset
</Button>
- <div className="ml-auto flex items-center gap-2">
+ <div className="flex w-full flex-wrap items-center justify-end gap-2 sm:ml-auto sm:w-auto">
<div className="inline-flex h-8 rounded-full bg-muted p-0.5" role="radiogroup" aria-label="Variants">
{[1, 2, 3, 4].map((n) => (
<button key={n} type="button" role="radio" aria-checked={batch === n} onClick={() => setBatch(n)} className={cn("w-8 rounded-full font-mono text-[12px]", batch === n ? "bg-background shadow-soft" : "text-muted-foreground")}>
@@ -376,7 +389,7 @@ function SoulLocation({ projectId, folderId, engine, settings, context, brief, o
))}
</div>
)}
- <SaveElement kind="location" defaultName={prompt.split(/[,.]/)[0].replace(/^(an?|the)\s+/i, "").slice(0, 40) || "Location"} picked={picked} description={prompt} onSaved={() => onOpenChange(false)} />
+ <SaveElement kind="location" defaultName={locationName(prompt)} picked={picked} description={prompt} onSaved={() => onOpenChange(false)} />
</div>
)}
</>
diff --git a/src/components/cinema/workspace.tsx b/src/components/cinema/workspace.tsx
index c91b5422..21bc50df 100644
--- a/src/components/cinema/workspace.tsx
+++ b/src/components/cinema/workspace.tsx
@@ -320,7 +320,14 @@ function Workspace({ data, items, loading }: { data: ProjectView; items: CinemaG
<EngineSwitch value={engine} onChange={setEngine} size="sm" />
<Tooltip>
<TooltipTrigger asChild>
- <Button variant={panel === "director" ? "secondary" : "ghost"} size="sm" onClick={() => setPanel((p) => (p === "director" ? null : "director"))} aria-pressed={panel === "director"} className="shrink-0">
+ <Button
+ variant={panel === "director" ? "secondary" : "ghost"}
+ size="sm"
+ onClick={() => setPanel((p) => (p === "director" ? null : "director"))}
+ aria-pressed={panel === "director"}
+ aria-label="AI Director"
+ className="shrink-0 max-sm:size-8 max-sm:px-0"
+ >
<Bot /> <span className="hidden sm:inline">AI Director</span>
</Button>
</TooltipTrigger>
@@ -328,7 +335,7 @@ function Workspace({ data, items, loading }: { data: ProjectView; items: CinemaG
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
- <Button variant={panel === "brief" ? "secondary" : "ghost"} size="icon-sm" onClick={() => setPanel((p) => (p === "brief" ? null : "brief"))} aria-pressed={panel === "brief"} aria-label="Project brief" className="shrink-0">
+ <Button variant={panel === "brief" ? "secondary" : "ghost"} size="icon-sm" onClick={() => setPanel((p) => (p === "brief" ? null : "brief"))} aria-pressed={panel === "brief"} aria-label="Project brief" className="shrink-0 max-sm:hidden">
<FileText />
</Button>
</TooltipTrigger>
@@ -344,6 +351,9 @@ function Workspace({ data, items, loading }: { data: ProjectView; items: CinemaG
<DropdownMenuItem onClick={() => setSettingsOpen(true)}>
<Settings2 /> Project settings
</DropdownMenuItem>
+ <DropdownMenuItem onClick={() => setPanel("brief")}>
+ <FileText /> Project brief
+ </DropdownMenuItem>
<DropdownMenuItem onClick={() => update.mutate({ pinned: !project.pinned })}>
{project.pinned ? <PinOff /> : <Pin />} {project.pinned ? "Unpin project" : "Pin project"}
</DropdownMenuItem>
diff --git a/src/lib/catalog/cinema.ts b/src/lib/catalog/cinema.ts
index ac356690..516b770c 100644
--- a/src/lib/catalog/cinema.ts
+++ b/src/lib/catalog/cinema.ts
@@ -690,8 +690,8 @@ export function castPrompt(values: CastValues, description?: string): string {
/** A starting name for the saved element ("Rebel, 30s"); renamed on the element page. */
export function castName(values: CastValues): string {
- const archetype = values.archetype ? String(values.archetype) : "Cast member";
- return values.age ? `${archetype} ${values.age}` : archetype;
+ if (values.archetype) return values.age ? `${values.archetype} ${values.age}` : String(values.archetype);
+ return values.genre ? `${values.genre} lead` : "Cast member";
}
// ---------------------------------------------------------------------------
diff --git a/src/server/cinema-director.ts b/src/server/cinema-director.ts
index 2b616c3a..e195a2ff 100644
--- a/src/server/cinema-director.ts
+++ b/src/server/cinema-director.ts
@@ -157,19 +157,42 @@ const FRAMES: { title: string; frame: string; moves: (t: string) => string[]; fo
{ title: "Closing", frame: "Wide closing shot", moves: () => ["dolly-out"], focal: "35mm" },
];
-/** Split a script into beats: lines, else sentences; a one-line idea gets a 4-beat structure. */
-function beats(text: string, want?: number): string[] {
- const body = text
- .replace(/^(please\s+)?(write|make|create|generate|break( down)?|turn)\b[^:]*:\s*/i, "")
- .trim();
+/** "Generate an 8-shot storyboard for a sci-fi chase in Tokyo" → "a sci-fi chase in Tokyo". */
+export function ideaOf(text: string): string {
+ return text
+ .trim()
+ .replace(/^(please\s+)?(can you\s+)?(write|make|create|generate|give me|break( down)?|turn|draft|plan|storyboard|shoot|direct)\b\s*(me\s+)?/i, "")
+ .replace(/^(an?|the)\s+/i, "")
+ .replace(/\b\d+\s*[- ]?\s*(shots?|seconds?|secs?|s)\b[- ]?/gi, "")
+ .replace(/^(cinematic\s+)?(storyboard|shot list|breakdown|sequence|scene list)\s+(for|of|about)\s+/i, "")
+ .replace(/\s{2,}/g, " ")
+ .trim()
+ .replace(/[.\s]+$/, "");
+}
+
+const STORY_BEATS = ["the world is introduced", "the action begins", "a closer look at the character", "a telling detail", "a reaction", "the turning point", "the reveal", "the resolution"];
+const AD_BEATS = [
+ "the world of the product, setting the mood",
+ "the hero finds it",
+ "the product up close, light catching every surface",
+ "a sensory detail that sells the feeling",
+ "a reaction: the pleasure of using it",
+ "a bold, dynamic angle on the product",
+ "the brand world revealed",
+ "the final hero shot, product centred, room for the logo",
+];
+
+/** A script's lines (or sentences) are its beats; a one-line idea gets a shot structure around it. */
+function beats(text: string, want?: number): { beat: string; frame?: number }[] {
+ const body = text.replace(/^(please\s+)?(write|make|create|generate|break( down)?|turn)\b[^:\n]*:\s*/i, "").trim();
const lines = body.split(/\n+/).map((l) => l.replace(/^\s*(\d+[.)]|[-*•])\s*/, "").trim()).filter((l) => l.length > 3);
- let parts = lines.length > 1 ? lines : body.split(/(?<=[.!?])\s+/).map((s) => s.trim()).filter((s) => s.length > 3);
- const n = want ?? (parts.length > 1 ? Math.min(parts.length, 12) : 4);
- if (parts.length < n) {
- const idea = parts.join(" ") || body;
- parts = Array.from({ length: n }, (_, i) => parts[i] ?? idea);
- }
- return parts.slice(0, n);
+ const parts = lines.length > 1 ? lines : body.split(/(?<=[.!?])\s+/).map((x) => x.trim()).filter((x) => x.length > 3);
+ if (parts.length > 1) return parts.slice(0, want ?? 12).map((beat) => ({ beat }));
+ const idea = ideaOf(text);
+ const ad = has(text, "commercial", "advert", "product", "perfume", "brand", "spot", "promo");
+ const n = want ?? 4;
+ const order = n <= 4 ? [0, 1, 2, 7].slice(0, n) : Array.from({ length: n }, (_, i) => i % FRAMES.length);
+ return order.map((frame) => ({ beat: `${idea}, ${(ad ? AD_BEATS : STORY_BEATS)[frame]}`, frame }));
}
export function offlineDirector(text: string, project: Pick<CinemaProject, "brief" | "director">): { reply: string; shots: DirectorShot[]; brief?: string } {
@@ -185,13 +208,20 @@ export function offlineDirector(text: string, project: Pick<CinemaProject, "brie
].join("\n");
return { reply: "Here's a starting brief. Apply it to the project, then edit it as you like.", shots: [], brief };
}
+ const idea = ideaOf(text);
+ if (!text.includes("\n") && (!idea || /^(script|story|film|movie|scene|something)$/i.test(idea))) {
+ return {
+ reply: "What's the film about? Give me a line or two — a character, a place, what goes wrong — or paste your script, and I'll break it into shots with the camera, light and palette filled in.",
+ shots: [],
+ };
+ }
const count = /(\d+)\s*[- ]?\s*shots?/i.exec(text)?.[1];
const seconds = /(\d+)\s*[- ]?\s*(s|sec|second)s?\b/i.exec(text)?.[1];
const parts = beats(text, count ? Math.max(1, Math.min(12, Number(count))) : undefined);
const each = seconds ? Math.max(DURATION.min, Math.min(DURATION.max, Math.round(Number(seconds) / parts.length))) : DURATION.default;
const look = guessLook(t, project.director);
- const shots = parts.map((beat, i): DirectorShot => {
- const f = FRAMES[parts.length <= 4 ? [0, 1, 2, 7][i] : i % FRAMES.length] ?? FRAMES[i % FRAMES.length];
+ const shots = parts.map(({ beat, frame }, i): DirectorShot => {
+ const f = FRAMES[frame ?? (parts.length <= 4 ? [0, 1, 2, 7][i] : i % FRAMES.length)] ?? FRAMES[i % FRAMES.length];
return {
title: `${i + 1}. ${f.title}`,
prompt: `${f.frame}: ${beat.replace(/[.\s]+$/, "")}`,
diff --git a/tests/cinema-api.test.ts b/tests/cinema-api.test.ts
index 9b6400e4..82115e58 100644
--- a/tests/cinema-api.test.ts
+++ b/tests/cinema-api.test.ts
@@ -13,7 +13,7 @@ const { setSetting } = await import("@/server/settings");
const gens = await import("@/server/generations");
const cinema = await import("@/server/cinema");
const { generateInProject, swatchUrl } = await import("@/server/cinema-generate");
-const { askDirector, offlineDirector, parseDirectorAnswer } = await import("@/server/cinema-director");
+const { askDirector, ideaOf, offlineDirector, parseDirectorAnswer } = await import("@/server/cinema-director");
const projectsRoute = await import("@/app/api/cinema/projects/route");
const projectRoute = await import("@/app/api/cinema/projects/[id]/route");
const foldersRoute = await import("@/app/api/cinema/projects/[id]/folders/route");
@@ -187,6 +187,20 @@ describe("AI Director", () => {
expect(script.shots.map((s) => s.prompt)).toEqual(["Wide establishing shot: She opens the letter", "Medium shot: Her hands shake", "Close-up: She looks out the window at the rain"]);
expect(script.shots[0].settings.camera).toBe("35mm-film");
expect(offlineDirector("Write a project brief for a perfume commercial", { brief: { title: "", body: "" }, director: {} }).brief).toMatch(/^Context: /);
+
+ // A one-line idea gets a shot structure around it; a bare "write a script" asks what the film is about.
+ expect(ideaOf("Generate an 8-shot storyboard for a sci-fi chase scene through a neon city at night")).toBe("a sci-fi chase scene through a neon city at night");
+ const ad = offlineDirector("Create a 15-second cinematic perfume commercial", { brief: { title: "", body: "" }, director: {} });
+ expect(ad.shots.map((s) => s.prompt)).toEqual([
+ "Wide establishing shot: cinematic perfume commercial, the world of the product, setting the mood",
+ "Medium shot: cinematic perfume commercial, the hero finds it",
+ "Close-up: cinematic perfume commercial, the product up close, light catching every surface",
+ "Wide closing shot: cinematic perfume commercial, the final hero shot, product centred, room for the logo",
+ ]);
+ expect(ad.shots.every((s) => s.duration === 4 && s.settings.tempo === "dynamic")).toBe(true);
+ const ask = offlineDirector("Write a script", { brief: { title: "", body: "" }, director: {} });
+ expect(ask.shots).toEqual([]);
+ expect(ask.reply).toMatch(/What's the film about/);
});
it("parses an LLM answer and drops values the panel doesn't know", () => {