Skip to content

feat(app): per-domain display revisions - #580

Merged
LargeModGames merged 2 commits into
feat/frontend-runtimefrom
feat/display-revisions
Sep 26, 2026
Merged

LargeModGames merged 2 commits into
feat/frontend-runtimefrom
feat/display-revisions

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

This gives App one revision counter per displayed domain, so a frontend that does not redraw every frame can tell what changed. Every build writes the counters. Only test and the off-by-default gui feature can read them; src/gui/bridge.rs (two PRs up) is the first reader. It also stops current_playback_snapshot from describing the paused Spotify track while another source starts.

What changed:

  1. DisplayRevisions (src/core/app/display_revisions.rs) is a private App field with a named counter per DisplayDomain: Route, Status, Source, Theme, Playback. Both matches are exhaustive. App::display_revisions() and DisplayRevisions::get are cfg(any(test, feature = "gui")).
  2. Route, Status, Source and Theme bump inside their existing funnels, and a no-op (a repeat push, a refused pop, an unchanged source or theme) bumps nothing: push_navigation_stack, pop_navigation_stack, drop_error_routes, set_current_route_state, set_status_message, set_error_status_message, clear_status_message, handle_error, clear_api_error, set_active_source, the adaptive-theme fade and apply_settings_changes.
  3. Action::SetTheme goes through the new App::set_theme_colors, which bumps Theme only when a color changed.
  4. App::note_playback_change compares the position-free playback view (the PlaybackSnapshot with progress_ms zeroed, desired_volume(), the device name, the liked flag) with the last one and bumps Playback on a difference. It runs at the producer boundaries: the tail of Network::handle_network_event, the pump's source-router branch, the player event loop (skipping PositionChanged and Preloading), disconnect_streaming_player, the end of Driver::tick, and App::apply (now a wrapper around the old match).
  5. current_playback_snapshot returns None when active_decoded_source() holds but no source session exists yet, instead of falling through to the suspended Spotify context.

Deliberate behaviour changes a user can see:

  1. While Local Files, Subsonic, Internet Radio, YouTube or Qobuz fetches or probes its first track over a paused Spotify track, the OS media panels (MPRIS, Windows, macOS), Discord, the lyrics and cover-art panes and the spotatui.com now-playing card show nothing, and the window title falls back to the default. The same holds after such a start fails, for as long as the source keeps its claim on the output. CHANGELOG.md has the entry.

Testing

The suites ran on the top of the stack (feat/gui-onboarding), which contains this PR:

  • cargo fmt --all -- --check: clean.
  • cargo clippy --locked -- -D warnings on slim, headless, headless-streaming, mcp-only, ai-dj-only, default, the gui leg and the five-sources set with audio-viz-cpal: all Finished, no warnings.
  • cargo test --locked, 0 failed on every leg: slim 1253 passed, headless 851 passed, mcp-only 1377 passed, ai-dj-only 1530 passed (the four dead-code warnings in infra/dj test helpers predate this stack), default 1630 passed, gui leg 1369 passed.

On this PR's own head: cargo clippy --locked -- -D warnings on slim, headless and default: clean. cargo test --no-default-features --features telemetry,tui gates: ok. 10 passed. bash tools/check_gates_ratchet.sh against the PR below: ok.

Additional notes

Part 3 of 7 of a stack (#578 to #584). Base: #579.

  • 14 new tests (test_attribute_total 2229 to 2243) pin each funnel's bump and non-bump, a position-only change leaving Playback alone, a routed FinishNativeQueue moving Playback through start_tokio, and the None snapshot under a claim.
  • No test drives the OS panels, Discord, lyrics, cover art or the now-playing card through the new arm. They all read the snapshot the test pins. The MPRIS and macOS Now Playing arms compile only on their platforms.
  • Cost: note_playback_change builds and compares a PlaybackSnapshot at every boundary in every build, although only a gui build reads the result.
  • The next PR adds the Party, Devices, Search, Lyrics, Artist, Library and Queue domains and makes their fields private.

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

Summary by CodeRabbit

  • Bug Fixes
    • Media panels, Discord, the window title, lyrics and cover art, and the now-playing card no longer show a stale Spotify track while another source is loading or checking its first track.
    • Playback and display updates now stay in sync when tracks, routes, status messages, or themes change.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: d0eda759-3bf1-4f85-8a88-b79fb7620fd3

📥 Commits

Reviewing files that changed from the base of the PR and between c868fc4 and e0b7f3b.

📒 Files selected for processing (18)
  • CHANGELOG.md
  • src/core/action/apply.rs
  • src/core/action/tests.rs
  • src/core/app/album_theme.rs
  • src/core/app/construction.rs
  • src/core/app/display_revisions.rs
  • src/core/app/mod.rs
  • src/core/app/playback_routing.rs
  • src/core/app/route.rs
  • src/core/app/settings_apply.rs
  • src/core/app/status.rs
  • src/core/app/tick.rs
  • src/core/driver/mod.rs
  • src/infra/media_metadata.rs
  • src/infra/network/mod.rs
  • src/infra/player/events.rs
  • src/runtime/pump.rs
  • tools/gates.count

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: 85b53b1a-c603-4905-9e1d-97a35e8eb22f

📥 Commits

Reviewing files that changed from the base of the PR and between 308428f and c868fc4.

📒 Files selected for processing (18)
  • CHANGELOG.md
  • src/core/action/apply.rs
  • src/core/action/tests.rs
  • src/core/app/album_theme.rs
  • src/core/app/construction.rs
  • src/core/app/display_revisions.rs
  • src/core/app/mod.rs
  • src/core/app/playback_routing.rs
  • src/core/app/route.rs
  • src/core/app/settings_apply.rs
  • src/core/app/status.rs
  • src/core/app/tick.rs
  • src/core/driver/mod.rs
  • src/infra/media_metadata.rs
  • src/infra/network/mod.rs
  • src/infra/player/events.rs
  • src/runtime/pump.rs
  • tools/gates.count

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


📝 Walkthrough

Walkthrough

The app now tracks revisions for route, status, source, theme, and playback views. State updates and playback event paths record relevant changes. Decoded sources that own the sink without a playback session no longer report stale Spotify context metadata.

Changes

Display State and Playback

Layer / File(s) Summary
Display revision model and App state
src/core/app/display_revisions.rs, src/core/app/mod.rs, src/core/app/construction.rs
Adds five display revision counters, accessors for tests and GUI builds, and App state initialization.
Route, status, and theme revision updates
src/core/app/route.rs, src/core/app/status.rs, src/core/app/settings_apply.rs, src/core/app/tick.rs, src/core/app/album_theme.rs, src/core/action/apply.rs, src/core/action/tests.rs, tools/gates.count
Route, source, status, and theme state changes update their matching revision only when the relevant state changes. Tests cover revision behavior, and the test-attribute adoption baseline increases.
Playback revision comparison and event recording
src/core/app/playback_routing.rs, src/core/action/apply.rs, src/core/driver/mod.rs, src/infra/network/mod.rs, src/infra/player/events.rs, src/runtime/pump.rs
The app compares playback views without progress-only changes and records revisions after relevant action and event paths. Tests cover playback-view comparisons and source-router handling.
Decoded-source snapshot behavior
src/infra/media_metadata.rs, CHANGELOG.md
A decoded source that owns the sink but has no playback session returns no snapshot instead of Spotify context metadata. A regression test and changelog entry cover the now-playing behavior.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to c868f

No identified issue currently blocks merging this PR after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to c868f

The changes prevent an inactive decoded source from displaying an older Spotify track. No new privileged access path or confirmed security regression was found, but source-switching behavior and production use of the new display counters are not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is local playback metadata and display-state observation across sources; the reviewed revision API does not itself grant playback mutation authority.

Trust Boundaries and Controls

  • observed — The decoded-sink ownership check blocks a stale Spotify track from the shared snapshot when the decoded session is absent; the regression test exercises that handoff.

Hardening Proposals

  • proposed — Before relying on playback revisions for production display invalidation, exercise equal-metadata source switches and ensure device and liked-state comparisons derive from the owning source.
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title uses the valid conventional-commit prefix and clearly describes the main change. However, the subject is not imperative, as required. Change the subject to an imperative form, for example, "feat(app): add per-domain display revisions".
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR

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.

@LargeModGames LargeModGames changed the title feat/display revisions feat(app): per-domain display revisions Sep 26, 2026
@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.24138% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/infra/player/events.rs 0.0% 6 Missing ⚠️
src/core/driver/mod.rs 0.0% 1 Missing ⚠️
src/infra/network/mod.rs 0.0% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

A private DisplayRevisions on App moves one counter per displayed domain (route, status, browse source, theme, playback) only when that domain changed, so a frontend can tell what to redraw. Route, status, source and theme bump inside their existing App funnels; Action::SetTheme goes through a new App::set_theme_colors. Playback bumps at the producer boundaries (the network handler tail, the pump's router branch, the player event loop, the driver tick, App::apply) when the position-free playback view changed. The snapshot no longer falls through to the suspended Spotify track while a decoded source holds the sink with no session yet.
@LargeModGames
LargeModGames merged commit e3d06fb into main Sep 26, 2026
31 checks passed
@LargeModGames
LargeModGames deleted the feat/display-revisions branch September 26, 2026 11:25
LargeModGames added a commit that referenced this pull request Sep 26, 2026
# Summary

This makes most of the display state on `App` private, so each write
goes through a method that bumps the matching `DisplayRevisions` counter
from the PR below. A frontend can then redraw a domain only when its
revision moved. `DisplayDomain` gains `Party`, `Devices`, `Search`,
`Lyrics`, `Artist`, `Library` and `Queue`.

What changed:

1. `devices`, `search_results`, `party_status` and `party_session` are
private. Writes go through `set_devices`, `set_search_results`,
`set_party_status`, `set_party_session` and `party_session_mut`.
`set_search_results` now owns the cursor clamp, and
`clamp_search_cursors` is private. Readers outside `core/app` use
getters.
2. `lyrics`, `lyrics_status` and `lyrics_synced` are private behind
`App::set_lyrics`. The LRCLIB answer is applied by a pure
`apply_lyrics_response`.
3. The artist, album and show pages stay public and bump the `Artist`
revision where their producers finish (`App::bump_display` in
`infra/network/metadata.rs`, and in `core/app/library.rs`). `DjState`
gets a `revision` that its mutators bump: turn start and finish,
transcript lines, the step, the vibe, library indexing and the two
toggles.
4. The library pages, the playlist lists and folders, the saved-id sets,
the user and the five per-source sidebar lists are private, with one
getter and one `_mut` accessor per field. The accessor bumps the
`Library` revision. The in-app pagers and sorts use it too.
5. `queue` stays public. `note_playback_change` becomes
`note_display_changes`, which also compares the Spotify queue mirror,
the native queue and the queue-slot track at the same boundaries and
bumps `Queue` on a difference. It compares by reference and clones only
on a change.
6. `show_source_search_tracks` bumps `Search` without the clamp, so a
decoded-source search leaves the hidden result blocks' cursors for the
next Spotify search, as before.
7. `tools/gates.count`: `pub_fields_on_app` 139 -> 117,
`app_field_writes_in_tui_handlers` 186 -> 147.

The setters bump only `DisplayRevisions`. The plugin data generations
(`PluginDataKind`) bump where they did before, so plugins see no change.

No behaviour change.

# Testing

The suites ran on the top of the stack (`feat/gui-onboarding`), which
contains this PR:

- `cargo fmt --all -- --check`: clean.
- `cargo clippy --locked -- -D warnings` on slim, headless,
headless-streaming, mcp-only, ai-dj-only, default, the `gui` leg and the
five-sources set with `audio-viz-cpal`: all `Finished`, no warnings.
- `cargo test --locked`, `0 failed` on every leg: slim `1253 passed`,
headless `851 passed`, mcp-only `1377 passed`, ai-dj-only `1530 passed`
(the four dead-code warnings in `infra/dj` test helpers predate this
stack), default `1630 passed`, `gui` leg `1369 passed`.

On this PR's own head: `cargo clippy --locked -- -D warnings` on slim,
headless and default: clean. `cargo test --no-default-features
--features telemetry,tui gates`: `ok. 10 passed`. `bash
tools/check_gates_ratchet.sh` against the PR below: `ok`.

# Additional notes

Part 4 of 7 of a stack (#578 to #584). Base: #580.

The Linux `all-sources` test leg and the macOS job run only in CI.

Known trade-offs:

- A `_mut` accessor bumps `Library` when it is called, whether or not
the caller then writes. That can cause an extra redraw, never a missed
one.
- `DjState.revision` does not move for the setup picker or prompt edits.
Those are presentation state.
- Nothing outside tests reads the new revisions here.
`App::display_revisions` is `cfg(any(test, feature = "gui"))`.

Follow-ups:

- The track table (`track_table`, `playlist_track_*`, `recently_played`)
stays public with no revision.
- `App::raise_spotify_key_tier` (from #577) changes the artist page's
empty Top Tracks text without an `Artist` bump. Nothing sends the artist
page to a frontend yet, so it can bump when something does.

---
<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

* **Bug Fixes**
* Search results now consistently reset or clamp table cursors when
replaced.
* Updates to playlists, search results, lyrics, devices, artist
information, queues, and party and DJ state are reflected more reliably
in the display.

<!-- 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.

1 participant