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
fix: music video preview defaults to the live composition while editing, flags an out-of-date final render, and stops reloading on unrelated saves (#10162)
Adam Eivy961ea8b4a7be
diff --git a/client/src/components/musicVideo/CodeVideoPanel.jsx b/client/src/components/musicVideo/CodeVideoPanel.jsxindex 20cbb91359..c17c6abeb9 100644--- a/client/src/components/musicVideo/CodeVideoPanel.jsx+++ b/client/src/components/musicVideo/CodeVideoPanel.jsx@@ -40,7 +40,7 @@ export default function CodeVideoPanel({ project, audioUrl, onProject, productio.then((next) => { if (active) setDoc(next); }).catch((err) => { if (active) setError(err?.message || 'Could not build the code preview'); });return () => { active = false; };- }, [project.id, project.updatedAt, project.composition?.codeVideo?.generatedAt]);+ }, [project.id, project.composition?.codeVideo?.generatedAt]);const sections = useMemo(() => doc?.song?.sections || doc?.timeline?.sections || [], [doc]);const fps = doc?.fps || 24;diff --git a/client/src/components/musicVideo/CompositionPreviewPlayer.jsx b/client/src/components/musicVideo/CompositionPreviewPlayer.jsxindex e8cac4f00d..29216eed70 100644--- a/client/src/components/musicVideo/CompositionPreviewPlayer.jsx+++ b/client/src/components/musicVideo/CompositionPreviewPlayer.jsx@@ -54,7 +54,9 @@ export default function CompositionPreviewPlayer({ project, audioUrl, seekRequesconst seekState = useRef({ inFlight: false, pending: null, ready: false });const appliedSeek = useRef(null);- const refresh = doc ? `${doc.directory}|${project.updatedAt}` : null;+ // The document's own version (its folder + save time), not the project's+ // `updatedAt`: an unrelated save must not reload a playing preview.+ const refresh = doc ? `${doc.directory}|${doc.updatedAt || ''}` : null;useEffect(() => {let active = true;setPreview(null);diff --git a/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx b/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsxindex a261899501..0e0ba57322 100644--- a/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx+++ b/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx@@ -45,6 +45,18 @@ describe('CompositionPreviewPlayer', () => {expect(screen.queryByText(/Loading preview media/)).not.toBeInTheDocument();});+ it('keeps the loaded preview through an unrelated project save and rebuilds when the document version changes', async () => {+ const { rerender } = render(<CompositionPreviewPlayer project={project} audioUrl={null} />);+ const frame = await screen.findByTitle('Composition document preview');+ rerender(<CompositionPreviewPlayer project={{ ...project, updatedAt: '2026-02-02T00:00:00.000Z', name: 'Renamed' }} audioUrl={null} />);+ await act(async () => {});+ expect(api.getMusicVideoCompositionPreview).toHaveBeenCalledTimes(1);+ expect(screen.getByTitle('Composition document preview')).toBe(frame);+ const next = { ...project, composition: { mode: 'document', document: { ...DOCUMENT, directory: 'music-video/mv-1/composition/doc-b' } } };+ rerender(<CompositionPreviewPlayer project={next} audioUrl={null} />);+ await waitFor(() => expect(api.getMusicVideoCompositionPreview).toHaveBeenCalledTimes(2));+ });+it('does not build the preview behind a collapsed phone mini-player until it is expanded', async () => {const original = window.matchMedia;window.matchMedia = vi.fn(() => ({ matches: false }));diff --git a/client/src/components/musicVideo/DocumentCompositionPanel.jsx b/client/src/components/musicVideo/DocumentCompositionPanel.jsxindex 47729e76e2..166d3d4fe4 100644--- a/client/src/components/musicVideo/DocumentCompositionPanel.jsx+++ b/client/src/components/musicVideo/DocumentCompositionPanel.jsx@@ -309,7 +309,7 @@ export default function DocumentCompositionPanel({ project, audioUrl, onProject,<div className="rounded border border-port-border p-2"><p className="mb-2 text-xs text-port-text-muted">Candidate preview · {candidate.providerId || 'provider'} / {candidate.model || 'default model'} · active document stays selected until accepted</p><div className="grid grid-cols-1 gap-2 xl:grid-cols-2">- {doc?.source?.kind === 'generated' && <div><p className="text-xs text-port-text-muted">Before · accepted section</p><CompositionPreviewPlayer project={project} audioUrl={audioUrl} seekRequest={comparisonSeek} /></div>}+ {doc?.source?.kind === 'generated' && <div><p className="text-xs text-port-text-muted">Before · accepted section</p><CompositionPreviewPlayer project={project} audioUrl={null} seekRequest={comparisonSeek} /></div>}<div><p className="text-xs text-port-text-muted">After · candidate section</p><CompositionPreviewPlayer project={project} audioUrl={audioUrl} seekRequest={comparisonSeek} draft /></div></div>{(candidate.comparisons || []).filter((entry) => !selectedSection || entry.sectionId === selectedSection).map((entry) => <p key={entry.sectionId} className="mt-2 text-xs text-port-text-muted">diff --git a/client/src/components/musicVideo/stages/ComposeStage.jsx b/client/src/components/musicVideo/stages/ComposeStage.jsxindex 7bf1089fdb..90af86f51a 100644--- a/client/src/components/musicVideo/stages/ComposeStage.jsx+++ b/client/src/components/musicVideo/stages/ComposeStage.jsx@@ -24,6 +24,12 @@ export default function ComposeStage({ board }) {Change in Setup</button></div>+ {mode !== 'document' && (+ <p className="text-xs text-port-text-muted" role="status">+ No live preview for this style — render a draft excerpt to check changes.{' '}+ <button type="button" onClick={() => board.goToStage('review', 'mv-draft-excerpts')} className="min-h-[44px] px-1 text-port-accent sm:min-h-0">Render a draft excerpt</button>+ </p>+ )}<GradePanel project={project} onSave={board.saveCompositionGrade} />{mode !== 'eidoverse' && <TypographyPanel project={project} onEditLocal={board.editProjectLocal} onSave={board.saveProjectFields} />}{mode === 'eidoverse' && <EidoverseVideoPanel key={project.id} project={project} onProject={board.replaceProject} productionReadiness={board.productionReadiness} />}diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.jsindex 805a108285..45989b497b 100644--- a/client/src/lib/musicVideoStages.js+++ b/client/src/lib/musicVideoStages.js@@ -88,17 +88,21 @@ export function projectSpend(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. Each entry has a stable `id`+ * then each finished draft excerpt, newest 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+ * inputs changed is labelled out of date. Each entry has a stable `id`* (the `?play=` value) and a `label` for the source picker.*/-export function listPreviewSources(project, { finalVideoSrc = null } = {}) {+export function listPreviewSources(project, { finalVideoSrc = null, liveFirst = false } = {}) {const sources = [];- if (project?.renderHistoryId && finalVideoSrc) {- sources.push({ id: 'final', kind: 'video', label: 'Final render', src: finalVideoSrc, startSec: 0, endSec: null });- }- if (project?.composition?.mode === 'document' && project.composition.document) {- sources.push({ id: 'document', kind: 'document', label: 'Composition (live)' });- }+ 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 }+ : null;+ const live = project?.composition?.mode === 'document' && project.composition.document+ ? { id: 'document', kind: 'document', label: 'Composition (live)' }+ : null;+ sources.push(...(liveFirst ? [live, final] : [final, live]).filter(Boolean));const excerpts = (project?.excerpts || []).filter((e) => e.status === 'complete' && e.filename).reverse();for (const excerpt of excerpts) {sources.push({diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.jsindex a2a81e8701..1f42208729 100644--- a/client/src/lib/musicVideoStages.test.js+++ b/client/src/lib/musicVideoStages.test.js@@ -174,6 +174,10 @@ describe('listPreviewSources', () => {.toEqual(['final', 'document', 'excerpt:b', 'excerpt:a']);// The final render plays only once its file has resolved; a non-document mode has no live composition.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(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 });});diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 3a1f9fbea4..3c382a1bba 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -1026,7 +1026,7 @@ export default function MusicVideo() {} : null;const StageView = STAGE_VIEWS[activeStage];- const previewSources = selected ? listPreviewSources(selected, { finalVideoSrc: finalVideo.src }) : [];+ const previewSources = selected ? listPreviewSources(selected, { finalVideoSrc: finalVideo.src, liveFirst: activeStage === 'compose' }) : [];return (<div className="flex h-full flex-col">diff --git a/server/lib/musicVideoDependencies.js b/server/lib/musicVideoDependencies.jsindex 550f01660e..2fa3c95bc6 100644--- a/server/lib/musicVideoDependencies.js+++ b/server/lib/musicVideoDependencies.js@@ -159,6 +159,7 @@ export function presentMusicVideoDependencies(project) {reasons: [...new Set(changes.map((change) => change.reason))] };};return { ...project,+ ...(project.renderHistoryId && project.renderDependencies ? { renderDependencyState: state(project.renderDependencies) } : {}),scenes: (project.scenes || []).map((scene) => ({ ...scene, takes: (scene.takes || []).map((take) => ({ ...take,...(take.dependencies ? { dependencyState: state(take.dependencies) } : {}),})) })),diff --git a/server/routes/musicVideoDependencies.test.js b/server/routes/musicVideoDependencies.test.jsindex 409be25e3a..e282d90d9e 100644--- a/server/routes/musicVideoDependencies.test.js+++ b/server/routes/musicVideoDependencies.test.js@@ -104,8 +104,11 @@ describe('public dependency save / repair / review workflow', () => {await request(app).patch(`${base()}/scenes/a`).send({ shotMode: 'performance', performanceSpeaker: 'Example Singer' });await projects.mutateProjectRecord(project.id, (current) => ({ project: { ...current, excerpts: current.excerpts.map((excerpt) => excerpt.id === 'excerpt-a'? { ...excerpt, dependencies: captureMusicVideoEvidence(current, { startSec: 0, endSec: 5 }) } : excerpt) } }));+ await projects.mutateProjectRecord(project.id, (current) => ({ project: { ...current, renderHistoryId: 'example-render', renderDependencies: captureMusicVideoEvidence(current) } }));+ expect((await fresh()).renderDependencyState.status).toBe('current');await request(app).patch(`${base()}/scenes/a`).send({ performanceSpeaker: 'Example Duet Partner' });const changed = await fresh();+ expect(changed.renderDependencyState.status).toBe('stale');expect(changed.excerpts[0].dependencyState.status).toBe('stale');expect(changed.excerpts[1].dependencyState.status).toBe('current');expect(changed.scenes.map((scene) => scene.videoHistoryId)).toEqual(['clip-a', 'clip-b']);