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

refactor: replace listPreviewSources ordering booleans with leadWith (#12403)

[._.]/ Adam Eivy0d95312d8e9c
diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.js
index e31a10fa89..490626f1cc 100644
--- a/client/src/lib/musicVideoStages.js
+++ b/client/src/lib/musicVideoStages.js
@@ -179,18 +179,17 @@ export function boardJobEstimate(project) {
/**
* Everything the docked preview can play, in the order it picks a default:
* the final render (its resolved `finalVideoSrc`), the composition document,
- * then each finished draft excerpt, newest first (`draftsFirst`, on Final
- * render, puts the drafts before the composition; `storyboardFirst`, on
- * Storyboard, puts the live document, then the animatic, first). While editing the
- * composition (`liveFirst`, the Compose stage) the live document leads so an
- * old final render is not what the user sees by default. A final render whose
+ * then each finished draft excerpt, newest first. `leadWith` picks the
+ * ordering: `"final"` (default) as above; `"drafts"` (Final render stage)
+ * puts the drafts before the composition; `"storyboard"` (Plan and Shots
+ * stages) puts the live document, then the animatic, first. A final render whose
* inputs changed is labelled out of date. Last comes the storyboard animatic —
* the song under each shot's frame or card — so a project with a track and
* shots always has something to watch — and after it the lyric timing
* playthrough once the words are aligned. Each entry has a stable `id` (the
* `?play=` value) and a `label` for the source picker.
*/
-export function listPreviewSources(project, { finalVideoSrc = null, liveFirst = false, draftsFirst = false, storyboardFirst = false } = {}) {
+export function listPreviewSources(project, { finalVideoSrc = null, leadWith = 'final' } = {}) {
const sources = [];
const final = project?.renderHistoryId && finalVideoSrc
? { id: 'final', kind: 'video', label: project.renderDependencyState?.status === 'stale' ? 'Final render (out of date)' : 'Final render', src: finalVideoSrc, startSec: 0, endSec: null }
@@ -204,13 +203,13 @@ export function listPreviewSources(project, { finalVideoSrc = null, liveFirst =
label: `${excerpt.dependencyState?.status === 'stale' ? 'Older draft' : 'Draft'} ${formatTimecode(excerpt.startSec)}–${formatTimecode(excerpt.endSec)} · ${excerpt.id.slice(-6)}`,
}));
// Final render is reviewed by watching its drafts until the final render exists.
- const ordered = liveFirst || storyboardFirst ? [live, final, ...drafts] : draftsFirst ? [final, ...drafts, live] : [final, live, ...drafts];
+ const ordered = leadWith === 'storyboard' ? [live, final, ...drafts] : leadWith === 'drafts' ? [final, ...drafts, live] : [final, live, ...drafts];
sources.push(...ordered.filter(Boolean));
if (projectHasAudio(project) && (project?.scenes || []).length > 0) {
const animatic = { id: 'animatic', kind: 'animatic', label: 'Storyboard animatic' };
// On Storyboard the storyboard itself leads (the live document, else the animatic): a draft
// clip covers only its own range, so most shots could not be played from it.
- if (storyboardFirst) sources.splice(live ? 1 : 0, 0, animatic);
+ if (leadWith === 'storyboard') sources.splice(live ? 1 : 0, 0, animatic);
else sources.push(animatic);
}
// The aligned words over a plain frame, for checking timing before there is any picture.
diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.js
index 7b031b415e..53f9b061c3 100644
--- a/client/src/lib/musicVideoStages.test.js
+++ b/client/src/lib/musicVideoStages.test.js
@@ -379,7 +379,7 @@ describe('listPreviewSources', () => {
expect(ids({ renderHistoryId: 'r1', composition: { mode: 'concat', document: { directory: 'd' } }, excerpts })).toEqual(['excerpt:b', 'excerpt:a']);
// Composing puts the live document ahead of an old final render, and a stale final says so.
const stale = { renderHistoryId: 'r1', renderDependencyState: { status: 'stale' }, composition: { mode: 'document', document: { directory: 'd' } }, excerpts };
- expect(ids(stale, { finalVideoSrc: '/data/videos/final.mp4', liveFirst: true })).toEqual(['document', 'final', 'excerpt:b', 'excerpt:a']);
+ expect(ids(stale, { finalVideoSrc: '/data/videos/final.mp4', leadWith: 'storyboard' })).toEqual(['document', 'final', 'excerpt:b', 'excerpt:a']);
expect(listPreviewSources(stale, { finalVideoSrc: '/data/videos/final.mp4' })[0].label).toBe('Final render (out of date)');
expect(listPreviewSources({ excerpts: [{ id: 'c', status: 'error' }] })).toEqual([]);
expect(listPreviewSources({ excerpts })[0]).toMatchObject({ kind: 'video', src: '/data/videos/b.mp4', startSec: 10, endSec: 20 });
@@ -696,9 +696,9 @@ describe('preview source order on Storyboard', () => {
const drafts = [{ id: 'aaaaaa', status: 'complete', filename: 'a.mp4', startSec: 72, endSec: 95 }];
const board = { trackId: 't1', scenes: [scene()], excerpts: drafts };
expect(listPreviewSources(board).map((s) => s.id)).toEqual(['excerpt:aaaaaa', 'animatic']);
- expect(listPreviewSources(board, { storyboardFirst: true }).map((s) => s.id)).toEqual(['animatic', 'excerpt:aaaaaa']);
+ expect(listPreviewSources(board, { leadWith: 'storyboard' }).map((s) => s.id)).toEqual(['animatic', 'excerpt:aaaaaa']);
const doc = { ...board, composition: { mode: 'document', document: { directory: 'd' } } };
- expect(listPreviewSources(doc, { storyboardFirst: true }).map((s) => s.id)).toEqual(['document', 'animatic', 'excerpt:aaaaaa']);
+ expect(listPreviewSources(doc, { leadWith: 'storyboard' }).map((s) => s.id)).toEqual(['document', 'animatic', 'excerpt:aaaaaa']);
});
});
@@ -706,7 +706,7 @@ describe('preview source order on Final render', () => {
it('puts the drafts ahead of the live composition until a final render exists', () => {
const project = { composition: { mode: 'document', document: { directory: 'd' } }, excerpts: [{ id: 'aaaaaa', status: 'complete', filename: 'a.mp4', startSec: 0, endSec: 5 }] };
expect(listPreviewSources(project).map((s) => s.id)).toEqual(['document', 'excerpt:aaaaaa']);
- expect(listPreviewSources(project, { draftsFirst: true }).map((s) => s.id)).toEqual(['excerpt:aaaaaa', 'document']);
+ expect(listPreviewSources(project, { leadWith: 'drafts' }).map((s) => s.id)).toEqual(['excerpt:aaaaaa', 'document']);
});
});
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 145c0c6d4e..9a4751e5f7 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -1655,7 +1655,7 @@ function ProjectWorkspace({
: { headline: 'Loading status…', tone: 'muted', needsYouStage: null };
const reviewStage = selected ? approvalStageFor(activeStage, selected, productionReview.readiness, productionReview.proof.active) : null;
- const previewSources = selected ? listPreviewSources(selected, { finalVideoSrc: finalVideo.src, draftsFirst: activeStage === 'review', storyboardFirst: activeStage === 'board' || activeStage === 'produce' }) : [];
+ const previewSources = selected ? listPreviewSources(selected, { finalVideoSrc: finalVideo.src, leadWith: activeStage === 'review' ? 'drafts' : (activeStage === 'board' || activeStage === 'produce') ? 'storyboard' : 'final' }) : [];
return (
<>