Skip to content

Support responsive height in Playlist Manager and Playlist views#226

Merged
bjarneo merged 9 commits into
bjarneo:mainfrom
zambetti:playlist-responsive
May 14, 2026
Merged

Support responsive height in Playlist Manager and Playlist views#226
bjarneo merged 9 commits into
bjarneo:mainfrom
zambetti:playlist-responsive

Conversation

@zambetti
Copy link
Copy Markdown
Contributor

@zambetti zambetti commented May 11, 2026

This PR improves the Playlist Manager and Playlist views by adding support for the expanded-view setting ctrl+x

Additionally, there are improvements to scrolling behavior, the helpKey line to clarify navigation and display the track name next to the 'add' functions, and corrected visibilty #/# status in the playlist views (and keymap).

Summary by CodeRabbit

  • Bug Fixes

    • Improved scroll position preservation during filter interactions in the playlist manager.
    • Fixed viewport anchoring to keep selected items visible when navigating lists and tracks.
  • Improvements

    • Enhanced counter display logic for filtered vs. unfiltered views.
    • Refactored overlay rendering for better scrolling behavior consistency across navigation interactions.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

📝 Walkthrough

Walkthrough

This PR adds viewport scroll position tracking to the playlist manager overlay, enabling the UI to anchor the cursor in view during navigation and filter interactions. It extends the playlist manager state with scroll fields, adds measurement and adjustment helpers per screen, integrates scroll management into key handling and the update cycle, and refactors the overlay rendering with shell helpers and inline footer counter logic.

Changes

Playlist Manager Scroll Management

Layer / File(s) Summary
State Model Extension
ui/model/state.go
plManagerState struct gains scroll and savedScroll fields to track and preserve vertical scroll position.
Measurement and Scroll Helpers
ui/model/overlays.go, ui/model/scroll.go
New functions plMgrListVisible(), plMgrListMaybeAdjustScroll(), plMgrTracksVisible(), and plMgrTracksMaybeAdjustScroll() measure visible content and clamp scroll for list and tracks screens. measurePlVisible updated to use mainSections for consistent chrome measurement. applyHeightMode and adjustScroll now guard against nil playlist.
Overlay Initialization and State Management
ui/model/overlays.go
openPlaylistManager initializes cursor, scroll, and deletion state, then applies list-screen scroll adjustment. plMgrEnterTrackList resets scroll state and applies tracks-screen adjustment. plMgrResetFilter and filter recomputation reset scroll and apply screen-appropriate adjustment. plMgrRefreshList re-adjusts list scroll after playlist reload.
Key Handler Updates
ui/model/keys.go
All three key handlers (handlePlMgrListKey, handlePlMgrFilterKey, handlePlMgrTracksKey) updated to save/restore scroll on filter entry/exit, reset scroll to 0 during filtering, and call per-screen scroll-adjustment helpers on navigation (cursor movement, paging, expand/collapse, home/end). Filter cancellation and exit restore both cursor and scroll. Down-key during filtering exits immediately with cursor/scroll reset.
Update Cycle Integration
ui/model/update.go
After KeyPressMsg handling, applyHeightMode() and adjustScroll() recalculate visible heights and scroll. On WindowSizeMsg, scroll adjustment extends to playlist manager when visible, selecting list or tracks logic based on active screen.
Overlay View Rendering
ui/model/view_overlays.go
Playlist manager list rendering refactored to use plMgrListShell() helper and internal plRow model, with explicit spacer and pseudo-item handling and early-return paths for empty/no-match states. Tracks rendering refactored to use plMgrTracksShell(), switch to m.plMgrTracksVisible() for sizing, and inline rendered/total counters. Footer keybindings updated for both screens. New playlist name overlay uses dynamic now-playing-aware label. Import added for cliamp/history to handle special playlist items.
Navigation List Footer Display
ui/model/view_nav.go, ui/model/view_helpers.go
Generic navCountLine helper removed. Artist, album, and track list renderers now compute rendered-row counts inline and build footers showing rendered/total (normal) or total/total (when search active), replacing the previous helper.
Keymap View Updates
ui/model/keymap.go
Keymap probe-line construction simplified to delegate footer-message insertion to appendFooterMessages. Footer rendering updated to use appendFooterMessages with conditional footerCount formatting for search vs non-search states.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • bjarneo/cliamp#217: Both PRs modify the same playlist-visible/height and scroll logic (measurePlVisible, applyHeightMode/adjustScroll and related playlist-overlay state/handlers).
  • bjarneo/cliamp#190: Both PRs modify playlist scrolling and playlist-manager rendering (changes to scroll logic and renderPlMgrTracks/related helpers).
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main objective: adding responsive height support to Playlist Manager and Playlist views, which aligns with the documented PR objectives and the substantial refactoring across multiple view files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/model/keys.go (1)

1588-1619: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Re-clamp playlist-manager scroll after track removal.

After case "d" removes a track and updates m.plManager.tracks, the cursor is re-clamped (lines 1612-1618) but m.plManager.scroll is not. The filter branch is covered because plMgrRecomputeFilter calls plMgrTracksMaybeAdjustScroll internally, but when m.plManager.filter == "" the scroll can be left pointing past len(tracks)-visible (e.g., deleting the last track while scrolled near the bottom). The viewport then renders blank trailing rows until the next user input.

🛠️ Proposed fix
             newCount := m.plMgrTracksViewCount()
             if m.plManager.cursor >= newCount {
                 m.plManager.cursor = newCount - 1
             }
             if m.plManager.cursor < 0 {
                 m.plManager.cursor = 0
             }
+            m.plMgrTracksMaybeAdjustScroll(m.plMgrTracksVisible())
         }
🤖 Prompt for 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.

In `@ui/model/keys.go` around lines 1588 - 1619, The removal flow in case "d"
updates m.plManager.tracks and re-clamps m.plManager.cursor but never adjusts
m.plManager.scroll when m.plManager.filter == "", causing blank trailing rows;
fix by invoking the existing scroll-adjust helper
(m.plMgrTracksMaybeAdjustScroll()) after updating m.plManager.tracks (or
otherwise clamp m.plManager.scroll to the valid range computed from len(tracks)
and the visible count), keeping the cursor adjustments as-is; place the call
just after setting m.plManager.tracks and after the filter-branch so both
filtered and unfiltered paths ensure scroll is valid.
🤖 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.

Outside diff comments:
In `@ui/model/keys.go`:
- Around line 1588-1619: The removal flow in case "d" updates m.plManager.tracks
and re-clamps m.plManager.cursor but never adjusts m.plManager.scroll when
m.plManager.filter == "", causing blank trailing rows; fix by invoking the
existing scroll-adjust helper (m.plMgrTracksMaybeAdjustScroll()) after updating
m.plManager.tracks (or otherwise clamp m.plManager.scroll to the valid range
computed from len(tracks) and the visible count), keeping the cursor adjustments
as-is; place the call just after setting m.plManager.tracks and after the
filter-branch so both filtered and unfiltered paths ensure scroll is valid.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b8250322-1c7e-4325-9e8e-85519d13986c

📥 Commits

Reviewing files that changed from the base of the PR and between 42564b5 and ba1c4bd.

📒 Files selected for processing (9)
  • ui/model/keymap.go
  • ui/model/keys.go
  • ui/model/overlays.go
  • ui/model/scroll.go
  • ui/model/state.go
  • ui/model/update.go
  • ui/model/view_helpers.go
  • ui/model/view_nav.go
  • ui/model/view_overlays.go
💤 Files with no reviewable changes (1)
  • ui/model/view_helpers.go

@bjarneo bjarneo merged commit 72c5829 into bjarneo:main May 14, 2026
1 check passed
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.

2 participants