From b42d1022a74e8ce65aa4440c058adc5edcd9bc21 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Thu, 2 Oct 2025 19:06:28 -0400 Subject: [PATCH] tui: let users exit shell mode with escape key in addition to backspace at position 0 --- .../src/cli/cmd/tui/component/prompt/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 60ab1fd12..7fdf6015c 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -110,6 +110,7 @@ export function Prompt(props: PromptProps) { command: input, }, }) + setStore("mode", "normal") } else if (input.startsWith("/")) { const [command, ...args] = input.split(" ") sdk.session.command({ @@ -230,10 +231,12 @@ export function Prompt(props: PromptProps) { e.preventDefault() return } - if (e.name === "backspace" && input.cursorPosition === 0 && store.mode === "shell") { - setStore("mode", "normal") - e.preventDefault() - return + if (store.mode === "shell") { + if ((e.name === "backspace" && input.cursorPosition === 0) || e.name === "escape") { + setStore("mode", "normal") + e.preventDefault() + return + } } if (store.mode === "normal") autocomplete.onKeyDown(e) if (!autocomplete.visible) {