Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

Storyboards: start a Video draft from a storyboard (#13283)

[._.]/acd60f972d24
diff --git a/client/src/components/creative-director/StoryboardVideoShots.jsx b/client/src/components/creative-director/StoryboardVideoShots.jsx
new file mode 100644
index 0000000000..48bd254a02
--- /dev/null
+++ b/client/src/components/creative-director/StoryboardVideoShots.jsx
@@ -0,0 +1,33 @@
+import { formatCount, formatTimecode } from '../../utils/formatters';
+import { STORYBOARD_VIDEO_LIMITS } from '../../../../server/lib/storyboardVideo.js';
+
+const plural = (n, word) => `${formatCount(n)} ${word}${n === 1 ? '' : 's'}`;
+
+/**
+ * The shots a storyboard gives a new Video draft, exactly as they are written:
+ * each panel's prompt and length. The draft runs their total.
+ */
+export default function StoryboardVideoShots({ plan }) {
+ const trimmed = plan.shots.filter((shot) => shot.trimmed).length;
+ return (
+ <section aria-label="Shots from the storyboard" className="space-y-2">
+ <p className="text-sm text-port-text-muted">
+ {plural(plan.shots.length, 'shot')}, one per panel, <span className="tabular-nums">{formatTimecode(plan.totalSeconds)}</span> in all.
+ {' '}Changing the brief, style or production settings later has the director rewrite them.
+ </p>
+ {plan.problem && <p role="alert" className="text-sm text-port-error">{plan.problem}</p>}
+ {trimmed > 0 && <p className="text-sm text-port-warning">{plural(trimmed, 'panel')} longer than {STORYBOARD_VIDEO_LIMITS.shotMaxSec} s {trimmed === 1 ? 'is' : 'are'} cut to {STORYBOARD_VIDEO_LIMITS.shotMaxSec} s, the longest Video shot.</p>}
+ <ol className="space-y-1.5 max-h-80 overflow-auto" aria-label="Shot prompts">
+ {plan.shots.map((shot, index) => (
+ <li key={shot.sceneId} className="rounded border border-port-border p-2 text-xs text-gray-400">
+ <p className="flex items-baseline gap-2 text-sm text-white">
+ <span className="min-w-0 flex-1 truncate">{index + 1}. {shot.label}</span>
+ <span className="shrink-0 tabular-nums text-gray-400">{shot.durationSeconds} s</span>
+ </p>
+ <p className="break-words">{shot.prompt}</p>
+ </li>
+ ))}
+ </ol>
+ </section>
+ );
+}
diff --git a/client/src/components/creative-director/VideoDraftDrawer.jsx b/client/src/components/creative-director/VideoDraftDrawer.jsx
index 817dd2313b..db4b1da131 100644
--- a/client/src/components/creative-director/VideoDraftDrawer.jsx
+++ b/client/src/components/creative-director/VideoDraftDrawer.jsx
@@ -2,11 +2,15 @@ import { useRunwayCatalog } from '../../hooks/useRunwayCatalog.js';
import { VIDEO_REVIEW_CHECKPOINTS } from '../../../../server/lib/creativeDirectorPresets.js';
import { VIDEO_RENDER_MODES, modeLabel } from '../../lib/imageGenBackends.js';
import { RUNWAY_DEFAULT_IMAGE_VIDEO_MODEL, getRunwayVideoModel } from '../../lib/runwayVideoModels.js';
-import { useEffect, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
import Drawer from '../Drawer.jsx';
import useDrawerTab from '../../hooks/useDrawerTab.js';
import toast from '../ui/Toast';
import { createCreativeDirectorProject, updateCreativeDirectorProject } from '../../services/apiCreativeDirector.js';
+import { startVideoFromStoryboard } from '../../services/apiStoryboards.js';
+import { storyboardVideoPlan } from '../../../../server/lib/storyboardVideo.js';
+import { ASPECT_RATIOS } from '../../../../server/lib/creativeDirectorPresets.js';
+import StoryboardVideoShots from './StoryboardVideoShots.jsx';
import { listUniverseNames } from '../../services/apiUniverseBuilder.js';
import { listPipelineSeriesNames } from '../../services/apiPipeline.js';
import { listCatalogIngredients } from '../../services/apiCatalog.js';
@@ -18,7 +22,8 @@ import { Clapperboard, FileText, Library } from 'lucide-react';
const TABS = [{ id: 'brief', label: 'Brief', icon: FileText }, { id: 'production', label: 'Production', icon: Clapperboard }, { id: 'sources', label: 'Sources', icon: Library }];
const fieldClass = 'w-full mt-1 bg-port-bg border border-port-border rounded px-2 py-2 text-sm';
-export default function VideoDraftDrawer({ open, onClose, project, onSaved, catalogIngredientIds = [] }) {
+// `storyboard` starts a new draft from that board: its panels become the shots and set the length.
+export default function VideoDraftDrawer({ open, onClose, project, onSaved, catalogIngredientIds = [], storyboard = null }) {
const [tab, setTab] = useDrawerTab('videoDraftTab', 'brief', TABS.map(t => t.id));
const [form, setForm] = useState({});
const runwayCatalog = useRunwayCatalog(open && form.videoMode === 'runway');
@@ -30,15 +35,16 @@ export default function VideoDraftDrawer({ open, onClose, project, onSaved, cata
const [sourceId, setSourceId] = useState('');
const [sourceQuery, setSourceQuery] = useState('');
const [saving, setSaving] = useState(false);
+ const plan = useMemo(() => (open && storyboard && !project ? storyboardVideoPlan(storyboard) : null), [open, storyboard, project]);
useEffect(() => {
if (!open) return undefined;
let active = true;
setSourceId('');
setSourceQuery('');
const draft = project?.videoDraft;
- setForm({ name: project?.name || '', userStory: project?.userStory || '', styleSpec: project?.styleSpec || '',
+ setForm({ name: project?.name || storyboard?.name || '', userStory: project?.userStory || storyboard?.logline || '', styleSpec: project?.styleSpec || '',
videoMode: project?.renderBackend?.video?.mode || 'local', backendModelId: project?.renderBackend?.video?.modelId || '',
- aspectRatio: project?.aspectRatio || '16:9', quality: project?.quality || 'standard', modelId: (project?.renderBackend?.video?.mode === 'local' ? project.renderBackend.video.modelId : '') || project?.modelId || '',
+ aspectRatio: project?.aspectRatio || (ASPECT_RATIOS.includes(storyboard?.aspectRatio) ? storyboard.aspectRatio : '16:9'), quality: project?.quality || 'standard', modelId: (project?.renderBackend?.video?.mode === 'local' ? project.renderBackend.video.modelId : '') || project?.modelId || '',
min: draft?.durationRange?.min || 30, max: draft?.durationRange?.max || 60,
reviewPolicy: draft?.reviewPolicy || 'review', transition: draft?.transition || 'cut', audioMode: draft?.audio?.mode || 'native', trackId: draft?.audio?.trackId || '', audioPrompt: draft?.audio?.prompt || '', audioProvider: draft?.audio?.providerId || '', audioModel: draft?.audio?.model || '',
sources: draft?.sources || catalogIngredientIds.map(id => ({ kind: 'catalog', id })) });
@@ -48,14 +54,15 @@ export default function VideoDraftDrawer({ open, onClose, project, onSaved, cata
Promise.all([listUniverseNames({ silent: true }), listPipelineSeriesNames({ silent: true }), listCatalogIngredients({ limit: 100, silent: true })]).then(([u, s, c]) => { if (active) setSourceOptions({ universe: rows(u), series: rows(s), catalog: rows(c) }); }).catch(() => { if (active) toast.error('Unable to load source choices. Close and reopen to retry.'); });
listVideoModels({ silent: true }).then(m => { if (active) setModels(m || []); }).catch(() => {});
return () => { active = false; };
- }, [open, project?.id]);
+ }, [open, project?.id, storyboard?.id]);
const change = (key, value) => setForm(prev => ({ ...prev, [key]: value }));
const input = (key, label, options = {}) => <label htmlFor={`video-draft-${key}`} className="block text-sm">{label}<input id={`video-draft-${key}`} className={fieldClass} value={form[key] ?? ''} onChange={e => change(key, e.target.value)} {...options} /></label>;
const select = (key, label, choices) => <label htmlFor={`video-draft-${key}`} className="block text-sm">{label}<select id={`video-draft-${key}`} className={fieldClass} value={form[key] || ''} onChange={e => change(key, e.target.value)}>{choices.map(([value, text]) => <option key={value} value={value}>{text}</option>)}</select></label>;
- const exactTarget = Math.min(Number(form.max), Math.max(Number(form.min), project?.targetDurationSeconds ?? Number(form.max)));
+ const exactTarget = plan ? plan.totalSeconds : Math.min(Number(form.max), Math.max(Number(form.min), project?.targetDurationSeconds ?? Number(form.max)));
const save = async () => {
if (!form.name?.trim()) { setTab('brief'); toast.error('Name is required'); return; }
- const min = Number(form.min), max = Number(form.max);
+ if (plan?.problem) { setTab('brief'); toast.error(plan.problem); return; }
+ const min = plan ? exactTarget : Number(form.min), max = plan ? exactTarget : Number(form.max);
if (!Number.isInteger(min) || !Number.isInteger(max) || min < 5 || max > 600 || min > max) { setTab('brief'); toast.error('Choose a duration range between 5 and 600 seconds, minimum first'); return; }
const sources = form.sources || [];
const payload = { name: form.name.trim(), userStory: form.userStory, styleSpec: form.styleSpec,
@@ -64,19 +71,23 @@ export default function VideoDraftDrawer({ open, onClose, project, onSaved, cata
renderBackend: { ...project?.renderBackend, video: { ...project?.renderBackend?.video, mode: form.videoMode, modelId: form.videoMode === 'local' ? form.modelId : form.backendModelId || null } },
videoDraft: { durationRange: { min, max }, sources, transition: form.transition, audio: { mode: form.audioMode, ...(form.trackId ? { trackId: form.trackId } : {}), ...(form.audioPrompt ? { prompt: form.audioPrompt } : {}), ...(form.audioProvider ? { providerId: form.audioProvider } : {}), ...(form.audioModel ? { model: form.audioModel } : {}) }, reviewPolicy: form.reviewPolicy, checkpoints: project?.videoDraft?.checkpoints || VIDEO_REVIEW_CHECKPOINTS } };
setSaving(true);
- const saved = await (project ? updateCreativeDirectorProject(project.id, payload, { silent: true }) : createCreativeDirectorProject(payload, { silent: true }))
+ const saved = await (project ? updateCreativeDirectorProject(project.id, payload, { silent: true })
+ : plan ? startVideoFromStoryboard(storyboard.id, { boardUpdatedAt: storyboard.updatedAt, project: payload }, { silent: true }).then(res => res.project)
+ : createCreativeDirectorProject(payload, { silent: true }))
.catch(err => { toast.error(err.message || 'Unable to save video draft'); return null; });
setSaving(false);
if (saved) { onClose(); onSaved(saved); toast.success(project?.status && project.status !== 'draft' ? 'Production settings saved' : 'Video draft saved'); }
};
- return <Drawer open={open} onClose={onClose} title={project ? !project.status || project.status === 'draft' ? 'Edit video draft' : 'Edit production settings' : 'New video draft'} subtitle="Saving makes no provider calls. Start or resume production when ready." size="lg" tabs={TABS} activeTab={tab} onTabChange={setTab} closeOnEsc={false} closeOnBackdrop={false}>
+ return <Drawer open={open} onClose={onClose} title={project ? !project.status || project.status === 'draft' ? 'Edit video draft' : 'Edit production settings' : plan ? 'Video from storyboard' : 'New video draft'} subtitle="Saving makes no provider calls. Start or resume production when ready." size="lg" tabs={TABS} activeTab={tab} onTabChange={setTab} closeOnEsc={false} closeOnBackdrop={false}>
<fieldset disabled={saving} className="space-y-4">
{tab === 'brief' && <>
{input('name', 'Name', { maxLength: 200 })}
<label htmlFor="video-draft-userStory" className="block text-sm">Brief<textarea id="video-draft-userStory" value={form.userStory || ''} onChange={e => change('userStory', e.target.value)} className={fieldClass} rows={4} maxLength={10000} /></label>
<label htmlFor="video-draft-styleSpec" className="block text-sm">Style<textarea id="video-draft-styleSpec" value={form.styleSpec || ''} onChange={e => change('styleSpec', e.target.value)} className={fieldClass} rows={3} maxLength={5000} /></label>
+ {plan ? <StoryboardVideoShots plan={plan} /> : <>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">{input('min', 'Minimum duration (seconds)', { type: 'number', min: 5, max: 600 })}{input('max', 'Maximum duration (seconds)', { type: 'number', min: 5, max: 600 })}</div>
<p className="text-sm text-port-text-muted" aria-live="polite">Exact target: {Number.isFinite(exactTarget) && Number(form.min) <= Number(form.max) ? `${exactTarget} seconds` : 'Choose a valid range'}. Existing targets are preserved within the range; new drafts use the maximum.</p>
+ </>}
</>}
{tab === 'production' && <>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">{select('aspectRatio', 'Aspect ratio', ['16:9', '9:16', '1:1'].map(x => [x, x]))}{select('quality', 'Quality', ['draft', 'standard', 'high'].map(x => [x, x]))}</div>
@@ -107,7 +118,7 @@ export default function VideoDraftDrawer({ open, onClose, project, onSaved, cata
<ul className="space-y-2">{(form.sources || []).map(source => <li key={`${source.kind}:${source.id}`} className="flex items-center justify-between gap-2 border border-port-border rounded p-2"><span>{source.kind}: {sourceOptions[source.kind]?.find(s => s.id === source.id)?.name || sourceOptions[source.kind]?.find(s => s.id === source.id)?.title || source.id}</span><button aria-label={`Remove ${source.kind} source ${source.id}`} onClick={() => change('sources', form.sources.filter(s => s !== source))}>Remove</button></li>)}</ul>
<p className="text-sm text-port-text-muted">Attach up to 50 sources from existing creative records. Imported music and voice references remain attached until you remove them.</p>
</>}
- <div className="flex justify-end gap-2 border-t border-port-border pt-4"><button disabled={saving} onClick={onClose} className="px-3 py-2 rounded border border-port-border">Cancel</button><button disabled={saving} onClick={save} className="px-3 py-2 rounded bg-port-accent text-white disabled:opacity-50">{saving ? 'Saving…' : project?.status && project.status !== 'draft' ? 'Save production settings' : 'Save draft'}</button></div>
+ <div className="flex justify-end gap-2 border-t border-port-border pt-4"><button disabled={saving} onClick={onClose} className="px-3 py-2 rounded border border-port-border">Cancel</button><button disabled={saving || !!plan?.problem} onClick={save} className="px-3 py-2 rounded bg-port-accent text-white disabled:opacity-50">{saving ? 'Saving…' : project?.status && project.status !== 'draft' ? 'Save production settings' : 'Save draft'}</button></div>
</fieldset>
</Drawer>;
}
diff --git a/client/src/components/creative-director/VideoDraftDrawer.test.jsx b/client/src/components/creative-director/VideoDraftDrawer.test.jsx
index db6727d891..807e0cb3e6 100644
--- a/client/src/components/creative-director/VideoDraftDrawer.test.jsx
+++ b/client/src/components/creative-director/VideoDraftDrawer.test.jsx
@@ -5,13 +5,15 @@ vi.mock('../../services/apiUniverseBuilder.js', () => ({ listUniverseNames: vi.f
vi.mock('../../services/apiPipeline.js', () => ({ listPipelineSeriesNames: vi.fn(() => Promise.resolve([])) }));
vi.mock('../../services/apiCatalog.js', () => ({ listCatalogIngredients: vi.fn(() => Promise.resolve([])) }));
import { it, expect, vi } from 'vitest';
-import { render, screen, waitFor } from '@testing-library/react';
+import { act, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { MemoryRouter } from 'react-router';
vi.mock('../../services/apiCreativeDirector.js', () => ({ createCreativeDirectorProject: vi.fn(), updateCreativeDirectorProject: vi.fn() }));
+vi.mock('../../services/apiStoryboards.js', () => ({ startVideoFromStoryboard: vi.fn() }));
vi.mock('../../services/apiImageVideo.js', () => ({ listVideoModels: vi.fn(() => Promise.resolve([])) }));
vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));
import { createCreativeDirectorProject, updateCreativeDirectorProject } from '../../services/apiCreativeDirector.js';
+import { startVideoFromStoryboard } from '../../services/apiStoryboards.js';
import VideoDraftDrawer from './VideoDraftDrawer.jsx';
it('edits the same draft without changing workspace or losing source revisions', async () => {
const user = userEvent.setup();
@@ -44,3 +46,33 @@ it('defaults a new Video draft to native clip audio', async () => {
render(<MemoryRouter initialEntries={['/?videoDraftTab=production']}><VideoDraftDrawer open onClose={vi.fn()} onSaved={vi.fn()} /></MemoryRouter>);
expect(await screen.findByLabelText('Audio contract')).toHaveValue('native');
});
+
+it('starts a draft from a storyboard with its panels as the shots, shown before saving', async () => {
+ const user = userEvent.setup();
+ const storyboard = { id: 'sb-example', name: 'Example board', logline: 'A girl comes home.', aspectRatio: '9:16', updatedAt: '2026-01-01T00:00:00.000Z', beats: [
+ { id: 'beat-1', title: 'Arrival', panels: [{ id: 'panel-1', action: 'She steps off the bus', framing: 'wide', seconds: 4 }, { id: 'panel-2', action: 'The square', seconds: 12 }] },
+ ] };
+ const created = { id: 'cd-example', workspace: 'video' };
+ startVideoFromStoryboard.mockResolvedValue({ project: created });
+ const saved = vi.fn();
+ render(<MemoryRouter><VideoDraftDrawer open storyboard={storyboard} onClose={vi.fn()} onSaved={saved} /></MemoryRouter>);
+ expect(screen.getByLabelText('Name')).toHaveValue('Example board');
+ expect(screen.getByText('She steps off the bus. Wide shot.')).toBeInTheDocument();
+ expect(screen.getByText(/cut to 10 s/)).toBeInTheDocument();
+ expect(screen.queryByLabelText('Minimum duration (seconds)')).not.toBeInTheDocument();
+ await user.click(screen.getByRole('button', { name: 'Save draft' }));
+ await waitFor(() => expect(saved).toHaveBeenCalledWith(created));
+ expect(startVideoFromStoryboard).toHaveBeenCalledWith('sb-example', { boardUpdatedAt: storyboard.updatedAt, project: expect.objectContaining({
+ name: 'Example board', userStory: 'A girl comes home.', aspectRatio: '9:16', targetDurationSeconds: 14,
+ videoDraft: expect.objectContaining({ durationRange: { min: 14, max: 14 } }),
+ }) }, { silent: true });
+ expect(createCreativeDirectorProject).not.toHaveBeenCalled();
+});
+
+it('holds a storyboard too short for a Video and says why', async () => {
+ const storyboard = { id: 'sb-short', name: 'Short', updatedAt: 'x', beats: [{ id: 'beat-1', title: 'Blink', panels: [{ id: 'panel-1', action: 'A flash', seconds: 2 }] }] };
+ render(<MemoryRouter><VideoDraftDrawer open storyboard={storyboard} onClose={vi.fn()} onSaved={vi.fn()} /></MemoryRouter>);
+ await act(async () => {});
+ expect(screen.getByRole('alert')).toHaveTextContent('needs at least 5 s');
+ expect(screen.getByRole('button', { name: 'Save draft' })).toBeDisabled();
+});
diff --git a/client/src/pages/CreativeDirectorDetail.jsx b/client/src/pages/CreativeDirectorDetail.jsx
index 064ccb9f27..ba1b6092dc 100644
--- a/client/src/pages/CreativeDirectorDetail.jsx
+++ b/client/src/pages/CreativeDirectorDetail.jsx
@@ -286,6 +286,7 @@ function CreativeDirectorProject({ id, basePath }) {
<h2 className="text-lg font-medium">Video production</h2>
<p className="text-port-text-muted">Start authorizes the saved choices within your limits. Enabled review checkpoints pause for your approval.</p>
<p className="whitespace-pre-wrap">{project.userStory || 'Add a brief to describe this video.'}</p>
+ {project.storyboardId && <p className="text-sm"><Link to={`/storyboards/${project.storyboardId}`} className="text-port-accent hover:underline">Shots started from a storyboard</Link></p>}
<p className="text-sm">Exact target: {project.targetDurationSeconds} seconds (requested: {project.videoDraft?.durationRange?.min}–{project.videoDraft?.durationRange?.max} seconds) · {project.aspectRatio} · {project.quality}</p>
<p className="text-sm">Review: {project.videoDraft?.reviewPolicy || 'review'} · Checkpoints: {(project.videoDraft?.checkpoints || []).join(', ')}</p>
<VideoCutPanel project={project} />
diff --git a/client/src/pages/StoryboardDetail.jsx b/client/src/pages/StoryboardDetail.jsx
index 9600ccde9c..b80f572808 100644
--- a/client/src/pages/StoryboardDetail.jsx
+++ b/client/src/pages/StoryboardDetail.jsx
@@ -11,7 +11,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Link, useNavigate, useParams, useSearchParams } from 'react-router';
-import { ArrowLeft, LayoutGrid, LayoutPanelLeft, ListMusic, Loader2, Play, Plus, Rows3, ScrollText } from 'lucide-react';
+import { ArrowLeft, Clapperboard, LayoutGrid, LayoutPanelLeft, ListMusic, Loader2, Play, Plus, Rows3, ScrollText } from 'lucide-react';
import TabPills from '../components/ui/TabPills';
import toast from '../components/ui/Toast';
import socket from '../services/socket';
@@ -31,6 +31,7 @@ import SongBriefDrawer from '../components/storyboards/SongBriefDrawer';
import StoryboardPlayer from '../components/storyboards/StoryboardPlayer';
import PanelCard from '../components/storyboards/PanelCard';
import PanelDrawer from '../components/storyboards/PanelDrawer';
+import VideoDraftDrawer from '../components/creative-director/VideoDraftDrawer';
import { beatSeconds, findPanel } from '../components/storyboards/storyboardArt';
const VIEW_TABS = [
@@ -48,7 +49,7 @@ export default function StoryboardDetail() {
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
const view = VIEW_IDS.has(searchParams.get('view')) ? searchParams.get('view') : 'beats';
- // Drawers over the board (`?plot=open`, `?brief=open`), deep-linkable.
+ // Drawers over the board (`?plot=open`, `?brief=open`, `?video=open`), deep-linkable.
const setDrawerParam = (key, on) => setSearchParams((prev) => {
const next = new URLSearchParams(prev);
if (on) next.set(key, 'open');
@@ -58,6 +59,7 @@ export default function StoryboardDetail() {
const plotOpen = searchParams.get('plot') === 'open';
const setPlotOpen = (on) => setDrawerParam('plot', on);
const briefOpen = searchParams.get('brief') === 'open';
+ const videoOpen = searchParams.get('video') === 'open';
const viewQuery = (next) => (next === 'beats' ? '' : `?view=${next}`);
const viewSuffix = viewQuery(view);
// undefined = loading, null = missing.
@@ -259,6 +261,11 @@ export default function StoryboardDetail() {
<button type="button" onClick={() => setDrawerParam('brief', true)} className={headerButton}>
<ListMusic size={16} aria-hidden="true" /> Song brief
</button>
+ {board.beats.length > 0 && (
+ <button type="button" onClick={() => setDrawerParam('video', true)} className={headerButton}>
+ <Clapperboard size={16} aria-hidden="true" /> Make video
+ </button>
+ )}
{board.beats.some((beat) => beat.panels.length) && <MakeEmptyPanels boardId={id} />}
</div>
</header>
@@ -327,6 +334,8 @@ export default function StoryboardDetail() {
)}
</div>
+ <VideoDraftDrawer open={videoOpen} storyboard={board} onClose={() => setDrawerParam('video', false)}
+ onSaved={(created) => navigate(`/creative-director/${created.id}/overview`)} />
<SongBriefDrawer open={briefOpen} board={board} onClose={() => setDrawerParam('brief', false)} />
<PlotBeatsDrawer open={plotOpen} board={board} onClose={() => setPlotOpen(false)} onBoard={apply} />
<PanelDrawer
diff --git a/client/src/services/README.md b/client/src/services/README.md
index c6875ead6b..1b255f1bf7 100644
--- a/client/src/services/README.md
+++ b/client/src/services/README.md
@@ -87,7 +87,7 @@ toasts on throw). **Custom catch ⇒ `silent: true`** — otherwise toasts fire
| `apiMeatspace.js` | MeatSpace health, genome, POST, memory-practice, and atomic POST training-run APIs. |
| `apiMortalLoom.js` | Mortality tracking. |
| `apiMoodBoard.js` | Mood boards (inspiration canvas + items), `listMoodBoardNames()` for pickers, `composeMoodBoardPrompt()` which stores the board's composite style prompt. |
-| `apiStoryboards.js` | Storyboards (Create › Storyboards): board/beat/panel CRUD and moves, panel art takes (add, select, remove), the panel maker (board recipe, per-panel node values, node runs, Make empty panels), beats from a plot summary (preview, then add), the saved recipe library, Make storyboard from a music video and Fit to song (write a video's shots from its linked board), and a fitted shot's Update from its edited panel and Use as panel art; every board write returns the whole board. |
+| `apiStoryboards.js` | Storyboards (Create › Storyboards): board/beat/panel CRUD and moves, panel art takes (add, select, remove), the panel maker (board recipe, per-panel node values, node runs, Make empty panels), beats from a plot summary (preview, then add), the saved recipe library, Make storyboard from a music video and Fit to song (write a video's shots from its linked board), a fitted shot's Update from its edited panel and Use as panel art, and Start a Video draft from a board; every board write returns the whole board. |
| `apiTribe.js` | Tribe people (relationship rings + contacts), plus `getTribeDuplicateIdentifiers()` (`GET /tribe/duplicate-identifiers`): a non-blocking report of emails/phones shared by more than one person. |
| `apiTimeline.js` | Human-activity timeline: `/timeline/day`. |
| `apiCalendar.js` | Calendar events. |
diff --git a/client/src/services/apiStoryboards.js b/client/src/services/apiStoryboards.js
index dd7b18b380..965e99a325 100644
--- a/client/src/services/apiStoryboards.js
+++ b/client/src/services/apiStoryboards.js
@@ -90,3 +90,8 @@ export const updateShotFromStoryboardPanel = (projectId, sceneId, options) =>
request(`/storyboards/music-video/${enc(projectId)}/shots/${enc(sceneId)}/update-from-panel`, { method: 'POST', ...options });
export const sendShotStillToStoryboardPanel = (projectId, sceneId, options) =>
request(`/storyboards/music-video/${enc(projectId)}/shots/${enc(sceneId)}/panel-art`, { method: 'POST', ...options });
+
+// A Video (Creative Director) draft from a board: the draft drawer's choices, its shots the
+// panels as previewed (lib/storyboardVideo.js) → { project }. 409 when the board changed since.
+export const startVideoFromStoryboard = (id, input, options) =>
+ request(`/storyboards/${enc(id)}/video`, { ...json('POST', input), ...options });
diff --git a/docs/API.md b/docs/API.md
index d0f99844b0..42cb7ae262 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -808,7 +808,7 @@ Every mounted API prefix (see `server/index.js` for the authoritative list). Dom
| `/api/music-video` | Music video projects; [one-prompt autonomous runs](./features/music-video-autonomous.md) at `/api/music-video/autonomous` |
| `/api/music-video/character-styles` | Built-in character styles a project loads via `concept.characterStyleId`: list with each style's sheet prompt and this install's sheet (`GET /`), full style (`GET /:id`), set or clear the install's character sheet (`PUT /:id/reference` `{ imageId }`) |
| `/api/mood-boards` | Mood boards; `POST /:id/generate` writes 1–4 prompts with the chosen LLM and queues new image items using saved imagegen settings (1024×576 default). Body: `requestId` (UUID), `providerId`, optional `model`, `effort`, `direction`, `count`, `render` (`mode`, `model`, `width`, `height`), `retry`. `GET /:id/generate` restores transient status; `mood-board:generate` pushes progress. Retry reuses the original batch and only queues unfinished slots. Prompt writing uses stored text, not pixels; saved prompts and references survive navigation and server restart, while transient batch status and recent request receipts reset on restart. |
-| `/api/storyboards` | Storyboards (Create › Storyboards): `GET`/`POST /`, `GET`/`PATCH`/`DELETE /:id`; beats at `/:id/beats` (`POST`, `PATCH`/`DELETE /:beatId`, `POST /:beatId/move`); panels at `/:id/beats/:beatId/panels` (`POST`) and `/:id/panels/:panelId` (`PATCH`, `DELETE`, `POST /move` with `{ beatId?, index }`); panel art takes at `/:id/panels/:panelId/takes` (`POST` `{ source, image \| sketchKey }`, `POST /:takeId/select`, `DELETE /:takeId`); the panel maker at `PUT /:id/recipe` (`{ recipe \| null }`, null = default), `GET /:id/panels/:panelId/make` (linked catalog reference images), `PATCH /:id/panels/:panelId/make/:nodeId` (`{ text?, excludedRefs?, extraRefs? }`) and `POST /:id/panels/:panelId/make/:nodeId/run` (an LLM node answers when done; an image node once its frames are queued, with `storyboard:make` socket events after). Beats from a plot summary: `POST /:id/beats/extract` (`{ plot, providerId?, model?, effort? }` → `{ board, beats, sentPrompt, promptAdditions }`: the plot and pick are saved, the beats are a preview) and `POST /:id/beats/add` (`{ beats }`, appended). Make empty panels: `GET /:id/make-empty` (`{ batch, panelCount, steps }`: the panels with no art and each node it runs with its model) and `POST /:id/make-empty` (202, one batch per board, `storyboard:make-batch` progress). The saved recipe library: `GET`/`POST /recipes` (`{ name, recipe }`) and `DELETE /recipes/:recipeId`. The animatic's temp track is `PATCH /:id` `{ tempTrack: { filename, name?, sections?, lines? } \| null }`, naming an audio file already in `/api/uploads`, with its song marks (`sections` `{ id?, label, at }`, lyric `lines` `{ id?, text, at \| null }`); a beat starts at one with `PATCH …/beats/:beatId` `{ pin }`. Make storyboard from a music video: `POST /from-music-video/:projectId` (201 `{ board, project }`: one beat per song section, one panel per shot, and the project's `storyboardId` set; 409 while it links a live board). Fit to song: `POST /fit-music-video/:projectId` (`{ boardUpdatedAt, starts? }`, `starts` = beat id → picked start seconds → `{ project, shots, replaced }`: the linked board's panels written as the video's shots, each with `panelId`/`panelRev` and the panel's art as `panelArt`, a frame reference that keeps one slot; 409 when the board changed since `boardUpdatedAt`, the song is not analyzed, or a shot is locked). A fitted shot and its panel: `POST /music-video/:projectId/shots/:sceneId/update-from-panel` (`{ scene }`: the edited panel's action becomes the shot's intent, its art the shot's `panelArt` frame reference, and its `panelRev` is refreshed) and `POST /music-video/:projectId/shots/:sceneId/panel-art` (`{ board, scene }`: the shot's still becomes the panel's selected take and the shot's `panelArt`); both 409 `PANEL_MISSING` when the panel is gone. Every write returns the whole board; over-limit text is refused. Beat extraction, a node run and `POST /:id/make-empty` are host control (they run a caller-chosen provider or queue renders); the rest store records. |
+| `/api/storyboards` | Storyboards (Create › Storyboards): `GET`/`POST /`, `GET`/`PATCH`/`DELETE /:id`; beats at `/:id/beats` (`POST`, `PATCH`/`DELETE /:beatId`, `POST /:beatId/move`); panels at `/:id/beats/:beatId/panels` (`POST`) and `/:id/panels/:panelId` (`PATCH`, `DELETE`, `POST /move` with `{ beatId?, index }`); panel art takes at `/:id/panels/:panelId/takes` (`POST` `{ source, image \| sketchKey }`, `POST /:takeId/select`, `DELETE /:takeId`); the panel maker at `PUT /:id/recipe` (`{ recipe \| null }`, null = default), `GET /:id/panels/:panelId/make` (linked catalog reference images), `PATCH /:id/panels/:panelId/make/:nodeId` (`{ text?, excludedRefs?, extraRefs? }`) and `POST /:id/panels/:panelId/make/:nodeId/run` (an LLM node answers when done; an image node once its frames are queued, with `storyboard:make` socket events after). Beats from a plot summary: `POST /:id/beats/extract` (`{ plot, providerId?, model?, effort? }` → `{ board, beats, sentPrompt, promptAdditions }`: the plot and pick are saved, the beats are a preview) and `POST /:id/beats/add` (`{ beats }`, appended). Make empty panels: `GET /:id/make-empty` (`{ batch, panelCount, steps }`: the panels with no art and each node it runs with its model) and `POST /:id/make-empty` (202, one batch per board, `storyboard:make-batch` progress). The saved recipe library: `GET`/`POST /recipes` (`{ name, recipe }`) and `DELETE /recipes/:recipeId`. The animatic's temp track is `PATCH /:id` `{ tempTrack: { filename, name?, sections?, lines? } \| null }`, naming an audio file already in `/api/uploads`, with its song marks (`sections` `{ id?, label, at }`, lyric `lines` `{ id?, text, at \| null }`); a beat starts at one with `PATCH …/beats/:beatId` `{ pin }`. Make storyboard from a music video: `POST /from-music-video/:projectId` (201 `{ board, project }`: one beat per song section, one panel per shot, and the project's `storyboardId` set; 409 while it links a live board). Fit to song: `POST /fit-music-video/:projectId` (`{ boardUpdatedAt, starts? }`, `starts` = beat id → picked start seconds → `{ project, shots, replaced }`: the linked board's panels written as the video's shots, each with `panelId`/`panelRev` and the panel's art as `panelArt`, a frame reference that keeps one slot; 409 when the board changed since `boardUpdatedAt`, the song is not analyzed, or a shot is locked). A fitted shot and its panel: `POST /music-video/:projectId/shots/:sceneId/update-from-panel` (`{ scene }`: the edited panel's action becomes the shot's intent, its art the shot's `panelArt` frame reference, and its `panelRev` is refreshed) and `POST /music-video/:projectId/shots/:sceneId/panel-art` (`{ board, scene }`: the shot's still becomes the panel's selected take and the shot's `panelArt`); both 409 `PANEL_MISSING` when the panel is gone. Start a Video from a board: `POST /:id/video` (`{ boardUpdatedAt, project }`, `project` = the Video draft choices of `POST /api/creative-director` → 201 `{ project }`: a Video draft with `storyboardId` whose treatment is one shot per panel, each with the panel's action as intent and prompt, its seconds rounded and capped at 10, and its catalog cast; the length is the shots' total; 409 when the board changed, 400 `STORYBOARD_VIDEO_UNFIT` under 5 s, over 600 s or over 120 shots; no provider call). Every write returns the whole board; over-limit text is refused. Beat extraction, a node run and `POST /:id/make-empty` are host control (they run a caller-chosen provider or queue renders); the rest store records. |
| `/api/decks` | Decks (playing-card / tarot designer) |
| `/api/writers-room` | Writers Room |
| `/api/universe-builder` | Universe Builder |
diff --git a/server/hostControlCoverage.test.js b/server/hostControlCoverage.test.js
index 6a3de5d422..3db75cb74d 100644
--- a/server/hostControlCoverage.test.js
+++ b/server/hostControlCoverage.test.js
@@ -1164,6 +1164,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['DELETE /api/storyboards/:id/panels/:panelId/takes/:takeId', REMOVES_RECORD],
['POST /api/storyboards/:id/panels/:panelId/takes/:takeId/select', RECORDS],
['PUT /api/storyboards/:id/recipe', RECORDS],
+ ['POST /api/storyboards/:id/video', RECORDS],
['POST /api/storyboards/fit-music-video/:projectId', RECORDS],
['POST /api/storyboards/from-music-video/:projectId', RECORDS],
['POST /api/storyboards/music-video/:projectId/shots/:sceneId/panel-art', RECORDS],
diff --git a/server/lib/README.md b/server/lib/README.md
index 8fa76b0d37..14eb09e8b0 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -201,6 +201,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `storyboardSongBrief.js` | A storyboard's beats as a song map: `storyboardSongSections` (role, target length, energy, mood, lyric theme per beat), `storyboardSongBriefText` (the paste-ready brief), `storyboardTimeline` (the animatic's timing: panel holds, beats pinned to temp-track marks, the runs before them fitted) / `STORYBOARD_DEFAULT_HOLD_SEC`. No model call. Browser-safe. |
| `storyboardRecipe.js` | Storyboard panel maker recipes: node types and ports (`RECIPE_NODE_PORTS`: text, system, llm, references, image, panel), `defaultPanelRecipe` (Text → Prompt writer + System prompt → Image + References → Panel), `sanitizeRecipe` (edges join matching ports, no cycles), `recipeRunOrder`, `nodeInputValue` / `nodeOutputValue` (what flows into a node for one panel), `sanitizePanelMake` (per-panel run state), `STORYBOARD_RENDER_SIZES`. Browser-safe. |
| `storyboardRecord.js` | Shared Storyboard record (Create › Storyboards): `sanitizeStoryboard` (beats → panels → art takes, catalog refs by id), `sanitizeTake`, `summarizeStoryboard` (with runtime), `sanitizeSavedRecipe` (a saved recipe library entry). |
+| `storyboardVideo.js` | Start a Video from a storyboard: `storyboardVideoPlan` turns a board's panels into Video (Creative Director) treatment shots (intent, prompt from action/framing/camera, whole seconds capped at 10, catalog ids) with the treatment text and a `problem` when the board can't make a Video; `STORYBOARD_VIDEO_LIMITS`. Shared by the drawer preview and the write. Browser-safe. |
| `storyboardVocabulary.js` | Storyboard ids (`isValidStoryboardId`, `newStoryboardId`, `isValidStoryboardRecipeId`), vocab (`STORYBOARD_MUSICAL_ROLES`, aspect ratios, art styles, framings, take sources) and `STORYBOARD_LIMITS`. Browser-safe: the client editor imports it. |
| `storyArc.js` | Canonical Arc + Season + Reader-Map shapes, plus sanitizeSeriesDesign/renderSeriesDesign for author-owned series intent. |
| `storyArcLimits.js` | Pure canonical length/count caps and series-design field/mode contract shared by sanitizers, schemas and browser editors. |
diff --git a/server/lib/index.js b/server/lib/index.js
index 8129f94c71..5162b20205 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -151,6 +151,7 @@ export * from './storyboardFit.js';
export * from './storyboardRecipe.js';
export * from './storyboardRecord.js';
export * from './storyboardSongBrief.js';
+export * from './storyboardVideo.js';
export * from './storyboardVocabulary.js';
export * from './seasonStructure.js';
export * from './seriesAutopilotDefaults.js';
diff --git a/server/lib/storyboardValidation.js b/server/lib/storyboardValidation.js
index 27f654ef5f..931889b89f 100644
--- a/server/lib/storyboardValidation.js
+++ b/server/lib/storyboardValidation.js
@@ -12,6 +12,7 @@ import {
import { RECIPE_LIMITS as R, RECIPE_NODE_TYPES, RECIPE_PORT_LABELS } from './storyboardRecipe.js';
import { BEAT_EXTRACT_LIMITS } from './storyboardBeatExtract.js';
import { isStoryboardTempTrackFilename } from './storyboardRecord.js';
+import { creativeDirectorProjectCreateSchema } from './creativeDirectorValidation.js';
const text = (max) => z.string().max(max);
const ref = z.string().trim().min(1).max(L.refId);
@@ -140,6 +141,13 @@ export const storyboardBeatsAddSchema = z.object({
beats: z.array(z.object({ ...beatFields, panels: z.array(addedPanel).max(L.panelsPerBeat) }).strict()).min(1).max(L.beats),
}).strict();
+// Start a Video from a storyboard: the Video draft drawer's choices plus the
+// board revision the shot preview was drawn from. The draft is always a Video.
+export const storyboardVideoStartSchema = z.object({
+ boardUpdatedAt: z.string().min(1).max(64),
+ project: z.preprocess((value) => (value && typeof value === 'object' ? { ...value, workspace: 'video' } : value), creativeDirectorProjectCreateSchema),
+}).strict();
+
// Fit to song: the board revision the preview was built from, and the beat starts the user picked.
export const storyboardFitSchema = z.object({
boardUpdatedAt: z.string().min(1).max(64),
diff --git a/server/lib/storyboardVideo.js b/server/lib/storyboardVideo.js
new file mode 100644
index 0000000000..608653d38e
--- /dev/null
+++ b/server/lib/storyboardVideo.js
@@ -0,0 +1,90 @@
+/**
+ * Start a Video from a storyboard — the board's panels as Video (Creative
+ * Director) shots: one shot per panel in board order, its intent and prompt
+ * from the panel's own words, its length from the panel's seconds (or the
+ * default hold) in whole seconds up to the Video shot maximum. A beat with no
+ * panels still gives one shot from its words, so no beat is dropped. Shared by
+ * the drawer's preview (in the browser) and the write (on the server), so the
+ * shots written are the ones shown. No model call.
+ *
+ * Browser-safe: no node-only imports.
+ */
+
+import { STORYBOARD_DEFAULT_HOLD_SEC } from './storyboardSongBrief.js';
+import { STORYBOARD_MUSICAL_ROLE_LABELS } from './storyboardVocabulary.js';
+
+// Bounds of the Video treatment schema (creativeDirectorValidation.js).
+export const STORYBOARD_VIDEO_LIMITS = Object.freeze({
+ shotMaxSec: 10, totalMinSec: 5, totalMaxSec: 600, shots: 120, cast: 50,
+});
+const TEXT = { intent: 1000, logline: 500, synopsis: 5000, script: 50000 };
+
+const FRAMING_WORDS = Object.freeze({
+ 'extreme-wide': 'Extreme wide shot', wide: 'Wide shot', medium: 'Medium shot', close: 'Close-up',
+ 'extreme-close': 'Extreme close-up', 'over-the-shoulder': 'Over-the-shoulder shot', 'two-shot': 'Two-shot', pov: 'POV shot',
+});
+
+const clip = (text, max) => String(text || '').trim().slice(0, max);
+const sentence = (text) => (/[.!?…]["')\]]?$/.test(text) ? text : `${text}.`);
+const beatTitle = (beat, index) => clip(beat.title || STORYBOARD_MUSICAL_ROLE_LABELS[beat.musicalRole] || `Beat ${index + 1}`, 120);
+
+/** A panel's Video prompt: its action, framing and camera move, as written on the panel. */
+function storyboardVideoPrompt(panel, fallback) {
+ const action = clip(panel?.action, 4000) || clip(fallback, 4000);
+ return [action, FRAMING_WORDS[panel?.framing], panel?.camera ? `Camera: ${clip(panel.camera, 400)}` : null]
+ .filter(Boolean).map(sentence).join(' ');
+}
+
+/**
+ * The Video plan for a board: `shots` (treatment scenes, each with the
+ * `beatId`/`panelId` it came from, `trimmed` when the panel ran past the shot
+ * maximum, and the catalog ids it shows), `totalSeconds`, the catalog ids
+ * across the board (`catalogIds`, capped), the treatment text, and `problem`
+ * when the board can't make a Video yet (null when it can).
+ */
+export function storyboardVideoPlan(board) {
+ const L = STORYBOARD_VIDEO_LIMITS;
+ const beats = board?.beats || [];
+ const shots = [];
+ const script = [];
+ beats.forEach((beat, b) => {
+ const title = beatTitle(beat, b);
+ script.push(`${b + 1}. ${title}${beat.what ? ` — ${clip(beat.what, 2000)}` : ''}`);
+ const words = clip(beat.what, 2000) || title;
+ (beat.panels.length ? beat.panels : [null]).forEach((panel, p) => {
+ const hold = panel?.seconds > 0 ? panel.seconds : STORYBOARD_DEFAULT_HOLD_SEC;
+ const prompt = storyboardVideoPrompt(panel, words);
+ shots.push({
+ sceneId: `scene-${shots.length + 1}`,
+ order: shots.length,
+ beatId: beat.id,
+ panelId: panel?.id || null,
+ label: beat.panels.length > 1 ? `${title} · ${p + 1}/${beat.panels.length}` : title,
+ intent: clip(panel?.action, TEXT.intent) || clip(words, TEXT.intent),
+ prompt,
+ durationSeconds: Math.min(L.shotMaxSec, Math.max(1, Math.round(hold))),
+ trimmed: hold > L.shotMaxSec + 0.5,
+ catalogIds: panel ? [...new Set([...(panel.castIds || []), ...(panel.environmentIds || []), ...(panel.objectIds || [])])] : [],
+ });
+ if (panel) script.push(` ${b + 1}.${p + 1} ${prompt}${panel.dialogue ? ` "${clip(panel.dialogue, 2000)}"` : ''}`);
+ });
+ });
+ const totalSeconds = shots.reduce((sum, shot) => sum + shot.durationSeconds, 0);
+ const catalogIds = [...new Set(shots.flatMap((shot) => shot.catalogIds))].slice(0, L.cast);
+ let problem = null;
+ if (!beats.length) problem = 'Add beats and panels first; each panel becomes a shot.';
+ else if (shots.length > L.shots) problem = `The board makes ${shots.length} shots; a video holds at most ${L.shots}.`;
+ else if (totalSeconds < L.totalMinSec) problem = `The shots run ${totalSeconds} s; a video needs at least ${L.totalMinSec} s. Give the panels more seconds.`;
+ else if (totalSeconds > L.totalMaxSec) problem = `The shots run ${totalSeconds} s; a video runs at most ${L.totalMaxSec} s.`;
+ const name = clip(board?.name, 200) || 'Untitled storyboard';
+ return {
+ shots,
+ totalSeconds,
+ catalogIds,
+ problem,
+ logline: clip(board?.logline, TEXT.logline) || name,
+ synopsis: clip(board?.plot, TEXT.synopsis)
+ || clip(beats.map((beat, b) => sentence(clip(beat.what, 2000) || beatTitle(beat, b))).join(' '), TEXT.synopsis) || name,
+ script: clip(script.join('\n'), TEXT.script) || name,
+ };
+}
diff --git a/server/routes/hostControlStoryboards.test.js b/server/routes/hostControlStoryboards.test.js
index d43a428466..f3b1ee8ae0 100644
--- a/server/routes/hostControlStoryboards.test.js
+++ b/server/routes/hostControlStoryboards.test.js
@@ -122,6 +122,7 @@ describe('Storyboards agent runs require operator authority (#12952)', () => {
'POST /api/storyboards/:id/panels/:panelId/move',
'POST /api/storyboards/:id/panels/:panelId/takes',
'POST /api/storyboards/:id/panels/:panelId/takes/:takeId/select',
+ 'POST /api/storyboards/:id/video',
'POST /api/storyboards/fit-music-video/:projectId',
'POST /api/storyboards/from-music-video/:projectId',
'POST /api/storyboards/music-video/:projectId/shots/:sceneId/panel-art',
diff --git a/server/routes/storyboards.js b/server/routes/storyboards.js
index 759809d7af..57e67b42dc 100644
--- a/server/routes/storyboards.js
+++ b/server/routes/storyboards.js
@@ -10,7 +10,7 @@ import { validateRequest } from '../lib/validation.js';
import {
storyboardBeatCreateSchema, storyboardBeatUpdateSchema, storyboardCreateSchema, storyboardMoveSchema,
storyboardPanelCreateSchema, storyboardPanelMoveSchema, storyboardPanelNodeUpdateSchema, storyboardPanelUpdateSchema,
- storyboardBeatsAddSchema, storyboardFitSchema, storyboardPlotExtractSchema, storyboardRecipeSchema, storyboardSavedRecipeSchema, storyboardTakeCreateSchema, storyboardUpdateSchema,
+ storyboardBeatsAddSchema, storyboardFitSchema, storyboardVideoStartSchema, storyboardPlotExtractSchema, storyboardRecipeSchema, storyboardSavedRecipeSchema, storyboardTakeCreateSchema, storyboardUpdateSchema,
} from '../lib/storyboardValidation.js';
import {
addBeat, addPanel, addPanelTake, createStoryboard, deleteBeat, deletePanel, deleteStoryboard, getStoryboard,
@@ -22,6 +22,7 @@ import {
} from '../services/storyboards/make.js';
import { fitMusicVideoToStoryboard, updateShotFromPanel, sendShotStillToPanel } from '../services/storyboards/fitMusicVideo.js';
import { makeStoryboardFromMusicVideo } from '../services/storyboards/fromMusicVideo.js';
+import { startVideoFromStoryboard } from '../services/storyboards/toVideo.js';
import { addBeats, extractBeats } from '../services/storyboards/plot.js';
import { deleteSavedRecipe, listSavedRecipes, saveRecipe } from '../services/storyboards/recipeLibrary.js';
@@ -78,6 +79,10 @@ router.delete('/:id', asyncHandler(async (req, res) => {
res.json(await deleteStoryboard(req.params.id));
}));
+router.post('/:id/video', asyncHandler(async (req, res) => {
+ res.status(201).json(await startVideoFromStoryboard(req.params.id, validateRequest(storyboardVideoStartSchema, req.body ?? {})));
+}));
+
router.post('/:id/beats', asyncHandler(async (req, res) => {
const { index, ...fields } = validateRequest(storyboardBeatCreateSchema, req.body ?? {});
res.status(201).json(await addBeat(req.params.id, fields, { index }));
diff --git a/server/services/creativeDirector/projectsLogic.js b/server/services/creativeDirector/projectsLogic.js
index fb2b619640..53d8320934 100644
--- a/server/services/creativeDirector/projectsLogic.js
+++ b/server/services/creativeDirector/projectsLogic.js
@@ -205,7 +205,7 @@ export function buildProjectRecord(input, { id, now, collectionId }) {
styleSpec = '', startingImageFile = null, userStory = null,
disableAudio = true, autoAcceptScenes = false, sourceIssueId = null, commissionId = null,
cast = [], generateFirstPass = false, directive = null,
- modelOverrides = {}, renderBackend = null, styleReferenceImages = null,
+ modelOverrides = {}, renderBackend = null, styleReferenceImages = null, storyboardId = null,
} = input;
const referenceImages = normalizeStyleReferenceImages(styleReferenceImages);
const videoDraft = input.workspace === 'video'
@@ -281,6 +281,10 @@ export function buildProjectRecord(input, { id, now, collectionId }) {
// project's record is unchanged. Additive JSONB — no schema-version bump; a
// peer without the files just resolves fewer of them.
...(referenceImages.length ? { styleReferenceImages: referenceImages } : {}),
+ // The storyboard a Video was started from (services/storyboards/toVideo.js).
+ // SERVER-MANAGED like `commissionId`, and omitted when unset so other
+ // records are unchanged. Additive JSONB — no schema-version bump.
+ ...(storyboardId ? { storyboardId } : {}),
collectionId,
timelineProjectId: null,
finalVideoId: null,
diff --git a/server/services/storyboards/toVideo.js b/server/services/storyboards/toVideo.js
new file mode 100644
index 0000000000..976981218c
--- /dev/null
+++ b/server/services/storyboards/toVideo.js
@@ -0,0 +1,58 @@
+/**
+ * Start a Video from a storyboard: creates a Video (Creative Director) draft
+ * linked to the board (`project.storyboardId`) and writes its treatment from
+ * the panels (lib/storyboardVideo.js, the plan the drawer previews): one shot
+ * per panel with the panel's action as intent and prompt, its seconds up to the
+ * shot maximum, and its catalog cast. The draft's length is the shots' total.
+ * Nothing renders until the user starts production; no model call.
+ */
+
+import { ServerError } from '../../lib/errorHandler.js';
+import { storyboardVideoPlan } from '../../lib/storyboardVideo.js';
+import { getStoryboard } from './index.js';
+
+export async function startVideoFromStoryboard(boardId, { boardUpdatedAt, project: choices }) {
+ const board = await getStoryboard(boardId);
+ if (board.updatedAt !== boardUpdatedAt) {
+ throw new ServerError('The storyboard changed since these shots were shown. Check them again.', { status: 409, code: 'STORYBOARD_CHANGED' });
+ }
+ const plan = storyboardVideoPlan(board);
+ if (plan.problem) throw new ServerError(plan.problem, { status: 400, code: 'STORYBOARD_VIDEO_UNFIT' });
+
+ const [{ createProject, deleteProject, setTreatment }, { resolveIngredientsByIds }, { buildCastFromIngredients }] = await Promise.all([
+ import('../creativeDirector/local.js'), import('../catalogDB.js'), import('../creativeDirector/catalogSeed.js'),
+ ]);
+ // Only ingredients that still exist become sources; a deleted one would block Start.
+ const ingredients = await resolveIngredientsByIds(plan.catalogIds);
+ const castById = new Map(buildCastFromIngredients(ingredients).map((member) => [member.ingredientId, member]));
+ const picked = choices.videoDraft?.sources || [];
+ const catalogIds = [...new Set([...picked.filter((s) => s.kind === 'catalog').map((s) => s.id), ...castById.keys()])].slice(0, 50);
+ const total = plan.totalSeconds;
+ const project = await createProject({
+ ...choices,
+ workspace: 'video',
+ targetDurationSeconds: total,
+ catalogIngredientIds: catalogIds,
+ storyboardId: board.id,
+ videoDraft: {
+ ...choices.videoDraft,
+ durationRange: { min: total, max: total },
+ sources: [...picked.filter((s) => s.kind !== 'catalog'), ...catalogIds.map((id) => ({ kind: 'catalog', id }))].slice(0, 50),
+ },
+ });
+ const scenes = plan.shots.map((shot) => {
+ const cast = shot.catalogIds.map((id) => castById.get(id)).filter(Boolean);
+ return {
+ sceneId: shot.sceneId, order: shot.order, intent: shot.intent, prompt: shot.prompt,
+ durationSeconds: shot.durationSeconds, ...(cast.length ? { cast } : {}),
+ };
+ });
+ const seeded = await setTreatment(project.id, { logline: plan.logline, synopsis: plan.synopsis, script: plan.script, scenes })
+ .catch(async (err) => {
+ // A draft without its shots would hand the treatment to the director; take it back.
+ await deleteProject(project.id).catch((cleanup) => console.error(`❌ Could not remove Video draft ${project.id}: ${cleanup.message}`));
+ throw err;
+ });
+ console.log(`🎬 Video ${project.id} started from storyboard ${board.id}: ${scenes.length} shot(s), ${total}s`);
+ return { project: seeded };
+}
diff --git a/server/services/storyboards/toVideo.test.js b/server/services/storyboards/toVideo.test.js
new file mode 100644
index 0000000000..ff92f306bd
--- /dev/null
+++ b/server/services/storyboards/toVideo.test.js
@@ -0,0 +1,85 @@
+/**
+ * Start a Video from a storyboard through the real router and file-backed
+ * stores: the panels become the draft's shots, linked to the board, and a
+ * board that can't make a Video leaves no draft behind.
+ */
+import { afterAll, describe, expect, it, vi } from 'vitest';
+import express from 'express';
+import { request } from '../../lib/testHelper.js';
+import { errorMiddleware } from '../../lib/errorHandler.js';
+import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../../lib/mockPathsDataRoot.js';
+
+const ROOT = () => lazyTempDataRoot('storyboard-to-video-');
+vi.mock('../../lib/paths.js', async (importOriginal) => makePathsProxy(await importOriginal(), { dataRoot: ROOT }));
+vi.mock('../../lib/fileUtils.js', async (importOriginal) => makePathsProxy(await importOriginal(), { dataRoot: ROOT }));
+vi.mock('../instanceIdentity.js', () => ({ ensureInstanceId: vi.fn(async () => 'example-owner'), getInstanceId: vi.fn(async () => 'example-owner') }));
+vi.mock('../settings.js', () => ({ getSettings: vi.fn(async () => ({})) }));
+vi.mock('../catalogDB.js', async (importOriginal) => ({
+ ...await importOriginal(),
+ // Only `ing-hero` still exists in the catalog.
+ resolveIngredientsByIds: vi.fn(async (ids = []) => ids.filter((id) => id === 'ing-hero')
+ .map((id) => ({ id, name: 'Example Hero', type: 'character', payload: {} }))),
+ linkIngredientsToCreativeDirector: vi.fn(async (_id, ingredients) => ingredients),
+}));
+
+vi.mock('../catalogDB/ingredients.js', async (importOriginal) => ({
+ ...await importOriginal(),
+ getIngredient: vi.fn(async (id) => (id === 'ing-hero' ? { id, name: 'Example Hero', type: 'character', updatedAt: '2026-01-01T00:00:00.000Z' } : null)),
+}));
+
+const { default: storyboardRoutes } = await import('../../routes/storyboards.js');
+const { listProjects } = await import('../creativeDirector/local.js');
+
+const app = express();
+app.use(express.json());
+app.use('/api/storyboards', storyboardRoutes);
+app.use(errorMiddleware);
+afterAll(cleanupTempDataRoots);
+
+const choices = { name: 'Example Video', aspectRatio: '16:9', quality: 'standard', modelId: '', targetDurationSeconds: 5, userStory: 'Example brief' };
+
+async function board(beats, firstPanel = {}) {
+ const created = await request(app).post('/api/storyboards').send({ name: 'Example board', logline: 'A girl comes home.' });
+ const added = await request(app).post(`/api/storyboards/${created.body.id}/beats/add`).send({ beats });
+ const panelId = added.body.beats?.[0]?.panels[0]?.id ?? (await request(app).get(`/api/storyboards/${created.body.id}`)).body.beats[0].panels[0].id;
+ if (Object.keys(firstPanel).length) await request(app).patch(`/api/storyboards/${created.body.id}/panels/${panelId}`).send(firstPanel);
+ return (await request(app).get(`/api/storyboards/${created.body.id}`)).body;
+}
+
+describe('start a Video from a storyboard', () => {
+ it('creates a linked Video draft whose shots are the panels', async () => {
+ const b = await board([
+ { title: 'Arrival', panels: [
+ { action: 'She steps off the bus', framing: 'wide', camera: 'slow push in', seconds: 4.4 },
+ { action: 'The town square', seconds: 14 },
+ ] },
+ { title: 'Home', what: 'She finds the house empty', panels: [] },
+ ], { castIds: ['ing-hero', 'ing-gone'] });
+ const res = await request(app).post(`/api/storyboards/${b.id}/video`).send({ boardUpdatedAt: b.updatedAt, project: choices });
+ expect([res.status, res.body.error]).toEqual([201, undefined]);
+ const { project } = res.body;
+ expect(project).toMatchObject({
+ workspace: 'video', storyboardId: b.id, targetDurationSeconds: 17, status: 'draft',
+ videoDraft: { durationRange: { min: 17, max: 17 }, sources: [{ kind: 'catalog', id: 'ing-hero' }] },
+ });
+ expect(project.cast.map((member) => member.ingredientId)).toEqual(['ing-hero']);
+ expect(project.treatment.logline).toBe('A girl comes home.');
+ expect(project.treatment.scenes.map((s) => [s.intent, s.prompt, s.durationSeconds, (s.cast || []).map((c) => c.name)])).toEqual([
+ ['She steps off the bus', 'She steps off the bus. Wide shot. Camera: slow push in.', 4, ['Example Hero']],
+ ['The town square', 'The town square.', 10, []],
+ ['She finds the house empty', 'She finds the house empty.', 3, []],
+ ]);
+ expect(project.treatment.artifact.shots.at(-1).endSeconds).toBe(17);
+ });
+
+ it('refuses a board edited since the preview, and one too short for a Video, without leaving a draft', async () => {
+ const b = await board([{ title: 'Blink', panels: [{ action: 'A flash', seconds: 2 }] }]);
+ const before = (await listProjects()).length;
+ const stale = await request(app).post(`/api/storyboards/${b.id}/video`).send({ boardUpdatedAt: '2000-01-01T00:00:00.000Z', project: choices });
+ expect([stale.status, stale.body.code]).toEqual([409, 'STORYBOARD_CHANGED']);
+ const short = await request(app).post(`/api/storyboards/${b.id}/video`).send({ boardUpdatedAt: b.updatedAt, project: choices });
+ expect([short.status, short.body.code]).toEqual([400, 'STORYBOARD_VIDEO_UNFIT']);
+ expect(short.body.error).toMatch(/at least 5 s/);
+ expect((await listProjects()).length).toBe(before);
+ });
+});