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

Keep a shot locked when the director swaps its still or edits its prompt (#11267)

[._.]/37f0c9092f5a
diff --git a/server/routes/musicVideoTakes.test.js b/server/routes/musicVideoTakes.test.js
index a3e5ba8607..3f9dcfacb5 100644
--- a/server/routes/musicVideoTakes.test.js
+++ b/server/routes/musicVideoTakes.test.js
@@ -282,6 +282,39 @@ describe('swapping a shot from unused takes', () => {
});
});
+describe('a director\'s still change keeps the shot locked', () => {
+ // Uniquely catches a swapped still or edited prompt leaving the shot "changed since you locked it", so its clip can't render.
+ it('re-binds the still lock on Use, take select and a prompt edit, and drops a clip lock made from the old still', async () => {
+ for (const name of ['a-1.png', 'a-2.png', 'floor.png']) seedImage(name);
+ seedVideoHistory([{ id: 'clip-a1' }]);
+ await addTake(sceneA.sceneId, { kind: 'image', assetId: 'a-1.png', source: 'generated' });
+ const second = await addTake(sceneA.sceneId, { kind: 'image', assetId: 'a-2.png', source: 'generated' });
+ await addTake(sceneA.sceneId, { kind: 'video', assetId: 'clip-a1', source: 'generated', sourceImageId: 'a-1.png' });
+ await addTake(sceneB.sceneId, { kind: 'image', assetId: 'floor.png', source: 'generated' });
+ await request(app).delete(`${base()}/scenes/${sceneB.sceneId}`);
+ const { setShotLocks, shotLocks, clipLocks } = await import('../services/musicVideo/productionReview.js');
+ const lockA = async (stage) => projects.mutateProjectRecord(project.id, (current) => ({ project: setShotLocks(current, { sceneIds: [sceneA.sceneId], locked: true, stage }) }));
+ await lockA('still');
+ const stillLock = async () => shotLocks(await reload())[sceneA.sceneId];
+
+ expect((await request(app).post(`${base()}/scenes/${sceneA.sceneId}/takes/use`).send({ kind: 'image', assetId: 'floor.png' })).status).toBe(200);
+ expect(await stillLock()).toBe('locked');
+ expect((await request(app).post(`${base()}/scenes/${sceneA.sceneId}/takes/${second.body.take.takeId}/select`)).status).toBe(200);
+ expect(await stillLock()).toBe('locked');
+ expect((await request(app).patch(`${base()}/scenes/${sceneA.sceneId}`).send({ prompt: 'Slow push toward the reel' })).status).toBe(200);
+ expect(await stillLock()).toBe('locked');
+
+ // A clip lock made from the old still goes stale with it; a director edit then re-locks the still and drops the clip lock.
+ await lockA('video');
+ await projects.mutateProjectRecord(project.id, (current) => ({ project: { ...current,
+ scenes: current.scenes.map((scene) => scene.sceneId === sceneA.sceneId ? { ...scene, endImageId: 'a-1.png' } : scene) } }));
+ expect(await stillLock()).toBe('changed');
+ expect((await request(app).patch(`${base()}/scenes/${sceneA.sceneId}`).send({ referenceImageId: 'floor.png' })).status).toBe(200);
+ expect(await stillLock()).toBe('locked');
+ expect(clipLocks(await reload())[sceneA.sceneId]).toBe('open');
+ });
+});
+
describe('renders made for a video with no shot', () => {
// Uniquely catches a sheet, test or Video Gen render for the video (no shot keeps it) missing from its collection and the picker.
it('files completed renders naming the video, and clips stamped with it, into its collection', async () => {
diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.js
index 5aa5e55f48..7e7ebee8a5 100644
--- a/server/services/musicVideo/productionReview.js
+++ b/server/services/musicVideo/productionReview.js
@@ -280,6 +280,31 @@ export function carryShotLocks(before, after, { from = {} } = {}) {
return carried ? { ...after, productionReview: { ...after.productionReview, shotApprovals } } : after;
}
+/**
+ * Keep a shot's still lock through the director's own edit to it: picking or
+ * swapping its still or end frame, or editing its prompts, re-binds the lock to
+ * the shot as it now is, so its clip can be rendered without unlocking and
+ * locking again. A lock already stale is re-bound the same way. Automation
+ * never reaches this (preserveAutomatedShotLocks refuses its edits), and a
+ * locked video refuses the edit before it (assertClipUnlocked). A clip lock
+ * that no longer holds is dropped: its clip was made from the old still.
+ */
+export function keepDirectorStillLock(before, after, sceneId) {
+ const lock = shotLocks(before)?.[sceneId];
+ const scene = after.scenes?.find(s => s.sceneId === sceneId);
+ if ((lock !== 'locked' && lock !== 'changed') || !scene) return after;
+ // A whole-board approval this edit stales would open every other shot it covered.
+ const next = carryShotLocks(before, after);
+ if (shotLocks(next)?.[sceneId] === 'locked') return next;
+ const held = next.productionReview?.shotApprovals?.[sceneId]
+ || { ...before.productionReview?.approvals?.storyboard, fromBoardApproval: true };
+ const shotApprovals = { ...next.productionReview?.shotApprovals,
+ [sceneId]: stillLock(next, scene, { ...held, relockedAt: new Date().toISOString() }) };
+ const { [sceneId]: _stale, ...clipApprovals } = next.productionReview?.clipApprovals || {};
+ return { ...next, productionReview: { ...next.productionReview, shotApprovals,
+ ...(next.productionReview?.clipApprovals ? { clipApprovals } : {}) } };
+}
+
/**
* Lock or unlock Board shots for the director. A lock binds to the shot as it is now.
* `stage: 'video'` locks or unlocks a video shot's selected clip, which needs its
diff --git a/server/services/musicVideo/projects.js b/server/services/musicVideo/projects.js
index 5e970e536e..017a7cf5ff 100644
--- a/server/services/musicVideo/projects.js
+++ b/server/services/musicVideo/projects.js
@@ -254,10 +254,11 @@ export async function addProjectScenes(id, sceneInputs, { source = null } = {})
/** Edit against the fresh record so a concurrent video lock cannot be bypassed. */
export async function updateScene(id, sceneId, patch) {
- const [{ applySceneUpdate }, { assertClipUnlocked }] = await Promise.all([import('./projectsLogic.js'), import('./productionReview.js')]);
+ const [{ applySceneUpdate }, { assertClipUnlocked, keepDirectorStillLock }] = await Promise.all([import('./projectsLogic.js'), import('./productionReview.js')]);
const { updated } = await mutateProjectRecord(id, (current) => {
assertClipUnlocked(current, sceneId, patch);
- return applySceneUpdate(current, sceneId, patch);
+ const outcome = applySceneUpdate(current, sceneId, patch);
+ return { ...outcome, project: keepDirectorStillLock(current, outcome.project, sceneId) };
});
return updated;
}
@@ -359,10 +360,11 @@ export async function appendTakesAcrossScenes(id, items) {
/** Explicitly select a take for its scene slot. Returns the updated scene. */
export async function selectSceneTake(id, sceneId, takeId) {
- const [{ selectSceneTake: select }, { assertClipUnlocked }] = await Promise.all([import('./takes.js'), import('./productionReview.js')]);
+ const [{ selectSceneTake: select }, { assertClipUnlocked, keepDirectorStillLock }] = await Promise.all([import('./takes.js'), import('./productionReview.js')]);
const { scene } = await mutateProjectRecord(id, (current) => {
assertClipUnlocked(current, sceneId);
- return select(current, sceneId, takeId);
+ const outcome = select(current, sceneId, takeId);
+ return { ...outcome, project: keepDirectorStillLock(current, outcome.project, sceneId) };
});
return scene;
}
@@ -377,7 +379,7 @@ export async function selectSceneTake(id, sceneId, takeId) {
* Returns the updated scene.
*/
export async function placeMediaPoolItem(id, sceneId, { kind, assetId, withAssetId = null }) {
- const [{ appendSceneTakes: append, selectSceneTake: select }, { assertClipUnlocked }, { projectTakeAssets }] = await Promise.all([
+ const [{ appendSceneTakes: append, selectSceneTake: select }, { assertClipUnlocked, keepDirectorStillLock }, { projectTakeAssets }] = await Promise.all([
import('./takes.js'), import('./productionReview.js'), import('./mediaPool.js'),
]);
const { scene } = await mutateProjectRecord(id, (current) => {
@@ -395,7 +397,7 @@ export async function placeMediaPoolItem(id, sceneId, { kind, assetId, withAsset
: [...(still ? [input('image', still)] : []), ...(clip ? [input('video', clip)] : [])];
let outcome = append(current, sceneId, inputs);
for (const take of outcome.appended) outcome = { ...select(outcome.project, sceneId, take.takeId), appended: outcome.appended };
- return outcome;
+ return { ...outcome, project: keepDirectorStillLock(current, outcome.project, sceneId) };
});
return scene;
}
diff --git a/server/services/musicVideo/projects.test.js b/server/services/musicVideo/projects.test.js
index 8de703e9dd..8d787f68c7 100644
--- a/server/services/musicVideo/projects.test.js
+++ b/server/services/musicVideo/projects.test.js
@@ -259,7 +259,7 @@ describe('automation respects persisted shot locks (#11218)', () => {
await projects.mutateProjectRecord(p.id, current => applySceneUpdate(current, b.sceneId, { prompt: 'Allowed run edit' }), { source: 'orchestrator' });
expect((await projects.getProject(p.id)).scenes[1].prompt).toBe('Allowed run edit');
await projects.updateScene(p.id, a.sceneId, { prompt: 'Director edit' });
- expect(shotLocks(await projects.getProject(p.id))).toEqual({ [a.sceneId]: 'changed', [b.sceneId]: 'open' });
+ expect(shotLocks(await projects.getProject(p.id))).toEqual({ [a.sceneId]: 'locked', [b.sceneId]: 'open' });
});
it('keeps locked storyboard rows and the original board when a planner replaces its IDs', async () => {