diff options
| author | Ganesh <[email protected]> | 2026-02-17 17:34:11 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-17 06:04:11 -0600 |
| commit | 0186a8506340f6f6715262d4986c45740fb488d5 (patch) | |
| tree | 8b7c66fc5652fc5bef1e1039481e83934b072c97 | |
| parent | ed4e4843c2a65018d6f23f24f86c6a471e391053 (diff) | |
| download | opencode-0186a8506340f6f6715262d4986c45740fb488d5.tar.gz opencode-0186a8506340f6f6715262d4986c45740fb488d5.zip | |
fix(app): keep Escape handling local to prompt input on macOS desktop (#13963)
| -rw-r--r-- | packages/app/src/components/prompt-input.tsx | 40 |
1 files changed, 30 insertions, 10 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<PromptInputProps> = (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<PromptInputProps> = (props) => { return } } - if (store.mode === "shell") { - const { collapsed, cursorPosition, textLength } = getCaretState() - if (event.key === "Escape") { + + 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<PromptInputProps> = (props) => { if (event.key === "Enter" && !event.shiftKey) { handleSubmit(event) } - if (event.key === "Escape") { - if (store.popover) { - closePopover() - } else if (working()) { - abort() - } - } } return ( |
