Deluan 239d5d3975 fix(ui): prevent transient jump to wrong song on play (#5441 regression)
When playing a song, the web player would sometimes briefly skip to a
different song, attempt to play it, then snap back to the chosen track.

Root cause: the music player can emit a PLAYER_SYNC_QUEUE carrying its
previous (old) queue while it loads the newly selected one. Since #5441
widened reduceSyncQueue's hasPendingSwitch to keep playIndex alive
whenever clear=true, that stale list was adopted into state with
playIndex pointing at a track the user never chose. The library then
played that track for an instant before the correct queue settled.

Fix: when a switch is pending, only adopt a synced queue that actually
contains the pending track (state.queue[playIndex], matched by trackId).
A sync missing it is stale and is ignored, keeping the intended queue and
pending switch alive so the next, correct sync is adopted normally.
2026-06-27 11:01:59 -04:00
..