opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[Windows] CTRL_C_EVENT not handled by bun (umbrella issue)

Open kommander opened this issue 1 month ago • 5 comments

This is to collect issues that are reporting ANSI escape sequences after CTRL+C in some windows terminals and shell, where it sends a CTRL_C_EVENT which is not handled by bun.

  • https://github.com/anomalyco/opencode/issues/7062
  • https://github.com/anomalyco/opencode/issues/6912

kommander avatar Jan 06 '26 11:01 kommander

This umbrella issue appropriately collects ANSI escape sequence issues related to CTRL_C handling. Additional related issues found:

  • #6189: In the Windows system, pressing Ctrl+C will automatically exit the terminal
  • #5990: Ctrl+C interruption causes terminal corruption with ANSI escape sequences
  • #3057: Ctrl+C should terminate child processes
  • #2999: Provide means to disable Ctrl-C (Windows quits app instead of copy)
  • #5071: Ctrl+C exiting app even when prompt input isn't empty

All of these appear to stem from improper CTRL_C_EVENT and signal handling on Windows. The umbrella issue structure is good for tracking the root cause.

github-actions[bot] avatar Jan 06 '26 11:01 github-actions[bot]

on windows bun, the ctrl+c sigint gets sent to all process+childprocess, so the bun run wrapper instantly kills its child. i need to check what happens with the published app too... i have a bun wip branch that is a poc fixing this, but it janky. not sure its something opentui/opencode can handle as a workaround if its parent process is killing it

Hona avatar Jan 06 '26 22:01 Hona

Is this issue for collecting reports until the Bun team fixes it or are temporary workarounds in OpenCode also accepted?

val-2 avatar Jan 08 '26 12:01 val-2

I have submitted a PR to the Bun team resolving this for us

Hona avatar Jan 08 '26 22:01 Hona

https://github.com/oven-sh/bun/pull/25876

I am seeing about adding tests. Also need to investigate the wider impact of this change. So there's more for me to do on this PR. Hoping for guidance from the Bun team tho.

Hona avatar Jan 08 '26 23:01 Hona

oven-sh/bun#25876

I am seeing about adding tests. Also need to investigate the wider impact of this change. So there's more for me to do on this PR. Hoping for guidance from the Bun team tho.

Thanks for doing this! I press Ctrl+C out of habit and get kicked out 4-5x a day. Ugh.

carljuneau avatar Jan 15 '26 16:01 carljuneau