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
Keep storyboard rows in step with split, re-planned and cut shots (#11498)
[._.]/0c90773aced2
diff --git a/client/src/hooks/useMusicVideoProductionReview.js b/client/src/hooks/useMusicVideoProductionReview.jsindex c10733adc8..ef0269f6e2 100644--- a/client/src/hooks/useMusicVideoProductionReview.js+++ b/client/src/hooks/useMusicVideoProductionReview.js@@ -1,7 +1,7 @@import { useEffect, useRef, useState } from 'react';import { checkMusicVideoOverlayText, reverifyMusicVideoAlignment, importMusicVideoDocumentShots, getMusicVideoProductionReview, saveMusicVideoProductionDraft, prepareMusicVideoProductionReview,approveMusicVideoProductionReview, lockMusicVideoShots, renderMusicVideoProductionProof, musicVideoExcerptRenderEventsUrl,- cancelMusicVideoExcerptRender, importMusicVideoProductionPlanning, bindMusicVideoProductionShot, addMusicVideoProductionFeedback, resolveMusicVideoProductionFeedback, syncMusicVideoLyricAnchors, reviseMusicVideoProductionFromFeedback, revertMusicVideoProductionInput } from '../services/apiMusicVideo.js';+ cancelMusicVideoExcerptRender, importMusicVideoProductionPlanning, bindMusicVideoProductionShot, addMusicVideoProductionFeedback, resolveMusicVideoProductionFeedback, syncMusicVideoLyricAnchors, removeMusicVideoStaleStoryboardRows, reviseMusicVideoProductionFromFeedback, revertMusicVideoProductionInput } from '../services/apiMusicVideo.js';import useSseJobSlot from './useSseJobSlot.js';/**@@ -65,6 +65,8 @@ export default function useMusicVideoProductionReview({ project, replaceProjectresolveFeedback: (feedbackId, resolution) => call(() => resolveMusicVideoProductionFeedback(project.id, { feedbackId, resolution }, { silent: true })),// Anchor the flagged shots (or `sceneIds`) to the lyric lines sung over them.syncLyricAnchors: sceneIds => call(() => syncMusicVideoLyricAnchors(project.id, sceneIds ? { sceneIds } : {}, { silent: true })),+ // Drop the storyboard rows left from deleted shots.+ removeStaleRows: () => call(() => removeMusicVideoStaleStoryboardRows(project.id, { silent: true })),revise: stage => call(() => reviseMusicVideoProductionFromFeedback(project.id, { stage }, { silent: true })),revert: (stage, field) => call(() => revertMusicVideoProductionInput(project.id, { stage, field }, { silent: true })),importDocumentShots: body => call(() => importMusicVideoDocumentShots(project.id, body, { silent: true })),diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.jsindex e7f0aa6329..f977c8d27f 100644--- a/client/src/lib/musicVideoStages.js+++ b/client/src/lib/musicVideoStages.js@@ -777,9 +777,10 @@ const STORYBOARD_PROBLEM_GROUPS = [function storyboardProblemItems(readiness, scenes = []) {// Shots whose lyric anchors differ from the singing get a row of their own that names each shot.const anchors = lyricAnchorItem(readiness, scenes);+ const stale = staleRowsItem(readiness);const problems = summarizeStoryboardProblems(readiness?.storyboard?.problems?.filter(notFeedback)- .filter((text) => !anchors || !ANCHOR_PROBLEM.test(text)));- if (readiness?.storyboard?.approved || (!problems.length && !anchors)) return [];+ .filter((text) => (!anchors || !ANCHOR_PROBLEM.test(text)) && (!stale || !STALE_ROWS_PROBLEM.test(text))));+ if (readiness?.storyboard?.approved || (!problems.length && !anchors && !stale)) return [];return [...STORYBOARD_PROBLEM_GROUPS.flatMap((group, index) => {const earlier = STORYBOARD_PROBLEM_GROUPS.slice(0, index);const mine = problems.filter((text) => group.test.test(text) && !earlier.some((g) => g.test.test(text)));@@ -788,10 +789,31 @@ function storyboardProblemItems(readiness, scenes = []) {const stale = group.id === 'art' && staleApprovalText(readiness?.art?.stale);const details = stale ? mine.map((text) => (ART_APPROVAL_PROBLEM.test(text) ? `${stale} Approve it again on the Look step.` : text)) : mine;return [{ id: `board-${group.id}`, label: group.label, done: false, details, action: group.action }];- }), ...(anchors ? [anchors] : [])];+ }), ...(stale ? [stale] : []), ...(anchors ? [anchors] : [])];}const ANCHOR_PROBLEM = /^Review lyric anchors for /;+const STALE_ROWS_PROBLEM = /left from deleted shots\.$/;+const ROW_ACTION_CHARS = 60;++/**+ * Storyboard rows left from shots that were cut: each by its old time span and+ * action (the shot is gone, so there is no card to open), and one button that+ * removes them all.+ */+function staleRowsItem(readiness) {+ const rows = readiness?.storyboard?.staleRows;+ if (!rows?.length || readiness?.storyboard?.approved) return null;+ const span = (row) => (Number.isFinite(row.startSec) && Number.isFinite(row.endSec)+ ? `${formatTimecode(row.startSec)}–${formatTimecode(row.endSec)}` : 'Untimed');+ const action = (text) => (text.length > ROW_ACTION_CHARS ? `${text.slice(0, ROW_ACTION_CHARS).trimEnd()}…` : text);+ return {+ id: 'board-stale-rows', label: 'Rows from deleted shots', done: false,+ detail: `${rows.length === 1 ? 'This storyboard row belongs' : 'These storyboard rows belong'} to a shot that was cut.`,+ details: [...new Set(rows.map((row) => (row.action ? `${span(row)} · ${action(row.action)}` : span(row))))],+ action: { label: rows.length === 1 ? 'Remove it' : `Remove all ${rows.length}`, run: 'remove-stale-rows' },+ };+}const ART_APPROVAL_PROBLEM = /^Review and approve the current art direction/;const quoted = (lines) => (lines.length ? lines.map((line) => `“${line}”`).join(' / ') : 'nothing');diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 3c185b8ce9..28cc4e342d 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -1190,6 +1190,7 @@ export default function MusicVideo() {if (action.run === 'revise-feedback') { reviseFromFeedback(action.stage); return; }if (action.run === 'keep-approval') { keepApproval(action.stage); return; }if (action.run === 'sync-lyric-anchors') { productionReview.syncLyricAnchors(); return; }+ if (action.run === 'remove-stale-rows') { productionReview.removeStaleRows(); return; }if (action.editShot) { editShot(action.editShot); return; }goToStage(action.stage || activeStage, action.anchor, action.params);};diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsxindex b76a872cd1..8a1a9f88c6 100644--- a/client/src/pages/MusicVideo.test.jsx+++ b/client/src/pages/MusicVideo.test.jsx@@ -38,7 +38,7 @@ const { sseState, ytSseStates, getYtSseState } = vi.hoisted(() => {// This page suite exercises existing controls with production approvals already granted.// ProductionReviewPanel and route integration suites exercise the real approval refusals.-const feedbackCalls = vi.hoisted(() => ({ resolveFeedback: vi.fn(async () => null), syncLyricAnchors: vi.fn(async () => null), revise: vi.fn(async () => ({ revision: { sceneIds: ['s-a'] } })) }));+const feedbackCalls = vi.hoisted(() => ({ resolveFeedback: vi.fn(async () => null), syncLyricAnchors: vi.fn(async () => null), removeStaleRows: vi.fn(async () => null), revise: vi.fn(async () => ({ revision: { sceneIds: ['s-a'] } })) }));vi.mock('../hooks/useMusicVideoProductionReview.js', () => ({ default: ({ project }) => ({...feedbackCalls,readiness: project?.productionReadiness || { readyForProduction: true, basis: {}, art: { approved: true, problems: [] }, storyboard: { approved: true, problems: [] }, proof: { approved: true, problems: [] } },@@ -3436,6 +3436,24 @@ describe('stage checklist and project options', () => {await waitFor(() => expect(document.getElementById('scene-s-b')).toBeTruthy());});+ // Uniquely catches a row left from a cut shot holding the board with no way to clear it from the checklist.+ it('lists the storyboard rows left from deleted shots by time and action, and removes them in one tap', async () => {+ const project = { ...PROJECT_ANALYZED, scenes: [{ sceneId: 's-a', label: 'Drummer', startSec: 0, endSec: 4 }],+ productionReview: { draft: { storyboard: [] } },+ productionReadiness: { readyForProduction: false, basis: {}, art: { approved: true, problems: [] },+ storyboard: { approved: false, problems: ['Remove 2 storyboard rows left from deleted shots.'],+ staleRows: [{ id: null, sceneId: 'gone-1', startSec: 62.5, endSec: 64.25, action: 'A figure skids across the floor' },+ { id: null, sceneId: 'gone-2', startSec: 70, endSec: 71, action: '' }] }, proof: { approved: false, problems: [] } } };+ await openProject(project, 'board');+ const checklist = screen.getByRole('region', { name: 'What this step needs' });+ expect(checklist).toHaveTextContent('Rows from deleted shots');+ expect(checklist).toHaveTextContent('1:02.50–1:04.25 · A figure skids across the floor');+ expect(checklist).toHaveTextContent('1:10.00–1:11.00');+ expect(checklist).not.toHaveTextContent('Remove 2 storyboard rows');+ fireEvent.click(within(checklist).getByRole('button', { name: /Remove all 2/ }));+ expect(feedbackCalls.removeStaleRows).toHaveBeenCalledWith();+ });+it('builds the cast & sets from the Look checklist when nothing is written yet', async () => {const project = { ...PROJECT_ANALYZED, scenes: [], castAndSets: undefined, devArtifacts: [],productionReadiness: { readyForProduction: false, basis: {}, art: { approved: false, problems: ['Cast guide needs editable direction.'] },diff --git a/client/src/services/apiMusicVideo.js b/client/src/services/apiMusicVideo.jsindex f51f211ce2..c46594bad0 100644--- a/client/src/services/apiMusicVideo.js+++ b/client/src/services/apiMusicVideo.js@@ -596,6 +596,8 @@ export const addMusicVideoProductionFeedback = (id, body, options = {}) => requeexport const revertMusicVideoProductionInput = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/revert`, { method: 'POST', body: JSON.stringify(body), ...options });export const reviseMusicVideoProductionFromFeedback = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/revise`, { method: 'POST', body: JSON.stringify(body), ...options });export const syncMusicVideoLyricAnchors = (id, body = {}, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/lyric-anchors`, { method: 'POST', body: JSON.stringify(body), ...options });+// Remove the storyboard rows left from deleted shots.+export const removeMusicVideoStaleStoryboardRows = (id, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/stale-rows`, { method: 'DELETE', ...options });export const resolveMusicVideoProductionFeedback = (id, body, options = {}) => request(`/music-video/${encodeURIComponent(id)}/production-review/feedback/resolve`, { method: 'POST', body: JSON.stringify(body), ...options });// Drafting is free; generation and candidate selection are separate explicit actions.export const saveMusicVideoSongRevision = (id, fields, options = {}) => request(`/music-video/${encodeURIComponent(id)}/song-revision`, { method: 'POST', body: JSON.stringify(fields), ...options });diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.jsindex 8afbc68757..845c25b1bb 100644--- a/server/routes/musicVideo.js+++ b/server/routes/musicVideo.js@@ -15,7 +15,7 @@ import { Router } from 'express';import { musicVideoSongStyleSunoSchema, musicVideoProjectListQuerySchema, musicVideoFinishedOutsideSchema, musicVideoProductionDraftSchema, musicVideoProductionApprovalSchema, musicVideoShotLockSchema, musicVideoProductionProofSchema, musicVideoProductionImportSchema, musicVideoContinueShotSchema, musicVideoPoolUseSchema, musicVideoPoolMarkSchema, musicVideoPoolSearchQuerySchema, musicVideoPoolDeleteSchema, musicVideoProductionFeedbackSchema, musicVideoProductionFeedbackResolutionSchema, musicVideoLyricAnchorSyncSchema, musicVideoProductionReviseSchema, musicVideoProductionRevertSchema } from '../lib/musicVideoValidation.js';import { productionReadiness } from '../services/musicVideo/productionReview.js';import { finishedOutsideBlocker } from '../lib/musicVideoFinishedOutside.js';-import { getProductionReview, saveProductionDraft, prepareProductionReview, approveProductionReview, lockProductionShots, renderProductionProof, requireProductionReviewer, importProductionPlanning, bindProductionShot, addProductionFeedback, closeProductionFeedback, syncLyricAnchors, reviseProductionFromFeedback, revertProductionInput } from '../services/musicVideo/productionReviewService.js';+import { getProductionReview, saveProductionDraft, prepareProductionReview, approveProductionReview, lockProductionShots, renderProductionProof, requireProductionReviewer, importProductionPlanning, bindProductionShot, addProductionFeedback, closeProductionFeedback, syncLyricAnchors, removeStaleStoryboardRows, reviseProductionFromFeedback, revertProductionInput } from '../services/musicVideo/productionReviewService.js';import { asyncHandler, ServerError } from '../lib/errorHandler.js';import {validateRequest,@@ -735,6 +735,9 @@ router.post('/:id/production-review/feedback/resolve', asyncHandler(async (req,router.post('/:id/production-review/lyric-anchors', asyncHandler(async (req, res) => {res.json(await syncLyricAnchors(req.params.id, validateRequest(musicVideoLyricAnchorSyncSchema, req.body ?? {})));}));+router.delete('/:id/production-review/stale-rows', asyncHandler(async (req, res) => {+ res.json(await removeStaleStoryboardRows(req.params.id));+}));// An explicit click: the only provider call is the stage's own revision.router.post('/:id/production-review/revise', asyncHandler(async (req, res) => {res.json(await reviseProductionFromFeedback(req.params.id, validateRequest(musicVideoProductionReviseSchema, req.body ?? {})));diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.jsindex bda02178ef..9de3514a9d 100644--- a/server/services/musicVideo/productionReview.js+++ b/server/services/musicVideo/productionReview.js@@ -562,6 +562,23 @@ export function boardStoryboard(project, storyboard = project.productionReview?..map(scene => boardShotFromScene(project, scene))];}+/** Draft rows still bound to a Board scene that no longer exists: leftovers from a cut, merge or re-plan. */+function staleStoryboardRows(project) {+ const draft = project.productionReview?.draft;+ if (!Array.isArray(draft?.storyboard) || draft.storyboardSource === 'document') return [];+ const ids = new Set((project.scenes || []).map(scene => scene.sceneId));+ return draft.storyboard.filter(shot => shot?.sceneId && !ids.has(shot.sceneId));+}++/** The project without its stale draft rows; unchanged when there are none. Unbound rows stay to be bound. */+export function dropStaleStoryboardRows(project) {+ const stale = staleStoryboardRows(project);+ if (!stale.length) return project;+ const draft = project.productionReview.draft;+ return { ...project, productionReview: { ...project.productionReview,+ draft: { ...draft, storyboard: draft.storyboard.filter(shot => !stale.includes(shot)) } } };+}+/*** Re-anchor the storyboard rows of `sceneIds` (every shot when null) to the* lyric lines sung over their scenes now, keeping each row's span in step with@@ -623,6 +640,9 @@ export function productionReadiness(project) {}}const documentShots = draft.storyboardSource === 'document';+ // Each row left from a deleted shot, by its span and action, so the checklist can name it and remove them all.+ const staleRows = documentShots ? [] : staleStoryboardRows(project)+ .map(shot => ({ id: shot.id || null, sceneId: shot.sceneId, startSec: shot.startSec ?? null, endSec: shot.endSec ?? null, action: shot.action || '' }));const scenes = documentShots ? (draft.storyboard || []).map(shot => ({ ...shot, sceneId: shot.id, label: shot.id })) : project.scenes || [];if (documentShots) {if (project.composition?.mode !== 'document' || !project.composition.document?.directory@@ -631,7 +651,8 @@ export function productionReadiness(project) {}if (new Set(scenes.map(s => s.id)).size !== scenes.length || scenes.some(s => !text(s.id))) boardProblems.push('Document shots need unique source IDs.');} else {- if (draft.storyboard?.some(shot => !shot.sceneId || !scenes.some(s => s.sceneId === shot.sceneId))) boardProblems.push('Bind every draft shot to a real Board scene.');+ if (draft.storyboard?.some(shot => !shot.sceneId)) boardProblems.push('Bind every draft shot to a real Board scene.');+ if (staleRows.length) boardProblems.push(`Remove ${staleRows.length} storyboard row${staleRows.length === 1 ? '' : 's'} left from deleted shots.`);if (new Set((draft.storyboard || []).map(s => s.sceneId)).size !== draft.storyboard?.length) boardProblems.push('Each storyboard shot must bind to its own Board scene.');}if (!scenes.length) boardProblems.push('Create a timed shot storyboard.');@@ -677,7 +698,7 @@ export function productionReadiness(project) {// The overlay text check is advice on the storyboard, like camera variety; it never blocks approval.storyboard: { approved: storyboardApproved, problems: [...new Set(boardProblems)], camera,// Board shots as reviewed, derived rows included, so the editor and approval card show what the gate checked.- shots: documentShots ? null : boardStoryboard(project), lyricAnchors, text: overlayTextReport(project, overlayTextBasis), stale: storyboardApproved ? null : staleApproval(project, 'storyboard', basis.storyboard, inputs),+ shots: documentShots ? null : boardStoryboard(project), lyricAnchors, staleRows, text: overlayTextReport(project, overlayTextBasis), stale: storyboardApproved ? null : staleApproval(project, 'storyboard', basis.storyboard, inputs),shotLocks: locks, unlocked: byShot ? unlocked : [], clipLocks: clips,// Video shots whose clip is not locked yet: the board is finished when every shot is fully locked.clipsUnlocked: clips ? Object.keys(clips).filter(id => clips[id] && clips[id] !== 'locked') : [] },diff --git a/server/services/musicVideo/productionReview.storyboard.test.js b/server/services/musicVideo/productionReview.storyboard.test.jsindex 6f457a6288..92b8d4ec8d 100644--- a/server/services/musicVideo/productionReview.storyboard.test.js+++ b/server/services/musicVideo/productionReview.storyboard.test.js@@ -1,6 +1,6 @@import { describe, it, expect } from 'vitest';-import { anchorShotsToSungLyrics, productionReadiness, productionAlignmentBasis, approveProductionStage, carryProductionApprovals, carryShotLocks, assertShotApproval, assertClipUnlocked, setShotLocks } from './productionReview.js';-import { addScenes, applySceneUpdate, mergeNextScene, removeScene } from './projectsLogic.js';+import { anchorShotsToSungLyrics, dropStaleStoryboardRows, productionReadiness, productionAlignmentBasis, approveProductionStage, carryProductionApprovals, carryShotLocks, assertShotApproval, assertClipUnlocked, setShotLocks } from './productionReview.js';+import { addScenes, applySceneUpdate, mergeNextScene, removeScene, replaceScenes, splitScene } from './projectsLogic.js';const WORD_PROBLEM = /bounded, positive-duration word timings/;const SHOT_PROBLEM = /^Complete timing, action, staging, camera and transition/;@@ -268,3 +268,39 @@ describe('lyric anchors follow the singing', () => {expect(back.productionReview.draft.storyboard.find((shot) => shot.sceneId === 's2').lyricCueIds).toEqual([]);});});++describe('storyboard rows stay bound to the shots on the board', () => {+ const row = (sceneId, extra = {}) => ({ sceneId, lyricCueIds: [], action: 'Reels spin', staging: 'Wide', camera: 'Locked off', transition: 'Cut', ...extra });++ // Uniquely catches a row left from a cut shot holding the board until someone binds it to a shot that no longer exists.+ it('names rows left from deleted shots and removes them in one go, keeping unbound rows to bind', () => {+ const left = project({ draftShots: [row('s1', { lyricCueIds: ['c1'] }), row('gone', { startSec: 2, endSec: 3.5, action: 'Skid across the floor' }), { ...row(null), id: 'draft-9' }] });+ const { storyboard } = productionReadiness(left);+ expect(storyboard.staleRows).toEqual([{ id: null, sceneId: 'gone', startSec: 2, endSec: 3.5, action: 'Skid across the floor' }]);+ expect(storyboard.problems).toContain('Remove 1 storyboard row left from deleted shots.');+ expect(storyboard.problems).toContain('Bind every draft shot to a real Board scene.');+ const cleaned = dropStaleStoryboardRows(left);+ expect(cleaned.productionReview.draft.storyboard.map((shot) => shot.sceneId)).toEqual(['s1', null]);+ expect(productionReadiness(cleaned).storyboard.staleRows).toEqual([]);+ expect(dropStaleStoryboardRows(cleaned)).toBe(cleaned);+ });++ // Uniquely catches a split leaving its row on the whole old span while the new piece has none.+ it('splits the row with the shot: each piece keeps the direction, anchored to its own lines', () => {+ const board = project({ draftShots: [row('s1', { id: 'r1', startSec: 0, endSec: 4, lyricCueIds: ['c1'] }), row('s2')] });+ const { project: split, scenes: [first, second] } = splitScene(board, 's1', { atSec: 2.5 });+ const rows = split.productionReview.draft.storyboard;+ expect(rows.map((shot) => shot.sceneId)).toEqual([first.sceneId, second.sceneId, 's2']);+ expect(rows[0]).toMatchObject({ id: 'r1', startSec: 0, endSec: 2.5, lyricCueIds: ['c1'], action: 'Reels spin' });+ expect(rows[1]).toMatchObject({ id: `shot-${second.sceneId}`, startSec: 2.5, endSec: 4, lyricCueIds: [], action: 'Reels spin' });+ const { storyboard } = productionReadiness(split);+ expect(storyboard.staleRows).toEqual([]);+ expect(storyboard.problems.filter((p) => ANCHOR_PROBLEM.test(p))).toEqual([]);+ });++ it('drops the rows of shots a re-plan replaces', () => {+ const board = project({ draftShots: [row('s1'), row('s2')] });+ const { project: replanned } = replaceScenes(board, [{ label: 'Verse', startSec: 0, endSec: 4 }, { label: 'New', startSec: 4, endSec: 6, visualIntent: 'x' }, { label: 'Tag', startSec: 6, endSec: 8, visualIntent: 'y' }]);+ expect(replanned.productionReview.draft.storyboard.map((shot) => shot.sceneId)).toEqual(['s1']);+ });+});diff --git a/server/services/musicVideo/productionReviewService.js b/server/services/musicVideo/productionReviewService.jsindex 0d079e1d22..79930d5dd4 100644--- a/server/services/musicVideo/productionReviewService.js+++ b/server/services/musicVideo/productionReviewService.js@@ -3,7 +3,7 @@ import { ServerError } from '../../lib/errorHandler.js';import { getProject, mutateProjectRecord } from './projects.js';import { musicVideoEvents } from './events.js';import { shotCameraLabel } from '../../lib/cameraMovements.js';-import { productionReadiness, boardStoryboard, seedArtDraft, productionReviewBasis, productionAlignmentBasis, documentStoryboardBasis, approveProductionStage, assertProductionApproval, assertShotApproval, assertClipUnlocked, setShotLocks, recordProductionFeedback, resolveProductionFeedback, revertApprovedInput, anchorShotsToSungLyrics, clipLocked } from './productionReview.js';+import { productionReadiness, boardStoryboard, seedArtDraft, productionReviewBasis, productionAlignmentBasis, documentStoryboardBasis, approveProductionStage, assertProductionApproval, assertShotApproval, assertClipUnlocked, setShotLocks, recordProductionFeedback, resolveProductionFeedback, revertApprovedInput, anchorShotsToSungLyrics, clipLocked, dropStaleStoryboardRows, carryStoryboardApproval } from './productionReview.js';import { cuesSungWithin } from '../../lib/musicVideoLyricAnchors.js';const reviewProcessId = randomUUID();@@ -128,11 +128,12 @@ export async function saveProductionDraft(id, draft) {const guard = await validateGuideSelection(await requireProject(id), () => draft.guideArtifactId);const { project } = await mutateProjectRecord(id, current => {guard(current);- return { project: { ...current,+ // An editor copy saved after a shot was cut must not bring that shot's row back.+ return { project: dropStaleStoryboardRows({ ...current,productionReview: { ...current.productionReview, draft,alignmentBasis: draft.timingStatus === 'verified'? (current.productionReview?.draft?.timingStatus !== 'verified' ? productionAlignmentBasis(current) : current.productionReview?.alignmentBasis)- : null } } };+ : null } }) };});return changed(project);}@@ -331,6 +332,16 @@ export async function syncLyricAnchors(id, { sceneIds = null } = {}) {return changed(project);}+/** Remove the storyboard rows left from deleted shots, keeping a current storyboard approval. */+export async function removeStaleStoryboardRows(id) {+ const { project } = await mutateProjectRecord(id, current => {+ const pruned = dropStaleStoryboardRows(current);+ if (pruned === current) return { project: current };+ return { project: carryStoryboardApproval(current, { ...pruned, updatedAt: new Date().toISOString() }, 'Removed rows left from deleted shots') };+ });+ return changed(project);+}+export async function closeProductionFeedback(id, input) {const { project } = await mutateProjectRecord(id, current => ({ project: resolveProductionFeedback(current, input) }));return changed(project);diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.jsindex ec3237aea0..ff9660997b 100644--- a/server/services/musicVideo/projectsLogic.js+++ b/server/services/musicVideo/projectsLogic.js@@ -41,7 +41,7 @@ import { normalizeFilmLook } from '../../lib/filmLook.js';import { normalizeTitleCard } from '../../lib/musicVideoTitleCard.js';import { normalizeStatsOutro } from '../../lib/musicVideoStatsOutro.js';import { remapTreatmentForClone, scenesFingerprint } from './treatment.js';-import { anchorShotsToSungLyrics, carryStoryboardApproval } from './productionReview.js';+import { anchorShotsToSungLyrics, carryStoryboardApproval, dropStaleStoryboardRows } from './productionReview.js';import { cuesSungWithin } from '../../lib/musicVideoLyricAnchors.js';import { normalizeMusicVideoAutomation } from '../../lib/musicVideoAutomation.js';@@ -625,7 +625,8 @@ export function replaceScenes(project, sceneInputs) {...(prior.direction ? { direction: prior.direction } : {}),};});- return { project: touch(project, { scenes }), scenes, replaced: existing.length };+ // Rows bound to shots the new plan dropped go with them.+ return { project: dropStaleStoryboardRows(touch(project, { scenes })), scenes, replaced: existing.length };}// Scene fields a director edits within an approved shot (its span, wording, selected@@ -844,7 +845,21 @@ export function splitScene(project, sceneId, { backend = null, atSec = null } =const nextScenes = [...scenes.slice(0, idx), ...pieces, ...scenes.slice(idx + 1)].map((s, i) => ({ ...s, order: i }));- const next = touch(project, { scenes: nextScenes });+ const extra = { scenes: nextScenes };+ // The shot's storyboard row follows its first piece; each later piece gets a+ // copy of the row's direction, all anchored to the lines sung over them.+ const draft = project.productionReview?.draft;+ const row = Array.isArray(draft?.storyboard) && draft.storyboardSource !== 'document'+ ? draft.storyboard.find((shot) => shot?.sceneId === sceneId) : null;+ if (row) {+ const anchored = (piece) => cuesSungWithin(project.lyricCues, piece.startSec, piece.endSec).map((cue) => cue.id);+ const span = (piece) => ('startSec' in row || 'endSec' in row ? { startSec: piece.startSec, endSec: piece.endSec } : {});+ const rows = pieces.map((piece, i) => ({ ...row, ...(i ? { id: `shot-${piece.sceneId}`, sceneId: piece.sceneId } : {}),+ ...span(piece), lyricCueIds: anchored(piece) }));+ const storyboard = draft.storyboard.flatMap((shot) => (shot === row ? rows : [shot]));+ extra.productionReview = { ...project.productionReview, draft: { ...draft, storyboard } };+ }+ const next = touch(project, extra);return { project: next, scenes: nextScenes.slice(idx, idx + count) };}