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: music video project list sorts by recent, groups versions, filters by name and shows run state live (#10167)

Adam Eivy780e2ee16f8b
diff --git a/client/src/components/musicVideo/MusicVideoProjectCard.jsx b/client/src/components/musicVideo/MusicVideoProjectCard.jsx
index 8d75765e42..41b0f01684 100644
--- a/client/src/components/musicVideo/MusicVideoProjectCard.jsx
+++ b/client/src/components/musicVideo/MusicVideoProjectCard.jsx
@@ -1,11 +1,12 @@
import { useState, useEffect } from 'react';
-import { Film, Play, Music, Wand2, Sparkles, Copy, Trash2, ArrowUpRight } from 'lucide-react';
+import { Film, Play, Music, Wand2, Sparkles, Copy, Trash2, ArrowUpRight, ChevronLeft, ChevronRight } from 'lucide-react';
import MediaImage from '../MediaImage.jsx';
import ScenePreview from '../creative-director/ScenePreview.jsx';
import ConfirmButtonPair from '../ui/ConfirmButtonPair.jsx';
import { formatUsd } from '../../utils/formatters.js';
import { selectMusicVideoPreview } from '../../lib/musicVideoPreview.js';
import { useVideoFileSrc } from '../../hooks/useVideoFileSrc.js';
+import { projectRunPill } from '../../lib/musicVideoProjectList.js';
import { deriveStages, projectSpend, projectShotSummary, MUSIC_VIDEO_STAGES } from '../../lib/musicVideoStages.js';
export const STATUS_COLORS = {
@@ -17,6 +18,12 @@ export const STATUS_COLORS = {
failed: 'bg-port-error/30 text-port-error',
};
+const PILL_TONES = {
+ warn: 'bg-port-warning/30 text-port-warning',
+ ok: 'bg-port-success/30 text-port-success',
+ muted: 'bg-port-accent/30 text-port-accent',
+};
+
export default function MusicVideoProjectCard({
project,
trackLabel,
@@ -27,6 +34,9 @@ export default function MusicVideoProjectCard({
onConfirmDelete,
onCancelDelete,
cloning = false,
+ versionCount = 1,
+ versionIndex = 0,
+ onVersionStep,
}) {
const [playing, setPlaying] = useState(false);
const preview = selectMusicVideoPreview(project);
@@ -50,6 +60,7 @@ export default function MusicVideoProjectCard({
const currentStageObj = MUSIC_VIDEO_STAGES.find((s) => s.id === currentStageId);
const stageLabel = currentStageObj?.label || currentStageId;
+ const pill = projectRunPill(project);
const spend = projectSpend(project);
const audioTitle = trackLabel || project.uploadedAudioFilename || null;
const conceptText = project.concept?.style || project.concept?.prompt || null;
@@ -72,9 +83,34 @@ export default function MusicVideoProjectCard({
{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>
+ {versionCount > 1 ? (
+ <span className="flex items-center gap-0.5 text-[10px] px-1 py-0.5 rounded bg-port-border text-port-text-muted font-mono" data-testid={`mv-version-switcher-${project.id}`}>
+ <button
+ type="button"
+ onClick={() => onVersionStep?.(1)}
+ disabled={versionIndex >= versionCount - 1}
+ aria-label="Older version"
+ className="disabled:opacity-30"
+ ><ChevronLeft size={12} aria-hidden="true" /></button>
+ <span>v{project.version || 1} of {versionCount}</span>
+ <button
+ type="button"
+ onClick={() => onVersionStep?.(-1)}
+ disabled={versionIndex <= 0}
+ aria-label="Newer version"
+ className="disabled:opacity-30"
+ ><ChevronRight size={12} aria-hidden="true" /></button>
+ </span>
+ ) : (
+ <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>
+ )}
+ {pill && (
+ <span data-testid={`mv-run-pill-${project.id}`} className={`text-[10px] font-medium px-2 py-0.5 rounded ${PILL_TONES[pill.tone]}`}>
+ {pill.label}
+ </span>
+ )}
<span className={`text-[10px] font-medium px-2 py-0.5 rounded ${STATUS_COLORS[project.status] || 'bg-port-border'}`}>
{project.status}
</span>
diff --git a/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx b/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx
index 71cacdd51b..21c98d9d6b 100644
--- a/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx
+++ b/client/src/components/musicVideo/MusicVideoProjectCard.test.jsx
@@ -172,3 +172,22 @@ describe('MusicVideoProjectCard', () => {
expect(screen.getByText('No render preview yet')).toBeInTheDocument();
});
});
+
+describe('MusicVideoProjectCard run pill and version switcher', () => {
+ it('shows the run pill and steps through versions', () => {
+ const onVersionStep = vi.fn();
+ render(
+ <MusicVideoProjectCard
+ project={{ ...BASE_PROJECT, autonomousRun: { status: 'awaiting-approval', awaiting: 'lyrics' } }}
+ versionCount={3}
+ versionIndex={0}
+ onVersionStep={onVersionStep}
+ />,
+ );
+ expect(screen.getByTestId('mv-run-pill-mv-card-1').textContent).toBe('Needs you');
+ expect(screen.getByText('v2 of 3')).toBeTruthy();
+ fireEvent.click(screen.getByLabelText('Older version'));
+ expect(onVersionStep).toHaveBeenCalledWith(1);
+ expect(screen.getByLabelText('Newer version').disabled).toBe(true);
+ });
+});
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index 643dbf671f..918cb8d2f6 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -66,6 +66,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `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), `projectShotSummary(project)` (document shots or scene counts), `stageChecklist(stageId, project, readiness)` (what one stage tab still needs, with the open approval's reason and a scroll anchor), `projectServicesSummary(project)` (the saved image/video render services), `compareMusicVideoProjectsNewestFirst(a, b)` (sort projects newest created / updated first for project cards and pickers), and `currentProductionRun`; `productionReviewStopGuidance` separates current approval blockers from historical run stops. Used by `components/musicVideo/MusicVideoLayout.jsx` and `pages/MusicVideo.jsx`. |
| `musicVideoAttention.js` | Music Video "Needs attention" model (#9940): `deriveAttentionItems(project, live)` returns the banner rows for server-held states a client-orchestrated workflow can strand — an open/rendering revision, an interrupted Cast & Sets stage, a running auto-review waiting on its revised sections, a final render nobody is watching — derived from the persisted record so they survive a reload (healthy work this tab can see progressing is not flagged); `openRevisionOf(project)`; `ATTENTION_ANCHOR_ID` + `revealAttention()` scroll a refusal toast to the banner. Used by `components/musicVideo/NeedsAttentionBanner.jsx` and `pages/MusicVideo.jsx`. |
+| `musicVideoProjectList.js` | Music Video project index model (#10167): `projectRunPill(project)` (Running / Needs you / Interrupted / Done, from the same next-action and attention logic as the header), `groupMusicVideoProjects(projects, query)` (collapse forks under their root, newest version first, name filter, groups ordered by last touch), and `compareMusicVideoProjectsRecentlyTouched`. Used by `pages/MusicVideo.jsx` and `components/musicVideo/MusicVideoProjectCard.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 (including the Suno form options and `isSunoModelValid`) plus `autonomousStageRows(run)` and `isAutonomousLive(run)` for the run panel, and `autopilotDraftFromParams` / `autopilotParamsFromDraft` for the music-video-autopilot Schedule settings form. |
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index c85d3c2205..9bd55bebbf 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -76,6 +76,7 @@ export * from './musicVideoTakes.js';
export * from './musicVideoShotTiming.js';
export * from './musicVideoStages.js';
export * from './musicVideoAttention.js';
+export * from './musicVideoProjectList.js';
export * from './musicVideoUniverseRefs.js';
export * from './musicVideoAutomation.js';
export * from './musicVideoAutonomous.js';
diff --git a/client/src/lib/musicVideoProjectList.js b/client/src/lib/musicVideoProjectList.js
new file mode 100644
index 0000000000..8fac5c3369
--- /dev/null
+++ b/client/src/lib/musicVideoProjectList.js
@@ -0,0 +1,65 @@
+/**
+ * Music Video project index model (#10167): the card pill, version grouping,
+ * name filter and "recently touched" order. Pure; the pill reuses the same
+ * stage / next-action / attention derivations as the project header so a card
+ * and the header never disagree about whether a project needs the director.
+ */
+import { deriveStages, deriveNextAction, currentProductionRun } from './musicVideoStages.js';
+import { deriveAttentionItems } from './musicVideoAttention.js';
+
+const NEEDS_YOU_ACTIONS = new Set([
+ 'review-production', 'approve-cast-sets', 'resume-cast-sets', 'review-autonomous',
+ 'resume-autonomous', 'retry-autonomous', 'resume-production',
+]);
+const RUNNING_ACTIONS = new Set(['stop-production', 'busy', 'render-progress']);
+
+/** Run state for a project card: `{ id, label, tone }` or null when idle. */
+export function projectRunPill(project) {
+ if (!project) return null;
+ const interrupted = project.autonomousRun?.interrupted
+ || project.castAndSets?.interrupted
+ || currentProductionRun(project)?.interrupted;
+ if (interrupted) return { id: 'interrupted', label: 'Interrupted', tone: 'warn' };
+ const action = deriveNextAction(project);
+ if (deriveAttentionItems(project).length > 0 || NEEDS_YOU_ACTIONS.has(action?.id)) {
+ return { id: 'needs-you', label: 'Needs you', tone: 'warn' };
+ }
+ if (RUNNING_ACTIONS.has(action?.id) || project.status === 'rendering') {
+ return { id: 'running', label: 'Running', tone: 'muted' };
+ }
+ if (deriveStages(project).stages.every((s) => s.state === 'done')) {
+ return { id: 'done', label: 'Done', tone: 'ok' };
+ }
+ return null;
+}
+
+const touched = (p) => Date.parse(p?.updatedAt || p?.createdAt) || 0;
+
+/** Most recently updated first (created time breaks ties). */
+export function compareMusicVideoProjectsRecentlyTouched(a, b) {
+ return touched(b) - touched(a) || (Date.parse(b?.createdAt) || 0) - (Date.parse(a?.createdAt) || 0);
+}
+
+/**
+ * Collapse forks under their root project. Returns `[{ rootId, versions }]`
+ * ordered by the most recent touch of any version; `versions` is newest
+ * version first. A name `query` keeps only matching versions.
+ */
+export function groupMusicVideoProjects(projects, query = '') {
+ const needle = String(query || '').trim().toLowerCase();
+ const groups = new Map();
+ for (const project of Array.isArray(projects) ? projects : []) {
+ if (needle && !String(project.name || '').toLowerCase().includes(needle)) continue;
+ const rootId = project.rootProjectId || project.id;
+ if (!groups.has(rootId)) groups.set(rootId, []);
+ groups.get(rootId).push(project);
+ }
+ return [...groups.entries()]
+ .map(([rootId, versions]) => ({
+ rootId,
+ versions: versions.sort((a, b) => (b.version || 1) - (a.version || 1) || compareMusicVideoProjectsRecentlyTouched(a, b)),
+ touchedAt: Math.max(...versions.map(touched)),
+ }))
+ .sort((a, b) => b.touchedAt - a.touchedAt)
+ .map(({ rootId, versions }) => ({ rootId, versions }));
+}
diff --git a/client/src/lib/musicVideoProjectList.test.js b/client/src/lib/musicVideoProjectList.test.js
new file mode 100644
index 0000000000..833e1e0c07
--- /dev/null
+++ b/client/src/lib/musicVideoProjectList.test.js
@@ -0,0 +1,40 @@
+import { describe, it, expect } from 'vitest';
+import { groupMusicVideoProjects, projectRunPill, compareMusicVideoProjectsRecentlyTouched } from './musicVideoProjectList.js';
+
+describe('groupMusicVideoProjects', () => {
+ const projects = [
+ { id: 'a1', name: 'Alpha', version: 1, createdAt: '2026-01-01T00:00:00Z', updatedAt: '2026-01-02T00:00:00Z' },
+ { id: 'a2', name: 'Alpha v2', version: 2, rootProjectId: 'a1', createdAt: '2026-01-03T00:00:00Z', updatedAt: '2026-01-03T00:00:00Z' },
+ { id: 'b1', name: 'Beta', version: 1, createdAt: '2026-01-02T00:00:00Z', updatedAt: '2026-02-01T00:00:00Z' },
+ ];
+
+ it('collapses forks under their root, newest version first, and orders groups by last touch', () => {
+ const groups = groupMusicVideoProjects(projects);
+ expect(groups.map((g) => g.rootId)).toEqual(['b1', 'a1']);
+ expect(groups[1].versions.map((v) => v.id)).toEqual(['a2', 'a1']);
+ });
+
+ it('filters by name, keeping only matching versions', () => {
+ const groups = groupMusicVideoProjects(projects, ' v2 ');
+ expect(groups).toHaveLength(1);
+ expect(groups[0].versions.map((v) => v.id)).toEqual(['a2']);
+ });
+
+ it('sorts a background-updated project to the top', () => {
+ const touched = projects.map((p) => (p.id === 'a1' ? { ...p, updatedAt: '2026-03-01T00:00:00Z' } : p));
+ expect(groupMusicVideoProjects(touched)[0].rootId).toBe('a1');
+ expect(compareMusicVideoProjectsRecentlyTouched(touched[0], touched[2])).toBeLessThan(0);
+ });
+});
+
+describe('projectRunPill', () => {
+ it('reports interrupted, needs-you and running autonomous runs', () => {
+ expect(projectRunPill({ id: 'p', autonomousRun: { status: 'running', interrupted: true } }).id).toBe('interrupted');
+ expect(projectRunPill({ id: 'p', autonomousRun: { status: 'awaiting-approval', awaiting: 'lyrics' } }).id).toBe('needs-you');
+ expect(projectRunPill({ id: 'p', autonomousRun: { status: 'running', stage: 'lyrics' } }).id).toBe('running');
+ });
+
+ it('is null for an idle new project', () => {
+ expect(projectRunPill({ id: 'p', status: 'draft' })).toBeNull();
+ });
+});
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index f0b81d622d..3a1f9fbea4 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -4,6 +4,7 @@ import { useEffect, useState, useCallback, useMemo, useRef } from 'react';
import { useParams, useNavigate, useSearchParams, useLocation } from 'react-router';
import { Plus, Film, Copy, Trash2, Wand2, Pencil } from 'lucide-react';
import toast from '../components/ui/Toast';
+import socket from '../services/socket';
import ConfirmButtonPair from '../components/ui/ConfirmButtonPair';
import { useConfirmDelete } from '../hooks/useConfirmDelete';
import PageHeader from '../components/PageHeader';
@@ -85,6 +86,7 @@ import { deriveAttentionItems } from '../lib/musicVideoAttention.js';
import {
productionReviewStopGuidance, approvalSummary, deriveNextAction, deriveStages, projectShotSummary, describeProjectStatus, listPreviewSources, projectSpend, resolveStageParam, stageChecklist, compareMusicVideoProjectsNewestFirst,
} from '../lib/musicVideoStages.js';
+import { groupMusicVideoProjects } from '../lib/musicVideoProjectList.js';
import { AUTONOMOUS_STATUS_LABELS, AUTONOMOUS_VIEWABLE_STAGES } from '../lib/musicVideoAutonomous.js';
// Automation first: a new project defaults to autopilot with the free tools.
@@ -295,6 +297,25 @@ export default function MusicVideo() {
return next;
});
+ // Index: name filter lives in the URL (?q=); forks collapse under their root
+ // with a per-card version switcher; cards patch in place from run events.
+ const nameQuery = searchParams.get('q') || '';
+ const setNameQuery = (value) => setSearchParams((prev) => {
+ const next = new URLSearchParams(prev);
+ if (value) next.set('q', value); else next.delete('q');
+ return next;
+ }, { replace: true });
+ const projectGroups = useMemo(() => groupMusicVideoProjects(projects, nameQuery), [projects, nameQuery]);
+ const [pickedVersion, setPickedVersion] = useState({}); // rootId -> project id
+ useEffect(() => {
+ const onRunEvent = (data) => {
+ if (data?.project?.id) setProjects((prev) => prev.map((p) => (p.id === data.project.id ? data.project : p)));
+ };
+ const events = ['music-video:autonomous', 'music-video:production'];
+ events.forEach((e) => socket.on(e, onRunEvent));
+ return () => events.forEach((e) => socket.off(e, onRunEvent));
+ }, []);
+
// Preparation is already resolving the project's audio at kickoff;
// relinking the track now would leave the project pointing at a NEW track
// while the video that finishes rendering was produced from the OLD one.
@@ -1230,26 +1251,49 @@ export default function MusicVideo() {
</div>
) : (
<div className="space-y-3">
- <div className="flex items-center justify-between">
+ <div className="flex flex-wrap items-center justify-between gap-2">
<h2 className="text-sm font-semibold uppercase tracking-wider text-port-text-muted">
- Projects ({projects.length})
+ Projects ({projectGroups.length})
</h2>
+ <label htmlFor="mv-project-filter" className="sr-only">Filter projects by name</label>
+ <input
+ id="mv-project-filter"
+ type="search"
+ value={nameQuery}
+ onChange={(e) => setNameQuery(e.target.value)}
+ placeholder="Filter by name…"
+ className="min-w-0 w-full sm:w-64 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm"
+ />
</div>
+ {projectGroups.length === 0 && (
+ <p className="text-sm text-port-text-muted">No projects match &ldquo;{nameQuery}&rdquo;.</p>
+ )}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" data-testid="mv-project-grid">
- {sortedProjects.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}
- />
- ))}
+ {projectGroups.map(({ rootId, versions }) => {
+ const picked = versions.findIndex((v) => v.id === pickedVersion[rootId]);
+ const versionIndex = picked >= 0 ? picked : 0;
+ const project = versions[versionIndex];
+ return (
+ <MusicVideoProjectCard
+ key={rootId}
+ 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}
+ versionCount={versions.length}
+ versionIndex={versionIndex}
+ onVersionStep={(delta) => {
+ const target = versions[versionIndex + delta];
+ if (target) setPickedVersion((prev) => ({ ...prev, [rootId]: target.id }));
+ }}
+ />
+ );
+ })}
</div>
</div>
)}