Skip to content

[MOB] Fix mobile lineup tap skipping past target track#14217

Open
dylanjeffers wants to merge 2 commits intomainfrom
claude/fix-mobile-track-selection-nvXYI
Open

[MOB] Fix mobile lineup tap skipping past target track#14217
dylanjeffers wants to merge 2 commits intomainfrom
claude/fix-mobile-track-selection-nvXYI

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

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 queueIndex against an empty/swapped RNTP queue.

Root cause

handleQueueIdxChange polls TrackPlayer.getQueue() until queue.length > queueIndex, then calls TrackPlayer.skip(queueIndex). But handleQueueChange builds the RNTP queue non-monotonically:

  1. add(firstTrack=t1) → queue [t1]
  2. add(t2) at end → queue [t1, t2] (length=2 already)
  3. add(t0, 0) → queue [t0, t1, t2], active shifts to position 1

The poll exits between steps 2 and 3, when the queue is [t1, t2]. It skips to position 1, which is t2 at that moment. Step 3 then inserts t0 at the front, shifting the active track from position 1 to position 2 — and t2 plays.

Fix

Track the in-flight handleQueueChange() promise via a new queueSetupJobRef and await it at the top of handleQueueIdxChange so 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

  • On iOS and Android, open Trending (Week / Month / All Time) and tap the 2nd tile — the second track should buffer and play (no skip to third)
  • Tap the 3rd, 5th, and 10th tiles cold (no prior playback) — each should play the tapped track
  • While a track is already playing, tap a different tile in the same lineup — new track plays, no skip
  • Tap "next" rapidly during the first ~5s after a fresh tap — verify the linked-issue fix (QA-2255) still works (no stuck-on-first-track)
  • Switch between trending tabs and tap mid-list tiles — verify queue setup completes before skip lands

https://claude.ai/code/session_0177nV8SgkRaPqCTSk1mv8q6


Generated by Claude Code

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-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

🦋 Changeset detected

Latest commit: 1a52670

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@audius/mobile Patch

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants