From 34990ef1be8c58cc4c5791d92110e77ab23581cb Mon Sep 17 00:00:00 2001 From: Yassir Janah Date: Tue, 24 Mar 2026 09:27:17 +0100 Subject: [PATCH] fix(tui): reset leaked mouse tracking on startup When a previous process is killed externally (TerminateProcess on Windows, SIGKILL on POSIX), mouse tracking can be left enabled in the terminal. Send disable sequences before the renderer configures its own mouse state to recover from a dirty baseline. --- packages/opencode/src/cli/cmd/tui/app.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx index dc052c4d2e04..c6e8a6d05ff8 100644 --- a/packages/opencode/src/cli/cmd/tui/app.tsx +++ b/packages/opencode/src/cli/cmd/tui/app.tsx @@ -119,6 +119,11 @@ export function tui(input: { return new Promise(async (resolve) => { const unguard = win32InstallCtrlCGuard() win32DisableProcessedInput() + // If a previous process was killed externally (TerminateProcess on Windows, + // SIGKILL on POSIX), mouse tracking can be left enabled. Reset it before + // the renderer configures its own mouse state. + if (process.stdout.isTTY) + process.stdout.write("\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l") const mode = await getTerminalBackgroundColor()