Skip to content

fix: pausing a natively queued Spotify track actually pauses it - #427

Merged
LargeModGames merged 1 commit into
mainfrom
fix/native-queue-pause-routing
Aug 7, 2026
Merged

LargeModGames merged 1 commit into
mainfrom
fix/native-queue-pause-routing

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Aug 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

With spotatui as the playback device, pausing a track played through the
native queue (or from a raw track list like Liked Songs) flipped the playbar
to paused while the audio kept playing, and resume was broken the same way.

Those tracks are loaded via a direct player.load() with no Spirc context,
and Spirc drops any command whose play_request_id it did not issue: its
handle_pause/handle_play no-op unless its own play_status covers the
current audio. The command router sent Pause/Play to Spirc only, so both
were silent no-ops for direct-loaded tracks while every caller flipped the
UI state optimistically.

Pause/Play now go to both the raw Player (always acts on whatever is
actually loaded) and Spirc (keeps Connect state in sync when it is
managing playback). The double-send is safe in both directions: the Player
ignores commands invalid for its state, and Spirc re-syncs its status from
the resulting Paused/Playing events. This also un-breaks safeguards that
silently relied on the same call (the stray-audio-over-queue guard, the
preemptive pauses during queue handoff, the unavailable-track escalation
stop), which explains the ghost audio and some stuck auto-advances around
the native queue.

Also adds info-level logging at the end-of-track decision points
(end of track <id>: <decision> and the continuation branches) so any
remaining auto-advance stall can be pinned from the log.

Testing

  • cargo fmt --all
  • cargo clippy --no-default-features --features telemetry -- -D warnings
  • cargo clippy -- -D warnings
  • cargo test --no-default-features --features telemetry (564 passed)
  • cargo test (832 passed)
  • Manual TUI test with the full build: pause/resume on a queued Spotify
    track and queue auto-advance now behave correctly

Additional notes

Verified against the vendored librespot fork that player.load(..., play=true)
starts playback regardless of a prior paused sink, so the now-real preemptive
pauses before queue advances cannot introduce a new stall.


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

Summary by CodeRabbit

  • Bug Fixes
    • Improved direct play and pause controls for Spotify tracks queued natively.
    • Playback toggles now work consistently across queued tracks and raw track lists.
    • Improved handling when tracks finish, pause, stop, resume, or transition to the next item.
    • Prevented playback from becoming stuck when moving between queued tracks or exhausting a track list.
    • Added clearer playback decision logging to support troubleshooting.

Spirc silently ignores play/pause for tracks it did not start itself,
which covers every direct-loaded track (native queue Spotify slots and
raw URI lists). The command router only sent those commands to Spirc, so
spacebar flipped the playbar while audio kept going, and the stray-audio
guard and queue-handoff preempt pauses were no-ops. Send the commands to
the underlying player too, and log the end-of-track decision points to
help pin down any remaining auto-advance stalls.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The change makes deferred play and pause commands update both the direct player and Spirc. Playback continuation and end-of-track paths now log their selected decisions. The changelog documents the native queued-track control fix.

Native playback control

Layer / File(s) Summary
Direct player command handling
src/infra/player/streaming.rs, CHANGELOG.md
DeferredPlayerCommand::Play and Pause now update Player and Spirc. The changelog records the behavior.
Playback decision logging
src/infra/player/events.rs, src/infra/network/playback.rs
End-of-track and continuation paths log selected actions, including raw-list advancement, paused-track handling, resumption, queue takeover, and exhaustion.

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

Sequence Diagram(s)

sequenceDiagram
  participant DeferredPlayerCommand
  participant Player
  participant Spirc
  DeferredPlayerCommand->>Player: Apply play or pause directly
  DeferredPlayerCommand->>Spirc: Synchronize playback state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title uses the valid fix: prefix and clearly describes the change, but its subject is descriptive rather than imperative. Rewrite the subject as an imperative, for example: fix: pause natively queued Spotify tracks correctly.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/native-queue-pause-routing
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/native-queue-pause-routing

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/streaming.rs`:
- Around line 72-87: Update the DeferredPlayerCommand handling around Self::Play
and Self::Pause to avoid sending duplicate Player operations when Spirc owns the
current track. Track whether Spirc successfully handles the command, and invoke
player.play() or player.pause() directly only when Spirc cannot own the current
track, preserving direct-player behavior for tracks loaded outside Spirc.
🪄 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: 4c190053-8203-47e3-aaf7-3cfdfe040d4c

📥 Commits

Reviewing files that changed from the base of the PR and between b3cf30d and e8e335a.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • src/infra/network/playback.rs
  • src/infra/player/events.rs
  • src/infra/player/streaming.rs

Comment thread src/infra/player/streaming.rs Resolved
@LargeModGames
LargeModGames merged commit 29e3c36 into main Aug 7, 2026
15 checks passed
@LargeModGames
LargeModGames deleted the fix/native-queue-pause-routing branch August 7, 2026 13:45
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