Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: confirm before a Music Video track change clears analysis, lyric timing, MIDI and vocal stem (#10145)
Adam Eivyfeb966ef240f
diff --git a/client/src/components/musicVideo/TrackPanel.jsx b/client/src/components/musicVideo/TrackPanel.jsxindex 20a8f35a68..ba0269793e 100644--- a/client/src/components/musicVideo/TrackPanel.jsx+++ b/client/src/components/musicVideo/TrackPanel.jsx@@ -1,3 +1,4 @@+import { useState } from 'react';import { Music, Download } from 'lucide-react';import toast from '../ui/Toast';import MidiVisualization from '../songs/MidiVisualization.jsx';@@ -8,6 +9,23 @@ import SoundBedControl from './SoundBedControl.jsx';import { trackSourceLabel } from '../../lib/trackProvenance.js';import { trackOptionLabels } from '../../utils/trackOptionLabels.js';+const hasTime = (e) => Number.isFinite(e?.startSec) || Number.isFinite(e?.endSec);++// What a track change would wipe from this project (mirrors the server's+// track-change invalidation in projectsLogic.js). Empty means nothing to lose.+function timedDataLabels(project) {+ const cues = project.lyricCues || [];+ const labels = [];+ if (project.audioAnalysis) labels.push('beat/tempo analysis');+ if (cues.some((c) => c.words?.length) || cues.some(hasTime) || (project.phrases || []).some(hasTime)) {+ labels.push('lyric and phrase timing (including word alignment)');+ }+ if (project.midiTranscription) labels.push('MIDI transcription');+ if (project.vocalStemFilename) labels.push('vocal stem');+ if ((project.scenes || []).some((s) => s.beatAligned)) labels.push('beat-aligned shot timing');+ return labels;+}+/*** The project's audio: pick an existing library track or import fresh audio from* YouTube (re-selecting either PATCHes the project's trackId), then preview and@@ -21,6 +39,18 @@ export default function TrackPanel({project, tracks, trackName, audioFilename, youtube,renderBound, midiBound, onChangeTrack, onProjectUpdated, separation = null,}) {+ // A pending change that would destroy timed data waits for explicit confirm.+ const [pending, setPending] = useState(null);+ const clearLabels = timedDataLabels(project);+ const requestChange = (change) => {+ if (clearLabels.length === 0) return runChange(change, {});+ setPending(change);+ };+ const runChange = (change, opts) => {+ setPending(null);+ if (change.kind === 'youtube') youtube.startEdit(project.id);+ else onChangeTrack(change.trackId, { ...opts, cleared: clearLabels });+ };const blockedMessage = renderBound? 'Wait for the current render to finish before changing the track': midiBound@@ -41,7 +71,7 @@ export default function TrackPanel({</span>)}<select value={project.trackId || ''} aria-label="Change track"- onChange={(e) => e.target.value && onChangeTrack(e.target.value)}+ onChange={(e) => e.target.value && requestChange({ kind: 'track', trackId: e.target.value })}disabled={youtube.editJob.active || renderBound || midiBound}title={blockedMessage || undefined}className="bg-port-bg border border-port-border rounded px-1.5 py-1 disabled:opacity-50 min-h-[44px] sm:min-h-0">@@ -56,11 +86,32 @@ export default function TrackPanel({toast.error(blockedMessage);return;}- youtube.startEdit(project.id);+ requestChange({ kind: 'youtube' });}}compact/></div>+ {pending && (+ <div role="alertdialog" aria-label="Confirm track change" className="mt-2 rounded border border-port-warning/50 bg-port-warning/10 p-2 text-xs space-y-2">+ <p>+ {pending.kind === 'youtube' ? 'Importing new audio' : 'Changing the track'} will clear: {clearLabels.join(', ')}. Lyric text and scenes are kept. You will need to re-run Analyze and Align words.+ </p>+ <div className="flex flex-wrap gap-2">+ <button type="button" onClick={() => runChange(pending, {})}+ className="min-h-[44px] sm:min-h-0 px-2 py-1 rounded bg-port-error text-white">+ {pending.kind === 'youtube' ? 'Import audio' : 'Change track'}+ </button>+ {pending.kind === 'track' && (+ <button type="button" onClick={() => runChange(pending, { fork: true })}+ className="min-h-[44px] sm:min-h-0 px-2 py-1 rounded border border-port-border text-port-accent">+ Fork & change track+ </button>+ )}+ <button type="button" onClick={() => setPending(null)}+ className="min-h-[44px] sm:min-h-0 px-2 py-1 rounded border border-port-border">Cancel</button>+ </div>+ </div>+ )}<VocalStemControlproject={project}hasAudio={Boolean(project.trackId || project.uploadedAudioFilename)}diff --git a/client/src/components/musicVideo/TrackSelectors.test.jsx b/client/src/components/musicVideo/TrackSelectors.test.jsxindex bc8dff8833..03a6a4a277 100644--- a/client/src/components/musicVideo/TrackSelectors.test.jsx+++ b/client/src/components/musicVideo/TrackSelectors.test.jsx@@ -70,7 +70,8 @@ describe('Music Video track choices', () => {expect(within(select).getByRole('option', { name: /\[b-123456\]$/ })).toHaveValue(tracks[1].id);expect(within(select).getByRole('option', { name: /No audio$/ })).toHaveValue('example-missing');fireEvent.change(select, { target: { value: tracks[1].id } });- expect(onChangeTrack).toHaveBeenCalledWith(tracks[1].id);+ fireEvent.click(screen.getByRole('button', { name: 'Change track' }));+ expect(onChangeTrack).toHaveBeenCalledWith(tracks[1].id, { cleared: ['beat/tempo analysis'] });expect(api.updateMusicVideoProject).not.toHaveBeenCalled();expect(youtube.startEdit).not.toHaveBeenCalled();rerender(<TrackPanel {...props} tracks={[...tracks].reverse()} renderBound />);@@ -78,6 +79,31 @@ describe('Music Video track choices', () => {for (const [id, label] of labels) expect(Array.from(select.options).find((option) => option.value === id)?.textContent).toBe(label);});+ // Uniquely catches a track pick silently wiping analysis/alignment/MIDI/stem.+ it('confirms before a track change that would clear timed data, and lets the user fork or cancel', () => {+ const onChangeTrack = vi.fn();+ const rich = { ...project, midiTranscription: { filename: 'x.mid' }, vocalStemFilename: 's.wav',+ lyricCues: [{ text: 'a', startSec: 1, endSec: 2 }] };+ const props = { project: rich, tracks, trackName, youtube, onChangeTrack, onProjectUpdated: vi.fn() };+ const { rerender } = render(<TrackPanel {...props} />);+ const select = screen.getByRole('combobox', { name: 'Change track' });+ fireEvent.change(select, { target: { value: tracks[1].id } });+ expect(onChangeTrack).not.toHaveBeenCalled();+ const dialog = screen.getByRole('alertdialog');+ for (const t of ['beat/tempo analysis', 'lyric and phrase timing', 'MIDI transcription', 'vocal stem']) {+ expect(dialog.textContent).toContain(t);+ }+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));+ expect(screen.queryByRole('alertdialog')).toBeNull();+ expect(onChangeTrack).not.toHaveBeenCalled();+ fireEvent.change(select, { target: { value: tracks[1].id } });+ fireEvent.click(screen.getByRole('button', { name: /Fork & change track/ }));+ expect(onChangeTrack).toHaveBeenCalledWith(tracks[1].id, expect.objectContaining({ fork: true }));+ rerender(<TrackPanel {...props} project={{ id: 'p', trackId: tracks[0].id }} />);+ fireEvent.change(select, { target: { value: tracks[1].id } });+ expect(onChangeTrack).toHaveBeenLastCalledWith(tracks[1].id, { cleared: [] });+ });+it('keeps timing revisions audio-only, excludes the current track, and waits for explicit preview', () => {render(<AudioTimingPanel project={project} tracks={tracks} onApplied={vi.fn()} />);fireEvent.click(screen.getByRole('button', { name: 'Preview audio timing revision' }));diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 83fdd5dd69..903fa4bd37 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -558,7 +558,7 @@ export default function MusicVideo() {// Re-point the selected project at a different library track (the detail// view's "Change track" picker — previously there was no way to relink a// project's audio after creation at all).- const handleChangeTrack = (trackId) => {+ const handleChangeTrack = (trackId, { fork = false, cleared = [] } = {}) => {if (!selected) return;if (renderTargetsSelected) {toast.error('Wait for the current render to finish before changing the track');@@ -572,8 +572,20 @@ export default function MusicVideo() {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))+ // Fork first so the original keeps its analysis/alignment; the new track is+ // applied to the fork only.+ const base = fork+ ? cloneMusicVideoProject(selected.id, {}, { silent: true })+ : Promise.resolve(selected);+ base+ .then((target) => updateMusicVideoProject(target.id, patch, { silent: true }).then((proj) => ({ proj, forked: target !== selected })))+ .then(({ proj, forked }) => {+ if (forked) {+ setProjects((prev) => [...prev, proj]);+ navigate(`/music-video/${proj.id}/setup`);+ } else replaceProject(proj);+ if (cleared.length > 0) toast.success('Track changed — re-run Analyze and Align words');+ }).catch((err) => toast.error(err?.message || 'Failed to change track'));};