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:
@@ -104,6 +104,7 @@ export const BottomTerminalDock: React.FC<BottomTerminalDockProps> = ({ isOpen,
|
|||||||
const appliedHeight = isOpen
|
const appliedHeight = isOpen
|
||||||
? (isFullscreen ? Math.max(0, fullscreenHeight ?? standardHeight) : standardHeight)
|
? (isFullscreen ? Math.max(0, fullscreenHeight ?? standardHeight) : standardHeight)
|
||||||
: 0;
|
: 0;
|
||||||
|
const shouldApplyFullscreenLayout = isOpen && isFullscreen;
|
||||||
|
|
||||||
const handlePointerDown = (event: React.PointerEvent) => {
|
const handlePointerDown = (event: React.PointerEvent) => {
|
||||||
if (!isOpen || isFullscreen) return;
|
if (!isOpen || isFullscreen) return;
|
||||||
@@ -118,11 +119,11 @@ export const BottomTerminalDock: React.FC<BottomTerminalDockProps> = ({ isOpen,
|
|||||||
ref={dockRef}
|
ref={dockRef}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex overflow-hidden border-t border-border bg-sidebar',
|
'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',
|
isResizing ? 'transition-none' : 'transition-[height] duration-300 ease-in-out',
|
||||||
!isOpen && 'border-t-0'
|
!isOpen && 'border-t-0'
|
||||||
)}
|
)}
|
||||||
style={isFullscreen ? {
|
style={shouldApplyFullscreenLayout ? {
|
||||||
top: 'var(--oc-header-height, 48px)',
|
top: 'var(--oc-header-height, 48px)',
|
||||||
} : {
|
} : {
|
||||||
height: `${appliedHeight}px`,
|
height: `${appliedHeight}px`,
|
||||||
|
|||||||
@@ -54,6 +54,44 @@ export const useKeyboardShortcuts = () => {
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const combo = (actionId: string) => getEffectiveShortcutCombo(actionId, shortcutOverrides);
|
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) => {
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
if (eventMatchesShortcut(e, combo('open_command_palette'))) {
|
if (eventMatchesShortcut(e, combo('open_command_palette'))) {
|
||||||
@@ -416,9 +454,11 @@ export const useKeyboardShortcuts = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.addEventListener('keydown', handleTerminalShortcutCapture, true);
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
window.addEventListener('keydown', handleKeyDown);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
window.removeEventListener('keydown', handleTerminalShortcutCapture, true);
|
||||||
window.removeEventListener('keydown', handleKeyDown);
|
window.removeEventListener('keydown', handleKeyDown);
|
||||||
};
|
};
|
||||||
}, [
|
}, [
|
||||||
|
|||||||
Reference in New Issue
Block a user