Repository navigation
fix(streaming): preserve external device handoffs - #438
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughNative streaming recovery distinguishes local stops, Spotify Connect handoffs, and unexpected disconnects. Handoffs rebuild an idle backend without reclaiming playback. Unexpected disconnects restore playback, while queue replay and device selection remain restoration-aware. ChangesNative streaming recovery
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant NativeSession
participant events_rs
participant PlaybackNetwork
participant SpotifyConnect
NativeSession->>events_rs: emit disconnect reason
events_rs->>PlaybackNetwork: apply restoration decision
PlaybackNetwork->>SpotifyConnect: inspect active device
SpotifyConnect-->>PlaybackNetwork: report external playback
PlaybackNetwork-->>events_rs: skip native transfer when another device is active
Possibly related PRs
🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/infra/player/events.rs`:
- Around line 46-51: Update should_replay_published_queue_slot to require
request.reselect_device in addition to request.restore_playback and
queue_now_is_spotify, so replay occurs only after native-device confirmation.
Adjust the related test to verify that an unconfirmed restoration request does
not replay the queue slot.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3d4acc90-ab3b-40c1-bbb0-50bb83a7170a
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (5)
CHANGELOG.mdCargo.tomlsrc/core/app.rssrc/infra/player/events.rssrc/infra/player/streaming.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/infra/network/playback.rs`:
- Around line 2294-2305: Update the state assignments at the recovery-yield
paths around the existing activation handling so app.is_streaming_active remains
false whenever external_playback_active is true. Propagate the
external_playback_active condition into both assignments currently setting the
flag at the referenced recovery branches, while preserving true only when the
native device is confirmed active.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 603b81d8-dc31-416f-910a-e8792f941506
📒 Files selected for processing (5)
CHANGELOG.mdsrc/infra/network/mod.rssrc/infra/network/playback.rssrc/infra/player/events.rssrc/runtime.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- CHANGELOG.md
- src/infra/player/events.rs
There was a problem hiding this comment.
Pull request overview
Adjusts native streaming recovery behavior so that when playback is handed off to another Spotify Connect device, spotatui rebuilds an idle streaming backend without reclaiming playback—addressing #437 and improving correctness of recovery decisions using librespot’s disconnect reason.
Changes:
- Classify
SessionDisconnectedhandling bySessionDisconnectReasonand gate recovery actions (reselect/replay) behind explicitrestore_playbackintent. - Extend
AutoSelectStreamingDevice/auto_select_streaming_deviceplumbing withyield_to_external_playbackto avoid transferring playback away from an actively playing external device during recovery. - Pin librespot to the upstream disconnect-reason change, update Nix hash, and document the behavior change in the changelog.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/runtime.rs | Updates startup auto-select event to pass the new yield_to_external_playback flag. |
| src/infra/player/streaming.rs | Re-exports librespot disconnect reason alongside player events for downstream handling. |
| src/infra/player/events.rs | Implements disconnect-reason-based recovery policy; adds restore_playback intent and request merge semantics; adds targeted unit tests. |
| src/infra/network/playback.rs | Extends streaming device auto-select API to optionally yield to external playback during recovery; adds stale-restore guard. |
| src/infra/network/mod.rs | Updates IoEvent::AutoSelectStreamingDevice variant signature and dispatch wiring. |
| src/core/app.rs | Ensures recovery requests created from app-driven recovery set restore_playback: true. |
| flake.nix | Updates librespot output hash to match the pinned revision. |
| CHANGELOG.md | Adds Unreleased entry describing the fixed handoff/recovery behavior. |
| Cargo.toml | Pins librespot patch dependencies to the commit containing disconnect-reason support. |
| Cargo.lock | Updates lockfile sources to the new librespot revision. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/infra/network/mod.rs`:
- Around line 71-74: Update event_bypasses_spotify_auth to include
ReplayPublishedSpotifyQueueSlot, ensuring this no-op fallback bypasses Spotify
authentication when the queue router does not consume the event.
In `@src/infra/queue/dispatch.rs`:
- Around line 48-54: Add streaming-feature regression tests covering playing and
paused queue-slot replay, yielded external playback, event consumption, and
network fallback around the replay handling in replay_published_spotify_slot and
the IoEvent::ReplayPublishedSpotifyQueueSlot dispatch path. Then run cargo fmt
--all, the specified telemetry Clippy and test commands, and the full cargo run
validation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 760995e8-a683-4931-bd90-6627c388bcf2
📒 Files selected for processing (4)
src/infra/network/mod.rssrc/infra/network/playback.rssrc/infra/player/events.rssrc/infra/queue/dispatch.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- src/infra/player/events.rs
Summary
Fixes #437
When playback moves from spotatui to another Spotify Connect device, spotatui now rebuilds an idle backend without reclaiming playback. Unexpected connection failures still restore the session, and an explicit Play action still selects spotatui normally.
Pins librespot to the merged disconnect-reason change: LargeModGames/spotatui-librespot@f775c39
Testing
cargo fmt --allcargo clippy --locked -- -D warningscargo clippy --no-default-features --features telemetry -- -D warningscargo test— 842 passedcargo test --no-default-features --features telemetry— 572 passedSummary by CodeRabbit