Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: approving Cast & Sets seeds the art draft; Rebuild after skip or approve; import a guide on the tab (#10138)

Adam Eivydcd69062093a
diff --git a/client/src/components/musicVideo/CastAndSetsCheckin.jsx b/client/src/components/musicVideo/CastAndSetsCheckin.jsx
index b3f4b522a7..6fc01ed103 100644
--- a/client/src/components/musicVideo/CastAndSetsCheckin.jsx
+++ b/client/src/components/musicVideo/CastAndSetsCheckin.jsx
@@ -30,10 +30,10 @@ 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 with notes,
+ * and the director's actions (Approve & continue, Regenerate,
* Edit direction on a procedural sheet, Resume, Skip).
*/
-export default function CastAndSetsCheckin({ project, busy, onOpenSheet, onApprove, onRegenerate, onEditDirection, onResume, onSkip }) {
+export default function CastAndSetsCheckin({ project, busy, onOpenSheet, onApprove, onRegenerate, onEditDirection, onResume, onRebuild, onSkip }) {
const stage = project.castAndSets;
if (!stage) return null;
const working = WORKING.has(stage.status) && !stage.interrupted;
@@ -58,9 +58,9 @@ export default function CastAndSetsCheckin({ project, busy, onOpenSheet, onAppro
)}
{stage.status === 'review' && (
<>
- <button type="button" disabled={busy || !openNotes} onClick={onRegenerate} title={openNotes ? 'Re-render what your notes touch' : 'Add a note on the sheet first'}
+ <button type="button" disabled={busy} onClick={onRegenerate} title={openNotes ? 'Re-render what your notes touch' : 'Re-render every image — or add a note on the sheet to change just one'}
className={`${buttonClass} border border-port-border`}>
- <RotateCcw size={14} aria-hidden="true" /> Regenerate with notes
+ <RotateCcw size={14} aria-hidden="true" /> {openNotes ? 'Regenerate with notes' : 'Regenerate'}
</button>
{onEditDirection && stage.direction?.medium === 'procedural' && (
<CastAndSetsDirectionEditor key={stage.revision} project={project} direction={stage.direction} busy={busy} onSave={onEditDirection} />
@@ -75,6 +75,12 @@ export default function CastAndSetsCheckin({ project, busy, onOpenSheet, onAppro
<Play size={14} aria-hidden="true" /> Resume
</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`}>
+ <RotateCcw size={14} aria-hidden="true" /> Rebuild
+ </button>
+ )}
{!working && !['approved', 'skipped'].includes(stage.status) && (
<button type="button" disabled={busy} onClick={onSkip} className={`${buttonClass} text-port-text-muted`}>
<SkipForward size={14} aria-hidden="true" /> Skip check-in
diff --git a/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx b/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx
index 1f74617e08..d40a0a6a02 100644
--- a/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx
+++ b/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx
@@ -185,3 +185,53 @@ describe('Cast & Sets direction editing', () => {
expect(screen.getByLabelText('Camera').value).toBe('locked off');
});
});
+
+describe('Cast & Sets tab: undo, regenerate and guide import', () => {
+ const sheet = { id: 'sheet-1', title: 'Check-in sheet', kind: 'cast-sets', version: 1, status: 'approved', mimeType: 'text/html', updatedAt: '2026-01-01T00:00:00Z' };
+ const imported = { id: 'guide-1', title: 'My guide', kind: 'other', version: 1, status: 'pending', mimeType: 'image/png', updatedAt: '2026-01-02T00:00:00Z' };
+ const movie = { id: 'clip-1', title: 'A clip', kind: 'animatic', version: 1, status: 'pending', mimeType: 'video/mp4', updatedAt: '2026-01-03T00:00:00Z' };
+ const withStatus = (status, extra = {}) => ({ id: 'example-project', devArtifacts: [sheet, imported, movie], castAndSets: { revision: 1, status, plan: {}, images: {}, artifactId: 'sheet-1', ...extra } });
+ const open = (value, board = {}) => {
+ const Page = () => {
+ const [current, setCurrent] = useState(value);
+ const actions = useMusicVideoCastAndSets({ project: current, replaceProject: setCurrent });
+ return <CastSetsStage board={{ project: current, locked: false, castSets: actions, kickoff: { running: false }, devArtifacts: { busy: false }, openArtifact: vi.fn(), approveCastAndSets: actions.approve, skipCastAndSets: actions.skip, ...board }} />;
+ };
+ return render(<Page />);
+ };
+
+ it.each(['approved', 'skipped'])('restarts a %s check-in from the tab with Rebuild', async (status) => {
+ api.startMusicVideoCastAndSets.mockResolvedValue({ project: withStatus('directing', { revision: 2 }) });
+ open(withStatus(status));
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Rebuild' })); });
+ expect(api.startMusicVideoCastAndSets).toHaveBeenCalledWith('example-project', {}, { silent: true });
+ expect(screen.getByText('revision 2')).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Rebuild' })).toBeNull();
+ });
+
+ it('offers Regenerate without a note and no Rebuild while the sheet awaits review', async () => {
+ api.regenerateMusicVideoCastAndSets.mockResolvedValue({ project: withStatus('imaging', { revision: 2 }) });
+ open(withStatus('review'));
+ expect(screen.queryByRole('button', { name: 'Rebuild' })).toBeNull();
+ const regenerate = screen.getByRole('button', { name: /Regenerate/ });
+ expect(regenerate).not.toBeDisabled();
+ await act(async () => { fireEvent.click(regenerate); });
+ expect(api.regenerateMusicVideoCastAndSets).toHaveBeenCalledWith('example-project', {}, { silent: true });
+ });
+
+ it('imports a guide here and chooses it as the visual guide, only for usable files', () => {
+ const useAsGuide = vi.fn();
+ open(withStatus('approved'), { onUploadArtifact: vi.fn(), useAsGuide });
+ expect(screen.getByLabelText('Import development file')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Use My guide as visual guide' }));
+ expect(useAsGuide).toHaveBeenCalledWith('guide-1');
+ expect(screen.queryByRole('button', { name: 'Use A clip as visual guide' })).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() });
+ expect(screen.getByText(/Visual guide$/)).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Use Check-in sheet as visual guide' })).toBeNull();
+ });
+});
diff --git a/client/src/components/musicVideo/DevArtifactDrawer.jsx b/client/src/components/musicVideo/DevArtifactDrawer.jsx
index e7d7ef8bbb..0f343a7634 100644
--- a/client/src/components/musicVideo/DevArtifactDrawer.jsx
+++ b/client/src/components/musicVideo/DevArtifactDrawer.jsx
@@ -93,10 +93,10 @@ export default function DevArtifactDrawer({
<div className="flex flex-wrap gap-2">
{isStageSheet ? (
<>
- <button type="button" disabled={busy || stageWorking || openNotes.length === 0} onClick={() => castAndSets.regenerate()}
- title={openNotes.length ? 'Re-render only what your open notes touch, as a new version' : 'Add a note first'}
+ <button type="button" disabled={busy || stageWorking} onClick={() => castAndSets.regenerate()}
+ title={openNotes.length ? 'Re-render only what your open notes touch, as a new version' : 'Re-render every image as a new version — or add a note to change just one'}
className={`${buttonClass} border border-port-border`}>
- <RotateCcw size={14} aria-hidden="true" /> Regenerate with notes
+ <RotateCcw size={14} aria-hidden="true" /> {openNotes.length ? 'Regenerate with notes' : 'Regenerate'}
</button>
{stage.status === 'review' && (
<button type="button" disabled={busy} onClick={() => castAndSets.approveAndContinue()} className={`${buttonClass} bg-port-accent text-white`}>
diff --git a/client/src/components/musicVideo/DevArtifactsPanel.jsx b/client/src/components/musicVideo/DevArtifactsPanel.jsx
index 26dcf6efc1..e2f614f5ee 100644
--- a/client/src/components/musicVideo/DevArtifactsPanel.jsx
+++ b/client/src/components/musicVideo/DevArtifactsPanel.jsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import { FileText, Film, Image as ImageIcon, LayoutGrid, Users, Upload, FolderOpen } from 'lucide-react';
+import { FileText, Film, Image as ImageIcon, LayoutGrid, Users, Upload, FolderOpen, Check } from 'lucide-react';
import Pill from '../ui/Pill.jsx';
import FilePickerButton from '../ui/FilePickerButton.jsx';
import { timeAgo } from '../../utils/formatters.js';
@@ -18,6 +18,8 @@ export const DEV_ARTIFACT_STATUS = {
'changes-requested': { label: 'Changes requested', tone: 'error' },
};
const ACCEPT = '.html,.htm,.md,.mp4,.png,.jpg,.jpeg';
+// What the production approvals accept as the visual cast/environment guide.
+const GUIDE_MIME_TYPES = ['text/html', 'image/png', 'image/jpeg'];
/**
* The project's development files ("ingredients") — the Cast & Sets sheet,
@@ -27,9 +29,11 @@ const ACCEPT = '.html,.htm,.md,.mp4,.png,.jpg,.jpeg';
*
* `kinds` narrows the list to those artifact kinds (the Cast & Sets tab shows
* only its own sheets); without `onUpload` the import control is left out.
+ * With `onUseAsGuide(artifactId)` each usable sheet or image gets a
+ * "Use as visual guide" action; `guideId` marks the one already chosen.
*/
export default function DevArtifactsPanel({
- project, busy, onOpen, onUpload = null, kinds = null, title = 'Development',
+ project, busy, onOpen, onUpload = null, onUseAsGuide = null, guideId = null, kinds = null, title = 'Development',
emptyText = 'Check-in sheets, animatics and other working files',
}) {
const artifacts = (project.devArtifacts || [])
@@ -71,9 +75,9 @@ export default function DevArtifactsPanel({
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}>
+ <li key={artifact.id} className="flex flex-wrap items-center gap-1">
<button type="button" onClick={() => onOpen(artifact.id)}
- className="w-full flex flex-wrap items-center gap-2 py-2 text-left min-h-[44px] hover:bg-port-bg/60 rounded px-1">
+ 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>
<span className="text-[11px] text-port-text-muted">{DEV_ARTIFACT_KIND_LABELS[artifact.kind] || artifact.kind} · v{artifact.version}</span>
@@ -81,6 +85,14 @@ export default function DevArtifactsPanel({
<Pill size="xs" tone={status.tone}>{status.label}</Pill>
<span className="text-[11px] text-port-text-muted hidden sm:inline">{timeAgo(artifact.updatedAt)}</span>
</button>
+ {onUseAsGuide && (!artifact.mimeType || GUIDE_MIME_TYPES.includes(artifact.mimeType)) && (artifact.id === guideId
+ ? <Pill size="xs" tone="success"><Check size={11} className="inline" aria-hidden="true" /> Visual guide</Pill>
+ : (
+ <button type="button" disabled={busy} onClick={() => onUseAsGuide(artifact.id)} aria-label={`Use ${artifact.title} as visual guide`}
+ className="text-xs text-port-accent border border-port-border rounded px-2 min-h-[44px] sm:min-h-0 sm:py-1 disabled:opacity-50">
+ Use as visual guide
+ </button>
+ ))}
</li>
);
})}
diff --git a/client/src/components/musicVideo/stages/CastSetsStage.jsx b/client/src/components/musicVideo/stages/CastSetsStage.jsx
index 42aa934da9..e819b3cdb8 100644
--- a/client/src/components/musicVideo/stages/CastSetsStage.jsx
+++ b/client/src/components/musicVideo/stages/CastSetsStage.jsx
@@ -18,6 +18,7 @@ export default function CastSetsStage({ board }) {
onRegenerate={() => castSets.regenerate()}
onEditDirection={castSets.editDirection}
onResume={() => castSets.resume()}
+ onRebuild={() => castSets.start()}
onSkip={board.skipCastAndSets}
/>
) : (
@@ -30,9 +31,11 @@ export default function CastSetsStage({ board }) {
project={project}
busy={board.devArtifacts.busy}
onOpen={board.openArtifact}
- kinds={['cast-sets']}
- title="Cast & Sets sheets"
- emptyText="The check-in sheet appears here once the cast and sets are built"
+ onUpload={board.onUploadArtifact}
+ onUseAsGuide={board.useAsGuide}
+ guideId={project.productionReview?.draft?.guideArtifactId || null}
+ title="Cast & Sets sheets and visual guides"
+ emptyText="The check-in sheet appears here once the cast and sets are built — or import your own guide"
/>
</div>
);
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 4f0944318c..849cc1106d 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -106,6 +106,9 @@ function autopilotBlocker(project) {
}
// The panels each stage tab renders (see lib/musicVideoStages.js for the ids).
+// A saved art draft needs every field the server schema requires.
+const EMPTY_PRODUCTION_DRAFT = { cast: '', environments: '', visualLanguage: '', motionLanguage: '', guideArtifactId: null,
+ lyricsMode: 'vocal', timingStatus: 'provisional', timingNotes: '', storyboard: [] };
const STAGE_VIEWS = {
setup: SetupStage, 'cast-sets': CastSetsStage, board: BoardStage, produce: ProduceStage, compose: ComposeStage, review: ReviewStage, publish: PublishStage,
};
@@ -1080,6 +1083,8 @@ export default function MusicVideo() {
commitSceneTiming,
approveCastAndSets,
skipCastAndSets,
+ // Choose a Development file as the art-direction visual guide (saved with the rest of the draft).
+ useAsGuide: (artifactId) => productionReview.save({ ...EMPTY_PRODUCTION_DRAFT, ...(selected.productionReview?.draft || {}), guideArtifactId: artifactId }),
goToStage,
openArtifact,
openPreview,
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index 4592508803..62392af487 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -2481,8 +2481,11 @@ describe('MusicVideo stage tabs (#9243)', () => {
board: { 'AI Plan': () => screen.queryByRole('button', { name: /AI Plan/ }), 'Add scene': () => screen.queryByRole('button', { name: /Add scene/ }), 'Shot prompt': () => screen.queryByLabelText('Shot prompt') },
produce: { 'Automation brief': () => screen.queryByLabelText('Automation brief'), 'Start production': () => screen.queryByRole('button', { name: /Start production/ }) },
compose: { Typography: () => screen.queryByText(/^Typography —/) },
- review: { 'Render final': () => screen.queryByRole('button', { name: /^Render final$/ }), 'Render excerpt': () => screen.queryByRole('button', { name: /Render excerpt/ }), 'Import development file': () => screen.queryByLabelText('Import development file') },
+ review: { 'Render final': () => screen.queryByRole('button', { name: /^Render final$/ }), 'Render excerpt': () => screen.queryByRole('button', { name: /Render excerpt/ }) },
};
+ // Importing a file is deliberately offered on two tabs: a guide is imported where it is chosen (Cast & Sets),
+ // and any other development file on Review.
+ const importFile = () => screen.queryByLabelText('Import development file');
await openProject(project);
for (const [stage, own] of Object.entries(landmarks)) {
await openStage(stage);
@@ -2491,6 +2494,7 @@ describe('MusicVideo stage tabs (#9243)', () => {
if (other === stage) continue;
for (const [name, find] of Object.entries(theirs)) expect(find(), `${name} must not be on ${stage}`).toBeFalsy();
}
+ expect(!!importFile(), `Import development file on ${stage}`).toBe(stage === 'cast-sets' || stage === 'review');
}
});
diff --git a/server/services/musicVideo/castAndSets.js b/server/services/musicVideo/castAndSets.js
index 7cc5a31beb..896de25cc7 100644
--- a/server/services/musicVideo/castAndSets.js
+++ b/server/services/musicVideo/castAndSets.js
@@ -73,15 +73,17 @@ function write(project, stage, now) {
/**
* Begin (or restart) the stage. Refuses while a working stage is live in
- * this process, and once approved (regenerate instead). Returns `{ project, stage }`.
+ * this process, and while a sheet awaits review (regenerate instead). A
+ * skipped or approved stage restarts as a Rebuild: the prior sheet's artifact
+ * keeps its versions, so the earlier sheet stays in history. Returns `{ project, stage }`.
*/
export function startCastAndSetsOnProject(project, { processId, productionRunId = null }, now = new Date().toISOString()) {
const current = project?.castAndSets || null;
if (current && CAST_SETS_WORKING.includes(current.status) && current.processId === processId) {
throw stageError(409, 'CAST_SETS_IN_PROGRESS', 'The Cast & Sets check-in is already being prepared');
}
- if (current?.status === 'approved' || current?.status === 'review') {
- throw stageError(409, 'CAST_SETS_EXISTS', 'This project already has a Cast & Sets sheet — regenerate it with notes instead');
+ if (current?.status === 'review') {
+ throw stageError(409, 'CAST_SETS_EXISTS', 'This project already has a Cast & Sets sheet awaiting review — regenerate it instead');
}
const stage = {
revision: (current?.revision || 0) + 1,
diff --git a/server/services/musicVideo/castAndSetsService.js b/server/services/musicVideo/castAndSetsService.js
index 92bda03008..0cba8c351a 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 } from './productionReview.js';
+import { productionFeedbackContext, seedArtDraft } from './productionReview.js';
import { withMusicVideoStyle } from './styleReferences.js';
/**
* Music Video — Cast & Sets check-in orchestrator.
@@ -540,6 +540,9 @@ function applyApproval(project, now) {
concept: { ...(project.concept || {}), subjects: castAndSetsSubjects(project, stage) },
};
assertMusicVideoMediaSelections(next);
+ // Approving the sheet seeds the art-direction draft and guide so the next
+ // approval is one click, not a re-typing of what the sheet already says.
+ next = seedArtDraft(next, stage);
if (stage.artifactId && (next.devArtifacts || []).some((a) => a.id === stage.artifactId && !a.deleted)) {
next = reviewDevArtifact(next, stage.artifactId, { status: 'approved' }, now).project;
}
@@ -596,7 +599,7 @@ export async function startCastAndSets(projectId, { providerId, model, effort, p
}
/**
- * Regenerate with notes. `notes` default to the open notes on the stage's
+ * Regenerate, with notes or without. `notes` default to the open notes on the stage's
* sheet. A note aimed at an image (`character`, `looks`, `set:<id>`,
* `test:<n>`, …) re-renders that image and what depends on it; any other
* note revises the direction, and only images whose prompt changed re-render.
@@ -610,7 +613,6 @@ export async function regenerateCastAndSets(projectId, { notes = null, providerI
const reviewNotes = (project.productionReview?.feedback || []).filter(n => n.stage === 'art' && !n.resolvedAt)
.map(n => ({ target: `production-review:${n.target}`, text: n.text }));
const source = [...(Array.isArray(notes) ? notes : (artifact?.notes || []).filter((n) => !n.resolvedAt)), ...reviewNotes];
- if (!source.length) throw new ServerError('Add a note first — nothing says what to change', { status: 422, code: 'CAST_SETS_NO_NOTES' });
const imageNotes = {};
const directionNotes = [];
for (const note of source) {
@@ -630,7 +632,9 @@ export async function regenerateCastAndSets(projectId, { notes = null, providerI
});
console.log(`🎭 Music Video Cast & Sets ${short(projectId)} regenerating r${out.stage.revision} (${source.length} note(s)${redirect ? ', new direction' : ''})`);
publish(projectId, out.project);
- const forceKeys = Object.keys(imageNotes);
+ // With no notes the director asks for another take: every image re-renders
+ // from the current direction.
+ const forceKeys = source.length ? Object.keys(imageNotes) : Object.keys(stage.plan || {});
inBackground('The regeneration', projectId, () => (redirect
? runDirection(projectId, { providerId, model, effort, notes: directionNotes, forceKeys })
: writePlan(projectId, { forceKeys })));
diff --git a/server/services/musicVideo/castAndSetsService.test.js b/server/services/musicVideo/castAndSetsService.test.js
index 144cde824a..b0d7244548 100644
--- a/server/services/musicVideo/castAndSetsService.test.js
+++ b/server/services/musicVideo/castAndSetsService.test.js
@@ -371,6 +371,59 @@ describe('Cast & Sets check-in', () => {
]);
});
+ it('seeds the empty art-direction draft and guide on approval without overwriting typed text', async () => {
+ const project = await seed();
+ await request(app).post(`/api/music-video/${project.id}/cast-and-sets`).send({});
+ await runTo(project.id, 'review');
+ await projects.mutateProjectRecord(project.id, (c) => ({ project: { ...c, productionReview: { draft: { cast: 'My own cast notes', environments: ' ' } } } }));
+
+ const approved = await request(app).post(`/api/music-video/${project.id}/cast-and-sets/approve`).send({});
+ expect(approved.status).toBe(200);
+ const done = await current(project.id);
+ const draft = done.productionReview.draft;
+ expect(draft.cast).toBe('My own cast notes');
+ expect(draft.environments).toContain('Lamp room');
+ expect(draft.visualLanguage).toBeTruthy();
+ expect(draft.motionLanguage).toBeTruthy();
+ expect(draft.guideArtifactId).toBe(done.castAndSets.artifactId);
+ // Seeding is editable content only: no approval is recorded.
+ expect(done.productionReview.approvals?.art).toBeUndefined();
+ });
+
+ it.each(['approved', 'skipped'])('rebuilds a %s check-in as a new revision that keeps the prior sheet as an earlier version', async (end) => {
+ const project = await seed();
+ await request(app).post(`/api/music-video/${project.id}/cast-and-sets`).send({});
+ await runTo(project.id, 'review');
+ const first = await current(project.id);
+ const artifactId = first.castAndSets.artifactId;
+ const finish = await request(app).post(`/api/music-video/${project.id}/cast-and-sets/${end === 'approved' ? 'approve' : 'skip'}`).send({});
+ expect(finish.body.stage.status).toBe(end);
+
+ const rebuilt = await request(app).post(`/api/music-video/${project.id}/cast-and-sets`).send({});
+ expect(rebuilt.status).toBe(202);
+ expect(rebuilt.body.stage).toMatchObject({ status: 'directing', revision: 2 });
+ await runTo(project.id, 'review');
+ const after = await current(project.id);
+ expect(after.castAndSets.status).toBe('review');
+ expect(after.castAndSets.artifactId).toBe(artifactId);
+ expect(after.devArtifacts.find((a) => a.id === artifactId).version).toBe(2);
+ // A sheet awaiting review still points the director at Regenerate.
+ const again = await request(app).post(`/api/music-video/${project.id}/cast-and-sets`).send({});
+ expect(again.status).toBe(409);
+ });
+
+ it('regenerates without notes by re-rendering every image', async () => {
+ const project = await seed();
+ await request(app).post(`/api/music-video/${project.id}/cast-and-sets`).send({});
+ await runTo(project.id, 'review');
+ const before = jobs.length;
+ const regen = await request(app).post(`/api/music-video/${project.id}/cast-and-sets/regenerate`).send({});
+ expect(regen.status).toBe(202);
+ await runTo(project.id, 'review');
+ expect(new Set(jobs.slice(before).map(keyOf))).toEqual(new Set(Object.keys((await current(project.id)).castAndSets.plan)));
+ expect((await current(project.id)).castAndSets.revision).toBe(2);
+ });
+
it('regenerates only the images a note touches (and what depends on them) as a new sheet version', async () => {
const project = await seed();
await request(app).post(`/api/music-video/${project.id}/cast-and-sets`).send({});
diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.js
index 8225cfd68e..5c5daa666b 100644
--- a/server/services/musicVideo/productionReview.js
+++ b/server/services/musicVideo/productionReview.js
@@ -38,6 +38,28 @@ function hasProofEvidence(review) {
return (review.method == null || review.method === 'playback') && review.watchedWithAudio === true;
}
+const describeDirection = value => typeof value === 'string' ? value : JSON.stringify(value || {}, null, 2);
+
+/**
+ * Seed the empty art-direction draft fields (and the visual guide) from a
+ * Cast & Sets sheet. Text the director already typed — and a guide already
+ * chosen — is never overwritten, and a document-shot draft is left alone.
+ * Seeding supplies editable content only; it never records an approval.
+ */
+export function seedArtDraft(project, stage = project.castAndSets) {
+ const prior = project.productionReview?.draft || {};
+ if (prior.storyboardSource === 'document' || !stage?.direction) return project;
+ const d = stage.direction;
+ const keep = (key, fallback) => text(prior[key]) ? prior[key] : fallback;
+ const draft = { lyricsMode: 'vocal', timingStatus: 'provisional', timingNotes: '', storyboard: [], ...prior,
+ cast: keep('cast', describeDirection(d.protagonist)),
+ environments: keep('environments', describeDirection(d.sets)),
+ visualLanguage: keep('visualLanguage', describeDirection({ look: d.look, palette: d.protagonist?.palette, world: d.world })),
+ motionLanguage: keep('motionLanguage', describeDirection({ movement: d.protagonist?.movement, camera: d.world?.camera, transitions: d.world?.transitions })),
+ guideArtifactId: prior.guideArtifactId || (artifact(project, stage.artifactId) ? stage.artifactId : null) };
+ return { ...project, productionReview: { ...project.productionReview, draft } };
+}
+
export function productionReviewBasis(project) {
const draft = project.productionReview?.draft || {};
const art = hash({ projectId: project.id, mediaMode: project.mediaMode, authoringRenderer: project.composition?.authoringRenderer, mode: project.composition?.mode, policy: project.productionPolicy,
diff --git a/server/services/musicVideo/productionReviewService.js b/server/services/musicVideo/productionReviewService.js
index 57af85859f..fb81342e12 100644
--- a/server/services/musicVideo/productionReviewService.js
+++ b/server/services/musicVideo/productionReviewService.js
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
import { ServerError } from '../../lib/errorHandler.js';
import { getProject, mutateProjectRecord } from './projects.js';
import { musicVideoEvents } from './events.js';
-import { productionReadiness, productionReviewBasis, productionAlignmentBasis, documentStoryboardBasis, approveProductionStage, assertProductionApproval, recordProductionFeedback, resolveProductionFeedback } from './productionReview.js';
+import { productionReadiness, seedArtDraft, productionReviewBasis, productionAlignmentBasis, documentStoryboardBasis, approveProductionStage, assertProductionApproval, recordProductionFeedback, resolveProductionFeedback } from './productionReview.js';
const reviewProcessId = randomUUID();
@@ -188,20 +188,9 @@ export async function prepareProductionReview(id, options = {}) {
await approveCastAndSets(id);
project = await requireProject(id);
}
- const d = stage?.direction || {};
- const describe = value => typeof value === 'string' ? value : JSON.stringify(value || {}, null, 2);
// Merge against the latest draft while holding the write lock: a guide job
// may finish while the operator is editing its text.
- await mutateProjectRecord(id, current => {
- if (current.productionReview?.draft?.storyboardSource === 'document') return { project: current };
- const prior = current.productionReview?.draft || {};
- const draft = { lyricsMode: 'vocal', timingStatus: 'provisional', timingNotes: '', storyboard: [], ...prior,
- cast: prior.cast || describe(d.protagonist), environments: prior.environments || describe(d.sets),
- visualLanguage: prior.visualLanguage || describe({ look: d.look, palette: d.protagonist?.palette, world: d.world }),
- motionLanguage: prior.motionLanguage || describe({ movement: d.protagonist?.movement, camera: d.world?.camera, transitions: d.world?.transitions }),
- guideArtifactId: prior.guideArtifactId || stage?.artifactId };
- return { project: { ...current, productionReview: { ...current.productionReview, draft } } };
- });
+ await mutateProjectRecord(id, current => ({ project: seedArtDraft(current, stage) }));
project = await requireProject(id);
if (project.productionReview?.draft?.storyboardSource === 'document' || !productionReadiness(project).art.approved) return present(project);
if (!project.scenes?.length) {