diff --git a/src/__tests__/renderer/hooks/useMainKeyboardHandler.test.ts b/src/__tests__/renderer/hooks/useMainKeyboardHandler.test.ts index 4de61be4..fc794684 100644 --- a/src/__tests__/renderer/hooks/useMainKeyboardHandler.test.ts +++ b/src/__tests__/renderer/hooks/useMainKeyboardHandler.test.ts @@ -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', () => { diff --git a/src/renderer/hooks/keyboard/useMainKeyboardHandler.ts b/src/renderer/hooks/keyboard/useMainKeyboardHandler.ts index c875ce70..695b01a0 100644 --- a/src/renderer/hooks/keyboard/useMainKeyboardHandler.ts +++ b/src/renderer/hooks/keyboard/useMainKeyboardHandler.ts @@ -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; }