From 8ca1ee99dcf770f55bee41cba300e79cb8a62ed3 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 3 Nov 2025 20:16:04 -0500 Subject: [PATCH 1/2] tui: use keybind helper for history navigation to respect custom keybindings --- .../src/cli/cmd/tui/component/prompt/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 4078bf6fd3b1..591fecc6b7c4 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -587,8 +587,12 @@ export function Prompt(props: PromptProps) { return } - if (e.name === "up" && input.visualCursor.visualRow === 0) input.cursorOffset = 0 - if (e.name === "down" && input.visualCursor.visualRow === input.height - 1) + if (keybind.match("history_previous", e) && input.visualCursor.visualRow === 0) + input.cursorOffset = 0 + if ( + keybind.match("history_next", e) && + input.visualCursor.visualRow === input.height - 1 + ) input.cursorOffset = input.plainText.length } if (!autocomplete.visible) { @@ -712,7 +716,8 @@ export function Prompt(props: PromptProps) { {props.hint!} - {keybind.print("command_list")} commands + {keybind.print("command_list")}{" "} + commands From 0538f43f516337ce294e9e3fcaecc8ee93e8b05f Mon Sep 17 00:00:00 2001 From: Stephen Collings Date: Tue, 4 Nov 2025 01:25:35 +0000 Subject: [PATCH 2/2] fix: Provide OPENCODE & AGENT env vars (#3843) Co-authored-by: Aiden Cline --- packages/opencode/src/cli/cmd/tui/thread.ts | 8 +++++++- packages/opencode/src/index.ts | 3 ++- packages/opencode/src/tool/bash.ts | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/thread.ts b/packages/opencode/src/cli/cmd/tui/thread.ts index 66a22bf9049e..1c2baeff448b 100644 --- a/packages/opencode/src/cli/cmd/tui/thread.ts +++ b/packages/opencode/src/cli/cmd/tui/thread.ts @@ -82,7 +82,13 @@ export const TuiThreadCommand = cmd({ return undefined })() - const worker = new Worker("./src/cli/cmd/tui/worker.ts") + const worker = new Worker("./src/cli/cmd/tui/worker.ts", { + env: Object.fromEntries( + Object.entries(process.env).filter( + (entry): entry is [string, string] => entry[1] !== undefined, + ), + ), + }) worker.onerror = console.error const client = Rpc.client(worker) process.on("uncaughtException", (e) => { diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.ts index 9c2877d2dd21..7fd7aeb1099a 100644 --- a/packages/opencode/src/index.ts +++ b/packages/opencode/src/index.ts @@ -62,7 +62,8 @@ const cli = yargs(hideBin(process.argv)) })(), }) - process.env["OPENCODE"] = "1" + process.env.AGENT = "1" + process.env.OPENCODE = "1" Log.Default.info("opencode", { version: Installation.VERSION, diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index e7b7d7382468..febd253a0c05 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -144,6 +144,9 @@ export const BashTool = Tool.define("bash", { const proc = spawn(params.command, { shell: true, cwd: Instance.directory, + env: { + ...process.env, + }, stdio: ["ignore", "pipe", "pipe"], detached: process.platform !== "win32", })