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

Lock storyboard shots one at a time (#11217)

[._.]/fe008cd198c7
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsx
index fb73348ff8..dbd5d02908 100644
--- a/client/src/components/musicVideo/SceneCard.jsx
+++ b/client/src/components/musicVideo/SceneCard.jsx
@@ -22,6 +22,7 @@ import { buildSceneTimingPresentation } from '../../lib/musicVideoSceneTiming.js
import SceneTimingPlan from './SceneTimingPlan.jsx';
import SceneRenderProgress from './SceneRenderProgress.jsx';
import { COVERAGE_TOLERANCE_SEC, SCENE_ATTENTION_LABELS, sceneAttention } from '../../lib/musicVideoSceneAttention.js';
+import { ShotLockButton } from './ShotLock.jsx';
// The two timeline-bound scene fields rendered as identical number inputs.
const SCENE_TIME_FIELDS = [['Start', 'startSec'], ['End', 'endSec']];
@@ -213,6 +214,7 @@ export default function SceneCard({
<div className="space-y-2 p-3 pt-0">
{/* A move swaps this shot with its neighbor; the song timing and lyric stay with the slot. */}
<div className="flex items-center justify-end gap-2">
+ <ShotLockButton sceneId={scene.sceneId} className="mr-auto" />
{documentComposition && (
<span className="mr-auto text-[11px] text-gray-400">Shot order comes from the composition document, so it can't be reordered here.</span>
)}
diff --git a/client/src/components/musicVideo/ShotLock.jsx b/client/src/components/musicVideo/ShotLock.jsx
new file mode 100644
index 0000000000..de5b80b356
--- /dev/null
+++ b/client/src/components/musicVideo/ShotLock.jsx
@@ -0,0 +1,40 @@
+import { createContext, useContext } from 'react';
+import { Lock, LockOpen } from 'lucide-react';
+
+/**
+ * Per-shot locks for the open project: `locks` maps a
+ * sceneId to `locked`, `changed` (locked, then edited) or `open`; `toggle(sceneId, lock)`
+ * locks or unlocks one shot. Null outside a project, or for a document
+ * storyboard, which has no per-shot locks.
+ */
+export const ShotLockContext = createContext(null);
+
+export const SHOT_LOCK_LABELS = Object.freeze({ locked: 'Locked', changed: 'Changed since locked', open: 'Not locked' });
+
+/** The lock state of one shot, or null when shots are not lockable here. */
+export function useShotLock(sceneId) {
+ const value = useContext(ShotLockContext);
+ const state = sceneId && value?.locks ? value.locks[sceneId] : null;
+ return state ? { state, toggle: (lock) => value.toggle(sceneId, lock), busy: !!value.busy } : null;
+}
+
+const baseCls = 'inline-flex min-h-[44px] shrink-0 items-center justify-center gap-1 rounded border px-2 text-xs disabled:opacity-50 sm:min-h-[28px]';
+
+/**
+ * One tap to lock a shot (its clip can then be made) or to unlock it. A shot
+ * edited since it was locked offers Lock again.
+ */
+export function ShotLockButton({ sceneId, className = '' }) {
+ const lock = useShotLock(sceneId);
+ if (!lock) return null;
+ const locked = lock.state === 'locked';
+ const label = locked ? 'Unlock' : lock.state === 'changed' ? 'Lock again' : 'Lock';
+ return (
+ <button type="button" onClick={() => lock.toggle(!locked)} disabled={lock.busy} aria-pressed={locked}
+ title={locked ? 'Locked: its clip can be made. Tap to unlock.' : 'Lock this shot so its clip can be made'}
+ className={`${baseCls} ${locked ? 'border-port-success/50 bg-port-success/10 text-port-success' : lock.state === 'changed' ? 'border-port-warning/50 bg-port-warning/10 text-port-warning' : 'border-port-border text-port-text'} ${className}`}>
+ {locked ? <Lock size={14} aria-hidden="true" /> : <LockOpen size={14} aria-hidden="true" />}
+ {label}
+ </button>
+ );
+}
diff --git a/client/src/components/musicVideo/ShotStepper.jsx b/client/src/components/musicVideo/ShotStepper.jsx
index ec0b23996a..d6f6cb872f 100644
--- a/client/src/components/musicVideo/ShotStepper.jsx
+++ b/client/src/components/musicVideo/ShotStepper.jsx
@@ -1,6 +1,7 @@
import { useEffect, useRef } from 'react';
import { SkipBack, SkipForward } from 'lucide-react';
import { shouldIgnoreGlobalKey } from '../../lib/a11yKeyboard.js';
+import { ShotLockButton } from './ShotLock.jsx';
// Back within this far into a shot goes to the shot before it; further in, to its own start.
const RESTART_SEC = 1;
@@ -30,6 +31,15 @@ export function shotSteps(scenes, t, range = null) {
return { back, next, index: current + 1, count: starts.length };
}
+/** The shot playing at song time `t`: the last one that has started. */
+function shotOnScreen(scenes, t) {
+ let current = null;
+ for (const scene of scenes || []) {
+ if (Number.isFinite(scene?.startSec) && scene.startSec <= t + ON_START_SEC && (!current || scene.startSec >= current.startSec)) current = scene;
+ }
+ return current;
+}
+
const buttonCls = 'flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center rounded border border-port-border bg-port-bg text-port-text disabled:opacity-40 sm:min-h-[28px] sm:min-w-[28px]';
/**
@@ -39,6 +49,7 @@ const buttonCls = 'flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-
*/
export default function ShotStepper({ scenes, time, onSeek, range = null, disabled = false, keys = false, className = '' }) {
const { back, next, index, count } = shotSteps(scenes, time, range);
+ const onScreen = shotOnScreen(scenes, time);
const latest = useRef({ back, next, onSeek, disabled });
latest.current = { back, next, onSeek, disabled };
useEffect(() => {
@@ -66,6 +77,7 @@ export default function ShotStepper({ scenes, time, onSeek, range = null, disabl
<button type="button" onClick={() => onSeek(next)} disabled={disabled || next == null} aria-label="Next shot" title="Next shot" className={buttonCls}>
<SkipForward size={14} aria-hidden="true" />
</button>
+ {onScreen && <ShotLockButton sceneId={onScreen.sceneId} />}
</div>
);
}
diff --git a/client/src/components/musicVideo/ShotStepper.test.jsx b/client/src/components/musicVideo/ShotStepper.test.jsx
index 05612eeec6..7e59c92366 100644
--- a/client/src/components/musicVideo/ShotStepper.test.jsx
+++ b/client/src/components/musicVideo/ShotStepper.test.jsx
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen } from '@testing-library/react';
import ShotStepper, { shotSteps } from './ShotStepper.jsx';
+import { ShotLockContext } from './ShotLock.jsx';
const scenes = [{ startSec: 4 }, { startSec: 0 }, { startSec: 8.5 }, { startSec: null }];
@@ -32,3 +33,27 @@ describe('ShotStepper', () => {
expect(onSeek).not.toHaveBeenCalled();
});
});
+
+describe('ShotStepper shot lock', () => {
+ const shots = [{ sceneId: 'a', startSec: 0 }, { sceneId: 'b', startSec: 4 }];
+ const renderWith = (locks, time) => {
+ const toggle = vi.fn();
+ render(<ShotLockContext.Provider value={{ locks, toggle, busy: false }}><ShotStepper scenes={shots} time={time} onSeek={vi.fn()} /></ShotLockContext.Provider>);
+ return toggle;
+ };
+
+ it('locks the shot on screen in one tap, and unlocks a locked one', () => {
+ const toggle = renderWith({ a: 'locked', b: 'changed' }, 5);
+ fireEvent.click(screen.getByRole('button', { name: 'Lock again' }));
+ expect(toggle).toHaveBeenLastCalledWith('b', true);
+ });
+
+ it('offers Unlock on a locked shot, and no lock button without lockable shots', () => {
+ const toggle = renderWith({ a: 'locked', b: 'open' }, 1);
+ fireEvent.click(screen.getByRole('button', { name: 'Unlock' }));
+ expect(toggle).toHaveBeenLastCalledWith('a', false);
+ document.body.innerHTML = '';
+ render(<ShotStepper scenes={shots} time={1} onSeek={vi.fn()} />);
+ expect(screen.queryByRole('button', { name: /lock/i })).toBeNull();
+ });
+});
diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsx
index 0204f9d48d..301d379167 100644
--- a/client/src/components/musicVideo/stages/BoardStage.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.jsx
@@ -1,9 +1,10 @@
-import { useEffect, useLayoutEffect, useRef } from 'react';
+import { useContext, useEffect, useLayoutEffect, useRef } from 'react';
import { useSearchParams } from 'react-router';
-import { Plus, Image as ImageIcon, Film, Code2, Type, FlagTriangleRight } from 'lucide-react';
+import { Plus, Image as ImageIcon, Film, Code2, Type, FlagTriangleRight, Lock, LockOpen } from 'lucide-react';
import BeatTimeline from '../BeatTimeline.jsx';
import ContactSheetButton from '../ContactSheetButton.jsx';
import SceneCard from '../SceneCard.jsx';
+import { ShotLockContext, SHOT_LOCK_LABELS } from '../ShotLock.jsx';
import TreatmentPanel, { treatmentSummary } from '../TreatmentPanel.jsx';
import StageSection from '../StageSection.jsx';
import { PlanActions } from '../ProjectActionGroups.jsx';
@@ -42,6 +43,18 @@ function SceneMediaBadges({ scene, layered }) {
);
}
+/** Top-left mark on a Board thumbnail: locked, or changed since it was locked (an open shot shows none). */
+function SceneLockBadge({ sceneId, state }) {
+ if (state !== 'locked' && state !== 'changed') return null;
+ const Icon = state === 'locked' ? Lock : LockOpen;
+ return (
+ <span id={`scene-lock-${sceneId}`} title={SHOT_LOCK_LABELS[state]}
+ className={`port-media-overlay-strong absolute left-1 top-1 inline-flex items-center rounded p-0.5 ${state === 'locked' ? 'text-port-success' : 'text-port-warning'}`}>
+ <Icon size={12} aria-hidden="true" /><span className="sr-only">{SHOT_LOCK_LABELS[state]}</span>
+ </span>
+ );
+}
+
/**
* Storyboard: the treatment (the brief the planner reads, then per-shot
* direction), planning tools, the opening title card, the beat timeline, and the scene cards —
@@ -52,6 +65,7 @@ function SceneMediaBadges({ scene, layered }) {
export default function BoardStage({ board }) {
const { project, locked, busy, sceneMedia, videoSettings, takes, treatment, activeSceneId, onToggleSceneExpand } = board;
const scenes = project.scenes || [];
+ const shotLocks = useContext(ShotLockContext)?.locks || {};
const [searchParams, setSearchParams] = useSearchParams();
const filter = parseSceneFilter(searchParams.get('scenes'));
const setFilter = (next) => setSearchParams((prev) => {
@@ -179,11 +193,13 @@ export default function BoardStage({ board }) {
ref={element => { if (element) thumbnailsRef.current.set(scene.sceneId, element); else thumbnailsRef.current.delete(scene.sceneId); }}
onClick={() => { board.seekToScene?.(scene); onToggleSceneExpand?.(scene.sceneId, true); }}
aria-label={`Open ${scene.sectionLabel || scene.label || `Scene ${scene.order + 1}`}`}
- aria-describedby={sceneMediaKind(scene, { layered }) || scene.endImageId ? `scene-media-${scene.sceneId}` : undefined}
+ aria-describedby={[['locked', 'changed'].includes(shotLocks[scene.sceneId]) && `scene-lock-${scene.sceneId}`,
+ (sceneMediaKind(scene, { layered }) || scene.endImageId) && `scene-media-${scene.sceneId}`].filter(Boolean).join(' ') || undefined}
className={`min-w-0 rounded border p-2 text-left ${activeSceneId === scene.sceneId ? 'border-port-accent bg-port-accent/10' : 'border-port-border bg-port-card'}`}>
<span className="relative block">
{scene.referenceImageId ? <img src={musicVideoImageSrc(scene.referenceImageId)} alt="" loading="lazy" className="aspect-video w-full rounded object-cover" />
: <span className="flex aspect-video items-center justify-center rounded bg-port-bg text-port-text-muted"><ImageIcon size={22} aria-hidden="true" /></span>}
+ <SceneLockBadge sceneId={scene.sceneId} state={shotLocks[scene.sceneId]} />
<SceneMediaBadges scene={scene} layered={layered} />
</span>
<span className="mt-1 block truncate text-sm">{scene.sectionLabel || scene.label || `Scene ${scene.order + 1}`}</span>
diff --git a/client/src/components/musicVideo/stages/BoardStage.test.jsx b/client/src/components/musicVideo/stages/BoardStage.test.jsx
index 717e234f76..594be58f9c 100644
--- a/client/src/components/musicVideo/stages/BoardStage.test.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.test.jsx
@@ -3,6 +3,7 @@ import { describe, it, expect, vi } from 'vitest';
import { fireEvent, render, screen } from '@testing-library/react';
import { MemoryRouter, useLocation } from 'react-router';
import BoardStage from './BoardStage.jsx';
+import { ShotLockContext } from '../ShotLock.jsx';
vi.mock('../../../hooks/useVideoFileSrc.js', () => ({ useVideoFileSrc: () => ({}) }));
vi.mock('../BeatTimeline.jsx', () => ({ default: () => null }));
@@ -67,3 +68,16 @@ describe('BoardStage thumbnail media badges', () => {
expect(document.getElementById(descriptionOf('Open Shot 3')).textContent).toBe('Code');
});
});
+
+describe('BoardStage thumbnail lock marks', () => {
+ it('marks locked and changed shots, and leaves open ones bare', () => {
+ const scenes = [scene(1), scene(2), scene(3)];
+ render(<MemoryRouter><ShotLockContext.Provider value={{ locks: { s1: 'locked', s2: 'changed', s3: 'open' }, toggle: vi.fn() }}>
+ <BoardStage board={board(scenes)} /></ShotLockContext.Provider></MemoryRouter>);
+ const described = (name) => screen.getByRole('button', { name }).getAttribute('aria-describedby').split(' ')
+ .map(id => document.getElementById(id).textContent);
+ expect(described('Open Shot 1')).toEqual(['Locked', 'Clip']);
+ expect(described('Open Shot 2')).toEqual(['Changed since locked', 'Clip']);
+ expect(described('Open Shot 3')).toEqual(['Clip']);
+ });
+});
diff --git a/client/src/hooks/useMusicVideoProductionReview.js b/client/src/hooks/useMusicVideoProductionReview.js
index 89285ce350..91d907602a 100644
--- a/client/src/hooks/useMusicVideoProductionReview.js
+++ b/client/src/hooks/useMusicVideoProductionReview.js
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react';
import { checkMusicVideoOverlayText, reverifyMusicVideoAlignment, importMusicVideoDocumentShots, getMusicVideoProductionReview, saveMusicVideoProductionDraft, prepareMusicVideoProductionReview,
- approveMusicVideoProductionReview, renderMusicVideoProductionProof, musicVideoExcerptRenderEventsUrl,
+ approveMusicVideoProductionReview, lockMusicVideoShots, renderMusicVideoProductionProof, musicVideoExcerptRenderEventsUrl,
cancelMusicVideoExcerptRender, importMusicVideoProductionPlanning, bindMusicVideoProductionShot, addMusicVideoProductionFeedback, resolveMusicVideoProductionFeedback, reviseMusicVideoProductionFromFeedback, revertMusicVideoProductionInput } from '../services/apiMusicVideo.js';
import useSseJobSlot from './useSseJobSlot.js';
@@ -75,6 +75,9 @@ export default function useMusicVideoProductionReview({ project, replaceProject
prepare: () => call(() => prepareMusicVideoProductionReview(project.id, {}, { silent: true })),
approve: (stage, proofReview) => call(() => approveMusicVideoProductionReview(project.id,
{ stage, basis: readiness?.basis[stage], ...(stage === 'proof' ? { proofReview } : {}) }, { silent: true })),
+ // Lock (or unlock) single shots: a locked shot's clip can be made before the whole board is approved.
+ // Not silent: the buttons live on scene cards and the player, away from the review panel's error line.
+ lockShots: (sceneIds, locked) => call(() => lockMusicVideoShots(project.id, { sceneIds, locked })),
renderProof: window => proof.start({ id: project.id, window }, project.id),
};
}
diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.js
index 5fc5b3b486..d6abf69d3b 100644
--- a/client/src/lib/musicVideoStages.js
+++ b/client/src/lib/musicVideoStages.js
@@ -633,6 +633,15 @@ export function summarizeStoryboardProblems(problems = []) {
});
}
+// Once any shot is locked one at a time, the board is approved when every shot is: say how many are left.
+function unlockedDetail(readiness, item) {
+ const left = readiness?.storyboard?.approved ? 0 : (readiness?.storyboard?.unlocked || []).length;
+ if (!left) return item;
+ const count = `${formatCount(left)} shot${left === 1 ? '' : 's'} not locked yet.`;
+ // A stale board keeps its "changed since" text (and Keep approved) after the count.
+ return { ...item, detail: item.stale ? `${count} ${item.detail}` : `${count} Lock each on its card, or approve them all here.` };
+}
+
// The server names each open change request as a readiness problem; the
// checklist lists those requests on their own Feedback row instead.
const FEEDBACK_PROBLEM = /^Resolve (art|storyboard|proof) feedback for /;
@@ -828,7 +837,8 @@ export function stageChecklist(stageId, project, readiness = project?.production
...problems,
// The problems are listed above, one row per group; the approval row need not repeat the first.
// A stale approval keeps its "changed since" text: it is the only place the checklist names what changed.
- problems.length && !storyboardApproval.stale ? { ...storyboardApproval, detail: 'Approve once the items above are done.' } : storyboardApproval,
+ problems.length && !storyboardApproval.stale ? { ...storyboardApproval, detail: 'Approve once the items above are done.' }
+ : unlockedDetail(readiness, storyboardApproval),
];
}
case 'produce': {
diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.js
index f5b1bf7407..754361c4d0 100644
--- a/client/src/lib/musicVideoStages.test.js
+++ b/client/src/lib/musicVideoStages.test.js
@@ -500,6 +500,13 @@ describe('stageChecklist', () => {
const stale = { ...readiness, storyboard: { approved: false, problems: ['Review and approve the current art direction first.'], stale: { changedFields: ['art direction', 'cast'] } } };
expect(stageChecklist('board', castProject({ scenes: [scene()] }), stale).at(-1).detail).toMatch(/changed since: art direction, cast/);
});
+ it('counts the shots left to lock once shots are locked one at a time', () => {
+ const readiness = { ...NOT_APPROVED, art: { approved: true, problems: [] }, storyboard: { approved: false, problems: [], unlocked: ['s2', 's3'] } };
+ expect(stageChecklist('board', castProject({ scenes: [scene()] }), readiness).at(-1))
+ .toMatchObject({ id: 'approve-storyboard', detail: '2 shots not locked yet. Lock each on its card, or approve them all here.' });
+ const stale = { ...readiness, storyboard: { ...readiness.storyboard, stale: { changedFields: ['scene 2 prompt'] } } };
+ expect(stageChecklist('board', castProject({ scenes: [scene()] }), stale).at(-1).detail).toMatch(/^2 shots not locked yet\. .*changed since: scene 2 prompt/);
+ });
it('counts per-scene changes in a stale approval instead of naming every scene', () => {
const prompts = Array.from({ length: 26 }, (_, i) => `scene ${i + 1} prompt`);
expect(changedFieldsText(['storyboard shots', ...prompts, 'scene 4 timing'])).toBe('storyboard shots, 26 scene prompts, scene 4 timing');
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index d9cf21f379..581f1105f9 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -66,6 +66,7 @@ import CreateProjectDrawer from '../components/musicVideo/CreateProjectDrawer.js
import AutonomousStartDrawer from '../components/musicVideo/AutonomousStartDrawer.jsx';
import { automationDraftFrom, automationFromDraft } from '../lib/musicVideoAutomation.js';
import { listUniverseNames } from '../services/apiUniverseBuilder.js';
+import { ShotLockContext } from '../components/musicVideo/ShotLock.jsx';
import MusicVideoLayout, { MUSIC_VIDEO_PAGE_ID, MUSIC_VIDEO_SCROLL_ID } from '../components/musicVideo/MusicVideoLayout.jsx';
import ProjectManageActions from '../components/musicVideo/ProjectManageActions.jsx';
import ProjectSettingsDrawer, { SETTINGS_TAB_IDS } from '../components/musicVideo/ProjectSettingsDrawer.jsx';
@@ -296,6 +297,10 @@ export default function MusicVideo() {
navigate(newest ? `/music-video/${encodeURIComponent(newest.id)}/${stageOnlyParam}` : "/music-video", { replace: true });
}, [stageOnlyParam, summaries.loaded, summaries.error, sortedProjects, navigate]);
const productionReview = useMusicVideoProductionReview({ project: selected, replaceProject });
+ const shotLocks = productionReview.readiness?.storyboard?.shotLocks;
+ const shotLockValue = shotLocks
+ ? { locks: shotLocks, toggle: (sceneId, lock) => productionReview.lockShots([sceneId], lock), busy: productionReview.busy }
+ : null;
// Posting (#9282): fill each platform's post in the PortOS Browser, post on a second press.
const publishing = useMusicVideoPublishing({ project: selected, replaceProject });
// Publish counts every platform the director turned on (#9287), not just any one post.
@@ -1523,6 +1528,7 @@ export default function MusicVideo() {
/>
)}
{selected && (
+ <ShotLockContext.Provider value={shotLockValue}>
<MusicVideoLayout
project={selected}
trackLabel={trackName(selected.trackId)}
@@ -1592,6 +1598,7 @@ export default function MusicVideo() {
>
<StageView key={selected.id} board={board} />
</MusicVideoLayout>
+ </ShotLockContext.Provider>
)}
</div>
</div>
diff --git a/client/src/services/apiMusicVideo.js b/client/src/services/apiMusicVideo.js
index 5c9085bde0..64a9d7e6f8 100644
--- a/client/src/services/apiMusicVideo.js
+++ b/client/src/services/apiMusicVideo.js
@@ -555,6 +555,7 @@ export const checkMusicVideoOverlayText = (id, options = {}) => request(`/music-
export const reverifyMusicVideoAlignment = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/alignment`, { method: 'POST', body: JSON.stringify(body), ...options });
export const saveMusicVideoProductionDraft = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review`, { method: 'PUT', body: JSON.stringify(body), ...options });
export const prepareMusicVideoProductionReview = (id, body = {}, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/prepare`, { method: 'POST', body: JSON.stringify(body), ...options });
+export const lockMusicVideoShots = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/shots`, { method: 'POST', body: JSON.stringify(body), ...options });
export const approveMusicVideoProductionReview = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/approve`, { method: 'POST', body: JSON.stringify(body), ...options });
export const renderMusicVideoProductionProof = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/proof`, { method: 'POST', body: JSON.stringify(body), ...options });
export const importMusicVideoProductionPlanning = (id, source, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/import`, { method: 'POST', body: JSON.stringify({ source }), ...options });
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index 13dfc077a8..c703c4c046 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -1356,6 +1356,10 @@ export const musicVideoDocumentShotsSchema = z.object({
// the current start frame as its end frame.
export const musicVideoContinueShotSchema = z.object({ keepStillAsEnd: z.boolean().optional() }).strict();
export const musicVideoProductionImportSchema = z.object({ source: z.string().min(2).max(250000) }).strict();
+export const musicVideoShotLockSchema = z.object({
+ sceneIds: z.array(z.string().min(1).max(200)).min(1).max(500),
+ locked: z.boolean(),
+}).strict();
export const musicVideoProductionApprovalSchema = z.object({
stage: z.enum(['art', 'storyboard', 'proof']), basis: z.string().min(1).max(128),
password: z.string().max(1024).optional(),
diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.js
index f9338d00fd..a8a90701d3 100644
--- a/server/routes/musicVideo.js
+++ b/server/routes/musicVideo.js
@@ -12,10 +12,10 @@ import { existsSync } from 'fs';
import { unlink } from 'fs/promises';
import { pipeline } from 'stream/promises';
import { Router } from 'express';
-import { musicVideoSongStyleSunoSchema, musicVideoProjectListQuerySchema, musicVideoFinishedOutsideSchema, musicVideoProductionDraftSchema, musicVideoProductionApprovalSchema, musicVideoProductionProofSchema, musicVideoProductionImportSchema, musicVideoContinueShotSchema, musicVideoProductionFeedbackSchema, musicVideoProductionFeedbackResolutionSchema, musicVideoProductionReviseSchema, musicVideoProductionRevertSchema } from '../lib/musicVideoValidation.js';
+import { musicVideoSongStyleSunoSchema, musicVideoProjectListQuerySchema, musicVideoFinishedOutsideSchema, musicVideoProductionDraftSchema, musicVideoProductionApprovalSchema, musicVideoShotLockSchema, musicVideoProductionProofSchema, musicVideoProductionImportSchema, musicVideoContinueShotSchema, musicVideoProductionFeedbackSchema, musicVideoProductionFeedbackResolutionSchema, musicVideoProductionReviseSchema, musicVideoProductionRevertSchema } from '../lib/musicVideoValidation.js';
import { productionReadiness } from '../services/musicVideo/productionReview.js';
import { finishedOutsideBlocker } from '../lib/musicVideoFinishedOutside.js';
-import { getProductionReview, saveProductionDraft, prepareProductionReview, approveProductionReview, renderProductionProof, requireProductionReviewer, importProductionPlanning, bindProductionShot, addProductionFeedback, closeProductionFeedback, reviseProductionFromFeedback, revertProductionInput } from '../services/musicVideo/productionReviewService.js';
+import { getProductionReview, saveProductionDraft, prepareProductionReview, approveProductionReview, lockProductionShots, renderProductionProof, requireProductionReviewer, importProductionPlanning, bindProductionShot, addProductionFeedback, closeProductionFeedback, reviseProductionFromFeedback, revertProductionInput } from '../services/musicVideo/productionReviewService.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
import {
validateRequest,
@@ -777,6 +777,12 @@ router.post('/:id/production-review/approve', asyncHandler(async (req, res) => {
const reviewer = await requireProductionReviewer(req);
res.json(await approveProductionReview(req.params.id, { stage: input.stage, basis: input.basis, proofReview: input.proofReview, reviewer }));
}));
+// Lock or unlock single Board shots: a locked shot may have its clip made before the whole storyboard is approved.
+router.post('/:id/production-review/shots', asyncHandler(async (req, res) => {
+ const input = validateRequest(musicVideoShotLockSchema, req.body);
+ const reviewer = await requireProductionReviewer(req);
+ res.json(await lockProductionShots(req.params.id, { ...input, reviewer }));
+}));
router.post('/:id/production-review/proof', asyncHandler(async (req, res) => {
res.status(202).json(await renderProductionProof(req.params.id, validateRequest(musicVideoProductionProofSchema, req.body)));
}));
diff --git a/server/routes/musicVideoProductionReview.test.js b/server/routes/musicVideoProductionReview.test.js
index 3c4499ad20..7185263679 100644
--- a/server/routes/musicVideoProductionReview.test.js
+++ b/server/routes/musicVideoProductionReview.test.js
@@ -381,8 +381,9 @@ describe('human-reviewed Music Video workflow', () => {
expect(revised.body.project.productionReview.reviewedRevisions[entry.basis].draft.storyboard[0].staging).toBe('Figure foreground, doorway behind');
expect(revised.body.project.productionReview.feedback.at(-1).resolvedAt).toBeUndefined();
expect(revised.body.readiness.art.approved).toBe(true);
- // Rewording an approved shot keeps the storyboard approval; the proof it fed is reviewed again.
- expect(revised.body.readiness.storyboard.approved).toBe(true);
+ // Rewording an approved shot unlocks that shot, and the board until it is locked again.
+ expect(revised.body.readiness.storyboard.approved).toBe(false);
+ expect(revised.body.readiness.storyboard.unlocked).toHaveLength(1);
expect(revised.body.readiness.proof.approved).toBe(false);
const resolution = { feedbackId: entry.id, resolution: 'Reviewed the revised staging.' };
expect((await request(app).post(`${base}/production-review/feedback/resolve`).set('authorization', 'Bearer expired').send(resolution)).status).toBe(401);
@@ -538,6 +539,24 @@ describe('revising from review feedback', () => {
});
});
+describe('locking one shot', () => {
+ const lock = (body, auth) => {
+ const req = request(app).post(`${base}/production-review/shots`);
+ return (auth ? req.set('authorization', auth) : req).send(body);
+ };
+
+ it('locks and unlocks a Board shot for a signed-in reviewer only', async () => {
+ const sceneId = (await store.getProject(project.id)).scenes[0].sceneId;
+ expect((await lock({ sceneIds: [sceneId], locked: true }, 'Bearer expired')).status).toBe(401);
+ const locked = await lock({ sceneIds: [sceneId], locked: true });
+ expect(locked.status).toBe(200);
+ expect(locked.body.readiness.storyboard.shotLocks[sceneId]).toBe('locked');
+ const unlocked = await lock({ sceneIds: [sceneId], locked: false });
+ expect(unlocked.body.readiness.storyboard.shotLocks[sceneId]).toBe('open');
+ expect((await lock({ sceneIds: ['missing-scene'], locked: true })).status).toBe(404);
+ });
+});
+
describe('reverting a changed input to its approved value (#10241)', () => {
const revert = body => request(app).post(`${base}/production-review/revert`).send(body);
diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.js
index 0f3f11ba18..e6dbb6e52f 100644
--- a/server/services/musicVideo/productionReview.js
+++ b/server/services/musicVideo/productionReview.js
@@ -110,6 +110,56 @@ export function seedArtDraft(project, stage = project.castAndSets) {
return { ...project, productionReview: { ...project.productionReview, draft, seededDraft } };
}
+/**
+ * What one Board shot renders from: its prompts and direction, its span and
+ * lyric, its selected frames and performance setup, and its storyboard row.
+ * A shot lock (`productionReview.shotApprovals[sceneId]`) holds while this is
+ * unchanged, so an edit unlocks only the shot it touches. The selected clip is
+ * the shot's output, not an input, so choosing a take keeps the lock.
+ */
+function shotApprovalBasis(project, scene) {
+ const row = (project.productionReview?.draft?.storyboard || []).find(shot => shot?.sceneId === scene.sceneId);
+ const { prompt, framePrompt, visualIntent, camera, direction, startSec, endSec, lyricText, referenceImageId, endImageId,
+ shotMode, performanceSpeaker, performanceStyle, visualLayer, loop } = scene;
+ return hash({ prompt, framePrompt, visualIntent, camera, direction, startSec, endSec, lyricText, referenceImageId, endImageId,
+ shotMode, performanceSpeaker, performanceStyle, visualLayer, loop,
+ row: row ? { action: row.action, staging: row.staging, camera: row.camera, transition: row.transition, lyricCueIds: row.lyricCueIds } : null });
+}
+
+/** Each Board shot's lock: `locked`, `changed` (locked, then edited) or `open`. Null for a document storyboard. */
+export function shotLocks(project) {
+ if (project.productionReview?.draft?.storyboardSource === 'document') return null;
+ const approvals = project.productionReview?.shotApprovals || {};
+ return Object.fromEntries((project.scenes || []).map(scene => {
+ const approval = approvals[scene.sceneId];
+ return [scene.sceneId, !approval ? 'open' : approval.basis === shotApprovalBasis(project, scene) ? 'locked' : 'changed'];
+ }));
+}
+
+/** Lock or unlock Board shots for the director. A lock binds to the shot as it is now. */
+export function setShotLocks(project, { sceneIds, locked, reviewer = null, approvedBy = null }) {
+ if (project.productionReview?.draft?.storyboardSource === 'document') {
+ throw new ServerError('Document shots are reviewed in their authored source; approve the storyboard instead.', { status: 409, code: 'DOCUMENT_STORYBOARD' });
+ }
+ const scenes = sceneIds.map(id => (project.scenes || []).find(scene => scene.sceneId === id));
+ if (scenes.some(scene => !scene)) throw new ServerError('Scene not found', { status: 404, code: 'NOT_FOUND' });
+ const approvals = { ...project.productionReview?.shotApprovals };
+ const approvedAt = new Date().toISOString();
+ for (const scene of scenes) {
+ if (!locked) delete approvals[scene.sceneId];
+ else approvals[scene.sceneId] = { basis: shotApprovalBasis(project, scene), approvedAt,
+ ...(approvedBy ? { approvedBy } : {}), ...(reviewer ? { reviewer: structuredClone(reviewer) } : {}) };
+ }
+ const review = { ...project.productionReview, shotApprovals: approvals };
+ // Unlocking withdraws the whole-board approval too: with every lock gone, readiness would otherwise
+ // fall back to it and read the board approved with no shot locked.
+ if (!locked && review.approvals?.storyboard) {
+ const { storyboard: _withdrawn, ...rest } = review.approvals;
+ review.approvals = rest;
+ }
+ return { ...project, productionReview: review };
+}
+
/**
* Is a storyboard approval current on this revision? Either it was given on
* exactly this revision, or only the wording, prompts or timing of the shots
@@ -364,7 +414,12 @@ export function productionReadiness(project) {
if (overlapping.some(c => !shot?.lyricCueIds?.includes(c.id))
|| shot?.lyricCueIds?.some(id => !cues.some(c => c.id === id))) boardProblems.push(`Review lyric anchors for ${scene.label || 'each shot'}.`);
}
- const storyboardApproved = !boardProblems.length && storyboardApprovalCurrent(review.approvals?.storyboard, basis);
+ // Once any shot has been locked, the board is approved exactly when every shot is.
+ const locks = shotLocks(project);
+ const byShot = !!locks && Object.keys(review.shotApprovals || {}).length > 0;
+ const unlocked = locks ? Object.keys(locks).filter(id => locks[id] !== 'locked') : [];
+ const storyboardApproved = !boardProblems.length && (byShot ? scenes.length > 0 && !unlocked.length
+ : storyboardApprovalCurrent(review.approvals?.storyboard, basis));
const camera = storyboardCameraReport(scenes, documentShots ? null : boardStoryboard(project));
const proof = review.proof;
const excerpt = (project.excerpts || []).find(e => e.id === proof?.excerptId);
@@ -379,7 +434,8 @@ export function productionReadiness(project) {
// The overlay text check is advice on the storyboard, like camera variety; it never blocks approval.
storyboard: { approved: storyboardApproved, problems: [...new Set(boardProblems)], camera,
// Board shots as reviewed, derived rows included, so the editor and approval card show what the gate checked.
- shots: documentShots ? null : boardStoryboard(project), text: overlayTextReport(project, overlayTextBasis), stale: storyboardApproved ? null : staleApproval(project, 'storyboard', basis.storyboard, inputs) },
+ shots: documentShots ? null : boardStoryboard(project), text: overlayTextReport(project, overlayTextBasis), stale: storyboardApproved ? null : staleApproval(project, 'storyboard', basis.storyboard, inputs),
+ shotLocks: locks, unlocked: byShot ? unlocked : [] },
proof: { approved: proofApproved, problems: proofProblems, excerptId: excerpt?.id || null, stale: proofApproved ? null : staleApproval(project, 'proof', basis.proof, inputs) },
castAndSets: castAndSetsApproval(project),
// The animated proof is optional review evidence: the approved storyboard is what the final render needs.
@@ -458,6 +514,21 @@ export function assertProductionApproval(project, stage = 'proof') {
{ status: 409, code: 'MUSIC_VIDEO_APPROVAL_REQUIRED', context: { stage, readiness } });
}
+/**
+ * The approval one Board shot's clip needs: the art direction, and that shot
+ * locked (or the whole storyboard approved, which a board with no shot locks
+ * still uses).
+ */
+export function assertShotApproval(project, sceneId) {
+ const readiness = productionReadiness(project);
+ if (!readiness.art.approved) assertProductionApproval(project, 'art');
+ if (readiness.storyboard.approved || readiness.storyboard.shotLocks?.[sceneId] === 'locked') return;
+ throw new ServerError(readiness.storyboard.shotLocks?.[sceneId] === 'changed'
+ ? 'This shot changed since you locked it. Lock it again to make its clip.'
+ : 'Lock this shot (or approve the storyboard) before making its clip.',
+ { status: 409, code: 'MUSIC_VIDEO_APPROVAL_REQUIRED', context: { stage: 'storyboard', sceneId, readiness } });
+}
+
/** Evidence is bound to the exact revision and excerpt. Machine review never
* claims human playback; rendering alone is not a review. */
export function approveProductionStage(project, { stage, basis, proofReview, approvedBy, reviewer }) {
@@ -487,6 +558,10 @@ export function approveProductionStage(project, { stage, basis, proofReview, app
const decision = { stage, basis: expected, ...(stage === 'storyboard' ? { shotsBasis: productionReviewBasis(project).storyboardShots } : {}), inputs: productionApprovalInputs(project)[stage], values: productionApprovalValues(project, stage), approvedAt: new Date().toISOString(),
...(approvedBy ? { approvedBy } : {}), ...(reviewer ? { reviewer: structuredClone(reviewer) } : {}),
...(stage === 'proof' ? { proofReview: structuredClone(proofReview) } : {}) };
+ // Approving the whole board locks every shot on it, so a later edit unlocks only the shot it touches.
+ if (stage === 'storyboard' && project.productionReview?.draft?.storyboardSource !== 'document' && (project.scenes || []).length) {
+ project = setShotLocks(project, { sceneIds: project.scenes.map(scene => scene.sceneId), locked: true, reviewer, approvedBy });
+ }
return { ...project, productionReview: { ...project.productionReview,
approvalHistory: [...(project.productionReview?.approvalHistory || []), decision],
reviewedRevisions: { ...project.productionReview?.reviewedRevisions, [basis]: { draft: structuredClone(project.productionReview?.draft || {}), scenes: structuredClone(project.scenes || []), proof: structuredClone(project.productionReview?.proof || null), capturedAt: new Date().toISOString() } },
diff --git a/server/services/musicVideo/productionReview.storyboard.test.js b/server/services/musicVideo/productionReview.storyboard.test.js
index 5dc9fff40a..152aad5704 100644
--- a/server/services/musicVideo/productionReview.storyboard.test.js
+++ b/server/services/musicVideo/productionReview.storyboard.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
-import { productionReadiness, productionAlignmentBasis, approveProductionStage, carryProductionApprovals } from './productionReview.js';
+import { productionReadiness, productionAlignmentBasis, approveProductionStage, carryProductionApprovals, assertShotApproval, setShotLocks } from './productionReview.js';
import { applySceneUpdate, mergeNextScene, removeScene } from './projectsLogic.js';
const WORD_PROBLEM = /bounded, positive-duration word timings/;
@@ -91,40 +91,80 @@ describe('the director trimming an approved storyboard', () => {
return approveProductionStage(art, { stage: 'storyboard', basis: productionReadiness(art).basis.storyboard });
}
- // Uniquely catches cutting a shot and stretching its neighbour over the gap asking for a fresh storyboard approval.
- it('keeps the approval through a cut and a retime, and still stales on new content', () => {
+ // Uniquely catches cutting a shot unlocking the shots it never touched.
+ it('keeps untouched shots locked through a cut and unlocks only the shot stretched over the gap', () => {
const cut = removeScene(approvedBoard(), 's2');
expect(cut.productionReview.draft.storyboard.map((shot) => shot.sceneId)).toEqual(['s1', 's3']);
- expect(productionReadiness(cut).storyboard.problems).toContain('Storyboard shots must cover the master without unintended gaps or overlaps.');
+ expect(productionReadiness(cut).storyboard.shotLocks).toEqual({ s1: 'locked', s3: 'locked' });
const { project: stretched } = applySceneUpdate(cut, 's1', { endSec: 6 });
- expect(productionReadiness(stretched).storyboard).toMatchObject({ approved: true, stale: null });
- const { project: relyriced } = applySceneUpdate(stretched, 's1', { lyricText: 'A new line' });
- expect(productionReadiness(relyriced).storyboard.approved).toBe(false);
+ expect(productionReadiness(stretched).storyboard).toMatchObject({ approved: false, unlocked: ['s1'], shotLocks: { s1: 'changed', s3: 'locked' } });
});
- // Uniquely catches rewording one approved shot (its prompt, or its storyboard row) un-approving the whole board.
- it('keeps the approval when a shot is reworded, and stales it when a shot is added', () => {
- const { project: reprompted } = applySceneUpdate(approvedBoard(), 's2', { visualIntent: 'ASCII-art music video on the CRT', prompt: 'Green ASCII frames' });
- const rows = reprompted.productionReview.draft.storyboard.map((shot) => shot.sceneId === 's2' ? { ...shot, action: 'ASCII-art video plays' } : shot);
- const reworded = { ...reprompted, productionReview: { ...reprompted.productionReview, draft: { ...reprompted.productionReview.draft, storyboard: rows } } };
- expect(productionReadiness(reworded).storyboard).toMatchObject({ approved: true, stale: null });
- // A row that drops its lyric anchor keeps the allowance but fails the anchor check, so the board is not approved.
- const unanchoredRows = rows.map((shot) => shot.sceneId === 's1' ? { ...shot, lyricCueIds: [] } : shot);
- const unanchored = productionReadiness({ ...reworded, productionReview: { ...reworded.productionReview,
- draft: { ...reworded.productionReview.draft, storyboard: unanchoredRows } } }).storyboard;
+ it('unlocks only the merged shot when two shots are joined', () => {
+ const { project: merged } = mergeNextScene(approvedBoard(), 's1');
+ expect(productionReadiness(merged).storyboard.shotLocks).toEqual({ s1: 'changed', s3: 'locked' });
+ });
+
+ // Uniquely catches a lyric anchor dropped from a row slipping past the board check.
+ it('still blocks the board on a storyboard row that drops its lyric anchor', () => {
+ const board = approvedBoard();
+ const rows = board.productionReview.draft.storyboard.map((shot) => shot.sceneId === 's1' ? { ...shot, lyricCueIds: [] } : shot);
+ const unanchored = productionReadiness({ ...board, productionReview: { ...board.productionReview,
+ draft: { ...board.productionReview.draft, storyboard: rows } } }).storyboard;
expect(unanchored.approved).toBe(false);
expect(unanchored.problems).toContain('Review lyric anchors for Verse.');
- const added = { ...reworded, scenes: [...reworded.scenes.map((scene) => scene.sceneId === 's3' ? { ...scene, endSec: 7 } : scene),
- { sceneId: 's4', label: 'Extra', startSec: 7, endSec: 8, visualIntent: 'A new shot', framePrompt: 'Wide shot' }] };
- const addedBoard = productionReadiness(added).storyboard;
- expect(addedBoard.problems).toEqual([]);
- expect(addedBoard.approved).toBe(false);
- expect(addedBoard.stale.changedFields).toContain('scene 4 timing');
});
+});
- it('keeps the approval when two shots are merged into one', () => {
- const { project: merged } = mergeNextScene(approvedBoard(), 's1');
- expect(productionReadiness(merged).storyboard).toMatchObject({ approved: true, stale: null });
+describe('locking shots one at a time', () => {
+ function artApproved() {
+ const planned = project();
+ const scenes = [planned.scenes[0], { ...planned.scenes[1], sceneId: 's2', label: 'Insert', endSec: 6 },
+ { ...planned.scenes[1], sceneId: 's3', startSec: 6, endSec: 8 }];
+ const draft = { ...planned.productionReview.draft, cast: 'The director', environments: 'Edit room', visualLanguage: 'Analog grain',
+ motionLanguage: 'Slow push-ins', guideArtifactId: 'g1' };
+ const ready = { ...planned, scenes, devArtifacts: [{ id: 'g1', mimeType: 'image/png', file: 'guide.png', version: 1 }],
+ productionReview: { ...planned.productionReview, draft } };
+ return approveProductionStage(ready, { stage: 'art', basis: productionReadiness(ready).basis.art });
+ }
+
+ // Uniquely catches a single shot's clip waiting on the whole storyboard approval.
+ it('lets a locked shot make its clip before the board is approved', () => {
+ const art = artApproved();
+ expect(() => assertShotApproval(art, 's2')).toThrow(/Lock this shot/);
+ const locked = setShotLocks(art, { sceneIds: ['s2'], locked: true });
+ expect(() => assertShotApproval(locked, 's2')).not.toThrow();
+ expect(() => assertShotApproval(locked, 's1')).toThrow(/Lock this shot/);
+ expect(productionReadiness(locked).storyboard).toMatchObject({ approved: false, unlocked: ['s1', 's3'] });
+ const all = setShotLocks(locked, { sceneIds: ['s1', 's3'], locked: true });
+ expect(productionReadiness(all).storyboard).toMatchObject({ approved: true, unlocked: [] });
+ });
+
+ // Uniquely catches one shot's edit un-approving every other shot on an approved board.
+ it('unlocks only the shot an edit touches, and the board until it is locked again', () => {
+ const art = artApproved();
+ const approved = approveProductionStage(art, { stage: 'storyboard', basis: productionReadiness(art).basis.storyboard });
+ expect(productionReadiness(approved).storyboard.shotLocks).toEqual({ s1: 'locked', s2: 'locked', s3: 'locked' });
+ const { project: edited } = applySceneUpdate(approved, 's2', { prompt: 'ASCII-art music video on the CRT' });
+ const board = productionReadiness(edited).storyboard;
+ expect(board.shotLocks).toEqual({ s1: 'locked', s2: 'changed', s3: 'locked' });
+ expect(board).toMatchObject({ approved: false, unlocked: ['s2'] });
+ expect(() => assertShotApproval(edited, 's1')).not.toThrow();
+ expect(() => assertShotApproval(edited, 's2')).toThrow(/changed since you locked it/);
+ // Picking another clip take is the shot's output, not an input: it stays locked.
+ const { project: retaken } = applySceneUpdate(edited, 's1', { videoHistoryId: 'clip-2' });
+ expect(productionReadiness(retaken).storyboard.shotLocks.s1).toBe('locked');
+ const relocked = setShotLocks(retaken, { sceneIds: ['s2'], locked: true });
+ expect(productionReadiness(relocked).storyboard.approved).toBe(true);
+ });
+
+ // Uniquely catches unlocking every shot falling back to the old whole-board approval.
+ it('leaves the board unapproved after every shot of an approved board is unlocked', () => {
+ const art = artApproved();
+ const approved = approveProductionStage(art, { stage: 'storyboard', basis: productionReadiness(art).basis.storyboard });
+ const open = setShotLocks(approved, { sceneIds: ['s1', 's2', 's3'], locked: false });
+ expect(productionReadiness(open).storyboard.approved).toBe(false);
+ expect(() => assertShotApproval(open, 's1')).toThrow(/Lock this shot/);
});
});
diff --git a/server/services/musicVideo/productionReviewService.js b/server/services/musicVideo/productionReviewService.js
index e7cb2e4d28..00bdf87da9 100644
--- a/server/services/musicVideo/productionReviewService.js
+++ b/server/services/musicVideo/productionReviewService.js
@@ -3,7 +3,7 @@ import { ServerError } from '../../lib/errorHandler.js';
import { getProject, mutateProjectRecord } from './projects.js';
import { musicVideoEvents } from './events.js';
import { shotCameraLabel } from '../../lib/cameraMovements.js';
-import { productionReadiness, boardStoryboard, seedArtDraft, productionReviewBasis, productionAlignmentBasis, documentStoryboardBasis, approveProductionStage, assertProductionApproval, recordProductionFeedback, resolveProductionFeedback, revertApprovedInput } from './productionReview.js';
+import { productionReadiness, boardStoryboard, seedArtDraft, productionReviewBasis, productionAlignmentBasis, documentStoryboardBasis, approveProductionStage, assertProductionApproval, assertShotApproval, setShotLocks, recordProductionFeedback, resolveProductionFeedback, revertApprovedInput } from './productionReview.js';
const reviewProcessId = randomUUID();
@@ -25,15 +25,18 @@ export const getProductionReview = async id => present(await requireProject(id))
/**
* The approval a scene's media job needs. A still is how the director reviews
* the storyboard, so a still for a planned shot needs only the art direction;
- * clips, and anything a production run submits, wait for the storyboard. A
+ * a Board shot's own clip needs that shot locked (or the whole storyboard
+ * approved); anything a production run submits waits for the storyboard. A
* production run's bulk work also waits for the animated proof, except the
* stills of a run that stops before clips: the proof is made from clips.
*/
export async function assertMusicVideoSceneReview(tag, kind = null) {
if (!tag?.projectId || !tag.sceneId) return;
const project = await requireProject(tag.projectId);
- const boardStill = kind === 'image' && !tag.productionRunId && (project.scenes || []).some(scene => scene.sceneId === tag.sceneId);
- assertProductionApproval(project, boardStill ? 'art' : 'storyboard');
+ const boardShot = !tag.productionRunId && (project.scenes || []).some(scene => scene.sceneId === tag.sceneId);
+ if (boardShot && kind === 'image') assertProductionApproval(project, 'art');
+ else if (boardShot) assertShotApproval(project, tag.sceneId);
+ else assertProductionApproval(project, 'storyboard');
if (tag.productionRunId) {
const run = project.productionRuns?.find(r => r.id === tag.productionRunId);
const stillsOnly = kind === 'image' && run?.stopBefore === 'clips';
@@ -151,6 +154,12 @@ export async function revertProductionInput(id, input) {
return changed(project);
}
+/** Lock or unlock Board shots for an authenticated reviewer, under the project write lock. */
+export async function lockProductionShots(id, input) {
+ const { project } = await mutateProjectRecord(id, current => ({ project: setShotLocks(current, input) }));
+ return changed(project);
+}
+
export async function approveProductionReview(id, input) {
const guard = await validateGuideSelection(await requireProject(id), current => current.productionReview?.draft?.guideArtifactId);
const { project } = await mutateProjectRecord(id, current => {