Repository navigation
Fix close shortcuts targeting original window - #4615
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughCmd+W and Cmd+Shift+W close shortcuts are updated to resolve targets by preferring the current focused cmux terminal window (via NSApp.keyWindow/NSApp.mainWindow) and fall back to event-derived metadata only when necessary. Three AppDelegate helpers implement this resolution, three shortcut paths are refactored to use them, and tests validate behavior when event-window metadata is stale. ChangesFocused window close shortcut routing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 16 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (16 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 |
Greptile SummaryThis PR fixes a focus-routing bug where Confidence Score: 5/5Safe to merge — the routing change is well-scoped, the priority order (keyWindow → mainWindow → event fallback) is correct for all three close actions, and the regression tests directly cover the stale-metadata scenario that prompted the fix. The three new helpers correctly prefer the actually focused window over AppKit event metadata. The auxiliary-window check in closeTab is expanded to include keyWindow and mainWindow before the event window, which is strictly better than the old code. The closeWorkspace and closeWindow handlers are simpler and more correct. No incorrect data can reach the close operations through the new paths. The regression tests verify the exact bug scenario end-to-end. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Close shortcut fired\nCmd+W / Cmd+Shift+W / Cmd+Q] --> B{matchConfiguredShortcut}
B -->|closeTab| CT_AUX[auxiliaryWindowForFocusedCloseShortcut]
CT_AUX --> CT_AUX1{keyWindow is\nauxiliary?}
CT_AUX1 -->|Yes| CLOSE_AUX[performClose on aux window]
CT_AUX1 -->|No| CT_AUX2{mainWindow is\nauxiliary?}
CT_AUX2 -->|Yes| CLOSE_AUX
CT_AUX2 -->|No| CT_AUX3{event window is\nauxiliary?}
CT_AUX3 -->|Yes| CLOSE_AUX
CT_AUX3 -->|No| CT_MGR[routedManager from\ntabManagerForFocusedCloseShortcut]
CT_MGR --> CT_PANEL[closeCurrentPanelWithConfirmation]
B -->|closeWorkspace| CW_MGR[tabManagerForFocusedCloseShortcut]
CW_MGR --> CW_CLOSE[closeCurrentWorkspaceWithConfirmation]
B -->|closeWindow| CW_WIN[mainWindowForFocusedCloseShortcut]
CW_WIN --> CW_SYNC[synchronizeActiveMainWindowContext]
CW_SYNC --> CW_CONF[closeWindowWithConfirmation]
subgraph mainWindowForFocusedCloseShortcut
MF1{keyWindow is\nmain terminal?}
MF1 -->|Yes| MF_KEY[return keyWindow]
MF1 -->|No| MF2{mainWindow is\nmain terminal?}
MF2 -->|Yes| MF_MAIN[return mainWindow]
MF2 -->|No| MF_EVT[mainWindowForShortcutEvent - event fallback]
end
CT_MGR -.-> MF1
CW_MGR -.-> MF1
CW_WIN -.-> MF1
Reviews (2): Last reviewed commit: "test: tighten close shortcut routing ass..." | Re-trigger Greptile |
Summary
Testing
Fixes #4614
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.Note
Medium Risk
Changes global keyboard shortcut routing for close actions (
Cmd+W,Cmd+Shift+W, close window), which can affect multi-window behavior and regress edge cases involving auxiliary windows.Overview
Fixes close-shortcut routing so focused-window close actions prefer
NSApp.keyWindow/NSApp.mainWindowover potentially staleNSEventwindow metadata, and syncs the active main-window context before executing close operations.This introduces focused close helpers (
mainWindowForFocusedCloseShortcut,tabManagerForFocusedCloseShortcut,auxiliaryWindowForFocusedCloseShortcut) to consistently decide between auxiliary windows (e.g., browser popups) and the focused main window’sTabManager.Adds regression tests ensuring
Cmd+W(close tab/panel) andCmd+Shift+W(close workspace) act on the currently focused window even when the key event’swindowNumberpoints at an older window.Reviewed by Cursor Bugbot for commit 12056b5. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Route close shortcuts to the focused window so tabs, workspaces, and windows close in the right place, even when the key event has stale window metadata. Adds stricter regression tests for Cmd+W and Cmd+Shift+W. Fixes #4614.
keyWindow/mainWindowand resync app context; only fall back to the event’s window.TabManager.Written for commit 12056b5. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
Bug Fixes
Tests