Right-sidebar mode shortcuts do nothing when the key view briefly clears
What you'd hit
Focus the right sidebar (files, sessions, and so on), then do something that briefly clears the key view. Press a right-sidebar mode shortcut (Ctrl+1..5 by default) during that window and nothing happens, instead of switching the sidebar mode.
Why
shouldRouteRightSidebarModeShortcut decides whether a mode shortcut routes to the sidebar. It bails to the active sidebar intent only when there is no first responder:
guard let responder = window.firstResponder else { return sidebarIntentActive }
But makeFirstResponder(nil) does not leave firstResponder nil. AppKit parks the first responder on the window itself, so window.firstResponder is the window. The guard treats that as a real responder and falls through to the terminal-surface checks, which can't resolve a view from a window and return false, so the shortcut does nothing even though a sidebar intent is active. The nil-responder fallback was added for exactly this "responder temporarily clears" case (#6472), but it keyed on a state AppKit essentially never produces.
Fix
Treat a responder that is the window itself like no responder:
guard let responder = window.firstResponder, responder !== window else { return sidebarIntentActive }
This only changes the one case where the responder is parked on the window and a sidebar intent is active. With no intent the result is unchanged, and a real view responder still takes the terminal path.
Tests
AppDelegateSurfaceShortcutRoutingTests.rightSidebarModeShortcutsDoNotFallThroughWhenResponderTemporarilyClears already exists (it shipped with the fallback in #6472) and is red on main, because the fallback keyed on nil while AppKit parks the responder on the window. Before, the mode shortcut falls through to selectSurfaceByNumber (the recorded issues are three keys across ten cycles). After, all 9 tests in the suite pass.
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.
Summary by cubic
Fix right-sidebar mode shortcuts (Ctrl+1–5) to still switch modes when the key view briefly clears. When makeFirstResponder(nil) parks focus on the window, treat window.firstResponder === window as no responder and route to the active right-sidebar intent.
Summary by CodeRabbit
- Bug Fixes
- Improved right-sidebar keyboard shortcut handling when no specific window control is focused.
- Shortcuts now correctly follow the active right-sidebar mode in this situation.