Repository navigation
feat(app): per-domain display revisions - #580
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedNext included review available in 27 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Repository: LargeModGames/spotatui/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (18)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: LargeModGames/spotatui/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (18)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe 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. ChangesDisplay State and Playback
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to No identified issue currently blocks merging this PR after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to 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 Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 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 |
Codecov Report❌ Patch coverage is
📢 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.
c868fc4 to
e0b7f3b
Compare
# 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 -->
Summary
This gives
Appone revision counter per displayed domain, so a frontend that does not redraw every frame can tell what changed. Every build writes the counters. Onlytestand the off-by-defaultguifeature can read them;src/gui/bridge.rs(two PRs up) is the first reader. It also stopscurrent_playback_snapshotfrom describing the paused Spotify track while another source starts.What changed:
DisplayRevisions(src/core/app/display_revisions.rs) is a privateAppfield with a named counter perDisplayDomain:Route,Status,Source,Theme,Playback. Both matches are exhaustive.App::display_revisions()andDisplayRevisions::getarecfg(any(test, feature = "gui")).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 andapply_settings_changes.Action::SetThemegoes through the newApp::set_theme_colors, which bumps Theme only when a color changed.App::note_playback_changecompares the position-free playback view (thePlaybackSnapshotwithprogress_mszeroed,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 ofNetwork::handle_network_event, the pump's source-router branch, the player event loop (skippingPositionChangedandPreloading),disconnect_streaming_player, the end ofDriver::tick, andApp::apply(now a wrapper around the old match).current_playback_snapshotreturnsNonewhenactive_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:
CHANGELOG.mdhas 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 warningson slim, headless, headless-streaming, mcp-only, ai-dj-only, default, theguileg and the five-sources set withaudio-viz-cpal: allFinished, no warnings.cargo test --locked,0 failedon every leg: slim1253 passed, headless851 passed, mcp-only1377 passed, ai-dj-only1530 passed(the four dead-code warnings ininfra/djtest helpers predate this stack), default1630 passed,guileg1369 passed.On this PR's own head:
cargo clippy --locked -- -D warningson slim, headless and default: clean.cargo test --no-default-features --features telemetry,tui gates:ok. 10 passed.bash tools/check_gates_ratchet.shagainst the PR below:ok.Additional notes
Part 3 of 7 of a stack (#578 to #584). Base: #579.
test_attribute_total2229 to 2243) pin each funnel's bump and non-bump, a position-only change leaving Playback alone, a routedFinishNativeQueuemoving Playback throughstart_tokio, and theNonesnapshot under a claim.note_playback_changebuilds and compares aPlaybackSnapshotat every boundary in every build, although only aguibuild reads the result.💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit