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

Bad marks and video locks reject unused takes (#11484)

[._.]/dfbbfbf14f2e
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsx
index 37798027f9..002586eaf3 100644
--- a/client/src/components/musicVideo/SceneCard.jsx
+++ b/client/src/components/musicVideo/SceneCard.jsx
@@ -115,7 +115,7 @@ export default function SceneCard({
settingsSaving, videoBlockedReason, videoBlockedReasonFor = null, canContinueShot,
onMove, onDelete, onEditLocal, onSave,
project = null, onGenerateFrame, onGenerateVideo, onContinueVideo, onGenerateEndFrame, generatingEndFrame = false, onContinueFromPrevious, previousHasClip = false,
- onOpenPreview, onSelectTake, onReviewTake, onRejectUnusedTakes = null, onSwapFrames = null, onMarkTake = null, onImportTake, onImportClipTake, onPlacePoolItem, onTrimClip, projectId = null, aspect = '16:9', videoModels = [], defaultVideoModel = '', shotNumbers = undefined, takeBusy = false, layered = false, documentComposition = false,
+ onOpenPreview, onSelectTake, onReviewTake, onRejectUnusedTakes = null, onSwapFrames = null, onMarkTake = null, onPoolMarked = null, onImportTake, onImportClipTake, onPlacePoolItem, onTrimClip, projectId = null, aspect = '16:9', videoModels = [], defaultVideoModel = '', shotNumbers = undefined, takeBusy = false, layered = false, documentComposition = false,
lipSyncBackend = '', songDurationSec = null, onSplit, onMergeNext, onMoveStart = null, nextEndSec = null, falVideoSettings = null, onSeek, performanceReview = null, onRepairPerformance, repairBusy = false,
expanded, onToggleExpand, stepShot = null, footageOptional = false, failedScenes = null, songReview = null,
}) {
@@ -678,7 +678,8 @@ export default function SceneCard({
</div>
{swapKind && (
<SceneTakePicker open onClose={() => setSwapKind(null)} projectId={projectId} scene={scene} kind={swapKind}
- shotNumbers={shotNumbers} busy={takeBusy} onPlace={(pick) => onPlacePoolItem?.(scene, pick)} />
+ shotNumbers={shotNumbers} busy={takeBusy} onPlace={(pick) => onPlacePoolItem?.(scene, pick)}
+ onMarked={(result) => onPoolMarked?.(projectId, result)} />
)}
</details>
{failure && (
diff --git a/client/src/components/musicVideo/SceneTakePicker.jsx b/client/src/components/musicVideo/SceneTakePicker.jsx
index 40701d7efd..795bcfea9a 100644
--- a/client/src/components/musicVideo/SceneTakePicker.jsx
+++ b/client/src/components/musicVideo/SceneTakePicker.jsx
@@ -66,7 +66,7 @@ export function filterPool(items, { kind, query, shotNumbers }) {
* not placed yet) or ✕ bad, filter by mark, and delete bad ones from the
* media library (the server refuses anything a shot uses).
*/
-export default function SceneTakePicker({ open, onClose, projectId, scene, kind, shotNumbers = new Map(), onPlace, busy = false }) {
+export default function SceneTakePicker({ open, onClose, projectId, scene, kind, shotNumbers = new Map(), onPlace, onMarked = null, busy = false }) {
const [pool, setPool] = useState(null);
const [error, setError] = useState(null);
const [group, setGroup] = useState('shot');
@@ -121,7 +121,9 @@ export default function SceneTakePicker({ open, onClose, projectId, scene, kind,
// Tapping the active mark clears it.
const toggleMark = (mark) => run(async () => {
const next = picked.mark === mark ? null : mark;
- await markMusicVideoPoolAssets(projectId, [{ kind: picked.kind, assetId: picked.assetId }], next, { silent: true });
+ const result = await markMusicVideoPoolAssets(projectId, [{ kind: picked.kind, assetId: picked.assetId }], next, { silent: true });
+ // Bad rejects its takes on the shots not using it; the board shows that at once.
+ onMarked?.(result);
setPool((prev) => prev.map((item) => (poolKey(item) === poolKey(picked) ? { ...item, mark: next } : item)));
setPicked((prev) => ({ ...prev, mark: next }));
});
diff --git a/client/src/components/musicVideo/SceneTakeStrip.jsx b/client/src/components/musicVideo/SceneTakeStrip.jsx
index 567e923885..6b13d20473 100644
--- a/client/src/components/musicVideo/SceneTakeStrip.jsx
+++ b/client/src/components/musicVideo/SceneTakeStrip.jsx
@@ -17,7 +17,8 @@ const KIND_LABEL = { image: 'Frame takes', video: 'Clip takes', endImage: 'End f
*
* Rejecting a take only says it is not for this shot: it stays available to
* other shots in Swap. Bad is a separate mark (`marks`, the project's
- * assetMarks; `onMark(take, 'bad' | null)`) for files to clean up later.
+ * assetMarks; `onMark(take, 'bad' | null)`) for files to clean up later; the
+ * server also rejects a bad file's takes on the shots not using it.
*
* A legacy take (a pre-takes selection the server hasn't materialized yet) is
* shown but has no actions — it has no take id to address. `grid` lays the
@@ -117,7 +118,7 @@ export default function SceneTakeStrip({
{onMark && (
<button type="button" disabled={busy} onClick={() => onMark(take, bad ? null : 'bad')} aria-pressed={bad}
className={`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] min-h-[32px] sm:min-h-0 disabled:opacity-50 ${bad ? 'bg-port-error/20 text-port-error' : 'bg-port-border'}`}
- title={bad ? 'Clear the bad mark' : 'Mark this file bad, to clean up when the project is done. It stays counted in the stats.'}>
+ title={bad ? 'Clear the bad mark' : 'Mark this file bad, to clean up when the project is done. It is also rejected on every shot not using it, and stays counted in the stats.'}>
<Ban size={11} /> Bad
</button>
)}
diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsx
index 6b84ddc5fc..552742d6da 100644
--- a/client/src/components/musicVideo/stages/BoardStage.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.jsx
@@ -242,6 +242,7 @@ export default function BoardStage({ board }) {
onRejectUnusedTakes={takes.rejectUnusedTakes}
onSwapFrames={takes.swapFrames}
onMarkTake={takes.markTake}
+ onPoolMarked={takes.applyPoolMarks}
onContinueFromPrevious={takes.continueFromPrevious}
// The server's own neighbor rule: the shot before this one by start time.
previousHasClip={Boolean(shotHandoffSource(project, previousShot(project, scene.sceneId)))}
diff --git a/client/src/hooks/useMusicVideoTakes.js b/client/src/hooks/useMusicVideoTakes.js
index c491d284f3..a4f4324e36 100644
--- a/client/src/hooks/useMusicVideoTakes.js
+++ b/client/src/hooks/useMusicVideoTakes.js
@@ -116,9 +116,15 @@ export default function useMusicVideoTakes({ project, applyScenePatch, patchProj
);
// Mark a take's file bad (or clear it): a project-wide mark, separate from rejecting it from this shot.
+ // A mark's answer: the project's marks, and the shots whose takes a Bad mark rejected.
+ const applyPoolMarks = (projectId, { assetMarks, scenes = [] } = {}) => {
+ if (assetMarks) patchProject?.(projectId, { assetMarks });
+ for (const scene of scenes) applyScene(projectId, scene);
+ };
+
const markTake = (take, mark) => runTakeOp(
(projectId) => markMusicVideoPoolAssets(projectId, [{ kind: take.kind === 'video' ? 'video' : 'image', assetId: take.assetId }], mark, { silent: true })
- .then(({ assetMarks }) => { patchProject?.(projectId, { assetMarks }); return null; }),
+ .then((result) => { applyPoolMarks(projectId, result); return null; }),
'Failed to mark the take',
);
@@ -210,5 +216,5 @@ export default function useMusicVideoTakes({ project, applyScenePatch, patchProj
if (failures.length) toast.error(failures.slice(0, 3).join(' · '));
};
- return { busy, selectTake, placePoolItem, trimClipTake, reviewTake, rejectUnusedTakes, swapFrames, markTake, continueFromPrevious, importTake, importClipTake, exportHandoff, exportHandoffBundle, importHandoffFiles };
+ return { busy, selectTake, placePoolItem, trimClipTake, reviewTake, rejectUnusedTakes, swapFrames, markTake, applyPoolMarks, continueFromPrevious, importTake, importClipTake, exportHandoff, exportHandoffBundle, importHandoffFiles };
}
diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.js
index 82a63932b9..610ac5caa0 100644
--- a/server/routes/musicVideo.js
+++ b/server/routes/musicVideo.js
@@ -1569,7 +1569,7 @@ router.get('/:id/stats-outro', asyncHandler(async (req, res) => {
// The asset manager: mark unused stills and clips ★ ingredient / ✕ bad, or delete them from the library.
router.patch('/:id/media-pool/marks', asyncHandler(async (req, res) => {
const { items, mark } = validateRequest(musicVideoPoolMarkSchema, req.body);
- res.json({ assetMarks: await markMediaPoolAssets(req.params.id, items.map((item) => `${item.kind}:${item.assetId}`), mark) });
+ res.json(await markMediaPoolAssets(req.params.id, items.map((item) => `${item.kind}:${item.assetId}`), mark));
}));
router.post('/:id/media-pool/delete', asyncHandler(async (req, res) => {
diff --git a/server/routes/musicVideoTakes.test.js b/server/routes/musicVideoTakes.test.js
index e47e78bfca..4001272bf9 100644
--- a/server/routes/musicVideoTakes.test.js
+++ b/server/routes/musicVideoTakes.test.js
@@ -285,6 +285,25 @@ describe('swapping a shot from unused takes', () => {
});
});
+describe('locking a shot\'s video', () => {
+ // Uniquely catches a video lock leaving the shot's other takes as open candidates, or rejecting the ones it uses.
+ it('rejects the shot\'s unused frame and clip takes', async () => {
+ for (const name of ['lock-a.png', 'lock-b.png']) seedImage(name);
+ seedVideoHistory([{ id: 'lock-clip', filename: 'lock-clip.mp4' }, { id: 'lock-other', filename: 'lock-other.mp4' }]);
+ for (const [kind, assetId] of [['image', 'lock-a.png'], ['image', 'lock-b.png'], ['video', 'lock-clip'], ['video', 'lock-other']]) {
+ await addTake(sceneA.sceneId, { kind, assetId, source: 'generated' });
+ }
+ const { setShotLocks } = await import('../services/musicVideo/productionReview.js');
+ const { lockProductionShots } = await import('../services/musicVideo/productionReviewService.js');
+ await projects.mutateProjectRecord(project.id, (current) => ({ project: setShotLocks(current, { sceneIds: [sceneA.sceneId], locked: true, stage: 'still' }) }));
+ await lockProductionShots(project.id, { sceneIds: [sceneA.sceneId], locked: true, stage: 'video' });
+ const scene = (await reload()).scenes.find((s) => s.sceneId === sceneA.sceneId);
+ expect(Object.fromEntries(scene.takes.map((take) => [take.assetId, take.status])))
+ .toEqual({ 'lock-a.png': 'candidate', 'lock-b.png': 'rejected', 'lock-clip': 'candidate', 'lock-other': 'rejected' });
+ expect(scene).toMatchObject({ referenceImageId: 'lock-a.png', videoHistoryId: 'lock-clip' });
+ });
+});
+
describe('a swapped still brings its frame prompt', () => {
// Uniquely catches a still placed from another shot or the floor leaving the start or end prompt describing the old picture, or carrying the look twice.
it('sets the start or end frame prompt to the one the placed still was made from, without the project look', async () => {
@@ -389,6 +408,24 @@ describe('the shot asset manager', () => {
expect((await listed()).mark).toBe('bad');
});
+ // Uniquely catches a Bad mark leaving the file offered as a candidate on shots, or clearing a shot's selection.
+ it('rejects a bad file on every shot not using it, and keeps it where it is in use', async () => {
+ for (const name of ['a-pick.png', 'spare.png']) seedImage(name);
+ await addTake(sceneA.sceneId, { kind: 'image', assetId: 'a-pick.png', source: 'generated' });
+ await addTake(sceneA.sceneId, { kind: 'image', assetId: 'spare.png', source: 'generated' });
+ await addTake(sceneB.sceneId, { kind: 'image', assetId: 'spare.png', source: 'generated' });
+ await addTake(sceneB.sceneId, { kind: 'endImage', assetId: 'a-pick.png', source: 'generated' });
+ const marked = await request(app).patch(`${base()}/media-pool/marks`).send({ items: [{ kind: 'image', assetId: 'spare.png' }, { kind: 'image', assetId: 'a-pick.png' }], mark: 'bad' });
+ expect(marked.status).toBe(200);
+ // Shot A uses a-pick and shot B uses spare (its first take), so only A's spare changes.
+ expect(marked.body.scenes.map((scene) => scene.sceneId)).toEqual([sceneA.sceneId]);
+ const statuses = (scene) => Object.fromEntries(scene.takes.map((take) => [`${take.kind}:${take.assetId}`, take.status]));
+ expect(statuses(marked.body.scenes[0])).toEqual({ 'image:a-pick.png': 'candidate', 'image:spare.png': 'rejected' });
+ const saved = (await reload()).scenes;
+ expect(statuses(saved.find((scene) => scene.sceneId === sceneB.sceneId))).toEqual({ 'image:spare.png': 'candidate', 'endImage:a-pick.png': 'candidate' });
+ expect(saved.find((scene) => scene.sceneId === sceneA.sceneId).referenceImageId).toBe('a-pick.png');
+ });
+
// Uniquely catches a deleted still or clip leaving a take, mark or collection row pointing at a file that is gone, and a shot's own still being deletable.
it('marks unused assets, refuses a shot\'s own, and forgets deleted ones everywhere', async () => {
for (const name of ['keep.png', 'bad.png', 'used.png', 'b-used.png']) seedImage(name);
diff --git a/server/services/musicVideo/mediaPool.js b/server/services/musicVideo/mediaPool.js
index c913c85846..e5be549f23 100644
--- a/server/services/musicVideo/mediaPool.js
+++ b/server/services/musicVideo/mediaPool.js
@@ -55,6 +55,9 @@ export function droppedTakeAssets(before, after) {
* Mark assets ★ ingredient (good, unplaced) or ✕ bad (to clean up); null
* clears the mark. Marks live on the project (`assetMarks`, keyed
* `<image|video>:<ref>`), so a still bad for one video stays fine in another.
+ * Bad also rejects the asset's takes on every shot not using it now; a shot's
+ * selection is never cleared, and clearing the mark leaves the rejects.
+ * `scenes` lists the shots whose takes changed.
*/
export function markPoolAssets(project, keys, mark) {
const assetMarks = { ...(project.assetMarks || {}) };
@@ -62,7 +65,19 @@ export function markPoolAssets(project, keys, mark) {
if (mark) assetMarks[key] = mark;
else delete assetMarks[key];
}
- return { project: { ...project, assetMarks } };
+ if (mark !== 'bad') return { project: { ...project, assetMarks }, scenes: [] };
+ const bad = new Set(keys);
+ const changed = [];
+ const scenes = (project.scenes || []).map((scene) => {
+ if (!Array.isArray(scene.takes)) return scene;
+ const reject = (take) => take?.status !== 'rejected' && bad.has(`${KIND_OF_SLOT[take?.kind]}:${take?.assetId}`)
+ && scene[TAKE_SLOT[take.kind]] !== take.assetId;
+ if (!scene.takes.some(reject)) return scene;
+ const next = { ...scene, takes: scene.takes.map((take) => (reject(take) ? { ...take, status: 'rejected' } : take)) };
+ changed.push(next);
+ return next;
+ });
+ return { project: { ...project, assetMarks, scenes }, scenes: changed };
}
/**
diff --git a/server/services/musicVideo/productionReviewService.js b/server/services/musicVideo/productionReviewService.js
index 2c0a086f67..0d079e1d22 100644
--- a/server/services/musicVideo/productionReviewService.js
+++ b/server/services/musicVideo/productionReviewService.js
@@ -158,8 +158,14 @@ export async function revertProductionInput(id, input) {
}
/** Lock or unlock Board shots for an authenticated reviewer, under the project write lock. */
+// Locking a shot's video finalizes it: its other frame and clip takes are rejected, as Reject unused does.
export async function lockProductionShots(id, input) {
- const { project } = await mutateProjectRecord(id, current => ({ project: setShotLocks(current, input) }));
+ const { rejectUnusedTakes } = await import('./takes.js');
+ const { project } = await mutateProjectRecord(id, current => {
+ const locked = setShotLocks(current, input);
+ if (input.stage !== 'video' || !input.locked) return { project: locked };
+ return { project: input.sceneIds.reduce((next, sceneId) => rejectUnusedTakes(next, sceneId).project, locked) };
+ });
return changed(project);
}
diff --git a/server/services/musicVideo/projects.js b/server/services/musicVideo/projects.js
index 03e2a0a26e..4a0c140800 100644
--- a/server/services/musicVideo/projects.js
+++ b/server/services/musicVideo/projects.js
@@ -339,11 +339,14 @@ export async function moveProjectSceneStart(id, sceneId, { startSec }) {
});
}
-/** Mark unused assets ★ ingredient or ✕ bad (null clears); returns the project's marks. */
+/**
+ * Mark assets ★ ingredient or ✕ bad (null clears). Returns the project's marks and
+ * the shots whose takes a bad mark rejected.
+ */
export async function markMediaPoolAssets(id, keys, mark) {
const { markPoolAssets } = await import('./mediaPool.js');
- const { project } = await mutateProjectRecord(id, (current) => markPoolAssets(current, keys, mark));
- return project.assetMarks || {};
+ const { project, scenes } = await mutateProjectRecord(id, (current) => markPoolAssets(current, keys, mark));
+ return { assetMarks: project.assetMarks || {}, scenes };
}
// ---- scene takes (#8965) ----