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 video shots in two steps, keep still locks across cut moves, hide the unused animated proof (#11237)

[._.]/6417fe5d7f12
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsx
index d4956a85a4..69297bf535 100644
--- a/client/src/components/musicVideo/SceneCard.jsx
+++ b/client/src/components/musicVideo/SceneCard.jsx
@@ -209,7 +209,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" />
+ <ShotLockButton scene={scene} 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
index e4df923dbc..16a65fbc2e 100644
--- a/client/src/components/musicVideo/ShotLock.jsx
+++ b/client/src/components/musicVideo/ShotLock.jsx
@@ -2,39 +2,75 @@ 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.
+ * Per-shot locks for the open project: `locks` maps a sceneId to its still's
+ * lock — `locked`, `changed` (locked, then edited) or `open`; `clips` maps a
+ * video shot to its clip's lock the same way (null for a shot with no video
+ * step: a still, card or code shot locks once). `toggle(sceneId, lock, stage)`
+ * locks or unlocks one shot's `still` or `video`. 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' });
+export const SHOT_LOCK_LABELS = Object.freeze({ locked: 'Locked', still: 'Still locked, video not locked yet', changed: 'Changed since locked', open: 'Not locked' });
+
+/**
+ * A shot's lock as one state: `locked` once every step is (a video shot's
+ * still and clip), `still` while only a video shot's still is, else the
+ * still's own `changed` or `open`.
+ */
+export function overallShotLock(still, clip) {
+ if (still !== 'locked') return still;
+ if (clip == null || clip === 'locked') return 'locked';
+ return clip === 'changed' ? 'changed' : 'still';
+}
/** 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 still = sceneId && value?.locks ? value.locks[sceneId] : null;
+ if (!still) return null;
+ const clip = value.clips?.[sceneId] ?? null;
+ return { state: overallShotLock(still, clip), still, clip, toggle: (lock, stage = 'still') => value.toggle(sceneId, lock, stage), busy: !!value.busy };
}
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]';
+const toneCls = { locked: 'border-port-success/50 bg-port-success/10 text-port-success', changed: 'border-port-warning/50 bg-port-warning/10 text-port-warning', open: 'border-port-border text-port-text' };
+
+function LockButton({ lock, locking, stage, tone, label, title, iconOnly = false, className = '' }) {
+ const Icon = locking ? LockOpen : Lock;
+ return (
+ <button type="button" onClick={() => lock.toggle(locking, stage)} disabled={lock.busy} aria-pressed={!locking}
+ title={title} aria-label={iconOnly ? label : undefined} className={`${baseCls} ${toneCls[tone]} ${className}`}>
+ <Icon size={14} aria-hidden="true" />
+ {!iconOnly && label}
+ </button>
+ );
+}
/**
- * One tap to lock a shot (its clip can then be made) or to unlock it. A shot
- * edited since it was locked keeps its warning color and offers Lock.
+ * The tap that moves one shot through its locks. A still, card or code shot
+ * locks once. A video shot locks its still (ready to render), then, once it
+ * has a clip, its video; Unlock steps back one lock at a time. An edited lock
+ * keeps its warning color and says so in its title.
*/
-export function ShotLockButton({ sceneId, className = '' }) {
- const lock = useShotLock(sceneId);
+export function ShotLockButton({ scene, className = '' }) {
+ const lock = useShotLock(scene?.sceneId);
if (!lock) return null;
- const locked = lock.state === 'locked';
- const label = locked ? 'Unlock' : 'Lock';
+ const { still, clip } = lock;
+ const video = clip != null;
+ if (still !== 'locked') {
+ const changed = still === 'changed' ? 'Changed since locked. ' : '';
+ return <LockButton lock={lock} locking stage="still" tone={still === 'changed' ? 'changed' : 'open'} className={className}
+ label={video ? 'Lock still' : 'Lock'}
+ title={`${changed}${video ? 'Approve this still so its clip can be rendered' : 'Lock this shot'}`} />;
+ }
+ if (!video) return <LockButton lock={lock} locking={false} stage="still" tone="locked" label="Unlock" title="Locked. Tap to unlock." className={className} />;
+ if (clip === 'locked') return <LockButton lock={lock} locking={false} stage="video" tone="locked" label="Unlock video" title="Video locked: this shot can't change. Tap to unlock the video." className={className} />;
+ if (!scene.videoHistoryId) return <LockButton lock={lock} locking={false} stage="still" tone="locked" label="Unlock still" title="Still locked: make its clip, then lock the video. Tap to unlock the still." className={className} />;
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.state === 'changed' ? 'Changed since locked. Lock this shot again so its clip can be made.' : '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>
+ <span className={`inline-flex shrink-0 gap-1 ${className}`}>
+ <LockButton lock={lock} locking stage="video" tone={clip === 'changed' ? 'changed' : 'open'} label="Lock video" title={`${clip === 'changed' ? 'Changed since locked. ' : ''}Lock this clip so the shot can't change`} />
+ <LockButton lock={lock} locking={false} stage="still" tone="locked" iconOnly label="Unlock still" title="Still locked. Tap to unlock the still." />
+ </span>
);
}
diff --git a/client/src/components/musicVideo/ShotStepper.jsx b/client/src/components/musicVideo/ShotStepper.jsx
index 2c84d18995..fe1130c899 100644
--- a/client/src/components/musicVideo/ShotStepper.jsx
+++ b/client/src/components/musicVideo/ShotStepper.jsx
@@ -86,7 +86,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} />}
+ {onScreen && <ShotLockButton scene={onScreen} />}
</div>
);
}
diff --git a/client/src/components/musicVideo/ShotStepper.test.jsx b/client/src/components/musicVideo/ShotStepper.test.jsx
index 9f64cd90eb..0f5e4fb2e0 100644
--- a/client/src/components/musicVideo/ShotStepper.test.jsx
+++ b/client/src/components/musicVideo/ShotStepper.test.jsx
@@ -45,17 +45,44 @@ describe('ShotStepper shot lock', () => {
it('locks the shot on screen in one tap, and unlocks a locked one', () => {
const toggle = renderWith({ a: 'locked', b: 'changed' }, 5);
const lock = screen.getByRole('button', { name: 'Lock' });
- expect(lock).toHaveAttribute('title', 'Changed since locked. Lock this shot again so its clip can be made.');
+ expect(lock.title).toMatch(/^Changed since locked/);
fireEvent.click(lock);
- expect(toggle).toHaveBeenLastCalledWith('b', true);
+ expect(toggle).toHaveBeenLastCalledWith('b', true, 'still');
});
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);
+ expect(toggle).toHaveBeenLastCalledWith('a', false, 'still');
document.body.innerHTML = '';
render(<ShotStepper scenes={shots} time={1} onSeek={vi.fn()} />);
expect(screen.queryByRole('button', { name: /lock/i })).toBeNull();
});
+
+ // Uniquely catches a video shot skipping its clip lock, or a still lock with no way back.
+ it('walks a video shot from Lock still to Lock video to Unlock video', () => {
+ const scenes = [{ sceneId: 'a', startSec: 0 }, { sceneId: 'b', startSec: 4, videoHistoryId: 'clip-1' }];
+ const view = (locks, clips, time) => {
+ const toggle = vi.fn();
+ document.body.innerHTML = '';
+ render(<ShotLockContext.Provider value={{ locks, clips, toggle, busy: false }}><ShotStepper scenes={scenes} time={time} onSeek={vi.fn()} /></ShotLockContext.Provider>);
+ return toggle;
+ };
+ let toggle = view({ a: 'open', b: 'open' }, { a: 'open', b: 'open' }, 1);
+ fireEvent.click(screen.getByRole('button', { name: 'Lock still' }));
+ expect(toggle).toHaveBeenLastCalledWith('a', true, 'still');
+ // No clip yet: the still stays locked until its clip is made.
+ toggle = view({ a: 'locked', b: 'open' }, { a: 'open', b: 'open' }, 1);
+ expect(screen.queryByRole('button', { name: 'Lock video' })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Unlock still' }));
+ expect(toggle).toHaveBeenLastCalledWith('a', false, 'still');
+ toggle = view({ a: 'open', b: 'locked' }, { a: 'open', b: 'open' }, 5);
+ fireEvent.click(screen.getByRole('button', { name: 'Lock video' }));
+ expect(toggle).toHaveBeenLastCalledWith('b', true, 'video');
+ fireEvent.click(screen.getByRole('button', { name: 'Unlock still' }));
+ expect(toggle).toHaveBeenLastCalledWith('b', false, 'still');
+ toggle = view({ a: 'open', b: 'locked' }, { a: 'open', b: 'locked' }, 5);
+ fireEvent.click(screen.getByRole('button', { name: 'Unlock video' }));
+ expect(toggle).toHaveBeenLastCalledWith('b', false, 'video');
+ });
});
diff --git a/client/src/components/musicVideo/SongRevisionPanel.jsx b/client/src/components/musicVideo/SongRevisionPanel.jsx
index 64e85d7bad..810d291868 100644
--- a/client/src/components/musicVideo/SongRevisionPanel.jsx
+++ b/client/src/components/musicVideo/SongRevisionPanel.jsx
@@ -96,7 +96,7 @@ export default function SongRevisionPanel({ project, tracks = [], onUpdated, onF
<ol className="list-inside list-decimal space-y-1">
<li><Link className="text-port-accent" to={`/music-video/${project.id}/setup`}>Follow the re-time on the Song step, then replan the shots it flags.</Link></li>
<li><Link className="text-port-accent" to={`/music-video/${project.id}/produce#mv-composition`}>Regenerate or reimport the composition against the new audio.</Link> Imported source can contain a fuller timeline than the Storyboard; revise that source too.</li>
- <li><Link className="text-port-accent" to={`/music-video/${project.id}/produce#mv-review-proof`}>Rebuild and review proofs before the full video.</Link></li>
+ <li><Link className="text-port-accent" to={`/music-video/${project.id}/review#mv-draft-excerpts`}>Render a draft of the changed sections before the full video.</Link></li>
</ol>
</div>}
</>}
diff --git a/client/src/components/musicVideo/SongRevisionPanel.test.jsx b/client/src/components/musicVideo/SongRevisionPanel.test.jsx
index 13ec08d1ba..e52af6509f 100644
--- a/client/src/components/musicVideo/SongRevisionPanel.test.jsx
+++ b/client/src/components/musicVideo/SongRevisionPanel.test.jsx
@@ -34,7 +34,7 @@ describe('song revision UI', () => {
expect(await screen.findByText(/New master selected/)).toBeInTheDocument();
expect(screen.getByRole('link', { name: /Regenerate or reimport/ })).toHaveAttribute('href', '/music-video/fork/produce#mv-composition');
expect(screen.getByRole('link', { name: /Follow the re-time on the Song step/ })).toHaveAttribute('href', '/music-video/fork/setup');
- expect(screen.getByRole('link', { name: /Rebuild and review proofs/ })).toHaveAttribute('href', '/music-video/fork/produce#mv-review-proof');
+ expect(screen.getByRole('link', { name: /Render a draft of the changed sections/ })).toHaveAttribute('href', '/music-video/fork/review#mv-draft-excerpts');
expect(api.act.mock.calls.map((call) => call[1])).toEqual(['generate', 'select']);
});
it('recovers a revision completed while Setup was closed and adopts its saved fields', async () => {
diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsx
index 4646136f2a..f805b4821d 100644
--- a/client/src/components/musicVideo/stages/BoardStage.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.jsx
@@ -5,7 +5,7 @@ import BeatTimeline from '../BeatTimeline.jsx';
import ContactSheetButton from '../ContactSheetButton.jsx';
import SceneCard from '../SceneCard.jsx';
import ScenePoster from '../ScenePoster.jsx';
-import { ShotLockContext, SHOT_LOCK_LABELS } from '../ShotLock.jsx';
+import { ShotLockContext, SHOT_LOCK_LABELS, overallShotLock } from '../ShotLock.jsx';
import { shotNumbers } from '../ShotStepper.jsx';
import TreatmentPanel, { treatmentSummary } from '../TreatmentPanel.jsx';
import StageSection from '../StageSection.jsx';
@@ -34,14 +34,19 @@ function SceneMediaBadges({ scene, layered }) {
);
}
-/** Top-left mark on a Board thumbnail: locked, or changed since it was locked (an open shot shows none). */
+const LOCK_BADGED = ['locked', 'still', 'changed'];
+
+/**
+ * Top-left mark on a Board thumbnail: locked, a video shot with only its still
+ * locked ("Still"), 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;
+ if (!LOCK_BADGED.includes(state)) return null;
+ const Icon = state === 'changed' ? LockOpen : Lock;
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>
+ className={`port-media-overlay-strong absolute left-1 top-1 inline-flex items-center gap-0.5 rounded p-0.5 text-[10px] font-medium leading-none ${state === 'changed' ? 'text-port-warning' : 'text-port-success'}`}>
+ <Icon size={12} aria-hidden="true" />{state === 'still' && <span aria-hidden="true">Still</span>}<span className="sr-only">{SHOT_LOCK_LABELS[state]}</span>
</span>
);
}
@@ -56,7 +61,8 @@ function SceneLockBadge({ sceneId, state }) {
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 lockValue = useContext(ShotLockContext);
+ const shotLocks = Object.fromEntries(Object.entries(lockValue?.locks || {}).map(([id, still]) => [id, overallShotLock(still, lockValue.clips?.[id])]));
const [searchParams, setSearchParams] = useSearchParams();
const filter = parseSceneFilter(searchParams.get('scenes'));
const setFilter = (next) => setSearchParams((prev) => {
@@ -182,7 +188,7 @@ 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 ${shotName(scene)}`}
- aria-describedby={[['locked', 'changed'].includes(shotLocks[scene.sceneId]) && `scene-lock-${scene.sceneId}`,
+ aria-describedby={[LOCK_BADGED.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">
diff --git a/client/src/components/musicVideo/stages/BoardStage.test.jsx b/client/src/components/musicVideo/stages/BoardStage.test.jsx
index 5a8e764162..f3cb883e77 100644
--- a/client/src/components/musicVideo/stages/BoardStage.test.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.test.jsx
@@ -70,15 +70,18 @@ describe('BoardStage thumbnail media badges', () => {
});
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() }}>
+ it('marks locked, still-only and changed shots, and leaves open ones bare', () => {
+ const scenes = [scene(1), scene(2), scene(3), scene(4)];
+ render(<MemoryRouter><ShotLockContext.Provider value={{ locks: { s1: 'locked', s2: 'changed', s3: 'open', s4: 'locked' },
+ clips: { s1: 'locked', s2: 'open', s3: 'open', s4: '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 · Part 1')).toEqual(['Locked', 'Clip']);
expect(described('Open Shot 2 · Part 2')).toEqual(['Changed since locked', 'Clip']);
expect(described('Open Shot 3 · Part 3')).toEqual(['Clip']);
+ // A video shot whose still is locked but whose clip is not reads "Still".
+ expect(document.getElementById('scene-lock-s4')).toMatchObject({ title: 'Still locked, video not locked yet' });
});
});
diff --git a/client/src/components/musicVideo/stages/ProduceStage.jsx b/client/src/components/musicVideo/stages/ProduceStage.jsx
index 94be033bdf..6aba639c77 100644
--- a/client/src/components/musicVideo/stages/ProduceStage.jsx
+++ b/client/src/components/musicVideo/stages/ProduceStage.jsx
@@ -9,8 +9,8 @@ import { FOOTAGE_OPTIONAL_MODES } from '../../../lib/musicVideoStages.js';
/**
* Make: the picture for every shot, then the composition over it. A render
* style that draws its own picture (code, document, Eidoverse) keeps the
- * footage tools folded, since footage is optional there. The optional animated proof sits at the bottom of
- * the page with the other approvals; the autopilot and production runs live in
+ * footage tools folded, since footage is optional there. The optional animated proof shows at the bottom of
+ * the page only while a production run's pilot or open feedback needs it; the autopilot and production runs live in
* Project settings › Autopilot.
*/
export default function ProduceStage({ board }) {
diff --git a/client/src/hooks/useMusicVideoProductionReview.js b/client/src/hooks/useMusicVideoProductionReview.js
index 91d907602a..6082b20556 100644
--- a/client/src/hooks/useMusicVideoProductionReview.js
+++ b/client/src/hooks/useMusicVideoProductionReview.js
@@ -77,7 +77,7 @@ export default function useMusicVideoProductionReview({ project, replaceProject
{ 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 })),
+ lockShots: (sceneIds, locked, stage = 'still') => call(() => lockMusicVideoShots(project.id, { sceneIds, locked, stage })),
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 d6abf69d3b..33ebb69422 100644
--- a/client/src/lib/musicVideoStages.js
+++ b/client/src/lib/musicVideoStages.js
@@ -647,6 +647,17 @@ function unlockedDetail(readiness, item) {
const FEEDBACK_PROBLEM = /^Resolve (art|storyboard|proof) feedback for /;
const notFeedback = (text) => !FEEDBACK_PROBLEM.test(text);
+/**
+ * Whether Make shows the animated proof: only while something needs it — a
+ * production run parked on its pilot proof before bulk generation, a proof
+ * rendering, or open change requests on one. The final render never waits on it.
+ */
+export function proofReviewInUse(project, readiness, { proofActive = false } = {}) {
+ const run = currentProductionRun(project);
+ return proofActive || openChangeRequests(project, 'proof').length > 0
+ || (!!run && RESUMABLE_RUN_STATUSES.has(run.status) && !!run.pilot?.scenes?.length && !readiness?.proof?.approved);
+}
+
/** The open change requests on one approval stage ('art' | 'storyboard' | 'proof'). */
export const openChangeRequests = (project, stage) => (project?.productionReview?.feedback || [])
.filter((f) => f.stage === stage && f.decision === 'request-changes' && !f.resolvedAt);
@@ -843,7 +854,7 @@ export function stageChecklist(stageId, project, readiness = project?.production
}
case 'produce': {
// Make: footage (unless the render style draws its own picture), the
- // composition over it, then the optional proof (see deriveStages).
+ // composition over it, then the optional proof while a run needs it (see proofReviewInUse).
const items = [];
if (!FOOTAGE_OPTIONAL_MODES.has(mode)) {
const layered = isLayeredComposition(project);
@@ -853,8 +864,9 @@ export function stageChecklist(stageId, project, readiness = project?.production
action: footageDone ? null : { label: 'Make the footage', anchor: 'mv-generation' } });
}
const proofApproval = approval('proof', 'Animated proof', null);
- // Optional: shown so it can be found, never counted toward the step being done.
- const proof = { ...proofApproval, label: proofApproval.done ? proofApproval.label : 'Animated proof (optional)', optional: true, detail: null };
+ // Optional: never counted toward the step being done.
+ const proof = proofReviewInUse(project, readiness)
+ ? [{ ...proofApproval, label: proofApproval.done ? proofApproval.label : 'Animated proof (optional)', optional: true, detail: null }] : [];
const composition = project.composition || {};
let work = null;
if (mode === 'composed') work = { id: 'composition', label: 'Timed typography added', done: (composition.textCues || []).length > 0, action: { label: 'Add typography', anchor: 'mv-typo-font' } };
@@ -869,7 +881,7 @@ export function stageChecklist(stageId, project, readiness = project?.production
action: done ? null : { label: 'Open Code Video', anchor: 'mv-code-section' } };
}
const proofFeedback = feedbackItem(project, 'proof', readiness, { optional: true });
- return [...items, ...(work ? [work] : []), ...(proofFeedback ? [proofFeedback] : []), proof];
+ return [...items, ...(work ? [work] : []), ...(proofFeedback ? [proofFeedback] : []), ...proof];
}
case 'review':
return [{
diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.js
index 754361c4d0..a22e016614 100644
--- a/client/src/lib/musicVideoStages.test.js
+++ b/client/src/lib/musicVideoStages.test.js
@@ -159,7 +159,7 @@ describe('deriveStages / deriveNextAction', () => {
expect(deriveStages(withMode({ mode: 'composed', textCues: [] })).current).toBe('produce');
// Eidoverse needs no footage; Make waits on a saved scene.
expect(deriveStages(withMode({ mode: 'eidoverse' })).current).toBe('produce');
- expect(stageChecklist('produce', withMode({ mode: 'eidoverse' }), APPROVED).map((i) => [i.id, i.done])).toEqual([['composition', false], ['approve-proof', true]]);
+ expect(stageChecklist('produce', withMode({ mode: 'eidoverse' }), APPROVED).map((i) => [i.id, i.done])).toEqual([['composition', false]]);
expect(stageChecklist('produce', withMode({ mode: 'eidoverse' }), APPROVED)[0])
.toMatchObject({ label: 'Save the Eidoverse scene', done: false, action: { anchor: 'mv-eidoverse-scene' } });
const saved = withMode({ mode: 'eidoverse', eidoverseScene: { inlineScript: 'scene()' } });
@@ -183,7 +183,7 @@ describe('deriveStages / deriveNextAction', () => {
it('does not require scene footage for code-rendered or document projects', () => {
const bare = { productionReadiness: APPROVED, id: 'p', trackId: 't1', audioAnalysis: ANALYSIS, scenes: [scene({ referenceImageId: null, videoHistoryId: null })] };
// Make lists no footage row for them; only the composition and its proof remain.
- expect(stageChecklist('produce', { ...bare, composition: { mode: 'code' } }, APPROVED).map((i) => i.id)).toEqual(['composition', 'approve-proof']);
+ expect(stageChecklist('produce', { ...bare, composition: { mode: 'code' } }, APPROVED).map((i) => i.id)).toEqual(['composition']);
const doc = { ...bare, composition: { mode: 'document' } };
expect(deriveStages(doc).current).toBe('produce');
expect(deriveNextAction(doc).label).toBe('Attach a composition');
@@ -244,7 +244,7 @@ describe('following the tab order', () => {
expect(deriveStages(project, readinessFor(project, approvals)).current).toBe('publish');
});
- it('a typography edit after proof approval keeps Make done and lists the proof as optional', () => {
+ it('a typography edit after proof approval keeps Make done and leaves the unused proof off its list', () => {
const composition = { mode: 'composed', textCues: [{ id: 'c1', text: 'Hello', startSec: 0, endSec: 2 }] };
const project = { id: 'p', trackId: 't1', audioAnalysis: ANALYSIS, scenes: [scene()], composition };
const approvals = { art: true, storyboard: true, approvedComposition: JSON.stringify(composition) };
@@ -256,7 +256,7 @@ describe('following the tab order', () => {
.toMatchObject({ board: 'done', produce: 'done', review: 'active' });
expect(deriveNextAction(edited, { readiness })).toMatchObject({ id: 'render-final' });
expect(stageChecklist('produce', edited, readiness).map((i) => [i.id, i.done, !!i.optional, i.label]))
- .toEqual([['footage', true, false, 'Footage for every shot (1 of 1)'], ['composition', true, false, 'Timed typography added'], ['approve-proof', false, true, 'Animated proof (optional)']]);
+ .toEqual([['footage', true, false, 'Footage for every shot (1 of 1)'], ['composition', true, false, 'Timed typography added']]);
});
it('keeps the header on the footage until it is in, unless a run is parked on its pilot proof', () => {
@@ -266,6 +266,9 @@ describe('following the tab order', () => {
// A run parked on its pilot proof before paid bulk generation still sends the director to that proof.
const parked = { ...project, productionRuns: [run({ status: 'blocked', pilot: { scenes: [{ sceneId: 's1' }] } })] };
expect(deriveNextAction(parked, { readiness })).toMatchObject({ id: 'review-production', stage: 'produce', anchor: 'mv-review-proof' });
+ // Make lists the optional proof only while such a run needs it.
+ expect(stageChecklist('produce', parked, readiness).map((i) => i.label)).toContain('Animated proof (optional)');
+ expect(stageChecklist('produce', project, readiness).map((i) => i.label)).not.toContain('Animated proof (optional)');
const parkedNoPilot = { ...project, productionRuns: [run({ status: 'blocked' })] };
expect(deriveNextAction(parkedNoPilot, { readiness })).toMatchObject({ id: 'resume-production' });
});
@@ -476,10 +479,10 @@ describe('stageChecklist', () => {
expect(stageChecklist('produce', castProject({ composition: { mode: 'composed' }, scenes: [scene(), scene({ sceneId: 's2', videoHistoryId: null, visualLayer: 'code', startSec: 0, endSec: 2 })] }), APPROVED)[0])
.toMatchObject({ id: 'footage', label: 'Footage for every shot (2 of 2)', done: true });
// A code render draws its own picture: no footage row, just its composition and proof.
- expect(stageChecklist('produce', castProject({ composition: { mode: 'code' } }), APPROVED).map((i) => i.id)).toEqual(['composition', 'approve-proof']);
+ expect(stageChecklist('produce', castProject({ composition: { mode: 'code' } }), APPROVED).map((i) => i.id)).toEqual(['composition']);
// The proof closes Make, after the composition work it is judged over.
expect(stageChecklist('produce', castProject({ scenes: [scene()], composition: { mode: 'composed', textCues: [] } }), APPROVED).map((i) => [i.id, i.done]))
- .toEqual([['footage', true], ['composition', false], ['approve-proof', true]]);
+ .toEqual([['footage', true], ['composition', false]]);
});
it('asks for the storyboard review, not a board plan, when a document storyboard brings its own shots', () => {
const project = { id: 'p', trackId: 't1', audioAnalysis: ANALYSIS, ...LYRICS, scenes: [], composition: { mode: 'document', document: { directory: 'd' } },
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 925382fde4..7e4a94070a 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -97,7 +97,7 @@ import { deriveAttentionItems } from '../lib/musicVideoAttention.js';
import { latestMusicVideoReviewDraft } from '../../../server/lib/musicVideoReviewDraft.js';
import { useMusicVideoReviewDraft } from '../hooks/useMusicVideoReviewDraft.js';
import {
- deriveNextAction, deriveStages, describeProjectStatus, listPreviewSources, projectSpend, resolveStageParam, stageChecklist, stepNotes, autopilotStatus, compareMusicVideoProjectsNewestFirst,
+ deriveNextAction, deriveStages, describeProjectStatus, listPreviewSources, projectSpend, resolveStageParam, stageChecklist, stepNotes, autopilotStatus, compareMusicVideoProjectsNewestFirst, proofReviewInUse,
} from '../lib/musicVideoStages.js';
import { groupMusicVideoProjects } from '../lib/musicVideoProjectList.js';
import { AUTONOMOUS_VIEWABLE_STAGES } from '../lib/musicVideoAutonomous.js';
@@ -300,7 +300,8 @@ export default function MusicVideo() {
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 }
+ ? { locks: shotLocks, clips: productionReview.readiness.storyboard.clipLocks || null,
+ toggle: (sceneId, lock, stage) => productionReview.lockShots([sceneId], lock, stage), 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 });
@@ -1574,7 +1575,9 @@ export default function MusicVideo() {
headerAnchor={nextAction?.kind === 'goto' ? nextAction.anchor : null}
/>
)}
- review={APPROVAL_STAGE_BY_TAB[activeStage] ? (
+ // Make shows the optional proof only while a run's pilot or open feedback needs it.
+ review={APPROVAL_STAGE_BY_TAB[activeStage] && (activeStage !== 'produce'
+ || proofReviewInUse(selected, productionReview.readiness, { proofActive: productionReview.proof.active })) ? (
<ProductionReviewPanel
key={`${selected.id}-${activeStage}`}
project={selected}
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index a9be86ab26..e0f5e4cd5d 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -2688,7 +2688,7 @@ describe('MusicVideo stage tabs (#9243)', () => {
}
});
- it('leads Storyboard and Make with the player and their approval, closes Look with its approval, keeps the run in Project settings and unsaved planning edits across steps', async () => {
+ it('leads Storyboard with the player and its approval, leaves an unused proof off Make, closes Look with its approval, keeps the run in Project settings and unsaved planning edits across steps', async () => {
listMusicVideoProjects.mockResolvedValue([{ ...PROJECT_WITH_CLIP,
autonomousRun: { status: 'needs-human', stage: 'video', output: {}, brief: {} },
}]);
@@ -2701,7 +2701,7 @@ describe('MusicVideo stage tabs (#9243)', () => {
const castDraft = within(review).getByLabelText('Cast guide');
fireEvent.change(castDraft, { target: { value: 'Example unsaved cast direction' } });
- const approvals = { 'cast-sets': 'Art direction', board: 'Lyric-timed storyboard', produce: 'Animated proof' };
+ const approvals = { 'cast-sets': 'Art direction', board: 'Lyric-timed storyboard' };
for (const stage of ['board', 'produce', 'cast-sets']) {
await openStage(stage);
const panel = screen.getByRole('tabpanel');
@@ -2709,6 +2709,11 @@ describe('MusicVideo stage tabs (#9243)', () => {
const title = selectedTab().textContent.split(',')[0];
expect(within(panel).getByRole('heading', { level: 3, name: title })).toBeInTheDocument();
expect(panel).toHaveAccessibleName(title);
+ // Make shows the optional proof only while a production run needs it.
+ if (stage === 'produce') {
+ expect(within(panel).queryByRole('region', { name: 'Production review' })).toBeNull();
+ continue;
+ }
const stageReview = within(panel).getByRole('region', { name: 'Production review' });
if (stage === 'cast-sets') {
// Look is reviewed through its visual guide: the step's work comes first and the approval closes it.
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index 24a1516a3d..5577db4ac4 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -1361,6 +1361,8 @@ export const musicVideoProductionImportSchema = z.object({ source: z.string().mi
export const musicVideoShotLockSchema = z.object({
sceneIds: z.array(z.string().min(1).max(200)).min(1).max(500),
locked: z.boolean(),
+ // A video shot locks its still first (ready to render), then its clip.
+ stage: z.enum(['still', 'video']).optional(),
}).strict();
export const musicVideoProductionApprovalSchema = z.object({
stage: z.enum(['art', 'storyboard', 'proof']), basis: z.string().min(1).max(128),
diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.js
index f87ffe511d..21c41e4830 100644
--- a/server/services/musicVideo/autonomousService.test.js
+++ b/server/services/musicVideo/autonomousService.test.js
@@ -1366,12 +1366,12 @@ describe('autopilot clears the gates it was granted on its own', () => {
});
// Uniquely catches a run granted the storyboard parking for the director when a lyric edit stales that approval mid-production.
- it('approves a storyboard a lyric edit staled again and resumes production', async () => {
+ it('approves a storyboard an edit staled again and resumes production', async () => {
analyzed({ productionReview: { draft: { ...GUIDE, lyricsMode: 'instrumental', timingNotes: 'Synthetic instrumental master checked.', storyboard: [shot] } } });
await service.startAutonomousVideo({ prompt: 'p', tools: ['image:local'], ...GRANT[0] }, GRANT[1]);
await vi.waitFor(() => expect(doubles.startProduction).toHaveBeenCalledOnce());
const project = store.get('mv-auto');
- project.scenes[0].lyricText = 'the dancer turns toward the light';
+ project.scenes[0].prompt = 'the dancer turns toward the light';
project.productionRuns = [{ id: 'mvpr-1', status: 'blocked', createdAt: new Date().toISOString() }];
expect(actual.productionReadiness(project).storyboard.approved).toBe(false);
doubles.approveProductionReview.mockClear();
diff --git a/server/services/musicVideo/continueShot.js b/server/services/musicVideo/continueShot.js
index 74d10ec9fa..906dd65abd 100644
--- a/server/services/musicVideo/continueShot.js
+++ b/server/services/musicVideo/continueShot.js
@@ -20,6 +20,7 @@ import { findFfmpeg, probeVideoGeometry, runFfmpegProcess, safeUnder } from '../
import { previousShot, sceneClipOutFrameSec } from '../../lib/musicVideoHandoffFrame.js';
import { getHistoryItem } from '../videoGen/history.js';
import { appendSceneTakes, getProject, selectSceneTake } from './projects.js';
+import { assertClipUnlocked } from './productionReview.js';
const refuse = (message, code, status = 409) => new ServerError(message, { status, code });
@@ -32,6 +33,7 @@ export async function continueFromPreviousShot(projectId, sceneId, { keepStillAs
if (!project) throw refuse('Project not found', 'NOT_FOUND', 404);
const scene = project.scenes?.find((s) => s.sceneId === sceneId);
if (!scene) throw refuse('Scene not found', 'NOT_FOUND', 404);
+ assertClipUnlocked(project, sceneId);
const previous = previousShot(project, sceneId);
if (!previous) throw refuse('This is the first shot, so there is no previous shot to continue from', 'MUSIC_VIDEO_NO_PREVIOUS_SHOT');
const entry = previous.videoHistoryId ? await getHistoryItem(previous.videoHistoryId) : null;
diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.js
index 6da65b5724..dd9adb5aad 100644
--- a/server/services/musicVideo/productionReview.js
+++ b/server/services/musicVideo/productionReview.js
@@ -10,6 +10,7 @@ import { cameraVarietyReport } from './shotCamera.js';
import { overlayTextReport } from './overlayText.js';
import { musicVideoAspect } from '../../lib/musicVideoAspect.js';
import { lyricCueSpan } from './timedText.js';
+import { isLayeredComposition, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
const artifact = (project, id) => (project.devArtifacts || []).find(a => a.id === id && !a.deleted);
const artifactBasis = a => a ? { id: a.id, version: a.version, file: a.file } : null;
const source = p => {
@@ -113,9 +114,9 @@ export function seedArtDraft(project, stage = project.castAndSets) {
/**
* 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.
+ * Automation may not change any of it on a locked shot (preserveAutomatedShotLocks).
+ * The selected clip is the shot's output, not an input. A lock saved before
+ * still locks ignored timing (no `v`) still binds to this whole basis.
*/
function shotApprovalBasis(project, scene) {
const row = (project.productionReview?.draft?.storyboard || []).find(shot => shot?.sceneId === scene.sceneId);
@@ -126,6 +127,26 @@ function shotApprovalBasis(project, scene) {
row: row ? { action: row.action, staging: row.staging, camera: row.camera, transition: row.transition, lyricCueIds: row.lyricCueIds } : null });
}
+/**
+ * What a still lock (`productionReview.shotApprovals[sceneId]`, `v: 2`) binds
+ * to: the shot's render inputs without its timing. Moving a cut, and the lyric
+ * that moves with it, keeps the still approved; a locked clip refuses the move
+ * instead (assertClipUnlocked), since its span is part of the clip.
+ */
+function stillLockBasis(project, scene) {
+ const row = (project.productionReview?.draft?.storyboard || []).find(shot => shot?.sceneId === scene.sceneId);
+ const { prompt, framePrompt, visualIntent, camera, direction, referenceImageId, endImageId,
+ shotMode, performanceSpeaker, performanceStyle, visualLayer, loop } = scene;
+ return hash({ prompt, framePrompt, visualIntent, camera, direction, referenceImageId, endImageId,
+ shotMode, performanceSpeaker, performanceStyle, visualLayer, loop,
+ row: row ? { action: row.action, staging: row.staging, camera: row.camera, transition: row.transition } : null });
+}
+
+const STILL_LOCK_VERSION = 2;
+const stillLock = (project, scene, fields) => ({ ...fields, basis: stillLockBasis(project, scene), v: STILL_LOCK_VERSION });
+const stillLockHolds = (project, scene, approval) => approval.v === STILL_LOCK_VERSION
+ ? approval.basis === stillLockBasis(project, scene) : approval.basis === shotApprovalBasis(project, scene);
+
/** Is the whole-board storyboard approval (given before shots locked one by one, or by Approve all) current? */
const boardApprovalCovers = project => storyboardApprovalCurrent(project.productionReview?.approvals?.storyboard, productionReviewBasis(project));
@@ -140,10 +161,54 @@ export function shotLocks(project) {
const covered = (project.scenes || []).some(scene => !approvals[scene.sceneId]) && boardApprovalCovers(project);
return Object.fromEntries((project.scenes || []).map(scene => {
const approval = approvals[scene.sceneId];
- return [scene.sceneId, !approval ? (covered ? 'locked' : 'open') : approval.basis === shotApprovalBasis(project, scene) ? 'locked' : 'changed'];
+ return [scene.sceneId, !approval ? (covered ? 'locked' : 'open') : stillLockHolds(project, scene, approval) ? 'locked' : 'changed'];
+ }));
+}
+
+/**
+ * Whether a shot locks in two steps: a generated clip locks its still (ready to
+ * render), then the clip. Stills, cards, code shots and clips rendered from code
+ * have nothing more to approve after their first lock.
+ */
+const shotHasVideoStage = (project, scene) => !scene.codeClip
+ && sceneVisualLayer(scene, { layered: isLayeredComposition(project) }) === 'footage';
+
+/**
+ * Each video shot's clip lock (`productionReview.clipApprovals[sceneId]`):
+ * `locked` while its still stays locked and the clip it locked is still the
+ * selected one, `changed` once either moved, `open` before it is locked. Null
+ * for a shot with no video step, and for a document storyboard.
+ */
+export function clipLocks(project, locks = shotLocks(project)) {
+ if (!locks) return null;
+ const approvals = project.productionReview?.clipApprovals || {};
+ return Object.fromEntries((project.scenes || []).map(scene => {
+ if (!shotHasVideoStage(project, scene)) return [scene.sceneId, null];
+ const approval = approvals[scene.sceneId];
+ return [scene.sceneId, !approval ? 'open'
+ : locks[scene.sceneId] === 'locked' && approval.videoHistoryId === scene.videoHistoryId ? 'locked' : 'changed'];
}));
}
+const clipLocked = (project, sceneId) => project.productionReview?.clipApprovals?.[sceneId]
+ && clipLocks(project)?.[sceneId] === 'locked';
+
+/** What a locked clip freezes: the inputs it was rendered from, and the selected clip itself. */
+const CLIP_LOCKED_FIELDS = ['prompt', 'framePrompt', 'visualIntent', 'camera', 'direction', 'startSec', 'endSec', 'lyricText',
+ 'referenceImageId', 'endImageId', 'shotMode', 'performanceSpeaker', 'performanceStyle', 'visualLayer', 'loop', 'videoHistoryId', 'codeClip'];
+
+/**
+ * Refuse a change to a shot whose video is locked: `patch` is a scene patch
+ * (only the fields that would change what it shows count), or null for a
+ * change that replaces the shot (delete, split, merge, a new take or job).
+ */
+export function assertClipUnlocked(project, sceneId, patch = null) {
+ if (!clipLocked(project, sceneId)) return;
+ const scene = project.scenes.find(s => s.sceneId === sceneId);
+ if (patch && !CLIP_LOCKED_FIELDS.some(key => key in patch && hash(patch[key] ?? null) !== hash(scene[key] ?? null))) return;
+ throw new ServerError('This shot\'s video is locked. Unlock the video to change it.', { status: 409, code: 'MUSIC_VIDEO_SHOT_LOCKED', context: { sceneId } });
+}
+
/** Apply an automation proposal under the store lock; locked render inputs stay intact. */
export function preserveAutomatedShotLocks(before, after, source) {
const locks = shotLocks(before) || {};
@@ -155,20 +220,21 @@ export function preserveAutomatedShotLocks(before, after, source) {
// hash so existing shot locks keep their cross-version meaning.
const repairBasis = shot => hash({ stillFixes: shot.stillFixes, clipFixes: shot.clipFixes });
return !proposed || shotApprovalBasis(before, scene) !== shotApprovalBasis(after, proposed)
- || repairBasis(scene) !== repairBasis(proposed);
+ || repairBasis(scene) !== repairBasis(proposed)
+ || (clipLocked(before, scene.sceneId) && proposed.videoHistoryId !== scene.videoHistoryId);
});
// Materialize legacy whole-board locks before an open shot's edit can stale
// that approval. No new approval is granted: these shots were already locked.
const shotApprovals = { ...after.productionReview?.shotApprovals };
for (const scene of locked) shotApprovals[scene.sceneId] = before.productionReview?.shotApprovals?.[scene.sceneId]
- || { ...before.productionReview?.approvals?.storyboard, basis: shotApprovalBasis(before, scene), fromBoardApproval: true };
+ || stillLock(before, scene, { ...before.productionReview?.approvals?.storyboard, fromBoardApproval: true });
let next = { ...after, productionReview: { ...after.productionReview, shotApprovals } };
if (!rejected.length) return { project: next, rejected: false };
// A merge/re-plan may replace IDs or spans. Refuse the whole board mutation
// rather than splice an old locked shot into an overlapping new timeline.
next = { ...next, composition: before.composition, scenes: before.scenes.map(scene => {
const output = after.scenes?.find(candidate => candidate.sceneId === scene.sceneId);
- return output ? { ...scene, takes: output.takes, videoHistoryId: output.videoHistoryId } : scene;
+ return output ? { ...scene, takes: output.takes, videoHistoryId: clipLocked(before, scene.sceneId) ? scene.videoHistoryId : output.videoHistoryId } : scene;
}), productionReview: { ...next.productionReview,
draft: before.productionReview?.draft } };
for (const scene of rejected) {
@@ -181,30 +247,45 @@ export function preserveAutomatedShotLocks(before, after, source) {
return { project: next, rejected: true };
}
-/** 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 }) {
+/**
+ * Lock or unlock Board shots for the director. A lock binds to the shot as it is now.
+ * `stage: 'video'` locks or unlocks a video shot's selected clip, which needs its
+ * still locked first; unlocking a still unlocks its clip too.
+ */
+export function setShotLocks(project, { sceneIds, locked, stage = 'still', 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' });
+ if (stage === 'video') return setClipLocks(project, scenes, { locked, reviewer, approvedBy });
const approvals = { ...project.productionReview?.shotApprovals };
+ // A lock saved before timing left the still basis moves to the new basis while it still holds,
+ // so a later cut move keeps it.
+ for (const scene of project.scenes || []) {
+ const held = approvals[scene.sceneId];
+ if (held && held.v !== STILL_LOCK_VERSION && stillLockHolds(project, scene, held)) approvals[scene.sceneId] = stillLock(project, scene, held);
+ }
+ const clipApprovals = { ...project.productionReview?.clipApprovals };
const approvedAt = new Date().toISOString();
// A current whole-board approval becomes a lock on every shot it covers first, so withdrawing it
// below (or a later edit staling it) never opens the shots the director did not touch.
if (boardApprovalCovers(project)) {
const carried = project.productionReview.approvals.storyboard;
for (const scene of project.scenes || []) {
- if (!approvals[scene.sceneId]) approvals[scene.sceneId] = { basis: shotApprovalBasis(project, scene), approvedAt: carried.approvedAt || approvedAt, fromBoardApproval: true,
- ...(carried.approvedBy ? { approvedBy: carried.approvedBy } : {}), ...(carried.reviewer ? { reviewer: structuredClone(carried.reviewer) } : {}) };
+ if (!approvals[scene.sceneId]) approvals[scene.sceneId] = stillLock(project, scene, { approvedAt: carried.approvedAt || approvedAt, fromBoardApproval: true,
+ ...(carried.approvedBy ? { approvedBy: carried.approvedBy } : {}), ...(carried.reviewer ? { reviewer: structuredClone(carried.reviewer) } : {}) });
}
}
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) } : {}) };
+ if (!locked) {
+ delete approvals[scene.sceneId];
+ delete clipApprovals[scene.sceneId];
+ } else approvals[scene.sceneId] = stillLock(project, scene, { approvedAt,
+ ...(approvedBy ? { approvedBy } : {}), ...(reviewer ? { reviewer: structuredClone(reviewer) } : {}) });
}
- const review = { ...project.productionReview, shotApprovals: approvals };
+ const review = { ...project.productionReview, shotApprovals: approvals,
+ ...(project.productionReview?.clipApprovals ? { clipApprovals } : {}) };
// 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) {
@@ -214,6 +295,21 @@ export function setShotLocks(project, { sceneIds, locked, reviewer = null, appro
return { ...project, productionReview: review };
}
+function setClipLocks(project, scenes, { locked, reviewer, approvedBy }) {
+ const stills = shotLocks(project);
+ const clipApprovals = { ...project.productionReview?.clipApprovals };
+ const approvedAt = new Date().toISOString();
+ for (const scene of scenes) {
+ if (!locked) { delete clipApprovals[scene.sceneId]; continue; }
+ if (!shotHasVideoStage(project, scene)) throw new ServerError('This shot has no video to lock.', { status: 409, code: 'MUSIC_VIDEO_NO_VIDEO_STAGE' });
+ if (stills[scene.sceneId] !== 'locked') throw new ServerError('Lock this shot\'s still before its video.', { status: 409, code: 'MUSIC_VIDEO_APPROVAL_REQUIRED' });
+ if (!scene.videoHistoryId) throw new ServerError('Make and choose this shot\'s clip before locking its video.', { status: 409, code: 'MUSIC_VIDEO_NO_CLIP' });
+ clipApprovals[scene.sceneId] = { videoHistoryId: scene.videoHistoryId, approvedAt,
+ ...(approvedBy ? { approvedBy } : {}), ...(reviewer ? { reviewer: structuredClone(reviewer) } : {}) };
+ }
+ return { ...project, productionReview: { ...project.productionReview, clipApprovals } };
+}
+
/**
* 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
@@ -472,6 +568,7 @@ export function productionReadiness(project) {
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 clips = clipLocks(project, locks);
const storyboardApproved = !boardProblems.length && (byShot ? scenes.length > 0 && !unlocked.length
: storyboardApprovalCurrent(review.approvals?.storyboard, basis));
const camera = storyboardCameraReport(scenes, documentShots ? null : boardStoryboard(project));
@@ -489,7 +586,9 @@ export function productionReadiness(project) {
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),
- shotLocks: locks, unlocked: byShot ? unlocked : [] },
+ shotLocks: locks, unlocked: byShot ? unlocked : [], clipLocks: clips,
+ // Video shots whose clip is not locked yet: the board is finished when every shot is fully locked.
+ clipsUnlocked: clips ? Object.keys(clips).filter(id => clips[id] && clips[id] !== 'locked') : [] },
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.
@@ -579,7 +678,7 @@ export function assertShotApproval(project, sceneId) {
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.',
+ : 'Lock this shot\'s still (or approve the storyboard) before making its clip.',
{ status: 409, code: 'MUSIC_VIDEO_APPROVAL_REQUIRED', context: { stage: 'storyboard', sceneId, readiness } });
}
diff --git a/server/services/musicVideo/productionReview.storyboard.test.js b/server/services/musicVideo/productionReview.storyboard.test.js
index 9cc15a9a49..4403a312f5 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, assertShotApproval, setShotLocks } from './productionReview.js';
+import { productionReadiness, productionAlignmentBasis, approveProductionStage, carryProductionApprovals, assertShotApproval, assertClipUnlocked, setShotLocks } from './productionReview.js';
import { applySceneUpdate, mergeNextScene, removeScene } from './projectsLogic.js';
const WORD_PROBLEM = /bounded, positive-duration word timings/;
@@ -91,18 +91,21 @@ describe('the director trimming an approved storyboard', () => {
return approveProductionStage(art, { stage: 'storyboard', basis: productionReadiness(art).basis.storyboard });
}
- // 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', () => {
+ // Uniquely catches cutting a shot, or moving a cut, unlocking an approved still.
+ it('keeps every still locked through a cut and the shot stretched over the gap, and unlocks only a changed picture', () => {
const cut = removeScene(approvedBoard(), 's2');
expect(cut.productionReview.draft.storyboard.map((shot) => shot.sceneId)).toEqual(['s1', 's3']);
expect(productionReadiness(cut).storyboard.shotLocks).toEqual({ s1: 'locked', s3: 'locked' });
+ // Moving a cut keeps the still approved: its timing is the clip's, which a video lock guards.
const { project: stretched } = applySceneUpdate(cut, 's1', { endSec: 6 });
- expect(productionReadiness(stretched).storyboard).toMatchObject({ approved: false, unlocked: ['s1'], shotLocks: { s1: 'changed', s3: 'locked' } });
+ expect(productionReadiness(stretched).storyboard).toMatchObject({ approved: true, unlocked: [], shotLocks: { s1: 'locked', s3: 'locked' } });
+ const { project: redrawn } = applySceneUpdate(stretched, 's1', { framePrompt: 'Close-up, desk lamp' });
+ expect(productionReadiness(redrawn).storyboard).toMatchObject({ approved: false, unlocked: ['s1'], shotLocks: { s1: 'changed', s3: 'locked' } });
});
- it('unlocks only the merged shot when two shots are joined', () => {
+ it('keeps the merged shot still locked when two shots are joined', () => {
const { project: merged } = mergeNextScene(approvedBoard(), 's1');
- expect(productionReadiness(merged).storyboard.shotLocks).toEqual({ s1: 'changed', s3: 'locked' });
+ expect(productionReadiness(merged).storyboard.shotLocks).toEqual({ s1: 'locked', s3: 'locked' });
});
// Uniquely catches a lyric anchor dropped from a row slipping past the board check.
@@ -173,7 +176,7 @@ describe('locking shots one at a time', () => {
const legacy = { ...approved, productionReview: review };
expect(productionReadiness(legacy).storyboard).toMatchObject({ approved: true, unlocked: [] });
// The shape already saved by the first release: one shot locked on top of the old approval.
- const s2 = { basis: setShotLocks(legacy, { sceneIds: ['s2'], locked: true }).productionReview.shotApprovals.s2.basis };
+ const s2 = setShotLocks(legacy, { sceneIds: ['s2'], locked: true }).productionReview.shotApprovals.s2;
expect(productionReadiness({ ...legacy, productionReview: { ...review, shotApprovals: { s2 } } }).storyboard)
.toMatchObject({ approved: true, unlocked: [] });
// Locking now carries the approval onto every shot, so it outlives the approval going stale.
@@ -191,6 +194,26 @@ describe('locking shots one at a time', () => {
expect(productionReadiness(open).storyboard.approved).toBe(false);
expect(() => assertShotApproval(open, 's1')).toThrow(/Lock this shot/);
});
+
+ // Uniquely catches a video shot locking in one step, or a still/card shot asking for a video lock.
+ it('locks a video shot still first, then its clip, and a card shot once', () => {
+ const art = artApproved();
+ const composed = { ...art, composition: { mode: 'composed' }, scenes: art.scenes.map(s => s.sceneId === 's3' ? { ...s, visualLayer: 'card' } : s) };
+ const still = setShotLocks(composed, { sceneIds: ['s2', 's3'], locked: true });
+ expect(productionReadiness(still).storyboard).toMatchObject({ clipLocks: { s1: 'open', s2: 'open', s3: null }, clipsUnlocked: ['s1', 's2'] });
+ expect(() => setShotLocks(still, { sceneIds: ['s2'], locked: true, stage: 'video' })).toThrow(/choose this shot's clip/);
+ expect(() => setShotLocks(still, { sceneIds: ['s3'], locked: true, stage: 'video' })).toThrow(/no video/);
+ expect(() => setShotLocks(composed, { sceneIds: ['s1'], locked: true, stage: 'video' })).toThrow(/still before its video/);
+ const { project: rendered } = applySceneUpdate(still, 's2', { videoHistoryId: 'clip-1' });
+ const video = setShotLocks(rendered, { sceneIds: ['s2'], locked: true, stage: 'video' });
+ expect(productionReadiness(video).storyboard).toMatchObject({ clipLocks: { s2: 'locked' }, clipsUnlocked: ['s1'] });
+ expect(() => assertClipUnlocked(video, 's2', { prompt: 'New motion' })).toThrow(/video is locked/);
+ expect(() => assertClipUnlocked(video, 's2', { textZone: 'upper' })).not.toThrow();
+ expect(() => assertClipUnlocked(video, 's1')).not.toThrow();
+ // Unlocking the still takes the clip lock with it.
+ const reopened = setShotLocks(video, { sceneIds: ['s2'], locked: false });
+ expect(productionReadiness(reopened).storyboard.clipLocks.s2).toBe('open');
+ });
});
describe('derived shot transitions', () => {
diff --git a/server/services/musicVideo/productionReviewService.js b/server/services/musicVideo/productionReviewService.js
index 92e3709ab4..ca1b9f47ed 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, assertShotApproval, setShotLocks, recordProductionFeedback, resolveProductionFeedback, revertApprovedInput } from './productionReview.js';
+import { productionReadiness, boardStoryboard, seedArtDraft, productionReviewBasis, productionAlignmentBasis, documentStoryboardBasis, approveProductionStage, assertProductionApproval, assertShotApproval, assertClipUnlocked, setShotLocks, recordProductionFeedback, resolveProductionFeedback, revertApprovedInput } from './productionReview.js';
const reviewProcessId = randomUUID();
@@ -34,6 +34,8 @@ export async function assertMusicVideoSceneReview(tag, kind = null) {
if (!tag?.projectId || !tag.sceneId) return;
const project = await requireProject(tag.projectId);
const boardShot = !tag.productionRunId && (project.scenes || []).some(scene => scene.sceneId === tag.sceneId);
+ // A locked video is final: no new still or clip for that shot, from the director or a run.
+ assertClipUnlocked(project, tag.sceneId);
if (boardShot && kind === 'image') assertProductionApproval(project, 'art');
else if (boardShot) assertShotApproval(project, tag.sceneId);
else assertProductionApproval(project, 'storyboard');
diff --git a/server/services/musicVideo/projects.js b/server/services/musicVideo/projects.js
index e8388080a0..02b54ab321 100644
--- a/server/services/musicVideo/projects.js
+++ b/server/services/musicVideo/projects.js
@@ -249,13 +249,26 @@ export async function addProjectScenes(id, sceneInputs, { source = null } = {})
return { project, scenes };
}
+/**
+ * A shot whose video is locked keeps what it shows: refuse a change to it
+ * (`patch` names the fields a scene edit changes; null replaces the shot).
+ */
+async function assertClipsUnlocked(id, sceneIds, patch = null) {
+ const project = await getProject(id);
+ if (!project?.productionReview?.clipApprovals) return;
+ const { assertClipUnlocked } = await import('./productionReview.js');
+ for (const sceneId of sceneIds) assertClipUnlocked(project, sceneId, patch);
+}
+
export async function updateScene(id, sceneId, patch) {
+ await assertClipsUnlocked(id, [sceneId], patch);
const result = await (await selectBackend()).updateScene(id, sceneId, patch);
emitRecordUpdated('musicVideoProject', id);
return result;
}
export async function deleteScene(id, sceneId) {
+ await assertClipsUnlocked(id, [sceneId]);
const next = await (await selectBackend()).deleteScene(id, sceneId);
emitRecordUpdated('musicVideoProject', id);
return next;
@@ -273,6 +286,7 @@ export async function reorderProjectScenes(id, orderedIds) {
* Returns `{ project, scenes }` — the persisted project and the pieces.
*/
export async function splitProjectScene(id, sceneId, options = {}) {
+ await assertClipsUnlocked(id, [sceneId]);
const { splitScene } = await import('./projectsLogic.js');
return mutateProjectRecord(id, (current) => splitScene(current, sceneId, options));
}
@@ -282,6 +296,8 @@ export async function splitProjectScene(id, sceneId, options = {}) {
* of the split. Returns `{ project, scene }`.
*/
export async function mergeProjectNextScene(id, sceneId, options = {}) {
+ const scenes = (await getProject(id))?.scenes || [];
+ await assertClipsUnlocked(id, [sceneId, scenes[scenes.findIndex(scene => scene.sceneId === sceneId) + 1]?.sceneId].filter(Boolean));
const { mergeNextScene } = await import('./projectsLogic.js');
return mutateProjectRecord(id, (current) => mergeNextScene(current, sceneId, options));
}
@@ -318,6 +334,7 @@ export async function appendTakesAcrossScenes(id, items) {
/** Explicitly select a take for its scene slot. Returns the updated scene. */
export async function selectSceneTake(id, sceneId, takeId) {
+ await assertClipsUnlocked(id, [sceneId]);
const scene = await (await selectBackend()).selectSceneTake(id, sceneId, takeId);
emitRecordUpdated('musicVideoProject', id);
return scene;
diff --git a/server/services/musicVideo/projects.test.js b/server/services/musicVideo/projects.test.js
index fac800199f..b03e3fff3e 100644
--- a/server/services/musicVideo/projects.test.js
+++ b/server/services/musicVideo/projects.test.js
@@ -301,3 +301,31 @@ describe('automation respects persisted shot locks (#11218)', () => {
expect(shotLocks(clip.project)[scene.sceneId]).toBe('locked');
});
});
+
+describe('a locked shot video', () => {
+ // Uniquely catches a video lock that only labels the shot: edits, split, merge, take choice and a run must all be refused.
+ it('freezes the shot for the director and for automation until its video is unlocked', async () => {
+ const { setShotLocks, clipLocks } = await import('./productionReview.js');
+ const p = await projects.createProject({ name: 'Video lock' });
+ const scene = await projects.addProjectScene(p.id, { startSec: 0, endSec: 2, prompt: 'Approved' });
+ await projects.updateScene(p.id, scene.sceneId, { videoHistoryId: 'clip-1' });
+ const lock = (locked, stage) => projects.mutateProjectRecord(p.id, current => ({ project: setShotLocks(current, { sceneIds: [scene.sceneId], locked, stage }) }));
+ await lock(true, 'still');
+ await lock(true, 'video');
+ expect(clipLocks(await projects.getProject(p.id))[scene.sceneId]).toBe('locked');
+ await expect(projects.updateScene(p.id, scene.sceneId, { prompt: 'Director edit' })).rejects.toMatchObject({ code: 'MUSIC_VIDEO_SHOT_LOCKED' });
+ await expect(projects.updateScene(p.id, scene.sceneId, { videoHistoryId: 'clip-2' })).rejects.toMatchObject({ code: 'MUSIC_VIDEO_SHOT_LOCKED' });
+ await expect(projects.deleteScene(p.id, scene.sceneId)).rejects.toMatchObject({ code: 'MUSIC_VIDEO_SHOT_LOCKED' });
+ await expect(projects.splitProjectScene(p.id, scene.sceneId, { atSec: 1 })).rejects.toMatchObject({ code: 'MUSIC_VIDEO_SHOT_LOCKED' });
+ await expect(projects.selectSceneTake(p.id, scene.sceneId, 'take-1')).rejects.toMatchObject({ code: 'MUSIC_VIDEO_SHOT_LOCKED' });
+ await projects.addProjectScene(p.id, { startSec: 2, endSec: 3, prompt: 'After' });
+ await expect(projects.mergeProjectNextScene(p.id, scene.sceneId)).rejects.toMatchObject({ code: 'MUSIC_VIDEO_SHOT_LOCKED' });
+ // A field that doesn't change what the shot shows stays editable.
+ await projects.updateScene(p.id, scene.sceneId, { prompt: 'Approved', textZone: 'upper' });
+ const run = await projects.mutateProjectRecord(p.id, current => ({ project: { ...current, scenes: current.scenes.map(s => ({ ...s, videoHistoryId: 'run-clip' })) } }), { source: 'production-run' });
+ expect(run.project.scenes[0].videoHistoryId).toBe('clip-1');
+ await lock(false, 'video');
+ await projects.updateScene(p.id, scene.sceneId, { videoHistoryId: 'clip-2' });
+ expect((await projects.getProject(p.id)).scenes[0].videoHistoryId).toBe('clip-2');
+ });
+});