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

feat: render richly detailed project cards with preview on music video main page

[._.]/ Adam Eivy33c7755ec695
diff --git a/client/src/components/musicVideo/MusicVideoProjectCard.jsx b/client/src/components/musicVideo/MusicVideoProjectCard.jsx
new file mode 100644
index 0000000000..28a6a77c11
--- /dev/null
+++ b/client/src/components/musicVideo/MusicVideoProjectCard.jsx
@@ -0,0 +1,322 @@
+import { useState, useEffect } from 'react';
+import { Film, Play, Music, Wand2, Sparkles, Copy, Trash2, ArrowUpRight } from 'lucide-react';
+import MediaImage from '../MediaImage.jsx';
+import ScenePreview from '../creative-director/ScenePreview.jsx';
+import ConfirmButtonPair from '../ui/ConfirmButtonPair.jsx';
+import { selectMusicVideoPreview } from '../../lib/musicVideoPreview.js';
+import { useVideoFileSrc } from '../../hooks/useVideoFileSrc.js';
+import { deriveStages, projectSpend, MUSIC_VIDEO_STAGES } from '../../lib/musicVideoStages.js';
+
+export const STATUS_COLORS = {
+ draft: 'bg-port-border text-port-text',
+ analyzed: 'bg-port-accent/30 text-port-accent',
+ ready: 'bg-port-accent/30 text-port-accent',
+ rendering: 'bg-port-warning/30 text-port-warning',
+ complete: 'bg-port-success/30 text-port-success',
+ failed: 'bg-port-error/30 text-port-error',
+};
+
+export default function MusicVideoProjectCard({
+ project,
+ trackLabel,
+ onSelect,
+ onClone,
+ isConfirmingDelete = false,
+ onRequestDelete,
+ onConfirmDelete,
+ onCancelDelete,
+ cloning = false,
+}) {
+ const [playing, setPlaying] = useState(false);
+ const preview = selectMusicVideoPreview(project);
+
+ // When preview target changes, stop playing
+ useEffect(() => {
+ setPlaying(false);
+ }, [preview.jobId, preview.src]);
+
+ // Video resolution via hook (lazy: only when playing)
+ const { src: resolvedSrc, resolving, retry: retryResolve } = useVideoFileSrc(preview.jobId, {
+ enabled: playing && preview.kind === 'video',
+ });
+
+ const scenes = Array.isArray(project.scenes) ? project.scenes : [];
+ const scenesWithClips = scenes.filter((s) => s.videoHistoryId).length;
+ const scenesWithFrames = scenes.filter((s) => s.referenceImageId).length;
+ const scenesProgressPct = scenes.length > 0 ? Math.round((scenesWithClips / scenes.length) * 100) : 0;
+
+ const { current: currentStageId } = deriveStages(project);
+ const currentStageObj = MUSIC_VIDEO_STAGES.find((s) => s.id === currentStageId);
+ const stageLabel = currentStageObj?.label || currentStageId;
+
+ const spend = projectSpend(project);
+ const audioTitle = trackLabel || project.uploadedAudioFilename || null;
+ const conceptText = project.concept?.style || project.concept?.prompt || null;
+ const palette = Array.isArray(project.visualSpec?.palette) ? project.visualSpec.palette : [];
+
+ return (
+ <div
+ data-testid={`mv-project-card-${project.id}`}
+ className="bg-port-card border border-port-border rounded-lg p-4 flex flex-col justify-between hover:border-port-accent/40 transition-colors space-y-3 min-w-0"
+ >
+ {/* Top Header & Identification */}
+ <div className="space-y-1.5 min-w-0">
+ <div className="flex items-start justify-between gap-2">
+ <button
+ type="button"
+ onClick={onSelect}
+ className="text-left font-semibold text-base text-port-text hover:text-port-accent transition-colors truncate max-w-full flex-1"
+ title={project.name}
+ >
+ {project.name}
+ </button>
+ <div className="flex items-center gap-1 shrink-0">
+ <span className="text-[10px] px-1.5 py-0.5 rounded bg-port-border text-port-text-muted font-mono">
+ v{project.version || 1}
+ </span>
+ <span className={`text-[10px] font-medium px-2 py-0.5 rounded ${STATUS_COLORS[project.status] || 'bg-port-border'}`}>
+ {project.status}
+ </span>
+ </div>
+ </div>
+
+ {/* Mode & Stage indicators */}
+ <div className="flex flex-wrap items-center gap-1.5 text-[10px]">
+ {project.mode === 'autonomous' ? (
+ <span className="px-1.5 py-0.5 rounded bg-port-accent/20 text-port-accent border border-port-accent/30 flex items-center gap-1">
+ <Wand2 size={10} aria-hidden="true" /> Autopilot
+ </span>
+ ) : (
+ <span className="px-1.5 py-0.5 rounded bg-port-border/60 text-port-text-muted flex items-center gap-1">
+ <Film size={10} aria-hidden="true" /> Director
+ </span>
+ )}
+ <span className="px-1.5 py-0.5 rounded bg-port-bg border border-port-border text-port-text-muted">
+ Stage: <strong className="text-port-text font-medium">{stageLabel}</strong>
+ </span>
+ {project.concept?.universeId && (
+ <span className="px-1.5 py-0.5 rounded bg-purple-500/15 text-purple-300 border border-purple-500/30 flex items-center gap-1">
+ <Sparkles size={10} aria-hidden="true" /> {project.concept.universeId}
+ </span>
+ )}
+ </div>
+ </div>
+
+ {/* Media Preview Box */}
+ <div className="relative aspect-video rounded bg-black/50 border border-port-border overflow-hidden group shrink-0">
+ {preview.kind === 'video' && playing ? (
+ resolving ? (
+ <div className="w-full h-full flex items-center justify-center text-xs text-port-text-muted">
+ Loading video…
+ </div>
+ ) : (
+ <ScenePreview
+ jobId={preview.jobId}
+ src={resolvedSrc || preview.src}
+ onRetry={retryResolve}
+ label={`${project.name} — ${preview.label}`}
+ aspectClass="aspect-video"
+ autoPlay
+ />
+ )
+ ) : preview.kind === 'video' ? (
+ <>
+ <button
+ type="button"
+ onClick={onSelect}
+ className="block w-full h-full text-left"
+ aria-label={`Open project ${project.name}`}
+ >
+ <MediaImage
+ src={preview.poster}
+ alt={`${project.name} preview`}
+ loading="lazy"
+ className="w-full h-full object-cover"
+ />
+ </button>
+ <button
+ type="button"
+ onClick={() => setPlaying(true)}
+ aria-label={`Play ${preview.label}`}
+ title={`Play ${preview.label}`}
+ className="always-dark absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-10 h-10 flex items-center justify-center rounded-full bg-black/60 text-white hover:bg-black/80 hover:scale-105 transition-all shadow-lg focus:outline-none focus:ring-2 focus:ring-port-accent"
+ >
+ <Play size={16} className="ml-0.5" aria-hidden="true" />
+ </button>
+ <span className="always-dark absolute bottom-1.5 left-1.5 px-1.5 py-0.5 rounded bg-black/70 text-white text-[10px] font-medium pointer-events-none flex items-center gap-1">
+ <Film size={10} aria-hidden="true" /> {preview.label}
+ </span>
+ </>
+ ) : preview.kind === 'image' ? (
+ <>
+ <button
+ type="button"
+ onClick={onSelect}
+ className="block w-full h-full text-left"
+ aria-label={`Open project ${project.name}`}
+ >
+ <MediaImage
+ src={preview.src}
+ fallbackSrc={preview.fallbackSrc}
+ alt={`${project.name} frame`}
+ loading="lazy"
+ className="w-full h-full object-cover"
+ />
+ </button>
+ <span className="always-dark absolute bottom-1.5 left-1.5 px-1.5 py-0.5 rounded bg-black/70 text-white text-[10px] font-medium pointer-events-none">
+ {preview.label}
+ </span>
+ </>
+ ) : (
+ <button
+ type="button"
+ onClick={onSelect}
+ className="w-full h-full flex flex-col items-center justify-center gap-1.5 text-port-text-muted text-xs hover:bg-port-border/20 transition-colors"
+ aria-label={`Open project ${project.name}`}
+ >
+ <Film size={22} className="opacity-40" aria-hidden="true" />
+ <span>No render preview yet</span>
+ </button>
+ )}
+ </div>
+
+ {/* Rich Configuration Options & Audio Info */}
+ <div className="space-y-2 text-xs">
+ {/* Audio row */}
+ <div className="flex items-center justify-between gap-2 text-port-text-muted">
+ <span className="flex items-center gap-1.5 truncate font-medium text-port-text" title={audioTitle || 'No audio track'}>
+ <Music size={13} className="text-port-accent shrink-0" aria-hidden="true" />
+ <span className="truncate">{audioTitle || 'No audio track'}</span>
+ </span>
+ {project.audioAnalysis?.bpm ? (
+ <span className="shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded bg-port-bg border border-port-border">
+ {project.audioAnalysis.bpm} BPM
+ </span>
+ ) : null}
+ </div>
+
+ {/* Configuration Badges */}
+ <div className="flex flex-wrap items-center gap-1.5 text-[10px]">
+ <span className="px-1.5 py-0.5 rounded bg-port-bg border border-port-border font-mono text-[10px]" title="Video Backend">
+ {project.videoSettings?.backend || 'local'}
+ </span>
+ {project.videoSettings?.modelId && (
+ <span className="px-1.5 py-0.5 rounded bg-port-bg border border-port-border font-mono text-[10px] truncate max-w-[120px]" title={`Model: ${project.videoSettings.modelId}`}>
+ {project.videoSettings.modelId}
+ </span>
+ )}
+ <span className="px-1.5 py-0.5 rounded bg-port-bg border border-port-border text-[10px]">
+ {project.videoSettings?.generationMode === 'text' ? 'T2V' : 'I2V'}
+ </span>
+ {project.videoSettings?.audioReactiveLora && (
+ <span className="px-1.5 py-0.5 rounded bg-port-accent/15 text-port-accent text-[10px] border border-port-accent/30" title="Audio Reactive LoRA">
+ Reactive
+ </span>
+ )}
+ {project.vocalStemFilename && (
+ <span className="px-1.5 py-0.5 rounded bg-port-accent/15 text-port-accent text-[10px] border border-port-accent/30">
+ Vocal Stem
+ </span>
+ )}
+ {project.midiTranscription && (
+ <span className="px-1.5 py-0.5 rounded bg-port-accent/15 text-port-accent text-[10px] border border-port-accent/30">
+ MIDI
+ </span>
+ )}
+ {project.composition?.mode && project.composition.mode !== 'concat' && (
+ <span className="px-1.5 py-0.5 rounded bg-port-bg border border-port-border text-[10px] capitalize">
+ {project.composition.mode}
+ </span>
+ )}
+ {palette.length > 0 && (
+ <div className="flex items-center gap-0.5 ml-1" title="Color palette">
+ {palette.slice(0, 5).map((color, idx) => (
+ <span
+ key={idx}
+ className="w-2.5 h-2.5 rounded-full border border-port-border shrink-0"
+ style={{ backgroundColor: color }}
+ title={color}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+
+ {/* Concept / Style snippet */}
+ {conceptText && (
+ <p className="text-[11px] text-port-text-muted italic line-clamp-1 truncate" title={conceptText}>
+ &ldquo;{conceptText}&rdquo;
+ </p>
+ )}
+
+ {/* Storyboard & scenes progress */}
+ <div className="space-y-1 pt-1.5 border-t border-port-border/40 text-[11px]">
+ <div className="flex items-center justify-between text-port-text-muted">
+ <span>
+ {scenes.length} scene{scenes.length === 1 ? '' : 's'}
+ {scenesWithClips > 0 ? ` · ${scenesWithClips} clip${scenesWithClips === 1 ? '' : 's'}` : ''}
+ {scenesWithFrames > 0 && scenesWithClips === 0 ? ` · ${scenesWithFrames} frame${scenesWithFrames === 1 ? '' : 's'}` : ''}
+ </span>
+ {spend.capUsd != null || spend.spentUsd > 0 ? (
+ <span className="font-mono text-port-text-muted">
+ ${spend.spentUsd.toFixed(2)}{spend.capUsd != null ? ` / $${spend.capUsd}` : ''}
+ </span>
+ ) : null}
+ </div>
+ {scenes.length > 0 && (
+ <div className="h-1 bg-port-bg rounded overflow-hidden">
+ <div
+ className="h-full bg-port-accent transition-all duration-300"
+ style={{ width: `${scenesProgressPct}%` }}
+ title={`${scenesProgressPct}% clips rendered`}
+ />
+ </div>
+ )}
+ </div>
+ </div>
+
+ {/* Footer Actions */}
+ <div className="flex items-center justify-between gap-2 pt-2 border-t border-port-border mt-auto shrink-0">
+ <div className="flex items-center gap-1.5">
+ <button
+ type="button"
+ onClick={onSelect}
+ className="bg-port-accent hover:bg-port-accent/80 text-white rounded px-2.5 py-1 text-xs font-medium flex items-center gap-1 min-h-[32px] transition-colors"
+ >
+ Open <ArrowUpRight size={13} aria-hidden="true" />
+ </button>
+ <button
+ type="button"
+ onClick={() => onClone?.()}
+ disabled={cloning}
+ title="Fork this project version"
+ className="bg-port-bg border border-port-border hover:bg-port-border/40 text-port-text rounded px-2 py-1 text-xs flex items-center gap-1 min-h-[32px] disabled:opacity-50 transition-colors"
+ >
+ <Copy size={13} aria-hidden="true" /> {cloning ? 'Forking…' : 'Fork'}
+ </button>
+ </div>
+
+ {isConfirmingDelete ? (
+ <ConfirmButtonPair
+ prompt="Delete?"
+ confirmText="Delete"
+ ariaLabel={`Confirm delete project ${project.name}`}
+ confirmAriaLabel={`Confirm delete project ${project.name}`}
+ onConfirm={onConfirmDelete}
+ onCancel={onCancelDelete}
+ />
+ ) : (
+ <button
+ type="button"
+ onClick={onRequestDelete}
+ title={`Delete project ${project.name}`}
+ aria-label={`Delete project ${project.name}`}
+ className="flex min-h-[32px] min-w-[32px] items-center justify-center rounded border border-port-border px-2 py-1 text-xs text-port-error hover:bg-port-error/10 transition-colors"
+ >
+ <Trash2 size={13} aria-hidden="true" />
+ </button>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx b/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx
new file mode 100644
index 0000000000..71cacdd51b
--- /dev/null
+++ b/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx
@@ -0,0 +1,174 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent, act, waitFor } from '@testing-library/react';
+import MusicVideoProjectCard from './MusicVideoProjectCard.jsx';
+
+vi.mock('../../services/apiImageVideo.js', () => ({
+ getVideoHistoryItem: vi.fn(async (id) => ({ id, filename: `${id}.mp4` })),
+}));
+
+const BASE_PROJECT = {
+ id: 'mv-card-1',
+ name: 'Cyber Horizon',
+ version: 2,
+ status: 'ready',
+ mode: 'autonomous',
+ trackId: 'track-1',
+ audioAnalysis: { bpm: 128, durationSec: 180 },
+ vocalStemFilename: 'vocals.wav',
+ midiTranscription: 'notes.mid',
+ videoSettings: {
+ backend: 'fal',
+ modelId: 'hunyuan_video',
+ generationMode: 'image',
+ audioReactiveLora: 'audio-reactive.safetensors',
+ },
+ concept: {
+ universeId: 'neon-city',
+ style: 'retro synthwave neon lighting',
+ },
+ visualSpec: {
+ palette: ['#ff007f', '#00f0ff'],
+ references: [],
+ },
+ scenes: [
+ { sceneId: 's1', referenceImageId: 'frame-1.png', videoHistoryId: 'vid-1' },
+ { sceneId: 's2', referenceImageId: 'frame-2.png', videoHistoryId: null },
+ ],
+ renderHistoryId: null,
+};
+
+describe('MusicVideoProjectCard', () => {
+ it('renders richly detailed metadata and configuration options', () => {
+ const onSelect = vi.fn();
+ render(
+ <MusicVideoProjectCard
+ project={BASE_PROJECT}
+ trackLabel="Synth Dreams"
+ onSelect={onSelect}
+ />,
+ );
+
+ // Title and version
+ expect(screen.getByText('Cyber Horizon')).toBeInTheDocument();
+ expect(screen.getByText('v2')).toBeInTheDocument();
+ expect(screen.getByText('ready')).toBeInTheDocument();
+
+ // Mode and stage
+ expect(screen.getByText(/Autopilot/i)).toBeInTheDocument();
+ expect(screen.getByText(/Stage:/i)).toBeInTheDocument();
+ expect(screen.getByText('neon-city')).toBeInTheDocument();
+
+ // Audio & analysis
+ expect(screen.getByText('Synth Dreams')).toBeInTheDocument();
+ expect(screen.getByText('128 BPM')).toBeInTheDocument();
+ expect(screen.getByText('Vocal Stem')).toBeInTheDocument();
+ expect(screen.getByText('MIDI')).toBeInTheDocument();
+
+ // Video settings
+ expect(screen.getByText('fal')).toBeInTheDocument();
+ expect(screen.getByText('hunyuan_video')).toBeInTheDocument();
+ expect(screen.getByText('I2V')).toBeInTheDocument();
+ expect(screen.getByText('Reactive')).toBeInTheDocument();
+
+ // Style text
+ expect(screen.getByText(/retro synthwave neon lighting/i)).toBeInTheDocument();
+
+ // Scene stats
+ expect(screen.getByText(/2 scenes · 1 clip/i)).toBeInTheDocument();
+ });
+
+ it('handles clicking the open button or title to select project', () => {
+ const onSelect = vi.fn();
+ render(
+ <MusicVideoProjectCard
+ project={BASE_PROJECT}
+ trackLabel="Synth Dreams"
+ onSelect={onSelect}
+ />,
+ );
+
+ fireEvent.click(screen.getByRole('button', { name: /^Open$/i }));
+ expect(onSelect).toHaveBeenCalledTimes(1);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Cyber Horizon' }));
+ expect(onSelect).toHaveBeenCalledTimes(2);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Open project Cyber Horizon' }));
+ expect(onSelect).toHaveBeenCalledTimes(3);
+ });
+
+ it('renders video preview with play button and handles clicking play', async () => {
+ render(
+ <MusicVideoProjectCard
+ project={BASE_PROJECT}
+ trackLabel="Synth Dreams"
+ />,
+ );
+
+ // Shows scene clip label and play button
+ expect(screen.getByText('Scene 1 clip')).toBeInTheDocument();
+ const playBtn = screen.getByRole('button', { name: /Play Scene 1 clip/i });
+ expect(playBtn).toBeInTheDocument();
+
+ await act(async () => {
+ fireEvent.click(playBtn);
+ });
+
+ // After clicking play, it mounts ScenePreview
+ await waitFor(() => {
+ expect(screen.queryByRole('button', { name: /Play Scene 1 clip/i })).not.toBeInTheDocument();
+ });
+ });
+
+ it('handles fork/clone and delete confirmation', () => {
+ const onClone = vi.fn();
+ const onRequestDelete = vi.fn();
+ const onConfirmDelete = vi.fn();
+ const onCancelDelete = vi.fn();
+
+ const { rerender } = render(
+ <MusicVideoProjectCard
+ project={BASE_PROJECT}
+ onClone={onClone}
+ onRequestDelete={onRequestDelete}
+ isConfirmingDelete={false}
+ />,
+ );
+
+ // Fork
+ fireEvent.click(screen.getByRole('button', { name: /Fork/i }));
+ expect(onClone).toHaveBeenCalledTimes(1);
+
+ // Delete request
+ fireEvent.click(screen.getByRole('button', { name: /Delete project Cyber Horizon/i }));
+ expect(onRequestDelete).toHaveBeenCalledTimes(1);
+
+ // When confirming delete
+ rerender(
+ <MusicVideoProjectCard
+ project={BASE_PROJECT}
+ onClone={onClone}
+ onRequestDelete={onRequestDelete}
+ isConfirmingDelete={true}
+ onConfirmDelete={onConfirmDelete}
+ onCancelDelete={onCancelDelete}
+ />,
+ );
+
+ expect(screen.getByText('Delete?')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Confirm delete project Cyber Horizon' }));
+ expect(onConfirmDelete).toHaveBeenCalledTimes(1);
+ });
+
+ it('renders placeholder when no render is present', () => {
+ const emptyProj = {
+ ...BASE_PROJECT,
+ id: 'empty-1',
+ scenes: [],
+ visualSpec: null,
+ renderHistoryId: null,
+ };
+ render(<MusicVideoProjectCard project={emptyProj} />);
+ expect(screen.getByText('No render preview yet')).toBeInTheDocument();
+ });
+});
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index 3ee7a5333c..531d373314 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -65,6 +65,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `musicVideoTakes.js` | Music-video scene takes view helpers (#8965): `sceneTakeList(scene, kind)` lists a scene's image/video takes with an un-materialized pre-takes selection appended as a read-only `legacy` take; `takePreviewKey`, `takeThumbUrl`, `takeProvenance`; `TAKE_SLOT` maps a take kind to its selection field. Used by `components/musicVideo/SceneTakeStrip.jsx` and `pages/MusicVideo.jsx`. |
| `musicVideoShotTiming.js` | Re-export of `server/lib/musicVideoShotTiming.js` (#8977) — shot modes, the verified source-audio lip-sync capability table, `performanceBlockedReason`, `planPerformanceRepair` (measured accepted-prefix boundary, suffix interval and next spend), `planPerformanceWindow`, `grokCoverage`, `approximateMotionCues`, `shotSplitLimit` (when a scene offers a lyric-boundary split), `falSceneTake` (a fal take's model, length, resolution and estimated cost). Used by `hooks/useMusicVideoSceneMedia.js` and `components/musicVideo/SceneCard.jsx`. |
| `musicVideoStages.js` | Music Video page stage model: `MUSIC_VIDEO_STAGES` (setup → cast-sets → board → produce → compose → review), `resolveStageParam(value)` for the `:stage` route param, `deriveStages(project)` (per-stage `done`/`active`/`blocked`/`todo` + `current`, the first incomplete stage; a live production run pins Produce), `deriveNextAction(project, ctx)` (the one primary action the sticky header offers — approve Cast & Sets, stop/resume production, render final, …), `projectSpend(project)` (paid generation used vs. cap) and `currentProductionRun`. Used by `components/musicVideo/MusicVideoLayout.jsx` and `pages/MusicVideo.jsx`. |
+| `musicVideoPreview.js` | Pick the representative produced asset for a Music Video project card (`selectMusicVideoPreview`: final video → latest excerpt → latest rendered scene clip → latest scene reference frame → visual spec reference) for the main project grid. Pure, computed off the project record, with image path and fallback helpers (`musicVideoImageSrc`, `musicVideoImageFallback`). |
| `musicVideoUniverseRefs.js` | `pullUniverseCanonReferences(universe, existingReferences)` (#8978) maps a linked universe's characters/places/objects to visual-spec references (character/set/prop roles), skipping images already present and capping at `MUSIC_VIDEO_MAX_REFERENCES` (24, mirrors the server schema). Returns `{ next, added, skipped }`; the caller persists `next` via the ordinary visualSpec PATCH. Used by `components/musicVideo/VisualSpecPanel.jsx`. (The style snapshots are derived server-side, #9105.) |
| `musicVideoAutonomous.js` | Fully-autonomous Music Video, client half: re-exports the server stage vocabulary (`AUTONOMOUS_STAGES`, checkpoint ids, default tools/limits, `autonomousMedium`), the status/checkpoint labels, and owns the start form's `emptyAutonomousDraft` / `autonomousRequestFromDraft` mapping plus `autonomousStageRows(run)` and `isAutonomousLive(run)` for the run panel, and `autopilotDraftFromParams` / `autopilotParamsFromDraft` for the music-video-autopilot Schedule settings form. |
| `musicVideoAutomation.js` | Music Video automation brief, client half: re-exports the server tool catalog (`MUSIC_VIDEO_AUTOMATION_TOOLS` / `_TOOL_IDS`), `DEFAULT_AUTOMATION_TOOLS` (the unmetered tools), and the form mapping `automationDraftFrom(automation)` / `automationFromDraft(draft)` (empty budget = no cap; the direction-LLM pin rides as `llm`, absent = Auto), plus `llmRouteLabel(route)` for the stage-route summary. Used by the create drawer and `AutopilotPanel`. |
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index cb9f596a71..5f6589d88d 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -77,6 +77,7 @@ export * from './musicVideoStages.js';
export * from './musicVideoUniverseRefs.js';
export * from './musicVideoAutomation.js';
export * from './musicVideoAutonomous.js';
+export * from './musicVideoPreview.js';
export * from './pipelineImageDefaults.js';
export * from './reverseOutlineGrid.js';
export * from './reviewerModels.js';
diff --git a/client/src/lib/musicVideoPreview.js b/client/src/lib/musicVideoPreview.js
new file mode 100644
index 0000000000..ce314ef018
--- /dev/null
+++ b/client/src/lib/musicVideoPreview.js
@@ -0,0 +1,101 @@
+import { videoSrcForJob, videoPosterForJob } from './creativeDirectorPreview.js';
+
+const nonEmptyString = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
+
+export const musicVideoImageSrc = (assetId) => {
+ const raw = nonEmptyString(assetId);
+ if (!raw) return null;
+ if (/^(https?:|data:|blob:)/i.test(raw) || raw.startsWith('/')) return raw;
+ return `/data/images/${raw}`;
+};
+
+export const musicVideoImageFallback = (assetId) => {
+ const raw = nonEmptyString(assetId);
+ if (!raw || raw.includes('.')) return null;
+ return `/data/images/${raw}.png`;
+};
+
+/**
+ * Normalized preview descriptor for a music video project:
+ * { kind: 'video', jobId?, src, poster?, label }
+ * { kind: 'image', src, fallbackSrc?, label }
+ * { kind: 'none', label }
+ */
+export function selectMusicVideoPreview(project) {
+ const none = { kind: 'none', label: 'No render yet' };
+ if (!project || typeof project !== 'object') return none;
+
+ // 1. Final video render (the complete produced music video)
+ const finalId = nonEmptyString(project.renderHistoryId);
+ if (finalId) {
+ return {
+ kind: 'video',
+ jobId: finalId,
+ src: videoSrcForJob(finalId),
+ poster: videoPosterForJob(finalId),
+ label: 'Final video',
+ };
+ }
+
+ // 2. Latest completed excerpt render
+ const excerpts = Array.isArray(project.excerpts) ? project.excerpts : [];
+ const latestExcerpt = [...excerpts].reverse().find((e) => e.status === 'complete' && (e.filename || e.jobId));
+ if (latestExcerpt) {
+ const excerptJobId = nonEmptyString(latestExcerpt.jobId);
+ const filename = nonEmptyString(latestExcerpt.filename);
+ const excerptSrc = filename ? `/data/videos/${filename}` : (excerptJobId ? videoSrcForJob(excerptJobId) : null);
+ return {
+ kind: 'video',
+ jobId: excerptJobId,
+ src: excerptSrc,
+ poster: excerptJobId ? videoPosterForJob(excerptJobId) : null,
+ label: latestExcerpt.label || 'Latest excerpt',
+ };
+ }
+
+ // 3. Latest scene video clip
+ const scenes = Array.isArray(project.scenes) ? project.scenes : [];
+ for (let i = scenes.length - 1; i >= 0; i -= 1) {
+ const s = scenes[i];
+ const vidId = nonEmptyString(s?.videoHistoryId);
+ if (vidId) {
+ return {
+ kind: 'video',
+ jobId: vidId,
+ src: videoSrcForJob(vidId),
+ poster: videoPosterForJob(vidId),
+ label: `Scene ${i + 1} clip`,
+ };
+ }
+ }
+
+ // 4. Latest scene reference frame
+ for (let i = scenes.length - 1; i >= 0; i -= 1) {
+ const s = scenes[i];
+ const frameId = nonEmptyString(s?.referenceImageId);
+ if (frameId) {
+ return {
+ kind: 'image',
+ src: musicVideoImageSrc(frameId),
+ fallbackSrc: musicVideoImageFallback(frameId),
+ label: `Scene ${i + 1} frame`,
+ };
+ }
+ }
+
+ // 5. Visual specification references
+ const visualRefs = project.visualSpec?.references;
+ if (Array.isArray(visualRefs) && visualRefs.length > 0) {
+ const refId = nonEmptyString(visualRefs[0]?.imageId);
+ if (refId) {
+ return {
+ kind: 'image',
+ src: musicVideoImageSrc(refId),
+ fallbackSrc: musicVideoImageFallback(refId),
+ label: visualRefs[0].label || 'Style reference',
+ };
+ }
+ }
+
+ return none;
+}
diff --git a/client/src/lib/musicVideoPreview.test.js b/client/src/lib/musicVideoPreview.test.js
new file mode 100644
index 0000000000..a69260a134
--- /dev/null
+++ b/client/src/lib/musicVideoPreview.test.js
@@ -0,0 +1,108 @@
+import { describe, it, expect } from 'vitest';
+import { selectMusicVideoPreview, musicVideoImageSrc, musicVideoImageFallback } from './musicVideoPreview.js';
+
+describe('selectMusicVideoPreview', () => {
+ it('returns none for null or empty project', () => {
+ expect(selectMusicVideoPreview(null)).toEqual({ kind: 'none', label: 'No render yet' });
+ expect(selectMusicVideoPreview({})).toEqual({ kind: 'none', label: 'No render yet' });
+ });
+
+ it('selects final video render when renderHistoryId is set', () => {
+ const project = {
+ id: 'p1',
+ name: 'Test Project',
+ renderHistoryId: 'final-job-123',
+ };
+ const preview = selectMusicVideoPreview(project);
+ expect(preview).toEqual({
+ kind: 'video',
+ jobId: 'final-job-123',
+ src: '/data/videos/final-job-123.mp4',
+ poster: '/data/video-thumbnails/final-job-123.jpg',
+ label: 'Final video',
+ });
+ });
+
+ it('selects latest completed excerpt when no final render is present', () => {
+ const project = {
+ id: 'p1',
+ excerpts: [
+ { id: 'e1', status: 'failed', filename: 'fail.mp4' },
+ { id: 'e2', status: 'complete', filename: 'excerpt-2.mp4', jobId: 'job-e2', label: 'Bridge preview' },
+ ],
+ };
+ const preview = selectMusicVideoPreview(project);
+ expect(preview).toEqual({
+ kind: 'video',
+ jobId: 'job-e2',
+ src: '/data/videos/excerpt-2.mp4',
+ poster: '/data/video-thumbnails/job-e2.jpg',
+ label: 'Bridge preview',
+ });
+ });
+
+ it('selects latest rendered scene clip when no final render or excerpt exists', () => {
+ const project = {
+ id: 'p1',
+ scenes: [
+ { sceneId: 's1', videoHistoryId: 'vid-1' },
+ { sceneId: 's2', videoHistoryId: 'vid-2' },
+ { sceneId: 's3', videoHistoryId: null },
+ ],
+ };
+ const preview = selectMusicVideoPreview(project);
+ expect(preview).toEqual({
+ kind: 'video',
+ jobId: 'vid-2',
+ src: '/data/videos/vid-2.mp4',
+ poster: '/data/video-thumbnails/vid-2.jpg',
+ label: 'Scene 2 clip',
+ });
+ });
+
+ it('selects latest scene reference frame when no video render exists', () => {
+ const project = {
+ id: 'p1',
+ scenes: [
+ { sceneId: 's1', referenceImageId: 'frame-1.png' },
+ { sceneId: 's2', referenceImageId: 'frame-2.png' },
+ ],
+ };
+ const preview = selectMusicVideoPreview(project);
+ expect(preview).toEqual({
+ kind: 'image',
+ src: '/data/images/frame-2.png',
+ fallbackSrc: null,
+ label: 'Scene 2 frame',
+ });
+ });
+
+ it('selects visual spec reference when no scene frame or video exists', () => {
+ const project = {
+ id: 'p1',
+ visualSpec: {
+ references: [{ imageId: 'mood-board-ref', label: 'Cyberpunk street' }],
+ },
+ };
+ const preview = selectMusicVideoPreview(project);
+ expect(preview).toEqual({
+ kind: 'image',
+ src: '/data/images/mood-board-ref',
+ fallbackSrc: '/data/images/mood-board-ref.png',
+ label: 'Cyberpunk street',
+ });
+ });
+});
+
+describe('musicVideoImageSrc and fallback', () => {
+ it('handles absolute or schema urls', () => {
+ expect(musicVideoImageSrc('/custom/path.png')).toBe('/custom/path.png');
+ expect(musicVideoImageSrc('https://example.com/img.png')).toBe('https://example.com/img.png');
+ expect(musicVideoImageSrc('image.png')).toBe('/data/images/image.png');
+ });
+
+ it('supplies fallback when extension is absent', () => {
+ expect(musicVideoImageFallback('img')).toBe('/data/images/img.png');
+ expect(musicVideoImageFallback('img.png')).toBe(null);
+ });
+});
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 63ba4564af..db6f393eb3 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -59,6 +59,7 @@ import AutonomousRunPanel from '../components/musicVideo/AutonomousRunPanel.jsx'
import { automationDraftFrom, automationFromDraft } from '../lib/musicVideoAutomation.js';
import { listUniverseNames } from '../services/apiUniverseBuilder.js';
import MusicVideoLayout from '../components/musicVideo/MusicVideoLayout.jsx';
+import MusicVideoProjectCard from '../components/musicVideo/MusicVideoProjectCard.jsx';
import PreviewDock from '../components/musicVideo/PreviewDock.jsx';
import SetupStage from '../components/musicVideo/stages/SetupStage.jsx';
import CastSetsStage from '../components/musicVideo/stages/CastSetsStage.jsx';
@@ -132,7 +133,8 @@ export default function MusicVideo() {
const [compositionSavePending, setCompositionSavePending] = useState(0);
useEffect(() => { setStyleReferencesPending(false); }, [selectedId]);
const [planning, setPlanning] = useState(false);
- const [cloning, setCloning] = useState(false);
+ const [cloningId, setCloningId] = useState(null);
+ const cloning = !!cloningId;
const [importingLyrics, setImportingLyrics] = useState(false);
const [aligningLyrics, setAligningLyrics] = useState(false);
const [createOpen, setCreateOpen] = useState(false);
@@ -341,17 +343,21 @@ export default function MusicVideo() {
.catch((err) => toast.error(err?.message || 'Failed to delete project'));
};
- const handleClone = (options = {}) => {
- if (!selected || cloning) return;
- setCloning(true);
- cloneMusicVideoProject(selected.id, options, { silent: true })
+ const handleClone = (optionsOrTarget = {}, maybeOptions = {}) => {
+ const isTarget = optionsOrTarget && typeof optionsOrTarget.id === 'string';
+ const target = isTarget ? optionsOrTarget : selected;
+ const options = isTarget ? maybeOptions : (optionsOrTarget || {});
+
+ if (!target || cloningId) return;
+ setCloningId(target.id);
+ cloneMusicVideoProject(target.id, options, { silent: true })
.then((project) => {
setProjects((prev) => [...prev, project]);
navigate(`/music-video/${project.id}`);
toast.success(`Created ${project.name}`);
})
.catch((err) => toast.error(err?.message || 'Failed to clone project'))
- .finally(() => setCloning(false));
+ .finally(() => setCloningId(null));
};
// Resolves with the analyzed project, or null when analysis failed (toasted).
@@ -1046,24 +1052,60 @@ export default function MusicVideo() {
</p>
)}
{!selected && (loading || !routeProjectId) && (
- <div className="bg-port-card border border-port-border rounded-lg p-6 text-center">
- <p className="text-sm text-port-text-muted mb-3">Pick a project in the header, start a new one — seed a name, universe and board, choose the tools and a budget, and let autopilot churn — or go fully autonomous from a single prompt.</p>
- <div className="flex flex-wrap justify-center gap-2">
- <button
- type="button"
- onClick={() => setCreateOpen(true)}
- className="inline-flex items-center gap-1 bg-port-accent text-white rounded px-3 py-1.5 text-sm min-h-[44px] sm:min-h-0"
- >
- <Plus size={15} /> New music video
- </button>
- <button
- type="button"
- onClick={() => setAutonomousOpen(true)}
- className="inline-flex items-center gap-1 rounded border border-port-accent text-port-accent px-3 py-1.5 text-sm min-h-[44px] sm:min-h-0"
- >
- <Wand2 size={15} /> Autonomous
- </button>
+ <div className="space-y-6">
+ <div className="bg-port-card border border-port-border rounded-lg p-6 text-center">
+ <p className="text-sm text-port-text-muted mb-3">Pick a project in the header, start a new one — seed a name, universe and board, choose the tools and a budget, and let autopilot churn — or go fully autonomous from a single prompt.</p>
+ <div className="flex flex-wrap justify-center gap-2">
+ <button
+ type="button"
+ onClick={() => setCreateOpen(true)}
+ className="inline-flex items-center gap-1 bg-port-accent text-white rounded px-3 py-1.5 text-sm min-h-[44px] sm:min-h-0"
+ >
+ <Plus size={15} /> New music video
+ </button>
+ <button
+ type="button"
+ onClick={() => setAutonomousOpen(true)}
+ className="inline-flex items-center gap-1 rounded border border-port-accent text-port-accent px-3 py-1.5 text-sm min-h-[44px] sm:min-h-0"
+ >
+ <Wand2 size={15} /> Autonomous
+ </button>
+ </div>
</div>
+
+ {loading ? (
+ <div className="text-center py-8 text-sm text-port-text-muted">
+ Loading projects…
+ </div>
+ ) : projects.length === 0 ? (
+ <div className="text-center py-6 text-sm text-port-text-muted">
+ No music video projects yet. Create your first project above to get started.
+ </div>
+ ) : (
+ <div className="space-y-3">
+ <div className="flex items-center justify-between">
+ <h2 className="text-sm font-semibold uppercase tracking-wider text-port-text-muted">
+ Projects ({projects.length})
+ </h2>
+ </div>
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" data-testid="mv-project-grid">
+ {projects.map((project) => (
+ <MusicVideoProjectCard
+ key={project.id}
+ project={project}
+ trackLabel={trackName(project.trackId)}
+ onSelect={() => selectProject(project.id)}
+ onClone={(options) => handleClone(project, options)}
+ isConfirmingDelete={isConfirmingDelete(project.id)}
+ onRequestDelete={() => handleDeleteRequest(project.id)}
+ onConfirmDelete={() => confirmDelete(() => handleDelete(project.id))}
+ onCancelDelete={cancelDelete}
+ cloning={cloningId === project.id}
+ />
+ ))}
+ </div>
+ </div>
+ )}
</div>
)}
{selected && (
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index 8639b94ad1..446efeb4da 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -2280,3 +2280,101 @@ it('waits for a grade save before rendering and keeps the saved look when a late
await waitFor(() => expect(toast.error).toHaveBeenCalledWith('Grade save unavailable'));
expect(screen.getByLabelText('Default section look').value).toBe('teal-night');
});
+
+describe('MusicVideo main page project cards', () => {
+ it('renders richly detailed cards for each project below the new project card', async () => {
+ const projectWithRender = {
+ ...PROJECT_WITH_CLIP,
+ id: 'mv-render-1',
+ name: 'Electric Skyline',
+ status: 'complete',
+ renderHistoryId: 'rh-final-1',
+ audioAnalysis: { bpm: 124, durationSec: 210 },
+ videoSettings: { backend: 'fal', modelId: 'hunyuan_video', generationMode: 'image', audioReactiveLora: 'reactive.safetensors' },
+ concept: { universeId: 'cyber-tokyo', style: 'hyper-detailed synthwave' },
+ visualSpec: { palette: ['#ff0055', '#00ffee'], references: [] },
+ vocalStemFilename: 'electric-vocals.wav',
+ midiTranscription: 'electric-midi.mid',
+ };
+ listMusicVideoProjects.mockResolvedValueOnce([projectWithRender, PROJECT_NO_CLIP]);
+ renderMV();
+
+ // New project card exists
+ expect(await screen.findByRole('button', { name: /New music video/i })).toBeInTheDocument();
+
+ // Project cards grid exists below new project card
+ const grid = await screen.findByTestId('mv-project-grid');
+ expect(grid).toBeInTheDocument();
+
+ // Richly detailed cards rendered
+ expect(within(grid).getByText('Electric Skyline')).toBeInTheDocument();
+ expect(within(grid).getByText('No Clips')).toBeInTheDocument();
+
+ // Rich configuration options and status on Electric Skyline card
+ const card = screen.getByTestId('mv-project-card-mv-render-1');
+ expect(within(card).getByText('complete')).toBeInTheDocument();
+ expect(within(card).getByText('124 BPM')).toBeInTheDocument();
+ expect(within(card).getByText('fal')).toBeInTheDocument();
+ expect(within(card).getByText('hunyuan_video')).toBeInTheDocument();
+ expect(within(card).getByText('I2V')).toBeInTheDocument();
+ expect(within(card).getByText('Reactive')).toBeInTheDocument();
+ expect(within(card).getByText('Vocal Stem')).toBeInTheDocument();
+ expect(within(card).getByText('MIDI')).toBeInTheDocument();
+ expect(within(card).getByText('cyber-tokyo')).toBeInTheDocument();
+ expect(within(card).getByText(/hyper-detailed synthwave/i)).toBeInTheDocument();
+ expect(within(card).getByText('Final video')).toBeInTheDocument();
+ });
+
+ it('navigates to project when clicking Open on its card', async () => {
+ listMusicVideoProjects.mockResolvedValueOnce([PROJECT_WITH_CLIP]);
+ renderMV();
+
+ const card = await screen.findByTestId(`mv-project-card-${PROJECT_WITH_CLIP.id}`);
+ const openBtn = within(card).getByRole('button', { name: /^Open$/i });
+
+ await act(async () => {
+ fireEvent.click(openBtn);
+ });
+
+ // Navigates and loads the project board
+ expect(await screen.findByRole('heading', { level: 2, name: PROJECT_WITH_CLIP.name })).toBeInTheDocument();
+ });
+
+ it('handles forking a project directly from its card', async () => {
+ cloneMusicVideoProject.mockResolvedValueOnce({
+ ...PROJECT_WITH_CLIP,
+ id: 'mv-cloned-1',
+ name: 'Neon Run (v2)',
+ version: 2,
+ });
+ listMusicVideoProjects.mockResolvedValueOnce([PROJECT_WITH_CLIP]);
+ renderMV();
+
+ const card = await screen.findByTestId(`mv-project-card-${PROJECT_WITH_CLIP.id}`);
+
+ const forkBtn = within(card).getByRole('button', { name: /Fork/i });
+ await act(async () => {
+ fireEvent.click(forkBtn);
+ });
+ expect(cloneMusicVideoProject).toHaveBeenCalledWith(PROJECT_WITH_CLIP.id, {}, { silent: true });
+ });
+
+ it('handles deleting a project directly from its card with confirmation', async () => {
+ deleteMusicVideoProject.mockResolvedValueOnce({ ok: true });
+ listMusicVideoProjects.mockResolvedValueOnce([PROJECT_WITH_CLIP]);
+ renderMV();
+
+ const card = await screen.findByTestId(`mv-project-card-${PROJECT_WITH_CLIP.id}`);
+
+ const deleteBtn = within(card).getByRole('button', { name: `Delete project ${PROJECT_WITH_CLIP.name}` });
+ fireEvent.click(deleteBtn);
+ expect(within(card).getByText('Delete?')).toBeInTheDocument();
+
+ const confirmBtn = within(card).getByRole('button', { name: `Confirm delete project ${PROJECT_WITH_CLIP.name}` });
+ await act(async () => {
+ fireEvent.click(confirmBtn);
+ });
+ expect(deleteMusicVideoProject).toHaveBeenCalledWith(PROJECT_WITH_CLIP.id, { silent: true });
+ });
+});
+