Skip to content

Fix ghost spotatui Connect devices accumulating#299

Merged
LargeModGames merged 2 commits into
mainfrom
fix/ghost-connect-devices
Jun 11, 2026
Merged

Fix ghost spotatui Connect devices accumulating#299
LargeModGames merged 2 commits into
mainfrom
fix/ghost-connect-devices

Conversation

@LargeModGames

Copy link
Copy Markdown
Owner

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:

  1. Random device id per session. 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.
  2. Old spirc never shut down. Replacing app.streaming_player just 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, and request_native_streaming_recovery_if_disconnected), with an impl Drop for StreamingPlayer as 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): passed
  • cargo test (default features): 249 passed, including 3 new unit tests for the device id helpers
  • cargo fmt --all
  • cargo clippy --no-default-features --features telemetry -- -D warnings: passed
  • cargo test --no-default-features --features telemetry: 233 passed

Note: 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.

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.
@LargeModGames LargeModGames merged commit 0eef3f0 into main Jun 11, 2026
9 checks passed
@LargeModGames LargeModGames deleted the fix/ghost-connect-devices branch June 11, 2026 12:24
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.

1 participant