Skip to content

Compact window: Library ↔ Playlist toggle - #417

Merged
ad-repo merged 3 commits into
mainfrom
feat/compact-window-queue-toggle
Aug 10, 2026
Merged

ad-repo merged 3 commits into
mainfrom
feat/compact-window-queue-toggle

Conversation

@ad-repo

@ad-repo ad-repo commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a Library | Playlist toggle to the Compact window so users can view and edit the current playlist without opening the full Playlist window. Available in all three skin families (Modern, Metal, Classic). Also fixes a pre-existing bug found while testing.

Compact window toggle

  • A footer toggle at the bottom of the Compact window swaps its content region between the library browser and an embedded playlist.
  • Double-click a track to play it; selection, scrolling, and live now-playing highlight work in place.
  • The choice persists across launches (shared compactContentMode key across UI families).
  • Modern/Metal: the embedded playlist draws translucently so the Cava/art backdrop shows through it, matching the library list. Content-region bottom is threaded through a single contentRegionBottomY lever (status bar + footer), mirroring topChromeBottomY for the top, so the list/alphabet/hit-testing/scroll all reserve footer space.
  • Classic: managed in the container/controller rather than editing PlexBrowserView's internals. New ClassicCompactFooterView renders the toggle in authentic classic skin style; ClassicCompactContainerView lays out footer + browser/playlist (one visible at a time). Classic compact has no backdrop, so the embedded playlist stays opaque.
  • Both playlist views gained an isEmbedded flag (hides standalone title bar/close, disables window drag, routes body clicks to selection). The classic playlist hides its title bar via frame-extension behind the player bar (the browser's gap-free mechanism), sized to its own scale.

Bug fix (pre-existing)

  • Restored local videos misrouted to the audio engine. SavedTrack doesn't persist mediaType, so a video left in the playlist from a previous session was rebuilt as an audio track and failed to decode (kAudioFileInvalidFile). Restore now re-derives mediaType from the file extension (no file I/O), so videos open in the video player.

Testing

  • swift build clean.
  • Manual: toggle both modes in Modern/Metal/Classic compact windows; verified footer fills the width, backdrop shows through in Modern/Metal, no title-bar gap in Classic, playback/selection/scroll/persistence work.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Compact Window can switch between Library and Playlist views using a skin-aware footer.
    • The selected Compact Window view is remembered between sessions.
    • Embedded playlists integrate smoothly with Compact Window controls, layout, and focus behavior.
    • Playlist updates are now reflected consistently in both standalone and Compact Window views.
  • Bug Fixes

    • Restored local video files are correctly recognized and opened in the video player.

ad-repo and others added 2 commits August 10, 2026 16:05
The Compact window can now switch its content region between the library
browser and the current playlist via a toggle, so users can view and edit
the playlist without opening the full Playlist window.

Modern/Metal (ModernLibraryBrowserView):
- New persisted `compactContentMode` (shared UserDefaults key across UI families).
- Library | Playlist toggle rendered as a bottom footer; content region bottoms
  out at a single `contentRegionBottomY` lever (status bar + footer) so the list,
  alphabet index, hit-testing, and scroll clamping all reserve footer space.
- Embedded `ModernPlaylistView` fills the content region in Playlist mode; the
  library skips its content chrome there and the playlist draws transparently so
  the shared Cava/art backdrop shows through it like the library list.

ModernPlaylistView: `isEmbedded` flag hides the standalone title bar/close button
and disables window drag/undock (six title-bar sites), and makes the view
transparent when embedded; first-responder handoff enables keyboard nav.

Classic (PlexBrowser compact): managed in the container/controller rather than
editing PlexBrowserView's internals — classic compact has no backdrop, so the
embedded playlist stays opaque. New `ClassicCompactFooterView` draws the toggle in
authentic classic skin style; `ClassicCompactContainerView` lays out footer +
browser/playlist (browser XOR playlist by mode). `PlaylistView` gains `isEmbedded`
(non-draggable, no close) and hides its title bar via frame-extension behind the
player bar (the browser's gap-free mechanism), sized to its own scale.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
SavedTrack doesn't persist mediaType, and restorePlaylistState rebuilt local
tracks with the Track initializer's default (.audio) — so a video left in the
playlist from a previous session came back as audio and playTrack/loadTrack
routed it to AVAudioFile, which can't decode the video container (fails with
kAudioFileInvalidFile 'dta?'). Re-derive mediaType from the file extension on
restore (extension-only check, no file I/O) so videos open in the video player.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Compact Window now switches between the library and an embedded playlist with persisted state and skin support. Restored local video files now retain their video media type.

Changes

Compact Window playlist switching

Layer / File(s) Summary
Embedded playlist behavior
Sources/NullPlayer/Windows/ModernPlaylist/ModernPlaylistView.swift, Sources/NullPlayer/Windows/Playlist/PlaylistView.swift
Embedded playlists hide standalone window controls and backgrounds, prevent dragging, and focus when tracks are clicked.
Compact layout and footer
Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactContainerView.swift, Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactFooterView.swift, Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift
Compact layout reserves footer space, positions browser and playlist content, renders Library/Playlist controls, and updates geometry, scrolling, and hit testing.
Compact mode lifecycle and reload routing
Sources/NullPlayer/Windows/PlexBrowser/PlexBrowserWindowController.swift, Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserWindowController.swift, Sources/NullPlayer/Windows/CompactMode/CompactModeWindowController.swift, Sources/NullPlayer/App/WindowManager.swift, Sources/NullPlayer/App/AppDelegate.swift
Controllers create and remove compact subviews, persist the selected mode, apply skin updates, switch visibility and focus, and reload both standalone and compact playlists.

Local video state restoration

Layer / File(s) Summary
Restore local video media types
Sources/NullPlayer/App/AppStateManager.swift, CHANGELOG.md
Local video tracks now derive .video from their file extension during state restoration. The changelog records the change.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ClassicCompactFooterView
  participant PlexBrowserWindowController
  participant ModernLibraryBrowserView
  participant ModernPlaylistView
  User->>ClassicCompactFooterView: select Library or Playlist
  ClassicCompactFooterView->>PlexBrowserWindowController: report selected mode
  PlexBrowserWindowController->>ModernLibraryBrowserView: update compact content
  PlexBrowserWindowController->>ModernPlaylistView: toggle visibility and focus
  ModernLibraryBrowserView->>ModernPlaylistView: update embedded frame
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.82% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the primary change: a Library and Playlist toggle in the Compact window.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/compact-window-queue-toggle

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
Sources/NullPlayer/App/AppStateManager.swift (1)

999-1003: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a regression test for restored media types.

Test representative local video and audio extensions. Assert that restoration creates tracks with mediaType == .video and mediaType == .audio respectively. This protects the fix from future regressions.

🤖 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 `@Sources/NullPlayer/App/AppStateManager.swift` around lines 999 - 1003, Add a
regression test covering restoration through AppStateManager for representative
local video and audio file extensions. Assert restored video tracks have
mediaType .video and restored audio tracks have mediaType .audio, exercising the
AudioFileValidator.isVideoFile-based media type derivation.
🤖 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
`@Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift`:
- Around line 382-384: Remove the duplicate nested CompactContentMode
declaration in ModernLibraryBrowserView, retaining a single enum definition with
its existing library and queue cases.
- Around line 1204-1218: Synchronize compact playlist views after layout: in
Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift:1204-1218,
call queue.reloadData() after the final queue.frame assignment only when queue
is newly created; in
Sources/NullPlayer/Windows/PlexBrowser/PlexBrowserWindowController.swift:203-210,
call playlist.reloadData() after container.layoutChildren() and before showing
the selected compact content.
- Around line 1360-1364: Update the earlier sbRect.contains(dirtyRect) fast path
to also require showLibraryContent before calling drawServerBar. This prevents
server-bar-only redraws in compact queue mode while preserving the existing fast
path for other library content modes.

In `@Sources/NullPlayer/Windows/Playlist/PlaylistView.swift`:
- Around line 46-49: Update the embeddedTopInset computed property to return
Layout.titleBarHeight multiplied by scaleFactor only when isEmbedded is true;
otherwise return 0 as the safe standalone-mode default.

In `@Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactFooterView.swift`:
- Around line 137-146: Update ClassicCompactFooterView.mouseDown and the
corresponding footer implementation in
Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift:4017-4030
to expose separate Library and Playlist accessibility buttons with descriptive
labels, selected state, and press actions matching each segment. Add keyboard
activation for both controls while preserving the existing pointer selection
behavior; both listed sites require equivalent accessibility and keyboard
support.

---

Nitpick comments:
In `@Sources/NullPlayer/App/AppStateManager.swift`:
- Around line 999-1003: Add a regression test covering restoration through
AppStateManager for representative local video and audio file extensions. Assert
restored video tracks have mediaType .video and restored audio tracks have
mediaType .audio, exercising the AudioFileValidator.isVideoFile-based media type
derivation.
🪄 Autofix

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c1e7f0e-a0e2-4009-8d61-40d9d48c4454

📥 Commits

Reviewing files that changed from the base of the PR and between 7101d9f and 1ae850b.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • Sources/NullPlayer/App/AppStateManager.swift
  • Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift
  • Sources/NullPlayer/Windows/ModernPlaylist/ModernPlaylistView.swift
  • Sources/NullPlayer/Windows/Playlist/PlaylistView.swift
  • Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactContainerView.swift
  • Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactFooterView.swift
  • Sources/NullPlayer/Windows/PlexBrowser/PlexBrowserWindowController.swift

Comment on lines +382 to +384
/// Content shown below the compact player bar: the library browser or the play queue.
/// Only consulted when `compactMode == true`; the full library window is unaffected.
enum CompactContentMode: Int { case library = 0, queue = 1 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Remove the duplicate CompactContentMode declaration.

Line 384 redeclares the nested enum from Line 382. Swift rejects this invalid redeclaration, so the target cannot build. Keep one declaration.

🤖 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
`@Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift`
around lines 382 - 384, Remove the duplicate nested CompactContentMode
declaration in ModernLibraryBrowserView, retaining a single enum definition with
its existing library and queue cases.

Comment thread Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift Outdated
Comment thread Sources/NullPlayer/Windows/Playlist/PlaylistView.swift Outdated
Comment on lines +137 to +146
override func mouseDown(with event: NSEvent) {
let point = convert(event.locationInWindow, from: nil)
let scale = nativeScale
guard scale > 0 else { return }
// View point (bottom-left origin) → native units (top-left origin).
let nativeX = point.x / scale
let segments = segmentRects()
// Split at the divider so the entire footer width is clickable (incl. the thin margins).
onSelect?(nativeX >= segments.playlist.minX)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Expose the compact selector to keyboard and assistive technologies. Both Library/Playlist selectors are custom-drawn and pointer-only. VoiceOver users and keyboard-only users cannot switch compact content.

  • Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactFooterView.swift#L137-L146: expose Library and Playlist as accessible buttons with labels, selected state, and press actions. Add keyboard activation.
  • Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift#L4017-L4030: expose the two footer segments with equivalent accessibility and keyboard actions.
📍 Affects 2 files
  • Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactFooterView.swift#L137-L146 (this comment)
  • Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift#L4017-L4030
🤖 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 `@Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactFooterView.swift` around
lines 137 - 146, Update ClassicCompactFooterView.mouseDown and the corresponding
footer implementation in
Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift:4017-4030
to expose separate Library and Playlist accessibility buttons with descriptive
labels, selected state, and press actions matching each segment. Add keyboard
activation for both controls while preserving the existing pointer selection
behavior; both listed sites require equivalent accessibility and keyboard
support.

@ad-repo

ad-repo commented Aug 10, 2026

Copy link
Copy Markdown
Owner Author

Addressed the compact playlist review findings in 8f81f62:\n\n- Forward playlist mutations to both standalone and embedded compact playlist views.\n- Initialize embedded Classic and Modern/Metal playlists after final layout so current-track selection and scrolling are correct on first reveal.\n- Restore first-responder focus when Modern/Metal reopens directly in Playlist mode.\n- Suppress the Modern/Metal server-bar fast path while the transparent embedded playlist is visible.\n- Return a safe zero classic playlist inset outside embedded mode and remove the redundant playlist-color fallback.\n\nValidation:\n- swift build\n- swift test — 402 tests passed\n- git diff --check

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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
`@Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserWindowController.swift`:
- Around line 154-156: Update
ModernLibraryBrowserWindowController.reloadCompactPlaylist() to return
immediately unless the controller is in compact mode, using the applicable mode
check (isCompactMode or the project’s established isModernUIEnabled check)
before calling browserView.reloadCompactPlaylist().
🪄 Autofix

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

Review profile: CHILL

Plan: Pro Plus

Run ID: db02fff6-482f-4c42-af7f-6682a6c9b75f

📥 Commits

Reviewing files that changed from the base of the PR and between 1ae850b and 8f81f62.

📒 Files selected for processing (8)
  • Sources/NullPlayer/App/AppDelegate.swift
  • Sources/NullPlayer/App/WindowManager.swift
  • Sources/NullPlayer/Windows/CompactMode/CompactModeWindowController.swift
  • Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift
  • Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserWindowController.swift
  • Sources/NullPlayer/Windows/Playlist/PlaylistView.swift
  • Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactFooterView.swift
  • Sources/NullPlayer/Windows/PlexBrowser/PlexBrowserWindowController.swift
🚧 Files skipped from review as they are similar to previous changes (4)
  • Sources/NullPlayer/Windows/PlexBrowser/ClassicCompactFooterView.swift
  • Sources/NullPlayer/Windows/PlexBrowser/PlexBrowserWindowController.swift
  • Sources/NullPlayer/Windows/Playlist/PlaylistView.swift
  • Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserView.swift

Comment on lines +154 to +156
func reloadCompactPlaylist() {
browserView.reloadCompactPlaylist()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Guard the compact-only reload action.

ModernLibraryBrowserWindowController is also created for the normal library window. Add guard isCompactMode else { return } before forwarding reloadCompactPlaylist(). The downstream optional check is a safe fallback, but it does not enforce the mode boundary at this action layer.

As per coding guidelines, mode-specific action functions must use isModernUIEnabled or the applicable mode check.

Proposed fix
     func reloadCompactPlaylist() {
+        guard isCompactMode else { return }
         browserView.reloadCompactPlaylist()
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func reloadCompactPlaylist() {
browserView.reloadCompactPlaylist()
}
func reloadCompactPlaylist() {
guard isCompactMode else { return }
browserView.reloadCompactPlaylist()
}
🤖 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
`@Sources/NullPlayer/Windows/ModernLibraryBrowser/ModernLibraryBrowserWindowController.swift`
around lines 154 - 156, Update
ModernLibraryBrowserWindowController.reloadCompactPlaylist() to return
immediately unless the controller is in compact mode, using the applicable mode
check (isCompactMode or the project’s established isModernUIEnabled check)
before calling browserView.reloadCompactPlaylist().

Source: Coding guidelines

@ad-repo
ad-repo merged commit f645f9f into main Aug 10, 2026
1 check passed
@ad-repo
ad-repo deleted the feat/compact-window-queue-toggle branch August 31, 2026 13:57
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