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

fix: distinguish current Music Video review gates from stale history (#9922)

[._.]/ Adam Eivyc48bd286bb4b
diff --git a/client/src/components/musicVideo/AutonomousRunPanel.jsx b/client/src/components/musicVideo/AutonomousRunPanel.jsx
index b9ba751beb..558ee12609 100644
--- a/client/src/components/musicVideo/AutonomousRunPanel.jsx
+++ b/client/src/components/musicVideo/AutonomousRunPanel.jsx
@@ -5,6 +5,7 @@ import {
AUTONOMOUS_CHECKPOINT_LABELS, AUTONOMOUS_LYRICS_STEP_LABELS, AUTONOMOUS_SONG_STEP_LABELS, AUTONOMOUS_STATUS_LABELS, AUTONOMOUS_VIEWABLE_STAGES,
autonomousStageOutput, autonomousStageRows, isAutonomousLive,
} from '../../lib/musicVideoAutonomous.js';
+import { productionReviewStopGuidance } from '../../lib/musicVideoStages.js';
import AutoApproveFields from './AutoApproveFields.jsx';
// The stages that report a sub-step while they run (the server's `stages[id].step`).
@@ -57,7 +58,7 @@ function StageOutput({ run, row, editableBelow }) {
* `useAutonomousMusicVideo`; this panel only renders the run it is given.
* `framed={false}` drops the card chrome and title for a host that supplies them.
*/
-export default function AutonomousRunPanel({ project, auto, selectedStage = null, onSelectStage, framed = true }) {
+export default function AutonomousRunPanel({ project, auto, readiness, selectedStage = null, onSelectStage, framed = true }) {
const run = project?.autonomousRun;
const [edit, setEdit] = useState(null); // { for: stage, value } — the director's edit at a checkpoint
// Planning approval authority is granted with the next explicit resume.
@@ -65,6 +66,7 @@ export default function AutonomousRunPanel({ project, auto, selectedStage = null
const autoApprove = autoApproveEdit && autoApproveEdit.runId === run?.id ? autoApproveEdit.value : (run?.brief?.autoApprove || []).filter(stage => stage !== 'proof');
const [grantError, setGrantError] = useState(null);
if (!run) return null;
+ const guidance = productionReviewStopGuidance(run, readiness);
const rows = autonomousStageRows(run);
const live = isAutonomousLive(run);
const awaiting = run.status === 'awaiting-approval' ? run.awaiting : null;
@@ -139,10 +141,12 @@ export default function AutonomousRunPanel({ project, auto, selectedStage = null
{run.error && (
<p role="status" className="flex items-start gap-1 text-xs text-port-warning break-words min-w-0">
- <AlertTriangle size={13} className="mt-0.5 shrink-0" aria-hidden="true" /> <span className="min-w-0">{run.error}</span>
+ <AlertTriangle size={13} className="mt-0.5 shrink-0" aria-hidden="true" /> <span className="min-w-0">{guidance?.current || run.error}</span>
</p>
)}
+ {guidance?.historical && <p className="text-xs text-port-text-muted break-words">Historical stop reason: {guidance.historical}</p>}
+
{awaiting && (
<div className="rounded border border-port-border p-2 space-y-2">
<p className="text-xs text-port-text-muted">
diff --git a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx b/client/src/components/musicVideo/AutonomousRunPanel.test.jsx
index 869728b5e4..813b78a145 100644
--- a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx
+++ b/client/src/components/musicVideo/AutonomousRunPanel.test.jsx
@@ -374,3 +374,18 @@ describe('auto-approve the rest', () => {
await waitFor(() => expect(api.resumeAutonomousMusicVideo).toHaveBeenLastCalledWith('mv-1', { autoApprove: ['art', 'storyboard'] }, { silent: true }));
});
});
+
+describe('Current autonomous review guidance', () => {
+ it('keeps an approval failure historical as the current review gate advances', () => {
+ const error = 'Review and approve the current art direction first.';
+ const project = { id: 'history-fixture', autonomousRun: baseRun({ status: 'needs-human', stage: 'produce', error, errorCode: 'MUSIC_VIDEO_APPROVAL_REQUIRED' }) };
+ const auto = { busy: false, resume: vi.fn(), cancel: vi.fn() };
+ const readiness = { art: { approved: true, problems: [] }, storyboard: { approved: true, problems: [] }, proof: { approved: false, problems: ['Render and watch a current animated chorus proof with the master song.'] } };
+ const view = render(<MemoryRouter><AutonomousRunPanel project={project} auto={auto} readiness={readiness} /></MemoryRouter>);
+ expect(screen.getByRole('status')).toHaveTextContent('Render and watch a current animated chorus proof');
+ expect(screen.getByText(`Historical stop reason: ${error}`)).toBeTruthy();
+ view.rerender(<MemoryRouter><AutonomousRunPanel project={project} auto={auto} readiness={{ ...readiness, proof: { approved: true, problems: [] } }} /></MemoryRouter>);
+ expect(screen.getByRole('status')).toHaveTextContent('ready to resume explicitly');
+ expect(auto.resume).not.toHaveBeenCalled();
+ });
+});
diff --git a/client/src/components/musicVideo/AutopilotPanel.jsx b/client/src/components/musicVideo/AutopilotPanel.jsx
index 1ef527f83e..27eeca358b 100644
--- a/client/src/components/musicVideo/AutopilotPanel.jsx
+++ b/client/src/components/musicVideo/AutopilotPanel.jsx
@@ -11,7 +11,7 @@ import { codeFirstProductionAssets } from '../../../../server/lib/musicVideoMedi
import {
DEFAULT_AUTOMATION_TOOLS, MUSIC_VIDEO_AUTOMATION_TOOLS, MUSIC_VIDEO_LLM_STAGES, MUSIC_VIDEO_LLM_STAGE_LABELS, automationDraftFrom, automationFromDraft, llmRouteLabel,
} from '../../lib/musicVideoAutomation.js';
-import { RESUMABLE_RUN_STATUSES, currentProductionRun } from '../../lib/musicVideoStages.js';
+import { RESUMABLE_RUN_STATUSES, currentProductionRun, productionReviewStopGuidance } from '../../lib/musicVideoStages.js';
import { formatCount, formatUsd } from '../../utils/formatters.js';
const POOL_TOOLS = MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => t.group === 'image' || t.group === 'video');
@@ -59,7 +59,7 @@ function StepRow({ step }) {
);
}
-function RunView({ run, production, codeFirst, project }) {
+function RunView({ run, production, codeFirst, project, readiness }) {
const [budget, setBudget] = useState(null);
const live = RESUMABLE_RUN_STATUSES.has(run.status);
const steps = run.steps || [];
@@ -69,9 +69,10 @@ function RunView({ run, production, codeFirst, project }) {
const resumeValid = !budget || (Number.isInteger(budget.maxGenerations) && budget.maxGenerations >= run.limits.maxGenerations && budget.maxGenerations <= 500
&& Number.isInteger(budget.maxReviewAttempts) && budget.maxReviewAttempts >= run.limits.maxReviewAttempts && budget.maxReviewAttempts <= 10
&& (budget.spendCapUsd == null || (Number.isFinite(budget.spendCapUsd) && budget.spendCapUsd >= cap && budget.spendCapUsd <= 100000)));
+ const guidance = productionReviewStopGuidance(run, readiness, 'storyboard');
const hint = run.interrupted
? 'The server restarted — nothing is running. Resume to continue.'
- : run.stopReason;
+ : guidance?.current || run.stopReason;
return (
<div className="space-y-2">
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
@@ -108,6 +109,7 @@ function RunView({ run, production, codeFirst, project }) {
</div>;
})}
</div>}
+ {guidance?.historical && <p className="text-port-text-muted break-words">Historical stop reason: {guidance.historical}</p>}
{hint && <p className="text-port-warning break-words">{hint}</p>}
{steps.some((step) => step.retryBlocked) && <p className="text-port-warning">Terminal refusal recorded: unchanged inputs will not be submitted again on Resume. Repair the shot or cancel and choose another supported route. No new spend is reserved while blocked.</p>}
{run.error && <p role="status" className="text-port-error break-words">{run.error}</p>}
@@ -383,7 +385,7 @@ function BriefSection({ project, onSave, onKickoff, kickoffBusy, kickoffStep, ki
* it with an allowed provider/model pool and explicit limits. Progress arrives
* over the `music-video:production` socket event via `useMusicVideoProduction`.
*/
-function ProductionSection({ project, production }) {
+function ProductionSection({ project, production, readiness }) {
const run = currentProductionRun(project);
const active = run && RESUMABLE_RUN_STATUSES.has(run.status);
const codeFirst = project.productionPolicy?.strategy === 'code-first';
@@ -392,7 +394,7 @@ function ProductionSection({ project, production }) {
return (
<div className="rounded border border-port-border p-2 space-y-2 text-xs" aria-label="Production run">
<span className="font-medium flex items-center gap-1"><Clapperboard size={12} /> Autonomous production (opt-in)</span>
- {run && <RunView key={run.id} run={run} production={production} codeFirst={codeFirst} project={project} />}
+ {run && <RunView key={run.id} run={run} production={production} codeFirst={codeFirst} project={project} readiness={readiness} />}
{codeFirst && <>
<MediumPlanSummary project={project} />
<div className="rounded border border-port-border p-2 space-y-1" aria-label="Code-first asset preflight">
@@ -420,7 +422,7 @@ function ProductionSection({ project, production }) {
* `kickoffStep` names the kickoff step running now.
*/
export default function AutopilotPanel({
- project, production, onSave, onKickoff, kickoffBusy, kickoffStep = null, kickoffBlockedReason,
+ project, production, readiness, onSave, onKickoff, kickoffBusy, kickoffStep = null, kickoffBlockedReason,
}) {
return (
<section className="bg-port-card border border-port-border rounded-lg p-3 space-y-3 min-w-0" aria-label="Autopilot">
@@ -432,7 +434,7 @@ export default function AutopilotPanel({
kickoffStep={kickoffStep}
kickoffBlockedReason={kickoffBlockedReason}
/>
- <ProductionSection project={project} production={production} />
+ <ProductionSection project={project} production={production} readiness={readiness} />
</section>
);
}
diff --git a/client/src/components/musicVideo/AutopilotPanel.test.jsx b/client/src/components/musicVideo/AutopilotPanel.test.jsx
index bacdf5b254..cdc518b478 100644
--- a/client/src/components/musicVideo/AutopilotPanel.test.jsx
+++ b/client/src/components/musicVideo/AutopilotPanel.test.jsx
@@ -330,3 +330,19 @@ describe('AutopilotPanel budgeted pilot evidence (#9351)', () => {
expect(api.resumeMusicVideoProduction).toHaveBeenCalledWith('p1', 'run-1', { limits: { maxGenerations: 12, maxReviewAttempts: 5, spendCapUsd: 8 } }, { silent: true });
});
});
+
+describe('Historical production approval stops', () => {
+ it('shows a new current blocker then ready to resume without restarting or erasing history', () => {
+ const reason = 'Review and approve the current art direction first.';
+ const project = { id: 'history-fixture', productionRuns: [run({ status: 'blocked', stopReason: reason })] };
+ const readiness = { art: { approved: true, problems: [] }, storyboard: { approved: false, problems: ['Listen and verify the current word timings.'] }, proof: { approved: false, problems: [] } };
+ const production = { ...IDLE_PRODUCTION, resume: vi.fn() };
+ const view = render(<AutopilotPanel project={project} production={production} readiness={readiness} onSave={vi.fn()} onKickoff={vi.fn()} />);
+ expect(screen.getByText(`Historical stop reason: ${reason}`)).toBeTruthy();
+ expect(screen.getByText('Listen and verify the current word timings.')).toBeTruthy();
+ view.rerender(<AutopilotPanel project={project} production={production} readiness={{ ...readiness, storyboard: { approved: true, problems: [] } }} onSave={vi.fn()} onKickoff={vi.fn()} />);
+ expect(screen.getByText('Review requirements are satisfied — ready to resume explicitly.')).toBeTruthy();
+ expect(screen.getByText(`Historical stop reason: ${reason}`)).toBeTruthy();
+ expect(production.resume).not.toHaveBeenCalled();
+ });
+});
diff --git a/client/src/components/musicVideo/ProductionReviewPanel.jsx b/client/src/components/musicVideo/ProductionReviewPanel.jsx
index d3456b1bb1..f31eac2481 100644
--- a/client/src/components/musicVideo/ProductionReviewPanel.jsx
+++ b/client/src/components/musicVideo/ProductionReviewPanel.jsx
@@ -246,9 +246,15 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,
</label>
<label htmlFor={fieldId('alignment-status')} className="block text-sm">Alignment status
<select id={fieldId('alignment-status')} value={draft.timingStatus} onChange={e => set('timingStatus', e.target.value)} className={fieldClass}>
- <option value="provisional">Provisional — needs listening and correction</option><option value="verified">Verified against the current master vocal</option>
+ <option value="provisional">Provisional — needs listening and correction</option><option value="verified">{ready?.alignment?.status === 'stale' ? 'Previously verified — needs re-review' : 'Verified against the current master vocal'}</option>
</select>
</label>
+ {draft.lyricsMode === 'vocal' && ready?.alignment?.status === 'stale' && <div className="space-y-2">
+ <p role="status" className="text-sm text-port-warning">Word timings or master audio changed. The previous verification is historical; current alignment needs re-review.</p>
+ <p className="text-xs text-port-text-muted">Listen to the current master and inspect its word timings before reverifying. Save any edited notes first. This records your authenticated review; it does not approve the storyboard or fix timing errors.</p>
+ <button type="button" className={buttonClass} disabled={blocked || !draft.timingNotes.trim()}
+ onClick={() => review.reverifyAlignment(draft.timingNotes)}>Reverify current timings</button>
+ </div>}
<label htmlFor={fieldId('alignment-notes')} className="block text-sm">Alignment notes / instrumental rationale<textarea id={fieldId('alignment-notes')} rows={2} value={draft.timingNotes} onChange={e => set('timingNotes', e.target.value)} className={fieldClass} /></label>
<label htmlFor={fieldId('storyboard-source')} className="block text-sm">Storyboard source
<select id={fieldId('storyboard-source')} value={draft.storyboardSource || 'board'} onChange={e => set('storyboardSource', e.target.value)} className={fieldClass}>
diff --git a/client/src/components/musicVideo/ProductionReviewPanel.test.jsx b/client/src/components/musicVideo/ProductionReviewPanel.test.jsx
index 3bc0cf651f..d32a3c7532 100644
--- a/client/src/components/musicVideo/ProductionReviewPanel.test.jsx
+++ b/client/src/components/musicVideo/ProductionReviewPanel.test.jsx
@@ -190,3 +190,26 @@ describe('Production proof playback evidence', () => {
expect(review.approve).not.toHaveBeenCalled();
});
});
+
+describe('Stale alignment review', () => {
+ it('labels historical verification and offers an explicit native button with the saved notes', () => {
+ const vocal = { ...project, productionReview: { ...project.productionReview, draft: { ...project.productionReview.draft, lyricsMode: 'vocal' } } };
+ const review = reviewFixture();
+ review.readiness.alignment = { status: 'stale', basis: 'current-word-times' };
+ review.reverifyAlignment = vi.fn();
+ const view = render(<ProductionReviewPanel project={vocal} review={review} onOpenArtifact={vi.fn()} />);
+ fireEvent.click(screen.getByText('Edit visual guide and storyboard'));
+ expect(screen.getByRole('option', { name: 'Previously verified — needs re-review' }).selected).toBe(true);
+ const button = screen.getByRole('button', { name: 'Reverify current timings' });
+ expect(button.tagName).toBe('BUTTON');
+ expect(button.disabled).toBe(false);
+ expect(screen.getByText(/Listen to the current master and inspect its word timings/)).toBeTruthy();
+ expect(review.reverifyAlignment).not.toHaveBeenCalled();
+ fireEvent.click(button);
+ expect(review.reverifyAlignment).toHaveBeenCalledWith('Synthetic master');
+ fireEvent.change(screen.getByLabelText('Alignment notes / instrumental rationale'), { target: { value: 'New unsaved notes' } });
+ expect(button.disabled).toBe(true);
+ view.rerender(<ProductionReviewPanel project={vocal} review={{ ...review, busy: true }} onOpenArtifact={vi.fn()} />);
+ expect(button.disabled).toBe(true);
+ });
+});
diff --git a/client/src/components/musicVideo/stages/ProduceStage.jsx b/client/src/components/musicVideo/stages/ProduceStage.jsx
index 5395335476..7513b2ec61 100644
--- a/client/src/components/musicVideo/stages/ProduceStage.jsx
+++ b/client/src/components/musicVideo/stages/ProduceStage.jsx
@@ -15,6 +15,7 @@ export default function ProduceStage({ board }) {
key={`autopilot-${project.id}`}
project={project}
production={production}
+ readiness={board.productionReadiness}
onSave={board.saveAutomation}
onKickoff={board.onKickoff}
kickoffBusy={board.busy.analyzing || board.busy.planning || kickoff.running}
diff --git a/client/src/components/musicVideo/stages/SetupStage.jsx b/client/src/components/musicVideo/stages/SetupStage.jsx
index 906046a945..c46f255c2b 100644
--- a/client/src/components/musicVideo/stages/SetupStage.jsx
+++ b/client/src/components/musicVideo/stages/SetupStage.jsx
@@ -28,6 +28,7 @@ export default function SetupStage({ board }) {
key={`autonomous-${project.id}`}
project={project}
auto={autonomous}
+ readiness={board.productionReadiness}
selectedStage={runStage}
onSelectStage={onSelectStage}
framed
diff --git a/client/src/hooks/useMusicVideoProductionReview.js b/client/src/hooks/useMusicVideoProductionReview.js
index a17a55b85d..82cfc9a14c 100644
--- a/client/src/hooks/useMusicVideoProductionReview.js
+++ b/client/src/hooks/useMusicVideoProductionReview.js
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react';
-import { importMusicVideoDocumentShots, getMusicVideoProductionReview, saveMusicVideoProductionDraft, prepareMusicVideoProductionReview,
+import { reverifyMusicVideoAlignment, importMusicVideoDocumentShots, getMusicVideoProductionReview, saveMusicVideoProductionDraft, prepareMusicVideoProductionReview,
approveMusicVideoProductionReview, renderMusicVideoProductionProof, musicVideoExcerptRenderEventsUrl,
cancelMusicVideoExcerptRender, importMusicVideoProductionPlanning, bindMusicVideoProductionShot, addMusicVideoProductionFeedback, resolveMusicVideoProductionFeedback } from '../services/apiMusicVideo.js';
import useSseJobSlot from './useSseJobSlot.js';
@@ -55,6 +55,7 @@ export default function useMusicVideoProductionReview({ project, replaceProject
importDocumentShots: body => call(() => importMusicVideoDocumentShots(project.id, body, { silent: true })),
importPlanning: source => call(() => importMusicVideoProductionPlanning(project.id, source, { silent: true })),
bindShot: shotId => call(() => bindMusicVideoProductionShot(project.id, shotId, { silent: true })),
+ reverifyAlignment: notes => call(() => reverifyMusicVideoAlignment(project.id, { basis: state?.readiness.alignment.basis, notes }, { silent: true })),
save: draft => call(() => saveMusicVideoProductionDraft(project.id, draft, { silent: true })),
prepare: () => call(() => prepareMusicVideoProductionReview(project.id, {}, { silent: true })),
approve: (stage, proofReview) => call(() => approveMusicVideoProductionReview(project.id,
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index 3f869e7330..90a6396e76 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -64,7 +64,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `musicVideoLayers.js` | Music-video per-scene visual layers (#8985), re-exported from `server/lib/musicVideoLayers.js`: `MUSIC_VIDEO_VISUAL_LAYERS`, `MUSIC_VIDEO_STILL_MOVES`, `sceneVisualLayer(scene, { layered })`, `sceneHasAuthoredSpan`, `sceneRenderReady(scene, { layered })`. Used by `components/musicVideo/SceneCard.jsx`, `ProjectActionGroups.jsx` and `hooks/useMusicVideoSceneMedia.js`. |
| `musicVideoTakes.js` | Music-video scene takes view helpers (#8965): `sceneTakeList(scene, kind)` lists a scene's image/video takes with an un-materialized pre-takes selection appended as a read-only `legacy` take; `takePreviewKey`, `takeThumbUrl`, `takeProvenance`; `TAKE_SLOT` maps a take kind to its selection field. Used by `components/musicVideo/SceneTakeStrip.jsx` and `pages/MusicVideo.jsx`. |
| `musicVideoShotTiming.js` | Re-export of `server/lib/musicVideoShotTiming.js` (#8977) — shot modes, the verified source-audio lip-sync capability table, `performanceBlockedReason`, `planPerformanceRepair` (measured accepted-prefix boundary, suffix interval and next spend), `planPerformanceWindow`, `grokCoverage`, `approximateMotionCues`, `shotSplitLimit` (when a scene offers a lyric-boundary split), `falSceneTake` (a fal take's model, length, resolution and estimated cost). Used by `hooks/useMusicVideoSceneMedia.js` and `components/musicVideo/SceneCard.jsx`. |
-| `musicVideoStages.js` | Music Video page stage model: `MUSIC_VIDEO_STAGES` (setup → cast-sets → board → produce → compose → review), `resolveStageParam(value)` for the `:stage` route param, `deriveStages(project)` (per-stage `done`/`active`/`blocked`/`todo` + `current`, the first incomplete stage; a live production run pins Produce), `deriveNextAction(project, ctx)` (the one primary action the sticky header offers — approve Cast & Sets, stop/resume production, render final, …), `projectSpend(project)` (paid generation used vs. cap), `projectShotSummary(project)` (document shots or scene counts), and `currentProductionRun`. Used by `components/musicVideo/MusicVideoLayout.jsx` and `pages/MusicVideo.jsx`. |
+| `musicVideoStages.js` | Music Video page stage model: `MUSIC_VIDEO_STAGES` (setup → cast-sets → board → produce → compose → review), `resolveStageParam(value)` for the `:stage` route param, `deriveStages(project)` (per-stage `done`/`active`/`blocked`/`todo` + `current`, the first incomplete stage; a live production run pins Produce), `deriveNextAction(project, ctx)` (the one primary action the sticky header offers — approve Cast & Sets, stop/resume production, render final, …), `projectSpend(project)` (paid generation used vs. cap), `projectShotSummary(project)` (document shots or scene counts), and `currentProductionRun`; `productionReviewStopGuidance` separates current approval blockers from historical run stops. Used by `components/musicVideo/MusicVideoLayout.jsx` and `pages/MusicVideo.jsx`. |
| `musicVideoPreview.js` | Pick the representative produced asset for a Music Video project card (`selectMusicVideoPreview`: final video → latest excerpt → latest rendered scene clip → latest scene reference frame → visual spec reference) for the main project grid. Pure, computed off the project record, with image path and fallback helpers (`musicVideoImageSrc`, `musicVideoImageFallback`). |
| `musicVideoUniverseRefs.js` | `pullUniverseCanonReferences(universe, existingReferences)` (#8978) maps a linked universe's characters/places/objects to visual-spec references (character/set/prop roles), skipping images already present and capping at `MUSIC_VIDEO_MAX_REFERENCES` (24, mirrors the server schema). Returns `{ next, added, skipped }`; the caller persists `next` via the ordinary visualSpec PATCH. Used by `components/musicVideo/VisualSpecPanel.jsx`. (The style snapshots are derived server-side, #9105.) |
| `musicVideoAutonomous.js` | Fully-autonomous Music Video, client half: re-exports the server stage vocabulary (`AUTONOMOUS_STAGES`, checkpoint ids, default tools/limits, `autonomousMedium`), the status/checkpoint labels, and owns the start form's `emptyAutonomousDraft` / `autonomousRequestFromDraft` mapping (including the Suno form options and `isSunoModelValid`) plus `autonomousStageRows(run)` and `isAutonomousLive(run)` for the run panel, and `autopilotDraftFromParams` / `autopilotParamsFromDraft` for the music-video-autopilot Schedule settings form. |
diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.js
index 7f3a9db669..2bf05d27ae 100644
--- a/client/src/lib/musicVideoStages.js
+++ b/client/src/lib/musicVideoStages.js
@@ -35,6 +35,20 @@ export const currentProductionRun = (project) => {
return runs.find((r) => RESUMABLE_RUN_STATUSES.has(r.status)) || runs[runs.length - 1] || null;
};
+/** Current review guidance for a stopped approval-gated run; retain other failures. */
+export function productionReviewStopGuidance(run, readiness, through = 'proof') {
+ const reason = run?.stopReason || run?.error;
+ if (!readiness || !reason || !['blocked', 'needs-human', 'stopped', 'failed'].includes(run.status)) return null;
+ const approvalStop = run.errorCode === 'MUSIC_VIDEO_APPROVAL_REQUIRED'
+ || /^(?:Review and approve the current art direction|A reviewer must approve the current|Lyric alignment is provisional or changed|Production review needs human approval)/.test(reason);
+ if (!approvalStop) return null;
+ const stages = ['art', 'storyboard', 'proof'];
+ const stage = stages.slice(0, stages.indexOf(through) + 1).find(key => !readiness[key]?.approved);
+ const current = stage ? readiness[stage].problems?.[0]
+ || `Review and approve the current ${stage === 'art' ? 'art direction' : stage}.` : 'Review requirements are satisfied — ready to resume explicitly.';
+ return { current, historical: current !== reason ? reason : null };
+}
+
export function projectShotSummary(project) {
const draft = project?.productionReview?.draft;
const document = project?.composition?.mode === 'document' && draft?.storyboardSource === 'document';
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 075faf5c5b..5b77025145 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -79,7 +79,7 @@ import { isLtx2FamilyRuntime } from '../lib/runnerFamilies';
import { videoPosterForJob } from '../lib/creativeDirectorPreview.js';
import { sceneTakeList } from '../lib/musicVideoTakes.js';
import {
- approvalSummary, deriveNextAction, deriveStages, projectShotSummary, describeProjectStatus, listPreviewSources, projectSpend, resolveStageParam,
+ productionReviewStopGuidance, approvalSummary, deriveNextAction, deriveStages, projectShotSummary, describeProjectStatus, listPreviewSources, projectSpend, resolveStageParam,
} from '../lib/musicVideoStages.js';
import { AUTONOMOUS_STATUS_LABELS, AUTONOMOUS_VIEWABLE_STAGES } from '../lib/musicVideoAutonomous.js';
@@ -102,9 +102,10 @@ const STAGE_VIEWS = {
};
// Keep active work open; historical runs remain available behind their summary.
-const autopilotSummary = (run) => {
+const autopilotSummary = (run, readiness) => {
const label = run.interrupted ? 'Interrupted — resume to continue' : AUTONOMOUS_STATUS_LABELS[run.status] || run.status;
- return run.error ? `${label} — ${run.error}` : label;
+ const guidance = productionReviewStopGuidance(run, readiness);
+ return run.error ? `${label} — ${guidance?.current || run.error}` : label;
};
const STATUS_COLORS = {
@@ -1226,10 +1227,10 @@ export default function MusicVideo() {
<StageSection
key={`autonomous-${selected.id}`}
title="Autopilot run"
- summary={autopilotSummary(autopilotRun)}
+ summary={autopilotSummary(autopilotRun, productionReview.readiness)}
defaultOpen={!!runStage || autopilotRun.interrupted || ['running', 'awaiting-approval', 'needs-human', 'failed'].includes(autopilotRun.status)}
>
- <AutonomousRunPanel project={selected} auto={autonomous} selectedStage={runStage} onSelectStage={setRunStage} framed={false} />
+ <AutonomousRunPanel project={selected} auto={autonomous} readiness={productionReview.readiness} selectedStage={runStage} onSelectStage={setRunStage} framed={false} />
</StageSection>
)}
<StageSection
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index 7bc9b94e4b..2e233d52c1 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -2582,3 +2582,20 @@ describe('direct production review navigation', () => {
await waitFor(() => expect(art).toHaveFocus());
});
});
+
+describe('Autopilot collapsed review summary', () => {
+ it('shows the current blocker in the summary while retaining the historical error in run details', async () => {
+ const error = 'Review and approve the current art direction first.';
+ const project = { ...PROJECT_ANALYZED, autonomousRun: { id: 'history-run', status: 'needs-human', stage: 'produce',
+ error, errorCode: 'MUSIC_VIDEO_APPROVAL_REQUIRED', brief: { autoApprove: [] }, stages: {}, output: {} },
+ productionReadiness: { basis: {}, art: { approved: true, problems: [] }, storyboard: { approved: true, problems: [] },
+ proof: { approved: false, problems: ['Render and watch a current animated chorus proof with the master song.'] } } };
+ listMusicVideoProjects.mockResolvedValue([project]);
+ render(<MemoryRouter initialEntries={['/music-video/mv-3/review']}>{MV_ROUTES}</MemoryRouter>);
+ await screen.findByText(`Historical stop reason: ${error}`);
+ const summary = screen.getByText('Autopilot run').closest('summary');
+ fireEvent.click(summary);
+ expect(summary).toHaveTextContent('Render and watch a current animated chorus proof');
+ expect(summary.textContent).not.toContain(error);
+ });
+});
diff --git a/client/src/services/apiMusicVideo.js b/client/src/services/apiMusicVideo.js
index d718ffeaf3..00c45e6e24 100644
--- a/client/src/services/apiMusicVideo.js
+++ b/client/src/services/apiMusicVideo.js
@@ -435,6 +435,7 @@ export const applyMusicVideoAudioTiming = (id, data, options = {}) => request(`/
// Human-reviewed production planning and proof. These never accept approval state in a project PATCH.
export const getMusicVideoProductionReview = (id, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review`, options);
+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 approveMusicVideoProductionReview = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/approve`, { method: 'POST', body: JSON.stringify(body), ...options });
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index 02c6dd90f7..5b5a808a98 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -1066,6 +1066,9 @@ export const musicVideoProductionDraftSchema = z.object({
camera: z.string().max(4000), transition: z.string().max(4000),
}).strict()).max(2000),
}).strict();
+export const musicVideoAlignmentReviewSchema = z.object({
+ basis: z.string().min(1).max(128), notes: z.string().trim().min(1).max(4000),
+}).strict();
export const musicVideoDocumentShotsSchema = z.object({
documentDirectory: z.string().min(1).max(500), audioBasis: z.string().min(1).max(128),
sourceFile: z.string().min(1).max(200),
diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.js
index d065551a2d..fe9f6eea87 100644
--- a/server/routes/musicVideo.js
+++ b/server/routes/musicVideo.js
@@ -529,6 +529,13 @@ router.post('/:id/production-review/prepare', asyncHandler(async (req, res) => {
const input = validateRequest(musicVideoCastAndSetsStartSchema, req.body || {});
res.json(await prepareProductionReview(req.params.id, input));
}));
+router.post('/:id/production-review/alignment', asyncHandler(async (req, res) => {
+ const { musicVideoAlignmentReviewSchema } = await import('../lib/musicVideoValidation.js');
+ const input = validateRequest(musicVideoAlignmentReviewSchema, req.body);
+ const reviewer = await requireProductionReviewer(req);
+ const { reverifyProductionAlignment } = await import('../services/musicVideo/productionReviewService.js');
+ res.json(await reverifyProductionAlignment(req.params.id, { ...input, reviewer }));
+}));
router.post('/:id/production-review/approve', asyncHandler(async (req, res) => {
const input = validateRequest(musicVideoProductionApprovalSchema, req.body);
const reviewer = await requireProductionReviewer(req);
diff --git a/server/routes/musicVideoProductionReview.test.js b/server/routes/musicVideoProductionReview.test.js
index 6cd0afd6b5..d837cfd467 100644
--- a/server/routes/musicVideoProductionReview.test.js
+++ b/server/routes/musicVideoProductionReview.test.js
@@ -193,6 +193,37 @@ describe('human-reviewed Music Video workflow', () => {
expect(legacy.productionReview.approvals.art).toEqual(accepted.productionReview.approvals.art);
});
+ it('keeps changed word timings stale across draft saves and reverifies only the authenticated current basis', async () => {
+ await approve('art');
+ const prior = await read();
+ expect(prior.body.readiness.alignment.status).toBe('verified');
+ await store.updateProject(project.id, { lyricCues: [{ id: 'line-a', text: 'Example chorus', startSec: 1, endSec: 3,
+ words: [{ w: 'Example', startSec: 1, endSec: 1.5, conf: 'matched' }, { w: 'chorus', startSec: 1.5, endSec: 3, conf: 'matched' }] }] });
+ const saved = await save({ ...draft, timingNotes: 'Checked the updated fixture word onsets.', implementationPlan: 'Keep the existing renderer.' });
+ expect(saved.body.readiness.alignment.status).toBe('stale');
+ expect(saved.body.readiness.storyboard.problems.join(' ')).toContain('Lyric alignment is provisional or changed');
+ const reverify = (basis = saved.body.readiness.alignment.basis, notes = saved.body.project.productionReview.draft.timingNotes) =>
+ request(app).post(`${base}/production-review/alignment`).set('authorization', 'Bearer synthetic-agent').send({ basis, notes });
+ auth.authenticated = false;
+ expect((await reverify()).status).toBe(401);
+ auth.authenticated = true; auth.enabled = false;
+ expect((await reverify()).status).toBe(401);
+ auth.enabled = true;
+ expect((await request(app).post(`${base}/production-review/alignment`).set('authorization', 'Bearer expired')
+ .send({ basis: saved.body.readiness.alignment.basis, notes: draft.timingNotes })).status).toBe(401);
+ expect((await reverify(prior.body.readiness.alignment.basis)).body.code).toBe('MUSIC_VIDEO_REVIEW_STALE');
+ expect((await reverify(undefined, ' ')).status).toBe(400);
+ expect((await read()).body.readiness.alignment.status).toBe('stale');
+ const reviewed = await reverify();
+ expect(reviewed.status).toBe(200);
+ expect(reviewed.body.readiness.alignment.status).toBe('verified');
+ expect(reviewed.body.readiness.storyboard.approved).toBe(false);
+ expect(reviewed.body.project.productionReview.draft.timingNotes).toBe('Checked the updated fixture word onsets.');
+ expect(reviewed.body.project.productionReview.alignmentReview.reviewer).toMatchObject({ kind: 'session', sessionId: 'shared-agent-session' });
+ expect((await approve('art')).status).toBe(200);
+ expect((await approve('storyboard')).status).toBe(200);
+ });
+
it('distinguishes provisional/zero-length/missing lyrics from an explicit instrumental', async () => {
await approve('art');
await save({ ...draft, timingStatus: 'provisional' });
diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.js
index 98c50b77a5..8225cfd68e 100644
--- a/server/services/musicVideo/productionReview.js
+++ b/server/services/musicVideo/productionReview.js
@@ -65,6 +65,7 @@ export function productionReadiness(project) {
const review = project.productionReview || {};
const draft = review.draft || {};
const basis = productionReviewBasis(project);
+ const alignmentBasis = productionAlignmentBasis(project);
const unresolved = stage => (review.feedback || []).filter(f => f.stage === stage && f.decision === 'request-changes' && !f.resolvedAt);
const artProblems = unresolved('art').map(f => `Resolve art feedback for ${f.target}: ${f.text}`);
for (const [key, label] of [['cast', 'Cast guide'], ['environments', 'Environment guide'],
@@ -84,7 +85,7 @@ export function productionReadiness(project) {
if (!text(draft.timingNotes)) boardProblems.push('Explain and confirm the instrumental exception.');
} else {
if (!cues.length) boardProblems.push('Import lyrics and align them to the current vocal; missing lyrics are not an instrumental.');
- if (draft.timingStatus !== 'verified' || review.alignmentBasis !== productionAlignmentBasis(project)) boardProblems.push('Lyric alignment is provisional or changed. Listen and verify the current word timings.');
+ if (draft.timingStatus !== 'verified' || review.alignmentBasis !== alignmentBasis) boardProblems.push('Lyric alignment is provisional or changed. Listen and verify the current word timings.');
if (!text(draft.timingNotes)) boardProblems.push('Record how the vocal timings were checked.');
if (cues.some(c => !(Number.isFinite(c.startSec) && c.endSec > c.startSec && c.endSec <= duration)
|| !c.words?.length || c.words.some(w => !(Number.isFinite(w.startSec) && w.endSec > w.startSec)
@@ -130,7 +131,8 @@ export function productionReadiness(project) {
proofProblems.push('Render and watch a current animated chorus proof with the master song.');
}
const proofApproved = !proofProblems.length && hasProofEvidence(review.approvals?.proof?.proofReview) && review.approvals?.proof?.basis === hash({ basis: basis.proof, excerptId: excerpt.id, filename: excerpt.filename });
- return { basis, documentShotImport: { documentDirectory: project.composition?.document?.directory || null, audioBasis: productionAlignmentBasis(project) }, art: { approved: artApproved, problems: [...new Set(artProblems)] },
+ return { basis, alignment: { basis: alignmentBasis, status: draft.lyricsMode === 'instrumental' ? 'instrumental'
+ : draft.timingStatus !== 'verified' ? 'provisional' : review.alignmentBasis === alignmentBasis ? 'verified' : 'stale' }, documentShotImport: { documentDirectory: project.composition?.document?.directory || null, audioBasis: alignmentBasis }, art: { approved: artApproved, problems: [...new Set(artProblems)] },
storyboard: { approved: storyboardApproved, problems: [...new Set(boardProblems)] },
proof: { approved: proofApproved, problems: proofProblems, excerptId: excerpt?.id || null },
readyForProduction: proofApproved };
diff --git a/server/services/musicVideo/productionReviewService.js b/server/services/musicVideo/productionReviewService.js
index 946d3c7c83..da230c55be 100644
--- a/server/services/musicVideo/productionReviewService.js
+++ b/server/services/musicVideo/productionReviewService.js
@@ -121,6 +121,19 @@ export async function saveProductionDraft(id, draft) {
return changed(project);
}
+/** Only the explicit authenticated action can rebind already-verified timings. */
+export async function reverifyProductionAlignment(id, { basis, notes, reviewer }) {
+ const { project } = await mutateProjectRecord(id, current => {
+ if (basis !== productionAlignmentBasis(current)) throw new ServerError('The word timings changed while you were reviewing. Inspect them again.', { status: 409, code: 'MUSIC_VIDEO_REVIEW_STALE' });
+ const draft = current.productionReview?.draft;
+ if (!draft || draft.lyricsMode !== 'vocal') throw new ServerError('Save a vocal planning draft before verifying alignment.', { status: 409, code: 'PLANNING_DRAFT_REQUIRED' });
+ return { project: { ...current, productionReview: { ...current.productionReview,
+ draft: { ...draft, timingStatus: 'verified', timingNotes: notes }, alignmentBasis: basis,
+ alignmentReview: { basis, reviewer, reviewedAt: new Date().toISOString() } } } };
+ });
+ 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 => {