From 2dec4c178c3a124161490ca7236e308627eff15a Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Thu, 12 Mar 2026 18:09:48 -0400 Subject: [PATCH 1/2] fix: respect user keybinding configuration for input_submit/input_newline Make hardcoded default keybindings conditional so user configuration takes precedence. User bindings now come first in the array, and defaults are only added for actions the user hasn't configured. This fixes the issue where configuring: input_newline: return input_submit: ctrl+return,alt+return,shift+return Would fail because hardcoded defaults always matched first. Changes: - Check if user has configured submit/newline actions - Only add defaults for unconfigured actions - Put user bindings first so they take precedence --- .../cmd/tui/component/textarea-keybindings.ts | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/textarea-keybindings.ts b/packages/opencode/src/cli/cmd/tui/component/textarea-keybindings.ts index 36ab03de545..d7df599ed7d 100644 --- a/packages/opencode/src/cli/cmd/tui/component/textarea-keybindings.ts +++ b/packages/opencode/src/cli/cmd/tui/component/textarea-keybindings.ts @@ -64,10 +64,25 @@ export function useTextareaKeybindings() { return createMemo(() => { const keybinds = keybind.all - return [ - { name: "return", action: "submit" }, - { name: "return", meta: true, action: "newline" }, - ...TEXTAREA_ACTIONS.flatMap((action) => mapTextareaKeybindings(keybinds, action)), - ] satisfies KeyBinding[] + // Get user-defined bindings first + const userBindings = TEXTAREA_ACTIONS.flatMap((action) => + mapTextareaKeybindings(keybinds, action), + ) + + // Check if user has configured each action + const hasSubmitBinding = userBindings.some((b) => b.action === "submit") + const hasNewlineBinding = userBindings.some((b) => b.action === "newline") + + // Build defaults array, only adding defaults for unconfigured actions + const defaults: KeyBinding[] = [] + if (!hasSubmitBinding) { + defaults.push({ name: "return", action: "submit" }) + } + if (!hasNewlineBinding) { + defaults.push({ name: "return", meta: true, action: "newline" }) + } + + // User bindings come first so they take precedence over defaults + return [...userBindings, ...defaults] satisfies KeyBinding[] }) } From 1b5d18f1f700c721471744ea5c4733d1b343229d Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Fri, 13 Mar 2026 21:25:39 -0400 Subject: [PATCH 2/2] Fix: Allow submit keybinding to work with slash command autocomplete --- .../src/cli/cmd/tui/component/prompt/autocomplete.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx index 3240afab326..c412e11f0f3 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx @@ -566,7 +566,13 @@ export function Autocomplete(props: { } if (name === "return") { select() - e.preventDefault() + // After selection, autocomplete is hidden. If the key that triggered + // this is also the submit keybinding, we need to let the event + // propagate so the prompt can handle submission. + // Only prevent default if autocomplete is still visible (selection failed). + if (store.visible) { + e.preventDefault() + } return } if (name === "tab") {