Commit 2fd498c
authored
fix(app): resolve the playing item through the owner (#511)
# Summary
The four actions on "the item playing now" (jump to album `a`, jump to
artist `A`, jump to context `o`, add the playing track to a playlist
`w`/`W`) read the cached Spotify playback context directly. While a
decoded source (Local Files, Subsonic, Qobuz, Internet Radio, YouTube)
or the native queue slot owns the sink, that context names the
*suspended* Spotify track, so the keys fetched or staged the wrong item:
with a Qobuz track audible, `a` opened the suspended track's album with
a real `albums/{id}/tracks` request, and `W` offered to add a song the
user was not hearing to a Spotify playlist.
They now resolve through one `App::playing_item()` in
`core/app/playback_routing.rs`, which folds `playback_owner()` and the
queue slot into one answer, the way Like already did. Like goes through
the same resolver, so its own predicate and
`queue_now_spotify_track_uri` are gone. A queued Spotify track resolves
through the slot: its URI for the picker, its album id (or the album
lookup from the track id when the slot track carries none), its first
artist. A decoded owner answers with a status message.
A new ratchet counter, `direct_playback_context_reads`, counts every
read of `App::current_playback_context` outside the ownership resolver
and the snapshot builder, pins at 93 (97 before this PR), and may only
fall.
Deliberate behaviour changes:
1. With a decoded source or a decoded queue item playing, the five keys
show a status message instead of acting on the suspended Spotify track.
2. A queued Spotify track now jumps to its own album and artist and
stages itself in the picker. `o` on a queued track says the slot has no
play context.
3. The three jump keys say "Nothing is playing" where they were silent
(no session, no item, or no context). A context with no item (an ad
plays) still opens.
4. Jump to artist on a Spotify track with no artist id says so instead
of doing nothing.
The copy-URL keys keep their handler-side guard and still refuse a
queued Spotify track; converting them needs the resolver outside
`core/app/` and is a follow-up.
# Testing
- `cargo fmt --all -- --check`
- `cargo clippy -- -D warnings` on slim, headless, headless-streaming,
mcp-only, ai-dj-only, default, and the Windows stand-in for all-sources
(`audio-viz-cpal,windows-media` in place of `audio-viz,mpris`): clean.
- `cargo test` on slim (953), headless (588), mcp-only (1076),
ai-dj-only (1230), default (1260), five sources without cover-art (1730,
plus the pre-existing Windows-only `uri_round_trip` failure).
- `tools/check_gates_ratchet.sh main`: ok.
`direct_playback_context_reads` new at 93, `test_attribute_total` 1816
-> 1826, the rest unchanged.
- New tests: the queue slot beats the suspended context for album,
artist, context and the picker; the album lookup fallback; no context
and a context without an item; a pure test over all five owners; the
counter matcher.
- Not run here: the Linux `all-sources` leg and macOS.
# Additional notes
Follow-ups, not in this PR: under native streaming with a client-side
shuffle session or a direct URI-list load,
`current_playback_context.context` is `None` or stale, so `o` can open
the wrong context; the copy-URL asymmetry above; the stale Like clause
in the playbar-controls comment in `tui/ui/player.rs`.
---
<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**
- Jump-to-album, artist, and context actions now correctly handle queued
Spotify tracks.
- Playlist and save actions use the currently playing queued track when
applicable.
- Actions provide clear status messages when nothing is playing or the
source is not Spotify.
- **Bug Fixes**
- Improved track resolution across native queue and Spotify playback,
preventing stale playback information.
- **Documentation**
- Updated the unreleased changelog and playback guidance to reflect
source-aware playback actions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 4c01587 commit 2fd498c
14 files changed
Lines changed: 450 additions & 147 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
222 | 226 | | |
223 | 227 | | |
224 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
223 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
224 | 228 | | |
225 | 229 | | |
226 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
223 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
224 | 228 | | |
225 | 229 | | |
226 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
| 263 | + | |
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
267 | | - | |
268 | | - | |
| 268 | + | |
| 269 | + | |
269 | 270 | | |
270 | 271 | | |
271 | | - | |
| 272 | + | |
272 | 273 | | |
273 | 274 | | |
274 | | - | |
| 275 | + | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
| 348 | + | |
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
| 354 | + | |
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
526 | 500 | | |
527 | | - | |
528 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
529 | 505 | | |
530 | 506 | | |
531 | 507 | | |
| |||
615 | 591 | | |
616 | 592 | | |
617 | 593 | | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | 594 | | |
631 | 595 | | |
632 | 596 | | |
| |||
699 | 663 | | |
700 | 664 | | |
701 | 665 | | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | 666 | | |
714 | 667 | | |
715 | 668 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
25 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
26 | 74 | | |
27 | 75 | | |
28 | 76 | | |
| |||
396 | 444 | | |
397 | 445 | | |
398 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
399 | 478 | | |
400 | 479 | | |
401 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
243 | | - | |
244 | | - | |
| 242 | + | |
| 243 | + | |
245 | 244 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 245 | + | |
| 246 | + | |
252 | 247 | | |
253 | 248 | | |
254 | 249 | | |
255 | 250 | | |
256 | | - | |
| 251 | + | |
257 | 252 | | |
258 | 253 | | |
259 | | - | |
260 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
261 | 264 | | |
262 | 265 | | |
263 | 266 | | |
| |||
410 | 413 | | |
411 | 414 | | |
412 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
413 | 446 | | |
414 | 447 | | |
415 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | 153 | | |
180 | 154 | | |
181 | 155 | | |
| |||
0 commit comments