Fix Cmd+grave show/hide global hotkey
Root cause
showHideAllWindows could persist a Cmd+grave binding from Settings / cmux.json, but runtime registration dropped it before calling RegisterEventHotKey. The hardcoded system-wide conflict list always reserved Cmd+grave and Cmd+Shift+grave as macOS window-cycling shortcuts, and SystemWideHotkeyController.refreshRegistration re-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=0 for 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 showHideAllWindows system-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
- Added a regression test that the reporter’s exact shape (
key: "", keyCode: 50, command: true) maps toCarbonHotKeyRegistration(keyCode: 50, modifiers: cmdKey)and is accepted forshowHideAllWindows`. - Added coverage that Global Search still rejects the same Cmd+grave reservation.
- Probed
RegisterEventHotKey(50, cmdKey, ...)locally with a tiny Swift snippet: Carbon returnednoErrfor Cmd+grave. - Did not run a local cmux build or local tests per task instruction. The true end-to-end proof needs a running tagged app plus a global keypress from another app, so CI and later dogfood are the validation path.
Closes #6435
Need help on this PR? Tag /codesmith with 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. OnlyshowHideAllWindows can use Cmd+ and Cmd+Shift+`; other actions stay reserved, and Cmd+. remains blocked.
- Bug Fixes
- Filtered the hardcoded reservation so Cmd+
/Cmd+Shift+forshowHideAllWindowsaren’t treated as conflicts; others stay reserved. - Moved hotkey policy tests to Swift Testing with isolated
UserDefaultsand settings store, added teardown to restore state, and covered acceptance forshowHideAllWindows, rejection for Global Search, and Carbon keyCode/modifier mapping.
- Filtered the hardcoded reservation so Cmd+
Summary by CodeRabbit
-
Bug Fixes
- Improved system-wide keyboard shortcut conflict handling by applying action-specific filtering for command+grave (`) hotkeys—ensuring show/hide all windows accepts valid variants while other actions still respect reserved-shortcut rules.
-
Tests
- Added a new test suite covering system-wide shortcut policy behavior, including acceptance of command+grave (with and without shift) for show/hide all windows and rejection of command+grave for global search.