Repository navigation
fix(cli): fetch Spotify state only where read - #735
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The reviewed status change has no identified regression; the PR is mergeable after normal checks. Pre-merge checks |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…command # Conflicts: # CHANGELOG.md
Summary
Every
spotatui playback,play,listandsearchrun fetched the Spotify device list and the current playback before it looked at the subcommand. This PR makes each subcommand fetch only what it reads:probe_planinsrc/cli/handle.rs).search,list --playlistsandlist --likedfetch nothing first, so a rate limit on the device list no longer fails them.list --devicesfetches the devices.playfetches both (the start seeds its shuffle state from the playback).playbackfetches the devices (the saved-device retry from fix(cli): retry player commands on the saved device #465 still needs the re-pin) and fetches the playback first only for--toggle,--like,--dislike,--shuffle,--repeatand the share flags.--seekand the status line already fetch their own.get_statusdispatchedGetCurrentSavedTracks, which nothing read and which also started the background walk over every liked page.play --urirefuses a URI it cannot start. A clap value parser acceptsspotify:track:,spotify:album:,spotify:artist:,spotify:playlist:andspotify:show:(the five kinds the command dispatches). Any other value stops in argument parsing, before boot, with exit 2 and no Spotify request. Aqobuz:,file:,subsonic:,youtube:,radio:orapplemusic:URI gets a message that names its scheme; any other value gets the list of accepted kinds. Before, such a URI dispatched nothing, spent five Spotify requests and printed the Spotify status line.Deliberate behaviour changes:
spotatui search,list --playlistsandlist --likedno longer fail when the device-list request fails.spotatui play --uri <not a Spotify track/album/artist/playlist/show URI>exits 2 with a usage error (was: exit 0 or 1 after five requests). This includesspotify:episode:, which dispatched nothing before.Test-only change outside
src/cli: the new HTTP tests share the global pacing limiter inrequests.rswith every other HTTP test, and they pusheda_stalled_response_gives_up_at_the_deadline_as_a_transient_errorover its 3 s bound (the pacing wait sits inside its 300 ms deadline, so its request was never sent). A#[cfg(test)]thread-localSKIP_PACING, checked first inpace_spotify_api_call, lets the three timing tests (stalled, stalled 401, 429) skip the shared queue. Production code is unchanged.Testing
cargo fmt --all -- --checkcargo clippy -D warningson slim, headless, headless-streaming, mcp-only, ai-dj-only, default, default + all-sources, gui: all cleancargo test --no-default-features --features telemetry,tui: 1481 passed (run twice)cargo test --no-default-features --features telemetry: 1032 passedcargo test --no-default-features --features telemetry,tui,mcp-server: 1608 passedcargo test --no-default-features --features telemetry,tui,ai-dj: 1761 passedcargo test: 1887 passedcargo test --features all-sources: 2067 passed, 1 failed (infra::local::tests::uri_round_trip, the known Windows-only failure)cargo teston the gui leg list: 1603 passed, bindings unchangedNew tests: the probe plan for every subcommand and flag; four HTTP tests on a recording 127.0.0.1 listener (search sends no
me/playerrequest,list --devicesfetches only the devices,--togglefetches the playback twice and--nextonce, the status line sends nome/tracksrequest); the--uriparser.Live smoke test on Windows against my Spotify account (default build):
playback(status,-t,-n,-pp,--seek,--shuffle,-v,--share-track),list -d,list -p,list --liked,search -t,play -nandplay -u spotify:track:...all work;play -uwithqobuz:track:1,spotify:episode:1and anhttps://open.spotify.comlink exits 2 with the messages above.Not run: Linux, macOS; live
--like,--dislike,--repeat,--share-album,--transferand the saved-device retry.Additional notes
The CLI still drives Spotify only. When another spotatui process plays Local Files, Subsonic, YouTube, Qobuz or Radio,
spotatui playbackacts on the Spotify player, not on what you hear. Fixing that needs the CLI to ask the running spotatui, which is follow-up work.💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit
play --urivalidates Spotify URIs before running and reports clearer errors for unsupported types, including sources that can only be played in the running app.