Minimal mode follow-up review fixes - #1762
lawrencecchen wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughThis pull request implements per-window notification popover visibility tracking, refactors shortcut storage through a centralized API instead of direct UserDefaults access, fixes sidebar visibility logic inversion, improves workspace presentation mode initialization with titlebar handling, and updates corresponding UI and unit tests. Changes
Sequence Diagram(s)sequenceDiagram
participant Window as NSWindow
participant TitlebarControls as TitlebarControlsViewModel
participant NotificationPopover as TitlebarControlsAccessoryViewController
participant Controller as UpdateTitlebarAccessoryController
participant Delegate as AppDelegate
Window->>TitlebarControls: setHostWindow(window)
TitlebarControls->>TitlebarControls: Update hostWindow & hostWindowNumber
Note over NotificationPopover: User triggers popover
NotificationPopover->>NotificationPopover: Store popoverHostWindow = window
NotificationPopover->>Controller: Post cmuxNotificationsPopoverVisibilityDidChange<br/>(object: window)
Controller->>Controller: Receive notification with window context
Controller->>Controller: titlebarControlsShouldHandlePopoverVisibilityChange<br/>(hostWindowNumber, notificationObject)
alt Window Matches
Controller->>Controller: Update isNotificationsPopoverShown = true
else Window Mismatch
Controller->>Controller: Ignore notification
end
Delegate->>Controller: isNotificationsPopoverShown(in: window)
Controller-->>Delegate: Return per-window visibility state
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Sources/Update/UpdateTitlebarAccessory.swift`:
- Around line 1459-1466: isNotificationsPopoverShown(in:) can miss popovers
anchored externally; update the per-window check to also consider the popover's
external anchor window. In the predicate over controlsControllers.allObjects
(and using controller.popoverIsShownForTesting), treat a controller as shown for
the given window if controller.view.window === window OR if the controller's
popover has an externalAnchor whose window === window (e.g. check
controller.popover?.externalAnchor?.window). This ensures externally anchored
popovers are counted in the per-window visibility lookup.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d7931b07-3eae-48a0-84be-159ca4c10446
📒 Files selected for processing (8)
Sources/AppDelegate.swiftSources/TerminalController.swiftSources/Update/UpdateTitlebarAccessory.swiftSources/cmuxApp.swiftcmuxTests/AppDelegateShortcutRoutingTests.swiftcmuxTests/UpdatePillReleaseVisibilityTests.swiftcmuxUITests/BonsplitTabDragUITests.swiftcmuxUITests/MultiWindowNotificationsUITests.swift
| func isNotificationsPopoverShown(in window: NSWindow?) -> Bool { | ||
| guard let window else { | ||
| return isNotificationsPopoverShown() | ||
| } | ||
| return controlsControllers.allObjects.contains { controller in | ||
| controller.popoverIsShownForTesting && controller.view.window === window | ||
| } | ||
| } |
There was a problem hiding this comment.
Per-window visibility lookup can be wrong for externally anchored popovers.
isNotificationsPopoverShown(in:) checks controller.view.window === window, but popovers may be shown in externalAnchor.window (which can differ from the controller’s window). That causes false negatives when seeding per-window popover state.
Suggested fix
@@
final class TitlebarControlsAccessoryViewController: NSTitlebarAccessoryViewController, NSPopoverDelegate {
@@
var popoverIsShownForTesting: Bool { notificationsPopover.isShown }
+ func isNotificationsPopoverShown(in window: NSWindow?) -> Bool {
+ guard notificationsPopover.isShown else { return false }
+ guard let window else { return true }
+ return popoverHostWindow === window || view.window === window
+ }
@@
func isNotificationsPopoverShown(in window: NSWindow?) -> Bool {
guard let window else {
return isNotificationsPopoverShown()
}
return controlsControllers.allObjects.contains { controller in
- controller.popoverIsShownForTesting && controller.view.window === window
+ controller.isNotificationsPopoverShown(in: window)
}
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@Sources/Update/UpdateTitlebarAccessory.swift` around lines 1459 - 1466,
isNotificationsPopoverShown(in:) can miss popovers anchored externally; update
the per-window check to also consider the popover's external anchor window. In
the predicate over controlsControllers.allObjects (and using
controller.popoverIsShownForTesting), treat a controller as shown for the given
window if controller.view.window === window OR if the controller's popover has
an externalAnchor whose window === window (e.g. check
controller.popover?.externalAnchor?.window). This ensures externally anchored
popovers are counted in the per-window visibility lookup.
…iew-followups # Conflicts: # Sources/TerminalController.swift
Summary
Test Plan
Summary by cubic
Preserves Minimal mode for legacy hidden-titlebar setups and persists it to
UserDefaults, and scopes the notifications popover per window to prevent cross-window leaks. Also routes debug shortcut updates throughKeyboardShortcutSettingsand improves UI test stability.isNotificationsPopoverShown(in:)checks per-window.WorkspacePresentationModefrom the legacy hidden-titlebar preference when unset; otherwise defaults to Standard.Written for commit ee83108. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests