fix: keep terminal shortcuts working without blanking chat

Terminal toggle shortcuts work while the terminal is focused
Hiding an expanded terminal no longer leaves a blank page
This commit is contained in:
Bohdan Triapitsyn
2026-05-07 23:03:46 +03:00
parent cb8ea5e6c5
commit add73ad687
2 changed files with 43 additions and 2 deletions
@@ -104,6 +104,7 @@ export const BottomTerminalDock: React.FC<BottomTerminalDockProps> = ({ isOpen,
const appliedHeight = isOpen
? (isFullscreen ? Math.max(0, fullscreenHeight ?? standardHeight) : standardHeight)
: 0;
const shouldApplyFullscreenLayout = isOpen && isFullscreen;
const handlePointerDown = (event: React.PointerEvent) => {
if (!isOpen || isFullscreen) return;
@@ -118,11 +119,11 @@ export const BottomTerminalDock: React.FC<BottomTerminalDockProps> = ({ isOpen,
ref={dockRef}
className={cn(
'flex overflow-hidden border-t border-border bg-sidebar',
isFullscreen ? 'absolute inset-x-0 bottom-0 z-40' : 'relative',
shouldApplyFullscreenLayout ? 'absolute inset-x-0 bottom-0 z-40' : 'relative',
isResizing ? 'transition-none' : 'transition-[height] duration-300 ease-in-out',
!isOpen && 'border-t-0'
)}
style={isFullscreen ? {
style={shouldApplyFullscreenLayout ? {
top: 'var(--oc-header-height, 48px)',
} : {
height: `${appliedHeight}px`,
@@ -54,6 +54,44 @@ export const useKeyboardShortcuts = () => {
React.useEffect(() => {
const combo = (actionId: string) => getEffectiveShortcutCombo(actionId, shortcutOverrides);
const isTerminalEventTarget = (target: EventTarget | null) => {
if (!(target instanceof Element)) {
return false;
}
return Boolean(
target.closest('.terminal-viewport-container') ||
target.getAttribute('data-terminal-hidden-input') === 'true'
);
};
const handleTerminalShortcutCapture = (e: KeyboardEvent) => {
if (!isTerminalEventTarget(e.target)) {
return;
}
if (eventMatchesShortcut(e, combo('toggle_terminal'))) {
const { isMobile } = useUIStore.getState();
if (isMobile) {
return;
}
e.preventDefault();
e.stopPropagation();
toggleBottomTerminal();
return;
}
if (eventMatchesShortcut(e, combo('toggle_terminal_expanded'))) {
const { isMobile, isBottomTerminalExpanded } = useUIStore.getState();
if (isMobile) {
return;
}
e.preventDefault();
e.stopPropagation();
setBottomTerminalExpanded(!isBottomTerminalExpanded);
return;
}
};
const handleKeyDown = (e: KeyboardEvent) => {
if (eventMatchesShortcut(e, combo('open_command_palette'))) {
@@ -416,9 +454,11 @@ export const useKeyboardShortcuts = () => {
}
};
window.addEventListener('keydown', handleTerminalShortcutCapture, true);
window.addEventListener('keydown', handleKeyDown);
return () => {
window.removeEventListener('keydown', handleTerminalShortcutCapture, true);
window.removeEventListener('keydown', handleKeyDown);
};
}, [