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

FableLoom: make a storyboard from an episode path and send panel art back as scene art (#13293)

[._.]/c3e1dc1daafb
diff --git a/client/src/components/fableloom/LoomBoard.jsx b/client/src/components/fableloom/LoomBoard.jsx
index 2a0b520d45..5b52b59c47 100644
--- a/client/src/components/fableloom/LoomBoard.jsx
+++ b/client/src/components/fableloom/LoomBoard.jsx
@@ -1,6 +1,8 @@
-import { useMemo } from 'react';
-import { Check, CornerUpLeft, GitBranch, ImageIcon } from 'lucide-react';
+import { useEffect, useMemo, useState } from 'react';
+import { Link, useNavigate } from 'react-router';
+import { Check, CornerUpLeft, GitBranch, ImageIcon, LayoutPanelLeft, Loader2 } from 'lucide-react';
import MediaImage from '../MediaImage';
+import { listStoryboards, makeStoryboardFromFableLoom } from '../../services/api';
import { aspectClass } from '../storyboards/storyboardArt';
import { formatCount, formatTimecode } from '../../utils/formatters';
import { fableLoomBoardPath } from '../../../../server/lib/fableLoomBoard.js';
@@ -16,15 +18,45 @@ const thumb = (image) => `/data/images/${encodeURIComponent(image)}`;
* One path through an episode as storyboard panels, grouped by dramatic scene.
* A fork's other choices sit under its panel; picking one moves the path
* (`via`, in the URL). Tapping a panel opens the scene in the graph.
+ * "Make storyboard from this path" copies the path into Create › Storyboards,
+ * where recipes make panel art that "Use as scene art" sends back here.
*/
-export default function LoomBoard({ episode, aspectRatio, via, onPick, onOpenNode }) {
+export default function LoomBoard({ loomId, episode, aspectRatio, via, onPick, onOpenNode }) {
+ const navigate = useNavigate();
const path = useMemo(() => fableLoomBoardPath(episode, via), [episode, via]);
+ const [boards, setBoards] = useState([]);
+ const [making, setMaking] = useState(false);
+ useEffect(() => {
+ let active = true;
+ listStoryboards({ silent: true })
+ .then((rows) => { if (active) setBoards((rows || []).filter((b) => b.source?.loomId === loomId && b.source?.episodeId === episode.id)); })
+ .catch(() => {});
+ return () => { active = false; };
+ }, [loomId, episode.id]);
+ const makeBoard = async () => {
+ setMaking(true);
+ const board = await makeStoryboardFromFableLoom(loomId, episode.id, via).catch(() => null);
+ setMaking(false);
+ if (board?.id) navigate(`/storyboards/${encodeURIComponent(board.id)}`);
+ };
const scenes = path.beats.reduce((sum, beat) => sum + beat.panels.length, 0);
const titleOf = (id) => episode.nodes.find((node) => node.id === id)?.title || 'an earlier scene';
if (path.end === 'empty') return <p className="p-6 text-sm text-port-text-muted">This episode has no start scene yet.</p>;
return (
<div className="min-h-0 flex-1 overflow-y-auto p-2 sm:p-4 space-y-4" aria-label="Episode board">
+ <div className="flex flex-wrap items-center gap-2">
+ <button type="button" onClick={makeBoard} disabled={making}
+ className="min-h-[44px] inline-flex items-center gap-1.5 rounded border border-port-border px-3 text-sm text-port-text hover:border-port-accent/60 disabled:opacity-50">
+ {making ? <Loader2 size={16} className="animate-spin" aria-hidden="true" /> : <LayoutPanelLeft size={16} aria-hidden="true" />} Make storyboard from this path
+ </button>
+ {boards.map((board) => (
+ <Link key={board.id} to={`/storyboards/${encodeURIComponent(board.id)}`}
+ className="min-h-[44px] inline-flex items-center rounded px-2 text-sm text-port-accent hover:underline">
+ {board.name}
+ </Link>
+ ))}
+ </div>
<p className="text-xs text-port-text-muted">
{formatCount(scenes)} scene{scenes === 1 ? '' : 's'} on this path
{path.totalSeconds > 0 && <>, <span className="tabular-nums">{formatTimecode(path.totalSeconds)}</span></>}. {END_LABELS[path.end]}
diff --git a/client/src/components/storyboards/PanelDrawer.jsx b/client/src/components/storyboards/PanelDrawer.jsx
index 853bda6a35..e3bebddbd8 100644
--- a/client/src/components/storyboards/PanelDrawer.jsx
+++ b/client/src/components/storyboards/PanelDrawer.jsx
@@ -1,7 +1,7 @@
import { useEffect, useMemo, useState } from 'react';
import { useSearchParams } from 'react-router';
import {
- ChevronLeft, ChevronRight, Clapperboard, Drama, ImagePlus, Loader2, Mountain, Package, Palette, PenLine, Plus,
+ ChevronLeft, ChevronRight, Clapperboard, Drama, ImagePlus, ImageUp, Loader2, Mountain, Package, Palette, PenLine, Plus,
StickyNote, Trash2, Users, Wand2, X,
} from 'lucide-react';
import Drawer from '../Drawer';
@@ -35,8 +35,9 @@ const actionButton = 'min-h-[44px] inline-flex items-center justify-center gap-1
const iconButton = 'min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded text-gray-400 hover:text-white hover:bg-port-border/50 disabled:opacity-30 disabled:pointer-events-none';
const labelClass = 'block text-[11px] text-gray-500 mb-0.5';
-function ArtSection({ panel, aspectRatio, sketchNonce, moodBoardId, busy, onAddTake, onSelectTake, onRemoveTake, onSketch }) {
+function ArtSection({ panel, aspectRatio, sketchNonce, moodBoardId, busy, onAddTake, onSelectTake, onRemoveTake, onSketch, onSendToScene }) {
const [galleryOpen, setGalleryOpen] = useState(false);
+ const [sending, setSending] = useState(false);
const [pinsOpen, setPinsOpen] = useState(false);
const [confirmRemove, setConfirmRemove] = useState(false);
const take = selectedTake(panel);
@@ -85,6 +86,12 @@ function ArtSection({ panel, aspectRatio, sketchNonce, moodBoardId, busy, onAddT
<Palette size={16} aria-hidden="true" /> Mood board
</button>
) : null}
+ {onSendToScene && take?.image ? (
+ <button type="button" className={actionButton} disabled={sending}
+ onClick={async () => { setSending(true); await onSendToScene(); setSending(false); }}>
+ {sending ? <Loader2 size={16} className="animate-spin" aria-hidden="true" /> : <ImageUp size={16} aria-hidden="true" />} Use as scene art
+ </button>
+ ) : null}
{take ? (
<button type="button" className={`${actionButton} ml-auto hover:text-port-error`} onClick={() => setConfirmRemove(true)}>
<Trash2 size={16} aria-hidden="true" /> Take
@@ -136,6 +143,7 @@ function ShotTab({ board, found, panelNumber, sketchNonce, busy, handlers }) {
onSelectTake={handlers.onSelectTake}
onRemoveTake={handlers.onRemoveTake}
onSketch={handlers.onSketch}
+ onSendToScene={board.source?.kind === 'fableloom' && panel.sourceSceneId ? handlers.onSendToScene : null}
/>
<div>
<label htmlFor={fieldId('action')} className={labelClass}>Action</label>
diff --git a/client/src/pages/FableLoomStory.jsx b/client/src/pages/FableLoomStory.jsx
index 3ce68c6462..49ab686bf0 100644
--- a/client/src/pages/FableLoomStory.jsx
+++ b/client/src/pages/FableLoomStory.jsx
@@ -631,6 +631,7 @@ export default function FableLoomStory({ view = 'graph' }) {
</div>
) : boardOpen ? (
<LoomBoard
+ loomId={loomId}
episode={episode}
aspectRatio={asFableLoomRenderSettings(loom.renderSettings).aspectRatio}
via={via}
diff --git a/client/src/pages/FableLoomStory.test.jsx b/client/src/pages/FableLoomStory.test.jsx
index c68bfe5ec6..46c75a698c 100644
--- a/client/src/pages/FableLoomStory.test.jsx
+++ b/client/src/pages/FableLoomStory.test.jsx
@@ -8,6 +8,8 @@ const toastMocks = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn(), warning
vi.mock('../components/ui/Toast', () => ({ default: toastMocks }));
vi.mock('../services/api', () => ({
+ listStoryboards: vi.fn(async () => []),
+ makeStoryboardFromFableLoom: vi.fn(),
addLoomEpisode: vi.fn(),
addLoomNode: vi.fn(),
deleteLoomEpisode: vi.fn(),
@@ -254,6 +256,10 @@ describe('FableLoomStory episode outline route', () => {
describe('FableLoomStory episode board route', () => {
it('lays one path out as panels, moves it by a fork pick in the URL, and opens a scene in the graph', async () => {
const user = userEvent.setup();
+ api.listStoryboards.mockResolvedValueOnce([
+ { id: 'sb-made', name: 'Earlier board', source: { kind: 'fableloom', loomId: 'loom-1', episodeId: 'ep-1' } },
+ { id: 'sb-other', name: 'Unrelated board', source: null },
+ ]);
api.getLoom.mockResolvedValue(loom({ episodes: [episode({ nodes: [
{ id: 'node-1', title: 'Threshold', prose: 'You stand before the first door.', transitions: [
{ id: 'tr-left', targetNodeId: 'node-2', intent: 'Go left' },
@@ -277,9 +283,32 @@ describe('FableLoomStory episode board route', () => {
expect(await screen.findByRole('button', { name: 'Open scene 2: Right Hall' })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Open scene 2: Left Hall' })).not.toBeInTheDocument();
+ expect(screen.getByRole('link', { name: 'Earlier board' })).toHaveAttribute('href', '/storyboards/sb-made');
+ expect(screen.queryByRole('link', { name: 'Unrelated board' })).not.toBeInTheDocument();
+
await user.click(screen.getByRole('button', { name: 'Open scene 2: Right Hall' }));
expect(await screen.findByText('Editing scene: Right Hall')).toBeInTheDocument();
});
+
+ it('makes a storyboard from the picked path and opens it', async () => {
+ const user = userEvent.setup();
+ api.getLoom.mockResolvedValue(loom({ episodes: [episode({ nodes: [
+ { id: 'node-1', title: 'Threshold', prose: 'You stand before the first door.', isEnding: true, transitions: [] },
+ ] })] }));
+ api.makeStoryboardFromFableLoom.mockResolvedValueOnce({ id: 'sb-new' });
+ render(
+ <MemoryRouter initialEntries={['/fableloom/loom-1/ep-1/board?via=tr-right']}>
+ <Routes>
+ <Route path="/fableloom/:loomId/:episodeId/board" element={<FableLoomStory view="board" />} />
+ <Route path="/storyboards/:id" element={<p>Storyboard page</p>} />
+ </Routes>
+ </MemoryRouter>,
+ );
+
+ await user.click(await screen.findByRole('button', { name: 'Make storyboard from this path' }));
+ expect(api.makeStoryboardFromFableLoom).toHaveBeenCalledWith('loom-1', 'ep-1', ['tr-right']);
+ expect(await screen.findByText('Storyboard page')).toBeInTheDocument();
+ });
});
describe('FableLoomStory episode expansion safety', () => {
diff --git a/client/src/pages/StoryboardDetail.jsx b/client/src/pages/StoryboardDetail.jsx
index b80f572808..681a000ef3 100644
--- a/client/src/pages/StoryboardDetail.jsx
+++ b/client/src/pages/StoryboardDetail.jsx
@@ -11,14 +11,14 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Link, useNavigate, useParams, useSearchParams } from 'react-router';
-import { ArrowLeft, Clapperboard, LayoutGrid, LayoutPanelLeft, ListMusic, Loader2, Play, Plus, Rows3, ScrollText } from 'lucide-react';
+import { ArrowLeft, BookOpen, 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';
import {
addStoryboardBeat, addStoryboardPanel, addStoryboardPanelTake, createBlankSketch, deleteStoryboardBeat,
deleteStoryboardPanel, getStoryboard, listMoodBoardNames, moveStoryboardBeat, moveStoryboardPanel,
- removeStoryboardPanelTake, runStoryboardPanelNode, selectStoryboardPanelTake, updateStoryboard, updateStoryboardBeat,
+ removeStoryboardPanelTake, runStoryboardPanelNode, selectStoryboardPanelTake, sendStoryboardPanelToFableLoom, updateStoryboard, updateStoryboardBeat,
updateStoryboardPanel, updateStoryboardPanelNode, updateStoryboardRecipe,
} from '../services/api';
import { formatTimecode } from '../utils/formatters';
@@ -168,6 +168,10 @@ export default function StoryboardDetail() {
onSelectTake: (takeId) => write(() => selectStoryboardPanelTake(id, panelId, takeId)),
onRemoveTake: (takeId) => write(() => removeStoryboardPanelTake(id, panelId, takeId)),
onMove: (target) => write(() => moveStoryboardPanel(id, panelId, target)),
+ onSendToScene: async () => {
+ const res = await write(() => sendStoryboardPanelToFableLoom(id, panelId));
+ if (res) toast.success('Scene art updated in FableLoom');
+ },
onRecipe: (recipe) => write(() => updateStoryboardRecipe(id, recipe)),
onNodePatch: (nodeId, patch) => write(() => updateStoryboardPanelNode(id, panelId, nodeId, patch)),
// Resolves true when the node ran (Run all stops at the first failure,
@@ -267,6 +271,11 @@ export default function StoryboardDetail() {
</button>
)}
{board.beats.some((beat) => beat.panels.length) && <MakeEmptyPanels boardId={id} />}
+ {board.source?.kind === 'fableloom' && (
+ <Link to={`/fableloom/${encodeURIComponent(board.source.loomId)}/${encodeURIComponent(board.source.episodeId)}/board`} className={headerButton}>
+ <BookOpen size={16} aria-hidden="true" /> FableLoom episode
+ </Link>
+ )}
</div>
</header>
diff --git a/client/src/pages/StoryboardDetail.test.jsx b/client/src/pages/StoryboardDetail.test.jsx
index 1919068eaa..acec2460f4 100644
--- a/client/src/pages/StoryboardDetail.test.jsx
+++ b/client/src/pages/StoryboardDetail.test.jsx
@@ -23,6 +23,7 @@ const api = vi.hoisted(() => ({
extractStoryboardBeats: vi.fn(),
addStoryboardBeats: vi.fn(),
uploadFile: vi.fn(),
+ sendStoryboardPanelToFableLoom: vi.fn(),
getUploadUrl: (filename) => `/api/uploads/${filename}`,
}));
vi.mock('../services/api', () => {
@@ -130,6 +131,22 @@ describe('StoryboardDetail', () => {
expect(api.addStoryboardPanelTake).toHaveBeenCalledWith('sb-1', 'panel-1', { source: 'sketch', sketchKey: 'sketch:abc-123' });
});
+ it('sends a panel made from a FableLoom scene back as its scene art', async () => {
+ const linked = board({
+ source: { kind: 'fableloom', loomId: 'loom-1', episodeId: 'ep-1' },
+ beats: [{ id: 'beat-1', title: 'Arrival', what: '', why: '', emotion: '', musicalRole: null, sectionHint: '', panels: [
+ panel('panel-1', { sourceSceneId: 'node-1', takes: [{ id: 'take-1', source: 'generated', image: 'harbor.png', sketchKey: null }], selectedTakeId: 'take-1' }),
+ ] }],
+ });
+ api.getStoryboard.mockResolvedValue(linked);
+ api.sendStoryboardPanelToFableLoom.mockResolvedValue({ board: linked, node: { id: 'node-1', image: 'harbor.png' } });
+ renderAt('/storyboards/sb-1/panel/panel-1');
+
+ expect(await screen.findByRole('link', { name: 'FableLoom episode' })).toHaveAttribute('href', '/fableloom/loom-1/ep-1/board');
+ fireEvent.click(screen.getByRole('button', { name: 'Use as scene art' }));
+ await waitFor(() => expect(api.sendStoryboardPanelToFableLoom).toHaveBeenCalledWith('sb-1', 'panel-1'));
+ });
+
it('says so when the linked panel is gone', async () => {
api.getStoryboard.mockResolvedValue(board());
renderAt('/storyboards/sb-1/panel/panel-missing');
diff --git a/client/src/services/README.md b/client/src/services/README.md
index 1b255f1bf7..126c9f869a 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), 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. |
+| `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,, Start a Video draft from a board, and Make storyboard from a FableLoom path with Use as scene art; 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 965e99a325..6ff5d46714 100644
--- a/client/src/services/apiStoryboards.js
+++ b/client/src/services/apiStoryboards.js
@@ -95,3 +95,10 @@ export const sendShotStillToStoryboardPanel = (projectId, sceneId, options) =>
// 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 });
+
+// A new board from one FableLoom episode path (`via`: the transition ids picked at forks) → board.
+// Use as scene art: the panel's selected image becomes its scene's image → { board, node }.
+export const makeStoryboardFromFableLoom = (loomId, episodeId, via, options) =>
+ request(`/storyboards/from-fableloom/${enc(loomId)}/${enc(episodeId)}`, { ...json('POST', { via }), ...options });
+export const sendStoryboardPanelToFableLoom = (id, panelId, options) =>
+ request(`/storyboards/${enc(id)}/panels/${enc(panelId)}/scene-art`, { method: 'POST', ...options });
diff --git a/docs/API.md b/docs/API.md
index 42cb7ae262..47b17eb386 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. 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/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). Make storyboard from a FableLoom path: `POST /from-fableloom/:loomId/:episodeId` (`{ via? }`, the transition ids picked at forks → 201 board: one beat per dramatic scene on the path, one panel per scene with `sourceSceneId`, and the board's `source` naming the episode). Use as scene art: `POST /:id/panels/:panelId/scene-art` (`{ board, node }`: the panel's selected image becomes its scene's image; 400 `NO_IMAGE` for a sketch or no art). 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/docs/features/fableloom.md b/docs/features/fableloom.md
index cc50073f29..d487e9d198 100644
--- a/docs/features/fableloom.md
+++ b/docs/features/fableloom.md
@@ -117,6 +117,11 @@ scene-local clothes cannot silently reappear between episodes.
choices sit under its panel, and picking one moves the path (`?via=` holds
the picked transition ids). The path stops at an ending, a loop back or a
scene with no way on; tapping a panel opens that scene in the graph.
+ **Make storyboard from this path** copies the path into Create ›
+ Storyboards (one beat per dramatic scene, one panel per scene with its image
+ prompt, length, camera move and image), where the panel maker's recipes make
+ new art; a panel's **Use as scene art** sends its selected image back to its
+ scene. Boards made from the episode are linked beside the button.
- **Episode setup → Story beats → teleplay** — the production gate: draft one
concise log-line per eventual camera cut, edit paths and audience-channel
states, run the deterministic validator, and optionally ask the AI story
diff --git a/server/hostControlCoverage.test.js b/server/hostControlCoverage.test.js
index 3db75cb74d..af0f1847ae 100644
--- a/server/hostControlCoverage.test.js
+++ b/server/hostControlCoverage.test.js
@@ -1160,12 +1160,14 @@ const REVIEWED_OPEN_MUTATIONS = [
['PATCH /api/storyboards/:id/panels/:panelId', RECORDS],
['PATCH /api/storyboards/:id/panels/:panelId/make/:nodeId', RECORDS],
['POST /api/storyboards/:id/panels/:panelId/move', RECORDS],
+ ['POST /api/storyboards/:id/panels/:panelId/scene-art', RECORDS],
['POST /api/storyboards/:id/panels/:panelId/takes', RECORDS],
['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-fableloom/:loomId/:episodeId', RECORDS],
['POST /api/storyboards/from-music-video/:projectId', RECORDS],
['POST /api/storyboards/music-video/:projectId/shots/:sceneId/panel-art', RECORDS],
['POST /api/storyboards/music-video/:projectId/shots/:sceneId/update-from-panel', RECORDS],
diff --git a/server/lib/conflictJournal.test.js b/server/lib/conflictJournal.test.js
index c6225d214d..01eec4012c 100644
--- a/server/lib/conflictJournal.test.js
+++ b/server/lib/conflictJournal.test.js
@@ -725,7 +725,7 @@ describe('conflictJournal — RESTORABLE_FIELDS parity with the wire shape', ()
});
const COMMON = ['id', 'createdAt', 'updatedAt', 'deleted', 'deletedAt'];
const STRUCTURAL_FIELDS = {
- storyboard: [...COMMON, 'plotLlm'], // plotLlm: per-user provider pick
+ storyboard: [...COMMON, 'plotLlm', 'source'], // plotLlm: per-user provider pick; source: set when the board is made, never edited
deck: [...COMMON, 'kind', 'cards'], // kind mints the roster; cards restore with the deck row
};
diff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.js
index 3aa49cf60d..86f0666943 100644
--- a/server/lib/schemaVersions.js
+++ b/server/lib/schemaVersions.js
@@ -268,7 +268,9 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({
// peer would strip it the same way.
// v4 = song markers on the temp track (`sections`, `lines`) and a beat's
// `pin` to one of them.
- storyboards: 4,
+ // v5 = board-level `source` (the FableLoom episode it was made from) and a
+ // panel's `sourceSceneId`, which "Use as scene art" sends art back through.
+ storyboards: 5,
// v1 = author personas (PostgreSQL `authors` table) federated via the
// per-record peer-sync push pipeline (record kind `author`, sync category
// `authors`). A brand-NEW synced record type like `storyBuilder` below, so it
diff --git a/server/lib/storyboardRecord.js b/server/lib/storyboardRecord.js
index 792e0f9716..685b3d9630 100644
--- a/server/lib/storyboardRecord.js
+++ b/server/lib/storyboardRecord.js
@@ -47,6 +47,19 @@ export const isStoryboardTempTrackFilename = (value) => typeof value === 'string
const pick = (value, set, fallback = null) => (set.has(value) ? value : fallback);
const isoOr = (value, fallback) => (isNonBlankStr(value) && Number.isFinite(Date.parse(value)) ? value : fallback);
const entityId = (value, prefix) => (typeof value === 'string' && ENTITY_ID_PATTERN.test(value) ? value : newStoryboardEntityId(prefix));
+const refOrNull = (value) => trimTo(value, STORYBOARD_LIMITS.refId) || null;
+
+/**
+ * The production a board was made from, when one keeps scenes of its own that
+ * panels send art back to: a FableLoom episode (`loomId`, `episodeId`). Each
+ * such panel names its scene in `sourceSceneId`.
+ */
+function sanitizeSource(raw) {
+ if (!raw || typeof raw !== 'object' || raw.kind !== 'fableloom') return null;
+ const loomId = refOrNull(raw.loomId);
+ const episodeId = refOrNull(raw.episodeId);
+ return loomId && episodeId ? { kind: 'fableloom', loomId, episodeId } : null;
+}
function refList(value) {
if (!Array.isArray(value)) return [];
@@ -115,6 +128,7 @@ function sanitizePanel(raw) {
takes,
selectedTakeId,
make: sanitizePanelMake(raw.make, takeIds),
+ sourceSceneId: refOrNull(raw.sourceSceneId),
};
}
@@ -176,6 +190,7 @@ export function sanitizeStoryboard(raw) {
plot: trimTo(raw.plot, BEAT_EXTRACT_LIMITS.plot),
plotLlm: sanitizeLlmPick(raw.plotLlm),
tempTrack,
+ source: sanitizeSource(raw.source),
beats,
createdAt,
updatedAt: isoOr(raw.updatedAt, createdAt),
@@ -257,6 +272,7 @@ export function summarizeStoryboard(board) {
panelCount: panels.length,
runtimeSec: storyboardRuntime(board),
cover: cover ? { image: cover.image, sketchKey: cover.sketchKey } : null,
+ source: board.source,
updatedAt: board.updatedAt,
};
}
diff --git a/server/lib/storyboardValidation.js b/server/lib/storyboardValidation.js
index 931889b89f..d02ba14fe4 100644
--- a/server/lib/storyboardValidation.js
+++ b/server/lib/storyboardValidation.js
@@ -154,3 +154,8 @@ export const storyboardFitSchema = z.object({
starts: z.record(entityId, z.number().min(0).max(36000))
.refine((starts) => Object.keys(starts).length <= L.beats, { message: `At most ${L.beats} picked starts` }).optional(),
}).strict();
+
+// Make storyboard from this FableLoom path: the transition ids picked at forks.
+export const storyboardFromFableLoomSchema = z.object({
+ via: z.array(z.string().min(1).max(128)).max(500).default([]),
+}).strict();
diff --git a/server/routes/hostControlStoryboards.test.js b/server/routes/hostControlStoryboards.test.js
index f3b1ee8ae0..7926db143e 100644
--- a/server/routes/hostControlStoryboards.test.js
+++ b/server/routes/hostControlStoryboards.test.js
@@ -120,10 +120,12 @@ describe('Storyboards agent runs require operator authority (#12952)', () => {
'POST /api/storyboards/:id/beats/:beatId/panels',
'POST /api/storyboards/:id/beats/add',
'POST /api/storyboards/:id/panels/:panelId/move',
+ 'POST /api/storyboards/:id/panels/:panelId/scene-art',
'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-fableloom/:loomId/:episodeId',
'POST /api/storyboards/from-music-video/:projectId',
'POST /api/storyboards/music-video/:projectId/shots/:sceneId/panel-art',
'POST /api/storyboards/music-video/:projectId/shots/:sceneId/update-from-panel',
diff --git a/server/routes/storyboards.js b/server/routes/storyboards.js
index 57e67b42dc..c573ee6740 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, storyboardVideoStartSchema, storyboardPlotExtractSchema, storyboardRecipeSchema, storyboardSavedRecipeSchema, storyboardTakeCreateSchema, storyboardUpdateSchema,
+ storyboardBeatsAddSchema, storyboardFitSchema, storyboardFromFableLoomSchema, 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 { makeStoryboardFromFableLoom, sendPanelArtToFableLoom } from '../services/storyboards/fromFableLoom.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';
@@ -41,6 +42,12 @@ router.post('/from-music-video/:projectId', asyncHandler(async (req, res) => {
res.status(201).json(await makeStoryboardFromMusicVideo(req.params.projectId));
}));
+// Make storyboard from this FableLoom path; the panel route sends art back to its scene.
+router.post('/from-fableloom/:loomId/:episodeId', asyncHandler(async (req, res) => {
+ const { via } = validateRequest(storyboardFromFableLoomSchema, req.body ?? {});
+ res.status(201).json(await makeStoryboardFromFableLoom(req.params.loomId, req.params.episodeId, { via }));
+}));
+
// Fit to song: write the video's shots from its linked board, as previewed.
router.post('/fit-music-video/:projectId', asyncHandler(async (req, res) => {
res.json(await fitMusicVideoToStoryboard(req.params.projectId, validateRequest(storyboardFitSchema, req.body || {})));
@@ -118,6 +125,10 @@ router.post('/:id/panels/:panelId/move', asyncHandler(async (req, res) => {
res.json(await movePanel(req.params.id, req.params.panelId, validateRequest(storyboardPanelMoveSchema, req.body ?? {})));
}));
+router.post('/:id/panels/:panelId/scene-art', asyncHandler(async (req, res) => {
+ res.json(await sendPanelArtToFableLoom(req.params.id, req.params.panelId));
+}));
+
router.post('/:id/panels/:panelId/takes', asyncHandler(async (req, res) => {
res.status(201).json(await addPanelTake(req.params.id, req.params.panelId, validateRequest(storyboardTakeCreateSchema, req.body ?? {})));
}));
diff --git a/server/services/storyboards/fromFableLoom.js b/server/services/storyboards/fromFableLoom.js
new file mode 100644
index 0000000000..7fc5d9274c
--- /dev/null
+++ b/server/services/storyboards/fromFableLoom.js
@@ -0,0 +1,76 @@
+/**
+ * FableLoom and storyboards. "Make storyboard from this path" builds a board
+ * from one path through an episode (the FableLoom Board view's path, `via`
+ * picks at its forks): one beat per dramatic scene, one panel per scene with
+ * its image prompt, length, camera move and current art. The board keeps the
+ * episode as its `source` and each panel its scene, so recipe-made panel art
+ * goes back to the scene with "Use as scene art". The loom is not changed
+ * until then. Runs only on the user's tap; no model call.
+ */
+
+import { ServerError } from '../../lib/errorHandler.js';
+import { fableLoomBoardPath } from '../../lib/fableLoomBoard.js';
+import { asFableLoomRenderSettings } from '../../lib/fableLoomProduction.js';
+import { STORYBOARD_ASPECT_RATIOS, STORYBOARD_LIMITS as L } from '../../lib/storyboardVocabulary.js';
+import { trimTo } from '../../lib/textUtils.js';
+import { createStoryboard, getStoryboard } from './index.js';
+
+const notFound = (what) => new ServerError(`${what} not found`, { status: 404, code: 'NOT_FOUND' });
+
+function panelFromNode(node, seconds) {
+ return {
+ action: trimTo(node.imagePrompt || node.prose || node.title, L.panelText),
+ camera: trimTo(node.cameraMovement, L.camera),
+ seconds,
+ notes: trimTo(node.shot?.framing, L.notes),
+ takes: node.image ? [{ source: 'gallery', image: node.image }] : [],
+ sourceSceneId: node.id,
+ };
+}
+
+export async function makeStoryboardFromFableLoom(loomId, episodeId, { via = [] } = {}) {
+ const { getLoom } = await import('../fableLoom/records.js');
+ const loom = await getLoom(loomId);
+ if (!loom) throw notFound('Story');
+ const episode = loom.episodes.find((e) => e.id === episodeId);
+ if (!episode) throw notFound('Episode');
+ const path = fableLoomBoardPath(episode, via);
+ if (!path.beats.length) throw new ServerError('This episode has no start scene yet.', { status: 400, code: 'NO_SCENES' });
+ const aspect = asFableLoomRenderSettings(loom.renderSettings).aspectRatio;
+ const name = [loom.name, episode.title || `Episode ${episode.number}`].filter(Boolean).join(' · ');
+ const board = await createStoryboard({
+ name: trimTo(name, L.name) || 'Untitled storyboard',
+ logline: trimTo(episode.synopsis, L.logline),
+ aspectRatio: STORYBOARD_ASPECT_RATIOS.includes(aspect) ? aspect : '16:9',
+ universeId: loom.universeId || null,
+ }, {
+ beats: path.beats.map((beat) => ({
+ title: trimTo(beat.title, L.beatTitle),
+ panels: beat.panels.map(({ node, seconds }) => panelFromNode(node, seconds)),
+ })),
+ source: { kind: 'fableloom', loomId, episodeId },
+ });
+ console.log(`🎬 Storyboard ${board.id} made from FableLoom ${loomId} episode ${episodeId}`);
+ return board;
+}
+
+/** Use as scene art: the panel's selected image becomes its FableLoom scene's image. */
+export async function sendPanelArtToFableLoom(boardId, panelId) {
+ const board = await getStoryboard(boardId);
+ if (board.source?.kind !== 'fableloom') {
+ throw new ServerError('This storyboard was not made from a FableLoom episode.', { status: 400, code: 'NO_SOURCE' });
+ }
+ const panel = board.beats.flatMap((beat) => beat.panels).find((p) => p.id === panelId);
+ if (!panel) throw notFound('Panel');
+ if (!panel.sourceSceneId) throw new ServerError('This panel has no FableLoom scene.', { status: 400, code: 'NO_SOURCE' });
+ const take = panel.takes.find((t) => t.id === panel.selectedTakeId);
+ if (!take?.image) {
+ throw new ServerError('Pick an image for this panel first; a sketch can\'t be scene art.', { status: 400, code: 'NO_IMAGE' });
+ }
+ const { attachNodeImage } = await import('../fableLoom/records.js');
+ const { loomId, episodeId } = board.source;
+ const node = await attachNodeImage(loomId, episodeId, panel.sourceSceneId, { filename: take.image, jobId: null });
+ if (!node) throw notFound('FableLoom scene');
+ console.log(`🎬 Storyboard ${boardId} panel ${panelId} art sent to FableLoom scene ${node.id}`);
+ return { board, node };
+}
diff --git a/server/services/storyboards/fromFableLoom.test.js b/server/services/storyboards/fromFableLoom.test.js
new file mode 100644
index 0000000000..b02ff1a6e4
--- /dev/null
+++ b/server/services/storyboards/fromFableLoom.test.js
@@ -0,0 +1,72 @@
+/**
+ * Make storyboard from a FableLoom path and Use as scene art, through the real
+ * storyboard router and file-backed stores: the board mirrors the picked path,
+ * and only the tap on a panel changes its scene's image.
+ */
+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-from-loom-');
+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('../settings.js', () => ({ getSettings: vi.fn(async () => ({})) }));
+
+const { default: storyboardRoutes } = await import('../../routes/storyboards.js');
+const looms = await import('../fableLoom/records.js');
+
+const app = express();
+app.use(express.json());
+app.use('/api/storyboards', storyboardRoutes);
+app.use(errorMiddleware);
+afterAll(cleanupTempDataRoots);
+
+const node = (id, extra) => ({ id, title: id.toUpperCase(), prose: '', transitions: [], ...extra });
+
+describe('storyboard from a FableLoom path', () => {
+ it('builds the picked path as panels and sends a panel image back to its scene', async () => {
+ const loom = await looms.createLoom({ name: 'Example Story' });
+ const { episodes: [{ id: episodeId }] } = await looms.addEpisode(loom.id, { title: 'Pilot' });
+ await looms.mutateLoom(loom.id, (draft) => {
+ draft.episodes[0].startNodeId = 'node-a';
+ draft.episodes[0].nodes = [
+ node('node-a', {
+ imagePrompt: 'Wide of the harbor at dawn', image: 'harbor.png', cameraMovement: 'slow push-in',
+ shot: { dramaticSceneId: 'ds-1', dramaticSceneTitle: 'Arrival', durationSeconds: 6, framing: 'Wide, low angle' },
+ transitions: [{ id: 'tr-left', targetNodeId: 'node-b', intent: 'Board the ship' }, { id: 'tr-right', targetNodeId: 'node-c', intent: 'Stay ashore' }],
+ }),
+ node('node-b', { prose: 'The deck heaves.', isEnding: true }),
+ node('node-c', { prose: 'The market wakes.', isEnding: true }),
+ ];
+ return draft;
+ });
+
+ const made = await request(app).post(`/api/storyboards/from-fableloom/${loom.id}/${episodeId}`).send({ via: ['tr-right'] });
+ expect(made.status).toBe(201);
+ const board = made.body;
+ expect(board).toMatchObject({ name: 'Example Story · Pilot', source: { kind: 'fableloom', loomId: loom.id, episodeId } });
+ expect(board.beats.map((beat) => [beat.title, beat.panels.map((p) => p.sourceSceneId)])).toEqual([['Arrival', ['node-a']], ['NODE-C', ['node-c']]]);
+ expect(board.beats[0].panels[0]).toMatchObject({
+ action: 'Wide of the harbor at dawn', camera: 'slow push-in', seconds: 6, notes: 'Wide, low angle',
+ takes: [expect.objectContaining({ source: 'gallery', image: 'harbor.png' })],
+ });
+
+ // A panel with no image refuses; a new selected image goes to the scene.
+ const panelId = board.beats[1].panels[0].id;
+ expect((await request(app).post(`/api/storyboards/${board.id}/panels/${panelId}/scene-art`)).body.code).toBe('NO_IMAGE');
+ expect((await request(app).post(`/api/storyboards/${board.id}/panels/${panelId}/takes`).send({ source: 'generated', image: 'market.png' })).status).toBe(201);
+ const sent = await request(app).post(`/api/storyboards/${board.id}/panels/${panelId}/scene-art`);
+ expect(sent.status).toBe(200);
+ expect(sent.body.node).toMatchObject({ id: 'node-c', image: 'market.png' });
+ const after = await looms.getLoom(loom.id);
+ expect(after.episodes[0].nodes.map((n) => n.image)).toEqual(['harbor.png', null, 'market.png']);
+ });
+
+ it('refuses a missing episode', async () => {
+ const loom = await looms.createLoom({ name: 'Empty Story' });
+ const res = await request(app).post(`/api/storyboards/from-fableloom/${loom.id}/ep-missing`).send({});
+ expect(res.status).toBe(404);
+ });
+});
diff --git a/server/services/storyboards/index.js b/server/services/storyboards/index.js
index 6c4e1f2320..a0371b3769 100644
--- a/server/services/storyboards/index.js
+++ b/server/services/storyboards/index.js
@@ -56,10 +56,13 @@ export async function getStoryboard(id) {
return board;
}
-/** A new board; `beats` seeds it (e.g. built from a music video's shots). */
-export async function createStoryboard(input = {}, { beats = [] } = {}) {
+/**
+ * A new board; `beats` seeds it (e.g. built from a music video's shots) and
+ * `source` names the production it was made from (server-set, never patched).
+ */
+export async function createStoryboard(input = {}, { beats = [], source = null } = {}) {
const now = new Date().toISOString();
- const board = sanitizeStoryboard({ ...pickFields(input, BOARD_FIELDS), id: newStoryboardId(), beats, createdAt: now, updatedAt: now });
+ const board = sanitizeStoryboard({ ...pickFields(input, BOARD_FIELDS), id: newStoryboardId(), beats, source, createdAt: now, updatedAt: now });
await writeRaw(board.id, board);
emitRecordUpdated(STORYBOARD_KIND, board.id);
autoSubscribeRecordToAllPeers(STORYBOARD_KIND, board.id).catch(() => {});
diff --git a/server/services/storyboards/sync.test.js b/server/services/storyboards/sync.test.js
index c7b9765098..f33d4ab2c9 100644
--- a/server/services/storyboards/sync.test.js
+++ b/server/services/storyboards/sync.test.js
@@ -36,7 +36,7 @@ async function boardWithArt() {
describe('storyboard federation', () => {
it('declares its own version-gated sync category', () => {
- expect(PORTOS_SCHEMA_VERSIONS.storyboards).toBe(4);
+ expect(PORTOS_SCHEMA_VERSIONS.storyboards).toBe(5);
});
it('emits a record event on create, edit and delete so subscribed peers get each revision', async () => {