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: flag a changed Cast & Sets approval and list stale approvals in Needs attention (#10141)
Adam Eivy39d566ccbba9
diff --git a/client/src/components/musicVideo/CastAndSetsCheckin.jsx b/client/src/components/musicVideo/CastAndSetsCheckin.jsxindex 37ba9ffb07..e9cd50f94e 100644--- a/client/src/components/musicVideo/CastAndSetsCheckin.jsx+++ b/client/src/components/musicVideo/CastAndSetsCheckin.jsx@@ -1,6 +1,7 @@import { CheckCircle2, Eye, Play, RotateCcw, SkipForward, Users } from 'lucide-react';import LlmRouteNote from './LlmRouteNote.jsx';import Pill from '../ui/Pill.jsx';+import { staleApprovalText } from '../../lib/musicVideoStages.js';import CastAndSetsDirectionEditor from './CastAndSetsDirectionEditor.jsx';import CastAndSetsReferenceProgress from './CastAndSetsReferenceProgress.jsx';@@ -32,25 +33,33 @@ function statusLine(stage) {* The Cast & Sets check-in's state on the Autopilot card: progress while the* server works, "Waiting for your check-in" with the sheet one click away,* and the director's actions (Approve & continue, Regenerate,- * Edit direction on a procedural sheet, Resume, Skip).+ * Edit direction on a procedural sheet, Resume, Skip). An approved sheet whose+ * concept, style, subjects or song changed since (`stale`, from the server's+ * readiness) says what changed and offers Keep approved beside Rebuild (#10141).*/-export default function CastAndSetsCheckin({ project, busy, onOpenSheet, onApprove, onRegenerate, onEditDirection, onResume, onRebuild, onSkip }) {+export default function CastAndSetsCheckin({ project, stale = null, busy, onOpenSheet, onApprove, onRegenerate, onEditDirection, onResume, onRebuild, onReconfirm, onSkip }) {const stage = project.castAndSets;if (!stage) return null;const working = WORKING.has(stage.status) && !stage.interrupted;const sheet = stage.artifactId ? (project.devArtifacts || []).find((a) => a.id === stage.artifactId && !a.deleted) : null;const openNotes = (sheet?.notes || []).filter((n) => !n.resolvedAt).length;- const tone = stage.status === 'review' ? 'warning' : stage.status === 'approved' ? 'success' : stage.status === 'failed' ? 'error' : 'muted';+ const staleText = stage.status === 'approved' ? staleApprovalText(stale) : null;+ const tone = stage.status === 'review' || staleText ? 'warning' : stage.status === 'approved' ? 'success' : stage.status === 'failed' ? 'error' : 'muted';return (<div className={`rounded-lg border bg-port-card p-3 space-y-2 ${stage.status === 'review' ? 'border-port-warning/60' : 'border-port-border'}`} aria-label="Cast & Sets check-in"><div className="flex flex-wrap items-center gap-2"><Users size={14} className="text-port-accent shrink-0" aria-hidden="true" /><span className="text-sm font-medium">Cast & Sets check-in</span>- <Pill size="xs" tone={tone}>{stage.interrupted ? 'interrupted' : stage.status}</Pill>+ <Pill size="xs" tone={tone}>{stage.interrupted ? 'interrupted' : staleText ? 'approved · stale' : stage.status}</Pill>{stage.revision > 1 && <span className="text-[11px] text-port-text-muted">revision {stage.revision}</span>}<LlmRouteNote route={project.automation?.routes?.castAndSets} prefix="Direction ran on" /></div><p className={`text-xs ${stage.status === 'review' ? 'text-port-warning' : 'text-port-text-muted'}`} role="status">{statusLine(stage)}</p>+ {staleText && (+ <p className="text-xs text-port-warning">+ {staleText} Keep the sheet approved as it is, or rebuild it from the current inputs.+ </p>+ )}<CastAndSetsReferenceProgress stage={stage} /><div className="flex flex-wrap gap-2">{sheet && (@@ -77,6 +86,12 @@ export default function CastAndSetsCheckin({ project, busy, onOpenSheet, onAppro<Play size={14} aria-hidden="true" /> Resume</button>)}+ {staleText && onReconfirm && (+ <button type="button" disabled={busy} onClick={onReconfirm} title="Keep this sheet approved on the current concept, style, subjects and song"+ className={`${buttonClass} border border-port-border`}>+ <CheckCircle2 size={14} aria-hidden="true" /> Keep approved+ </button>+ )}{onRebuild && ['approved', 'skipped'].includes(stage.status) && (<button type="button" disabled={busy} onClick={onRebuild} title="Build a new sheet; the earlier one stays in the sheet's version history"className={`${buttonClass} border border-port-border`}>diff --git a/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx b/client/src/components/musicVideo/CastAndSetsCheckin.test.jsxindex 2edfe94bc8..9309ac4411 100644--- a/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx+++ b/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx@@ -6,7 +6,7 @@ import useMusicVideoCastAndSets from '../../hooks/useMusicVideoCastAndSets';const { listeners, api, getMediaJob } = vi.hoisted(() => ({listeners: new Map(),- api: { getMusicVideoProject: vi.fn(), startMusicVideoCastAndSets: vi.fn(), regenerateMusicVideoCastAndSets: vi.fn(), editMusicVideoCastAndSetsDirection: vi.fn(), resumeMusicVideoCastAndSets: vi.fn(), approveMusicVideoCastAndSets: vi.fn(), skipMusicVideoCastAndSets: vi.fn() },+ api: { getMusicVideoProject: vi.fn(), startMusicVideoCastAndSets: vi.fn(), regenerateMusicVideoCastAndSets: vi.fn(), editMusicVideoCastAndSetsDirection: vi.fn(), resumeMusicVideoCastAndSets: vi.fn(), approveMusicVideoCastAndSets: vi.fn(), reconfirmMusicVideoCastAndSets: vi.fn(), skipMusicVideoCastAndSets: vi.fn() },getMediaJob: vi.fn(),}));vi.mock('../../services/socket', () => ({ default: {@@ -228,6 +228,22 @@ describe('Cast & Sets tab: undo, regenerate and guide import', () => {expect(screen.queryByRole('button', { name: 'Use A clip as visual guide' })).toBeNull();});+ it('names what changed since an approved sheet and keeps it approved on request (#10141)', async () => {+ const stale = { approvedAt: '2026-01-01T00:00:00.000Z', changedFields: ['concept', 'style'] };+ api.reconfirmMusicVideoCastAndSets.mockResolvedValue({ project: withStatus('approved') });+ open(withStatus('approved'), { productionReadiness: { castAndSets: { approved: true, stale } } });+ expect(screen.getByText('approved · stale')).toBeInTheDocument();+ expect(screen.getByText(/^Approved earlier — changed since: concept, style\./)).toBeInTheDocument();+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Keep approved' })); });+ expect(api.reconfirmMusicVideoCastAndSets).toHaveBeenCalledWith('example-project', { silent: true });+ });++ it('shows no stale note or Keep approved for a current approval', () => {+ open(withStatus('approved'), { productionReadiness: { castAndSets: { approved: true, stale: null } } });+ expect(screen.queryByRole('button', { name: 'Keep approved' })).toBeNull();+ expect(screen.queryByText(/changed since/)).toBeNull();+ });+it('marks the chosen guide instead of offering it again', () => {const value = { ...withStatus('approved'), productionReview: { draft: { guideArtifactId: 'sheet-1' } } };open(value, { useAsGuide: vi.fn() });diff --git a/client/src/components/musicVideo/MusicVideoLayout.jsx b/client/src/components/musicVideo/MusicVideoLayout.jsxindex c46b0dceb3..e1303bda1d 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, Layers, LayoutGrid, Music, Play,+ AlertTriangle, ArrowRight, CheckCircle2, CircleDot, Clapperboard, Film, History, Layers, LayoutGrid, Music, Play,Send, SlidersHorizontal, Users,} from 'lucide-react';import TabPills from '../ui/TabPills.jsx';@@ -21,6 +21,9 @@ const STAGE_TRAILING = {active: <CircleDot size={12} className="shrink-0 text-port-accent max-lg:hidden" aria-label="in progress" />,blocked: <AlertTriangle size={12} className="shrink-0 text-port-warning" aria-label="needs you" />,};+// Approved earlier, changed since (#10141): shown at every width, like "needs you",+// because the stage's checklist names what to re-approve.+const STALE_MARK = <History size={12} className="shrink-0 text-port-warning" aria-label="approved earlier, changed since" />;// The page's scroll body (the route is full-width, so the page owns its// scroll): a new tab scrolls it back to the top.@@ -118,7 +121,7 @@ export default function MusicVideoLayout({id: entry.id,label: entry.label,icon: STAGE_ICONS[entry.id],- trailing: STAGE_TRAILING[entry.state] || null,+ trailing: entry.state !== 'blocked' && entry.stale ? STALE_MARK : STAGE_TRAILING[entry.state] || null,}));const showSpend = spend.spentUsd > 0 || spend.capUsd != null;const stageEntry = progress.stages.find((entry) => entry.id === stage);diff --git a/client/src/components/musicVideo/NeedsAttentionBanner.jsx b/client/src/components/musicVideo/NeedsAttentionBanner.jsxindex 29320f006b..142d7d3cf5 100644--- a/client/src/components/musicVideo/NeedsAttentionBanner.jsx+++ b/client/src/components/musicVideo/NeedsAttentionBanner.jsx@@ -83,6 +83,8 @@ function ItemActions({ item, busy, actions }) {</button></>);+ case 'stale-approvals':+ return <OpenLink item={item} />;default:return null;}diff --git a/client/src/components/musicVideo/TreatmentPanel.jsx b/client/src/components/musicVideo/TreatmentPanel.jsxindex 3cab52cfb0..5f41a9cbaa 100644--- a/client/src/components/musicVideo/TreatmentPanel.jsx+++ b/client/src/components/musicVideo/TreatmentPanel.jsx@@ -69,8 +69,10 @@ export function treatmentSummary(project) {* reads) belongs in Setup, while compile / arc / shot direction / Apply need* scenes and live on the Board. Omit it to render both. The caller supplies* the collapsible section, so there is no fold of its own here.+ * `storyboardApproved` (from the server's readiness) warns that any treatment+ * edit will need the storyboard re-approved (#10141).*/-export default function TreatmentPanel({ project, treatment: api, part = 'all' }) {+export default function TreatmentPanel({ project, treatment: api, part = 'all', storyboardApproved = false }) {const showBrief = part !== 'direction';const showDirection = part !== 'brief';const hasScenes = (project.scenes || []).length > 0;@@ -109,6 +111,11 @@ export default function TreatmentPanel({ project, treatment: api, part = 'all' }return (<div className="space-y-3">+ {storyboardApproved && (+ <p role="note" className="rounded border border-port-warning/40 bg-port-warning/5 p-2 text-xs text-port-warning">+ The storyboard is approved. Editing the treatment will need re-approval of the storyboard.+ </p>+ )}{showBrief && (<><div className="grid grid-cols-1 md:grid-cols-2 gap-2">diff --git a/client/src/components/musicVideo/TreatmentPanel.test.jsx b/client/src/components/musicVideo/TreatmentPanel.test.jsxindex 7167beccc3..07c168f8b3 100644--- a/client/src/components/musicVideo/TreatmentPanel.test.jsx+++ b/client/src/components/musicVideo/TreatmentPanel.test.jsx@@ -261,6 +261,12 @@ describe('TreatmentPanel split by dependency', () => {expect(screen.getByText('Draft without AI')).toBeTruthy();expect(screen.queryByLabelText('Audience')).toBeNull();});+ it('warns before a treatment edit that an approved storyboard will need re-approval (#10141)', () => {+ const { rerender } = render(<TreatmentPanel project={PROJECT} treatment={noop} part="brief" storyboardApproved />);+ expect(screen.getByRole('note')).toHaveTextContent('Editing the treatment will need re-approval of the storyboard');+ rerender(<TreatmentPanel project={PROJECT} treatment={noop} part="brief" />);+ expect(screen.queryByRole('note')).toBeNull();+ });it('summarizes revision, applied state and gaps for the section header', () => {expect(treatmentSummary({})).toBe('Not started');expect(treatmentSummary(PROJECT)).toBe('rev 3 · 0 directed shots · not applied · 1 capability gap');diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsxindex 6cfe6beafe..f60467d7a1 100644--- a/client/src/components/musicVideo/stages/BoardStage.jsx+++ b/client/src/components/musicVideo/stages/BoardStage.jsx@@ -80,7 +80,8 @@ export default function BoardStage({ board }) {</div><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" />+ <TreatmentPanel key={`treatment-${project.id}`} project={project} treatment={treatment} part="direction"+ storyboardApproved={!!board.productionReadiness?.storyboard?.approved} /></StageSection>{project.audioAnalysis && scenes.length > 0 && (diff --git a/client/src/components/musicVideo/stages/CastSetsStage.jsx b/client/src/components/musicVideo/stages/CastSetsStage.jsxindex 50e18ba23e..609fef3502 100644--- a/client/src/components/musicVideo/stages/CastSetsStage.jsx+++ b/client/src/components/musicVideo/stages/CastSetsStage.jsx@@ -12,6 +12,7 @@ export default function CastSetsStage({ board }) {{project.castAndSets ? (<CastAndSetsCheckinproject={project}+ stale={board.productionReadiness?.castAndSets?.stale || null}busy={locked || castSets.busy || kickoff.running}onOpenSheet={board.openArtifact}onApprove={board.approveCastAndSets}@@ -19,6 +20,7 @@ export default function CastSetsStage({ board }) {onEditDirection={castSets.editDirection}onResume={() => castSets.resume()}onRebuild={() => castSets.start()}+ onReconfirm={() => castSets.reconfirm()}onSkip={board.skipCastAndSets}/>) : (diff --git a/client/src/components/musicVideo/stages/SetupStage.jsx b/client/src/components/musicVideo/stages/SetupStage.jsxindex c95366dea1..0fe17adf1f 100644--- a/client/src/components/musicVideo/stages/SetupStage.jsx+++ b/client/src/components/musicVideo/stages/SetupStage.jsx@@ -237,7 +237,8 @@ export default function SetupStage({ board }) {</StageSection><StageSection id="mv-setup-treatment" title="Treatment brief" summary={`${treatmentSummary(project)} · feeds the shot planner`}><fieldset disabled={locked} className="min-w-0">- <TreatmentPanel key={`treatment-${project.id}`} project={project} treatment={treatment} part="brief" />+ <TreatmentPanel key={`treatment-${project.id}`} project={project} treatment={treatment} part="brief"+ storyboardApproved={!!board.productionReadiness?.storyboard?.approved} /></fieldset></StageSection></>diff --git a/client/src/hooks/useAutoRefetch.test.jsx b/client/src/hooks/useAutoRefetch.test.jsxindex 673f8780ee..f718fd597e 100644--- a/client/src/hooks/useAutoRefetch.test.jsx+++ b/client/src/hooks/useAutoRefetch.test.jsx@@ -151,8 +151,9 @@ describe('useAutoRefetch', () => {const { result } = renderHook(() => useAutoRefetch(fetchFn, 20));await waitFor(() => expect(result.current.data).toBe('first'));- await waitFor(() => expect(fetchFn.mock.calls.length).toBeGreaterThanOrEqual(4));- expect(result.current.data).toBe('recovered');+ // The 4th call being issued does not mean its result has been committed to state yet.+ await waitFor(() => expect(result.current.data).toBe('recovered'));+ expect(fetchFn.mock.calls.length).toBeGreaterThanOrEqual(4);expect(warn).toHaveBeenCalled();warn.mockRestore();});diff --git a/client/src/hooks/useMusicVideoCastAndSets.js b/client/src/hooks/useMusicVideoCastAndSets.jsindex 1761277aa7..32a3bfb43d 100644--- a/client/src/hooks/useMusicVideoCastAndSets.js+++ b/client/src/hooks/useMusicVideoCastAndSets.js@@ -9,6 +9,7 @@ import {editMusicVideoCastAndSetsDirection,resumeMusicVideoCastAndSets,approveMusicVideoCastAndSets,+ reconfirmMusicVideoCastAndSets,skipMusicVideoCastAndSets,} from '../services/apiMusicVideo.js';@@ -33,7 +34,7 @@ const reachedCheckpoint = (stage) => CHECKPOINTS.has(stage?.status) || stage?.in* `interrupted` by a restart), or null when it could not start or the wait was* abandoned with `cancelWait()` (the kickoff's Cancel).*- * Returns `{ busy, start, regenerate, editDirection, resume, approve, skip, runToCheckpoint, cancelWait }`.+ * Returns `{ busy, start, regenerate, editDirection, resume, approve, reconfirm, skip, runToCheckpoint, cancelWait }`.*/export default function useMusicVideoCastAndSets({ project, replaceProject } = {}) {const projectId = project?.id || null;@@ -118,6 +119,7 @@ export default function useMusicVideoCastAndSets({ project, replaceProject } = {const editDirection = (edits) => call(() => editMusicVideoCastAndSetsDirection(projectId, edits, { silent: true }), 'Direction saved — re-rendering what changed');const resume = () => call(() => resumeMusicVideoCastAndSets(projectId, { silent: true }));const approve = () => call(() => approveMusicVideoCastAndSets(projectId, { silent: true }), 'Cast & Sets approved');+ const reconfirm = () => call(() => reconfirmMusicVideoCastAndSets(projectId, { silent: true }), 'Cast & Sets kept approved');const skip = () => call(() => skipMusicVideoCastAndSets(projectId, { silent: true }), 'Cast & Sets check-in skipped');const runToCheckpoint = (target) => {@@ -147,5 +149,5 @@ export default function useMusicVideoCastAndSets({ project, replaceProject } = {w.resolve(null);};- return { busy, start, regenerate, editDirection, resume, approve, skip, runToCheckpoint, cancelWait };+ return { busy, start, regenerate, editDirection, resume, approve, reconfirm, skip, runToCheckpoint, cancelWait };}diff --git a/client/src/lib/musicVideoAttention.js b/client/src/lib/musicVideoAttention.jsindex 81d932d52e..41836272e2 100644--- a/client/src/lib/musicVideoAttention.js+++ b/client/src/lib/musicVideoAttention.js@@ -13,7 +13,7 @@*/import { describeAutonomousWait } from './musicVideoAutonomous.js';-import { RESUMABLE_RUN_STATUSES, currentProductionRun } from './musicVideoStages.js';+import { RESUMABLE_RUN_STATUSES, changedFieldsText, currentProductionRun } from './musicVideoStages.js';/** The DOM id of the banner, so a refusal toast can scroll to it. */export const ATTENTION_ANCHOR_ID = 'mv-needs-attention';@@ -40,11 +40,13 @@ function sectionProgress(project, revision) {* - `generatingSceneIds` — scenes with a frame/clip spinning on this board* - `draftRendering` — a draft excerpt render is attached to this tab* - `finalRenderAttached` — this tab already shows the final render's progress+ * - `readiness` — the server's production readiness, for approvals given on+ * inputs that have changed since (#10141)** Row shape: `{ id, kind, tone, title, detail, … }` plus the ids the action* needs — `revisionId` + `canResume` (revision), `runId` (auto-review).*/-export function deriveAttentionItems(project, { generatingSceneIds = null, draftRendering = false, finalRenderAttached = false } = {}) {+export function deriveAttentionItems(project, { generatingSceneIds = null, draftRendering = false, finalRenderAttached = false, readiness = project?.productionReadiness } = {}) {if (!project) return [];const items = [];const spinning = (sceneId) => !!generatingSceneIds?.has?.(sceneId);@@ -124,7 +126,38 @@ export function deriveAttentionItems(project, { generatingSceneIds = null, draftdetail: 'Reattach to watch its progress or cancel it.',});}- return [...items, ...parkedRunItems(project)];+ const stale = staleApprovalItem(project, readiness);+ return [...items, ...parkedRunItems(project), ...(stale ? [stale] : [])];+}++// Approvals in the order they are given, with the tab (and editor) each is re-given on.+const STALE_APPROVALS = [+ ['castAndSets', 'Cast & Sets check-in', 'cast-sets'],+ ['art', 'Art direction', 'cast-sets#mv-review-art'],+ ['storyboard', 'Timed storyboard', 'board#mv-review-storyboard'],+ ['proof', 'Animated proof', 'compose#mv-review-proof'],+];++// One row for every approval given on inputs that have changed since (#10141),+// naming what changed per approval and opening the earliest one. A running+// production replaces takes as its job, so it does not flag its own progress.+function staleApprovalItem(project, readiness) {+ if (currentProductionRun(project)?.status === 'running') return null;+ const stale = STALE_APPROVALS.filter(([key]) => readiness?.[key]?.stale);+ if (!stale.length) return null;+ const describe = ([key, label]) => {+ const fields = readiness[key].stale.changedFields || [];+ return fields.length ? `${label} — changed since: ${changedFieldsText(fields, 3)}` : `${label} — its inputs changed`;+ };+ return {+ id: 'stale-approvals',+ kind: 'stale-approvals',+ tone: 'warn',+ title: stale.length === 1 ? `${stale[0][1]} was approved earlier and has changed since` : `${stale.length} approvals were given before later changes`,+ detail: `${stale.map(describe).join('. ')}. Re-approve, or undo the change.`,+ projectId: project.id,+ openTo: stale[0][2],+ };}// Auto-review states that wait on the director (#10156): a limit, an unverifiablediff --git a/client/src/lib/musicVideoAttention.test.js b/client/src/lib/musicVideoAttention.test.jsindex 9bb6c2a8cc..1cda700fba 100644--- a/client/src/lib/musicVideoAttention.test.js+++ b/client/src/lib/musicVideoAttention.test.js@@ -155,3 +155,24 @@ describe('parked runs (#10156)', () => {expect(autoReviewNeedsUser(project({ autoReviews: [run({ status: 'needs-human' })] }))).toBe(true);});});++describe('stale approvals in Needs attention (#10141)', () => {+ const readiness = {+ castAndSets: { approved: true, stale: { changedFields: ['concept'] } },+ art: { approved: false, stale: { changedFields: ['concept', 'cast', 'environments', 'visual language'] } },+ storyboard: { approved: false, stale: null },+ proof: { approved: false, stale: null },+ };++ it('names what changed per approval and opens the earliest one', () => {+ const [item] = deriveAttentionItems(project(), { readiness });+ expect(item).toMatchObject({ kind: 'stale-approvals', openTo: 'cast-sets', title: '2 approvals were given before later changes' });+ expect(item.detail).toBe('Cast & Sets check-in — changed since: concept. Art direction — changed since: concept, cast, environments +1 more. Re-approve, or undo the change.');+ });++ it('stays quiet with no stale approval, and while a production run is replacing takes', () => {+ expect(deriveAttentionItems(project(), { readiness: { art: { stale: null } } })).toEqual([]);+ const producing = project({ productionRuns: [{ id: 'run-1', status: 'running' }], productionRunId: 'run-1' });+ expect(deriveAttentionItems(producing, { readiness }).some((i) => i.kind === 'stale-approvals')).toBe(false);+ });+});diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.jsindex 123b154ab7..35960a36c6 100644--- a/client/src/lib/musicVideoStages.js+++ b/client/src/lib/musicVideoStages.js@@ -275,7 +275,8 @@ export function lyricSetupState(project, readiness = project?.productionReadines/*** Each stage's state derived from the project record — `done`, `blocked`* (stopped and needs the director), `active` (the stage the project is in), or- * `todo` — plus `current`, the first stage that is not done. A live production+ * `todo`, with `stale` when an approval it owns was given on inputs that have+ * changed since — plus `current`, the first stage that is not done. A live production* run owns the project, so it pins `current` to Produce.** The animated proof is the last step of Compose (#10140): its basis covers the@@ -313,6 +314,13 @@ export function deriveStages(project, readiness = project?.productionReadiness,'cast-sets': castStopped,produce: !!run && RUN_BLOCKED_STATUSES.has(run.status),};+ // Approved earlier, inputs changed since (#10141): the tab says so rather than+ // reading as never done. The check-in sheet stays approved while stale.+ const stale = {+ 'cast-sets': !!readiness?.art?.stale || !!readiness?.castAndSets?.stale,+ board: !!readiness?.storyboard?.stale,+ compose: !!readiness?.proof?.stale,+ };const current = liveRun? 'produce': (MUSIC_VIDEO_STAGES.find((stage) => !done[stage.id])?.id || 'publish');@@ -320,7 +328,7 @@ export function deriveStages(project, readiness = project?.productionReadiness,let state = 'todo';if (done[stage.id] && !(stage.id === current && liveRun)) state = 'done';else if (stage.id === current) state = blocked[stage.id] ? 'blocked' : 'active';- return { ...stage, state };+ return { ...stage, state, stale: !!stale[stage.id] };});return { stages, current };}@@ -450,9 +458,12 @@ const ART_DIRECTION_FIELDS = [['cast', 'cast'], ['environments', 'sets'], ['visu/** "Approved earlier — changed since: concept, scene 3 prompt" for an approval whose inputs moved; null otherwise. */export function staleApprovalText(stale) {if (!stale) return null;- const shown = stale.changedFields.slice(0, 4).join(', ');- const more = stale.changedFields.length > 4 ? ` +${stale.changedFields.length - 4} more` : '';- return stale.changedFields.length ? `Approved earlier — changed since: ${shown}${more}.` : 'Approved earlier — its inputs changed since.';+ return stale.changedFields.length ? `Approved earlier — changed since: ${changedFieldsText(stale.changedFields)}.` : 'Approved earlier — its inputs changed since.';+}+/** "concept, scene 3 prompt +2 more": the first `limit` changed inputs of a stale approval. */+export function changedFieldsText(changedFields, limit = 4) {+ const more = changedFields.length > limit ? ` +${changedFields.length - limit} more` : '';+ return `${changedFields.slice(0, limit).join(', ')}${more}`;}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' };diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.jsindex fc42498bb1..d45982532e 100644--- a/client/src/lib/musicVideoStages.test.js+++ b/client/src/lib/musicVideoStages.test.js@@ -490,5 +490,8 @@ describe('stale approval text (#10141)', () => {const item = stageChecklist('cast-sets', { productionReview: { draft: {} } }, readiness).find((i) => i.id === 'approve-art');expect(item).toMatchObject({ done: false, stale: true });expect(item.detail).toMatch(/^Approved earlier — changed since: concept, scene 3 prompt\./);+ // The owning tab carries the stale mark; tabs whose approvals are current do not.+ const { stages } = deriveStages({ scenes: [] }, readiness);+ expect(stages.filter((s) => s.stale).map((s) => s.id)).toEqual(['cast-sets']);});});diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex d49706d2dc..ead7c003bc 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -993,6 +993,7 @@ export default function MusicVideo() {.filter((sceneId) => sceneMedia.genScenes?.[sceneId] || sceneMedia.genVideoScenes?.[sceneId])),draftRendering: excerpts.rendering,finalRenderAttached: renderTargetsSelected,+ readiness: productionReview.readiness,}) : [];const runNextAction = () => {if (!selected || !nextAction || nextAction.disabled || compositionSavePending > 0) return;diff --git a/client/src/services/apiMusicVideo.js b/client/src/services/apiMusicVideo.jsindex b773ce2ed6..2f3aa48d82 100644--- a/client/src/services/apiMusicVideo.js+++ b/client/src/services/apiMusicVideo.js@@ -411,6 +411,9 @@ export const resumeMusicVideoCastAndSets = (id, options = {}) =>request(`/music-video/${encodeURIComponent(id)}/cast-and-sets/resume`, { method: 'POST', body: '{}', ...options });export const approveMusicVideoCastAndSets = (id, options = {}) =>request(`/music-video/${encodeURIComponent(id)}/cast-and-sets/approve`, { method: 'POST', ...options });+// "Keep approved" (#10141): re-stamp an approved check-in on the project's current concept, style, subjects and song.+export const reconfirmMusicVideoCastAndSets = (id, options = {}) =>+ request(`/music-video/${encodeURIComponent(id)}/cast-and-sets/reconfirm`, { method: 'POST', ...options });export const skipMusicVideoCastAndSets = (id, options = {}) =>request(`/music-video/${encodeURIComponent(id)}/cast-and-sets/skip`, { method: 'POST', ...options });diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.jsindex a88451902c..70dc1b1015 100644--- a/server/routes/musicVideo.js+++ b/server/routes/musicVideo.js@@ -186,6 +186,7 @@ import {regenerateCastAndSets,resumeCastAndSets,approveCastAndSets,+ reconfirmCastAndSets,skipCastAndSets,getCastAndSets,presentProjectCastAndSets,@@ -1172,6 +1173,12 @@ router.post('/:id/cast-and-sets/approve', asyncHandler(async (req, res) => {res.json(await approveCastAndSets(req.params.id));}));+// "Keep approved": an approved check-in whose concept, style, subjects or song+// changed since is re-stamped on the current inputs (#10141). No body.+router.post('/:id/cast-and-sets/reconfirm', asyncHandler(async (req, res) => {+ res.json(await reconfirmCastAndSets(req.params.id));+}));+router.post('/:id/cast-and-sets/skip', asyncHandler(async (req, res) => {res.json(await skipCastAndSets(req.params.id));}));diff --git a/server/services/musicVideo/castAndSets.js b/server/services/musicVideo/castAndSets.jsindex 896de25cc7..2ad62320fe 100644--- a/server/services/musicVideo/castAndSets.js+++ b/server/services/musicVideo/castAndSets.js@@ -20,6 +20,7 @@* submittedPrompt?, submittedPromptTruncated?, submittedReferences?, submittedRevision? } },* artifactId, artifactVersion, notesApplied,* createdAt, updatedAt, approvedAt,+ * approvedInputs, // labeled input hashes the approval rests on (productionReview.js); absent on legacy approvals* }** Status: `directing` → `imaging` → `assembling` → `review` → `approved`, or@@ -126,6 +127,7 @@ export function reviseCastAndSetsOnProject(project, { processId, notesApplied =processId,notesApplied: notesApplied.map((n) => ({ id: n.id || null, target: n.target || null, text: trimTo(n.text, 2000) })),approvedAt: null,+ approvedInputs: null,}, now);}@@ -250,6 +252,17 @@ export function setCastAndSetsStatus(project, status, { reason = null, error = n}, now);}+/**+ * Keep an approved check-in approved on its current inputs ("Keep approved"):+ * re-stamps `approvedInputs` without re-applying the sheet, so the director's+ * later concept/style edits stand. Returns `{ project, stage }`.+ */+export function reconfirmCastAndSetsOnProject(project, approvedInputs, now = new Date().toISOString()) {+ const stage = requireStage(project);+ if (stage.status !== 'approved') throw stageError(409, 'CAST_SETS_NOT_APPROVED', `The Cast & Sets check-in is ${stage.status}, not approved`);+ return write(project, { ...stage, approvedInputs, approvedAt: now }, now);+}+/** Refuse an approval that has nothing to approve. */export function assertCastAndSetsApprovable(project) {const stage = requireStage(project);diff --git a/server/services/musicVideo/castAndSetsService.js b/server/services/musicVideo/castAndSetsService.jsindex 0cba8c351a..3f9a6aa987 100644--- a/server/services/musicVideo/castAndSetsService.js+++ b/server/services/musicVideo/castAndSetsService.js@@ -1,5 +1,5 @@import { musicVideoAllowsMedia, assertMusicVideoMediaSelections } from '../../lib/musicVideoMediaPolicy.js';-import { productionFeedbackContext, seedArtDraft } from './productionReview.js';+import { castAndSetsApprovalInputs, productionFeedbackContext, seedArtDraft } from './productionReview.js';import { withMusicVideoStyle } from './styleReferences.js';/*** Music Video — Cast & Sets check-in orchestrator.@@ -46,6 +46,7 @@ import {dispatchableImageKeys,linkCastAndSetsJob,presentCastAndSets,+ reconfirmCastAndSetsOnProject,reserveCastAndSetsImage,resumeCastAndSetsOnProject,reviseCastAndSetsOnProject,@@ -546,7 +547,9 @@ function applyApproval(project, now) {if (stage.artifactId && (next.devArtifacts || []).some((a) => a.id === stage.artifactId && !a.deleted)) {next = reviewDevArtifact(next, stage.artifactId, { status: 'approved' }, now).project;}- return setCastAndSetsStatus(next, 'approved', {}, now);+ // Record what the approval rests on, so a later concept/style/subject/song+ // edit can be named as "changed since" (#10141).+ return setCastAndSetsStatus(next, 'approved', { extra: { approvedInputs: castAndSetsApprovalInputs(next) } }, now);}// Settle the stage and re-base a production run waiting on it, in ONE write,@@ -568,6 +571,20 @@ export async function approveCastAndSets(projectId) {return { project: out.project, stage: presentCastAndSets(out.stage, PROCESS_ID) };}+/**+ * Keep an approved check-in approved on the project's current concept, style,+ * subjects and song (#10141): clears the "changed since" note without+ * rebuilding the sheet or re-applying its references. Returns `{ project, stage }`.+ */+export async function reconfirmCastAndSets(projectId) {+ await requireProject(projectId);+ const now = new Date().toISOString();+ const out = await mutateProjectRecord(projectId, (current) => reconfirmCastAndSetsOnProject(current, castAndSetsApprovalInputs(current), now));+ console.log(`✅ Music Video Cast & Sets ${short(projectId)} kept approved on current inputs`);+ publish(projectId, out.project);+ return { project: out.project, stage: presentCastAndSets(out.stage, PROCESS_ID) };+}+/** Skip the check-in (e.g. no image backend): the autopilot continues without it. */export async function skipCastAndSets(projectId) {await requireProject(projectId);diff --git a/server/services/musicVideo/castAndSetsService.test.js b/server/services/musicVideo/castAndSetsService.test.jsindex b0d7244548..bea181e074 100644--- a/server/services/musicVideo/castAndSetsService.test.js+++ b/server/services/musicVideo/castAndSetsService.test.js@@ -369,6 +369,17 @@ describe('Cast & Sets check-in', () => {expect(done.concept.subjects.map((s) => [s.id, s.kind])).toEqual([['s-band', 'character'], ['cs-protagonist', 'character'], ['cs-set-lab', 'place'], ['cs-set-harbor', 'place'], ['cs-set-roof', 'place'],]);++ // #10141: the approval records what it rests on, so a later concept edit is+ // named on the read; "Keep approved" re-stamps it without rebuilding the sheet.+ const castReadiness = async () => (await request(app).get(`/api/music-video/${project.id}`)).body.productionReadiness.castAndSets;+ expect(await castReadiness()).toEqual({ approved: true, stale: null });+ expect((await request(app).patch(`/api/music-video/${project.id}`).send({ concept: { prompt: 'a homecoming' } })).status).toBe(200);+ expect(await castReadiness()).toMatchObject({ approved: true, stale: { changedFields: ['concept'] } });+ const kept = await request(app).post(`/api/music-video/${project.id}/cast-and-sets/reconfirm`);+ expect(kept.status).toBe(200);+ expect(kept.body.project.concept.prompt).toBe('a homecoming');+ expect(await castReadiness()).toEqual({ approved: true, stale: null });});it('seeds the empty art-direction draft and guide on approval without overwriting typed text', async () => {diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.jsindex bd4228ec37..da87e6749c 100644--- a/server/services/musicVideo/productionReview.js+++ b/server/services/musicVideo/productionReview.js@@ -112,16 +112,52 @@ function productionApprovalInputs(project) {return { art, storyboard, proof };}+// The labels whose hash moved (or disappeared) between two input snapshots.+const changedInputs = (before, now) => Object.keys(now).filter(k => before[k] !== now[k])+ .concat(Object.keys(before).filter(k => !(k in now)));+/** `{ approvedAt, changedFields }` when a stage was approved on inputs that have since moved; null otherwise. */function staleApproval(project, stage, current, inputs) {const approval = project.productionReview?.approvals?.[stage];if (!approval || approval.basis === current) return null;const before = approval.inputs;- const changedFields = before ? Object.keys(inputs[stage]).filter(k => before[k] !== inputs[stage][k])- .concat(Object.keys(before).filter(k => !(k in inputs[stage]))) : [];+ const changedFields = before ? changedInputs(before, inputs[stage]) : [];return { approvedAt: approval.approvedAt || null, changedFields: changedFields.length ? changedFields : (before ? ['proof render'] : []) };}+/**+ * The labeled inputs a Cast & Sets approval rests on — the concept, its style,+ * the subjects (with the cast references the approval wrote) and the song —+ * hashed per label. Stored on the stage at approval as `approvedInputs`.+ * References hash by image only, so re-normalizing a reference's optional+ * fields is not mistaken for a new subject.+ */+export function castAndSetsApprovalInputs(project) {+ const { subjects, style, universeStyle, moodBoardStyle, ...concept } = project.concept || {};+ const spec = project.visualSpec || {};+ return {+ concept: h(concept),+ style: h([style || '', universeStyle || '', moodBoardStyle || '', spec.palette || [], spec.typography || '',+ spec.cameraRules || '', spec.moodBoardId || null, project.styleReferences ?? null]),+ subjects: h([subjects || [], (spec.references || []).map(r => r?.imageId || null)]),+ song: h([project.trackId || null, project.uploadedAudioFilename || null]),+ };+}++/**+ * The Cast & Sets check-in as an approval: `{ approved, stale }`. An approved+ * stage stays approved when its inputs move (its references still condition+ * the frames) but reports what changed since. A stage approved before inputs+ * were recorded has no basis to compare and reports no staleness.+ */+function castAndSetsApproval(project) {+ const stage = project.castAndSets;+ const approved = stage?.status === 'approved';+ if (!approved || !stage.approvedInputs) return { approved, stale: null };+ const changedFields = changedInputs(stage.approvedInputs, castAndSetsApprovalInputs(project));+ return { approved, stale: changedFields.length ? { approvedAt: stage.approvedAt || null, changedFields } : null };+}+export function productionReadiness(project) {const review = project.productionReview || {};const draft = review.draft || {};@@ -197,6 +233,7 @@ export function productionReadiness(project) {: draft.timingStatus !== 'verified' ? 'provisional' : review.alignmentBasis === alignmentBasis ? 'verified' : 'stale' }, documentShotImport: { documentDirectory: project.composition?.document?.directory || null, audioBasis: alignmentBasis }, art: { approved: artApproved, problems: [...new Set(artProblems)], stale: artApproved ? null : staleApproval(project, 'art', basis.art, inputs) },storyboard: { approved: storyboardApproved, problems: [...new Set(boardProblems)], stale: storyboardApproved ? null : staleApproval(project, 'storyboard', basis.storyboard, inputs) },proof: { approved: proofApproved, problems: proofProblems, excerptId: excerpt?.id || null, stale: proofApproved ? null : staleApproval(project, 'proof', basis.proof, inputs) },+ castAndSets: castAndSetsApproval(project),readyForProduction: proofApproved };}diff --git a/server/services/musicVideo/productionReview.stale.test.js b/server/services/musicVideo/productionReview.stale.test.jsindex 06ebb308fe..3254822013 100644--- a/server/services/musicVideo/productionReview.stale.test.js+++ b/server/services/musicVideo/productionReview.stale.test.js@@ -1,5 +1,7 @@import { describe, it, expect } from 'vitest';-import { productionReadiness } from './productionReview.js';+import { castAndSetsApprovalInputs, productionReadiness } from './productionReview.js';++const castAndSetsApproval = (project) => productionReadiness(project).castAndSets;// Approval records the labeled inputs it was granted on, so a later change can be named.const approvedArt = (project) => ({ ...project, productionReview: { ...project.productionReview,@@ -25,3 +27,24 @@ describe('stale approval reporting', () => {expect(Object.keys(edited).filter(k => edited[k] !== inputs[k])).toEqual(['scene 2 prompt']);});});++describe('Cast & Sets approval basis', () => {+ const project = { id: 'p1', trackId: 't1', concept: { prompt: 'Example concept', style: 'ink', subjects: [{ id: 's1' }] },+ visualSpec: { palette: ['#000000'], references: [{ id: 'r1', imageId: 'a.png', role: 'character' }] } };+ const approved = (p) => ({ ...p, castAndSets: { status: 'approved', approvedAt: '2026-01-01T00:00:00.000Z', approvedInputs: castAndSetsApprovalInputs(p) } });++ it('names concept, style, subject and song changes separately', () => {+ const base = approved(project);+ expect(castAndSetsApproval(base)).toEqual({ approved: true, stale: null });+ const edited = { ...base, trackId: 't2', concept: { ...project.concept, style: 'oil' }, visualSpec: { ...project.visualSpec, references: [] } };+ expect(castAndSetsApproval(edited).stale.changedFields).toEqual(['style', 'subjects', 'song']);+ });++ it('ignores a reference re-normalized with default fields, and never flags a legacy approval without recorded inputs', () => {+ const base = approved(project);+ const normalized = { ...base, visualSpec: { ...project.visualSpec, typography: '', references: [{ id: 'r1', imageId: 'a.png', role: 'character', note: '', use: 'reference', condition: false }] } };+ expect(castAndSetsApproval(normalized).stale).toBeNull();+ const legacy = { ...project, concept: { prompt: 'Changed' }, castAndSets: { status: 'approved', approvedAt: '2026-01-01T00:00:00.000Z' } };+ expect(castAndSetsApproval(legacy)).toEqual({ approved: true, stale: null });+ });+});