Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: preserve silent preview seek when loading paused (#11221)

Adam Eivy8ad60bfef450
diff --git a/client/src/components/musicVideo/CompositionPreviewPlayer.jsx b/client/src/components/musicVideo/CompositionPreviewPlayer.jsx
index cd68e9a5fd..d63b73ce49 100644
--- a/client/src/components/musicVideo/CompositionPreviewPlayer.jsx
+++ b/client/src/components/musicVideo/CompositionPreviewPlayer.jsx
@@ -53,6 +53,7 @@ export default function CompositionPreviewPlayer({ project, audioUrl, seekReques
const [t, setT] = useState(0);
const [playing, setPlaying] = useState(false);
const audioRef = useRef(null);
+ const wasPlaying = useRef(false);
const appliedSeek = useRef(null);
const filmLook = lyrics ? null : (project.filmLook ?? null);
const titleCard = useMemo(() => normalizeTitleCard(project.titleCard), [project.titleCard]);
@@ -99,7 +100,8 @@ export default function CompositionPreviewPlayer({ project, audioUrl, seekReques
// Pause/end repaints the current frame with the exact render filter.
useEffect(() => {
- if (!playing && preview.ready) seek(audioRef.current?.currentTime || 0);
+ if (wasPlaying.current && !playing && preview.ready) seek(audioRef.current?.currentTime || 0);
+ wasPlaying.current = playing;
}, [playing, preview.ready, seek]);
const togglePlay = () => {
diff --git a/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx b/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx
index 86c69c3e1d..4377060a63 100644
--- a/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx
+++ b/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx
@@ -199,17 +199,17 @@ describe('CompositionPreviewPlayer', () => {
});
it('seeks to each outside request once the preview knows its length, and follows the lyric line', async () => {
- const { rerender } = render(<CompositionPreviewPlayer project={project} audioUrl="/data/music/song.mp3" seekRequest={{ t: 2, n: 1 }} />);
+ const { rerender } = render(<CompositionPreviewPlayer project={project} audioUrl={null} seekRequest={{ t: 2, n: 1 }} />);
await waitFor(() => expect(screen.getByText('2.00s / 10.0s')).toBeTruthy());
expect(screen.getByTestId('preview-lyric')).toHaveTextContent('first line');
const seekAt = socket.emit.mock.calls.findIndex(([event, payload]) => event === 'generated-preview:seek' && payload.t === 2);
expect(seekAt).toBeGreaterThan(socket.emit.mock.calls.findIndex(([event]) => event === 'generated-preview:open'));
- rerender(<CompositionPreviewPlayer project={project} audioUrl="/data/music/song.mp3" seekRequest={{ t: 4.5, n: 2 }} />);
+ rerender(<CompositionPreviewPlayer project={project} audioUrl={null} seekRequest={{ t: 4.5, n: 2 }} />);
await waitFor(() => expect(screen.getByText('4.50s / 10.0s')).toBeTruthy());
expect(screen.getByTestId('preview-lyric')).toHaveTextContent('second line');
- rerender(<CompositionPreviewPlayer project={project} audioUrl="/data/music/song.mp3" seekRequest={{ t: 99, n: 3 }} />);
+ rerender(<CompositionPreviewPlayer project={project} audioUrl={null} seekRequest={{ t: 99, n: 3 }} />);
await waitFor(() => expect(screen.getByText(/^9\.9\ds \/ 10\.0s$/)).toBeTruthy());
});