From 166574a65850b1776915883b4865b319d5d6c28c Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 8 Jan 2026 19:24:20 -0500 Subject: [PATCH 1/2] wip: zen Revert "wip: zen" This reverts commit 4ac01dff23e46027c9ab520e1a6a240e0cc6d663. From a3820c2d4b56f013329deb255601c2fb61075705 Mon Sep 17 00:00:00 2001 From: lifefloating Date: Thu, 8 Jan 2026 19:07:34 +0800 Subject: [PATCH 2/2] feat: add double-ESC keybind to clear input field --- .../cli/cmd/tui/component/prompt/index.tsx | 29 ++++++++++++++++++- packages/web/src/content/docs/keybinds.mdx | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) 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 4558914cb7e..4364b0d1747 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -15,7 +15,7 @@ import { usePromptStash } from "./stash" import { DialogStash } from "../dialog-stash" import { type AutocompleteRef, Autocomplete } from "./autocomplete" import { useCommandDialog } from "../dialog-command" -import { useRenderer } from "@opentui/solid" +import { useRenderer, useKeyboard } from "@opentui/solid" import { Editor } from "@tui/util/editor" import { useExit } from "../../context/exit" import { Clipboard } from "../../util/clipboard" @@ -611,6 +611,33 @@ export function Prompt(props: PromptProps) { } const exit = useExit() + let lastEscTime = 0 + const DOUBLE_ESC_THRESHOLD = 300 + + // Global keyboard handler for double-ESC to clear input + useKeyboard((evt) => { + if (props.disabled) return + if (!input?.focused) return + if (evt.name !== "escape") return + if (store.prompt.input === "") return + if (dialog.stack.length > 0) return + + const now = Date.now() + if (now - lastEscTime < DOUBLE_ESC_THRESHOLD) { + input.clear() + input.extmarks.clear() + setStore("prompt", { + input: "", + parts: [], + }) + setStore("extmarkToPartIndex", new Map()) + lastEscTime = 0 + evt.preventDefault() + return + } + lastEscTime = now + }) + function pasteText(text: string, virtualText: string) { const currentOffset = input.visualCursor.offset const extmarkStart = currentOffset diff --git a/packages/web/src/content/docs/keybinds.mdx b/packages/web/src/content/docs/keybinds.mdx index 267d194c099..66eb03fa8e4 100644 --- a/packages/web/src/content/docs/keybinds.mdx +++ b/packages/web/src/content/docs/keybinds.mdx @@ -146,6 +146,7 @@ The OpenCode desktop app prompt input supports common Readline/Emacs-style short | `alt+d` | Kill next word | | `ctrl+t` | Transpose characters | | `ctrl+g` | Cancel popovers / abort running response | +| `esc esc`| Clear input field (double press) | ---