Skip to content

fix(queue): drop the suspended context when a handoff ends the queue (#708) - #718

Merged
LargeModGames merged 1 commit into
LargeModGames:mainfrom
kapok-4o:fix/handoff-drops-suspended-queue
Oct 7, 2026
Merged

LargeModGames merged 1 commit into
LargeModGames:mainfrom
kapok-4o:fix/handoff-drops-suspended-queue

Conversation

@kapok-4o

@kapok-4o kapok-4o commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #708.

A handoff during a queued Spotify track left playback on spotatui paused once it was handed back. disconnect_streaming_player dropped the Spotify queue slot but kept queue_suspended. With no Spotify slot and a context still suspended, the stray-play guard in handle_player_events treats every librespot Playing event as the gap between two queue items and pauses it, so the transferred track loads paused and Space only plays it for a moment.

As agreed in #708 (option 1), the handoff now ends the queue episode:

  • App::forget_queue_slot_after_handoff (core/app/queue.rs) is the slot teardown from disconnect_streaming_player, and now also clears queue_suspended and resets queue_slot_desired_playing.
  • App::librespot_playing_is_stray is the guard's predicate, moved unchanged out of events.rs so it can be tested.
  • New test playback_handed_back_after_a_handoff_mid_queue_is_not_re_paused; test_attribute_total 2542 → 2543.

Testing

rustc / clippy 1.99.0, macOS (aarch64):

  • cargo fmt --all --check: clean.
  • cargo clippy --locked <leg> -- -D warnings: clean for default, slim, headless, headless-streaming, mcp-only, ai-dj-only, gui, and the macos job's feature set.
  • cargo test --locked: default 1854 passed (on current main); earlier, before rebasing onto fix(network): move slow Spotify work off the pump #717, slim 1440 passed and the macos feature set 2441 passed, 22 ignored.
  • With the queue_suspended = None line removed, the new test fails ("the transferred track would be re-paused on every Playing event"); with it, it passes.

Not run here: the Linux all-sources leg (PipeWire), and a real phone handoff.

Additional notes

Only the Spotify-slot case is touched. A handoff while a decoded queue item owns the sink keeps today's behaviour.


💬 Questions or want to chat with other contributors? Join the spotatui Discord.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved playback handoff behavior when switching away from Spotify mid-queue. Suspended playback context is now restored correctly, and playback that should not take control is paused.
    • Fixed queue cleanup during playback teardown to prevent stale Spotify queue state from affecting subsequent playback.

…argeModGames#708)

A handoff during a queued Spotify track dropped the queue slot but kept
the suspended context. With no Spotify slot and a context still
suspended, the stray-play guard read every later librespot Playing event
as "between two queue items" and paused it, so playback handed back to
spotatui stayed paused.

The handoff now ends the queue episode: the suspended context goes with
the slot, as agreed in LargeModGames#708.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ef55a440-6b51-4c1b-8998-b7c2ebcd46d3
📥 Commits

Reviewing files that changed from the base of the PR and between bfacbbd and d9f87dd.

📒 Files selected for processing (3)
  • src/core/app/queue.rs
  • src/infra/player/events.rs
  • tools/gates.count

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The handoff teardown now clears suspended Spotify context and restores desired playback when it removes a Spotify queue slot. The Playing handler uses a shared predicate to identify playback that should be paused. A streaming test and the test-attribute adoption baseline were updated.

Changes

Streaming handoff

Layer / File(s) Summary
Queue handoff cleanup and event handling
src/core/app/queue.rs, src/infra/player/events.rs, tools/gates.count
Queue cleanup clears the Spotify slot and reload counter, drops suspended context, and restores desired playback. The Playing handler uses librespot_playing_is_stray() to decide whether to pause playback. The streaming test checks playback classification after cleanup, and the adoption baseline increases by one.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to d9f87

Clearing stale queue context is intended to prevent handed-back playback from being re-paused. No concrete merge-blocking issue is evident, though a live Spotify Connect handoff was not exercised.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the permitted conventional-commit prefix fix(queue):, clearly describes the queue handoff fix, and uses a concise imperative subject.
Linked Issues check ✅ Passed Issue #708 requires playback to resume after a handoff during a queued Spotify track. The reviewed code adds App::forget_queue_slot_after_handoff, which clears queue_suspended and restores `queue_…
Out of Scope Changes check ✅ Passed The changes stay within issue #708. They update Spotify queue-slot teardown, extract the related stray-play predicate for testing, add a regression test, and update the test adoption counter. The repo…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
✨ Simplify code
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kapok-4o
kapok-4o force-pushed the fix/handoff-drops-suspended-queue branch from 5ef63e4 to d9f87dd Compare October 7, 2026 19:17
@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/infra/player/events.rs 0.0% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@LargeModGames
LargeModGames merged commit 1cf9cb5 into LargeModGames:main Oct 7, 2026
25 of 31 checks passed
LargeModGames pushed a commit that referenced this pull request Oct 8, 2026
#722)

# Summary

Part of #716: the start itself.

`snapshot_tracks` (`infra/queue/mod.rs`) dropped every URI it could not
find in the track table or the search results. An MCP or AI DJ
`play_now` usually sends a URI that is in neither, so
`start_qobuz_queue`, `start_youtube_queue` and `start_subsonic_queue`
got an empty list, flashed "No … tracks to play", and played nothing
while the tool reported "Sent … to the player". A dropped URI also
shifted `start_idx` off the track the caller asked for whenever only
some of a list was off screen.

An unknown URI now gets a placeholder `TrackInfo` named after the URI,
the same shape the native queue (`tracks_for_uris` in `network/dj.rs`)
and the radio router (`snapshot_station`) already use for opaque items.
The start goes ahead, and a URI the source cannot fetch fails through
the source's own error path as before.

YouTube reads `duration_ms == 0` as a livestream, and a placeholder's 0
only means the duration is unknown. So `start_youtube_queue` and
`play_index` now refuse only a known row with no duration, and a
placeholder (`is_placeholder`) downloads like any other video.

Left for a follow-up, as said in #716:

- The real title. Until the source resolves it, the playbar shows the
URI. Qobuz has the catalogue call for it; Subsonic and YouTube each need
their own.
- `play_now` reporting a start that later fails, instead of "Sent … to
the player".

# Testing

rustc / clippy 1.99.0, macOS (aarch64):

- `cargo fmt --all --check`: clean.
- `cargo clippy --locked <leg> -- -D warnings`: clean for `default`,
`slim`, `headless`, `headless-streaming`, `mcp-only`, `ai-dj-only`,
`gui`, `telemetry,tui,subsonic`, and the `macos` job's feature set.
- `cargo test --locked`: `default` 1853 passed, `slim` 1447 passed, the
`macos` feature set 2453 passed, 22 ignored; after rebasing onto #718,
`telemetry,tui,local-files,subsonic,internet-radio,youtube,qobuz,mcp-server,ai-dj`
1976 passed, 22 ignored. One earlier `macos`-set run failed
`a_stalled_response_gives_up_at_the_deadline_as_a_transient_error` (its
3 s bound) while another build was compiling; it passed alone three
times and in the full rerun.
- New router test
`an_off_screen_youtube_start_is_not_refused_as_a_livestream` (yt-dlp
pointed at a missing path, so it stops right after); it fails with the
live-stream error without the fix.
`livestream_rows_are_refused_without_session` still passes, and
`a_placeholder_is_told_apart_from_a_known_row_with_no_duration` covers
the predicate.
- After the YouTube fix: fmt and clippy clean on the same legs plus
`telemetry,tui,youtube`; `default` 1854, `slim` 1447, `macos` set 2455
passed.
- `snapshot_drops_unknown_uris` becomes
`snapshot_keeps_an_off_screen_uri_as_a_placeholder_named_after_it`; new
`snapshot_keeps_positions_aligned_when_one_uri_is_off_screen`.

Not run here: the Linux `all-sources` leg, and a live `play_now` against
Qobuz, YouTube or Subsonic.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Queues now retain requested tracks even when they aren’t found in the
library or search results, preserving their position with a placeholder
entry.
* Unknown-duration YouTube tracks are no longer automatically treated as
livestreams, allowing playback to proceed to the normal audio or
download steps.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: 2570165831 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
LargeModGames added a commit that referenced this pull request Oct 11, 2026
# 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 -->
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.

After a handoff during a queued track, playback on spotatui is paused right away until a restart

2 participants