From cb25ed8cc8278aafe7b1ebe4e80c089e83a3c769 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Thu, 20 Aug 2026 10:19:36 -0500 Subject: [PATCH] fix(tui): restore option return newlines (#43655) Co-authored-by: nexxeln <95541290+nexxeln@users.noreply.github.com> --- packages/tui/src/config/keybind.ts | 2 +- packages/tui/src/config/v1/keybind.ts | 2 +- .../tui/test/cli/tui/dialog-prompt.test.tsx | 23 +++++++++++++++++++ packages/tui/test/mini/runtime.boot.test.ts | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/packages/tui/src/config/keybind.ts b/packages/tui/src/config/keybind.ts index e7cc454773..c026b56638 100644 --- a/packages/tui/src/config/keybind.ts +++ b/packages/tui/src/config/keybind.ts @@ -189,7 +189,7 @@ export const Definitions = { "prompt.clear": keybind("ctrl+c", "Clear input field"), "prompt.paste": keybind({ key: "ctrl+v", preventDefault: false }, "Paste from clipboard"), "input.submit": keybind("return", "Submit input"), - "input.newline": keybind("shift+return,ctrl+return,ctrl+j", "Insert newline in input"), + "input.newline": keybind("shift+return,ctrl+return,alt+return,ctrl+j", "Insert newline in input"), "input.move.left": keybind("left,ctrl+b", "Move cursor left in input"), "input.move.right": keybind("right,ctrl+f", "Move cursor right in input"), "input.move.up": keybind("up", "Move cursor up in input"), diff --git a/packages/tui/src/config/v1/keybind.ts b/packages/tui/src/config/v1/keybind.ts index cec2467e6c..e34f1a8dc5 100644 --- a/packages/tui/src/config/v1/keybind.ts +++ b/packages/tui/src/config/v1/keybind.ts @@ -174,7 +174,7 @@ export const Definitions = { input_clear: keybind("ctrl+c", "Clear input field"), input_paste: keybind({ key: "ctrl+v", preventDefault: false }, "Paste from clipboard"), input_submit: keybind("return", "Submit input"), - input_newline: keybind("shift+return,ctrl+return,ctrl+j", "Insert newline in input"), + input_newline: keybind("shift+return,ctrl+return,alt+return,ctrl+j", "Insert newline in input"), input_move_left: keybind("left,ctrl+b", "Move cursor left in input"), input_move_right: keybind("right,ctrl+f", "Move cursor right in input"), input_move_up: keybind("up", "Move cursor up in input"), diff --git a/packages/tui/test/cli/tui/dialog-prompt.test.tsx b/packages/tui/test/cli/tui/dialog-prompt.test.tsx index 135991d737..bde9cb0cdb 100644 --- a/packages/tui/test/cli/tui/dialog-prompt.test.tsx +++ b/packages/tui/test/cli/tui/dialog-prompt.test.tsx @@ -107,6 +107,29 @@ test("dialog prompt submit wins when return is also input newline", async () => } }) +test("alt return inserts a newline with default keybinds", async () => { + await using tmp = await tmpdir() + const confirmed: string[] = [] + const prompt = await mountPrompt({ + root: tmp.path, + keybinds: {}, + onConfirm: (value) => confirmed.push(value), + }) + + try { + await wait(() => prompt.app.renderer.currentFocusedEditor instanceof TextareaRenderable) + const textarea = prompt.app.renderer.currentFocusedEditor + if (!(textarea instanceof TextareaRenderable)) throw new Error("expected focused dialog textarea") + + prompt.app.mockInput.pressEnter({ meta: true }) + + expect(confirmed).toEqual([]) + expect(textarea.plainText).toBe("draft\n") + } finally { + await prompt.cleanup() + } +}) + test("dialog prompt submit can be rebound separately from input submit", async () => { await using tmp = await tmpdir() const confirmed: string[] = [] diff --git a/packages/tui/test/mini/runtime.boot.test.ts b/packages/tui/test/mini/runtime.boot.test.ts index 2fbafda909..fc79963ecc 100644 --- a/packages/tui/test/mini/runtime.boot.test.ts +++ b/packages/tui/test/mini/runtime.boot.test.ts @@ -21,7 +21,7 @@ describe("run runtime boot", () => { expect(result.keybinds.get("prompt.history.next")?.[0]?.key).toBe("down") expect(result.keybinds.get("prompt.clear")?.[0]?.key).toBe("ctrl+c") expect(result.keybinds.get("input.submit")?.[0]?.key).toBe("return") - expect(result.keybinds.get("input.newline")?.[0]?.key).toBe("shift+return,ctrl+return,ctrl+j") + expect(result.keybinds.get("input.newline")?.[0]?.key).toBe("shift+return,ctrl+return,alt+return,ctrl+j") expect(result.keybinds.get("prompt.queue")?.[0]?.key).toBe("return") })