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

Series Pipeline: open an issue's storyboard scenes in the shared editor, and send panel art back as a shot's start frame (#13307)

[._.]/c348e253fe7a
diff --git a/client/src/components/pipeline/stages/StoryboardsStage.jsx b/client/src/components/pipeline/stages/StoryboardsStage.jsx
index 1b80b04bcd..25e8786408 100644
--- a/client/src/components/pipeline/stages/StoryboardsStage.jsx
+++ b/client/src/components/pipeline/stages/StoryboardsStage.jsx
@@ -18,7 +18,7 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { useNavigate } from 'react-router';
-import { Plus, Trash2, Sparkles, Loader2, Wand2, Film, WandSparkles, Shirt, Layers, Pencil } from 'lucide-react';
+import { Plus, Trash2, Sparkles, Loader2, Wand2, Film, WandSparkles, Shirt, Layers, Pencil, LayoutPanelLeft } from 'lucide-react';
import socket from '../../../services/socket';
import toast from '../../ui/Toast';
import InlineConfirmRow from '../../ui/InlineConfirmRow';
@@ -33,6 +33,7 @@ import {
updatePipelineIssue,
extractPipelineStoryboardScenes,
createBlankSketch,
+ openStoryboardForPipelineIssue,
} from '../../../services/api';
import useUniverse from '../../../hooks/useUniverse';
import { matchCharactersInText } from '../../../lib/scenePrompt';
@@ -124,6 +125,16 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
return !!updated;
};
+ // Open in storyboard editor: the issue's linked board in Create › Storyboards
+ // (made from these scenes the first time), where recipes make panel art.
+ const [openingBoard, setOpeningBoard] = useState(false);
+ const openBoard = async () => {
+ setOpeningBoard(true);
+ const res = await openStoryboardForPipelineIssue(issue.id).catch(() => null);
+ setOpeningBoard(false);
+ if (res?.boardId) navigate(`/storyboards/${encodeURIComponent(res.boardId)}`);
+ };
+
const addScene = () => persist([...scenes, { slugline: '', description: '', imageJobId: null }]);
const removeScene = (i) => {
// Removing a scene reindexes everything after it, so any index-keyed
@@ -479,6 +490,16 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
: <Wand2 size={14} />}
From prose
</button>
+ <button
+ type="button"
+ onClick={openBoard}
+ disabled={openingBoard || !scenes.length}
+ title={scenes.length ? 'Open these scenes in the shared storyboard editor' : 'Add or extract scenes first'}
+ className="inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-port-card border border-port-border text-white text-sm hover:border-port-accent/50 disabled:opacity-40 disabled:cursor-not-allowed"
+ >
+ {openingBoard ? <Loader2 size={14} className="animate-spin" /> : <LayoutPanelLeft size={14} />}
+ Open in storyboard editor
+ </button>
<PromptCountInput id="storyboard-prompt-count" value={promptCount} onChange={setPromptCount} />
<button
type="button"
diff --git a/client/src/components/pipeline/stages/StoryboardsStage.test.jsx b/client/src/components/pipeline/stages/StoryboardsStage.test.jsx
new file mode 100644
index 0000000000..c4623bf790
--- /dev/null
+++ b/client/src/components/pipeline/stages/StoryboardsStage.test.jsx
@@ -0,0 +1,40 @@
+import { describe, it, expect, vi } from 'vitest';
+import { fireEvent, render, screen } from '@testing-library/react';
+import { MemoryRouter, Route, Routes } from 'react-router';
+
+const api = vi.hoisted(() => ({ openStoryboardForPipelineIssue: vi.fn() }));
+vi.mock('../../../services/api', () => {
+ const rest = ['generatePipelineVisualImage', 'generatePipelineSceneVideo', 'generatePipelineShotStartFrame',
+ 'refinePipelineSceneImagePrompt', 'generatePipelineSceneImagePrompts', 'updatePipelineIssue',
+ 'extractPipelineStoryboardScenes', 'createBlankSketch'];
+ return { ...api, ...Object.fromEntries(rest.map((name) => [name, vi.fn()])) };
+});
+vi.mock('../../../services/socket', () => ({ default: { on: vi.fn(), off: vi.fn() } }));
+vi.mock('../../../hooks/useUniverse', () => ({ default: () => [null] }));
+vi.mock('../MediaJobThumb', () => ({ default: () => null }));
+vi.mock('../../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));
+
+import StoryboardsStage from './StoryboardsStage';
+
+const issue = {
+ id: 'iss-1',
+ stages: { storyboards: { status: 'edited', scenes: [{ id: 'scene-01', slugline: 'INT. LAB — NIGHT', description: 'The lab hums.', shots: [] }] } },
+};
+
+describe('StoryboardsStage', () => {
+ it('opens the issue in the shared storyboard editor', async () => {
+ api.openStoryboardForPipelineIssue.mockResolvedValue({ boardId: 'sb-1', created: true });
+ render(
+ <MemoryRouter initialEntries={['/pipeline/issues/iss-1/storyboards']}>
+ <Routes>
+ <Route path="/pipeline/issues/:issueId/:stage" element={<StoryboardsStage issue={issue} series={null} onStageUpdate={vi.fn()} />} />
+ <Route path="/storyboards/:id" element={<p>Storyboard editor</p>} />
+ </Routes>
+ </MemoryRouter>,
+ );
+
+ fireEvent.click(screen.getByRole('button', { name: /Open in storyboard editor/ }));
+ expect(api.openStoryboardForPipelineIssue).toHaveBeenCalledWith('iss-1');
+ expect(await screen.findByText('Storyboard editor')).toBeInTheDocument();
+ });
+});
diff --git a/client/src/components/storyboards/PanelDrawer.jsx b/client/src/components/storyboards/PanelDrawer.jsx
index e3bebddbd8..0cefc8acb8 100644
--- a/client/src/components/storyboards/PanelDrawer.jsx
+++ b/client/src/components/storyboards/PanelDrawer.jsx
@@ -35,7 +35,7 @@ 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, onSendToScene }) {
+function ArtSection({ panel, aspectRatio, sketchNonce, moodBoardId, busy, onAddTake, onSelectTake, onRemoveTake, onSketch, onSendToScene, sendLabel }) {
const [galleryOpen, setGalleryOpen] = useState(false);
const [sending, setSending] = useState(false);
const [pinsOpen, setPinsOpen] = useState(false);
@@ -89,7 +89,7 @@ function ArtSection({ panel, aspectRatio, sketchNonce, moodBoardId, busy, onAddT
{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
+ {sending ? <Loader2 size={16} className="animate-spin" aria-hidden="true" /> : <ImageUp size={16} aria-hidden="true" />} {sendLabel}
</button>
) : null}
{take ? (
@@ -117,6 +117,9 @@ function ArtSection({ panel, aspectRatio, sketchNonce, moodBoardId, busy, onAddT
function ShotTab({ board, found, panelNumber, sketchNonce, busy, handlers }) {
const { panel, beat, beatIndex, index } = found;
const [confirmDelete, setConfirmDelete] = useState(false);
+ // A panel made from a production's scene or shot can send its art back there.
+ const sendLabel = board.source?.kind === 'fableloom' && panel.sourceSceneId ? 'Use as scene art'
+ : board.source?.kind === 'pipeline' && panel.sourceShotId ? 'Use as shot art' : null;
const fieldId = (name) => `panel-${panel.id}-${name}`;
const [secondsDraft, setSecondsDraft] = useState(panel.seconds ?? '');
useEffect(() => { setSecondsDraft(panel.seconds ?? ''); }, [panel.seconds]);
@@ -143,7 +146,8 @@ 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}
+ onSendToScene={sendLabel ? handlers.onSendToScene : null}
+ sendLabel={sendLabel}
/>
<div>
<label htmlFor={fieldId('action')} className={labelClass}>Action</label>
diff --git a/client/src/pages/StoryboardDetail.jsx b/client/src/pages/StoryboardDetail.jsx
index 681a000ef3..8f104f575d 100644
--- a/client/src/pages/StoryboardDetail.jsx
+++ b/client/src/pages/StoryboardDetail.jsx
@@ -170,7 +170,7 @@ export default function StoryboardDetail() {
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');
+ if (res) toast.success(board.source?.kind === 'pipeline' ? 'Shot start frame updated in the pipeline' : 'Scene art updated in FableLoom');
},
onRecipe: (recipe) => write(() => updateStoryboardRecipe(id, recipe)),
onNodePatch: (nodeId, patch) => write(() => updateStoryboardPanelNode(id, panelId, nodeId, patch)),
@@ -276,6 +276,11 @@ export default function StoryboardDetail() {
<BookOpen size={16} aria-hidden="true" /> FableLoom episode
</Link>
)}
+ {board.source?.kind === 'pipeline' && (
+ <Link to={`/pipeline/issues/${encodeURIComponent(board.source.issueId)}/storyboards`} className={headerButton}>
+ <BookOpen size={16} aria-hidden="true" /> Pipeline issue
+ </Link>
+ )}
</div>
</header>
diff --git a/client/src/services/README.md b/client/src/services/README.md
index 126c9f869a..ab471c8ab9 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,, 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. |
+| `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, Make storyboard from a FableLoom path, Open in storyboard editor for a pipeline issue, and Use as scene/shot 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 6ff5d46714..2c04e976c6 100644
--- a/client/src/services/apiStoryboards.js
+++ b/client/src/services/apiStoryboards.js
@@ -97,8 +97,14 @@ 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 }.
+// Use as scene / shot art: the panel's selected image goes back to its FableLoom scene or
+// pipeline shot → { board, target }.
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 });
+
+// Open in storyboard editor (Series Pipeline): the issue's linked board, made from its
+// storyboard scenes the first time → { boardId, created }.
+export const openStoryboardForPipelineIssue = (issueId, options) =>
+ request(`/storyboards/from-pipeline/${enc(issueId)}`, { method: 'POST', ...options });
diff --git a/docs/API.md b/docs/API.md
index 47b17eb386..582e63b36d 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). 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/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). Open in storyboard editor (Series Pipeline): `POST /from-pipeline/:issueId` (`{ boardId, created }`: the board whose `source` is the issue, made the first time with one beat per storyboard scene and one panel per shot, `sourceSceneId`/`sourceShotId` set; 201 when made, 200 when it existed; 400 `NO_SCENES`). Use as scene / shot art: `POST /:id/panels/:panelId/scene-art` (`{ board, target }`: the panel's selected image becomes its FableLoom scene's image or its pipeline shot's start frame; 400 `NO_IMAGE` for a sketch or no art, `NO_SOURCE` for a panel with no scene or shot, `PIPELINE_STAGE_LOCKED` while the pipeline stage is locked). 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/scripts/watch-ci-tests.test.js b/scripts/watch-ci-tests.test.js
index 322ea330da..2f12010fb5 100644
--- a/scripts/watch-ci-tests.test.js
+++ b/scripts/watch-ci-tests.test.js
@@ -7,6 +7,14 @@ import { afterAll, describe, expect, it as vitestIt } from 'vitest';
import { setTimeout as delay } from 'node:timers/promises';
import { ownTestBodies } from '../server/lib/mockPathsDataRoot.js';
+// Where PID 1 does not reap orphans (some containers), a killed orphan stays a
+// zombie that still answers signal 0; on Linux its /proc state says it exited.
+const exited = (pid) => {
+ try { process.kill(pid, 0); } catch { return true; }
+ if (process.platform !== 'linux') return false;
+ try { return /^[ZX]$/.test(readFileSync(`/proc/${pid}/stat`, 'utf8').replace(/^.*\) /s, '')[0]); } catch { return true; }
+};
+
const { it, drain } = ownTestBodies(vitestIt);
afterAll(drain);
@@ -70,7 +78,7 @@ describe.skipIf(process.platform === 'win32')('independent browser test watchdog
expect(result.error).toBeUndefined();
expect(result.status, result.stderr).toBe(denied || orphan ? 1 : stalled ? 124 : status);
const owned = JSON.parse(readFileSync(join(root, 'owned.json'), 'utf8'));
- if (!denied) for (const pid of [owned.worker, owned.launcher, ...(owned.orphan ? [owned.orphan] : [])]) expect(() => process.kill(pid, 0)).toThrow();
+ if (!denied) for (const pid of [owned.worker, owned.launcher, ...(owned.orphan ? [owned.orphan] : [])]) expect(exited(pid), `pid ${pid}`).toBe(true);
if (stalled) {
expect(result.stdout).toContain('CI test watchdog: 0s elapsed');
const progress = result.stderr.indexOf('server/lib/synthetic.test.js');
diff --git a/server/cos-runner/securityScan.process.test.js b/server/cos-runner/securityScan.process.test.js
index c503fbe214..a19f193f0d 100644
--- a/server/cos-runner/securityScan.process.test.js
+++ b/server/cos-runner/securityScan.process.test.js
@@ -1,4 +1,5 @@
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import { readFileSync } from 'fs';
import { mkdtemp, mkdir, readFile, writeFile, rm } from 'fs/promises';
import { join } from 'path';
import { tmpdir } from 'os';
@@ -18,7 +19,10 @@ afterEach(async () => {
for (const owner of owners.splice(0)) await cleanupSecurityScanGroup(owner);
await rm(root, { recursive: true, force: true });
});
-const gone = pid => { try { process.kill(pid, 0); return false; } catch (err) { return err.code === 'ESRCH'; } };
+// Where PID 1 does not reap orphans (some containers), a killed orphan stays a
+// zombie that still answers signal 0; on Linux its /proc state says it exited.
+const zombie = pid => { try { return /^[ZX]$/.test(readFileSync(`/proc/${pid}/stat`, 'utf8').replace(/^.*\) /s, '')[0]); } catch { return false; } };
+const gone = pid => { try { process.kill(pid, 0); return process.platform === 'linux' && zombie(pid); } catch (err) { return err.code === 'ESRCH'; } };
it.skipIf(process.platform === 'win32')('reaps a real inherited worker after the scanner exits without waiting for its pipes', async () => {
// This fixture is a local Node process only. It has no provider/network code.
diff --git a/server/hostControlCoverage.test.js b/server/hostControlCoverage.test.js
index af0f1847ae..01ae78327b 100644
--- a/server/hostControlCoverage.test.js
+++ b/server/hostControlCoverage.test.js
@@ -1169,6 +1169,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['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/from-pipeline/:issueId', RECORDS],
['POST /api/storyboards/music-video/:projectId/shots/:sceneId/panel-art', RECORDS],
['POST /api/storyboards/music-video/:projectId/shots/:sceneId/update-from-panel', RECORDS],
['POST /api/storyboards/recipes', RECORDS],
diff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.js
index 86f0666943..e705597296 100644
--- a/server/lib/schemaVersions.js
+++ b/server/lib/schemaVersions.js
@@ -270,7 +270,9 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({
// `pin` to one of them.
// 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,
+ // v6 = a `source` of kind `pipeline` (a Series Pipeline issue) and a
+ // panel's `sourceShotId`; a v5 peer would drop both.
+ storyboards: 6,
// 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 685b3d9630..ffdd138434 100644
--- a/server/lib/storyboardRecord.js
+++ b/server/lib/storyboardRecord.js
@@ -51,11 +51,18 @@ 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`.
+ * panels send art back to: a FableLoom episode (`loomId`, `episodeId`) or a
+ * Series Pipeline issue (`issueId`). Each such panel names its scene in
+ * `sourceSceneId`, and a pipeline panel made from a shot that shot in
+ * `sourceShotId`.
*/
function sanitizeSource(raw) {
- if (!raw || typeof raw !== 'object' || raw.kind !== 'fableloom') return null;
+ if (!raw || typeof raw !== 'object') return null;
+ if (raw.kind === 'pipeline') {
+ const issueId = refOrNull(raw.issueId);
+ return issueId ? { kind: 'pipeline', issueId } : null;
+ }
+ if (raw.kind !== 'fableloom') return null;
const loomId = refOrNull(raw.loomId);
const episodeId = refOrNull(raw.episodeId);
return loomId && episodeId ? { kind: 'fableloom', loomId, episodeId } : null;
@@ -129,6 +136,7 @@ function sanitizePanel(raw) {
selectedTakeId,
make: sanitizePanelMake(raw.make, takeIds),
sourceSceneId: refOrNull(raw.sourceSceneId),
+ sourceShotId: refOrNull(raw.sourceShotId),
};
}
diff --git a/server/routes/hostControlStoryboards.test.js b/server/routes/hostControlStoryboards.test.js
index 7926db143e..8158136b6e 100644
--- a/server/routes/hostControlStoryboards.test.js
+++ b/server/routes/hostControlStoryboards.test.js
@@ -127,6 +127,7 @@ describe('Storyboards agent runs require operator authority (#12952)', () => {
'POST /api/storyboards/fit-music-video/:projectId',
'POST /api/storyboards/from-fableloom/:loomId/:episodeId',
'POST /api/storyboards/from-music-video/:projectId',
+ 'POST /api/storyboards/from-pipeline/:issueId',
'POST /api/storyboards/music-video/:projectId/shots/:sceneId/panel-art',
'POST /api/storyboards/music-video/:projectId/shots/:sceneId/update-from-panel',
'POST /api/storyboards/recipes',
diff --git a/server/routes/storyboards.js b/server/routes/storyboards.js
index c573ee6740..8d2cbf66c0 100644
--- a/server/routes/storyboards.js
+++ b/server/routes/storyboards.js
@@ -22,7 +22,9 @@ 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 { makeStoryboardFromFableLoom } from '../services/storyboards/fromFableLoom.js';
+import { openStoryboardForPipelineIssue } from '../services/storyboards/fromPipeline.js';
+import { sendPanelArtToSource } from '../services/storyboards/sourceArt.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';
@@ -42,12 +44,18 @@ 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.
+// Make storyboard from this FableLoom path; the scene-art panel route sends art back to its source 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 }));
}));
+// Open in storyboard editor (Series Pipeline): the issue's linked board, made from its scenes the first time.
+router.post('/from-pipeline/:issueId', asyncHandler(async (req, res) => {
+ const result = await openStoryboardForPipelineIssue(req.params.issueId);
+ res.status(result.created ? 201 : 200).json(result);
+}));
+
// 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 || {})));
@@ -126,7 +134,7 @@ router.post('/:id/panels/:panelId/move', asyncHandler(async (req, res) => {
}));
router.post('/:id/panels/:panelId/scene-art', asyncHandler(async (req, res) => {
- res.json(await sendPanelArtToFableLoom(req.params.id, req.params.panelId));
+ res.json(await sendPanelArtToSource(req.params.id, req.params.panelId));
}));
router.post('/:id/panels/:panelId/takes', asyncHandler(async (req, res) => {
diff --git a/server/services/storyboards/fromFableLoom.js b/server/services/storyboards/fromFableLoom.js
index 7fc5d9274c..bb142ca232 100644
--- a/server/services/storyboards/fromFableLoom.js
+++ b/server/services/storyboards/fromFableLoom.js
@@ -13,7 +13,7 @@ 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';
+import { createStoryboard } from './index.js';
const notFound = (what) => new ServerError(`${what} not found`, { status: 404, code: 'NOT_FOUND' });
@@ -54,23 +54,10 @@ export async function makeStoryboardFromFableLoom(loomId, episodeId, { via = []
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' });
- }
+/** Use as scene art: the image becomes the FableLoom scene's image. */
+export async function attachPanelArtToFableLoomScene(source, panel, 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 });
+ const node = await attachNodeImage(source.loomId, source.episodeId, panel.sourceSceneId, { filename: 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 };
+ return { loomId: source.loomId, episodeId: source.episodeId, sceneId: node.id };
}
diff --git a/server/services/storyboards/fromFableLoom.test.js b/server/services/storyboards/fromFableLoom.test.js
index b02ff1a6e4..c526816f7f 100644
--- a/server/services/storyboards/fromFableLoom.test.js
+++ b/server/services/storyboards/fromFableLoom.test.js
@@ -59,7 +59,7 @@ describe('storyboard from a FableLoom path', () => {
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' });
+ expect(sent.body.target).toMatchObject({ loomId: loom.id, sceneId: 'node-c' });
const after = await looms.getLoom(loom.id);
expect(after.episodes[0].nodes.map((n) => n.image)).toEqual(['harbor.png', null, 'market.png']);
});
diff --git a/server/services/storyboards/fromPipeline.js b/server/services/storyboards/fromPipeline.js
new file mode 100644
index 0000000000..3a40ae8934
--- /dev/null
+++ b/server/services/storyboards/fromPipeline.js
@@ -0,0 +1,91 @@
+/**
+ * Series Pipeline and storyboards. "Open in storyboard editor" on an issue's
+ * storyboards stage builds a board from its scenes: one beat per scene, one
+ * panel per shot (its description, shot type, length and start frame), or one
+ * panel for a scene with no shots (its description and sketch). The board
+ * keeps the issue as its `source` and each panel its scene and shot, so panel
+ * art made with recipes goes back to the shot with "Use as shot art". The
+ * stage is not changed until then. Runs only on the user's tap; no model call.
+ */
+
+import { ServerError } from '../../lib/errorHandler.js';
+import { STORYBOARD_LIMITS as L, STORYBOARD_PANEL_FRAMINGS } from '../../lib/storyboardVocabulary.js';
+import { trimTo } from '../../lib/textUtils.js';
+import { createStoryboard, listStoryboards } from './index.js';
+
+const FRAMINGS = new Set(STORYBOARD_PANEL_FRAMINGS);
+const SKETCH_KEY = /^sketch:[A-Za-z0-9-]{1,80}$/;
+
+const panelFromShot = (scene, shot) => ({
+ action: trimTo(shot.description, L.panelText),
+ framing: FRAMINGS.has(shot.shotType) ? shot.shotType : null,
+ seconds: Number.isFinite(shot.durationSeconds) && shot.durationSeconds > 0 ? shot.durationSeconds : null,
+ takes: typeof shot.startFrameFilename === 'string' && shot.startFrameFilename ? [{ source: 'gallery', image: shot.startFrameFilename }] : [],
+ sourceSceneId: scene.id,
+ sourceShotId: shot.id,
+});
+
+const panelFromScene = (scene) => ({
+ action: trimTo(scene.description || scene.prompt || scene.summary || scene.action, L.panelText),
+ takes: SKETCH_KEY.test(scene.sketchKey || '') ? [{ source: 'sketch', sketchKey: scene.sketchKey }] : [],
+ sourceSceneId: scene.id,
+});
+
+function beatsFromScenes(scenes) {
+ return scenes.map((scene, index) => {
+ const shots = (Array.isArray(scene.shots) ? scene.shots : []).filter((shot) => shot?.id);
+ return {
+ title: trimTo(scene.slugline || scene.heading, L.beatTitle) || `Scene ${index + 1}`,
+ what: trimTo(scene.summary || scene.description, L.beatText),
+ panels: shots.length ? shots.map((shot) => panelFromShot(scene, shot)) : [panelFromScene(scene)],
+ };
+ });
+}
+
+/**
+ * The board linked to this issue's storyboards stage, made from its scenes
+ * when there is none yet (`created` says which).
+ */
+export async function openStoryboardForPipelineIssue(issueId) {
+ const { getIssue } = await import('../pipeline/issues.js');
+ const issue = await getIssue(issueId);
+ const linked = (await listStoryboards()).find((b) => b.source?.kind === 'pipeline' && b.source.issueId === issue.id);
+ if (linked) return { boardId: linked.id, created: false };
+ const scenes = (issue.stages?.storyboards?.scenes || []).filter((scene) => scene?.id);
+ if (!scenes.length) {
+ throw new ServerError('This issue has no storyboard scenes yet; add or extract scenes first.', { status: 400, code: 'NO_SCENES' });
+ }
+ const board = await createStoryboard({
+ name: trimTo(issue.title, L.name) || 'Untitled storyboard',
+ }, { beats: beatsFromScenes(scenes), source: { kind: 'pipeline', issueId: issue.id } });
+ console.log(`🎬 Storyboard ${board.id} made from pipeline issue ${issue.id} (${scenes.length} scene(s))`);
+ return { boardId: board.id, created: true };
+}
+
+/** Use as shot art: the image becomes the shot's start frame. Refused while the stage is locked. */
+export async function attachPanelArtToPipelineShot(source, panel, image) {
+ if (!panel.sourceShotId) {
+ throw new ServerError('This panel is a whole scene; only a panel made from a shot can send its art back.', { status: 400, code: 'NO_SOURCE' });
+ }
+ const { assertStageUnlocked, updateStageWithLatest } = await import('../pipeline/issues.js');
+ let found = false;
+ await updateStageWithLatest(source.issueId, 'storyboards', (stage) => {
+ assertStageUnlocked({ stages: { storyboards: stage } }, 'storyboards');
+ const scenes = Array.isArray(stage?.scenes) ? stage.scenes : [];
+ const nextScenes = scenes.map((scene) => {
+ if (scene?.id !== panel.sourceSceneId || !Array.isArray(scene.shots)) return scene;
+ return {
+ ...scene,
+ shots: scene.shots.map((shot) => {
+ if (shot?.id !== panel.sourceShotId) return shot;
+ found = true;
+ // Clearing the job id keeps an older render still in the queue from replacing this pick.
+ return { ...shot, startFrameFilename: image, startFrameJobId: null };
+ }),
+ };
+ });
+ return found ? { scenes: nextScenes } : {};
+ });
+ if (!found) throw new ServerError('Pipeline shot not found', { status: 404, code: 'NOT_FOUND' });
+ return { issueId: source.issueId, sceneId: panel.sourceSceneId, shotId: panel.sourceShotId };
+}
diff --git a/server/services/storyboards/fromPipeline.test.js b/server/services/storyboards/fromPipeline.test.js
new file mode 100644
index 0000000000..1f31d8dd3b
--- /dev/null
+++ b/server/services/storyboards/fromPipeline.test.js
@@ -0,0 +1,92 @@
+/**
+ * Open in storyboard editor (Series Pipeline) and Use as shot art, through the
+ * real storyboard router and file-backed board store. The pipeline issue store
+ * is an in-memory stand-in that applies stage writes the way
+ * `updateStageWithLatest` does.
+ */
+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-pipeline-');
+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 issues = vi.hoisted(() => new Map());
+vi.mock('../pipeline/issues.js', async () => {
+ const { assertStageUnlocked } = await vi.importActual('../pipeline/issuesShared.js');
+ return {
+ assertStageUnlocked,
+ getIssue: async (id) => {
+ if (!issues.has(id)) throw Object.assign(new Error('Issue not found'), { status: 404 });
+ return structuredClone(issues.get(id));
+ },
+ updateStageWithLatest: async (id, stageId, compute) => {
+ const issue = issues.get(id);
+ const patch = compute(issue.stages[stageId]);
+ issue.stages[stageId] = { ...issue.stages[stageId], ...patch };
+ return { issue, stage: issue.stages[stageId] };
+ },
+ };
+});
+
+const { default: storyboardRoutes } = await import('../../routes/storyboards.js');
+
+const app = express();
+app.use(express.json());
+app.use('/api/storyboards', storyboardRoutes);
+app.use(errorMiddleware);
+afterAll(cleanupTempDataRoots);
+
+const seed = (id, storyboards) => issues.set(id, { id, title: 'Example Issue', stages: { storyboards } });
+
+describe('storyboard from a pipeline issue', () => {
+ it('builds beats from scenes and panels from shots, reopens the same board, and sends a panel image to its shot', async () => {
+ seed('iss-1', {
+ scenes: [
+ { id: 'scene-01', slugline: 'INT. LAB — NIGHT', description: 'The lab hums.', shots: [
+ { id: 'shot-01', description: 'Wide of the lab', shotType: 'wide', durationSeconds: 5, startFrameFilename: 'lab.png' },
+ { id: 'shot-02', description: 'Close on the dial', shotType: 'close', durationSeconds: 3 },
+ ] },
+ { id: 'scene-02', slugline: 'EXT. ROOF — DAWN', description: 'She looks out.', sketchKey: 'sketch:abc-123' },
+ ],
+ });
+
+ const opened = await request(app).post('/api/storyboards/from-pipeline/iss-1');
+ expect(opened.status).toBe(201);
+ const board = (await request(app).get(`/api/storyboards/${opened.body.boardId}`)).body;
+ expect(board).toMatchObject({ name: 'Example Issue', source: { kind: 'pipeline', issueId: 'iss-1' } });
+ expect(board.beats.map((beat) => [beat.title, beat.panels.map((p) => [p.sourceSceneId, p.sourceShotId])])).toEqual([
+ ['INT. LAB — NIGHT', [['scene-01', 'shot-01'], ['scene-01', 'shot-02']]],
+ ['EXT. ROOF — DAWN', [['scene-02', null]]],
+ ]);
+ expect(board.beats[0].panels[0]).toMatchObject({
+ action: 'Wide of the lab', framing: 'wide', seconds: 5, takes: [expect.objectContaining({ source: 'gallery', image: 'lab.png' })],
+ });
+ expect(board.beats[1].panels[0].takes).toEqual([expect.objectContaining({ source: 'sketch', sketchKey: 'sketch:abc-123' })]);
+
+ const again = await request(app).post('/api/storyboards/from-pipeline/iss-1');
+ expect([again.status, again.body]).toEqual([200, { boardId: board.id, created: false }]);
+
+ const shotPanel = board.beats[0].panels[1].id;
+ expect((await request(app).post(`/api/storyboards/${board.id}/panels/${shotPanel}/takes`).send({ source: 'generated', image: 'dial.png' })).status).toBe(201);
+ issues.get('iss-1').stages.storyboards.locked = true;
+ expect((await request(app).post(`/api/storyboards/${board.id}/panels/${shotPanel}/scene-art`)).status).toBe(400);
+ issues.get('iss-1').stages.storyboards.locked = false;
+ const sent = await request(app).post(`/api/storyboards/${board.id}/panels/${shotPanel}/scene-art`);
+ expect(sent.status).toBe(200);
+ expect(issues.get('iss-1').stages.storyboards.scenes[0].shots.map((s) => s.startFrameFilename)).toEqual(['lab.png', 'dial.png']);
+
+ // A sketch is never sent as art.
+ expect((await request(app).post(`/api/storyboards/${board.id}/panels/${board.beats[1].panels[0].id}/scene-art`)).body.code).toBe('NO_IMAGE');
+ });
+
+ it('refuses an issue with no storyboard scenes', async () => {
+ seed('iss-empty', { scenes: [] });
+ const res = await request(app).post('/api/storyboards/from-pipeline/iss-empty');
+ expect([res.status, res.body.code]).toEqual([400, 'NO_SCENES']);
+ });
+});
diff --git a/server/services/storyboards/sourceArt.js b/server/services/storyboards/sourceArt.js
new file mode 100644
index 0000000000..7362f536da
--- /dev/null
+++ b/server/services/storyboards/sourceArt.js
@@ -0,0 +1,29 @@
+/**
+ * "Use as scene art" / "Use as shot art": a panel made from a production's
+ * scene sends its selected image back there — a FableLoom scene's image or a
+ * Series Pipeline shot's start frame. The board is not changed; the target
+ * changes only on this tap.
+ */
+
+import { ServerError } from '../../lib/errorHandler.js';
+import { attachPanelArtToFableLoomScene } from './fromFableLoom.js';
+import { attachPanelArtToPipelineShot } from './fromPipeline.js';
+import { getStoryboard } from './index.js';
+
+const ATTACH = { fableloom: attachPanelArtToFableLoomScene, pipeline: attachPanelArtToPipelineShot };
+
+export async function sendPanelArtToSource(boardId, panelId) {
+ const board = await getStoryboard(boardId);
+ const attach = ATTACH[board.source?.kind];
+ if (!attach) throw new ServerError('This storyboard was not made from a FableLoom episode or a pipeline issue.', { status: 400, code: 'NO_SOURCE' });
+ const panel = board.beats.flatMap((beat) => beat.panels).find((p) => p.id === panelId);
+ if (!panel) throw new ServerError('Panel not found', { status: 404, code: 'NOT_FOUND' });
+ if (!panel.sourceSceneId) throw new ServerError('This panel was added on the storyboard; it has no scene to send art to.', { 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 sent as art.', { status: 400, code: 'NO_IMAGE' });
+ }
+ const target = await attach(board.source, panel, take.image);
+ console.log(`🎬 Storyboard ${boardId} panel ${panelId} art sent to ${board.source.kind} scene ${panel.sourceSceneId}`);
+ return { board, target };
+}
diff --git a/server/services/storyboards/sync.test.js b/server/services/storyboards/sync.test.js
index f33d4ab2c9..02b29981ac 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(5);
+ expect(PORTOS_SCHEMA_VERSIONS.storyboards).toBe(6);
});
it('emits a record event on create, edit and delete so subscribed peers get each revision', async () => {