Skip to content

feat(gui): play the shown songs in a random order from the Shuffle button - #864

Merged
LargeModGames merged 1 commit into
LargeModGames:mainfrom
niukanen1:gui-shuffle-841
Oct 16, 2026
Merged

LargeModGames merged 1 commit into
LargeModGames:mainfrom
niukanen1:gui-shuffle-841

Conversation

@niukanen1

@niukanen1 niukanen1 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Which Issue Fixes

Fixes #841

Brief Description

The Shuffle button next to Play on Liked Songs and playlist pages was a placeholder: it was hard-coded disabled with no handler. It now plays the songs the page shows in a random order, only the matching rows when a filter is active.

shufflePlayRequest in gui/src/sortModel.ts collects the shown rows' URIs (skipping rows without one), shuffles them with Fisher-Yates, and returns a PlayUris action with offset: 0. The random function is a parameter so tests can pin the order. The button mirrors the Play button's enabled state (first < 0) and is labelled Shuffle ${title} to tell it apart from the player bar's shuffle toggle. No SetShuffle is sent: that acts on whatever is playing now, while this starts a new order for the list you are looking at.

No Rust change: PlayUris already routes through start_playback_uris, which keeps the existing 100-URI server-side window on Spotify and plays one random song on Apple Music, same as Play after a sort or filter.

How Did You Test

  • New shufflePlayRequest tests in gui/src/sortModel.test.ts: pinned orders for () => 0 and () => 0.999, no request when no shown row has a URI, single song and duplicate URIs kept, the caller's rows are not reordered, a URI of any source is kept, and a 101-URI list passes through whole (the window is the server's job).
  • New button tests in gui/src/listPage.test.tsx: enabled with aria-label="Shuffle Liked Songs" once the list shows a playable song, disabled while a playlist is still loading.
  • npm run lint, npm run format:check, npm run typecheck, npm test (407 passed), npm run build all pass in gui/.
  • Playwright chromium shots 42 passed; shots/chromium/library-playlist.png attached shows the page with the button in place.
  • Not checked by hand in the running app.

Shuffle button on the playlist page

Summary by CodeRabbit

  • New Features
    • Shuffle on Liked Songs and playlist pages now plays the displayed playable songs in random order. When a filter is active, Shuffle plays only the matching songs.
    • Available in both the desktop app and browser interface.

…tton

The Shuffle button next to Play on Liked Songs and playlist pages was a
placeholder that stayed disabled. It now sends a PlayUris action with the
shown rows' URIs shuffled by Fisher-Yates, so it plays what the page shows,
including the rows a filter narrowed it to. The random function is a
parameter so tests can pin the order.

Fixes LargeModGames#841
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30d63012-c04f-4d9e-a033-84afc7347298
📥 Commits

Reviewing files that changed from the base of the PR and between e6d22a7 and 190c7f4.

📒 Files selected for processing: 5
  • CHANGELOG.md
  • gui/src/ListPage.tsx
  • gui/src/listPage.test.tsx
  • gui/src/sortModel.test.ts
  • gui/src/sortModel.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The GUI now shuffles displayed tracks with playable URIs and sends them as a play request. The list-page button includes the list title in its accessible label and is disabled when the page has no first row.

Changes: GUI Shuffle playback

Layer / File(s) Summary
Build shuffled playback requests
gui/src/sortModel.ts, gui/src/sortModel.test.ts
shufflePlayRequest filters out tracks without URIs, shuffles the remaining URIs, and returns a PlayUris action or null. Tests cover shuffled order, empty results, duplicate URIs, and input preservation.
Connect Shuffle to list pages
gui/src/ListPage.tsx, gui/src/listPage.test.tsx, CHANGELOG.md
The list-page Shuffle button builds a request from displayed tracks and sends it when one is available. Tests cover its label and enabled state. The changelog records the Shuffle behavior for liked songs and playlists.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 190c7

Shuffle is ready to merge after normal checks; no actionable issue remains.

Pre-merge checks: Passed 4
Check name Status Explanation
Linked Issues check Passed Issue #841 requires Shuffle for Liked Songs, playlists, and Local Files folders. ListPage serves Liked Songs and every playlist view, including non-Spotify source playlists. The button uses `shown…
Out of Scope Changes check Passed The reported changes are limited to gui/src and CHANGELOG.md, which matches issue #841. The implementation, tests, and changelog entry directly support the Shuffle objective. No Rust, generated bi…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the valid conventional-commit prefix feat(gui):, clearly describes the Shuffle button change, and uses an imperative subject.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
✨ Simplify code
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LargeModGames
LargeModGames merged commit 7e78483 into LargeModGames:main Oct 16, 2026
32 checks passed
kapok-4o pushed a commit to kapok-4o/spotatui that referenced this pull request Oct 16, 2026
Route the two strings main added through the table: the Shuffle button's label (gui.shuffle_named, LargeModGames#864) and the missing ALSA default device hint (status.app.audio_backend_no_alsa_default, LargeModGames#861). Add generated_name to the PlaylistInfo built by the LargeModGames#859 test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GUI: make the Shuffle button on Liked Songs and playlist pages work

2 participants