Skip to content

Open source CapCut alternative.

TypeScript

feat(cut): plan generated video as a verified, editable storyboard

David Le11f9c0495447
diff --git a/site/scripts/genvideo-selftest.ts b/site/scripts/genvideo-selftest.ts
index 98f4324d..22e228a3 100644
--- a/site/scripts/genvideo-selftest.ts
+++ b/site/scripts/genvideo-selftest.ts
@@ -154,9 +154,13 @@ async function run(): Promise<void> {
const project = baseProject({ audioMode: "provided", audioClipId: "audio-clip", audioAssetId: "audio-asset", durationFrames: DURATION_FRAMES });
const orch = new VideoOrchestrator(project, d);
await orch.run();
- check("run pauses at breakdown", project.phase === "breakdown");
+ check("run pauses at the storyboard gate", project.phase === "storyboard");
check("nothing placed before approval", editor.placed.length === 0);
- project.shots[2].action = `${FAIL} a broken shot`; // dooms BOTH its keyframe and its video
+ // Doom the shot AT the gate: its opening frame was drawn during planning, so
+ // clear it too — the marker then fails both its re-mint and its video, and
+ // the shot must still fill its slot from a neighbor's frame.
+ project.shots[2].action = `${FAIL} a broken shot`;
+ project.shots[2].startKeyframe = undefined;
await orch.approveBreakdown();
check("run reaches done", project.phase === "done");
check("no holes — every shot on the timeline", project.shots.every((s) => !!s.timelineClipId));
@@ -467,12 +471,14 @@ async function run(): Promise<void> {
const { d } = deps(editor, { audioNative: true, failStyle: true });
const project = generatedProject();
const orch = new VideoOrchestrator(project, d);
- await orch.run();
+ // Style now runs during planning (before the storyboard gate), so a failed
+ // design fails the run there — the gate never opens on a broken bible.
let error = "";
- await orch.approveBreakdown().catch((e: unknown) => {
+ await orch.run().catch((e: unknown) => {
error = String(e);
});
check("a failed style design rejects the run", error.includes("fake style design failed"));
+ check("the run is marked failed", project.phase === "failed");
check("no stand-in bible is installed", project.characters.length === 0);
check("nothing rendered under a missing bible", project.shots.every((s) => s.status !== "placed"));
}
diff --git a/site/src/cut/components/SceneCard.tsx b/site/src/cut/components/SceneCard.tsx
index e6b50048..881be5e9 100644
--- a/site/src/cut/components/SceneCard.tsx
+++ b/site/src/cut/components/SceneCard.tsx
@@ -34,7 +34,7 @@ import { RefThumb } from "./AssetRefs";
const STATUS_LABEL: Record<SceneRun["status"], string> = {
planning: "Planning",
- awaiting_approval: "Ready to render",
+ awaiting_approval: "Storyboard ready",
generating: "Rendering",
done: "Done",
failed: "Failed",
@@ -141,7 +141,13 @@ export function SceneCard({ threadId }: { threadId: string }) {
)}
</button>
- {open && <ShotStrip run={run} redoable={run.status === "done"} />}
+ {open && (
+ <ShotStrip
+ run={run}
+ redoable={run.status === "done" || run.status === "awaiting_approval"}
+ atGate={run.status === "awaiting_approval"}
+ />
+ )}
</div>
) : (
// Nothing rendered yet (planning, at the gate, or a run that died
@@ -246,7 +252,15 @@ export function SceneCard({ threadId }: { threadId: string }) {
* Numbered placeholders with the planned description stand in while the frames
* are still being cut, so the same grid carries the run from plan through
* render without changing shape. */
-function ShotStrip({ run, redoable }: { run: SceneRun; redoable: boolean }) {
+function ShotStrip({
+ run,
+ redoable,
+ atGate,
+}: {
+ run: SceneRun;
+ redoable: boolean;
+ atGate: boolean;
+}) {
const assets = useEditor((s) => s.assets);
const aspect = useEditor((s) => s.aspect);
const baseRatio = aspect === "9:16" ? 9 / 16 : 16 / 9;
@@ -260,6 +274,7 @@ function ShotStrip({ run, redoable }: { run: SceneRun; redoable: boolean }) {
assets={assets}
baseRatio={baseRatio}
redoable={redoable}
+ atGate={atGate}
/>
))}
</div>
@@ -268,22 +283,24 @@ function ShotStrip({ run, redoable }: { run: SceneRun; redoable: boolean }) {
/** One grid tile: the shot's take once placed, else its opening frame, else a
* numbered placeholder over the planned description — so a shot reads before it
- * has a frame. Click opens whatever exists in the lightbox; once the run is done
- * the hover redo button re-renders just this shot (the same gate the old plan
- * rows carried — a redo before then would bill an unapproved shot). Tiles are
- * borderless so the grid stays flat inside the card. */
+ * has a frame. Click opens whatever exists in the lightbox. The hover redo
+ * button works in two places: at the storyboard gate it re-draws just this
+ * frame (a cheap image, nothing rendered yet), and once the run is done it
+ * re-renders the whole shot. Tiles are borderless so the grid stays flat. */
function ShotTile({
shot,
n,
assets,
baseRatio,
redoable,
+ atGate,
}: {
shot: Shot;
n: number;
assets: MediaAsset[];
baseRatio: number;
redoable: boolean;
+ atGate: boolean;
}) {
const clip = shot.clip ? assets.find((a) => a.id === shot.clip) : undefined;
const frame = shot.startKeyframe ? assets.find((a) => a.id === shot.startKeyframe) : undefined;
@@ -351,7 +368,7 @@ function ShotTile({
{redoable && (
<button
type="button"
- title="Redo this shot"
+ title={atGate ? "Redraw this frame" : "Redo this shot"}
onClick={(e) => {
e.stopPropagation();
useGenScene.getState().regenerateShot(n);
diff --git a/site/src/cut/lib/genScene.ts b/site/src/cut/lib/genScene.ts
index a18edc77..434f0248 100644
--- a/site/src/cut/lib/genScene.ts
+++ b/site/src/cut/lib/genScene.ts
@@ -343,6 +343,7 @@ function phaseActivity(phase: VideoPhase): string | undefined {
case "voicing": return "Voicing the narration…";
case "style": return "Designing the look, cast, and places…";
case "keyframes": return "Drawing each shot's opening frame…";
+ case "storyboard": return "Storyboard ready — review the frames before rendering.";
case "generating": return "Rendering shots…";
case "polish": return "Assembling the final cut…";
default: return undefined;
@@ -457,10 +458,11 @@ function statusFor(p: VideoProject): SceneStatus {
if (p.phase === "failed") return "failed";
if (p.phase === "done") return "done";
if (p.breakdownApproved) return "generating";
- // Unapproved: at the gate only once the plan exists. A run persisted
- // mid-planning must hydrate as planning — an Approve button with no shot
- // list behind it would render paid shots through a gate nobody reviewed.
- return p.shots.length > 0 ? "awaiting_approval" : "planning";
+ // Unapproved: the approval gate opens only at the storyboard phase, once the
+ // frames are drawn and story-checked. Anything earlier (writing, designing,
+ // drawing frames) is still planning — an Approve button before the frames
+ // exist would offer to render a storyboard nobody has seen.
+ return p.phase === "storyboard" ? "awaiting_approval" : "planning";
}
/** Reconstruct the feed a reload lost: the assets the run already made, in
@@ -742,10 +744,21 @@ export const useGenScene = create<GenSceneState>((set, get) => ({
},
regenerateShot: (n, note) => {
- // After a reload the finished run has no live orchestrator — rebuild it
- // from the persisted plan before deciding the scene "isn't done".
const openId = useEditor.getState().projectId;
if (!openId) return { ok: false, message: "Open a project first." };
+ // At the storyboard gate, "redo" re-draws the opening frame only — the
+ // cheap image, no take — and the run stays parked for approval. A note
+ // ("at night", "wider") rides into the frame and the shot's plan.
+ const gateRun = get().run;
+ if (gateRun && gateRun.projectId === openId && gateRun.status === "awaiting_approval") {
+ const orch = orchestrators.get(openId);
+ const id = orch?.shotIdByNumber(n);
+ if (!orch || !id) return { ok: false, message: `This scene has no shot ${n}.` };
+ orch.reviseStoryboardFrame(id, note).catch(() => {});
+ return { ok: true, message: note ? `Redrawing shot ${n} (${note})…` : `Redrawing shot ${n}…` };
+ }
+ // After a reload the finished run has no live orchestrator — rebuild it
+ // from the persisted plan before deciding the scene "isn't done".
if (!orchestrators.get(openId) || !get().run) resumeDoneRun();
const run = get().run;
const orch = orchestrators.get(openId);
diff --git a/site/src/cut/lib/genvideo/adapters/review.ts b/site/src/cut/lib/genvideo/adapters/review.ts
index c89cd02b..77eeb28b 100644
--- a/site/src/cut/lib/genvideo/adapters/review.ts
+++ b/site/src/cut/lib/genvideo/adapters/review.ts
@@ -17,7 +17,14 @@ import { hostedPost } from "../../hosted";
import { captureVideoFrames } from "../../visualFrames";
import { findRunAsset } from "../docWriter";
import { imagePart } from "./refImages";
-import type { FrameCheckInput, ReviewInput, ReviewRole, ReviewVerdict } from "../capabilities";
+import type {
+ FrameCheckInput,
+ ReviewInput,
+ ReviewRole,
+ ReviewVerdict,
+ StoryboardInput,
+ StoryboardVerdict,
+} from "../capabilities";
const MAX_FRAMES = 8;
/** Aim for one frame every ~1s of take. */
@@ -41,6 +48,15 @@ const IDENTITY_INSTRUCTIONS = `You compare character designs for a production.
Reply with JSON only: {"sameDesign": boolean, "drift": string}
The first image is the canonical design sheet. The frames after it show a character in a rendered shot — possibly at a distance, in motion, or seen from behind. Judge STRUCTURE, not rendering detail: head and hair silhouette, face shape and eye style when visible, body proportions, and the outfit with its exact colors — except attire the stated shot plan changes (a uniform, swimwear, a costume): that outfit is the plan's, not drift, so judge everything but the clothes. Distance or motion blur losing fine detail is fine; a DIFFERENT design is not — a rounder or simplified head, different hair silhouette, or a redesigned face means sameDesign false, as does a changed outfit the plan did not call for. Seen only from behind or far away, judge silhouette (and outfit, when the plan keeps it) — and silhouette includes head shape: a round or bean-shaped head where the sheet has an angular or spiky-haired one is a DIFFERENT design at any distance. drift, when false, is one short retake direction naming the difference ("a bean-headed chibi with dot eyes — match the sheet's spiky-haired detailed anime boy").`;
+const STORYBOARD_INSTRUCTIONS = `You are a director reviewing a storyboard before it goes to camera. The images are the ordered opening frames of consecutive shots in ONE continuous short video; judge them as a sequence that must tell the logline's story.
+Reply with JSON only: {"panels": [{"ok": boolean, "note": string}]} — exactly one entry per panel, in the order given.
+Rules:
+- ok is whether this panel earns its place in the story: it depicts its own beat AND moves the story forward from the panel before it. A frame that shows the wrong subject or action for its beat, merely repeats the previous panel without progressing, or is generic filler any beat could use, is not ok.
+- Continuity between panels is part of the story: a recurring character and their wardrobe, a named prop the story carries, the location, and the time of day stay consistent from panel to panel unless a beat itself changes them. A panel that silently drops a carried prop, restyles a character, or teleports the setting is not ok.
+- Judge story and continuity, NOT drawing polish — a separate art pass handles technique. Forgive small rendering detail, camera choice, and pose.
+- note, when ok is false, is one short retake direction for THAT frame naming what to change so it carries the story ("show the boy still holding the red kite from the last panel, now running toward the shore"). Empty string when ok is true.
+- Return one entry per panel in order. A panel that works is {"ok": true, "note": ""}.`;
+
const FRAME_INSTRUCTIONS = `You are a production's art director signing off one drawn frame against the production's benchmark sheet.
Reply with JSON only: {"ok": boolean, "note": string}
Rules:
@@ -94,6 +110,61 @@ The benchmark sheet — the artist to match:`,
return { ok, ...(note ? { note } : {}) };
},
+ async storyboard(input: StoryboardInput): Promise<StoryboardVerdict> {
+ const allOk = (): StoryboardVerdict => ({
+ notes: input.panels.map((p) => ({ shotId: p.shotId, ok: true })),
+ });
+ // Only panels whose frame resolves ride to the model — a missing frame
+ // has nothing to judge and passes. Numbered contiguously so the panel
+ // order the model replies in maps straight back to these shots.
+ const seen: { shotId: string; part: { data: string; mimeType: string } }[] = [];
+ const content: Record<string, unknown>[] = [
+ {
+ text: `Review this storyboard as one continuous short video, frames in order.
+The story (logline): ${input.logline || "(none written)"}
+The look: ${input.style || "(none)"}`,
+ },
+ ];
+ for (const p of input.panels) {
+ const asset = p.frameMediaId ? await findRunAsset(projectId, p.frameMediaId) : null;
+ const part = asset ? await imagePart(asset.url) : null;
+ if (!part) continue;
+ seen.push({ shotId: p.shotId, part });
+ content.push({
+ text: `Panel ${seen.length}${p.intent ? ` — purpose: ${p.intent}` : ""}: ${
+ p.action || "(no action written)"
+ }${p.narration ? ` — narration: "${p.narration}"` : ""}`,
+ });
+ content.push({ type: "input_image", dataBase64: part.data, mimeType: part.mimeType });
+ }
+ // Nothing to compare in isolation — a lone frame can't fail continuity.
+ if (seen.length < 2) return allOk();
+ const res = await hostedPost("/api/inference/responses", {
+ donkeyProvider: "gemini",
+ model: geminiModelRoles.review,
+ instructions: STORYBOARD_INSTRUCTIONS,
+ response_format: { type: "json_object" },
+ input: [{ role: "user", content }],
+ });
+ if (!res.ok) throw new Error("The review model is unavailable.");
+ const body = (await res.json()) as { output_text?: string };
+ const parsed = JSON.parse(body.output_text ?? "{}") as Record<string, unknown>;
+ const verdicts = Array.isArray(parsed.panels) ? parsed.panels : [];
+ const bySeen = new Map<string, StoryboardVerdict["notes"][number]>();
+ seen.forEach((s, i) => {
+ const v = (verdicts[i] ?? {}) as Record<string, unknown>;
+ const ok = v.ok !== false;
+ const note = typeof v.note === "string" ? v.note.trim() : "";
+ bySeen.set(s.shotId, { shotId: s.shotId, ok, ...(!ok && note ? { note } : {}) });
+ });
+ // Every panel gets a verdict; the ones with no frame default to ok.
+ return {
+ notes: input.panels.map(
+ (p) => bySeen.get(p.shotId) ?? { shotId: p.shotId, ok: true }
+ ),
+ };
+ },
+
async watch(input: ReviewInput): Promise<ReviewVerdict> {
// The take resolves wherever the run's project lives — store when open,
// persisted doc when the user switched away mid-render.
@@ -115,7 +186,7 @@ The benchmark sheet — the artist to match:`,
const content: Record<string, unknown>[] = [
{
text: `Review this take, shown as frames sampled along its ${clipSec.toFixed(1)}s.
-Planned action: ${input.action || "(none written — judge against the narration)"}
+${input.logline ? `The video's story: ${input.logline}\n` : ""}${input.intent ? `This shot's job in that story: ${input.intent}\n` : ""}Planned action: ${input.action || "(none written — judge against the narration)"}
The plan's look: ${input.style || "(none — judge content only)"}
Narration heard over the shot: ${input.narration ? `"${input.narration}"` : "(none)"}
The timeline slot needs ${input.slotSec.toFixed(1)}s of this take.`,
diff --git a/site/src/cut/lib/genvideo/adapters/text.ts b/site/src/cut/lib/genvideo/adapters/text.ts
index 88543048..f19b45a4 100644
--- a/site/src/cut/lib/genvideo/adapters/text.ts
+++ b/site/src/cut/lib/genvideo/adapters/text.ts
@@ -115,11 +115,12 @@ const distinct = (xs: string[]): string[] => Array.from(new Set(xs.filter(Boolea
const SCRIPT_INSTRUCTIONS = `You are a short-video writer. Turn the brief into a spoken video plan.
Reply with JSON only:
{"logline": string, "style": string, "beats": [
- {"dialogue": string, "action": string, "characters": ["char:1"], "location": "loc:1", "framing": string, "approxSeconds": number}
+ {"dialogue": string, "action": string, "characters": ["char:1"], "location": "loc:1", "framing": string, "intent": string, "approxSeconds": number}
]}
Rules:
- dialogue is the narration/spoken line for that beat (one or two sentences), action is what is shown on screen.
-- Shape the beats as a story, not a list: open by establishing the world, turn on a small surprise or decision, and end on a payoff image that resolves it.
+- logline is one sentence naming the whole video's story — the throughline every beat serves. intent is that beat's job in the story in a few words ("establish the world", "the turn", "the payoff", "raise the stakes"), so a shot rendered on its own still knows what it is FOR.
+- Shape the beats as a story, not a list: open by establishing the world, turn on a small surprise or decision, and end on a payoff image that resolves it. Every beat must move the story from the one before it — never a repeat or a generic filler image any beat could use.
- framing is real camera language fit to the genre, varied beat to beat — wide establishing, close-up, insert of a telling detail (a sign, hands, an object), POV, follow shot, over-the-shoulder, aerial, macro, low angle, whatever the story calls for. Never the same framing twice in a row, and never treat this list as a quota.
- action carries continuity: name the wardrobe items and props the story repeats (the book, the earbuds, the bag) in every beat where they appear, so shots rendered independently still match.
- A shot cannot be trusted to render readable text: no signs, labels, charts, graphic overlays, or lettering beyond a single short word — information the viewer must read goes in the dialogue instead.
@@ -127,21 +128,24 @@ Rules:
- Keep the whole thing near the requested length; each beat is about 4–8 seconds of narration.
- style is a short reusable look for the whole video (medium, lighting, palette, mood), described by its visual traits — never a real brand, franchise, show, or artist name, even one the brief uses (a generator rejects trademarked names).`;
+/** One raw beat object → a validated ScriptBeat. Shared by the first draft and
+ * the coverage revision so both coerce identically (intent included). */
+function toBeat(b: unknown): ScriptBeat {
+ const beat = (b ?? {}) as Record<string, unknown>;
+ return {
+ dialogue: str(beat.dialogue),
+ action: str(beat.action),
+ characters: idList(beat.characters),
+ location: str(beat.location) || "loc:1",
+ framing: str(beat.framing) || "medium shot",
+ ...(str(beat.intent) ? { intent: str(beat.intent) } : {}),
+ approxSeconds: Math.max(2, Math.min(8, num(beat.approxSeconds, 6))),
+ };
+}
+
function parseScript(o: Record<string, unknown>): ScriptPlan | null {
const rawBeats = Array.isArray(o.beats) ? o.beats : [];
- const beats: ScriptBeat[] = rawBeats
- .map((b): ScriptBeat => {
- const beat = (b ?? {}) as Record<string, unknown>;
- return {
- dialogue: str(beat.dialogue),
- action: str(beat.action),
- characters: idList(beat.characters),
- location: str(beat.location) || "loc:1",
- framing: str(beat.framing) || "medium shot",
- approxSeconds: Math.max(2, Math.min(8, num(beat.approxSeconds, 6))),
- };
- })
- .filter((b) => b.dialogue || b.action);
+ const beats: ScriptBeat[] = rawBeats.map(toBeat).filter((b) => b.dialogue || b.action);
if (beats.length === 0) return null;
return {
logline: str(o.logline),
@@ -150,6 +154,47 @@ function parseScript(o: Record<string, unknown>): ScriptPlan | null {
};
}
+// ── brief-coverage self-check ────────────────────────────────────────────────
+
+const COVERAGE_INSTRUCTIONS = `You are a script editor checking a drafted shot plan against its brief before it goes into production.
+Reply with JSON only:
+{"missing": [string], "beats": [
+ {"dialogue": string, "action": string, "characters": ["char:1"], "location": "loc:1", "framing": string, "intent": string, "approxSeconds": number}
+]}
+Rules:
+- missing lists every concrete thing the brief explicitly asks to see or say that the drafted beats do not — a named subject, object, action, place, or event. Judge only what the brief actually calls for; invent no new requirements.
+- If nothing is missing, return {"missing": [], "beats": []} and change nothing.
+- Otherwise return a COMPLETE revised beats array: keep the beats that work, and add or repair beats so every missing element lands on screen or in the narration. Stay near the same number of beats and total length, reuse the same char:/loc: ids, and keep the story shape (establish, turn, payoff) with each beat advancing the one before it.
+- Every rule the draft followed still holds: dialogue is the spoken line, action is what the camera sees, intent is the beat's job in the story, framing is real camera language varied beat to beat, no on-screen text, and no real brand, franchise, show, or artist names.`;
+
+/** Second pass: verify the draft covers everything the brief asks for, and
+ * revise it in place when it doesn't. Best-effort — a failure (or an
+ * unparseable revision) keeps the draft, so coverage never blocks a run that
+ * already has a usable script. Skipped when there is no brief to check against. */
+async function reviseForCoverage(brief: string, plan: ScriptPlan): Promise<ScriptPlan> {
+ const drafted = plan.beats
+ .map((b, i) => `${i + 1}. [${b.intent || "—"}] ${b.action}${b.dialogue ? ` — "${b.dialogue}"` : ""}`)
+ .join("\n");
+ const user = `Brief: ${brief}
+
+Drafted beats:
+${drafted}
+
+List anything the brief asks for that these beats miss. If nothing is missing, return empty arrays; otherwise return a full revised beats array that covers it.`;
+ try {
+ const revised = await llmJson(COVERAGE_INSTRUCTIONS, user, (o) => {
+ const rawBeats = Array.isArray(o.beats) ? o.beats : [];
+ const beats = rawBeats.map(toBeat).filter((b) => b.dialogue || b.action);
+ // Never null: an empty array is the valid "nothing missing" answer, and
+ // llmJson would otherwise retry a correct verdict as unusable.
+ return { beats } as { beats: ScriptBeat[] };
+ });
+ return revised.beats.length ? { ...plan, beats: revised.beats } : plan;
+ } catch {
+ return plan; // the draft stands — the check is an enhancement, not a gate
+ }
+}
+
export function makeScriptRole(): ScriptRole {
return {
async write(input) {
@@ -161,7 +206,11 @@ export function makeScriptRole(): ScriptRole {
const user = `Write a spoken video plan for this brief. Aim for about ${targetSeconds} seconds total across roughly ${beatCount} beats.
${refNote}
Brief: ${input.brief}`;
- return llmJson(SCRIPT_INSTRUCTIONS, user, parseScript);
+ const plan = await llmJson(SCRIPT_INSTRUCTIONS, user, parseScript);
+ // A one-shot draft can silently drop something the brief asked for; the
+ // coverage pass catches that at the source, before any style, sheet,
+ // keyframe, or render spends against a story that doesn't match.
+ return input.brief.trim() ? reviseForCoverage(input.brief.trim(), plan) : plan;
},
};
}
diff --git a/site/src/cut/lib/genvideo/capabilities.ts b/site/src/cut/lib/genvideo/capabilities.ts
index 7d8f9d80..b13e855f 100644
--- a/site/src/cut/lib/genvideo/capabilities.ts
+++ b/site/src/cut/lib/genvideo/capabilities.ts
@@ -148,6 +148,11 @@ export interface ReviewInput {
videoMediaId: string;
/** What the plan wanted on screen. */
action: string;
+ /** The video's one-line story, so the reviewer judges the take as this beat
+ * of that story — not as an isolated action divorced from what it is for. */
+ logline?: string;
+ /** This shot's job in the arc (its beat's intent) — the same grounding. */
+ intent?: string;
/** The plan's look — the reviewer judges the medium against it strictly. */
style?: string;
/** The shot's approved opening frame — the take must match its rendering
@@ -191,12 +196,50 @@ export interface FrameCheckInput {
subject: string;
}
+/** One frame of the storyboard: a shot's opening keyframe and what it is for. */
+export interface StoryboardPanel {
+ /** The shot this frame opens — the verdict is keyed back to it. */
+ shotId: string;
+ /** The frame image to judge; absent panels are skipped (nothing to see). */
+ frameMediaId?: string;
+ /** What the beat depicts, what is heard over it, and its job in the arc. */
+ action: string;
+ narration: string;
+ intent?: string;
+}
+
+export interface StoryboardInput {
+ /** The video's one-line story the ordered frames must tell. */
+ logline: string;
+ style?: string;
+ /** The shots' opening frames, in timeline order. */
+ panels: StoryboardPanel[];
+}
+
+/** A per-frame verdict on whether it earns its place in the story. */
+export interface StoryboardNote {
+ shotId: string;
+ ok: boolean;
+ /** Retake direction for a frame that doesn't carry the story — carried into
+ * the frame's re-mint prompt. */
+ note?: string;
+}
+
+export interface StoryboardVerdict {
+ notes: StoryboardNote[];
+}
+
export interface ReviewRole {
/** Watch a rendered take against its plan — the dailies check. */
watch(input: ReviewInput): Promise<ReviewVerdict>;
/** Judge one minted frame against the production's benchmark BEFORE it seeds
* a paid render — the same-artist gate. Optional; absent means no gate. */
frame?(input: FrameCheckInput): Promise<ReviewVerdict>;
+ /** Read the whole storyboard as one sequence BEFORE any video spends, and
+ * flag every frame that doesn't carry the story forward — a wrong beat, a
+ * repeat, a dropped prop, a teleported setting. Optional; absent means the
+ * frames go to camera unread as a sequence. */
+ storyboard?(input: StoryboardInput): Promise<StoryboardVerdict>;
}
/** One model choice per role — what the orchestrator runs against. */
diff --git a/site/src/cut/lib/genvideo/orchestrator.ts b/site/src/cut/lib/genvideo/orchestrator.ts
index ec6bed01..58ed9549 100644
--- a/site/src/cut/lib/genvideo/orchestrator.ts
+++ b/site/src/cut/lib/genvideo/orchestrator.ts
@@ -11,6 +11,10 @@
*
* brief → ingest → breakdown → (confirm) → style → keyframes → generating → polish → done
*
+ * The keyframes phase closes with a storyboard read: the minted frames are
+ * judged as one ordered sequence and any that fail to carry the story forward
+ * are reworked before generation, so drift is caught while it is still cheap.
+ *
* A run has one audio spine. In provided mode it is the user's dropped-in
* audio: shots tile it, their own audio muted, each lip-synced to its slice
* (inline for an audio-native model, else a lip-sync pass). In generated mode
@@ -97,16 +101,31 @@ export class VideoOrchestrator {
async run(): Promise<VideoProject> {
if (this.project.phase === "failed" || this.project.phase === "done") return this.project;
return this.failLoudly(async () => {
- const phases = [this.brief, this.ingest, this.breakdown];
- for (const phase of phases) {
+ // Plan all the way to the storyboard: script/segment the shots, design the
+ // look and cast, draw every opening frame, then read the frames as one
+ // sequence and rework the ones that don't carry the story. The sheets and
+ // keyframes are cheap images; the expensive video is what waits behind the
+ // gate. Skipped once already past the gate (an approve or a resume of an
+ // approved run re-enters here).
+ if (!this.project.breakdownApproved && this.project.phase !== "storyboard") {
+ const plan = [this.brief, this.ingest, this.breakdown, this.style, this.keyframes];
+ for (const phase of plan) {
+ if (this.aborted) return this.project;
+ await phase.call(this);
+ }
if (this.aborted) return this.project;
- await phase.call(this);
+ // Park at the storyboard gate for the user to approve or edit the frames.
+ if (!this.project.breakdownApproved) {
+ this.setPhase("storyboard");
+ await this.save();
+ return this.project;
+ }
}
- if (!this.project.breakdownApproved) return this.project; // wait for confirmation
- // Past the gate: the shots the user approved render as planned. Generated
- // mode voices nothing — each shot's video carries its own narration — so
- // the only spend beyond this point is the sheets, keyframes, and takes.
- const paid = [this.style, this.keyframes, this.generateAndPlaceAll, this.polish];
+ if (!this.project.breakdownApproved) return this.project; // still parked at the gate
+ // Past the gate: the approved storyboard renders. Generated mode voices
+ // nothing — each shot's video carries its own narration — so the only
+ // spend beyond here is the takes and the music bed.
+ const paid = [this.generateAndPlaceAll, this.polish];
for (const phase of paid) {
if (this.aborted) return this.project;
await phase.call(this);
@@ -137,12 +156,14 @@ export class VideoOrchestrator {
* placed shots — so only the missing work re-bills. */
async retryFailed(): Promise<VideoProject> {
if (this.project.phase !== "failed") return this.project;
- this.setPhase(this.project.breakdownApproved ? "style" : "brief");
+ // An approved run failed in generation — pick back up there; an unapproved
+ // one failed in planning, so re-plan to the storyboard gate.
+ this.setPhase(this.project.breakdownApproved ? "generating" : "brief");
await this.save();
return this.run();
}
- /** The user confirmed the shot list — continue the run. */
+ /** The user approved the storyboard — the shots render from here. */
async approveBreakdown(): Promise<VideoProject> {
this.project.breakdownApproved = true;
// The approval gate is the last moment the user can set the project shape;
@@ -200,6 +221,7 @@ export class VideoOrchestrator {
audioText: lines[pi] ?? "",
dialogue: lines[pi] ?? "",
action: beat.action,
+ ...(beat.intent ? { intent: beat.intent } : {}),
characters: beat.characters,
location: beat.location,
framing: beat.framing,
@@ -307,7 +329,7 @@ export class VideoOrchestrator {
this.deps.emit({ type: "asset", label: `Designed ${asset.name}`, mediaId: asset.mediaId, key: asset.id });
}
- // ── Phase D: keyframes (cheap, run in parallel) ──────────────────────────
+ // ── Phase D: keyframes (cheap, parallel) + storyboard coherence pass ─────
private async keyframes(): Promise<void> {
this.setPhase("keyframes");
const need = this.project.shots.filter((s) => !s.startKeyframe && s.status !== "placed");
@@ -316,6 +338,64 @@ export class VideoOrchestrator {
// in placeFallback, so nothing swallowed leaves a hole.
await fanOut(need, (shot) => this.makeKeyframes(shot), this.poolOpts(1));
await this.save();
+ // The frames are a storyboard now: read them as one sequence and rework the
+ // ones that don't carry the story, BEFORE any of them seeds a paid render.
+ await this.reviewStoryboard();
+ }
+
+ /** Read the minted keyframes as an ordered storyboard and re-mint every frame
+ * that fails to carry the story forward — a wrong beat, a repeat, a dropped
+ * prop, a teleported setting — each with the reviewer's note. Best-effort and
+ * story-only (the same-artist gate already held every frame to the look): a
+ * reviewer outage, or a plan with only one frame, leaves the board as drawn.
+ * Runs once per keyframe pass, before generation, so the fix is cheap. */
+ private async reviewStoryboard(): Promise<void> {
+ if (this.aborted) return;
+ const storyboard = this.deps.suite.review?.storyboard;
+ if (!storyboard) return;
+ const board = this.project.shots.filter((s) => s.startKeyframe && s.status !== "placed");
+ if (board.length < 2) return;
+ let verdict;
+ try {
+ verdict = await storyboard({
+ logline: this.project.script?.logline?.trim() || this.project.brief,
+ style: this.project.style,
+ panels: board.map((s) => ({
+ shotId: s.id,
+ frameMediaId: s.startKeyframe,
+ action: s.action,
+ narration: (s.dialogue ?? s.audioText).trim(),
+ ...(s.intent ? { intent: s.intent } : {}),
+ })),
+ });
+ } catch {
+ return; // the board goes to camera unread — a gate, not a blocker
+ }
+ const flagged = verdict.notes.filter((n) => !n.ok && n.note);
+ if (flagged.length === 0) return;
+ this.deps.emit({
+ type: "log",
+ message: `Reworking ${flagged.length} storyboard frame${flagged.length > 1 ? "s" : ""} to carry the story.`,
+ });
+ await fanOut(
+ flagged,
+ async (note) => {
+ const shot = this.project.shots.find((s) => s.id === note.shotId);
+ if (!shot || this.aborted) return;
+ // Release the flagged frame only once its replacement exists — a failed
+ // re-mint restores it rather than leaving the shot frame-less.
+ const prior = shot.startKeyframe;
+ shot.startKeyframe = undefined;
+ try {
+ await this.makeKeyframes(shot, note.note);
+ } catch {
+ /* restored below */
+ }
+ shot.startKeyframe = shot.startKeyframe ?? prior;
+ },
+ this.poolOpts(0)
+ );
+ await this.save();
}
private async makeKeyframes(shot: Shot, note?: string): Promise<void> {
@@ -325,7 +405,7 @@ export class VideoOrchestrator {
// The image model has no negative-prompt parameter, so the bans ride as
// avoid-text — a letterboxed or off-medium keyframe seeds a bad video.
const prompt = `${buildPrompt(shot, this.project)} Avoid: ${buildNegative(this.project)}.${
- note ? ` Note from the last take's review: ${note}` : ""
+ note ? ` Note from the review: ${note}` : ""
}`;
shot.startKeyframe = await this.screenedImage(`${prompt} Opening frame.`, refs, shot.action);
this.updateShot(shot, { status: "pending" });
@@ -470,6 +550,10 @@ export class VideoOrchestrator {
return await this.deps.suite.review!.watch({
videoMediaId: clip,
action: shot.action,
+ // The story spine, so the take is judged as this beat of the video —
+ // not an action stranded from what it is for.
+ logline: this.project.script?.logline?.trim() || this.project.brief || undefined,
+ ...(shot.intent ? { intent: shot.intent } : {}),
style: this.project.style,
keyframeMediaId: shot.startKeyframe,
// Identity is judged against the canonical sheets, not the keyframe —
@@ -641,6 +725,28 @@ export class VideoOrchestrator {
});
}
+ /** Re-draw one shot's opening frame at the storyboard gate, before any video
+ * spends. A note nudges it ("at night", "wider") and becomes part of the
+ * shot's plan; with none, the frame is simply re-rolled. Only the cheap
+ * keyframe is remade — the run stays parked at the gate. A no-op once the plan
+ * is approved (from there `regenerateShots` re-renders the take). A failed
+ * re-mint leaves the prior frame in place. */
+ async reviseStoryboardFrame(id: string, note?: string): Promise<VideoProject> {
+ if (this.aborted || this.project.breakdownApproved) return this.project;
+ const shot = this.project.shots.find((s) => s.id === id);
+ if (!shot) return this.project;
+ if (note) shot.action = shot.action ? `${shot.action} ${note}`.trim() : note;
+ try {
+ // The nudge already rides `action` (buildPrompt carries it), so the
+ // re-mint needs no separate review note.
+ await this.makeKeyframes(shot);
+ } catch {
+ this.updateShot(shot, { status: "pending" }); // clear the spinner; the prior frame stands
+ }
+ await this.save();
+ return this.project;
+ }
+
/** Re-cut a contiguous span of shots against the same audio: the segmenter
* re-slices just that span's narration (steered by the instruction), fresh
* shots replace the old ones between the same frame boundaries — the span
diff --git a/site/src/cut/lib/genvideo/prompt.ts b/site/src/cut/lib/genvideo/prompt.ts
index f4799a32..78e7d0fa 100644
--- a/site/src/cut/lib/genvideo/prompt.ts
+++ b/site/src/cut/lib/genvideo/prompt.ts
@@ -37,6 +37,10 @@ export function buildPrompt(shot: Shot, project: VideoProject): string {
if (asset && !asset.mediaId) parts.push(sentence(`${asset.name}: ${asset.description}`));
}
if (shot.framing) parts.push(`Framing, ${shot.framing}.`);
+ // The beat's job in the story, phrased as direction — it steers the
+ // composition and motion toward what the shot is FOR, and rides late so it
+ // never outweighs the look or the action at the prompt's head.
+ if (shot.intent) parts.push(`This shot's role in the story: ${sentence(shot.intent)}`);
parts.push(
"One single continuous shot with fluid, continuous character motion throughout — smooth, natural movement, never held poses or stepped animation. Pure visual storytelling: no on-screen text of any kind — no captions, subtitles, speech bubbles, titles, signs, or lettering — and no split screens, panels, or storyboard collages. No baked-in editing effects: no transition frames, fades, motion-blur smears, borders, or blurred letterbox bands — the picture fills the frame edge to edge, composed upright for this frame with a level horizon; cuts and transitions are added later in the editor."
);
diff --git a/site/src/cut/lib/genvideo/types.ts b/site/src/cut/lib/genvideo/types.ts
index c97e9807..dd0c949e 100644
--- a/site/src/cut/lib/genvideo/types.ts
+++ b/site/src/cut/lib/genvideo/types.ts
@@ -38,6 +38,10 @@ export interface ScriptBeat {
characters: string[];
location: string;
framing: string;
+ /** The beat's job in the arc — "establish the world", "the turn", "the
+ * payoff" — or a one-line director's note. Grounds the render and every
+ * judgment call in what the shot is FOR, not just what it depicts. */
+ intent?: string;
approxSeconds: number;
}
@@ -79,6 +83,10 @@ export interface Shot {
dialogue?: string;
/** What happens on screen — the motion, the beat. Text, never refs. */
action: string;
+ /** The shot's job in the story (from its script beat) — grounds the render
+ * prompt and the storyboard/dailies judgment in what the shot is FOR. Absent
+ * in provided-audio mode, where shots come from a segmenter, not a script. */
+ intent?: string;
characters: string[]; // character asset ids
location: string; // location asset id ("" = unspecified)
framing: string;
@@ -181,6 +189,10 @@ export type VideoPhase =
| "breakdown"
| "style"
| "keyframes"
+ /** Planning is complete — the storyboard is drawn and story-checked — and the
+ * run is parked at the approval gate. The user approves or edits the frames
+ * here; no video spends until then. */
+ | "storyboard"
| "generating"
| "review"
| "polish"