Skip to content

Improvements to album header visibility & control#234

Open
zambetti wants to merge 6 commits into
bjarneo:mainfrom
zambetti:improve-album-header-heuristic
Open

Improvements to album header visibility & control#234
zambetti wants to merge 6 commits into
bjarneo:mainfrom
zambetti:improve-album-header-heuristic

Conversation

@zambetti
Copy link
Copy Markdown
Contributor

@zambetti zambetti commented May 16, 2026

Previously, whether or not to show album headers was only decided on application launch, or when the entire playlist was replaced. This PR ensures the layout stays in sync as content changes, while also respecting manual user preference.

Changes

  • Runs the cohesion heuristic whenever tracks are added or queued so headers adapt as the playlist grows.
  • Preserves user preference for headers chosen with ctrl+h.
  • Provider browsing views now compute headers from their own results rather than the background playlist.
  • Replaces hardcoded header visibility default at launch with a heuristic check of the initial tracks.

Summary by CodeRabbit

  • Refactor

    • Header-state logic unified: header display is now recalculated consistently whenever tracks are added, queued, replaced, loaded, or when resuming sessions.
    • Heuristic reorganized to compute album/header cohesion from contiguous album segments and track counts.
  • New Features

    • Manual header toggle now sets a persistent manual mode so user show/hide preference is preserved.
    • Header state is derived from playlist tracks when replacing or resuming.
  • Bug Fixes

    • Fewer stale or incorrect header displays during playback, navigation, and playlist operations.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaces parameterized header initialization with setHeaderStateFromTracks/refreshHeaderState, adds a headerManual flag, and updates initialization, key handlers, overlays, playback flows, and Model.Update handlers to recompute header visibility after playlist mutations.

Changes

Header State Refresh Refactoring

Layer / File(s) Summary
Core header methods and heuristic
ui/model/view_helpers.go
Adds setHeaderStateFromTracks, refreshHeaderState, and computeHeaderState; removes setInitialHeaderState/isListCohesive.
Model field and startup initialization
ui/model/model.go, ui/model/init.go
Adds headerManual bool to Model; calls refreshHeaderState() in New and uses setHeaderStateFromTracks in ResumePlaylist.
Message and IPC handler updates
ui/model/update.go
Model.Update handlers and IPC calls now derive header state using setHeaderStateFromTracks(...) when replacing with a known track set, or call refreshHeaderState() after appends (covers tracksLoadedMsg, navTracksLoadedMsg, ytdlBatchMsg, feedTrackResolvedMsg, feedsLoadedMsg, fbTracksResolvedMsg, ipc.LoadMsg, ipc.QueueMsg).
Key handlers, overlays, and playback flows
ui/model/keys.go, ui/model/keys_nav.go, ui/model/overlays.go, ui/model/playback.go
ctrl+h now sets headerManual = true via toggleAlbumHeadersManual(); after playlist Add/Replace paths (playlist manager load/play, nav enter/R/a/q, overlay entry, play/append/queue), code calls refreshHeaderState() or setHeaderStateFromTracks() to sync header UI.

Sequence Diagrams

sequenceDiagram
  participant User
  participant Handler as UI Handler
  participant Playlist
  participant HeaderUI as Header State
  User->>Handler: action (enter, R, a, q, play, ctrl+h)
  Handler->>Playlist: Add/Replace tracks
  Handler->>HeaderUI: refreshHeaderState() / setHeaderStateFromTracks()
  HeaderUI->>Playlist: Tracks()
  HeaderUI->>HeaderUI: computeHeaderState
Loading
sequenceDiagram
  participant Events as Event/Message
  participant UpdateHandler
  participant Playlist
  participant HeaderUI as Header State
  Events->>UpdateHandler: tracksLoaded, navTracksLoaded, ytdlBatch, etc.
  UpdateHandler->>Playlist: Replace or Add tracks
  UpdateHandler->>HeaderUI: refreshHeaderState() / setHeaderStateFromTracks()
  HeaderUI->>Playlist: Tracks()
  HeaderUI->>HeaderUI: computeHeaderState
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • bjarneo/cliamp#208: Refactors album-header initialization and introduced related header-state behavior used here.
  • bjarneo/cliamp#190: Changes rendering/counting of album separators, touching related header/display behavior.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Title check ✅ Passed The title 'Improvements to album header visibility & control' clearly and concisely summarizes the main objective of the PR, which is to improve how album headers are displayed and controlled throughout the application.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 `@ui/model/view_helpers.go`:
- Around line 223-225: refreshHeaderState currently always sets
m.showAlbumHeaders from m.playlist.Tracks(), which breaks header heuristics for
non-playlist flows; restore source-specific computation by changing
refreshHeaderState to only apply when the visible list is the current playlist
and add/use the helper m.setHeaderStateFromTracks(tracks) to derive
m.showAlbumHeaders via isListCohesive(tracks) in playlist-manager and
nav-browser loaders and any other non-playlist callers so each caller computes
headers from its visible track slice instead of always using
m.playlist.Tracks().
🪄 Autofix (Beta)

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: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3391f6ef-458b-4709-91cd-15afd5a0ff89

📥 Commits

Reviewing files that changed from the base of the PR and between 94ba80c and f40c695.

📒 Files selected for processing (7)
  • ui/model/init.go
  • ui/model/keys.go
  • ui/model/keys_nav.go
  • ui/model/overlays.go
  • ui/model/playback.go
  • ui/model/update.go
  • ui/model/view_helpers.go

Comment thread ui/model/view_helpers.go Outdated
@zambetti zambetti changed the title Update album header visibility on track addition Improvements to album header visibility May 17, 2026
@zambetti zambetti changed the title Improvements to album header visibility Improvements to album header visibility & control May 18, 2026
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