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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: move each music-video approval onto its own stage tab (#10151)
Adam Eivyae2ef4391e95
diff --git a/client/src/components/musicVideo/ProductionReviewPanel.jsx b/client/src/components/musicVideo/ProductionReviewPanel.jsxindex ece9ec0eeb..5d80b642fa 100644--- a/client/src/components/musicVideo/ProductionReviewPanel.jsx+++ b/client/src/components/musicVideo/ProductionReviewPanel.jsx@@ -7,22 +7,27 @@ const EMPTY = { cast: '', environments: '', visualLanguage: '', motionLanguage:const fieldClass = 'mt-1 w-full rounded border border-port-border bg-port-bg p-2 text-sm';const buttonClass = 'min-h-[44px] rounded border border-port-border px-3 py-2 text-sm disabled:opacity-50';const labels = { art: 'Art direction', storyboard: 'Lyric-timed storyboard', proof: 'Animated proof' };+// Each approval lives on the tab that owns its work (#10151); the page passes `stage` to render only that one.+const STAGE_TABS = { art: 'cast-sets', storyboard: 'board', proof: 'compose' };const EMPTY_PLAYBACK = { method: 'playback', energyComparison: '', timecodedNotes: '', visualReview: '', audioReview: '', limitations: '' };/** Editable planning content and explicit operator decisions for every render mode. */-// `framed={false}` drops the card chrome and heading for a host that supplies them (the page's collapsible section).-// The proof is the last step of Compose (#10140): a host showing another tab passes `proofHere={false}`-// and `onOpenProof`, so the proof's render and approval controls live on Compose only.-export default function ProductionReviewPanel({ project, review, onOpenArtifact, framed = true, proofHere = true, onOpenProof = null }) {+// `framed={false}` drops the card chrome and heading for a host that supplies them.+// `stage` ('art' | 'storyboard' | 'proof') renders just that stage's approval, feedback and planning fields; omitted, all three render.+// `planning` is an optional `[draft, setDraft]` pair owned by the page so unsaved edits survive a tab switch; `onNavigate(tab, anchor)` jumps tabs.+export default function ProductionReviewPanel({ project, review, onOpenArtifact, framed = true, stage = null, planning = null, onNavigate = null }) {+ const showArt = !stage || stage === 'art';+ const showBoard = !stage || stage === 'storyboard';const fieldId = key => `mv-review-${project.id}-${key}`;const saved = project.productionReview?.draft || EMPTY;const [visibleArt, setVisibleArt] = useState(null);const [proofMedia, setProofMedia] = useState(null);const artIdentity = JSON.stringify([project.id, saved.guideArtifactId, project.devArtifacts?.find(a => a.id === saved.guideArtifactId)?.version]);- const [local, setLocal] = useState(null);+ const [ownLocal, setOwnLocal] = useState(null);+ const [local, setLocal] = planning || [ownLocal, setOwnLocal];const draft = local || saved;const dirty = !!local && JSON.stringify(local) !== JSON.stringify(saved);- const [feedback, setFeedback] = useState({ stage: 'art', target: '', text: '', decision: 'request-changes' });+ const [feedback, setFeedback] = useState({ stage: stage || 'art', target: '', text: '', decision: 'request-changes' });const [resolutions, setResolutions] = useState({});const [importError, setImportError] = useState(null);const [revisionNotice, setRevisionNotice] = useState(null);@@ -80,6 +85,11 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,if (!evidenceComplete) return 'Complete the visual and audio observations (at least 40 characters each) and state the review limitations.';return null;};+ // A link to another stage's section crosses tabs through the page; within a tab it just unfolds the target.+ const jump = (tab, anchor) => event => {+ if (onNavigate && stage && tab !== STAGE_TABS[stage]) { event.preventDefault(); onNavigate(tab, anchor); return; }+ openReviewSection(event);+ };const openReviewSection = event => {const target = document.getElementById(event.currentTarget.hash.slice(1));if (target) { target.open = true; target.focus({ preventScroll: true }); }@@ -117,10 +127,10 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,{!excerpt && <div className="rounded border border-port-border p-3 space-y-2" aria-label="Proof approval prerequisites"><p className="text-sm">{prototype ? 'The video below is a feasibility prototype, not a registered production proof. Watching it does not enable proof approval.' : 'No production proof is registered for this project.'}</p><ol className="list-decimal pl-5 text-sm space-y-2">- {!ready?.art.approved && <li><a href="#mv-review-art" onClick={openReviewSection} className="text-port-accent underline">Review and approve art direction</a> for the current revision.</li>}- {!ready?.storyboard.approved && <li><a href="#mv-review-storyboard" onClick={openReviewSection} className="text-port-accent underline">Resolve storyboard prerequisites and approve it</a>.+ {!ready?.art.approved && <li><a href="#mv-review-art" onClick={jump('cast-sets', 'mv-review-art')} className="text-port-accent underline">Review and approve art direction</a> for the current revision.</li>}+ {!ready?.storyboard.approved && <li><a href="#mv-review-storyboard" onClick={jump('board', 'mv-review-storyboard')} className="text-port-accent underline">Resolve storyboard prerequisites and approve it</a>.<ul className="list-disc pl-5">{(ready?.storyboard.problems || []).map(problem => <li key={problem}>{problem}</li>)}</ul>- <a href="#mv-review-planning" onClick={openReviewSection} className="text-port-accent underline">Open planning edits for alignment and document shot manifests</a>.+ <a href="#mv-review-planning" onClick={jump('board', 'mv-review-planning')} className="text-port-accent underline">Open planning edits for alignment and document shot manifests</a>.</li>}<li>Choose a 10–45 second chorus window and use “Render animated proof” below. The feasibility prototype button creates a separate, unapproved preview.</li><li>Review the proof with audio, add an energy comparison and timecoded notes, then approve using the playback attestation.</li>@@ -195,15 +205,11 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,</>;return <section id="mv-production-review" aria-label="Production review" className={framed ? 'rounded-lg border border-port-border bg-port-card p-3 space-y-3' : 'space-y-3'}>{framed && <h3 className="font-medium">Production review</h3>}- <p className="text-sm text-port-text-muted">Approve the visual direction, then the timed storyboard, then the reviewed animated proof. Approving a development file or rendering a draft does not approve production.</p>+ <p className="text-sm text-port-text-muted">{stage ? 'Approving a development file or rendering a draft does not approve production.'+ : 'Approve the visual direction, then the timed storyboard, then the reviewed animated proof. Approving a development file or rendering a draft does not approve production.'}</p>{review.error && <p role="alert" className="text-port-error">{review.error}</p>}<ol className="space-y-3">- {Object.entries(labels).map(([key, label]) => key === 'proof' && !proofHere ? <li key={key} className="rounded border border-port-border p-2">- <p className="text-sm font-medium">{label}</p>- <p role="status" className="text-xs">{ready?.proof.approved ? 'Approved for this revision' : 'Review required'}</p>- <p className="mt-1 text-xs text-port-text-muted">The proof is the last step of Compose: render, watch and approve it there, over the finished typography and grade.</p>- {onOpenProof && <button type="button" className={`${buttonClass} mt-2`} onClick={onOpenProof}>Open the proof in Compose</button>}- </li> : <li key={key}><details open={window.location.hash === `#mv-review-${key}` || key === nextStage} id={`mv-review-${key}`} tabIndex={-1} style={{ scrollMarginTop: 'calc(var(--mv-header-h, 9rem) + 1rem)' }} className="rounded border border-port-border p-2 focus:outline focus:outline-2 focus:outline-port-accent">+ {Object.entries(labels).filter(([key]) => !stage || key === stage).map(([key, label]) => <li key={key}><details open={!!stage || window.location.hash === `#mv-review-${key}` || key === nextStage} id={`mv-review-${key}`} tabIndex={-1} style={{ scrollMarginTop: 'calc(var(--mv-header-h, 9rem) + 1rem)' }} className="rounded border border-port-border p-2 focus:outline focus:outline-2 focus:outline-port-accent"><summary className="cursor-pointer min-h-[44px] py-2 text-sm font-medium">{label}</summary><p role="status" className="text-xs">{ready?.[key].approved ? 'Approved for this revision' : 'Review required'}</p><div id={fieldId(`${key}-prerequisites`)}>{(ready?.[key].problems || []).map(problem => <p key={problem} className="mt-1 text-xs text-port-text-muted">{problem}</p>)}</div>@@ -238,9 +244,9 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,<details><summary className="cursor-pointer min-h-[44px] py-2 text-sm">Review feedback and revision history</summary><p className="text-sm">Name a cast member, environment, shot, artifact or frame time. Structure acceptance records agreement on organization only; it never approves the art or authorizes production.</p>- <label htmlFor={fieldId('feedback-stage')} className="block text-sm">Feedback stage<select id={fieldId('feedback-stage')} className={fieldClass} value={feedback.stage} onChange={e => setFeedback({ ...feedback, stage: e.target.value })}>+ {!stage && <label htmlFor={fieldId('feedback-stage')} className="block text-sm">Feedback stage<select id={fieldId('feedback-stage')} className={fieldClass} value={feedback.stage} onChange={e => setFeedback({ ...feedback, stage: e.target.value })}>{Object.entries(labels).map(([key, label]) => <option key={key} value={key}>{label}</option>)}- </select></label>+ </select></label>}<label htmlFor={fieldId('feedback-target')} className="block text-sm">Feedback target<input id={fieldId('feedback-target')} className={fieldClass} value={feedback.target} placeholder="Cast: operator; shot: chorus; frame: 12.5s" onChange={e => setFeedback({ ...feedback, target: e.target.value })} /></label><label htmlFor={fieldId('feedback-text')} className="block text-sm">Requested change<textarea id={fieldId('feedback-text')} className={fieldClass} rows={3} value={feedback.text} onChange={e => setFeedback({ ...feedback, text: e.target.value })} /></label><label htmlFor={fieldId('feedback-decision')} className="block text-sm">Review decision<select id={fieldId('feedback-decision')} className={fieldClass} value={feedback.decision} onChange={e => setFeedback({ ...feedback, decision: e.target.value })}>@@ -255,7 +261,7 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,{savedRequestStage && openRequests(savedRequestStage).length > 0 && <p role="status" className="text-sm">Approval stays blocked until these are resolved. <a href={`#mv-review-${savedRequestStage}`} onClick={openReviewSection} className="text-port-accent underline">Revise from feedback</a>, or edit and resolve manually.</p>}- <ul className="mt-3 space-y-3">{(project.productionReview?.feedback || []).map(item => <li key={item.id} className="rounded border border-port-border p-2">+ <ul className="mt-3 space-y-3">{(project.productionReview?.feedback || []).filter(item => !stage || item.stage === stage).map(item => <li key={item.id} className="rounded border border-port-border p-2"><p className="text-sm"><strong>{item.target}</strong> · {item.decision} · {item.resolvedAt ? 'Resolved' : 'Open'}</p><p className="text-sm whitespace-pre-wrap">{item.text}</p><p className="text-xs text-port-text-muted">Reviewed revision {item.basis.slice(0, 12)}{ready?.basis[item.stage] !== item.basis ? ' · content has changed since review' : ' · current revision'}</p>@@ -268,10 +274,11 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,</>}</li>)}</ul></details>- <details id="mv-review-planning" tabIndex={-1} open={window.location.hash === '#mv-review-planning'} style={{ scrollMarginTop: 'calc(var(--mv-header-h, 9rem) + 1rem)' }}>- <summary className="cursor-pointer min-h-[44px] py-2 text-sm">Edit visual guide and storyboard</summary>+ {stage !== 'proof' && <details id="mv-review-planning" tabIndex={-1} open={!!stage || window.location.hash === '#mv-review-planning'} style={{ scrollMarginTop: 'calc(var(--mv-header-h, 9rem) + 1rem)' }}>+ <summary className="cursor-pointer min-h-[44px] py-2 text-sm">{!stage ? 'Edit visual guide and storyboard' : showArt ? 'Edit art direction and visual guide' : 'Edit alignment and storyboard shots'}</summary><div className="space-y-3">- <label htmlFor={fieldId('import')} className="block text-sm">Import planning JSON as an unapproved draft+ {importError && <p role="alert">{importError}</p>}+ {showArt && <label htmlFor={fieldId('import')} className="block text-sm">Import planning JSON as an unapproved draft<input id={fieldId('import')} type="file" accept=".json,application/json" disabled={dirty || review.busy} className={fieldClass}onChange={async e => {const file = e.target.files?.[0]; e.target.value = ''; setImportError(null);@@ -279,8 +286,8 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,try { if (await review.importPlanning(await file.text())) setLocal(null); }catch (error) { setImportError(error.message); }}} />- </label>- {project.composition?.mode === 'document' && <div className="space-y-2 rounded border border-port-border p-2">+ </label>}+ {showBoard && project.composition?.mode === 'document' && <div className="space-y-2 rounded border border-port-border p-2"><p className="text-sm">Document shot manifest</p><p className="text-xs text-port-text-muted">Export the composition in Compose. Have its author extract the actual shot IDs, timings and choreography from the source (for example timeline.js) into the JSON format below, keeping its documentDirectory and audioBasis from when that source was authored. A generic document section or Board row is not a shot list. Reauthor and reimport the composition after changing lyrics or timing, then import its matching manifest here.</p><label htmlFor={fieldId('document-shots')} className="block text-sm">Import document shot manifest@@ -297,7 +304,7 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,<details><summary className="cursor-pointer py-2 text-sm">Shot manifest format</summary><pre className="overflow-auto whitespace-pre-wrap break-all text-xs">{JSON.stringify({ ...ready?.documentShotImport, sourceFile: 'timeline.js', shots: [{ id: 'source-shot-id', sceneId: null, startSec: 0, endSec: 10, lyricCueIds: [], action: 'Source action', staging: 'Source staging', camera: 'Source camera', transition: 'Source transition' }] }, null, 2)}</pre></details><p className="text-xs">{project.productionReview?.documentStoryboard ? `Bound source: ${project.productionReview.documentStoryboard.sourceFile}. Reimporting a document, changing audio or editing these shots requires a new matching manifest.` : 'No document shot manifest bound. Board scenes do not stand in for source shots.'}</p></div>}- {importError && <p role="alert">{importError}</p>}+ {showArt && <>{draft.sourceArtifactId && <button type="button" className={buttonClass} onClick={() => onOpenArtifact(draft.sourceArtifactId)}>Read preserved original planning draft</button>}<button type="button" className={buttonClass} disabled={dirty || review.busy || documentShots} onClick={review.prepare}>Draft art direction and shots</button><p className="text-xs text-port-text-muted">Uses the saved authoring provider and allowed tools. Builds Cast & Sets first, then pauses for art approval before planning shots. Existing edits are retained.</p>@@ -323,6 +330,8 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,</select></label>{draft.guideArtifactId && <button type="button" className={buttonClass} onClick={() => onOpenArtifact(draft.guideArtifactId)}>Review visual sheet</button>}+ </>}+ {showBoard && <><label htmlFor={fieldId('song-content')} className="block text-sm">Song content<select id={fieldId('song-content')} value={draft.lyricsMode} onChange={e => set('lyricsMode', e.target.value)} className={fieldClass}><option value="vocal">Vocal song — aligned lyrics required</option><option value="instrumental">Instrumental — explicit exception</option>@@ -370,10 +379,10 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,</fieldset></details>;})}+ </>}<button type="button" className={buttonClass} disabled={!dirty || review.busy} onClick={async () => { if (await review.save(draft)) setLocal(null); }}>Save planning edits</button>{dirty && <p role="status" className="text-sm">Save edits before preparing, approving or rendering.</p>}</div>- </details>-+ </details>}</section>;}diff --git a/client/src/components/musicVideo/ProductionReviewPanel.test.jsx b/client/src/components/musicVideo/ProductionReviewPanel.test.jsxindex 6314e6d03f..0c1f5c3049 100644--- a/client/src/components/musicVideo/ProductionReviewPanel.test.jsx+++ b/client/src/components/musicVideo/ProductionReviewPanel.test.jsx@@ -316,3 +316,27 @@ describe('Stale alignment review', () => {expect(button.disabled).toBe(true);});});++describe('Per-stage approval sections (#10151)', () => {+ it('renders only its own stage and sends a missing prerequisite to the tab that owns it', () => {+ const review = reviewFixture();+ review.readiness.art.approved = false;+ const prototype = { ...project, productionReview: { ...project.productionReview, proof: null, prototype: { excerptId: 'proof-a' } } };+ const onNavigate = vi.fn();+ render(<ProductionReviewPanel project={prototype} review={review} onOpenArtifact={vi.fn()} stage="proof" onNavigate={onNavigate} />);+ expect(screen.queryByText('Art direction', { selector: 'summary' })).toBeNull();+ expect(screen.queryByText('Edit art direction and visual guide')).toBeNull();+ fireEvent.click(screen.getByText('Review and approve art direction'));+ expect(onNavigate).toHaveBeenCalledWith('cast-sets', 'mv-review-art');+ });++ it('keeps the art fields on the art section and the shot editor on the board section', () => {+ const art = render(<ProductionReviewPanel project={project} review={reviewFixture()} onOpenArtifact={vi.fn()} stage="art" />);+ expect(screen.getByLabelText('Cast guide')).toBeTruthy();+ expect(screen.queryByLabelText('Storyboard source')).toBeNull();+ art.unmount();+ render(<ProductionReviewPanel project={project} review={reviewFixture()} onOpenArtifact={vi.fn()} stage="storyboard" />);+ expect(screen.getByLabelText('Storyboard source')).toBeTruthy();+ expect(screen.queryByLabelText('Cast guide')).toBeNull();+ });+});diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.jsindex 7206c459ec..feef9ecb5b 100644--- a/client/src/lib/musicVideoStages.js+++ b/client/src/lib/musicVideoStages.js@@ -445,7 +445,7 @@ export function deriveNextAction(project, {}}-// The editable art-direction fields Production approvals needs before art can be approved.+// The editable art-direction fields the art approval needs before art can be approved.const ART_DIRECTION_FIELDS = [['cast', 'cast'], ['environments', 'sets'], ['visualLanguage', 'visual language'], ['motionLanguage', 'motion']];/** "Approved earlier — changed since: concept, scene 3 prompt" for an approval whose inputs moved; null otherwise. */export function staleApprovalText(stale) {@@ -455,6 +455,7 @@ export function staleApprovalText(stale) {return stale.changedFields.length ? `Approved earlier — changed since: ${shown}${more}.` : 'Approved earlier — its inputs changed since.';}const APPROVAL_ANCHORS = { art: 'mv-review-art', storyboard: 'mv-review-storyboard', proof: 'mv-review-proof' };+const APPROVAL_STAGES = { art: 'cast-sets', storyboard: 'board', proof: 'compose' };const PUBLISH_ANCHOR = 'mv-publish-kit';// Storyboard readiness problems, grouped by what the user has to go fix. The@@ -485,7 +486,7 @@ function storyboardProblemItems(readiness) {* header's "needs you" agree; `detail` says what is still missing (for an* approval, the server's first readiness problem); `action` is a* `{ label, anchor }` the tab can scroll to. Approvals are revision-bound and- * live in Production approvals, never on a development file: approving a+ * are decided on their own stage tab, never on a development file: approving a* Cast & Sets sheet file does not approve the art direction, so the art item* says so while it is open.*/@@ -499,8 +500,8 @@ export function stageChecklist(stageId, project, readiness = project?.productionconst stale = staleApprovalText(readiness?.[key]?.stale);return {id: `approve-${key}`, label: `${label} approved`, done: approved, stale: !!stale,- detail: approved || !readiness ? null : (stale ? `${stale} Re-approve in Production approvals.` : readiness[key]?.problems?.[0] || waitingText),- action: approved ? null : { label: `Review ${label.toLowerCase()}`, anchor: APPROVAL_ANCHORS[key] },+ detail: approved || !readiness ? null : (stale ? `${stale} Re-approve in the editor below.` : readiness[key]?.problems?.[0] || waitingText),+ action: approved ? null : { label: `Review ${label.toLowerCase()}`, anchor: APPROVAL_ANCHORS[key], stage: APPROVAL_STAGES[key] },};};switch (stageId) {@@ -531,9 +532,9 @@ export function stageChecklist(stageId, project, readiness = project?.production{ id: 'direction', label: 'Art direction written', done: missing.length === 0, detail: missing.length ? `Still missing: ${missing.join(', ')}.` : null,action: missing.length ? { label: 'Write art direction', anchor: APPROVAL_ANCHORS.art } : null },{ id: 'guide', label: guide ? `Visual guide chosen: ${guide.title || guide.filename || 'sheet'}` : 'Visual guide chosen', done: !!guide,- detail: guide ? null : 'Pick a Cast & Sets sheet as the visual guide in Production approvals.',+ detail: guide ? null : 'Pick a Cast & Sets sheet as the visual guide in the art direction editor below.',action: guide ? null : { label: 'Choose a guide', anchor: APPROVAL_ANCHORS.art } },- approval('art', 'Art direction', 'Ready for your review. Approving a sheet file does not approve the art direction; approve it in Production approvals.'),+ approval('art', 'Art direction', 'Ready for your review. Approving a sheet file does not approve the art direction; approve it below.'),];}case 'board': {@@ -542,7 +543,7 @@ export function stageChecklist(stageId, project, readiness = project?.production{ id: 'shots', label: 'Shots planned', done: planned, detail: planned ? null : 'Plan the shots from the header, or add scenes by hand.',action: planned ? null : { label: 'Open the treatment', anchor: 'mv-board-treatment' } },...storyboardProblemItems(readiness),- approval('storyboard', 'Timed storyboard', 'Ready for your review in Production approvals.'),+ approval('storyboard', 'Timed storyboard', 'Ready for your review below.'),];}case 'produce': {diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.jsindex 7171e2afb1..91fcdb968c 100644--- a/client/src/lib/musicVideoStages.test.js+++ b/client/src/lib/musicVideoStages.test.js@@ -383,7 +383,7 @@ describe('stageChecklist', () => {expect(items.map((i) => [i.id, i.done])).toEqual([['direction', true], ['guide', true], ['approve-art', false]]);expect(items[1].label).toBe('Visual guide chosen: Cast sheet');expect(items[2].detail).toMatch(/Approving a sheet file does not approve the art direction/);- expect(items[2].action).toEqual({ label: 'Review art direction', anchor: 'mv-review-art' });+ expect(items[2].action).toEqual({ label: 'Review art direction', anchor: 'mv-review-art', stage: 'cast-sets' });// Its done answer matches the tab's own state, so the checklist and the "needs you" mark agree.expect(deriveStages(castProject(), NOT_APPROVED).current).toBe('cast-sets');const approved = stageChecklist('cast-sets', castProject(), APPROVED);diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 5c237b9825..24004044f5 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -87,7 +87,7 @@ import { videoPosterForJob } from '../lib/creativeDirectorPreview.js';import { sceneTakeList } from '../lib/musicVideoTakes.js';import { deriveAttentionItems } from '../lib/musicVideoAttention.js';import {- productionReviewStopGuidance, approvalSummary, deriveNextAction, deriveStages, projectShotSummary, describeProjectStatus, listPreviewSources, projectSpend, resolveStageParam, stageChecklist, compareMusicVideoProjectsNewestFirst,+ productionReviewStopGuidance, deriveNextAction, deriveStages, projectShotSummary, describeProjectStatus, listPreviewSources, projectSpend, resolveStageParam, stageChecklist, compareMusicVideoProjectsNewestFirst,} from '../lib/musicVideoStages.js';import { groupMusicVideoProjects } from '../lib/musicVideoProjectList.js';import { AUTONOMOUS_STATUS_LABELS, AUTONOMOUS_VIEWABLE_STAGES } from '../lib/musicVideoAutonomous.js';@@ -109,6 +109,8 @@ function autopilotBlocker(project) {// A saved art draft needs every field the server schema requires.const EMPTY_PRODUCTION_DRAFT = { cast: '', environments: '', visualLanguage: '', motionLanguage: '', guideArtifactId: null,lyricsMode: 'vocal', timingStatus: 'provisional', timingNotes: '', storyboard: [] };+// The tab that owns each production approval (#10151).+const APPROVAL_STAGE_BY_TAB = { 'cast-sets': 'art', board: 'storyboard', compose: 'proof' };const STAGE_VIEWS = {setup: SetupStage, 'cast-sets': CastSetsStage, board: BoardStage, produce: ProduceStage, compose: ComposeStage, review: ReviewStage, publish: PublishStage,};@@ -369,6 +371,9 @@ export default function MusicVideo() {// picker opened for one project can never write into another.const [pickerTarget, setPickerTarget] = useState(null);useEffect(() => { setPickerTarget(null); }, [selectedId]);+ // Unsaved planning edits live here, not in the approval section, so they survive a tab switch (each tab mounts its own section).+ const [planningState, setPlanningState] = useState({ id: null, draft: null });+ const planningDraft = [planningState.id === selectedId ? planningState.draft : null, (draft) => setPlanningState({ id: selectedId, draft })];// Contact sheet open state lives in the URL (?sheet=contact) so it survives a// reload and Back closes it.const contactSheetOpen = searchParams.get('sheet') === 'contact';@@ -1432,22 +1437,25 @@ export default function MusicVideo() {<AutonomousRunPanel project={selected} auto={autonomous} readiness={productionReview.readiness} selectedStage={runStage} onSelectStage={setRunStage} framed={false} /></StageSection>)}- <StageSection- key={`production-review-${selected.id}`}- title="Production approvals"- summary={approvalSummary(productionReview.readiness) || 'Visual direction, timed storyboard and a watched proof'}- defaultOpen={nextAction?.id === 'review-production' && nextAction.stage === activeStage}- >- <ProductionReviewPanel project={selected} review={productionReview} onOpenArtifact={openArtifact} framed={false}- proofHere={activeStage === 'compose'} onOpenProof={() => goToStage('compose', 'mv-review-proof')} />- </StageSection></div>}><StageChecklistitems={stageChecklist(activeStage, selected, productionReview.readiness, publish)}- onAction={(action) => goToStage(activeStage, action.anchor)}+ onAction={(action) => goToStage(action.stage || activeStage, action.anchor)}headerAnchor={nextAction?.kind === 'goto' ? nextAction.anchor : null}/>+ {APPROVAL_STAGE_BY_TAB[activeStage] && (+ <ProductionReviewPanel+ key={`${selected.id}-${activeStage}`}+ project={selected}+ review={productionReview}+ onOpenArtifact={openArtifact}+ framed={false}+ stage={APPROVAL_STAGE_BY_TAB[activeStage]}+ planning={planningDraft}+ onNavigate={goToStage}+ />+ )}<StageView key={selected.id} board={board} /></MusicVideoLayout>)}diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsxindex 38816e9ada..b1192584a2 100644--- a/client/src/pages/MusicVideo.test.jsx+++ b/client/src/pages/MusicVideo.test.jsx@@ -2389,14 +2389,16 @@ describe('MusicVideo stage tabs (#9243)', () => {);const selectedTab = () => screen.getByRole('tab', { selected: true });- it('puts the selected stage before shared run/review panels and preserves review drafts when tabs change', async () => {+ it('puts the selected stage before the shared run panel, shows only its own approval, and keeps unsaved planning edits across tabs', async () => {listMusicVideoProjects.mockResolvedValue([{ ...PROJECT_WITH_CLIP,autonomousRun: { status: 'needs-human', stage: 'video', output: {}, brief: {} },}]);renderAt('/music-video/mv-1/cast-sets');await screen.findByRole('heading', { level: 2, name: PROJECT_WITH_CLIP.name });const review = screen.getByRole('region', { name: 'Production review' });- fireEvent.click(within(review).getByText('Edit visual guide and storyboard'));+ expect(within(review).getByText('Art direction')).toBeInTheDocument();+ expect(within(review).queryByText('Lyric-timed storyboard')).toBeNull();+ expect(screen.queryByText('Production approvals')).toBeNull();const castDraft = within(review).getByLabelText('Cast guide');fireEvent.change(castDraft, { target: { value: 'Example unsaved cast direction' } });@@ -2404,12 +2406,13 @@ describe('MusicVideo stage tabs (#9243)', () => {await openStage(stage);const panel = screen.getByRole('tabpanel');expect(within(panel).getByRole('heading', { level: 3, name: selectedTab().textContent })).toBeInTheDocument();- for (const shared of [screen.getByRole('region', { name: 'Autonomous run' }), review]) {- expect(panel.contains(shared)).toBe(false);- expect(panel.compareDocumentPosition(shared) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();- }- expect(within(review).getByLabelText('Cast guide')).toHaveValue('Example unsaved cast direction');+ const run = screen.getByRole('region', { name: 'Autonomous run' });+ expect(panel.contains(run)).toBe(false);+ expect(panel.compareDocumentPosition(run) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ if (stage === 'board') expect(within(panel).getByText('Lyric-timed storyboard')).toBeInTheDocument();+ if (stage === 'produce') expect(screen.queryByRole('region', { name: 'Production review' })).toBeNull();}+ expect(screen.getByLabelText('Cast guide')).toHaveValue('Example unsaved cast direction');});it('uses the newly selected project making-of notes and links when drafting publication copy', async () => {@@ -2771,8 +2774,9 @@ describe('direct production review navigation', () => {const action = await screen.findByRole('button', { name: 'Review art direction' });expect(screen.getByLabelText('Project')).toHaveTextContent('2 document shots');fireEvent.click(action);+ // The art approval now mounts on the Cast & Sets tab, so it only exists once the jump lands.+ await waitFor(() => expect(document.getElementById('mv-review-art')).toHaveFocus());const art = document.getElementById('mv-review-art');- await waitFor(() => expect(art).toHaveFocus());expect(art.closest('details').open).toBe(true);expect(screen.getByTestId('loc')).toHaveTextContent('/cast-sets#mv-review-art');fireEvent.click(screen.getByRole('button', { name: 'Review art direction' }));@@ -2783,7 +2787,7 @@ describe('direct production review navigation', () => {fireEvent.click(screen.getByRole('button', { name: 'go--1' }));expect(screen.getByTestId('loc')).toHaveTextContent('/review');fireEvent.click(screen.getByRole('button', { name: 'go-1' }));- await waitFor(() => expect(art).toHaveFocus());+ await waitFor(() => expect(document.getElementById('mv-review-art')).toHaveFocus());});});@@ -2800,7 +2804,7 @@ describe('stage checklist and Setup project options', () => {await openProject(project, 'cast-sets');const checklist = screen.getByRole('region', { name: 'What this stage needs' });expect(checklist).toHaveTextContent('1 of 3 done');- expect(checklist).toHaveTextContent('Pick a Cast & Sets sheet as the visual guide in Production approvals.');+ expect(checklist).toHaveTextContent('Pick a Cast & Sets sheet as the visual guide in the art direction editor below.');expect(checklist).toHaveTextContent('Art direction approved');expect(checklist).toHaveTextContent('Approving a sheet file does not approve the art direction');});