Repository navigation
Fix Cmd+grave show/hide global hotkey - #6477
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesCmd+` Hotkey Conflict Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 22 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (22 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 self-inflicted bug where
Confidence Score: 5/5Safe to merge — the production change is a single, well-bounded filter predicate that only touches one code path, and the logic is verified correct for every entry in the hardcoded conflict list. The filter expression correctly removes only the two Cmd+grave entries (unshifted and shifted) from the reserved list for No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["reservedSystemWideHotkeyShortcuts(excluding: currentAction)"] --> B["Add per-action configured shortcuts"]
B --> C["Filter hardcodedSystemWideHotkeyConflicts"]
C --> D{currentAction == showHideAllWindows?}
D -- No --> E["All hardcoded conflicts reserved\n(Ctrl+Tab, Cmd+grave, Cmd+Shift+grave, Cmd+.)"]
D -- Yes --> F{"entry.key == '`' &&\nentry.command &&\n!entry.option &&\n!entry.control?"}
F -- Yes --> G["Removed from reserved\n(Cmd+grave, Cmd+Shift+grave allowed)"]
F -- No --> H["Kept in reserved\n(Ctrl+Tab, Cmd+. still blocked)"]
E --> I["Return reserved list"]
G --> I
H --> I
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A["reservedSystemWideHotkeyShortcuts(excluding: currentAction)"] --> B["Add per-action configured shortcuts"]
B --> C["Filter hardcodedSystemWideHotkeyConflicts"]
C --> D{currentAction == showHideAllWindows?}
D -- No --> E["All hardcoded conflicts reserved\n(Ctrl+Tab, Cmd+grave, Cmd+Shift+grave, Cmd+.)"]
D -- Yes --> F{"entry.key == '`' &&\nentry.command &&\n!entry.option &&\n!entry.control?"}
F -- Yes --> G["Removed from reserved\n(Cmd+grave, Cmd+Shift+grave allowed)"]
F -- No --> H["Kept in reserved\n(Ctrl+Tab, Cmd+. still blocked)"]
E --> I["Return reserved list"]
G --> I
H --> I
Reviews (5): Last reviewed commit: "test: fix hotkey policy test teardown" | Re-trigger Greptile |
b64fa89 to
a24bc2b
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmuxTests/SystemWideHotkeyShortcutPolicyTests.swift (1)
56-63: 🧹 Nitpick | 🔵 Trivial | 💤 Low valueConsider testing Cmd+Shift+` rejection as well.
The acceptance test (lines 32-54) verifies both Cmd+` and Cmd+Shift+` for
showHideAllWindows. For symmetry and completeness, this rejection test could also verify thatglobalSearchrejects the shifted variant.✨ Optional: Add shifted variant test
`@Test` func globalSearchStillRejectsCommandGraveWindowCyclingHotkey() { let shortcut = commandGraveShortcut() `#expect`( KeyboardShortcutSettings.Action.globalSearch.normalizedRecordedShortcutResult(shortcut) == .rejected(.reservedBySystem) ) + + let shiftedShortcut = commandGraveShortcut(shift: true) + + `#expect`( + KeyboardShortcutSettings.Action.globalSearch.normalizedRecordedShortcutResult(shiftedShortcut) == + .rejected(.reservedBySystem) + ) }🤖 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 `@cmuxTests/SystemWideHotkeyShortcutPolicyTests.swift` around lines 56 - 63, The test `globalSearchStillRejectsCommandGraveWindowCyclingHotkey` currently only verifies rejection of the unshifted Cmd+` variant, but for consistency with the acceptance test (which checks both Cmd+` and Cmd+Shift+` for `showHideAllWindows`), this test should also verify that `globalSearch` rejects the shifted Cmd+Shift+` variant. Add an additional test case or expand the existing test to check that the shifted variant is also rejected with `.rejected(.reservedBySystem)` result.
🤖 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 `@cmuxTests/SystemWideHotkeyShortcutPolicyTests.swift`:
- Around line 56-63: The test
`globalSearchStillRejectsCommandGraveWindowCyclingHotkey` currently only
verifies rejection of the unshifted Cmd+` variant, but for consistency with the
acceptance test (which checks both Cmd+` and Cmd+Shift+` for
`showHideAllWindows`), this test should also verify that `globalSearch` rejects
the shifted Cmd+Shift+` variant. Add an additional test case or expand the
existing test to check that the shifted variant is also rejected with
`.rejected(.reservedBySystem)` result.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0e2a1973-2388-49f0-9cf3-f4b98318c9d3
📒 Files selected for processing (1)
cmuxTests/SystemWideHotkeyShortcutPolicyTests.swift
Root cause
showHideAllWindowscould persist a Cmd+grave binding from Settings /cmux.json, but runtime registration dropped it before callingRegisterEventHotKey. The hardcoded system-wide conflict list always reserved Cmd+grave and Cmd+Shift+grave as macOS window-cycling shortcuts, andSystemWideHotkeyController.refreshRegistrationre-runs that conflict check before registering.I verified the registration path rather than assuming the OS rejects it: a local Carbon probe for keyCode 50 returned
status=0for Cmd+grave, Cmd+Shift+grave, and Opt+grave. Ghostty’s working implementation uses a CGEvent tap for global keybinds, but cmux’s immediate failure was self-inflicted: the configured shortcut was never allowed to reach Carbon registration.Fix
Allow the Cmd+grave window-cycle pair only for the
showHideAllWindowssystem-wide action. The existing hardcoded reservations remain in place for other global hotkeys, including Global Search, and Cmd+. is still rejected for Show/Hide because it is AppKit’s standard cancel keystroke.Why this should not break other hotkeys
The change only filters the hardcoded Cmd+grave/Cmd+Shift+grave reservation when the current action being validated is
showHideAllWindows. Other system-wide actions still see that reservation, existing cmux action conflict checks still run, and the Carbon keyCode/modifier mapping path is unchanged.Verification
key: "", keyCode: 50, command: true) maps toCarbonHotKeyRegistration(keyCode: 50, modifiers: cmdKey)and is accepted forshowHideAllWindows`.RegisterEventHotKey(50, cmdKey, ...)locally with a tiny Swift snippet: Carbon returnednoErrfor Cmd+grave.Closes #6435
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Fixes the global Cmd+
show/hide hotkey so it registers and works system-wide on macOS. OnlyshowHideAllWindowscan use Cmd+and Cmd+Shift+`; other actions stay reserved, and Cmd+. remains blocked./Cmd+Shift+forshowHideAllWindowsaren’t treated as conflicts; others stay reserved.UserDefaultsand settings store, added teardown to restore state, and covered acceptance forshowHideAllWindows, rejection for Global Search, and Carbon keyCode/modifier mapping.Written for commit e3e8a55. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests