Fix ghost spotatui Connect devices accumulating#299
Merged
Conversation
Persist the librespot device id in the streaming cache dir so every launch and recovery registers as the same Spotify Connect device, and shut down the old spirc whenever the streaming player is replaced (explicit shutdown() at all replacement sites plus a Drop backstop). Addresses the ghost-device symptom of #297.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes the ghost-device symptom of #297 (also reported in #72): users accumulate multiple dead "spotatui" entries in Spotify's Connect device list. Two root causes:
SessionConfig::default()in librespot 0.8.0 generates a fresh UUID device id every time, so each app launch and each in-app streaming recovery registered a brand-new Connect device. The device id is now generated once, persisted to<streaming_cache>/device_id, and reused by every session.app.streaming_playerjust dropped the Arc, leaving the old librespot session registered with Spotify.player.shutdown()is now called at all three replacement sites (disconnect_streaming_player, the recovery success branch, andrequest_native_streaming_recovery_if_disconnected), with animpl Drop for StreamingPlayeras a backstop.This intentionally does not touch
src/infra/network/playback.rs, so it should not conflict with #298, which covers the other #297 symptoms (404 NO_ACTIVE_DEVICE routing and silent resume).Pre-existing ghost entries are not deleted; they age out of Spotify's list once nothing re-registers them.
Testing
cargo check(default features, compiles the streaming code): passedcargo test(default features): 249 passed, including 3 new unit tests for the device id helperscargo fmt --allcargo clippy --no-default-features --features telemetry -- -D warnings: passedcargo test --no-default-features --features telemetry: 233 passedNote: the new unit tests only compile under default features (streaming), not in the CI telemetry lane.
Manual verification: run the app, restart a few times, and force a recovery (e.g. transfer playback away in the official client); the Connect picker should show exactly one "spotatui" whose device id matches the persisted file and the
Initializing Spirc with device_id=...log line every time.