Ctrl-C doesn't clear the input on Windows, it crashes #7536

Closed
opened 2026-02-16 18:07:29 -05:00 by yindo · 4 comments
Owner

Originally created by @tnglemongrass on GitHub (Jan 25, 2026).

Originally assigned to: @kommander on GitHub.

Description

Description

On Windows 11, built-in Terminal App:

  1. launch opencode.cmd
  2. type 'hello' (without sending)
  3. press Ctrl-C

Expected:

  • clears the input, opencode still running

Actual:

  • the app crashes, user is thrown back to powershell prompt, mouse movements produce strange ANSI-characters

Interesting:

  • Ctrl-D and /exit work fine
  • Ctrl-C within the first second works fine, too
  • The following fix helps, as starting point (probably breaks other functionality):
--- a/packages/opencode/src/cli/cmd/tui/thread.ts
+++ b/packages/opencode/src/cli/cmd/tui/thread.ts
@@ -156,9 +156,9 @@ export const TuiThreadCommand = cmd({
       },
     })

-    setTimeout(() => {
-      client.call("checkUpgrade", { directory: cwd }).catch(() => {})
-    }, 1000)
+    // setTimeout(() => {
+    //   client.call("checkUpgrade", { directory: cwd }).catch(() => {})
+    // }, 1000)

     await tuiPromise
   },

Plugins

none

OpenCode version

latest dev branch:

commit d6c5ddd6dc835c4d0a3118350b92d7a9d03d7f22 (origin/dev, origin/HEAD, dev)
Author: GitHub Action <action@github.com>
Date:   Fri Jan 23 12:05:37 2026 +0000

    ignore: update download stats 2026-01-23

Steps to reproduce

see above

Screenshot and/or share link

none

Operating System

Windows 11

Terminal

Built-In Windows Terminal App

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @tnglemongrass on GitHub (Jan 25, 2026). Originally assigned to: @kommander on GitHub. ### Description ### Description On Windows 11, built-in Terminal App: 1. launch opencode.cmd 2. type 'hello' (without sending) 3. press Ctrl-C Expected: - clears the input, opencode still running Actual: - the app crashes, user is thrown back to powershell prompt, mouse movements produce strange ANSI-characters Interesting: - Ctrl-D and /exit work fine - Ctrl-C within the first second works fine, too - The following fix helps, as starting point (probably breaks other functionality): ```diff --- a/packages/opencode/src/cli/cmd/tui/thread.ts +++ b/packages/opencode/src/cli/cmd/tui/thread.ts @@ -156,9 +156,9 @@ export const TuiThreadCommand = cmd({ }, }) - setTimeout(() => { - client.call("checkUpgrade", { directory: cwd }).catch(() => {}) - }, 1000) + // setTimeout(() => { + // client.call("checkUpgrade", { directory: cwd }).catch(() => {}) + // }, 1000) await tuiPromise }, ``` ### Plugins none ### OpenCode version latest dev branch: ``` commit d6c5ddd6dc835c4d0a3118350b92d7a9d03d7f22 (origin/dev, origin/HEAD, dev) Author: GitHub Action <action@github.com> Date: Fri Jan 23 12:05:37 2026 +0000 ignore: update download stats 2026-01-23 ``` ### Steps to reproduce see above ### Screenshot and/or share link none ### Operating System Windows 11 ### Terminal Built-In Windows Terminal App ### Plugins _No response_ ### OpenCode version _No response_ ### Steps to reproduce _No response_ ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the windowsopentuibug labels 2026-02-16 18:07:29 -05:00
yindo closed this issue 2026-02-16 18:07:29 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 25, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7074: [Windows] CTRL_C_EVENT not handled by bun (umbrella issue) - This is the main tracking issue for Ctrl+C problems on Windows
  • #7062: Pressing Ctrl+C in input field outputs ANSI escape sequences/garbled text - Similar garbled output behavior
  • #10265: Ctrl+C during response causes terminal to print endless garbage and become unresponsive - Similar crash/garbage output behavior on Windows with PowerShell
  • #6189: In the Windows system, pressing Ctrl+C will automatically exit the terminal - Related Ctrl+C handling issue on Windows

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 25, 2026): This issue might be a duplicate of existing issues. Please check: - #7074: [Windows] CTRL_C_EVENT not handled by bun (umbrella issue) - This is the main tracking issue for Ctrl+C problems on Windows - #7062: Pressing Ctrl+C in input field outputs ANSI escape sequences/garbled text - Similar garbled output behavior - #10265: Ctrl+C during response causes terminal to print endless garbage and become unresponsive - Similar crash/garbage output behavior on Windows with PowerShell - #6189: In the Windows system, pressing Ctrl+C will automatically exit the terminal - Related Ctrl+C handling issue on Windows Feel free to ignore if none of these address your specific case.
Author
Owner

@InCerryGit commented on GitHub (Jan 26, 2026):

same issue

@InCerryGit commented on GitHub (Jan 26, 2026): same issue
Author
Owner

@tnglemongrass commented on GitHub (Jan 27, 2026):

Digging further, this is caused by how external commands are launched in /packages/opencode/src/installation/index.ts (via Bun Shell). Migrating to Bun Spawn seems to fix the issue for me:

From

        $`npm list -g --depth=0`.throws(false).quiet().text(),

To

      Bun.spawn(["npm", "list", "-g", "--depth=0"])

plus some try/catch and stdout handling to mimick throws(false).quiet().text() (it's needed for all occurrences in that file).

Some remarks:

  • Unclear why the one approach works and the other not.
  • These are only short-running processes. Why do they break ctrl-c permanently?
  • There are more files that import { $ }, but only the above file seems to produce the issue. At least, after using the bash tool and the !-prompt, ctrl-c still works fine.
  • As a user, I tried to disable auto-updates via config, but version check logic runs always. Would be nice to have this "as workaround".

The bug exists at least since v1.0.0 (3 months ago), and severely affects Windows users. So even a providing a functional workaround (disable auto-updates) would be a big step forward.

@tnglemongrass commented on GitHub (Jan 27, 2026): Digging further, this is caused by how external commands are launched in /packages/opencode/src/installation/index.ts (via [Bun Shell](https://bun.com/docs/runtime/shell)). Migrating to [Bun Spawn](https://bun.com/docs/runtime/child-process) seems to fix the issue for me: From ``` $`npm list -g --depth=0`.throws(false).quiet().text(), ``` To ``` Bun.spawn(["npm", "list", "-g", "--depth=0"]) ``` plus some try/catch and stdout handling to mimick throws(false).quiet().text() (it's needed for all occurrences in that file). Some remarks: - Unclear why the one approach works and the other not. - These are only short-running processes. Why do they break ctrl-c permanently? - There are more files that `import { $ }`, but only the above file seems to produce the issue. At least, after using the `bash` tool and the !-prompt, ctrl-c still works fine. - As a user, I tried to disable auto-updates via config, but version check logic runs always. Would be nice to have this "as workaround". The bug exists at least since v1.0.0 (3 months ago), and severely affects Windows users. So even a providing a functional workaround (disable auto-updates) would be a big step forward.
Author
Owner

@Hona commented on GitHub (Feb 12, 2026):

this is fixed as of 1.1.60

@Hona commented on GitHub (Feb 12, 2026): this is fixed as of 1.1.60
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7536