You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closes#657. The Spotify playlists sidebar can now be sorted three ways: Spotify (the rootlist order, the default and today's behavior), Recently played and Name. This follows the approach from the issue thread: Recently played comes from spotatui's own listening history, since the Web API has no per-playlist "last played".
Recently played orders playlists by the latest ListenRecord whose context_uri is that playlist. The history collector builds this map in the background read it already does for the streak cache (src/infra/history.rs) and updates it on each new listen, so no frame waits on the file. Playlists never played in spotatui follow in rootlist order.
Name is case-insensitive; ties keep rootlist order.
Folders are not flattened: a folder keeps its slot and only the playlists around it (at each level) are reordered. The community pin stays first. The cursor stays on the same row when the order changes or new listens arrive.
TUI: , in the playlists sidebar opens the existing sort menu with a new SidebarPlaylists context (src/core/sort.rs); a help row is added with the Spotify requirement. On macOS a plain , there sorts instead of opening settings, as it already does in the track table and album list.
GUI: a sort choice in the playlists section of Your Library (gui/src/LibraryPanel.tsx), with keyboard focus kept across a reorder.
The choice is saved as a sparse playlist_sidebar_order patch in state.yml; a missing or older file means Spotify order.
Strings in EN, zh-Hans and zh-Hant; bindings regenerated.
Testing
cargo fmt --all --check: clean
cargo clippy --locked -- -D warnings, with telemetry,tui, and with the gui leg's features: clean
cargo test --locked --no-default-features --features telemetry,tui: 1942 passed, 0 failed
cargo test with the gui leg's features: protocol tests 76 passed; typescript_bindings_are_written passed, no diff
desktop/: clippy clean, 7 tests passed
gui/: lint, format:check, typecheck, test (609 passed), build, and the Playwright scenes for sidebar reordering and the three languages in Chromium
New tests cover the ordering function (folders, pin, never-played tail, stable name ties), the history map, the state.yml round trip and older files, the sort menu keys, the Spotify requirement, and the GUI control.
Additional notes
Not tested against a live Spotify account. If #863 lands, pinned playlists would go right under the community pin, above whichever order is chosen.
💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit
New Features
Choose how Spotify playlists are ordered: Spotify’s default order, recently played, or by name. The selection is saved between sessions.
Change the order from the playlists sidebar with , or from Your Library in the GUI. Folder positions remain fixed, and the community playlist stays pinned first.
Recently played sorting updates as you listen, while keeping the current playlist selection when items move.
Sorting options are available in English, Simplified Chinese, and Traditional Chinese.
Reviewing files that changed from the base of the PR and between b9dff86 and 0fed162.
Files ignored due to path filters: 8
gui/src/bindings/GuiStrings.ts is excluded by !gui/src/bindings/**
gui/src/bindings/HelpStrings.ts is excluded by !gui/src/bindings/**
gui/src/bindings/PopupStrings.ts is excluded by !gui/src/bindings/**
gui/src/bindings/SidebarPlaylistOrder.ts is excluded by !gui/src/bindings/**
gui/src/bindings/SortContext.ts is excluded by !gui/src/bindings/**
gui/src/bindings/SortField.ts is excluded by !gui/src/bindings/**
gui/src/bindings/SourcePlaylists.ts is excluded by !gui/src/bindings/**
gui/src/bindings/strings.json is excluded by !gui/src/bindings/**
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Adds Spotify playlist ordering by Spotify order, recently played, or name. The selected order is persisted and applied in the terminal and GUI. Recent-play timestamps inform ordering, and folder positions remain fixed.
Changes: Spotify playlist ordering
Layer / File(s)
Summary
Sort options and persisted state src/core/sort.rs, src/core/state.rs
Adds sidebar playlist sort options and stores the selected order in runtime and persisted state. Sparse state updates and lenient loading handle the new field.
Listen tracking and sidebar ordering src/infra/history.rs, src/core/app/*, src/core/app/playlist_pages.rs
Tracks the latest listen timestamp for each Spotify playlist. Applies ordering within playlist slots, preserves folder positions and selected items, and retains the existing playlist-track order for RecentlyPlayed.
GUI sorting and library payload src/gui/protocol.rs, gui/src/LibraryPanel.tsx, gui/src/*test*, gui/e2e/*
Applies the selected order in the library payload, including nested folders. Adds a Spotify playlist sort selector and folder-aware row keys. Tests cover sort selection, focus, and localized labels.
Terminal controls and localized labels src/tui/*, src/core/i18n/*, CHANGELOG.md
Adds the comma-key sort menu for Spotify playlists, displays the current order in the playlist panel title, and provides translated labels. The changelog documents the options and controls.
sequenceDiagram
actor User
participant PlaylistHandler
participant SortMenu
participant App
participant PlaylistDisplay
User->>PlaylistHandler: Press comma in Spotify playlists
PlaylistHandler->>SortMenu: Open SidebarPlaylists sort menu
User->>SortMenu: Select an order
SortMenu->>App: Apply selected sort field
App->>App: Store order and schedule persistence
App->>PlaylistDisplay: Rebuild ordered playlist items
Loading
Merge Risk: Minimal · previous review b9dff
This change adds playlist sidebar sorting by Spotify order, recently played, or name in the terminal and GUI, and saves the choice. No actionable merge-blocking risk was found. The author reports that it was not tested against a live Spotify account.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title uses the conventional-commit prefix "feat" with the scope "playlists" and an imperative subject. It names the main change: sort orders for the playlist sidebar. The changeset adds Spotify, r…
Linked Issues check
Issue #657 requires a configurable sort mode for the playlists sidebar, particularly by recently played. The PR adds a SidebarPlaylists sort context with Spotify, Recently played, and Name orders (src…
Out of Scope Changes check
Every listed change connects to the sidebar sort feature. Core logic, state persistence, history tracking, protocol payloads, and TUI and GUI controls implement the requested sorting. The macOS plain-…
Full details: Title check
Explanation
The title uses the conventional-commit prefix "feat" with the scope "playlists" and an imperative subject. It names the main change: sort orders for the playlist sidebar. The changeset adds Spotify, recently played, and name sorting to the sidebar, which matches the title.
Full details: Linked Issues check
Explanation
Issue #657 requires a configurable sort mode for the playlists sidebar, particularly by recently played. The PR adds a SidebarPlaylists sort context with Spotify, Recently played, and Name orders (src/core/sort.rs). The TUI opens the sort menu with , in the playlist sidebar (src/tui/handlers/playlist.rs, src/tui/handlers/sort_menu.rs). The GUI adds a sort select in Your Library (gui/src/LibraryPanel.tsx). Recently played uses the latest ListenRecord per Spotify playlist context, maintained by the history collector (src/infra/history.rs). Playlists never played keep rootlist order. The selected order persists as playlist_sidebar_order in state.yml (src/core/state.rs). Unit, protocol, and GUI tests cover ordering, folders, persistence, and the sort control. The issue sets no extra acceptance criteria. Coding requirements are met by the summarized changes. Live Spotify behavior was not tested, which does not affect the requirement.
Full details: Out of Scope Changes check
Explanation
Every listed change connects to the sidebar sort feature. Core logic, state persistence, history tracking, protocol payloads, and TUI and GUI controls implement the requested sorting. The macOS plain-comma fallback change in src/core/app/keybindings.rs supports the new , shortcut in the playlist sidebar and leaves other active blocks unchanged. The sort_playlist_track_matches change in src/core/app/playlist_pages.rs handles the new SortField::RecentlyPlayed variant and does not alter track sorting. Localized strings, help rows, the CHANGELOG entry, and e2e and unit tests support the feature. Generated bindings are excluded from review and are not assessed. No unrelated change was identified in the summary.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Simplify code
Commit to this branch
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.
Reviewing files that changed from the base of the PR and between 4c5fc99 and b9dff86.
Files ignored due to path filters: 8
gui/src/bindings/GuiStrings.ts is excluded by !gui/src/bindings/**
gui/src/bindings/HelpStrings.ts is excluded by !gui/src/bindings/**
gui/src/bindings/PopupStrings.ts is excluded by !gui/src/bindings/**
gui/src/bindings/SidebarPlaylistOrder.ts is excluded by !gui/src/bindings/**
gui/src/bindings/SortContext.ts is excluded by !gui/src/bindings/**
gui/src/bindings/SortField.ts is excluded by !gui/src/bindings/**
gui/src/bindings/SourcePlaylists.ts is excluded by !gui/src/bindings/**
gui/src/bindings/strings.json is excluded by !gui/src/bindings/**
Files selected for processing: 31
CHANGELOG.md
gui/e2e/fixtures.ts
gui/e2e/focus.shot.ts
gui/e2e/localization.shot.ts
gui/src/LibraryPanel.tsx
gui/src/library.test.tsx
gui/src/libraryModel.test.ts
gui/src/libraryPanel.test.tsx
gui/src/mainLocalization.test.tsx
src/core/app/construction.rs
src/core/app/keybindings.rs
src/core/app/library.rs
src/core/app/mod.rs
src/core/app/playlist_folders.rs
src/core/app/playlist_pages.rs
src/core/i18n/gui.rs
src/core/i18n/gui/en.rs
src/core/i18n/gui/zh_hans.rs
src/core/i18n/gui/zh_hant.rs
src/core/i18n/help.rs
src/core/i18n/popups.rs
src/core/sort.rs
src/core/state.rs
src/gui/protocol.rs
src/infra/history.rs
src/tui/handlers/mod.rs
src/tui/handlers/playlist.rs
src/tui/handlers/sort_menu.rs
src/tui/keymap.rs
src/tui/ui/library.rs
src/tui/ui/popups.rs
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
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
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
Closes #657. The Spotify playlists sidebar can now be sorted three ways: Spotify (the rootlist order, the default and today's behavior), Recently played and Name. This follows the approach from the issue thread: Recently played comes from spotatui's own listening history, since the Web API has no per-playlist "last played".
ListenRecordwhosecontext_uriis that playlist. The history collector builds this map in the background read it already does for the streak cache (src/infra/history.rs) and updates it on each new listen, so no frame waits on the file. Playlists never played in spotatui follow in rootlist order.,in the playlists sidebar opens the existing sort menu with a newSidebarPlaylistscontext (src/core/sort.rs); a help row is added with the Spotify requirement. On macOS a plain,there sorts instead of opening settings, as it already does in the track table and album list.gui/src/LibraryPanel.tsx), with keyboard focus kept across a reorder.playlist_sidebar_orderpatch instate.yml; a missing or older file means Spotify order.Testing
telemetry,tui, and with theguileg's features: cleanguileg's features: protocol tests 76 passed; typescript_bindings_are_written passed, no diffdesktop/: clippy clean, 7 tests passedgui/: lint, format:check, typecheck, test (609 passed), build, and the Playwright scenes for sidebar reordering and the three languages in ChromiumNew tests cover the ordering function (folders, pin, never-played tail, stable name ties), the history map, the
state.ymlround trip and older files, the sort menu keys, the Spotify requirement, and the GUI control.Additional notes
Not tested against a live Spotify account. If #863 lands, pinned playlists would go right under the community pin, above whichever order is chosen.
💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit
,or from Your Library in the GUI. Folder positions remain fixed, and the community playlist stays pinned first.