opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Fix Ctrl+C handling on Windows

Open val-2 opened this issue 3 weeks ago • 2 comments

Closes #5071 To fix the bug described in the issue, I introduced a small wrapper around Bun.spawn that kind of mimics the Bun.$ interface for the usage patterns (.text() and .throw(false)) related to the two problematic commands (npm list and npm config get registry). I replaced the $ calls with this wrapper, and as a result the Ctrl+C handling now behaves correctly on Windows: it exits if no input prompt is present, otherwise it deletes the current input.

I placed the wrapper file in the same directory as the affected file to keep it close, since the bug currently impacts only that file. Additionally, the issue may be fixed upstream in Bun, in which case this wrapper would no longer be necessary.

val-2 avatar Dec 18 '25 19:12 val-2

I changed all occurrences of npm, pnpm and yarn to use spawnWrapper, excluding the ones that don't get used during OpenCode execution (for example as a standalone script like the publish script)

val-2 avatar Dec 19 '25 17:12 val-2

IT seems like the bug actually is in Bun

rekram1-node avatar Dec 20 '25 19:12 rekram1-node

@val-2 I think ik the better fix, see this: https://github.com/sst/opencode/commit/c333ffa38bc6fffd6d2cc7b89f4990074a49a522

All the "$" invocations were missing .quiet(..)

rekram1-node avatar Dec 22 '25 05:12 rekram1-node

I'm going to update this to use that and merge it, if that doesnt do the fix then we can explore this again

rekram1-node avatar Dec 22 '25 05:12 rekram1-node