[MOB] Fix mobile lineup tap skipping past target track#14217
Open
dylanjeffers wants to merge 2 commits intomainfrom
Open
[MOB] Fix mobile lineup tap skipping past target track#14217dylanjeffers wants to merge 2 commits intomainfrom
dylanjeffers wants to merge 2 commits intomainfrom
Conversation
handleQueueIdxChange polled for `queue.length > queueIndex` before calling skip, but handleQueueChange's middle-out enqueue grows the RNTP queue non-monotonically (append, then insert-at-0 to land prefix tracks). The poll could exit after the append phase — when the target slot was still occupied by a later track — so skip(queueIndex) landed on the track that would shortly be shifted by the pending insert-at-0. Tapping the second trending tile reproduced this: queue temporarily held [t1, t2], poll exited at length=2, skip(1) selected t2, then the prefix insert shifted t2 to position 2 (carrying the active marker), so the third track played. Track the in-flight handleQueueChange promise via queueSetupJobRef and await it at the top of handleQueueIdxChange. The defensive poll stays in place to cover the edge case where setup bails out (data not yet loaded) before populating the queue. https://claude.ai/code/session_0177nV8SgkRaPqCTSk1mv8q6
🦋 Changeset detectedLatest commit: 1a52670 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tapping the second tile on mobile trending starts buffering the second track and then jumps to the third track. Same off-by-one happens for any tap that lands on a non-zero
queueIndexagainst an empty/swapped RNTP queue.Root cause
handleQueueIdxChangepollsTrackPlayer.getQueue()untilqueue.length > queueIndex, then callsTrackPlayer.skip(queueIndex). ButhandleQueueChangebuilds the RNTP queue non-monotonically:add(firstTrack=t1)→ queue[t1]add(t2)at end → queue[t1, t2](length=2 already)add(t0, 0)→ queue[t0, t1, t2], active shifts to position 1The poll exits between steps 2 and 3, when the queue is
[t1, t2]. It skips to position 1, which ist2at that moment. Step 3 then insertst0at the front, shifting the active track from position 1 to position 2 — andt2plays.Fix
Track the in-flight
handleQueueChange()promise via a newqueueSetupJobRefand await it at the top ofhandleQueueIdxChangeso the active-index check happens against the final queue layout. The existing length poll stays as a defensive fallback for the case where setup bails out (e.g. dependency data not yet loaded) before populating the queue.Test plan
https://claude.ai/code/session_0177nV8SgkRaPqCTSk1mv8q6
Generated by Claude Code