Repository navigation
fix(playback): treat a pause with no active device as done - #707
Conversation
With startup behavior Pause and no Spotify device active, the startup pause got 404 NO_ACTIVE_DEVICE and opened the full-screen error page. Nothing plays anywhere in that case, so the pause already holds: log it and return instead of reporting an error.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughWhen Spotify reports ChangesPause handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Pausing without an active Spotify device should no longer show the startup error. No issue requiring a fix before merge was identified. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… (#694) # Summary Fixes #693. When I move playback from spotatui to my phone or CarPlay, it jumped back to spotatui after a few seconds. The PR has two parts. The first is the fix itself, the second came out of testing it. ## 1. The idle poll no longer takes playback back after a handoff What happens: after the handoff the playback poll gets `204 No Content` for a moment (nobody active). `reconcile_native_idle_device_if_preferred` then does `transfer(None)` + `activate()` because my saved device is the native one. The limit of 2 attempts doesn't help, because every rebuild after the handoff is a new player instance and that resets the attempts. - remember the handoff on `App` (`native_handed_off`, private, set on `RebuildIdle`) - while it's set the idle poll leaves the app state alone (no transfer, no `mark_native_streaming_device_available`) - cleared when the poll sees spotatui as the active device again, it's picked in the device list, or playback is started in spotatui - the reclaim now logs at info, the skip at debug (before there was no log line at all, that's why it was hard to find) ## 2. Play in spotatui after a handoff With part 1, play in spotatui did nothing after a handoff, because the rebuilt device has no track. So a bare resume (Space) while handed off now works like the official client: - if another device still holds the playback (e.g. the phone, paused, app open), it goes the normal Connect way and resumes there, like Enter - if no device holds it anymore (phone app closed, Spotify answers 204), it transfers the last playback over (before `activate()`, Spirc ignores a transfer after that) and plays it once it's loaded, with a status message - only one transfer per handoff; if it couldn't be sent it stays available, otherwise a second press takes the normal start path - the pending play is cancelled by any pause (also on the Connect route) and by the first `Playing`, so a pause from the phone sticks - Space while the pulled-back song already plays pauses it, also before Spotify confirms spotatui as the active device Startup and normal reconnects behave like before. # Testing ``` $ cargo fmt --all -- --check (no diff) $ cargo clippy --locked --no-default-features --features telemetry,tui -- -D warnings Finished ... $ cargo test --locked --no-default-features --features telemetry,tui test result: ok. 1434 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out $ cargo clippy --locked -- -D warnings Finished ... $ cargo test --locked test result: ok. 1840 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ``` The `get_artist_recovers_from_related_artists_403/404` tests fail for me now and then in the full run ("test timed out"). Same on plain `main`, I think it's the shared API pacing in the tests. Also tested it for real with a release build (`--debug`), NixOS + iPhone/CarPlay: - switched from spotatui to the phone: playback stays on the phone (before it came back after 10-25s, checked again with 0.42.0) - paused on the phone with the app open, then Space in spotatui: resumes on the phone, like Enter - paused on the phone and closed the app (Spotify then reports no device): Space in spotatui pulls the last song over and plays it - after that pull-back, paused from the phone right away: it stays paused; Space again plays normally, no second transfer - Space twice in a row right after the handoff: the second press takes the normal start path and it plays - Space while the pulled-back song plays, before Spotify confirms spotatui: it pauses - picked spotatui again on the phone: works normally - on startup it still takes the device like before (`idle playback poll: transferring playback to the native device`) - compared with the Spotify web player: playing on the phone stays there, a paused phone (app open, also after 11 minutes) resumes there, a gone phone gets the last song pulled over, a pause from the phone sticks. spotatui behaves the same in all of these # Additional notes This is my first PR here and I'm not that familiar with Rust, so I had some help from AI (Claude) tracking down the cause. I read through the diff and tested it as described above, but please have a close look. About the Codecov report: most of the missing lines are the native player paths (librespot events, transfer, play), which the tests can't run without a real `StreamingPlayer`. The decisions are pure functions with tests, and the poll part (paused phone, then 204) has a test through `get_current_playback` with a stub server, like the one in #707. Related to #676 but doesn't fix it (that one is in the librespot fork). After such a stop, play in spotatui now picks the last playback up again though. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * After playback is handed off to a phone, CarPlay, or another Spotify device, spotatui no longer automatically takes playback back during polling. * Playback stays on the receiving device until you select Play in spotatui. If Spotify reports that another device still holds playback, playback resumes there; otherwise, it resumes on spotatui. * Pausing during a handoff cancels a pending resume, preventing unintended playback. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: LargeModGames <[email protected]> Co-authored-by: LargeModGames <[email protected]>
# Summary Version bump and changelog for v0.44.0. No application code changes. - `Cargo.toml` and `Cargo.lock` go to 0.44.0, and `SECURITY.md` names 0.44 as the supported version. - `CHANGELOG.md`: `## [Unreleased]` is now `## [v0.44.0] 2026-10-12`. I checked every PR merged since v0.43.0 against it and added 24 entries that were missing, for #524, #569, #570, #574, #593, #618, #623, #624, #651, #652, #656, #675, #684, #700, #701, #706, #707, #709, #718, #719, #722, #730, #741 and #742. - Five older entries blamed the Web API, Development Mode or the token refresh, which #752 removed. They now describe what a v0.44 user sees. The #752 entry also says that related artists are empty for now. - The agent plugin goes to 0.2.0 (both manifests and the marketplace entry), because its skill now lists the ten new MCP tools. - README and `docs/roadmap.md`: rspotify is only models and ids now, `--debug` logs every Spotify request, recommendations work again, and related artists come back empty. - The `spotatui.wiki` submodule moves to the commit that replaces the client-id setup with the pairing login. # Testing - `cargo update -p spotatui --offline`, then `cargo metadata --locked`: ok - `cargo check --locked`: ok (`Checking spotatui v0.44.0`) # Additional notes This is the first release without a client id. Every Spotify user logs in once more with the pairing code, and Spotify in spotatui needs Premium. --- <sub>💬 Questions or want to chat with other contributors? Join the [spotatui Discord](https://spotatui.com/discord).</sub> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Search and sort playlists using loaded tracks, play playlists randomly, and browse artist albums across pages. * Spotify sessions now support HTTP proxies; listening parties stay connected with keep-alives. * **Improvements** * Playback handoffs, polling, and slow Spotify operations have been adjusted for smoother playback. * Skipped downloads can be canceled, and AI DJ/MCP playback can continue when off-screen. * **Bug Fixes** * Fixed issues with theme color startup, key handling, focus navigation, cursor placement, playlist sorting, and Qobuz retries. * **Documentation** * Updated installation, keybinding, and Spotify guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Fixes #704.
With startup behavior set to Pause and no Spotify device active, spotatui opened the full-screen error page on launch with
Spotify API 404 Not Found failed: ... NO_ACTIVE_DEVICE.Pause never transfers playback to a device at startup, so the startup pause is a bare
PUT me/player/pause. With nothing active, Spotify answers 404NO_ACTIVE_DEVICE. The saved-device retry is skipped because native streaming can claim the command, and the "native backend pending" suppression no longer applies because deferred startup has just cleared that flag. Sopause_playbackcalledhandle_error.A pause that finds no active device has nothing to pause, so the requested state already holds.
pause_playbacknow logs that case and returns. The check sits after the native suppression, so the "Reconnecting native streaming" status during recovery is unchanged, and it is outside any#[cfg], so it covers the streaming startup, the non-streaming startup inruntime/startup.rsand the GUI.The test reuses the HTTP stub helpers from the
metadata.rstests, which are nowpub(crate).Testing
pause_with_no_active_device_is_not_an_errorserves the real 404 body from a local listener. Without the fix it fails with:cargo fmt --all -- --check: exit 0cargo clippy --no-default-features --features telemetry,tui -- -D warnings:Finished, exit 0cargo clippy --no-default-features --features telemetry -- -D warnings:Finished, exit 0cargo clippy -- -D warnings:Finished, exit 0cargo test --no-default-features --features telemetry,tui:cargo test:I have not done the manual repro with a live account yet (Pause startup, all Spotify clients closed, with and without
enable_streaming).Additional notes
spotatui playback --toggleonly pauses when Spotify just reportedis_playing. If the device disappears between that poll and the pause, the command now exits 0 instead of non-zero. I think that is the right result, since nothing is playing.direct_playback_context_reads.💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit