Skip to content

fix: shuffle reorders the queue itself instead of using a parallel index map#14276

Merged
dylanjeffers merged 1 commit intomainfrom
claude/busy-maxwell-0cd9ed
May 8, 2026
Merged

fix: shuffle reorders the queue itself instead of using a parallel index map#14276
dylanjeffers merged 1 commit intomainfrom
claude/busy-maxwell-0cd9ed

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

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.

  • Before: state.queue always held the original order. A parallel shuffleOrder: number[] plus shuffleIndex tracked the shuffled traversal. Web's QueueTab and mobile's QueueDrawer rendered queue.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.
  • After: state.queue is 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 in shuffleOriginalQueue / shuffleOriginalIndices. Disabling shuffle restores the original order with the current track preserved at its original position. next / previous are simple index + 1 / index - 1 since the queue is already in playable order.
  • Mutations (addToQueue, playNext, removeFromQueue, appendPage, reorder, clearUpcoming) keep both the visible and original orders in sync.
  • Mobile AudioPlayer's auto-advance handler no longer needs a shuffle-specific branch — RNTP and redux indices align in all cases.

Test plan

  • Unit: 18 playback slice tests pass, covering shuffle enable/disable, next/previous, add/remove/reorder/appendPage during shuffle, and clearUpcoming
  • Manual: enable shuffle → play queue UI shows the same upcoming tracks that next/skip walks through
  • Manual: enable shuffle → skip a few tracks → disable shuffle → original order restored, current track stays current
  • Manual: enable shuffle → reorder a track via drag → that order is preserved while shuffle stays on
  • Manual mobile: enable shuffle → lock-screen "next track" art matches the next track that actually plays

🤖 Generated with Claude Code

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

changeset-bot Bot commented May 8, 2026

⚠️ No Changeset found

Latest commit: 441486e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-14276.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

@dylanjeffers dylanjeffers merged commit 3464d46 into main May 8, 2026
14 checks passed
@dylanjeffers dylanjeffers deleted the claude/busy-maxwell-0cd9ed branch May 8, 2026 00:21
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.

1 participant