fix: shuffle reorders the queue itself instead of using a parallel index map#14276
Merged
dylanjeffers merged 1 commit intomainfrom May 8, 2026
Merged
fix: shuffle reorders the queue itself instead of using a parallel index map#14276dylanjeffers merged 1 commit intomainfrom
dylanjeffers merged 1 commit intomainfrom
Conversation
…dex map Previously the playback queue stayed in original order while a parallel shuffleOrder/shuffleIndex pair tracked the shuffled traversal. The play queue UI and mobile track loader read the queue directly, so they showed and pre-loaded the wrong tracks whenever shuffle was on. The queue now holds the playable order directly — shuffled when shuffle is on. shuffleOriginalQueue/shuffleOriginalIndices keep the pre-shuffle order so disabling shuffle restores it with the current track preserved. Mutations during shuffle keep both views in sync. The mobile auto-advance handler no longer needs a shuffle-specific branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14276.audius.workers.dev Unique preview for this PR (deployed from this branch). |
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
The play queue UI was showing the wrong upcoming tracks when shuffle was enabled, because the queue and the shuffle order were stored separately and most consumers only read the queue.
state.queuealways held the original order. A parallelshuffleOrder: number[]plusshuffleIndextracked the shuffled traversal. Web'sQueueTaband mobile'sQueueDrawerrenderedqueue.slice(index + 1)(original-order), and mobile's RNTP queue was loaded in original order, so both UIs and the lock-screen pre-load were inconsistent with what would actually play next.state.queueis the playable order. When shuffle is enabled the queue is replaced with a shuffled copy (current track pinned at index 0) and the pre-shuffle order is captured inshuffleOriginalQueue/shuffleOriginalIndices. Disabling shuffle restores the original order with the current track preserved at its original position.next/previousare simpleindex + 1/index - 1since the queue is already in playable order.addToQueue,playNext,removeFromQueue,appendPage,reorder,clearUpcoming) keep both the visible and original orders in sync.AudioPlayer's auto-advance handler no longer needs a shuffle-specific branch — RNTP and redux indices align in all cases.Test plan
🤖 Generated with Claude Code