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
fix: foreground playable music video drafts in compact mobile review
[._.]/ Adam Eivy3fe8389593e3
diff --git a/client/src/components/creative-director/ScenePreview.jsx b/client/src/components/creative-director/ScenePreview.jsxindex edbd6c0092..ec0c966aaa 100644--- a/client/src/components/creative-director/ScenePreview.jsx+++ b/client/src/components/creative-director/ScenePreview.jsx@@ -90,12 +90,12 @@ export default function ScenePreview({ jobId, label, aspectClass = 'aspect-video});}, [autoPlay, src, jobId, attempt]);- if (!jobId) {+ if (!jobId && !src) {return <div className={`bg-port-bg ${aspectClass} flex items-center justify-center text-port-text-muted text-xs`}>no render yet</div>;}- const cacheBust = attempt > 0 ? `?retry=${attempt}` : '';+ const cacheBust = attempt > 0 ? `${src?.includes('?') ? '&' : '?'}retry=${attempt}` : '';const videoSrc = `${src || videoSrcForJob(jobId)}${cacheBust}`;- const posterSrc = `${videoPosterForJob(jobId)}${cacheBust}`;+ const posterSrc = jobId ? `${videoPosterForJob(jobId)}${attempt > 0 ? `?retry=${attempt}` : ''}` : undefined;if (missing) {return (<div className={`bg-port-bg ${aspectClass} flex flex-col items-center justify-center text-port-text-muted text-xs gap-2`}>diff --git a/client/src/components/musicVideo/DevArtifactDrawer.jsx b/client/src/components/musicVideo/DevArtifactDrawer.jsxindex 0f343a7634..bbf6eee930 100644--- a/client/src/components/musicVideo/DevArtifactDrawer.jsx+++ b/client/src/components/musicVideo/DevArtifactDrawer.jsx@@ -138,8 +138,8 @@ export default function DevArtifactDrawer({</button></div>- <div>- <h3 className="text-xs uppercase tracking-wide text-port-text-muted mb-1">Notes</h3>+ <details>+ <summary className="min-h-[44px] cursor-pointer text-sm">Notes and provenance · {(artifact.notes || []).length}</summary>{(artifact.notes || []).length === 0 && <p className="text-xs text-port-text-muted">No notes yet.</p>}<ul className="space-y-1.5">{[...(artifact.notes || [])].reverse().map((note) => (@@ -155,10 +155,10 @@ export default function DevArtifactDrawer({</li>))}</ul>- </div>+ </details>- <div>- <h3 className="text-xs uppercase tracking-wide text-port-text-muted mb-1">Versions</h3>+ <details>+ <summary className="min-h-[44px] cursor-pointer text-sm">Version history · {(artifact.versions || []).length}</summary><ol className="space-y-1 text-xs">{[...(artifact.versions || [])].reverse().map((v) => (<li key={v.version}>@@ -169,7 +169,7 @@ export default function DevArtifactDrawer({</li>))}</ol>- </div>+ </details><div className="pt-2 border-t border-port-border">{confirmDelete ? (diff --git a/client/src/components/musicVideo/DevArtifactPreview.jsx b/client/src/components/musicVideo/DevArtifactPreview.jsxindex c1dae4cb80..62050edb5d 100644--- a/client/src/components/musicVideo/DevArtifactPreview.jsx+++ b/client/src/components/musicVideo/DevArtifactPreview.jsx@@ -18,6 +18,6 @@ export default function DevArtifactPreview({ projectId, artifact, version = articonst title = `${artifact.title} v${version || 1}`;const props = { onLoad: () => onReady?.(true), onError: () => { onReady?.(false); setResponse({ url, available: false }); }, className: 'w-full min-w-0 rounded border border-port-border' };if (entry.mimeType?.startsWith('image/')) return <img {...props} src={url} alt={title} />;- if (entry.mimeType?.startsWith('video/')) return <video {...props} onLoadedData={() => onReady?.(true)} src={url} controls aria-label={title} />;+ if (entry.mimeType?.startsWith('video/')) return <video {...props} onLoadedData={() => onReady?.(true)} src={url} controls playsInline preload="metadata" aria-label={title} />;return <iframe {...props} key={url} src={url} title={title} sandbox="allow-scripts" referrerPolicy="no-referrer" className={`${props.className} h-[55vh] bg-white`} />;}diff --git a/client/src/components/musicVideo/DevArtifactsPanel.jsx b/client/src/components/musicVideo/DevArtifactsPanel.jsxindex e2f614f5ee..f9c41d256f 100644--- a/client/src/components/musicVideo/DevArtifactsPanel.jsx+++ b/client/src/components/musicVideo/DevArtifactsPanel.jsx@@ -1,8 +1,10 @@import { useState } from 'react';import { FileText, Film, Image as ImageIcon, LayoutGrid, Users, Upload, FolderOpen, Check } from 'lucide-react';import Pill from '../ui/Pill.jsx';+import VideoArtifactThumbnail from './VideoArtifactThumbnail.jsx';import FilePickerButton from '../ui/FilePickerButton.jsx';import { timeAgo } from '../../utils/formatters.js';+import { musicVideoDevArtifactFileUrl } from '../../services/apiMusicVideo.js';export const DEV_ARTIFACT_KIND_LABELS = {'cast-sets': 'Cast & Sets',@@ -69,17 +71,22 @@ export default function DevArtifactsPanel({)}</div>{artifacts.length > 0 && (- <ul className="divide-y divide-port-border">+ <ul className="grid grid-cols-2 gap-2 sm:grid-cols-3 xl:grid-cols-4">{artifacts.map((artifact) => {const Icon = KIND_ICONS[artifact.kind] || ImageIcon;const status = DEV_ARTIFACT_STATUS[artifact.status] || DEV_ARTIFACT_STATUS.pending;const open = (artifact.notes || []).filter((n) => !n.resolvedAt).length;return (- <li key={artifact.id} className="flex flex-wrap items-center gap-1">+ <li key={artifact.id} className="min-w-0 rounded border border-port-border p-2"><button type="button" onClick={() => onOpen(artifact.id)}- className="flex-1 min-w-0 flex flex-wrap items-center gap-2 py-2 text-left min-h-[44px] hover:bg-port-bg/60 rounded px-1">- <Icon size={15} className="text-port-text-muted shrink-0" aria-hidden="true" />- <span className="text-sm min-w-0 flex-1 truncate">{artifact.title}</span>+ className="w-full min-w-0 space-y-1 text-left min-h-[44px] hover:bg-port-bg/60 rounded"+ aria-label={`Open ${artifact.title} v${artifact.version}`}>+ <span className="flex aspect-video items-center justify-center overflow-hidden rounded bg-port-bg">+ {artifact.mimeType?.startsWith('image/') ? <img loading="lazy" src={musicVideoDevArtifactFileUrl(project.id, artifact.id, artifact.version)} alt="" className="h-full w-full object-cover" />+ : artifact.mimeType === 'video/mp4' ? <VideoArtifactThumbnail src={musicVideoDevArtifactFileUrl(project.id, artifact.id, artifact.version)} className="h-full w-full" />+ : <Icon size={28} className="text-port-text-muted" aria-hidden="true" />}+ </span>+ <span className="block text-sm min-w-0 truncate" title={artifact.title}>{artifact.title}</span><span className="text-[11px] text-port-text-muted">{DEV_ARTIFACT_KIND_LABELS[artifact.kind] || artifact.kind} · v{artifact.version}</span>{open > 0 && <Pill size="xs" tone="accent">{open} open note{open === 1 ? '' : 's'}</Pill>}<Pill size="xs" tone={status.tone}>{status.label}</Pill>diff --git a/client/src/components/musicVideo/MusicVideoLayout.jsx b/client/src/components/musicVideo/MusicVideoLayout.jsxindex e1303bda1d..c96176d2bd 100644--- a/client/src/components/musicVideo/MusicVideoLayout.jsx+++ b/client/src/components/musicVideo/MusicVideoLayout.jsx@@ -1,6 +1,6 @@import { useEffect, useRef, useState } from 'react';import {- AlertTriangle, ArrowRight, CheckCircle2, CircleDot, Clapperboard, Film, History, Layers, LayoutGrid, Music, Play,+ AlertTriangle, ArrowRight, CheckCircle2, ChevronDown, CircleDot, Clapperboard, Film, History, Layers, LayoutGrid, Music, Play,Send, SlidersHorizontal, Users,} from 'lucide-react';import TabPills from '../ui/TabPills.jsx';@@ -52,12 +52,12 @@ function ProjectStatusLine({ status }) {<div><buttontype="button"- className="flex min-h-8 w-full min-w-0 items-center gap-1 text-left text-xs sm:hidden"+ className="flex min-h-[44px] w-full min-w-0 items-center gap-1 text-left text-xs sm:hidden"aria-expanded={facts.length > 0 ? open : undefined}onClick={() => { if (facts.length > 0) setOpen((value) => !value); }}>- <span className={`min-w-0 truncate font-medium ${STATUS_TONES[status.tone] || ''}`}>{status.headline}</span>- {facts.length > 0 && <span className="shrink-0 text-port-text-muted">· {facts.length}</span>}+ <span className={`min-w-0 font-medium ${STATUS_TONES[status.tone] || ''}`}>{status.headline}</span>+ {facts.length > 0 && <ChevronDown size={14} aria-hidden="true" className={`shrink-0 ${open ? 'rotate-180' : ''}`} />}</button>{open && facts.length > 0 && (<p className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs">@@ -123,18 +123,18 @@ export default function MusicVideoLayout({icon: STAGE_ICONS[entry.id],trailing: entry.state !== 'blocked' && entry.stale ? STALE_MARK : STAGE_TRAILING[entry.state] || null,}));- const showSpend = spend.spentUsd > 0 || spend.capUsd != null;+ const showSpend = spend.spentUsd > 0 || spend.capUsd > 0;const stageEntry = progress.stages.find((entry) => entry.id === stage);const ActionIcon = nextAction?.kind === 'goto' ? ArrowRight : Play;return (- <div ref={rootRef} className={`space-y-3 ${dockVisible ? 'max-lg:pb-40' : 'max-md:pb-20'}`}>+ <div ref={rootRef} className={`space-y-3 ${dockVisible ? 'max-lg:pb-[calc(10rem+env(safe-area-inset-bottom))]' : 'max-md:pb-[calc(5rem+env(safe-area-inset-bottom))]'}`}><headerref={headerRef}className="sticky top-[calc(env(safe-area-inset-top)-1rem)] z-30 -mx-4 -mt-4 space-y-2 border-b border-port-border bg-port-bg px-4 pt-2 md:top-[calc(env(safe-area-inset-top)-1.5rem)] md:-mx-6 md:-mt-6 md:px-6">- <div className="flex min-w-0 items-center gap-3">- <h2 className="min-w-0 flex-1 truncate text-lg font-semibold" title={project.name}>{project.name}</h2>+ <div className="flex min-w-0 flex-wrap items-center gap-3">+ <h2 className="min-w-0 flex-1 basis-full truncate text-lg font-semibold max-sm:whitespace-normal max-sm:break-words sm:basis-auto" title={project.name}>{project.name}</h2><span className="flex min-w-0 items-center gap-1 text-xs text-port-text-muted max-sm:hidden"><Music size={12} className="shrink-0" aria-hidden="true" /><span className="truncate">{trackLabel}</span>@@ -153,7 +153,7 @@ export default function MusicVideoLayout({disabled={nextAction.disabled}title={nextAction.reason}aria-label={nextAction.label}- className="flex h-8 shrink-0 items-center gap-1 rounded bg-port-accent px-2 text-xs text-white disabled:opacity-50 sm:h-auto sm:min-h-0 sm:px-3 sm:py-1.5 sm:text-sm"+ className="flex min-h-[44px] shrink-0 items-center gap-1 rounded bg-port-accent px-2 text-xs text-white disabled:opacity-50 sm:min-h-0 sm:px-3 sm:py-1.5 sm:text-sm"><ActionIcon size={14} aria-hidden="true" /><span className="sm:hidden">{nextAction.shortLabel || nextAction.label}</span>@@ -162,6 +162,7 @@ export default function MusicVideoLayout({)}</div>{status && <ProjectStatusLine status={status} />}+ {nextAction?.disabled && nextAction.reason && <p role="status" className="text-xs text-port-text-muted">{nextAction.reason}</p>}{attention}<navaria-label="Stages"diff --git a/client/src/components/musicVideo/MusicVideoProjectCard.jsx b/client/src/components/musicVideo/MusicVideoProjectCard.jsxindex 7a4d0208dc..7930dc8aa3 100644--- a/client/src/components/musicVideo/MusicVideoProjectCard.jsx+++ b/client/src/components/musicVideo/MusicVideoProjectCard.jsx@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';import { Film, Play, Music, Wand2, Sparkles, Copy, Trash2, ArrowUpRight, ChevronLeft, ChevronRight } from 'lucide-react';import MediaImage from '../MediaImage.jsx';import ScenePreview from '../creative-director/ScenePreview.jsx';+import VideoArtifactThumbnail from './VideoArtifactThumbnail.jsx';import ConfirmButtonPair from '../ui/ConfirmButtonPair.jsx';import { formatUsd } from '../../utils/formatters.js';import { selectMusicVideoPreview } from '../../lib/musicVideoPreview.js';@@ -28,6 +29,7 @@ export default function MusicVideoProjectCard({project,trackLabel,onSelect,+ onReview,onClone,isConfirmingDelete = false,onRequestDelete,@@ -42,6 +44,9 @@ export default function MusicVideoProjectCard({// The index loads bounded summaries (#10169) that carry these derived values; a// full record (just created or forked) still derives them from its own fields.const preview = project.preview || selectMusicVideoPreview(project);+ const [draftMedia, setDraftMedia] = useState(null);+ const importedDraft = preview.source === 'animatic';+ const draftAvailable = draftMedia?.src === preview.src && draftMedia?.available;// When preview target changes, stop playinguseEffect(() => {@@ -82,11 +87,11 @@ export default function MusicVideoProjectCard({>{/* Top Header & Identification */}<div className="space-y-1.5 min-w-0">- <div className="flex items-start justify-between gap-2">+ <div className="flex flex-wrap items-start justify-between gap-2"><buttontype="button"onClick={onSelect}- className="text-left font-semibold text-base text-port-text hover:text-port-accent transition-colors truncate max-w-full flex-1"+ className="text-left font-semibold text-base text-port-text hover:text-port-accent transition-colors break-words max-w-full flex-1 basis-full sm:basis-auto"title={project.name}>{project.name}@@ -121,35 +126,15 @@ export default function MusicVideoProjectCard({</span>)}<span className={`text-[10px] font-medium px-2 py-0.5 rounded ${STATUS_COLORS[project.status] || 'bg-port-border'}`}>- {project.status}+ {preview.stale ? 'Final out of date' : importedDraft ? (draftMedia?.src === preview.src && draftMedia?.available === false ? 'Draft unavailable' : draftAvailable ? preview.reviewStatus === 'pending' ? 'Ready to review' : preview.reviewStatus === 'approved' ? 'Draft reviewed' : 'Changes requested' : 'Imported draft') : project.status}</span></div></div>- {/* Mode & Stage indicators */}- <div className="flex flex-wrap items-center gap-1.5 text-[10px]">- {project.mode === 'autonomous' ? (- <span className="px-1.5 py-0.5 rounded bg-port-accent/20 text-port-accent border border-port-accent/30 flex items-center gap-1">- <Wand2 size={10} aria-hidden="true" /> Autopilot- </span>- ) : (- <span className="px-1.5 py-0.5 rounded bg-port-border/60 text-port-text-muted flex items-center gap-1">- <Film size={10} aria-hidden="true" /> Director- </span>- )}- <span className="px-1.5 py-0.5 rounded bg-port-bg border border-port-border text-port-text-muted">- Stage: <strong className="text-port-text font-medium">{stageLabel}</strong>- </span>- {project.concept?.universeId && (- <span className="px-1.5 py-0.5 rounded bg-purple-500/15 text-purple-300 border border-purple-500/30 flex items-center gap-1">- <Sparkles size={10} aria-hidden="true" /> {project.concept.universeId}- </span>- )}- </div></div>{/* Media Preview Box */}- <div className="relative aspect-video rounded bg-black/50 border border-port-border overflow-hidden group shrink-0">+ <div className={`relative ${preview.kind === 'none' ? 'min-h-[4rem]' : 'aspect-video'} rounded bg-port-bg border border-port-border overflow-hidden group shrink-0`}>{preview.kind === 'video' && playing ? (resolving ? (<div className="w-full h-full flex items-center justify-center text-xs text-port-text-muted">@@ -173,23 +158,26 @@ export default function MusicVideoProjectCard({className="block w-full h-full text-left"aria-label={`Open project ${project.name}`}>- <MediaImage+ {importedDraft ? <VideoArtifactThumbnail src={preview.src}+ className="w-full h-full object-cover"+ onLoadedData={() => setDraftMedia({ src: preview.src, available: true })}+ onError={() => setDraftMedia({ src: preview.src, available: false })} /> : <MediaImagesrc={preview.poster}alt={`${project.name} preview`}loading="lazy"className="w-full h-full object-cover"- />+ />}</button><buttontype="button"onClick={() => setPlaying(true)}aria-label={`Play ${preview.label}`}title={`Play ${preview.label}`}- className="always-dark absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-10 h-10 flex items-center justify-center rounded-full bg-black/60 text-white hover:bg-black/80 hover:scale-105 transition-all shadow-lg focus:outline-none focus:ring-2 focus:ring-port-accent"+ className="port-media-overlay-strong absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-11 h-11 flex items-center justify-center rounded-full hover:scale-105 transition-all shadow-lg focus:outline-none focus:ring-2 focus:ring-port-accent"><Play size={16} className="ml-0.5" aria-hidden="true" /></button>- <span className="always-dark absolute bottom-1.5 left-1.5 px-1.5 py-0.5 rounded bg-black/70 text-white text-[10px] font-medium pointer-events-none flex items-center gap-1">+ <span className="port-media-overlay-strong absolute bottom-1.5 left-1.5 px-1.5 py-0.5 rounded text-[10px] font-medium pointer-events-none flex items-center gap-1"><Film size={10} aria-hidden="true" /> {preview.label}</span></>@@ -209,7 +197,7 @@ export default function MusicVideoProjectCard({className="w-full h-full object-cover"/></button>- <span className="always-dark absolute bottom-1.5 left-1.5 px-1.5 py-0.5 rounded bg-black/70 text-white text-[10px] font-medium pointer-events-none">+ <span className="port-media-overlay-strong absolute bottom-1.5 left-1.5 px-1.5 py-0.5 rounded text-[10px] font-medium pointer-events-none">{preview.label}</span></>@@ -227,7 +215,30 @@ export default function MusicVideoProjectCard({</div>{/* Rich Configuration Options & Audio Info */}+ <details className="text-xs">+ <summary className="min-h-[44px] cursor-pointer flex items-center text-port-text-muted">Production details · {stageLabel}</summary><div className="space-y-2 text-xs">+ {/* Mode & Stage indicators */}+ <div className="flex flex-wrap items-center gap-1.5 text-[10px]">+ {project.mode === 'autonomous' ? (+ <span className="px-1.5 py-0.5 rounded bg-port-accent/20 text-port-accent border border-port-accent/30 flex items-center gap-1">+ <Wand2 size={10} aria-hidden="true" /> Autopilot+ </span>+ ) : (+ <span className="px-1.5 py-0.5 rounded bg-port-border/60 text-port-text-muted flex items-center gap-1">+ <Film size={10} aria-hidden="true" /> Director+ </span>+ )}+ <span className="px-1.5 py-0.5 rounded bg-port-bg border border-port-border text-port-text-muted">+ Stage: <strong className="text-port-text font-medium">{stageLabel}</strong>+ </span>+ {project.concept?.universeId && (+ <span className="px-1.5 py-0.5 rounded bg-purple-500/15 text-purple-300 border border-purple-500/30 flex items-center gap-1">+ <Sparkles size={10} aria-hidden="true" /> {project.concept.universeId}+ </span>+ )}+ </div>+{/* Audio row */}<div className="flex items-center justify-between gap-2 text-port-text-muted"><span className="flex items-center gap-1.5 truncate font-medium text-port-text" title={audioTitle || 'No audio track'}>@@ -321,22 +332,23 @@ export default function MusicVideoProjectCard({</div></div>+ </details>{/* Footer Actions */}<div className="flex items-center justify-between gap-2 pt-2 border-t border-port-border mt-auto shrink-0"><div className="flex items-center gap-1.5"><buttontype="button"- onClick={onSelect}- className="bg-port-accent hover:bg-port-accent/80 text-white rounded px-2.5 py-1 text-xs font-medium flex items-center gap-1 min-h-[32px] transition-colors"+ onClick={onReview || onSelect}+ className="bg-port-accent hover:bg-port-accent/80 text-white rounded px-2.5 py-1 text-xs font-medium flex items-center gap-1 min-h-[44px] transition-colors">- Open <ArrowUpRight size={13} aria-hidden="true" />+ {importedDraft ? 'Review draft' : preview.source === 'final' ? 'Review video' : 'Open'} <ArrowUpRight size={13} aria-hidden="true" /></button><buttontype="button"onClick={() => onClone?.()}disabled={cloning}title="Fork this project version"- className="bg-port-bg border border-port-border hover:bg-port-border/40 text-port-text rounded px-2 py-1 text-xs flex items-center gap-1 min-h-[32px] disabled:opacity-50 transition-colors"+ className="bg-port-bg border border-port-border hover:bg-port-border/40 text-port-text rounded px-2 py-1 text-xs flex items-center gap-1 min-h-[44px] disabled:opacity-50 transition-colors"><Copy size={13} aria-hidden="true" /> {cloning ? 'Forking…' : 'Fork'}</button>@@ -357,7 +369,7 @@ export default function MusicVideoProjectCard({onClick={onRequestDelete}title={`Delete project ${project.name}`}aria-label={`Delete project ${project.name}`}- className="flex min-h-[32px] min-w-[32px] items-center justify-center rounded border border-port-border px-2 py-1 text-xs text-port-error hover:bg-port-error/10 transition-colors"+ className="flex min-h-[44px] min-w-[44px] items-center justify-center rounded border border-port-border px-2 py-1 text-xs text-port-error hover:bg-port-error/10 transition-colors"><Trash2 size={13} aria-hidden="true" /></button>diff --git a/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx b/client/src/components/musicVideo/MusicVideoProjectCard.test.jsxindex b5db2dc21d..5caff9fb8a 100644--- a/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx+++ b/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx@@ -1,4 +1,4 @@-import { describe, it, expect, vi } from 'vitest';+import { describe, it, expect, vi, afterEach } from 'vitest';import { render, screen, fireEvent, act, waitFor } from '@testing-library/react';import MusicVideoProjectCard from './MusicVideoProjectCard.jsx';@@ -36,8 +36,39 @@ const BASE_PROJECT = {],renderHistoryId: null,};+afterEach(() => vi.unstubAllGlobals());describe('MusicVideoProjectCard', () => {+ it('offers a distinct review action for an existing final render', () => {+ const onSelect = vi.fn(), onReview = vi.fn();+ render(<MusicVideoProjectCard project={{ ...BASE_PROJECT, renderHistoryId: 'example-final' }} onSelect={onSelect} onReview={onReview} />);+ fireEvent.click(screen.getByRole('button', { name: 'Review video' }));+ expect(onReview).toHaveBeenCalledTimes(1);+ expect(onSelect).not.toHaveBeenCalled();+ });+ it('offers exact imported-draft playback and only says ready after media loaded', async () => {+ let intersect;+ vi.stubGlobal('IntersectionObserver', class {+ constructor(callback) { intersect = callback; }+ observe() {}+ disconnect() {}+ });+ const src = '/api/music-video/example/dev-artifacts/film/file?version=2';+ const project = { ...BASE_PROJECT, preview: { kind: 'video', source: 'animatic', artifactId: 'film', version: 2, src, poster: null, label: 'Imported draft · v2', reviewStatus: 'pending' } };+ const { container } = render(<MusicVideoProjectCard project={project} />);+ expect(screen.queryByText('Ready to review')).toBeNull();+ expect(container.querySelector('video')).toBeNull(); // offscreen cards fetch no media+ act(() => intersect([{ isIntersecting: true }]));+ fireEvent.loadedData(container.querySelector('video'));+ expect(screen.getByText('Ready to review')).toBeInTheDocument();+ fireEvent.error(container.querySelector('video'));+ expect(screen.queryByText('Ready to review')).toBeNull();+ fireEvent.click(screen.getByRole('button', { name: 'Play Imported draft · v2' }));+ await waitFor(() => expect(container.querySelector('video')?.getAttribute('src')).toContain(src));+ fireEvent.error(container.querySelector('video'));+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));+ expect(container.querySelector('video').getAttribute('src')).toBe(`${src}&retry=1`);+ });it('renders a bounded summary (no scenes/runs) the same as a full record (#10169)', () => {const { scenes, ...rest } = BASE_PROJECT;const summary = {diff --git a/client/src/components/musicVideo/ProductionReviewPanel.jsx b/client/src/components/musicVideo/ProductionReviewPanel.jsxindex 5d80b642fa..d3b2c0a595 100644--- a/client/src/components/musicVideo/ProductionReviewPanel.jsx+++ b/client/src/components/musicVideo/ProductionReviewPanel.jsx@@ -205,11 +205,13 @@ 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">{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>+ <details><summary className="min-h-[44px] cursor-pointer text-xs text-port-text-muted">About production approvals</summary>+ <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>+ </details>{review.error && <p role="alert" className="text-port-error">{review.error}</p>}<ol className="space-y-3">- {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">+ {Object.entries(labels).filter(([key]) => !stage || key === stage).map(([key, label]) => <li key={key}><details open={window.location.hash === `#mv-review-${key}` || (!stage && 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>@@ -274,7 +276,7 @@ export default function ProductionReviewPanel({ project, review, onOpenArtifact,</>}</li>)}</ul></details>- {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)' }}>+ {stage !== 'proof' && <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">{!stage ? 'Edit visual guide and storyboard' : showArt ? 'Edit art direction and visual guide' : 'Edit alignment and storyboard shots'}</summary><div className="space-y-3">{importError && <p role="alert">{importError}</p>}diff --git a/client/src/components/musicVideo/ReviewDraftPanel.jsx b/client/src/components/musicVideo/ReviewDraftPanel.jsxnew file mode 100644index 0000000000..43a40712e5--- /dev/null+++ b/client/src/components/musicVideo/ReviewDraftPanel.jsx@@ -0,0 +1,20 @@+import { useMusicVideoReviewDraft } from '../../hooks/useMusicVideoReviewDraft.js';+import DevArtifactPreview from './DevArtifactPreview.jsx';++/** Playback of the recorded animatic version does not change native readiness. */+export default function ReviewDraftPanel({ project, onOpen, draftState }) {+ const localState = useMusicVideoReviewDraft(project, { enabled: !draftState });+ const { draft, checking, unavailableCount } = draftState || localState;+ if (checking) return <p role="status">Finding an available review draft…</p>;+ if (!draft) return unavailableCount ? <p role="alert">Imported drafts are unavailable. Choose an available development file below.</p> : null;+ const artifact = project.devArtifacts.find(item => item.id === draft.artifactId);+ return <section aria-label="Imported review draft" className="min-w-0 space-y-2 rounded-lg border border-port-border bg-port-card p-3">+ <div className="flex flex-wrap items-center justify-between gap-2">+ <h3 className="text-sm font-medium">Review draft · v{draft.version}</h3>+ <button type="button" onClick={() => onOpen(draft.artifactId)} className="min-h-[44px] rounded bg-port-accent px-3 text-sm text-white">Review & add notes</button>+ </div>+ <DevArtifactPreview key={draft.src} projectId={project.id} artifact={artifact} version={draft.version} />+ {unavailableCount > 0 && <p role="status" className="text-xs text-port-warning">Newer draft unavailable · showing {artifact.title} v{draft.version}.</p>}+ <p className="text-xs text-port-text-muted">Imported animatic · {draft.reviewStatus === 'approved' ? 'Draft reviewed' : draft.reviewStatus === 'changes-requested' ? 'Changes requested' : 'Pending review'}. Native storyboard and proof approvals are separate.</p>+ </section>;+}diff --git a/client/src/components/musicVideo/ReviewDraftPanel.test.jsx b/client/src/components/musicVideo/ReviewDraftPanel.test.jsxnew file mode 100644index 0000000000..c227f14088--- /dev/null+++ b/client/src/components/musicVideo/ReviewDraftPanel.test.jsx@@ -0,0 +1,47 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import ReviewDraftPanel from './ReviewDraftPanel.jsx';++const artifact = (id, day, version) => {+ const file = `music-video/example/dev/${id}/v${version}.mp4`;+ return { id, title: `${id} film`, kind: 'animatic', status: 'pending', version, file, mimeType: 'video/mp4',+ versions: [{ version, file, mimeType: 'video/mp4', bytes: 100, createdAt: `2026-01-${day}` }] };+};+const project = { id: 'example', devArtifacts: [artifact('old', '01', 2), artifact('new', '02', 3)] };+afterEach(() => vi.unstubAllGlobals());++describe('implicit imported draft review', () => {+ it('skips a missing newest file, discloses the fallback and opens the exact available artifact', async () => {+ const fetchFile = vi.fn(async url => ({ ok: !url.includes('/new/') }));+ vi.stubGlobal('fetch', fetchFile);+ const onOpen = vi.fn();+ render(<ReviewDraftPanel project={project} onOpen={onOpen} />);+ const player = await screen.findByLabelText('old film v2');+ expect(player).toHaveAttribute('src', '/api/music-video/example/dev-artifacts/old/file?version=2');+ expect(screen.getByText('Newer draft unavailable · showing old film v2.')).toBeInTheDocument();+ expect(fetchFile.mock.calls[0][0]).toBe('/api/music-video/example/dev-artifacts/new/file?version=3');+ fireEvent.click(screen.getByRole('button', { name: 'Review & add notes' }));+ expect(onOpen).toHaveBeenCalledWith('old');+ expect(screen.queryByRole('button', { name: /Approve/ })).toBeNull();+ });++ it('reports all missing drafts without offering a review action or an approval', async () => {+ const fetchFile = vi.fn(async () => ({ ok: false }));+ vi.stubGlobal('fetch', fetchFile);+ render(<ReviewDraftPanel project={project} onOpen={vi.fn()} />);+ expect(await screen.findByRole('alert')).toHaveTextContent('Imported drafts are unavailable');+ expect(fetchFile).toHaveBeenCalledTimes(2);+ expect(screen.queryByRole('button')).toBeNull();+ });++ it('drops availability responses from a superseded project', async () => {+ let finishOld;+ vi.stubGlobal('fetch', vi.fn(url => url.includes('/new/') ? new Promise(resolve => { finishOld = resolve; }) : Promise.resolve({ ok: true })));+ const { rerender } = render(<ReviewDraftPanel project={project} onOpen={vi.fn()} />);+ await waitFor(() => expect(finishOld).toBeTypeOf('function'));+ rerender(<ReviewDraftPanel project={{ id: 'other', devArtifacts: [artifact('old', '01', 2)] }} onOpen={vi.fn()} />);+ expect(await screen.findByLabelText('old film v2')).toHaveAttribute('src', '/api/music-video/other/dev-artifacts/old/file?version=2');+ finishOld({ ok: true });+ await waitFor(() => expect(screen.queryByLabelText('new film v3')).toBeNull());+ });+});diff --git a/client/src/components/musicVideo/VideoArtifactThumbnail.jsx b/client/src/components/musicVideo/VideoArtifactThumbnail.jsxnew file mode 100644index 0000000000..3db0a62f4a--- /dev/null+++ b/client/src/components/musicVideo/VideoArtifactThumbnail.jsx@@ -0,0 +1,19 @@+import { useEffect, useRef, useState } from 'react';+import { Film } from 'lucide-react';++/** Request a frame only when the thumbnail is visible, including inside disclosures. */+export default function VideoArtifactThumbnail({ src, className, onLoadedData, onError }) {+ const root = useRef(null);+ const [visible, setVisible] = useState(false);+ useEffect(() => {+ if (typeof IntersectionObserver !== 'function') return;+ const observer = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting));+ observer.observe(root.current);+ return () => observer.disconnect();+ }, []);+ return <span ref={root} className={`flex items-center justify-center ${className}`}>+ {visible ? <video src={`${src}#t=0.1`} preload="metadata" muted playsInline tabIndex={-1} aria-hidden="true"+ onLoadedData={onLoadedData} onError={onError} className="h-full w-full object-cover" />+ : <Film size={28} className="text-port-text-muted" aria-hidden="true" />}+ </span>;+}diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsxindex f60467d7a1..cd326628ec 100644--- a/client/src/components/musicVideo/stages/BoardStage.jsx+++ b/client/src/components/musicVideo/stages/BoardStage.jsx@@ -1,6 +1,6 @@-import { useEffect } from 'react';+import { useEffect, useLayoutEffect, useRef } from 'react';import { useSearchParams } from 'react-router';-import { Plus } from 'lucide-react';+import { Plus, Image as ImageIcon } from 'lucide-react';import BeatTimeline from '../BeatTimeline.jsx';import ContactSheetButton from '../ContactSheetButton.jsx';import SceneCard from '../SceneCard.jsx';@@ -10,7 +10,9 @@ import { PlanActions } from '../ProjectActionGroups.jsx';import ShotPacingFields from '../ShotPacingFields.jsx';import { isLayeredComposition } from '../../../lib/musicVideoLayers.js';import { FOOTAGE_OPTIONAL_MODES } from '../../../lib/musicVideoStages.js';-import { parseSceneFilter, sceneAttention, sceneMatchesFilter } from '../../../lib/musicVideoSceneAttention.js';+import { parseSceneFilter, sceneAttention, sceneMatchesFilter, SCENE_ATTENTION_LABELS } from '../../../lib/musicVideoSceneAttention.js';+import { musicVideoImageSrc } from '../../../lib/musicVideoPreview.js';+import { formatTimecode } from '../../../utils/formatters.js';const FILTER_LABELS = [['all', 'All'], ['attention', 'Needs attention'], ['missing', 'Missing footage']];const isTypingTarget = (el) => !!el && (el.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName));@@ -47,6 +49,20 @@ export default function BoardStage({ board }) {// The open scene stays listed while it is edited, even once fixing it drops it from the filter.const visible = scenes.filter((scene) => scene.sceneId === activeSceneId || sceneMatchesFilter(codesById.get(scene.sceneId), filter));const visibleIds = visible.map((scene) => scene.sceneId).join('\n');+ const thumbnailsRef = useRef(new Map());+ const inspectorRef = useRef(null);+ const focusAfterNavigation = useRef(null);+ const toggleInspector = (sceneId, open) => {+ if (!open) focusAfterNavigation.current = { target: 'thumbnail', sceneId };+ onToggleSceneExpand?.(sceneId, open);+ };+ useLayoutEffect(() => {+ const pending = focusAfterNavigation.current;+ if (!pending) return;+ const target = pending.target === 'thumbnail' ? thumbnailsRef.current.get(pending.sceneId) || thumbnailsRef.current.values().next().value+ : inspectorRef.current?.querySelector('summary');+ if (target) { target.focus({ preventScroll: true }); focusAfterNavigation.current = null; }+ }, [activeSceneId]);// j / k step through the listed scenes (opening one, which also routes to it).useEffect(() => {const ids = visibleIds ? visibleIds.split('\n') : [];@@ -54,7 +70,11 @@ export default function BoardStage({ board }) {if ((e.key !== 'j' && e.key !== 'k') || e.metaKey || e.ctrlKey || e.altKey || isTypingTarget(e.target) || !ids.length) return;const at = ids.indexOf(activeSceneId);const next = e.key === 'j' ? Math.min(at + 1, ids.length - 1) : Math.max(at === -1 ? 0 : at - 1, 0);- if (ids[next] !== activeSceneId) { e.preventDefault(); onToggleSceneExpand?.(ids[next], true); }+ if (ids[next] !== activeSceneId) {+ e.preventDefault();+ if (inspectorRef.current?.contains(document.activeElement)) focusAfterNavigation.current = { target: 'inspector' };+ onToggleSceneExpand?.(ids[next], true);+ }};window.addEventListener('keydown', onKey);return () => window.removeEventListener('keydown', onKey);@@ -74,10 +94,10 @@ export default function BoardStage({ board }) {}return (<fieldset disabled={locked} className="min-w-0 space-y-3">- <div className="rounded-lg border border-port-border bg-port-card p-3">+ <StageSection title="Planning tools"><PlanActions project={project} busy={busy} onPlan={board.onPlan} onAutoArrange={board.onAutoArrange} /><ShotPacingFields project={project} onEditLocal={board.editProjectLocal} onSave={board.saveProjectFields} />- </div>+ </StageSection><StageSection id="mv-board-treatment" title="Treatment" summary={scenes.length ? treatmentSummary(project) : 'Plan shots to direct them'}><TreatmentPanel key={`treatment-${project.id}`} project={project} treatment={treatment} part="direction"@@ -85,8 +105,10 @@ export default function BoardStage({ board }) {</StageSection>{project.audioAnalysis && scenes.length > 0 && (+ <StageSection title="Beat timeline"><BeatTimeline audioAnalysis={project.audioAnalysis} scenes={scenes} lyricCues={project.lyricCues} narrativeEvents={project.composition?.narrativeEvents}onSeek={(startSec) => board.seekToScene({ startSec })} onCommit={board.commitSceneTiming} />+ </StageSection>)}<div id="mv-scene-board" className="flex items-center justify-between">@@ -115,13 +137,26 @@ export default function BoardStage({ board }) {<p className="text-sm text-port-text-muted">No scenes match this filter.</p>)}<div className="@container">- <div className="grid grid-cols-1 items-start gap-3 @2xl:grid-cols-2 @5xl:grid-cols-3">- {scenes.map((scene, idx) => !visible.includes(scene) ? null : (+ <div className="grid grid-cols-2 items-start gap-2 @2xl:grid-cols-3 @5xl:grid-cols-4" aria-label="Storyboard thumbnails">+ {visible.map(scene => <button key={scene.sceneId} type="button" aria-pressed={activeSceneId === scene.sceneId}+ ref={element => { if (element) thumbnailsRef.current.set(scene.sceneId, element); else thumbnailsRef.current.delete(scene.sceneId); }}+ onClick={() => { board.seekToScene?.(scene); onToggleSceneExpand?.(scene.sceneId, true); }}+ aria-label={`Open ${scene.sectionLabel || scene.label || `Scene ${scene.order + 1}`}`}+ 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'}`}>+ {scene.referenceImageId ? <img src={musicVideoImageSrc(scene.referenceImageId)} alt="" loading="lazy" className="aspect-video w-full rounded object-cover" />+ : <span className="flex aspect-video items-center justify-center rounded bg-port-bg text-port-text-muted"><ImageIcon size={22} aria-hidden="true" /></span>}+ <span className="mt-1 block truncate text-sm">{scene.sectionLabel || scene.label || `Scene ${scene.order + 1}`}</span>+ <span className="block text-xs text-port-text-muted">{formatTimecode(scene.startSec)}–{formatTimecode(scene.endSec)}</span>+ {codesById.get(scene.sceneId).length > 0 && <span className="block text-xs text-port-warning">{SCENE_ATTENTION_LABELS[codesById.get(scene.sceneId)[0]]}</span>}+ </button>)}+ </div>+ <div ref={inspectorRef} className="mt-3">+ {scenes.map((scene, idx) => scene.sceneId !== activeSceneId ? null : (<SceneCardkey={scene.sceneId}scene={scene}expanded={activeSceneId === scene.sceneId}- onToggleExpand={onToggleSceneExpand}+ onToggleExpand={toggleInspector}performanceReview={performanceReviews.get(`${scene.sceneId}:${scene.videoHistoryId}`)}index={idx}isLast={idx === scenes.length - 1}diff --git a/client/src/components/musicVideo/stages/ReviewStage.jsx b/client/src/components/musicVideo/stages/ReviewStage.jsxindex 589363c24d..895f6161da 100644--- a/client/src/components/musicVideo/stages/ReviewStage.jsx+++ b/client/src/components/musicVideo/stages/ReviewStage.jsx@@ -6,6 +6,8 @@ import MakingOfExportPanel from '../MakingOfExportPanel.jsx';import StageSection from '../StageSection.jsx';import { isFinalRenderStale } from '../../../lib/musicVideoStages.js';import { RenderFinalButton } from '../ProjectActionGroups.jsx';+import ReviewDraftPanel from '../ReviewDraftPanel.jsx';+import { latestMusicVideoReviewDraft } from '../../../../../server/lib/musicVideoReviewDraft.js';/*** Review & Export: the final render and its player, draft excerpts with review@@ -16,11 +18,13 @@ export default function ReviewStage({ board }) {const {project, locked, renderJob, renderBound, finalVideo, excerpts, revisions, autoReview, sceneMedia, devArtifacts,} = board;+ const hasDraft = !!latestMusicVideoReviewDraft(project);return (<fieldset disabled={locked} className="min-w-0 space-y-3">+ {!project.renderHistoryId && <ReviewDraftPanel project={project} onOpen={board.openArtifact} draftState={board.reviewDraftState} />}<RenderFailure project={project} renderJob={renderJob} /><StageSection title="Dependency changes and repair"><DependencyImpactPanel project={project} busy={revisions.busy} onRepair={revisions.repair} /></StageSection>- <section id="mv-final-video" aria-label="Final render" className="rounded-lg border border-port-border bg-port-card p-3">+ <StageSection id="mv-final-video" title="Native final render" defaultOpen={!hasDraft || !!project.renderHistoryId || renderBound}><div className="flex flex-wrap items-center justify-between gap-2"><h3 className="text-sm font-medium">Final render</h3><RenderFinalButton project={project} renderJob={renderJob} readiness={board.productionReadiness} />@@ -33,9 +37,9 @@ export default function ReviewStage({ board }) {finalVideo={finalVideo}onOpenPreview={board.openPreview}/>- </section>+ </StageSection>- <div className="rounded-lg border border-port-border bg-port-card p-3">+ <StageSection title="Excerpt and revision tools" defaultOpen={!hasDraft || excerpts.rendering}><ExcerptPanelproject={project}rendering={excerpts.rendering}@@ -55,18 +59,18 @@ export default function ReviewStage({ board }) {revision={{ ...revisions, genScenes: sceneMedia.genScenes, genVideoScenes: sceneMedia.genVideoScenes }}autoReview={autoReview}/>- </div>+ </StageSection>- <StageSection title="Development files" summary="Guides, storyboards and contact sheets">- <DevArtifactsPanel+ <div id="mv-review-development"><DevArtifactsPanelproject={project}busy={devArtifacts.busy}onOpen={board.openArtifact}onUpload={board.onUploadArtifact}- />- </StageSection>+ /></div>+ <StageSection title="Making-of export"><MakingOfExportPanel project={project} />+ </StageSection></fieldset>);diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex b1286480d9..f681dfb117 100644--- a/client/src/hooks/README.md+++ b/client/src/hooks/README.md@@ -297,3 +297,5 @@ grep -i "what you want to do" client/src/hooks/README.md| `useMusicVideoProductionReview` | Server-authoritative art/storyboard/proof approvals and SSE proof rendering, with stale-readiness suppression. | Music Video production review. || `useCalendarWindowEvents` | `useCalendarWindowEvents(startDate, endDate)` — sequential 200-event offset pages for a complete calendar window, account/event deduplication, retry and date/sync supersession. | Day/Week/Month grids; pair with CalendarWindowStatus to disclose incomplete availability. |++| `useMusicVideoReviewDraft.js` | Sequential exact-version availability checks for implicit imported draft selection; stale requests abort, unavailable newer drafts are disclosed, explicit review versions remain pinned. |diff --git a/client/src/hooks/index.js b/client/src/hooks/index.jsindex 6f0f9bddc4..5ebfb210a5 100644--- a/client/src/hooks/index.js+++ b/client/src/hooks/index.js@@ -278,3 +278,5 @@ export * from './useModelLifecycle.js';export { default as useMusicVideoProductionReview } from './useMusicVideoProductionReview.js';export * from './useCalendarWindowEvents.js';++export * from './useMusicVideoReviewDraft.js';diff --git a/client/src/hooks/useMusicVideoReviewDraft.js b/client/src/hooks/useMusicVideoReviewDraft.jsnew file mode 100644index 0000000000..75fe528547--- /dev/null+++ b/client/src/hooks/useMusicVideoReviewDraft.js@@ -0,0 +1,35 @@+import { useEffect, useState } from 'react';+import { musicVideoReviewDrafts } from '../../../server/lib/musicVideoReviewDraft.js';++/** Resolve only the implicit review choice. Explicit drawer versions never fall back. */+export function useMusicVideoReviewDraft(project, { enabled = true } = {}) {+ const candidatesKey = JSON.stringify(enabled ? musicVideoReviewDrafts(project) : []);+ const [result, setResult] = useState(null);+ useEffect(() => {+ let active = true;+ const controller = new AbortController();+ const candidates = JSON.parse(candidatesKey);+ const resolve = async () => {+ let unavailableCount = 0;+ for (const draft of candidates) {+ try {+ const response = await fetch(draft.src, { method: 'HEAD', signal: controller.signal });+ if (!active) return;+ if (response.ok) {+ setResult({ key: candidatesKey, draft, unavailableCount });+ return;+ }+ } catch {+ if (!active) return;+ }+ unavailableCount += 1;+ }+ if (active) setResult({ key: candidatesKey, draft: null, unavailableCount });+ };+ resolve();+ return () => { active = false; controller.abort(); };+ }, [candidatesKey]);+ const checking = result?.key !== candidatesKey && candidatesKey !== '[]';+ return { draft: result?.key === candidatesKey ? result.draft : null,+ checking, unavailableCount: result?.key === candidatesKey ? result.unavailableCount : 0 };+}diff --git a/client/src/lib/musicVideoPreview.js b/client/src/lib/musicVideoPreview.jsindex ce314ef018..c4a2d1732f 100644--- a/client/src/lib/musicVideoPreview.js+++ b/client/src/lib/musicVideoPreview.js@@ -1,4 +1,5 @@import { videoSrcForJob, videoPosterForJob } from './creativeDirectorPreview.js';+import { latestMusicVideoReviewDraft } from '../../../server/lib/musicVideoReviewDraft.js';const nonEmptyString = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);@@ -30,13 +31,18 @@ export function selectMusicVideoPreview(project) {if (finalId) {return {kind: 'video',+ source: 'final',jobId: finalId,src: videoSrcForJob(finalId),poster: videoPosterForJob(finalId),- label: 'Final video',+ label: project.renderDependencyState?.status === 'stale' ? 'Previous final' : 'Final video',+ ...(project.renderDependencyState?.status === 'stale' ? { stale: true } : {}),};}+ const draft = latestMusicVideoReviewDraft(project);+ if (draft) return draft;+// 2. Latest completed excerpt renderconst excerpts = Array.isArray(project.excerpts) ? project.excerpts : [];const latestExcerpt = [...excerpts].reverse().find((e) => e.status === 'complete' && (e.filename || e.jobId));diff --git a/client/src/lib/musicVideoPreview.test.js b/client/src/lib/musicVideoPreview.test.jsindex a69260a134..b323574d17 100644--- a/client/src/lib/musicVideoPreview.test.js+++ b/client/src/lib/musicVideoPreview.test.js@@ -1,5 +1,53 @@import { describe, it, expect } from 'vitest';import { selectMusicVideoPreview, musicVideoImageSrc, musicVideoImageFallback } from './musicVideoPreview.js';+import { summarizeMusicVideoProject } from '../../../server/lib/musicVideoSummary.js';+import { deriveStages, describeProjectStatus } from './musicVideoStages.js';++const animatic = (id, version = 1, over = {}) => ({ id, kind: 'animatic', status: 'pending', version,+ file: `music-video/source-project/dev/${id}/v${version}.mp4`, mimeType: 'video/mp4', bytes: 200,+ versions: [{ version, file: `music-video/source-project/dev/${id}/v${version}.mp4`, mimeType: 'video/mp4', bytes: 200, createdAt: '2026-01-02' }], ...over });++it('surfaces a pinned imported animatic in both full and summary cards without completing production', () => {+ const project = { id: 'review-project', devArtifacts: [animatic('draft-film', 2)], scenes: [], composition: { mode: 'composed' } };+ const preview = selectMusicVideoPreview(project);+ expect(preview).toMatchObject({ source: 'animatic', version: 2, ownerProjectId: 'source-project', reviewStatus: 'pending',+ src: '/api/music-video/review-project/dev-artifacts/draft-film/file?version=2' });+ expect(summarizeMusicVideoProject(project, {}).preview).toEqual(preview);+ const progress = deriveStages(project, null);+ expect(progress.stages.find(stage => stage.id === 'review').state).not.toBe('done');+ const status = describeProjectStatus(project, { progress, reviewingDraft: true });+ expect(status.headline).toBe('Imported draft for review');+ expect(status.facts.find(fact => fact.id === 'render').label).toContain('pending review');+ expect(project.renderHistoryId).toBeUndefined();+});++it('keeps the native final ahead of drafts and rejects invalid, deleted and stale draft revisions', () => {+ const valid = animatic('good-film');+ const candidates = [animatic('removed', 1, { deleted: true }), animatic('stale', 1, { dependencyState: { status: 'stale' } }),+ animatic('wrong-kind', 1, { kind: 'other' }), animatic('missing-version', 1, { versions: [] }),+ animatic('mismatch', 2, { file: 'music-video/source-project/dev/mismatch/v1.mp4' })];+ const project = { id: 'review-project', devArtifacts: [valid, ...candidates] };+ expect(selectMusicVideoPreview(project).artifactId).toBe(valid.id);+ expect(selectMusicVideoPreview({ ...project, devArtifacts: candidates }).kind).toBe('none');+ expect(selectMusicVideoPreview({ ...project, renderHistoryId: 'native-final' }).label).toBe('Final video');+});++it('uses version creation time rather than later notes to choose the latest imported draft', () => {+ const old = animatic('old-film', 1, { updatedAt: '2026-05-01' });+ const newer = animatic('new-film', 1, { versions: [{ ...old.versions[0], file: 'music-video/source-project/dev/new-film/v1.mp4', createdAt: '2026-02-01' }], status: 'changes-requested' });+ expect(selectMusicVideoPreview({ id: 'review-project', devArtifacts: [newer, old] })).toMatchObject({ artifactId: 'new-film', reviewStatus: 'changes-requested' });+});++it('describes the resolved review snapshot, including missing newer drafts and all-unavailable media', () => {+ const project = { id: 'example', devArtifacts: [animatic('new-film', 3)], scenes: [] };+ const progress = deriveStages(project, null);+ const resolved = { draft: { version: 2, reviewStatus: 'approved' }, unavailableCount: 1, checking: false };+ const status = describeProjectStatus(project, { progress, reviewingDraft: true, reviewDraftState: resolved });+ expect(status.facts.find(fact => fact.id === 'render').label).toBe('Imported animatic v2 · draft reviewed');+ const missing = describeProjectStatus(project, { progress, reviewingDraft: true, reviewDraftState: { ...resolved, draft: null } });+ expect(missing.headline).toBe('Choose an available review file');+ expect(missing.facts.find(fact => fact.id === 'render').label).toBe('Imported drafts unavailable');+});describe('selectMusicVideoPreview', () => {it('returns none for null or empty project', () => {@@ -16,6 +64,7 @@ describe('selectMusicVideoPreview', () => {const preview = selectMusicVideoPreview(project);expect(preview).toEqual({kind: 'video',+ source: 'final',jobId: 'final-job-123',src: '/data/videos/final-job-123.mp4',poster: '/data/video-thumbnails/final-job-123.jpg',diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.jsindex 22b384313b..6759db0e99 100644--- a/client/src/lib/musicVideoStages.js+++ b/client/src/lib/musicVideoStages.js@@ -12,6 +12,7 @@ import { formatCount, formatTimecode } from '../utils/formatters.js';import { isNonBlankStr } from './textUtils';import { modeLabel } from './imageGenModes.js';import { falSceneTake } from './musicVideoShotTiming.js';+import { latestMusicVideoReviewDraft } from '../../../server/lib/musicVideoReviewDraft.js';export const MUSIC_VIDEO_STAGES = [{ id: 'setup', label: 'Setup', title: 'Setup' },@@ -171,7 +172,7 @@ export function approvalSummary(readiness) {* watch. `progress` is `deriveStages(…)`; `nextAction` is `deriveNextAction(…)`.* Fact tones are `ok`, `warn` or `muted`.*/-export function describeProjectStatus(project, { progress, nextAction = null, readiness = project?.productionReadiness } = {}) {+export function describeProjectStatus(project, { progress, nextAction = null, readiness = project?.productionReadiness, reviewingDraft = false, reviewDraftState } = {}) {if (!project || !progress) return null;const index = MUSIC_VIDEO_STAGES.findIndex((stage) => stage.id === progress.current);const entry = progress.stages.find((stage) => stage.id === progress.current);@@ -179,7 +180,8 @@ export function describeProjectStatus(project, { progress, nextAction = null, re// A goto into Production review is a human approval, not something the app does by itself.const needsYou = entry?.state === 'blocked' || nextAction?.id === 'review-production' || nextAction?.id === 'approve-cast-sets';const activeEvidence = ['draft-progress', 'proof-progress'].includes(nextAction?.id);- const headline = activeEvidence ? 'Review render in progress' : allDone+ const reviewDraft = reviewingDraft && reviewDraftState ? reviewDraftState.draft : latestMusicVideoReviewDraft(project);+ const headline = reviewingDraft ? reviewDraftState?.checking ? 'Checking review draft' : reviewDraft ? 'Imported draft for review' : 'Choose an available review file' : activeEvidence ? 'Review render in progress' : allDone? 'Published': `Stage ${index + 1} of ${MUSIC_VIDEO_STAGES.length}: ${entry?.label || ''}${needsYou ? ' · needs you' : ''}`;const facts = [];@@ -209,9 +211,12 @@ export function describeProjectStatus(project, { progress, nextAction = null, reconst drafts = (project.excerpts || []).filter((e) => e.status === 'complete' && e.filename).length;if (isFinalRenderStale(project)) facts.push({ id: 'render', label: STALE_RENDER_MESSAGE, tone: 'warn' });else if (project.renderHistoryId) facts.push({ id: 'render', label: 'Final render ready', tone: 'ok' });+ else if (reviewingDraft && reviewDraftState?.checking) facts.push({ id: 'render', label: 'Checking imported media availability', tone: 'muted' });+ else if (reviewingDraft && reviewDraftState?.unavailableCount && !reviewDraft) facts.push({ id: 'render', label: 'Imported drafts unavailable', tone: 'warn' });+ else if (reviewDraft) facts.push({ id: 'render', label: `Imported animatic v${reviewDraft.version} · ${reviewDraft.reviewStatus === 'pending' ? 'pending review' : reviewDraft.reviewStatus === 'approved' ? 'draft reviewed' : 'changes requested'}`, tone: 'muted' });else if (drafts) facts.push({ id: 'render', label: `${drafts} draft ${drafts === 1 ? 'excerpt' : 'excerpts'}, no final render`, tone: 'muted' });else facts.push({ id: 'render', label: 'Nothing rendered yet', tone: 'muted' });- return { headline, tone: activeEvidence ? 'muted' : allDone ? 'ok' : needsYou ? 'warn' : 'muted', facts };+ return { headline, tone: reviewingDraft ? 'muted' : activeEvidence ? 'muted' : allDone ? 'ok' : needsYou ? 'warn' : 'muted', facts };}export const STALE_RENDER_MESSAGE = 'Final render is out of date — re-render';@@ -370,7 +375,7 @@ export function deriveNextAction(project, {return { id: 'review-production', kind: 'goto', stage: art ? 'cast-sets' : board ? 'board' : 'compose',anchor: art ? 'mv-review-art' : board ? 'mv-review-storyboard' : 'mv-review-proof',label: art ? 'Review art direction' : board ? 'Review timed storyboard' : 'Review animated proof',- shortLabel: art ? 'Art' : board ? 'Board' : 'Proof' };+ shortLabel: art ? 'Review art' : board ? 'Review storyboard' : 'Review proof' };}if (run && RESUMABLE_RUN_STATUSES.has(run.status)) {if (run.status === 'running' && !run.interrupted) return { id: 'stop-production', kind: 'run', label: 'Stop production', shortLabel: 'Stop', runId: run.id };diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 4347a7b0fd..3455183543 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -87,6 +87,8 @@ import { isLtx2FamilyRuntime } from '../lib/runnerFamilies';import { videoPosterForJob } from '../lib/creativeDirectorPreview.js';import { sceneTakeList } from '../lib/musicVideoTakes.js';import { deriveAttentionItems } from '../lib/musicVideoAttention.js';+import { latestMusicVideoReviewDraft } from '../../../server/lib/musicVideoReviewDraft.js';+import { useMusicVideoReviewDraft } from '../hooks/useMusicVideoReviewDraft.js';import {productionReviewStopGuidance, deriveNextAction, deriveStages, projectShotSummary, describeProjectStatus, listPreviewSources, projectSpend, resolveStageParam, stageChecklist, compareMusicVideoProjectsNewestFirst,} from '../lib/musicVideoStages.js';@@ -269,7 +271,7 @@ export default function MusicVideo() {const [openedStage, setOpenedStage] = useState({ id: null, stage: null });// The opened stage waits for readiness (or its failure) so a done project never pins to Cast & Sets.const statusKnown = !!productionReview.readiness || !!productionReview.readinessError;- if (selected && statusKnown && openedStage.id !== selected.id) setOpenedStage({ id: selected.id, stage: progress.current });+ if (selected && statusKnown && openedStage.id !== selected.id) setOpenedStage({ id: selected.id, stage: latestMusicVideoReviewDraft(selected) && !selected.renderHistoryId ? 'review' : progress.current });const pinnedStage = openedStage.id === selected?.id ? openedStage.stage : null;const activeStage = resolveStageParam(routeStage) || (routeSceneId ? 'board' : (pinnedStage || progress.current));@@ -427,13 +429,13 @@ export default function MusicVideo() {// listening for anymore) and misattribute its progress UI to whichever// project is now selected. Block switching until that import settles. (The// hook re-asserts the same invariant against URL-driven navigation.)- const selectProject = (id) => {+ const selectProject = (id, stage = null) => {if (youtube.editJob.active && id !== selectedId) {toast.error(youtube.switchBlockedMessage);return;}const search = searchParams.toString();- navigate(id ? `/music-video/${id}${search ? `?${search}` : ''}` : `/music-video${search ? `?${search}` : ''}`);+ navigate(id ? `/music-video/${id}${stage ? `/${stage}` : ''}${search ? `?${search}` : ''}` : `/music-video${search ? `?${search}` : ''}`);};useEffect(() => {@@ -970,7 +972,7 @@ export default function MusicVideo() {const audioFilename = projectAudioFilename(selected);const audioUrl = audioFilename ? trackAudioUrl(audioFilename) : null;const autopilotRun = selected?.autonomousRun || null;- const nextAction = selected ? deriveNextAction(selected, {+ const productionNextAction = selected ? deriveNextAction(selected, {readiness: productionReview.readiness,publish,renderActive: renderTargetsSelected,@@ -985,6 +987,15 @@ export default function MusicVideo() {planning,analyzing,}) : null;+ const reviewingDraft = activeStage === 'review' && !!latestMusicVideoReviewDraft(selected) && !selected?.renderHistoryId;+ const reviewDraftState = useMusicVideoReviewDraft(selected, { enabled: reviewingDraft });+ const reviewDraft = reviewDraftState.draft;+ const nextAction = reviewingDraft ? reviewDraftState.checking+ ? { id: 'review-imported', kind: 'goto', stage: 'review', label: 'Checking review draft', disabled: true, reason: 'Checking exact-version media availability' }+ : reviewDraft+ ? { id: 'review-imported', kind: 'goto', stage: 'review', label: 'Review imported draft', shortLabel: 'Review draft' }+ : { id: 'review-files', kind: 'goto', stage: 'review', anchor: 'mv-review-development', label: 'Choose review file', shortLabel: 'Choose file' }+ : productionNextAction;// What the server holds that this tab might not be showing (#9940): derived// from the saved record, so it survives a reload. Work this tab can see// progressing (spinning sections, an attached render) is not flagged.@@ -997,6 +1008,7 @@ export default function MusicVideo() {}) : [];const runNextAction = () => {if (!selected || !nextAction || nextAction.disabled || compositionSavePending > 0) return;+ if (nextAction.id === 'review-imported') { openArtifact(reviewDraft.artifactId); return; }if (nextAction.kind === 'goto') { goToStage(nextAction.stage, nextAction.anchor); return; }switch (nextAction.id) {case 'kickoff': handleKickoff(); break;@@ -1020,6 +1032,7 @@ export default function MusicVideo() {// use, so a panel moving between tabs never changes a signature here.const board = selected ? {project: selected,+ reviewDraftState,activeSceneId: routeSceneId || null,onToggleSceneExpand: handleToggleSceneExpand,autopilotRun,@@ -1193,12 +1206,9 @@ export default function MusicVideo() {))}</select>{selected && (- <span className="flex items-center gap-1">- <span className="text-[10px] px-1.5 py-0.5 rounded bg-port-border">v{selected.version || 1}</span>- </span>- )}- {selected && (- <span className="flex flex-wrap items-center gap-1">+ <details className="min-w-0">+ <summary className="min-h-[44px] cursor-pointer rounded border border-port-border px-2 py-1.5 text-sm">Project actions · v{selected.version || 1}</summary>+ <div className="flex flex-wrap items-center gap-1 py-2"><buttontype="button"onClick={handleRename}@@ -1246,7 +1256,8 @@ export default function MusicVideo() {<Trash2 size={15} /></button>)}- </span>+ </div>+ </details>)}{!selected && (<>@@ -1377,6 +1388,8 @@ export default function MusicVideo() {project={project}trackLabel={trackName(project.trackId)}onSelect={() => selectProject(project.id)}+ onReview={project.preview?.source === 'final' || project.preview?.source === 'animatic' || project.renderHistoryId || latestMusicVideoReviewDraft(project)+ ? () => selectProject(project.id, 'review') : null}onClone={(options) => handleClone(project, options)}isConfirmingDelete={isConfirmingDelete(project.id)}onRequestDelete={() => handleDeleteRequest(project.id)}@@ -1415,7 +1428,7 @@ export default function MusicVideo() {onNextAction={runNextAction}spend={projectSpend(selected)}status={statusKnown && productionReview.readiness- ? describeProjectStatus(selected, { progress, nextAction, readiness: productionReview.readiness })+ ? describeProjectStatus(selected, { progress, nextAction: productionNextAction, readiness: productionReview.readiness, reviewingDraft, reviewDraftState }): statusKnown? { headline: `Status unavailable: ${productionReview.readinessError}`, tone: 'warn', facts: [] }: { headline: 'Loading status…', tone: 'muted', facts: [] }}@@ -1459,12 +1472,14 @@ export default function MusicVideo() {)}</div>}>+ <StageSection title="Native production prerequisites"><StageChecklistitems={stageChecklist(activeStage, selected, productionReview.readiness, publish)}onAction={(action) => goToStage(action.stage || activeStage, action.anchor, action.params)}onRevert={productionReview.revert}headerAnchor={nextAction?.kind === 'goto' ? nextAction.anchor : null}/>+ </StageSection>{APPROVAL_STAGE_BY_TAB[activeStage] && (<ProductionReviewPanelkey={`${selected.id}-${activeStage}`}diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsxindex 6564467ded..08f4d4ba27 100644--- a/client/src/pages/MusicVideo.test.jsx+++ b/client/src/pages/MusicVideo.test.jsx@@ -337,10 +337,17 @@ const selectProject = async (projectId) => {const STAGE_TABS = {setup: /^Setup/, 'cast-sets': /^Cast & Sets/, board: /^Board/, produce: /^Produce/, compose: /^Compose/, review: /^Review/,};-const openStage = async (stage) => {+const openStage = async (stage, selectFirstScene = true) => {const tab = await screen.findByRole('tab', { name: STAGE_TABS[stage] });fireEvent.click(tab);await waitFor(() => expect(screen.getByRole('tab', { name: STAGE_TABS[stage] })).toHaveAttribute('aria-selected', 'true'));+ // Scene controls now belong to one URL-selected inspector. The existing+ // generation/edit tests enter it through the visible thumbnail first.+ if (stage === 'board' && selectFirstScene) {+ const thumbnails = screen.getByLabelText('Storyboard thumbnails');+ const first = within(thumbnails).queryAllByRole('button')[0];+ if (first) await act(async () => { fireEvent.click(first); });+ }};const openProject = async (project, stage = null) => {@@ -1294,7 +1301,7 @@ describe('MusicVideo project versions', () => {await waitFor(() => expect(cloneMusicVideoProject).toHaveBeenCalledWith('mv-1', {}, { silent: true }));await screen.findByRole('heading', { level: 2, name: 'Neon Run v2' });- expect(screen.getByText('v2')).toBeTruthy();+ expect(screen.getByText('Project actions · v2')).toBeTruthy();});});@@ -1529,7 +1536,7 @@ describe('MusicVideo lyrics and shot coverage (#8964)', () => {expect(screen.getAllByText(/first line/).length).toBeGreaterThan(0);const players = document.body.querySelectorAll('video[src^="/data/videos/h"]');- expect(players).toHaveLength(2);+ expect(players).toHaveLength(1); // only the selected shot owns a playerfor (const player of players) {Object.defineProperty(player, 'duration', { configurable: true, value: 5 });fireEvent.loadedMetadata(player);@@ -1541,6 +1548,14 @@ describe('MusicVideo lyrics and shot coverage (#8964)', () => {fireEvent.click(within(alerts[0]).getByRole('button', { name: 'Trim to clip' }));await waitFor(() => expect(updateMusicVideoScene).toHaveBeenCalledWith('mv-1', 's1', { endSec: 7 }, { silent: true }));await waitFor(() => expect(screen.queryByRole('alert')).toBeNull());++ await act(async () => fireEvent.click(screen.getByRole('button', { name: 'Open Scene 2' })));+ const legacyPlayers = document.body.querySelectorAll('video[src^="/data/videos/h"]');+ expect(legacyPlayers).toHaveLength(1);+ expect(legacyPlayers[0]).toHaveAttribute('src', '/data/videos/h2.mp4');+ Object.defineProperty(legacyPlayers[0], 'duration', { configurable: true, value: 5 });+ fireEvent.loadedMetadata(legacyPlayers[0]);+ expect(screen.queryByRole('alert')).toBeNull(); // legacy shots still loop to fill their span});});@@ -1588,6 +1603,7 @@ describe('MusicVideo section layers (#8985)', () => {expect(renderBtn).toBeDisabled();await openStage('board');+ await act(async () => fireEvent.click(screen.getByRole('button', { name: 'Open Scene 2' })));const layer = document.getElementById('mv-scene-s2-layer');fireEvent.change(layer, { target: { value: 'card' } });await waitFor(() => expect(updateMusicVideoScene).toHaveBeenCalledWith('mv-1', 's2', { visualLayer: 'card' }, { silent: true }));@@ -1604,6 +1620,7 @@ describe('MusicVideo section layers (#8985)', () => {it('keeps a plain render on footage and says the layer only applies to composed renders', async () => {await openProject({ ...PROJECT_WITH_CLIP, scenes: [scenes[0], { ...scenes[1], visualLayer: 'card' }], composition: composition('concat') }, 'board');+ await act(async () => fireEvent.click(screen.getByRole('button', { name: 'Open Scene 2' })));expect(await screen.findByText(/Title card sections render in composed or document mode/)).toBeTruthy();await openStage('review');expect(screen.getByRole('button', { name: /^Render final$/ })).toBeDisabled();@@ -2604,9 +2621,9 @@ describe('MusicVideo stage tabs (#9243)', () => {await openStage('board');expect(screen.getByTitle('Composition document preview')).toBeTruthy();await waitFor(() => expect(screen.getByText('0.00s / 60.0s')).toBeTruthy());- fireEvent.click(screen.getByText('Scene 2'));+ fireEvent.click(screen.getByRole('button', { name: 'Open Scene 2' }));await waitFor(() => expect(screen.getByText('4.00s / 60.0s')).toBeTruthy());- fireEvent.click(screen.getByText('Scene 1'));+ fireEvent.click(screen.getByRole('button', { name: 'Open Scene 1' }));await waitFor(() => expect(screen.getByText('0.00s / 60.0s')).toBeTruthy());});@@ -2638,7 +2655,7 @@ describe('MusicVideo stage tabs (#9243)', () => {expect(final.getAttribute('src')).toBe('/data/videos/final.mp4');fireEvent.change(screen.getByLabelText('Preview source'), { target: { value: 'excerpt:mve-1' } });await waitFor(() => expect(screen.getByLabelText('Draft excerpt preview').getAttribute('src')).toBe('/data/videos/excerpt-old.mp4'));- await openStage('board');+ await openStage('board', false);expect(screen.getByLabelText('Draft excerpt preview').getAttribute('src')).toBe('/data/videos/excerpt-old.mp4');expect(screen.queryByLabelText('Final render preview')).toBeNull();});@@ -2735,6 +2752,16 @@ describe('MusicVideo main page project cards', () => {expect(await screen.findByRole('heading', { level: 2, name: PROJECT_WITH_CLIP.name })).toBeInTheDocument();});+ it('opens an existing final directly in Review from the project card', async () => {+ const project = { ...PROJECT_WITH_CLIP, renderHistoryId: 'example-final' };+ listMusicVideoProjects.mockResolvedValue([project]);+ render(<MemoryRouter initialEntries={['/music-video']}><LocationProbe />{MV_ROUTES}</MemoryRouter>);+ const card = await screen.findByTestId(`mv-project-card-${project.id}`);+ await act(async () => fireEvent.click(within(card).getByRole('button', { name: 'Review video' })));+ expect(screen.getByTestId('loc')).toHaveTextContent(`/music-video/${project.id}/review`);+ expect(screen.getByRole('tab', { name: /^Review/ })).toHaveAttribute('aria-selected', 'true');+ });+it('handles forking a project directly from its card', async () => {cloneMusicVideoProject.mockResolvedValueOnce({...PROJECT_WITH_CLIP,@@ -2926,22 +2953,41 @@ describe('MusicVideo deep-linking and drawer URL routing (#10168)', () => {await screen.findByRole('heading', { level: 2, name: PROJECT_WITH_CLIP.name });expect(screen.getByTestId('loc')).toHaveTextContent(`/music-video/${PROJECT_WITH_CLIP.id}/board`);+ expect(document.getElementById('scene-s1')).toBeNull();+ const thumbnail = screen.getByRole('button', { name: 'Open Scene 1' });+ await act(async () => fireEvent.click(thumbnail));const details = document.getElementById('scene-s1');expect(details).toBeInTheDocument();- await act(async () => {- details.open = true;- fireEvent(details, new Event('toggle'));- });expect(screen.getByTestId('loc')).toHaveTextContent(`/music-video/${PROJECT_WITH_CLIP.id}/board/scene/s1`);+ details.querySelector('summary').focus();await act(async () => {details.open = false;fireEvent(details, new Event('toggle'));});expect(screen.getByTestId('loc')).toHaveTextContent(`/music-video/${PROJECT_WITH_CLIP.id}/board`);+ expect(document.getElementById('scene-s1')).toBeNull();+ expect(thumbnail).toHaveFocus();await settle();});+ it('keeps scene routing and focus together when j/k switches the inspector', async () => {+ const first = { ...PROJECT_WITH_CLIP.scenes[0], sceneId: 's1', order: 0 };+ listMusicVideoProjects.mockResolvedValue([{ ...PROJECT_WITH_CLIP, scenes: [first, { ...first, sceneId: 's2', order: 1 }] }]);+ render(<MemoryRouter initialEntries={[`/music-video/${PROJECT_WITH_CLIP.id}/board/scene/s1`]}><LocationProbe />{MV_ROUTES}</MemoryRouter>);+ await screen.findByRole('heading', { level: 2, name: PROJECT_WITH_CLIP.name });+ document.querySelector('#scene-s1 summary').focus();+ await act(async () => fireEvent.keyDown(document.activeElement, { key: 'j' }));+ expect(screen.getByTestId('loc')).toHaveTextContent(`/music-video/${PROJECT_WITH_CLIP.id}/board/scene/s2`);+ expect(document.querySelector('#scene-s1')).toBeNull();+ expect(document.querySelector('#scene-s2 summary')).toHaveFocus();+ expect(document.querySelectorAll('video[src^="/data/videos/"]')).toHaveLength(1);+ await act(async () => fireEvent.keyDown(document.activeElement, { key: 'k' }));+ expect(screen.getByTestId('loc')).toHaveTextContent(`/music-video/${PROJECT_WITH_CLIP.id}/board/scene/s1`);+ expect(document.querySelector('#scene-s2')).toBeNull();+ expect(document.querySelector('#scene-s1 summary')).toHaveFocus();+ });+it('closes open drawer on back navigation', async () => {listMusicVideoProjects.mockResolvedValue([PROJECT_WITH_CLIP]);let routerNavigate;diff --git a/server/lib/README.md b/server/lib/README.mdindex 8ab3a2bf32..5c1ea0fd6d 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -854,3 +854,5 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `forgeMaintenanceTasks.js` | Current forge-maintenance screening version, queue-compatible identity check, task classification, and legacy refusal reason. || `peerAdminValidation.js` | Strict planning-only peer administration schemas, fixed actions and grant scope. |++| `musicVideoReviewDraft.js` | Pure imported Animatic review candidates, newest immutable version first; exact version URLs remain separate from native production approvals. |diff --git a/server/lib/index.js b/server/lib/index.jsindex 3e1aa3b5a3..af9abb6e82 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -836,3 +836,5 @@ export * from './forgeMaintenanceTasks.js';export * from './maintenanceAdmission.js';export * as peerAdminValidation from './peerAdminValidation.js';export * from './speechMatch.js';++export * from './musicVideoReviewDraft.js';diff --git a/server/lib/musicVideoReviewDraft.js b/server/lib/musicVideoReviewDraft.jsnew file mode 100644index 0000000000..b8a96fe9ef--- /dev/null+++ b/server/lib/musicVideoReviewDraft.js@@ -0,0 +1,25 @@+/** An imported animatic is a review snapshot, never a native production approval. */+export function musicVideoReviewDrafts(project) {+ if (!project?.id) return [];+ const artifacts = Array.isArray(project.devArtifacts) ? project.devArtifacts : [];+ const drafts = artifacts.flatMap(artifact => {+ if (artifact?.deleted || artifact?.kind !== 'animatic'+ || !['pending', 'approved', 'changes-requested'].includes(artifact.status)+ || artifact.dependencyState?.status === 'stale') return [];+ const entry = Array.isArray(artifact.versions) ? artifact.versions.find(version => version.version === artifact.version) : null;+ if (!entry || entry.mimeType !== 'video/mp4' || entry.file !== artifact.file+ || entry.mimeType !== artifact.mimeType || !(entry.bytes > 0)) return [];+ const match = /^music-video\/([A-Za-z0-9_-]+)\/dev\/([A-Za-z0-9_-]+)\/v([1-9]\d*)\.mp4$/.exec(entry.file);+ if (!match || match[2] !== artifact.id || Number(match[3]) !== artifact.version) return [];+ const src = `/api/music-video/${encodeURIComponent(project.id)}/dev-artifacts/${encodeURIComponent(artifact.id)}/file?version=${artifact.version}`;+ return [{ kind: 'video', source: 'animatic', artifactId: artifact.id, version: artifact.version,+ ownerProjectId: match[1], src, poster: null, label: `Imported draft · v${artifact.version}`,+ reviewStatus: artifact.status, createdAt: entry.createdAt || artifact.createdAt }];+ });+ // Notes and approvals update updatedAt; they must not promote an older film.+ return drafts.sort((a, b) => (Date.parse(b.createdAt) || 0) - (Date.parse(a.createdAt) || 0));+}++export function latestMusicVideoReviewDraft(project) {+ return musicVideoReviewDrafts(project)[0] || null;+}diff --git a/server/lib/musicVideoSummary.js b/server/lib/musicVideoSummary.jsindex 5326b63632..ddd1c8e9e2 100644--- a/server/lib/musicVideoSummary.js+++ b/server/lib/musicVideoSummary.js@@ -8,6 +8,7 @@* `musicVideoPreview.js`, which still derive them for a full record.*/import { isLayeredComposition, sceneRenderReady } from './musicVideoLayers.js';+import { latestMusicVideoReviewDraft } from './musicVideoReviewDraft.js';const STAGE_IDS = ['setup', 'cast-sets', 'board', 'produce', 'compose', 'review', 'publish'];const RESUMABLE_RUN_STATUSES = new Set(['running', 'stopped', 'limit-reached', 'blocked', 'needs-replan']);@@ -75,7 +76,11 @@ function projectPreview(project) {const video = (jobId, label, src = `/data/videos/${jobId}.mp4`) => ({kind: 'video', jobId, src, poster: jobId ? `/data/video-thumbnails/${jobId}.jpg` : null, label,});- if (finalId) return video(finalId, 'Final video');+ if (finalId) return { ...video(finalId, project.renderDependencyState?.status === 'stale' ? 'Previous final' : 'Final video'), source: 'final',+ ...(project.renderDependencyState?.status === 'stale' ? { stale: true } : {}) };++ const draft = latestMusicVideoReviewDraft(project);+ if (draft) return draft;const excerpts = Array.isArray(project.excerpts) ? project.excerpts : [];const excerpt = [...excerpts].reverse().find((e) => e.status === 'complete' && (e.filename || e.jobId));