From 0186a8506340f6f6715262d4986c45740fb488d5 Mon Sep 17 00:00:00 2001 From: Ganesh <179367536+itskritix@users.noreply.github.com> Date: Tue, 17 Feb 2026 17:34:11 +0530 Subject: [PATCH] fix(app): keep Escape handling local to prompt input on macOS desktop (#13963) --- packages/app/src/components/prompt-input.tsx | 42 +++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/packages/app/src/components/prompt-input.tsx b/packages/app/src/components/prompt-input.tsx index 984888c35..e21798738 100644 --- a/packages/app/src/components/prompt-input.tsx +++ b/packages/app/src/components/prompt-input.tsx @@ -280,6 +280,7 @@ export const PromptInput: Component = (props) => { } const isFocused = createFocusSignal(() => editorRef) + const escBlur = () => platform.platform === "desktop" && platform.os === "macos" const closePopover = () => setStore("popover", null) @@ -842,13 +843,39 @@ export const PromptInput: Component = (props) => { return } } - if (store.mode === "shell") { - const { collapsed, cursorPosition, textLength } = getCaretState() - if (event.key === "Escape") { - setStore("mode", "normal") + + if (event.key === "Escape") { + if (store.popover) { + closePopover() event.preventDefault() + event.stopPropagation() return } + + if (store.mode === "shell") { + setStore("mode", "normal") + event.preventDefault() + event.stopPropagation() + return + } + + if (working()) { + abort() + event.preventDefault() + event.stopPropagation() + return + } + + if (escBlur()) { + editorRef.blur() + event.preventDefault() + event.stopPropagation() + return + } + } + + if (store.mode === "shell") { + const { collapsed, cursorPosition, textLength } = getCaretState() if (event.key === "Backspace" && collapsed && cursorPosition === 0 && textLength === 0) { setStore("mode", "normal") event.preventDefault() @@ -927,13 +954,6 @@ export const PromptInput: Component = (props) => { if (event.key === "Enter" && !event.shiftKey) { handleSubmit(event) } - if (event.key === "Escape") { - if (store.popover) { - closePopover() - } else if (working()) { - abort() - } - } } return (