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: a storyboard edit waits on its shot until you tap Update (#13436)

[._.]/c1c1aa01acb7
diff --git a/client/src/components/pipeline/stages/StoryboardsStage.jsx b/client/src/components/pipeline/stages/StoryboardsStage.jsx
index 25e8786408..9d2929b962 100644
--- a/client/src/components/pipeline/stages/StoryboardsStage.jsx
+++ b/client/src/components/pipeline/stages/StoryboardsStage.jsx
@@ -17,7 +17,7 @@
*/
import { useEffect, useMemo, useRef, useState } from 'react';
-import { useNavigate } from 'react-router';
+import { Link, useNavigate } from 'react-router';
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';
@@ -34,6 +34,8 @@ import {
extractPipelineStoryboardScenes,
createBlankSketch,
openStoryboardForPipelineIssue,
+ getPipelineStoryboardChanges,
+ updatePipelineShotsFromBoard,
} from '../../../services/api';
import useUniverse from '../../../hooks/useUniverse';
import { matchCharactersInText } from '../../../lib/scenePrompt';
@@ -135,6 +137,34 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
if (res?.boardId) navigate(`/storyboards/${encodeURIComponent(res.boardId)}`);
};
+ // The linked board is a copy: panels edited there wait here, per shot, until Update.
+ const [boardChanges, setBoardChanges] = useState(null);
+ const [updatingFromBoard, setUpdatingFromBoard] = useState(null);
+ useEffect(() => {
+ let live = true;
+ getPipelineStoryboardChanges(issue.id, { silent: true })
+ .then((res) => { if (live) setBoardChanges(res); })
+ .catch(() => {});
+ return () => { live = false; };
+ }, [issue.id, issue.updatedAt]);
+ const changedShots = useMemo(() => new Map((boardChanges?.changed || []).map((c) => [c.shotId, c])), [boardChanges]);
+ const boardLocked = stage.locked === true;
+ const updateFromBoard = async (shotId = null) => {
+ setUpdatingFromBoard(shotId || 'all');
+ const res = await updatePipelineShotsFromBoard(issue.id, shotId).catch(() => null);
+ setUpdatingFromBoard(null);
+ if (!res) return;
+ const { updated, issue: saved, ...changes } = res;
+ setBoardChanges(changes);
+ if (saved?.stages?.storyboards) {
+ const next = saved.stages.storyboards;
+ setScenes(next.scenes || []);
+ scenesRef.current = next.scenes || [];
+ onStageUpdate?.('storyboards', next, saved);
+ }
+ toast.success(`${updated} shot${updated === 1 ? '' : 's'} updated from the storyboard`);
+ };
+
const addScene = () => persist([...scenes, { slugline: '', description: '', imageJobId: null }]);
const removeScene = (i) => {
// Removing a scene reindexes everything after it, so any index-keyed
@@ -511,6 +541,25 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
</div>
</div>
+ {changedShots.size > 0 && (
+ <div className="flex flex-wrap items-center gap-2 rounded-lg border border-port-warning/40 bg-port-warning/5 px-3 py-2 text-sm text-port-warning">
+ <LayoutPanelLeft size={14} />
+ <span className="flex-1 min-w-0">
+ Storyboard changed: {changedShots.size} shot{changedShots.size === 1 ? '' : 's'}{boardLocked ? ' (unlock the stage to update)' : ''}
+ </span>
+ <Link to={`/storyboards/${encodeURIComponent(boardChanges.boardId)}`} className="text-xs underline hover:text-white">Open board</Link>
+ <button
+ type="button"
+ onClick={() => updateFromBoard()}
+ disabled={boardLocked || !!updatingFromBoard}
+ className="inline-flex items-center gap-1 min-h-[36px] px-3 py-1 rounded bg-port-card border border-port-border text-white text-xs hover:border-port-accent/50 disabled:opacity-40"
+ >
+ {updatingFromBoard === 'all' ? <Loader2 size={12} className="animate-spin" /> : null}
+ Update all
+ </button>
+ </div>
+ )}
+
{confirmingFrom && (
<InlineConfirmRow
tone="warning"
@@ -670,6 +719,10 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
onSetShotGrammar={(j, patch) => setShotGrammar(i, j, patch)}
onBlurShot={() => persist(scenes)}
onRenderShot={(j) => handleRenderShot(i, j)}
+ changedShots={changedShots}
+ boardLocked={boardLocked}
+ updatingFromBoard={updatingFromBoard}
+ onUpdateFromBoard={updateFromBoard}
/>
</li>
))}
@@ -679,9 +732,12 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
);
}
+const CHANGED_FIELD_LABELS = { description: 'action', shotType: 'framing', durationSeconds: 'length' };
+
function ShotList({
sceneIdx, shots, renderingShots, actionsGated,
onAddShot, onRemoveShot, onUpdateShot, onSetShotGrammar, onBlurShot, onRenderShot,
+ changedShots, boardLocked, updatingFromBoard, onUpdateFromBoard,
}) {
const hasShots = shots.length > 0;
// Inline pre-render continuity warnings (#1468): the same hazards the server
@@ -718,6 +774,7 @@ function ShotList({
<ul className="space-y-2">
{shots.map((shot, j) => {
const isRendering = renderingShots.has(`${sceneIdx}:${j}`);
+ const change = shot.id ? changedShots?.get(shot.id) : null;
return (
<li key={shot.id || j} className="flex items-start gap-2 p-2 bg-port-bg/40 border border-port-border/60 rounded">
<span className="text-[10px] text-gray-500 font-mono pt-1.5 w-6">{j + 1}</span>
@@ -732,6 +789,21 @@ function ShotList({
className="px-2 py-1 bg-port-bg border border-port-border rounded text-white text-xs"
maxLength={4000}
/>
+ {change ? (
+ <div className="flex items-center gap-2 text-[11px] text-port-warning">
+ <span className="flex-1 min-w-0">Storyboard changed: {change.fields.map((f) => CHANGED_FIELD_LABELS[f] || f).join(', ')}</span>
+ <button
+ type="button"
+ onClick={() => onUpdateFromBoard(shot.id)}
+ disabled={boardLocked || !!updatingFromBoard}
+ title={boardLocked ? 'Unlock the stage to update' : 'Copy the edited panel to this shot'}
+ className="inline-flex items-center gap-1 min-h-[32px] px-2 py-1 rounded bg-port-card border border-port-border text-white hover:border-port-accent/50 disabled:opacity-40"
+ >
+ {updatingFromBoard === shot.id ? <Loader2 size={11} className="animate-spin" /> : null}
+ Update
+ </button>
+ </div>
+ ) : null}
{/* Shot-grammar editor (#1468): set/correct the film-grammar
fields the visual.shot-continuity check reads. Discrete
picks persist immediately and skip the description-driven
diff --git a/client/src/components/pipeline/stages/StoryboardsStage.test.jsx b/client/src/components/pipeline/stages/StoryboardsStage.test.jsx
index c4623bf790..f734fed307 100644
--- a/client/src/components/pipeline/stages/StoryboardsStage.test.jsx
+++ b/client/src/components/pipeline/stages/StoryboardsStage.test.jsx
@@ -2,7 +2,11 @@ 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() }));
+const api = vi.hoisted(() => ({
+ openStoryboardForPipelineIssue: vi.fn(),
+ getPipelineStoryboardChanges: vi.fn(async () => ({ boardId: null, locked: false, changed: [] })),
+ updatePipelineShotsFromBoard: vi.fn(),
+}));
vi.mock('../../../services/api', () => {
const rest = ['generatePipelineVisualImage', 'generatePipelineSceneVideo', 'generatePipelineShotStartFrame',
'refinePipelineSceneImagePrompt', 'generatePipelineSceneImagePrompts', 'updatePipelineIssue',
@@ -37,4 +41,22 @@ describe('StoryboardsStage', () => {
expect(api.openStoryboardForPipelineIssue).toHaveBeenCalledWith('iss-1');
expect(await screen.findByText('Storyboard editor')).toBeInTheDocument();
});
+
+ it('shows a shot edited on the linked board and updates it on tap', async () => {
+ const withShot = { ...issue, stages: { storyboards: { status: 'edited', scenes: [{ ...issue.stages.storyboards.scenes[0], shots: [{ id: 'shot-01', description: 'Wide of the lab', durationSeconds: 5 }] }] } } };
+ api.getPipelineStoryboardChanges.mockResolvedValueOnce({
+ boardId: 'sb-1', locked: false, changed: [{ sceneId: 'scene-01', shotId: 'shot-01', panelId: 'panel-1', fields: ['description'] }],
+ });
+ const saved = { ...withShot, stages: { storyboards: { ...withShot.stages.storyboards, scenes: [{ ...withShot.stages.storyboards.scenes[0], shots: [{ id: 'shot-01', description: 'Wide of the dark lab', durationSeconds: 5 }] }] } } };
+ api.updatePipelineShotsFromBoard.mockResolvedValue({ updated: 1, issue: saved, boardId: 'sb-1', locked: false, changed: [] });
+ const onStageUpdate = vi.fn();
+ render(<MemoryRouter><StoryboardsStage issue={withShot} series={null} onStageUpdate={onStageUpdate} /></MemoryRouter>);
+
+ expect(await screen.findByText('Storyboard changed: action')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Update' }));
+ expect(api.updatePipelineShotsFromBoard).toHaveBeenCalledWith('iss-1', 'shot-01');
+ expect(await screen.findByDisplayValue('Wide of the dark lab')).toBeInTheDocument();
+ expect(screen.queryByText(/Storyboard changed/)).not.toBeInTheDocument();
+ expect(onStageUpdate).toHaveBeenCalledWith('storyboards', saved.stages.storyboards, saved);
+ });
});
diff --git a/client/src/services/README.md b/client/src/services/README.md
index ab471c8ab9..1af68ed3a6 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, 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. |
+| `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 with its waiting board changes and Update, 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 2c04e976c6..cdb745cd53 100644
--- a/client/src/services/apiStoryboards.js
+++ b/client/src/services/apiStoryboards.js
@@ -108,3 +108,11 @@ export const sendStoryboardPanelToFableLoom = (id, panelId, options) =>
// storyboard scenes the first time → { boardId, created }.
export const openStoryboardForPipelineIssue = (issueId, options) =>
request(`/storyboards/from-pipeline/${enc(issueId)}`, { method: 'POST', ...options });
+
+// The linked board's edits waiting for the issue's shots → { boardId, locked, changed: [{ sceneId, shotId, panelId, fields }] }.
+export const getPipelineStoryboardChanges = (issueId, options) =>
+ request(`/storyboards/pipeline/${enc(issueId)}/changes`, options);
+
+// Update: copy edited panels (all, or one shot's) to their shots → { updated, issue, boardId, locked, changed }.
+export const updatePipelineShotsFromBoard = (issueId, shotId, options) =>
+ request(`/storyboards/pipeline/${enc(issueId)}/update-from-board`, { ...json('POST', shotId ? { shotId } : {}), ...options });
diff --git a/docs/API.md b/docs/API.md
index 582e63b36d..9757762db7 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). 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/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`). The board is a linked copy and the stage stays the source of truth: `GET /pipeline/:issueId/changes` (`{ boardId, locked, changed: [{ sceneId, shotId, panelId, fields }] }`, the shots whose panel was edited on the board since the shot last took it, by the panel's `sourceRev`) and `POST /pipeline/:issueId/update-from-board` (`{ shotId? }` → `{ updated, issue, boardId, locked, changed }`: each edited panel's action, framing and length copied to its shot, or only `shotId`'s; 409 `NO_BOARD`, 400 `PIPELINE_STAGE_LOCKED`). 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/server/hostControlCoverage.test.js b/server/hostControlCoverage.test.js
index 04d0da77f9..8c0639de8e 100644
--- a/server/hostControlCoverage.test.js
+++ b/server/hostControlCoverage.test.js
@@ -1170,6 +1170,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['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/pipeline/:issueId/update-from-board', RECORDS],
['POST /api/storyboards/recipes', RECORDS],
['DELETE /api/storyboards/recipes/:recipeId', REMOVES_RECORD],
// /api/sync
diff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.js
index e705597296..5845d43b94 100644
--- a/server/lib/schemaVersions.js
+++ b/server/lib/schemaVersions.js
@@ -272,7 +272,9 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({
// panel's `sourceSceneId`, which "Use as scene art" sends art back through.
// v6 = a `source` of kind `pipeline` (a Series Pipeline issue) and a
// panel's `sourceShotId`; a v5 peer would drop both.
- storyboards: 6,
+ // v7 = a panel's `sourceRev` (what its pipeline shot last took from it, so
+ // only a panel edited since reads as changed); a v6 peer would drop it.
+ storyboards: 7,
// 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/storyboardFit.js b/server/lib/storyboardFit.js
index f7808265e9..954265a11a 100644
--- a/server/lib/storyboardFit.js
+++ b/server/lib/storyboardFit.js
@@ -58,7 +58,12 @@ function sectionAt(sections, at) {
// What a shot drew from its panel; a later change to any of it marks the shot's panel changed.
const PANEL_REV_FIELDS = ['action', 'dialogue', 'framing', 'camera', 'castIds', 'environmentIds', 'objectIds'];
export function storyboardPanelRev(panel) {
- const text = JSON.stringify(PANEL_REV_FIELDS.map((key) => panel[key] ?? null));
+ return storyboardRev(PANEL_REV_FIELDS.map((key) => panel[key] ?? null));
+}
+
+/** A short FNV-1a hash of JSON-able values, for telling whether copied fields changed. */
+export function storyboardRev(values) {
+ const text = JSON.stringify(values);
let hash = 0x811c9dc5;
for (let i = 0; i < text.length; i += 1) hash = Math.imul(hash ^ text.charCodeAt(i), 0x01000193);
return (hash >>> 0).toString(36);
diff --git a/server/lib/storyboardRecord.js b/server/lib/storyboardRecord.js
index ffdd138434..4e6ca0a068 100644
--- a/server/lib/storyboardRecord.js
+++ b/server/lib/storyboardRecord.js
@@ -54,7 +54,7 @@ const refOrNull = (value) => trimTo(value, STORYBOARD_LIMITS.refId) || null;
* 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`.
+ * `sourceShotId`, with `sourceRev` marking what the shot last took from it.
*/
function sanitizeSource(raw) {
if (!raw || typeof raw !== 'object') return null;
@@ -137,6 +137,7 @@ function sanitizePanel(raw) {
make: sanitizePanelMake(raw.make, takeIds),
sourceSceneId: refOrNull(raw.sourceSceneId),
sourceShotId: refOrNull(raw.sourceShotId),
+ sourceRev: trimTo(raw.sourceRev, 16) || null,
};
}
diff --git a/server/lib/storyboardValidation.js b/server/lib/storyboardValidation.js
index d02ba14fe4..a7e5de1adf 100644
--- a/server/lib/storyboardValidation.js
+++ b/server/lib/storyboardValidation.js
@@ -155,6 +155,11 @@ export const storyboardFitSchema = z.object({
.refine((starts) => Object.keys(starts).length <= L.beats, { message: `At most ${L.beats} picked starts` }).optional(),
}).strict();
+// Update a pipeline issue's shots from its board: every edited panel, or one shot's.
+export const storyboardPipelineUpdateSchema = z.object({
+ shotId: z.string().trim().min(1).max(80).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([]),
diff --git a/server/routes/hostControlStoryboards.test.js b/server/routes/hostControlStoryboards.test.js
index 8158136b6e..d11fcc1e5a 100644
--- a/server/routes/hostControlStoryboards.test.js
+++ b/server/routes/hostControlStoryboards.test.js
@@ -130,6 +130,7 @@ describe('Storyboards agent runs require operator authority (#12952)', () => {
'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/pipeline/:issueId/update-from-board',
'POST /api/storyboards/recipes',
'PUT /api/storyboards/:id/recipe',
]);
diff --git a/server/routes/storyboards.js b/server/routes/storyboards.js
index 8d2cbf66c0..25904dee0d 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, storyboardFromFableLoomSchema, storyboardVideoStartSchema, storyboardPlotExtractSchema, storyboardRecipeSchema, storyboardSavedRecipeSchema, storyboardTakeCreateSchema, storyboardUpdateSchema,
+ storyboardBeatsAddSchema, storyboardFitSchema, storyboardFromFableLoomSchema, storyboardPipelineUpdateSchema, storyboardVideoStartSchema, storyboardPlotExtractSchema, storyboardRecipeSchema, storyboardSavedRecipeSchema, storyboardTakeCreateSchema, storyboardUpdateSchema,
} from '../lib/storyboardValidation.js';
import {
addBeat, addPanel, addPanelTake, createStoryboard, deleteBeat, deletePanel, deleteStoryboard, getStoryboard,
@@ -23,7 +23,7 @@ import {
import { fitMusicVideoToStoryboard, updateShotFromPanel, sendShotStillToPanel } from '../services/storyboards/fitMusicVideo.js';
import { makeStoryboardFromMusicVideo } from '../services/storyboards/fromMusicVideo.js';
import { makeStoryboardFromFableLoom } from '../services/storyboards/fromFableLoom.js';
-import { openStoryboardForPipelineIssue } from '../services/storyboards/fromPipeline.js';
+import { openStoryboardForPipelineIssue, pipelineStoryboardChanges, updatePipelineShotsFromBoard } 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';
@@ -56,6 +56,14 @@ router.post('/from-pipeline/:issueId', asyncHandler(async (req, res) => {
res.status(result.created ? 201 : 200).json(result);
}));
+// The linked board's edits waiting for the pipeline stage, and Update that copies them to the shots.
+router.get('/pipeline/:issueId/changes', asyncHandler(async (req, res) => {
+ res.json(await pipelineStoryboardChanges(req.params.issueId));
+}));
+router.post('/pipeline/:issueId/update-from-board', asyncHandler(async (req, res) => {
+ res.json(await updatePipelineShotsFromBoard(req.params.issueId, validateRequest(storyboardPipelineUpdateSchema, req.body ?? {})));
+}));
+
// 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 || {})));
diff --git a/server/services/storyboards/fromPipeline.js b/server/services/storyboards/fromPipeline.js
index 3a40ae8934..88ec4d1b07 100644
--- a/server/services/storyboards/fromPipeline.js
+++ b/server/services/storyboards/fromPipeline.js
@@ -3,20 +3,31 @@
* 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.
+ * keeps the issue as its `source` and each panel its scene and shot.
+ *
+ * The board is a linked copy: the stage stays the source of truth (episode
+ * video, audio and comic pages read its shots) and changes only on a tap.
+ * "Use as shot art" sends a panel's image to its shot's start frame; Update
+ * copies an edited panel's action, framing and length to its shot. A panel's
+ * `sourceRev` marks what its shot last took, so an edit made on the stage
+ * never reads as a storyboard change. Both refuse while the stage is locked.
+ * 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';
+import { storyboardRev } from '../../lib/storyboardFit.js';
+import { createStoryboard, getStoryboard, listStoryboards, mutateStoryboard } from './index.js';
const FRAMINGS = new Set(STORYBOARD_PANEL_FRAMINGS);
const SKETCH_KEY = /^sketch:[A-Za-z0-9-]{1,80}$/;
-const panelFromShot = (scene, shot) => ({
+const SHOT_SECONDS_MAX = 30;
+
+const panelRev = (panel) => storyboardRev([panel.action, panel.framing, panel.seconds]);
+
+const panelFromShot = (scene, shot) => withRev({
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,
@@ -25,6 +36,10 @@ const panelFromShot = (scene, shot) => ({
sourceShotId: shot.id,
});
+function withRev(panel) {
+ return { ...panel, sourceRev: panelRev(panel) };
+}
+
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 }] : [],
@@ -46,11 +61,15 @@ function beatsFromScenes(scenes) {
* The board linked to this issue's storyboards stage, made from its scenes
* when there is none yet (`created` says which).
*/
+async function linkedBoardId(issueId) {
+ return (await listStoryboards()).find((b) => b.source?.kind === 'pipeline' && b.source.issueId === issueId)?.id ?? null;
+}
+
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 linked = await linkedBoardId(issue.id);
+ if (linked) return { boardId: linked, 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' });
@@ -89,3 +108,85 @@ export async function attachPanelArtToPipelineShot(source, panel, image) {
if (!found) throw new ServerError('Pipeline shot not found', { status: 404, code: 'NOT_FOUND' });
return { issueId: source.issueId, sceneId: panel.sourceSceneId, shotId: panel.sourceShotId };
}
+
+/** The shot fields a panel's Update writes that differ from the shot now. */
+function panelShotPatch(panel, shot) {
+ const next = { shotType: panel.framing };
+ // An empty action keeps the description; the stage drops a shot with none.
+ if (panel.action) next.description = panel.action;
+ if (panel.seconds) next.durationSeconds = Math.min(SHOT_SECONDS_MAX, Math.max(1, Math.round(panel.seconds)));
+ const current = { ...shot, description: trimTo(shot.description, L.panelText) };
+ return Object.fromEntries(Object.entries(next).filter(([key, value]) => (current[key] ?? null) !== value));
+}
+
+// A board made before `sourceRev` has no mark, so any difference counts.
+const editedOnBoard = (panel) => !panel.sourceRev || panelRev(panel) !== panel.sourceRev;
+
+function shotPanels(board) {
+ return board.beats.flatMap((beat) => beat.panels).filter((panel) => panel.sourceSceneId && panel.sourceShotId);
+}
+
+const shotKey = (sceneId, shotId) => `${sceneId}\u0000${shotId}`;
+
+/** Shots whose panel was edited on the linked board since the shot last took it. */
+export async function pipelineStoryboardChanges(issueId) {
+ const { getIssue } = await import('../pipeline/issues.js');
+ const issue = await getIssue(issueId);
+ const boardId = await linkedBoardId(issue.id);
+ if (!boardId) return { boardId: null, locked: false, changed: [] };
+ const board = await getStoryboard(boardId);
+ const stage = issue.stages?.storyboards || {};
+ const shots = new Map();
+ for (const scene of stage.scenes || []) {
+ for (const shot of Array.isArray(scene?.shots) ? scene.shots : []) shots.set(shotKey(scene.id, shot?.id), shot);
+ }
+ const changed = shotPanels(board).flatMap((panel) => {
+ const shot = shots.get(shotKey(panel.sourceSceneId, panel.sourceShotId));
+ const fields = shot && editedOnBoard(panel) ? Object.keys(panelShotPatch(panel, shot)) : [];
+ return fields.length ? [{ sceneId: panel.sourceSceneId, shotId: panel.sourceShotId, panelId: panel.id, fields }] : [];
+ });
+ return { boardId, locked: stage.locked === true, changed };
+}
+
+/**
+ * Update: each shot (or just `shotId`) whose panel was edited on the board
+ * takes the panel's action, framing and length; the panels are then marked as
+ * taken. Refused while the stage is locked. Answers with the saved issue and
+ * the changes still waiting.
+ */
+export async function updatePipelineShotsFromBoard(issueId, { shotId = null } = {}) {
+ const { getIssue, assertStageUnlocked, updateStageWithLatest } = await import('../pipeline/issues.js');
+ const issue = await getIssue(issueId);
+ const boardId = await linkedBoardId(issue.id);
+ if (!boardId) throw new ServerError('Open this issue in the storyboard editor first.', { status: 409, code: 'NO_BOARD' });
+ const board = await getStoryboard(boardId);
+ const panels = new Map(shotPanels(board)
+ .filter((panel) => (!shotId || panel.sourceShotId === shotId) && editedOnBoard(panel))
+ .map((panel) => [shotKey(panel.sourceSceneId, panel.sourceShotId), panel]));
+ let taken = new Map();
+ const { issue: saved } = await updateStageWithLatest(issue.id, 'storyboards', (stage) => {
+ assertStageUnlocked({ stages: { storyboards: stage } }, 'storyboards');
+ taken = new Map();
+ const scenes = (Array.isArray(stage?.scenes) ? stage.scenes : []).map((scene) => {
+ if (!Array.isArray(scene?.shots)) return scene;
+ return {
+ ...scene,
+ shots: scene.shots.map((shot) => {
+ const panel = panels.get(shotKey(scene.id, shot?.id));
+ const patch = panel ? panelShotPatch(panel, shot) : {};
+ if (!Object.keys(patch).length) return shot;
+ taken.set(panel.id, panelRev(panel));
+ return { ...shot, ...patch };
+ }),
+ };
+ });
+ return taken.size ? { scenes } : {};
+ });
+ if (taken.size) {
+ await mutateStoryboard(boardId, (draft) => {
+ for (const panel of shotPanels(draft)) if (taken.has(panel.id)) panel.sourceRev = taken.get(panel.id);
+ });
+ console.log(`🎬 Pipeline issue ${issue.id}: ${taken.size} shot(s) updated from storyboard ${boardId}`);
+ }
+ return { updated: taken.size, issue: saved, ...(await pipelineStoryboardChanges(issue.id)) };
+}
diff --git a/server/services/storyboards/fromPipeline.test.js b/server/services/storyboards/fromPipeline.test.js
index 1f31d8dd3b..3f7500a7cd 100644
--- a/server/services/storyboards/fromPipeline.test.js
+++ b/server/services/storyboards/fromPipeline.test.js
@@ -84,6 +84,37 @@ describe('storyboard from a pipeline issue', () => {
expect((await request(app).post(`/api/storyboards/${board.id}/panels/${board.beats[1].panels[0].id}/scene-art`)).body.code).toBe('NO_IMAGE');
});
+ it('lists only panels edited on the board and copies them to their shots on Update', async () => {
+ seed('iss-2', {
+ scenes: [{ id: 'scene-01', slugline: 'INT. LAB — NIGHT', shots: [
+ { id: 'shot-01', description: 'Wide of the lab', shotType: 'wide', durationSeconds: 5 },
+ { id: 'shot-02', description: 'Close on the dial', shotType: 'close', durationSeconds: 3 },
+ ] }],
+ });
+ const { boardId } = (await request(app).post('/api/storyboards/from-pipeline/iss-2')).body;
+ const changes = async () => (await request(app).get('/api/storyboards/pipeline/iss-2/changes')).body;
+ expect(await changes()).toEqual({ boardId, locked: false, changed: [] });
+
+ // An edit made on the stage is not a storyboard change.
+ const shots = () => issues.get('iss-2').stages.storyboards.scenes[0].shots;
+ shots()[0].description = 'Wide of the lab, lights off';
+ expect((await changes()).changed).toEqual([]);
+
+ const board = (await request(app).get(`/api/storyboards/${boardId}`)).body;
+ const panelId = board.beats[0].panels[1].id;
+ await request(app).patch(`/api/storyboards/${boardId}/panels/${panelId}`).send({ action: 'Close on the cracked dial', seconds: 4.4 });
+ expect((await changes()).changed).toEqual([{ sceneId: 'scene-01', shotId: 'shot-02', panelId, fields: ['description', 'durationSeconds'] }]);
+
+ issues.get('iss-2').stages.storyboards.locked = true;
+ const refused = await request(app).post('/api/storyboards/pipeline/iss-2/update-from-board').send({ shotId: 'shot-02' });
+ expect([refused.status, refused.body.code]).toEqual([400, 'PIPELINE_STAGE_LOCKED']);
+ issues.get('iss-2').stages.storyboards.locked = false;
+
+ const updated = await request(app).post('/api/storyboards/pipeline/iss-2/update-from-board').send({ shotId: 'shot-02' });
+ expect(updated.body).toMatchObject({ updated: 1, changed: [] });
+ expect(shots().map((s) => [s.description, s.durationSeconds])).toEqual([['Wide of the lab, lights off', 5], ['Close on the cracked dial', 4]]);
+ });
+
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');
diff --git a/server/services/storyboards/sync.test.js b/server/services/storyboards/sync.test.js
index 02b29981ac..5efb737b97 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(6);
+ expect(PORTOS_SCHEMA_VERSIONS.storyboards).toBe(7);
});
it('emits a record event on create, edit and delete so subscribed peers get each revision', async () => {