MAESTRO: Allow tab switcher shortcut (Alt+Cmd+T) from file preview

Added isTabSwitcherShortcut to the overlay allowlist so users can
open the tab switcher modal while viewing a file preview tab.
This commit is contained in:
Pedram Amini
2026-02-02 16:44:51 -06:00
parent 21486e3a79
commit 1b42636d9d
2 changed files with 34 additions and 2 deletions

View File

@@ -378,6 +378,33 @@ describe('useMainKeyboardHandler', () => {
expect(mockSetSessions).toHaveBeenCalled();
expect(mockSetActiveFocus).toHaveBeenCalledWith('main');
});
it('should allow tab switcher shortcut (Alt+Cmd+T) when only overlays are open', () => {
const { result } = renderHook(() => useMainKeyboardHandler());
const mockSetTabSwitcherOpen = vi.fn();
result.current.keyboardHandlerRef.current = createMockContext({
hasOpenLayers: () => true, // Overlay is open (e.g., file preview)
hasOpenModal: () => false, // But no true modal
isTabShortcut: (_e: KeyboardEvent, actionId: string) => actionId === 'tabSwitcher',
setTabSwitcherOpen: mockSetTabSwitcherOpen,
});
act(() => {
window.dispatchEvent(
new KeyboardEvent('keydown', {
key: 't', // Alt key changes the key on macOS, but we use code
code: 'KeyT',
altKey: true,
metaKey: true,
bubbles: true,
})
);
});
// Alt+Cmd+T should open tab switcher even when file preview overlay is open
expect(mockSetTabSwitcherOpen).toHaveBeenCalledWith(true);
});
});
describe('navigation handlers delegation', () => {

View File

@@ -120,6 +120,10 @@ export function useMainKeyboardHandler(): UseMainKeyboardHandlerReturn {
!e.shiftKey &&
!e.altKey &&
(keyLower === 't' || keyLower === 'w');
// Allow tab switcher shortcut (Alt+Cmd+T) even when file preview is open
// NOTE: Must use e.code for Alt key combos on macOS because e.key produces special characters
const isTabSwitcherShortcut =
e.altKey && (e.metaKey || e.ctrlKey) && !e.shiftKey && codeKeyLower === 't';
if (ctx.hasOpenModal()) {
// TRUE MODAL is open - block most shortcuts from App.tsx
@@ -139,7 +143,7 @@ export function useMainKeyboardHandler(): UseMainKeyboardHandlerReturn {
// Allow Cmd+Shift+[] to fall through to App.tsx handler
// (which will cycle right panel tabs when file tab is active)
// Also allow right panel tab shortcuts to switch tabs while overlay is open
// Also allow tab management shortcuts (Cmd+T/W) so user can create/close tabs from file preview
// Also allow tab management shortcuts (Cmd+T/W, Alt+Cmd+T tab switcher) from file preview
if (
!isCycleShortcut &&
!isLayoutShortcut &&
@@ -148,7 +152,8 @@ export function useMainKeyboardHandler(): UseMainKeyboardHandlerReturn {
!isSessionJumpShortcut &&
!isJumpToBottomShortcut &&
!isMarkdownToggleShortcut &&
!isTabManagementShortcut
!isTabManagementShortcut &&
!isTabSwitcherShortcut
) {
return;
}