From bb56269cd19e202eb0b9b51306b6824d4484ee54 Mon Sep 17 00:00:00 2001 From: Joshua Bassett Date: Mon, 30 Mar 2026 19:59:55 +1100 Subject: [PATCH] fix: prevent waveform seekbar flashing back to old position on seek When clicking/dragging the waveform seekbar, the playback position would briefly flash back to the previous position before snapping to the new one. The seek function optimistically updates the store with the target position immediately but debounces the actual audio_seek IPC call by 100ms. During that window, audio:progress events from the Rust backend continue to arrive carrying the old playback position, overwriting the optimistic update and causing the visual flash. The fix skips incoming audio:progress events while a seek debounce is pending, since the store already holds the correct target position. Once the debounce fires and audio_seek is sent to the backend, progress events resume normally. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/store/playerStore.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/store/playerStore.ts b/src/store/playerStore.ts index 00462676..5bb21c17 100644 --- a/src/store/playerStore.ts +++ b/src/store/playerStore.ts @@ -159,6 +159,11 @@ function handleAudioPlaying(_duration: number) { } function handleAudioProgress(current_time: number, duration: number) { + // While a seek is pending, the store already holds the optimistic target + // position. Accepting stale progress from the Rust engine would briefly + // snap the waveform back to the old position before the seek completes. + if (seekDebounce) return; + const store = usePlayerStore.getState(); const track = store.currentTrack; if (!track) return;