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

Add a Lock all button to the Shots page (#11624)

[._.]/9afdb613602d
diff --git a/client/src/components/musicVideo/LockAllShots.jsx b/client/src/components/musicVideo/LockAllShots.jsx
new file mode 100644
index 0000000000..7f6630036f
--- /dev/null
+++ b/client/src/components/musicVideo/LockAllShots.jsx
@@ -0,0 +1,62 @@
+import { useContext, useState } from 'react';
+import { Lock } from 'lucide-react';
+import toast from '../ui/Toast';
+import { ShotLockContext } from './ShotLock.jsx';
+import { sceneMediaKind } from '../../lib/musicVideoSceneAttention.js';
+
+const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
+
+/**
+ * What one Lock all tap would lock: every shot whose still (with its picked
+ * image, or a card/code shot) isn't locked, and every video shot whose picked
+ * clip isn't locked once its still is (already, or in this same tap). Shots
+ * with nothing picked stay open.
+ */
+export function lockAllTargets(scenes, value, { layered = false } = {}) {
+ if (!value?.locks) return { stills: [], videos: [] };
+ const stills = scenes.filter((scene) => value.locks[scene.sceneId] && value.locks[scene.sceneId] !== 'locked'
+ && sceneMediaKind(scene, { layered })).map((scene) => scene.sceneId);
+ const videos = scenes.filter((scene) => {
+ const clip = value.clips?.[scene.sceneId];
+ return clip != null && clip !== 'locked' && scene.videoHistoryId
+ && (value.locks[scene.sceneId] === 'locked' || stills.includes(scene.sceneId));
+ }).map((scene) => scene.sceneId);
+ return { stills, videos };
+}
+
+/**
+ * Locks every shot's picked still and clip in one tap. Locking a video rejects
+ * that shot's unused takes, so the tap opens a confirm that says how many of
+ * each it locks first.
+ */
+export default function LockAllShots({ scenes, layered = false }) {
+ const value = useContext(ShotLockContext);
+ const [open, setOpen] = useState(false);
+ const { stills, videos } = lockAllTargets(scenes, value, { layered });
+ if (!value?.lockAll || (!stills.length && !videos.length)) return null;
+ const what = [stills.length && plural(stills.length, 'still'), videos.length && plural(videos.length, 'video')].filter(Boolean).join(' and ');
+ const run = async () => {
+ setOpen(false);
+ const result = await value.lockAll(stills, videos);
+ if (result) toast.success(`Locked ${what}`);
+ };
+ return (
+ <div className="relative">
+ <button type="button" onClick={() => setOpen((was) => !was)} disabled={value.busy} aria-expanded={open}
+ className="flex min-h-[44px] items-center gap-1 rounded border border-port-border px-2 py-1.5 text-sm disabled:opacity-50 sm:min-h-0">
+ <Lock size={15} aria-hidden="true" /> Lock all
+ </button>
+ {open && (
+ <div role="dialog" aria-label="Lock all shots"
+ className="absolute right-0 top-full z-20 mt-1 w-72 max-w-[calc(100vw-1rem)] space-y-2 rounded border border-port-border bg-port-card p-3 text-sm shadow-lg">
+ <p>Lock {what}?</p>
+ {videos.length > 0 && <p className="text-xs text-port-warning">Locking a video rejects that shot&apos;s unused takes.</p>}
+ <div className="flex justify-end gap-2">
+ <button type="button" onClick={() => setOpen(false)} className="min-h-[44px] rounded border border-port-border px-2 py-1 sm:min-h-0">Cancel</button>
+ <button type="button" onClick={run} className="min-h-[44px] rounded bg-port-accent px-2 py-1 text-white sm:min-h-0">Lock them</button>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/components/musicVideo/ShotLock.jsx b/client/src/components/musicVideo/ShotLock.jsx
index 87072a91b1..014a5e5e90 100644
--- a/client/src/components/musicVideo/ShotLock.jsx
+++ b/client/src/components/musicVideo/ShotLock.jsx
@@ -6,7 +6,8 @@ import { Lock, LockOpen } from 'lucide-react';
* lock — `locked`, `changed` (locked, then edited) or `open`; `clips` maps a
* video shot to its clip's lock the same way (null for a shot with no video
* step: a still, card or code shot locks once). `toggle(sceneId, lock, stage)`
- * locks or unlocks one shot's `still` or `video`. `unlocked` is `unlockedShots`
+ * locks or unlocks one shot's `still` or `video`; `lockAll(stills, videos)` locks
+ * many at once. `unlocked` is `unlockedShots`
* (the shots the Shots checklist counts as not locked yet). Null outside a
* project, or for a document storyboard, which has no per-shot locks.
*/
diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsx
index 6270a408c9..acc2b542ca 100644
--- a/client/src/components/musicVideo/stages/BoardStage.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.jsx
@@ -2,6 +2,7 @@ import { useContext, useEffect, useLayoutEffect, useRef } from 'react';
import { useNavigate, useSearchParams } from 'react-router';
import { Plus, Image as ImageIcon, Film, Code2, Type, FlagTriangleRight, Lock, LockOpen, X } from 'lucide-react';
import ContactSheetButton from '../ContactSheetButton.jsx';
+import LockAllShots from '../LockAllShots.jsx';
import SceneCard from '../SceneCard.jsx';
import EndingCard, { EndingThumbnail } from '../EndingCard.jsx';
import ScenePoster from '../ScenePoster.jsx';
@@ -174,6 +175,7 @@ export default function BoardStage({ board }) {
<div id="mv-scene-board" className="flex items-center justify-between">
<h3 className="text-sm font-medium">Scene board</h3>
<div className="flex items-center gap-2">
+ <LockAllShots scenes={scenes} layered={layered} />
<ContactSheetButton onOpen={board.openContactSheet} />
<button onClick={board.onAddScene} className="flex min-h-[44px] items-center gap-1 rounded bg-port-accent px-2 py-1.5 text-sm text-white sm:min-h-0">
<Plus size={15} /> Add scene
diff --git a/client/src/components/musicVideo/stages/BoardStage.test.jsx b/client/src/components/musicVideo/stages/BoardStage.test.jsx
index 92925aa1b5..2700e5084a 100644
--- a/client/src/components/musicVideo/stages/BoardStage.test.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.test.jsx
@@ -188,3 +188,33 @@ describe('BoardStage ending', () => {
canvas.mockRestore();
});
});
+
+describe('BoardStage Lock all', () => {
+ const scenes = [
+ scene(1),
+ scene(2, { videoHistoryId: null }),
+ scene(3, { referenceImageId: null, videoHistoryId: null }),
+ scene(4),
+ ];
+ const locks = { s1: 'open', s2: 'changed', s3: 'open', s4: 'locked' };
+ const clips = { s1: 'open', s2: 'open', s3: 'open', s4: 'locked' };
+ const renderLockAll = (value) => render(<MemoryRouter><ShotLockContext.Provider value={{ locks, clips, toggle: vi.fn(), ...value }}>
+ <BoardStage board={board(scenes)} /></ShotLockContext.Provider></MemoryRouter>);
+
+ it('says what it locks and that unused takes get rejected, then locks stills before videos', async () => {
+ const lockAll = vi.fn(async () => ({ project: {} }));
+ renderLockAll({ lockAll });
+ fireEvent.click(screen.getByRole('button', { name: 'Lock all' }));
+ // Shot 3 has nothing picked and shot 4 is already locked; shot 2 has a still but no clip.
+ expect(screen.getByText('Lock 2 stills and 1 video?')).toBeTruthy();
+ expect(screen.getByText(/rejects that shot's unused takes/)).toBeTruthy();
+ expect(lockAll).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('button', { name: 'Lock them' }));
+ await waitFor(() => expect(lockAll).toHaveBeenCalledWith(['s1', 's2'], ['s1']));
+ });
+
+ it('hides when every picked still and clip is locked', () => {
+ renderLockAll({ lockAll: vi.fn(), locks: { ...locks, s1: 'locked', s2: 'locked' }, clips: { ...clips, s1: 'locked' } });
+ expect(screen.queryByRole('button', { name: 'Lock all' })).toBeNull();
+ });
+});
diff --git a/client/src/hooks/useMusicVideoProductionReview.js b/client/src/hooks/useMusicVideoProductionReview.js
index ef0269f6e2..6c82d05efd 100644
--- a/client/src/hooks/useMusicVideoProductionReview.js
+++ b/client/src/hooks/useMusicVideoProductionReview.js
@@ -82,6 +82,13 @@ export default function useMusicVideoProductionReview({ project, replaceProject
// Lock (or unlock) single shots: a locked shot's clip can be made before the whole board is approved.
// Not silent: the buttons live on scene cards and the player, away from the review panel's error line.
lockShots: (sceneIds, locked, stage = 'still') => call(() => lockMusicVideoShots(project.id, { sceneIds, locked, stage })),
+ // Lock all: the stills first, since a video locks only over a locked still.
+ lockAll: (stills, videos) => call(async () => {
+ let result = null;
+ if (stills.length) result = await lockMusicVideoShots(project.id, { sceneIds: stills, locked: true, stage: 'still' });
+ if (videos.length) result = await lockMusicVideoShots(project.id, { sceneIds: videos, locked: true, stage: 'video' });
+ return result;
+ }),
renderProof: window => proof.start({ id: project.id, window }, project.id),
};
}
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 0f9ff996e1..5a4f89887d 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -312,7 +312,8 @@ export default function MusicVideo() {
const shotLockValue = shotLocks
? { locks: shotLocks, clips: productionReview.readiness.storyboard.clipLocks || null,
unlocked: unlockedShots(productionReview.readiness),
- toggle: (sceneId, lock, stage) => productionReview.lockShots([sceneId], lock, stage), busy: productionReview.busy }
+ toggle: (sceneId, lock, stage) => productionReview.lockShots([sceneId], lock, stage),
+ lockAll: productionReview.lockAll, busy: productionReview.busy }
: null;
// Posting (#9282): fill each platform's post in the PortOS Browser, post on a second press.
const publishing = useMusicVideoPublishing({ project: selected, replaceProject });
diff --git a/scripts/vitestCiPool.js b/scripts/vitestCiPool.js
index 7415b8cb5e..6c3bbf022d 100644
--- a/scripts/vitestCiPool.js
+++ b/scripts/vitestCiPool.js
@@ -40,11 +40,13 @@ export const EXCLUSIVE_CAPTURE_TESTS = [
// Exact SVG-filter screenshots hit the 30s CI budget alongside parallel tests.
'lib/filmLook.browser.test.js',
'lib/filmLookGpu.browser.test.js',
+ 'lib/musicVideoTitleCard.browser.test.js',
'services/htmlComposition/index.test.js',
'services/musicVideo/documentRender.browser.test.js',
'services/musicVideo/documentTemplates/layered/engine.overlay.browser.test.js',
'services/musicVideo/documentTemplates/shared/lyricType.browser.test.js',
'services/musicVideo/documentTemplates/shared/toonWorld.browser.test.js',
+ 'services/musicVideo/overlayTextService.browser.test.js',
'routes/musicVideoProductionReview.browser.test.js',
'routes/musicVideoRichAuthoring.browser.test.js',
];