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

fix(music-video): keep folded sections and the picked preview where the director left them

Claudeda681977d3cd
diff --git a/client/src/components/musicVideo/StageSection.jsx b/client/src/components/musicVideo/StageSection.jsx
index a5316b525b..dd933d40cf 100644
--- a/client/src/components/musicVideo/StageSection.jsx
+++ b/client/src/components/musicVideo/StageSection.jsx
@@ -1,14 +1,24 @@
+import { useEffect, useRef, useState } from 'react';
import { ChevronRight } from 'lucide-react';
/**
* A stage panel group that folds away: a native `<details>` (so it works
* without script and reads as a disclosure to assistive tech) with a one-line
* summary beside the title, collapsed unless `defaultOpen`. The summary row is
- * the 44px tap target on a phone.
+ * the 44px tap target on a phone. `defaultOpen` sets the first state; a later
+ * false → true change unfolds it (something now needs the director), but props
+ * never fold it — only the director closes an open section.
*/
export default function StageSection({ id, title, summary = null, defaultOpen = false, children, className = '' }) {
+ const ref = useRef(null);
+ const [initialOpen] = useState(defaultOpen);
+ const previous = useRef(defaultOpen);
+ useEffect(() => {
+ if (defaultOpen && !previous.current && ref.current) ref.current.open = true;
+ previous.current = defaultOpen;
+ }, [defaultOpen]);
return (
- <details id={id} open={defaultOpen || undefined} className={`group min-w-0 rounded-lg border border-port-border bg-port-card ${className}`}>
+ <details ref={ref} id={id} open={initialOpen || undefined} className={`group min-w-0 rounded-lg border border-port-border bg-port-card ${className}`}>
<summary className="flex min-h-[44px] cursor-pointer select-none items-center gap-2 px-3 py-2 marker:content-none [&::-webkit-details-marker]:hidden">
<ChevronRight size={14} aria-hidden="true" className="shrink-0 text-port-text-muted transition-transform group-open:rotate-90" />
<span className="shrink-0 text-sm font-medium">{title}</span>
diff --git a/client/src/components/musicVideo/StageSection.test.jsx b/client/src/components/musicVideo/StageSection.test.jsx
new file mode 100644
index 0000000000..ebcd011725
--- /dev/null
+++ b/client/src/components/musicVideo/StageSection.test.jsx
@@ -0,0 +1,29 @@
+import { describe, expect, it } from 'vitest';
+import { render } from '@testing-library/react';
+import StageSection from './StageSection.jsx';
+
+// The folded autopilot and approvals sections compute `defaultOpen` from live
+// project state; a change in that state may unfold a section but must never
+// fold one the director is working in.
+describe('StageSection', () => {
+ const section = (defaultOpen) => <StageSection id="example-section" title="Example" defaultOpen={defaultOpen}><p>Body</p></StageSection>;
+
+ it('stays open when defaultOpen turns false, and unfolds when it turns true', () => {
+ const { container, rerender } = render(section(true));
+ const details = container.querySelector('details');
+ expect(details.open).toBe(true);
+ rerender(section(false));
+ expect(details.open).toBe(true);
+
+ details.open = false;
+ rerender(section(false));
+ expect(details.open).toBe(false);
+ rerender(section(true));
+ expect(details.open).toBe(true);
+ });
+
+ it('starts folded when defaultOpen is false', () => {
+ const { container } = render(section(false));
+ expect(container.querySelector('details').open).toBe(false);
+ });
+});
diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.js
index 9098aa1b7d..a2cf186777 100644
--- a/client/src/lib/musicVideoStages.js
+++ b/client/src/lib/musicVideoStages.js
@@ -78,6 +78,12 @@ export function listPreviewSources(project, { finalVideoSrc = null } = {}) {
return sources;
}
+// A stopped run can be resumed as is; the others need the director first.
+const PRODUCTION_RUN_LABELS = {
+ running: 'Production running', stopped: 'Production paused', blocked: 'Production blocked',
+ 'limit-reached': 'Production at its limit', 'needs-replan': 'Production needs a replan',
+};
+
const APPROVAL_LABELS = { art: 'art', storyboard: 'storyboard', proof: 'proof' };
/** One line for the production-approval gate: which of the three approvals the current revision holds. */
@@ -115,7 +121,7 @@ export function describeProjectStatus(project, { progress, nextAction = null, re
}
const run = currentProductionRun(project);
if (run && RESUMABLE_RUN_STATUSES.has(run.status)) {
- facts.push({ id: 'production', label: run.status === 'running' ? 'Production running' : 'Production paused', tone: run.status === 'running' ? 'muted' : 'warn' });
+ facts.push({ id: 'production', label: PRODUCTION_RUN_LABELS[run.status] || 'Production paused', tone: run.status === 'running' ? 'muted' : 'warn' });
}
const approvals = approvalSummary(readiness);
if (approvals) facts.push({ id: 'approvals', label: `Approvals: ${approvals}`, tone: readiness.readyForProduction ? 'ok' : 'warn' });
diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.js
index e32a7aa0ce..86708f1dfa 100644
--- a/client/src/lib/musicVideoStages.test.js
+++ b/client/src/lib/musicVideoStages.test.js
@@ -163,6 +163,15 @@ describe('describeProjectStatus', () => {
]);
});
+ it('says why a stopped production run is waiting rather than calling every stop a pause', () => {
+ const fact = (status) => describeProjectStatus({ productionRuns: [{ id: 'r1', status }] }, { progress: stages('produce') })
+ .facts.find((entry) => entry.id === 'production').label;
+ expect(fact('stopped')).toBe('Production paused');
+ expect(fact('blocked')).toBe('Production blocked');
+ expect(fact('limit-reached')).toBe('Production at its limit');
+ expect(fact('needs-replan')).toBe('Production needs a replan');
+ });
+
it('reports drafts and the final render', () => {
const drafts = describeProjectStatus({ excerpts: [{ id: 'a', status: 'complete', filename: 'a.mp4' }] }, { progress: stages('review') });
expect(drafts.headline).toBe('Stage 6 of 7: Review');
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 2944a23422..a4035cba85 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -788,7 +788,9 @@ export default function MusicVideo() {
}, [pendingAnchor, activeStage]);
const goToStage = (stage, anchor = null) => {
setPendingAnchor(anchor ? { stage, id: anchor } : null);
- navigate(`/music-video/${encodeURIComponent(selected.id)}/${stage}`);
+ // The dock's picked source (`?play=`) follows the director across tabs.
+ const play = searchParams.get('play');
+ navigate(`/music-video/${encodeURIComponent(selected.id)}/${stage}${play ? `?play=${encodeURIComponent(play)}` : ''}`);
};
// The docked preview: scene cards seek it; on a phone it is a mini-player
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index 9daf2a1eb0..9b52aa8fb1 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -2338,6 +2338,22 @@ describe('MusicVideo stage tabs (#9243)', () => {
await waitFor(() => expect(screen.getByLabelText('Draft excerpt preview').getAttribute('src')).toBe('/data/videos/excerpt-old.mp4'));
});
+ it('plays the final render first and keeps a picked draft across stage tabs', async () => {
+ const project = {
+ ...PROJECT_WITH_CLIP,
+ renderHistoryId: 'rh-9',
+ excerpts: [{ id: 'mve-1', startSec: 0, endSec: 10, status: 'complete', filename: 'excerpt-old.mp4', notes: [] }],
+ };
+ await openProject(project, 'setup');
+ const final = await screen.findByLabelText('Final render preview');
+ expect(final.getAttribute('src')).toBe('/data/videos/final.mp4');
+ fireEvent.change(screen.getByLabelText('Preview source'), { target: { value: 'excerpt:mve-1' } });
+ await waitFor(() => expect(screen.getByLabelText('Draft excerpt preview').getAttribute('src')).toBe('/data/videos/excerpt-old.mp4'));
+ await openStage('board');
+ expect(screen.getByLabelText('Draft excerpt preview').getAttribute('src')).toBe('/data/videos/excerpt-old.mp4');
+ expect(screen.queryByLabelText('Final render preview')).toBeNull();
+ });
+
it('offers no preview when the project has neither a document nor a finished excerpt', async () => {
await openProject(PROJECT_WITH_CLIP, 'board');
expect(screen.queryByLabelText('Preview')).toBeNull();