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
feat: order music video UI track-first and auto-read track lyrics and metadata
Adam Eivy36b323a4eff7
diff --git a/client/src/components/musicVideo/CreateProjectDrawer.jsx b/client/src/components/musicVideo/CreateProjectDrawer.jsxindex b38c6ba667..358cd41200 100644--- a/client/src/components/musicVideo/CreateProjectDrawer.jsx+++ b/client/src/components/musicVideo/CreateProjectDrawer.jsx@@ -1,8 +1,10 @@-import { Bot, Clapperboard, Plus } from 'lucide-react';+import { Bot, Clapperboard, Plus, Music, Sparkles, FileText, CheckCircle2 } from 'lucide-react';import Drawer from '../Drawer.jsx';import YoutubeImportControls from './YoutubeImportControls.jsx';import AutomationBriefFields from './AutomationBriefFields.jsx';import MoodBoardReferenceStrip from '../moodBoard/MoodBoardReferenceStrip.jsx';+import { trackSourceLabel } from '../../lib/trackProvenance.js';+import { formatDurationSec } from '../../utils/formatters.js';const inputClass = 'w-full min-w-0 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm';const MODES = [@@ -10,11 +12,31 @@ const MODES = [{ id: 'director', label: 'Director', icon: Clapperboard, hint: 'Build the scene board by hand' },];-// "New music video" drawer — automation first: name, audio, universe/board,-// then (autopilot) the tools, guidance and budget the agent works within.-// `universes` is null while the page's name list is still loading.+/**+ * "New music video" drawer — track-first workflow:+ * 1. Select the music track (or import from YouTube) — audio source for the video.+ * 2. Lyrics, concept, and style info are automatically read from the chosen track.+ * 3. Name, mode, universe/moodboard, and brief settings.+ */export default function CreateProjectDrawer({ open, onClose, form, onFormChange, tracks, universes, trackName, youtube, onSubmit, submitting }) {const autopilot = form.mode === 'autonomous';+ const selectedTrack = (tracks || []).find((t) => t.id === form.trackId) || null;+ const sourceLabel = trackSourceLabel(selectedTrack);++ const handleTrackChange = (trackId) => {+ const track = (tracks || []).find((t) => t.id === trackId);+ const patch = { trackId };+ if (track) {+ if (!form.name || (tracks || []).some((t) => t.title === form.name)) {+ if (track.title) patch.name = track.title;+ }+ }+ onFormChange(patch);+ };++ const lineCount = selectedTrack?.lyrics+ ? selectedTrack.lyrics.split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !/^\[[^\]]*\]$/.test(l)).length+ : 0;return (<Drawer@@ -22,11 +44,99 @@ export default function CreateProjectDrawer({ open, onClose, form, onFormChange,onClose={onClose}size="md"title="New music video"- subtitle={autopilot ? 'Seed it, choose tools and a budget, and let the agent churn' : 'Choose the audio now or attach it later'}+ subtitle={autopilot ? 'Select your track, choose tools and a budget, and let the agent churn' : 'Select your music track to start creating'}closeOnEsc={false}closeOnBackdrop={false}><form onSubmit={onSubmit} className="space-y-4">+ {/* 1. Track selection — first element in the creation flow */}+ <div className="space-y-2 bg-port-bg/40 border border-port-border rounded-lg p-3">+ <label htmlFor="mv-track" className="block text-xs font-medium text-port-text">+ Track <span className="text-port-text-muted font-normal">(music audio source)</span>+ </label>+ <select+ id="mv-track"+ value={form.trackId}+ onChange={(e) => handleTrackChange(e.target.value)}+ disabled={youtube.createJob.active}+ className={`${inputClass} disabled:opacity-50`}+ >+ <option value="">— choose from music library —</option>+ {(tracks || []).map((t) => (+ <option key={t.id} value={t.id}>+ {t.title || t.id}{t.artist ? ` · ${t.artist}` : ''}+ </option>+ ))}+ </select>++ <div>+ <span className="block text-xs text-port-text-muted mb-1">…or import audio from YouTube</span>+ <div className="flex gap-1">+ <YoutubeImportControls+ id="mv-yt-create"+ url={youtube.createUrl}+ onUrlChange={(e) => youtube.setCreateUrl(e.target.value)}+ job={youtube.createJob}+ onStart={youtube.startCreate}+ />+ </div>+ </div>++ {form.trackId && !youtube.createJob.active && (+ <div className="mt-2 pt-2 border-t border-port-border/60 text-xs space-y-1.5">+ <div className="flex flex-wrap items-center gap-1.5">+ <span className="font-medium text-port-text flex items-center gap-1">+ <Music size={13} className="text-port-accent" /> Track set: {trackName(form.trackId)}+ </span>+ {selectedTrack?.artist && (+ <span className="text-port-text-muted">by {selectedTrack.artist}</span>+ )}+ {sourceLabel && (+ <span className="px-1.5 py-0.5 rounded bg-port-border text-port-text-muted text-[10px]">+ {sourceLabel}+ </span>+ )}+ {selectedTrack?.durationSec && (+ <span className="text-port-text-muted">({formatDurationSec(selectedTrack.durationSec)})</span>+ )}+ </div>+ <div className="flex flex-wrap items-center gap-2 text-[11px] text-port-text-muted">+ {lineCount > 0 ? (+ <span className="inline-flex items-center gap-1 text-port-success bg-port-success/10 px-1.5 py-0.5 rounded">+ <CheckCircle2 size={11} /> {lineCount} lyric lines loaded+ </span>+ ) : (+ <span className="text-port-text-muted">No lyrics in track</span>+ )}+ {selectedTrack?.concept && (+ <span className="inline-flex items-center gap-1 text-port-accent bg-port-accent/10 px-1.5 py-0.5 rounded">+ <FileText size={11} /> Concept loaded+ </span>+ )}+ {selectedTrack?.prompt && (+ <span className="inline-flex items-center gap-1 text-port-accent bg-port-accent/10 px-1.5 py-0.5 rounded">+ <Sparkles size={11} /> Style prompt loaded+ </span>+ )}+ </div>+ </div>+ )}+ </div>++ {/* 2. Project Name */}+ <div>+ <label htmlFor="mv-name" className="block text-xs text-port-text-muted mb-1">Name</label>+ <input+ id="mv-name"+ value={form.name}+ onChange={(e) => onFormChange({ name: e.target.value })}+ placeholder="Project name"+ maxLength={200}+ className={inputClass}+ />+ </div>++ {/* 3. Mode Selection */}<div className="grid grid-cols-2 gap-2" role="radiogroup" aria-label="Mode">{MODES.map(({ id, label, icon: Icon, hint }) => (<button@@ -43,46 +153,22 @@ export default function CreateProjectDrawer({ open, onClose, form, onFormChange,))}</div>- <div>- <label htmlFor="mv-name" className="block text-xs text-port-text-muted mb-1">Name</label>- <input- id="mv-name" value={form.name} onChange={(e) => onFormChange({ name: e.target.value })}- placeholder="Project name" autoFocus maxLength={200}- className={inputClass}- />- </div>-- <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">- <div className="min-w-0">- <label htmlFor="mv-track" className="block text-xs text-port-text-muted mb-1">Track</label>- <select id="mv-track" value={form.trackId} onChange={(e) => onFormChange({ trackId: e.target.value })}- disabled={youtube.createJob.active}- className={`${inputClass} disabled:opacity-50`}>- <option value="">— attach later —</option>- {tracks.map((t) => <option key={t.id} value={t.id}>{t.title || t.id}</option>)}- </select>- </div>+ {/* 4. Universe & Mood Board */}+ <div className="grid grid-cols-1 gap-3"><div className="min-w-0"><label htmlFor="mv-universe" className="block text-xs text-port-text-muted mb-1">Universe</label>- <select id="mv-universe" value={form.universeId} onChange={(e) => onFormChange({ universeId: e.target.value })}- className={inputClass}>+ <select+ id="mv-universe"+ value={form.universeId}+ onChange={(e) => onFormChange({ universeId: e.target.value })}+ className={inputClass}+ ><option value="">{universes === null ? 'Loading…' : 'No universe'}</option>{(universes || []).map((u) => <option key={u.id} value={u.id}>{u.name}</option>)}</select></div></div>- <div>- <label htmlFor="mv-yt-create" className="block text-xs text-port-text-muted mb-1">…or import audio from YouTube</label>- <div className="flex gap-1">- <YoutubeImportControls- id="mv-yt-create" url={youtube.createUrl} onUrlChange={(e) => youtube.setCreateUrl(e.target.value)}- job={youtube.createJob} onStart={youtube.startCreate}- />- </div>- {form.trackId && !youtube.createJob.active && (- <p className="text-xs text-port-text-muted mt-1">Track set: {trackName(form.trackId)}</p>- )}- </div>+<MoodBoardReferenceStripstorageKey="mv-create"value={form.moodBoardId}@@ -90,6 +176,7 @@ export default function CreateProjectDrawer({ open, onClose, form, onFormChange,newBoardName={form.name.trim()}/>+ {/* 5. Autopilot Brief */}{autopilot && (<AutomationBriefFieldsidPrefix="mv-create"@@ -98,8 +185,12 @@ export default function CreateProjectDrawer({ open, onClose, form, onFormChange,/>)}- <button type="submit" disabled={youtube.createJob.active || submitting || !form.name.trim()}- className="w-full flex items-center justify-center gap-1 bg-port-accent text-white rounded px-2 py-1.5 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50">+ {/* 6. Submit Button */}+ <button+ type="submit"+ disabled={youtube.createJob.active || submitting || !form.name.trim()}+ className="w-full flex items-center justify-center gap-1 bg-port-accent text-white rounded px-2 py-1.5 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50"+ ><Plus size={16} /> {submitting ? 'Creating…' : (autopilot ? 'Create autopilot project' : 'Create')}</button></form>diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 4c68436cd1..10b1b7d499 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -133,7 +133,11 @@ export default function MusicVideo() {routeProjectId,navigate,onTrackImported: (track) => setTracks((prev) => [...prev, track]),- onCreateComplete: (track) => setForm((f) => ({ ...f, trackId: track.id })),+ onCreateComplete: (track) => setForm((f) => ({+ ...f,+ trackId: track.id,+ ...(!f.name || tracks.some((t) => t.title === f.name) ? { name: track.title || '' } : {}),+ })),onProjectUpdated: replaceProject,});const midi = useMusicVideoMidiJob({@@ -238,7 +242,7 @@ export default function MusicVideo() {}if (creating) return;setCreating(true);- // Only the ids go up: the server snapshots the universe/board style into the concept.+ // Only the ids go up: the server snapshots the universe/board style and track metadata into the concept.createMusicVideoProject({name: form.name.trim(),mode: form.mode,@@ -391,7 +395,15 @@ export default function MusicVideo() {toast.error('Wait for the current render to finish before changing the track');return;}- updateMusicVideoProject(selected.id, { trackId }, { silent: true })+ const selectedTrack = tracks.find((t) => t.id === trackId);+ const patch = { trackId };+ if (selectedTrack?.concept && !selected.concept?.prompt) {+ patch.concept = { ...(selected.concept || {}), prompt: selectedTrack.concept };+ }+ if (selectedTrack?.prompt && !selected.concept?.style) {+ patch.concept = { ...(patch.concept || selected.concept || {}), style: selectedTrack.prompt };+ }+ updateMusicVideoProject(selected.id, patch, { silent: true }).then((proj) => replaceProject(proj)).catch((err) => toast.error(err?.message || 'Failed to change track'));};@@ -743,8 +755,36 @@ export default function MusicVideo() {unaccepted — after download-time acknowledgement it staysoff the board. */}- {/* Concept & style — optional global direction for the whole video,- set before "AI Plan" (see commitConcept above for what reads it). */}+ {/* Track audio source is first in the edit workspace */}+ <TrackPanel+ project={selected}+ tracks={tracks}+ trackName={trackName}+ audioFilename={projectAudioFilename(selected)}+ youtube={youtube}+ renderBound={renderTargetsSelected}+ midiBound={midiTargetsSelected}+ onChangeTrack={handleChangeTrack}+ onProjectUpdated={replaceProject}+ />+ <AnalysisPanel+ audioAnalysis={selected.audioAnalysis}+ scenes={selected.scenes || []}+ tempo={tempo}+ onReanalyze={handleAnalyze}+ analyzing={analyzing}+ />+ <LyricsPanel+ project={selected}+ onEditLocal={editProjectLocal}+ onSave={saveProjectFields}+ onImport={handleImportLyrics}+ importing={importingLyrics}+ onAlign={handleAlignLyrics}+ aligning={aligningLyrics}+ />++ {/* Concept & style — global direction for the video */}<div className="mt-2 grid grid-cols-1 sm:grid-cols-2 gap-2"><div><label htmlFor="mv-concept" className="block text-xs text-port-text-muted mb-1">Concept</label>@@ -779,26 +819,19 @@ export default function MusicVideo() {onSave={saveVisualSpec}onAddReference={() => setPickerTarget({ type: 'reference' })}/>- <TreatmentPanel key={`treatment-${selected.id}`} project={selected} treatment={treatment} />- <HandoffControls- projectId={selected.id}- busy={takes.busy}- onExport={takes.exportHandoff}- onExportBundle={takes.exportHandoffBundle}- onImport={takes.importHandoffFiles}- onOpenContactSheet={() => setContactSheetOpen(true)}- />- <TrackPanel+ <TypographyPanelproject={selected}- tracks={tracks}- trackName={trackName}- audioFilename={projectAudioFilename(selected)}- youtube={youtube}- renderBound={renderTargetsSelected}- midiBound={midiTargetsSelected}- onChangeTrack={handleChangeTrack}- onProjectUpdated={replaceProject}+ onEditLocal={editProjectLocal}+ onSave={saveProjectFields}/>+ <TreatmentPanel key={`treatment-${selected.id}`} project={selected} treatment={treatment} />+ {selected.composition?.mode === 'code' && (+ <CodeVideoPanel+ project={selected}+ audioUrl={projectAudioFilename(selected) ? trackAudioUrl(projectAudioFilename(selected)) : null}+ onProject={replaceProject}+ />+ )}<RenderStatusPanelrendering={renderTargetsSelected}progress={renderJob.progress}@@ -823,33 +856,13 @@ export default function MusicVideo() {revision={{ ...revisions, genScenes: sceneMedia.genScenes, genVideoScenes: sceneMedia.genVideoScenes }}autoReview={autoReview}/>- <LyricsPanel- project={selected}- onEditLocal={editProjectLocal}- onSave={saveProjectFields}- onImport={handleImportLyrics}- importing={importingLyrics}- onAlign={handleAlignLyrics}- aligning={aligningLyrics}- />- <TypographyPanel- project={selected}- onEditLocal={editProjectLocal}- onSave={saveProjectFields}- />- {selected.composition?.mode === 'code' && (- <CodeVideoPanel- project={selected}- audioUrl={projectAudioFilename(selected) ? trackAudioUrl(projectAudioFilename(selected)) : null}- onProject={replaceProject}- />- )}- <AnalysisPanel- audioAnalysis={selected.audioAnalysis}- scenes={selected.scenes || []}- tempo={tempo}- onReanalyze={handleAnalyze}- analyzing={analyzing}+ <HandoffControls+ projectId={selected.id}+ busy={takes.busy}+ onExport={takes.exportHandoff}+ onExportBundle={takes.exportHandoffBundle}+ onImport={takes.importHandoffFiles}+ onOpenContactSheet={() => setContactSheetOpen(true)}/></div>diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsxindex 2a0c9aef11..e8dcfcbf84 100644--- a/client/src/pages/MusicVideo.test.jsx+++ b/client/src/pages/MusicVideo.test.jsx@@ -1393,6 +1393,64 @@ describe('MusicVideo YouTube audio import (#1945)', () => {});});+ it('selects track first in create drawer, auto-fills name, reads track metadata, and passes concept/style on create', async () => {+ listMusicVideoProjects.mockResolvedValue([]);+ listTracks.mockResolvedValue([{+ id: 'track-cool',+ title: 'Neon Horizon',+ artist: 'SynthWave Artist',+ lyrics: 'Line 1\nLine 2\nLine 3',+ concept: 'Futuristic city chase',+ prompt: 'Cyberpunk neon aesthetics',+ durationSec: 180,+ }]);+ createMusicVideoProject.mockResolvedValue({ ...PROJECT_NO_CLIP, id: 'mv-cool', name: 'Neon Horizon' });+ renderMV();+ await openCreateForm();++ const trackSelect = await screen.findByLabelText(/Track/i);+ fireEvent.change(trackSelect, { target: { value: 'track-cool' } });++ // Project name was auto-filled from track title+ expect(screen.getByPlaceholderText('Project name')).toHaveValue('Neon Horizon');+ // Track info badge showing lyrics and concept detected+ expect(screen.getByText(/3 lyric lines loaded/i)).toBeInTheDocument();+ expect(screen.getByText(/Concept loaded/i)).toBeInTheDocument();+ expect(screen.getByText(/Style prompt loaded/i)).toBeInTheDocument();++ fireEvent.click(screen.getByRole('button', { name: /Create/ }));+ await waitFor(() => expect(createMusicVideoProject).toHaveBeenCalled());+ const [body] = createMusicVideoProject.mock.calls[0];+ expect(body).toMatchObject({+ name: 'Neon Horizon',+ trackId: 'track-cool',+ });+ });++ it('changing a track in the edit view auto-seeds track concept and style if not set', async () => {+ const project = { ...PROJECT_NO_CLIP, trackId: null, concept: null };+ listTracks.mockResolvedValue([{+ id: 'track-new',+ title: 'Solar Flare',+ concept: 'Space journey',+ prompt: 'Cosmic sci-fi',+ }]);+ updateMusicVideoProject.mockResolvedValue({ ...project, trackId: 'track-new', concept: { prompt: 'Space journey', style: 'Cosmic sci-fi' } });+ await openProject(project);++ const changeTrackSelect = screen.getByLabelText('Change track');+ fireEvent.change(changeTrackSelect, { target: { value: 'track-new' } });++ await waitFor(() => expect(updateMusicVideoProject).toHaveBeenCalledWith(+ project.id,+ {+ trackId: 'track-new',+ concept: { prompt: 'Space journey', style: 'Cosmic sci-fi' },+ },+ { silent: true },+ ));+ });+it('autopilot kickoff analyzes the song, then plans the shots against the brief', async () => {const project = { ...PROJECT_NO_CLIP, scenes: [], automation: { tools: ['image:local'], guidance: 'noir', budgetUsd: null } };analyzeMusicVideoProject.mockResolvedValue({ ...project, audioAnalysis: PROJECT_ANALYZED.audioAnalysis, status: 'analyzed' });diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.jsindex 1f0dafdab4..b3d0b106a7 100644--- a/server/lib/musicVideoValidation.js+++ b/server/lib/musicVideoValidation.js@@ -532,6 +532,11 @@ export const musicVideoProjectCreateSchema = z.object({visualSpec: musicVideoVisualSpecSchema.optional(),videoSettings: musicVideoVideoSettingsSchema.optional(),automation: musicVideoAutomationSchema.nullable().optional(),+ lyricCues: lyricCueList.optional(),+ phrases: phraseList.optional(),+ pacing: musicVideoPacingSchema.nullable().optional(),+ composition: musicVideoCompositionSchema.nullable().optional(),+ soundBed: musicVideoSoundBedSchema.nullable().optional(),}).strict();export const musicVideoProjectUpdateSchema = z.object({diff --git a/server/services/musicVideo/projects.js b/server/services/musicVideo/projects.jsindex f2308027e4..2fb06799e9 100644--- a/server/services/musicVideo/projects.js+++ b/server/services/musicVideo/projects.js@@ -73,6 +73,9 @@ export async function listProjectIds(options = {}) {// clip render (an explicit `body.backend`), so a target/install video pin can// only take effect HERE, at record creation — the same explicit-body seeding// trap the universe batch form and sprites page picker hit on the image side.+import { getTrack } from '../tracks/index.js';+import { parseLyricCues } from './timedText.js';+// resolveVideoMode usability-gates the pin (a disabled grok pin seeds local);// an input that names a backend explicitly wins untouched.async function seedVideoBackendDefault(input) {@@ -85,8 +88,73 @@ async function seedVideoBackendDefault(input) {return { ...input, videoSettings: { ...(input?.videoSettings || {}), backend } };}+// Automatically read lyrics and creative context from the linked music track+// in the music creation system when creating a project.+async function seedTrackMetadata(input) {+ if (!input?.trackId) return input;+ const track = await getTrack(input.trackId).catch(() => null);+ if (!track) return input;+ let lyricCues = input.lyricCues;+ if ((!lyricCues || lyricCues.length === 0) && track.lyrics) {+ const parsed = parseLyricCues(track.lyrics);+ if (parsed.cues && parsed.cues.length > 0) {+ lyricCues = parsed.cues;+ }+ }+ let name = input.name;+ if (!name && track.title) {+ name = track.title;+ }+ let concept = input.concept;+ if (track.concept || track.prompt) {+ concept = {+ ...(concept || {}),+ ...(track.concept && !concept?.prompt ? { prompt: track.concept } : {}),+ ...(track.prompt && !concept?.style ? { style: track.prompt } : {}),+ };+ }+ return {+ ...input,+ ...(name ? { name } : {}),+ ...(lyricCues ? { lyricCues } : {}),+ ...(concept ? { concept } : {}),+ };+}++// Automatically read lyrics and creative context when the project's track is changed.+async function seedTrackMetadataOnUpdate(id, patch) {+ if (!patch?.trackId) return patch;+ const project = await getProject(id).catch(() => null);+ if (!project || project.trackId === patch.trackId) return patch;+ const track = await getTrack(patch.trackId).catch(() => null);+ if (!track) return patch;+ let lyricCues = patch.lyricCues;+ if (!lyricCues && track.lyrics) {+ const parsed = parseLyricCues(track.lyrics);+ if (parsed.cues && parsed.cues.length > 0) {+ lyricCues = parsed.cues;+ }+ }+ let concept = patch.concept;+ if ((track.concept && !project.concept?.prompt) || (track.prompt && !project.concept?.style)) {+ concept = {+ ...(project.concept || {}),+ ...(concept || {}),+ ...(track.concept && !project.concept?.prompt && !concept?.prompt ? { prompt: track.concept } : {}),+ ...(track.prompt && !project.concept?.style && !concept?.style ? { style: track.prompt } : {}),+ };+ }+ return {+ ...patch,+ ...(lyricCues ? { lyricCues } : {}),+ ...(concept ? { concept } : {}),+ };+}+export async function createProject(input) {- const project = await (await selectBackend()).createProject(await withStyleSnapshots(await seedVideoBackendDefault(input)));+ const seeded = await seedTrackMetadata(await seedVideoBackendDefault(input));+ const snapshotted = await withStyleSnapshots(seeded);+ const project = await (await selectBackend()).createProject(snapshotted);announceNewProject(project.id);return project;}@@ -99,8 +167,9 @@ export async function cloneProject(id, options = {}) {export async function updateProject(id, patch) {const backend = await selectBackend();- const needsSnapshot = patch?.concept?.universeId !== undefined || patch?.visualSpec?.moodBoardId !== undefined;- const resolved = needsSnapshot ? await withStyleSnapshots(patch, await backend.getProject(id)) : patch;+ const seeded = await seedTrackMetadataOnUpdate(id, patch);+ const needsSnapshot = seeded?.concept?.universeId !== undefined || seeded?.visualSpec?.moodBoardId !== undefined;+ const resolved = needsSnapshot ? await withStyleSnapshots(seeded, await backend.getProject(id)) : seeded;const next = await backend.updateProject(id, resolved);emitRecordUpdated('musicVideoProject', id);return next;diff --git a/server/services/musicVideo/projects.test.js b/server/services/musicVideo/projects.test.jsindex 04d767621d..1e2d434659 100644--- a/server/services/musicVideo/projects.test.js+++ b/server/services/musicVideo/projects.test.js@@ -32,6 +32,9 @@ vi.mock('../sharing/recordEvents.js', () => ({const getSettings = vi.fn(async () => ({}));vi.mock('../settings.js', () => ({ getSettings: (...a) => getSettings(...a) }));+const getTrack = vi.fn(async () => null);+vi.mock('../tracks/index.js', () => ({ getTrack: (...a) => getTrack(...a) }));+const projects = await import('./projects.js');function reset() {@@ -41,6 +44,8 @@ function reset() {autoSubscribeRecordToAllPeers.mockClear();getSettings.mockClear();getSettings.mockResolvedValue({});+ getTrack.mockClear();+ getTrack.mockResolvedValue(null);}beforeEach(reset);afterAll(() => rmSync(TEST_DATA_ROOT, { recursive: true, force: true }));@@ -139,3 +144,78 @@ describe('create-time video-backend seeding (#3231 Phase 4)', () => {expect(p.videoSettings.backend).toBe('local');});});++describe('track metadata and lyrics auto-reading on create and update', () => {+ it('automatically reads lyrics, concept, prompt, and title from linked track at creation', async () => {+ getTrack.mockResolvedValue({+ id: 'track-1',+ title: 'Midnight Echoes',+ lyrics: '[00:01.00] Echoes in the dark\n[00:04.00] Shining like a spark',+ concept: 'A cyberpunk nocturnal story',+ prompt: 'Neon noir 80s anime style',+ });++ const project = await projects.createProject({ trackId: 'track-1' });++ expect(project.name).toBe('Midnight Echoes');+ expect(project.lyricCues).toHaveLength(2);+ expect(project.lyricCues[0].text).toBe('Echoes in the dark');+ expect(project.lyricCues[1].text).toBe('Shining like a spark');+ expect(project.concept).toMatchObject({+ prompt: 'A cyberpunk nocturnal story',+ style: 'Neon noir 80s anime style',+ });+ });++ it('preserves explicitly authored project fields over track defaults at creation', async () => {+ getTrack.mockResolvedValue({+ id: 'track-1',+ title: 'Midnight Echoes',+ lyrics: 'Line from track',+ concept: 'Track concept',+ prompt: 'Track style',+ });++ const project = await projects.createProject({+ name: 'Custom Name',+ trackId: 'track-1',+ lyricCues: [{ text: 'Custom cue' }],+ concept: { prompt: 'Custom concept', style: 'Custom style' },+ });++ expect(project.name).toBe('Custom Name');+ expect(project.lyricCues).toHaveLength(1);+ expect(project.lyricCues[0].text).toBe('Custom cue');+ expect(project.concept).toMatchObject({+ prompt: 'Custom concept',+ style: 'Custom style',+ });+ });++ it('automatically reads lyrics and concept when changing track via updateProject', async () => {+ getTrack.mockImplementation(async (id) => {+ if (id === 'track-2') {+ return {+ id: 'track-2',+ title: 'Morning Sun',+ lyrics: 'Golden light breaks through',+ concept: 'Dawn over the horizon',+ prompt: 'Impressionist pastel colors',+ };+ }+ return null;+ });++ const project = await projects.createProject({ name: 'Initial Project' });+ const updated = await projects.updateProject(project.id, { trackId: 'track-2' });++ expect(updated.trackId).toBe('track-2');+ expect(updated.lyricCues).toHaveLength(1);+ expect(updated.lyricCues[0].text).toBe('Golden light breaks through');+ expect(updated.concept).toMatchObject({+ prompt: 'Dawn over the horizon',+ style: 'Impressionist pastel colors',+ });+ });+});+diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.jsindex de84ebae57..d61e7751f6 100644--- a/server/services/musicVideo/projectsLogic.js+++ b/server/services/musicVideo/projectsLogic.js@@ -136,11 +136,13 @@ export function buildProjectRecord(input, { id, now }) {midiTranscription: null,// #8964 — editable timed lyric cues + phrase annotations (timed against// the current audio source) and the shot planner's pacing range.- lyricCues: [],- phrases: [],- pacing: null,+ lyricCues: Array.isArray(input.lyricCues) ? normalizeLyricCues(input.lyricCues) : [],+ phrases: Array.isArray(input.phrases) ? normalizePhrases(input.phrases) : [],+ pacing: input.pacing ?? null,// #8984 — composition manifest (null = plain concatenation render).- composition: null,+ composition: input.composition ? normalizeComposition(input.composition) : null,+ // #8988 — optional sound-design bed mixed under the song.+ soundBed: input.soundBed ? normalizeSoundBed(input.soundBed) : null,// #8980 — optional pre-production treatment (brief, arc, shot direction,// proof checklist); null until the director starts one. See treatment.js.treatment: null,