Bug: Ctrl+C interruption in opencode causes terminal corruption with ANSI escape sequences #3763

Closed
opened 2026-02-16 17:41:23 -05:00 by yindo · 2 comments
Owner

Originally created by @estudiochapunov on GitHub (Dec 22, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

When using opencode CLI, pressing Ctrl+C (intended as Esc) interrupts the session, leading to terminal corruption. After interruption, cursor/mouse movements display corrupted ANSI escape sequences (e.g., [^[[H for cursor home, [^[[2J for clear screen). The screen remains with opencode content, but keyboard partially loses control.

Upon closing and reopening the terminal, opencode is no longer in PATH (even though set persistently), requiring manual re-addition.

Steps to Reproduce

  1. Start opencode in CMD or PowerShell.
  2. During session, press Ctrl+C to interrupt.
  3. Observe terminal corruption (ANSI escape codes on cursor/mouse input).
  4. Close and reopen terminal.
  5. opencode command not found.

Environment

  • OS: Windows 11 Home (build 10.0.26220)
  • Terminal: CMD / PowerShell 7.5.4
  • opencode version: 1.0.186
  • PATH includes opencode via setx

Expected Behavior

Ctrl+C should cleanly exit without corrupting terminal or affecting PATH persistence.

Actual Behavior

Terminal corrupted with ANSI escapes, PATH changes not applied after restart.

Additional Notes

Issue may relate to signal handling or terminal integration on Windows. PATH persistence via setx works in normal cases.

Originally created by @estudiochapunov on GitHub (Dec 22, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description When using opencode CLI, pressing Ctrl+C (intended as Esc) interrupts the session, leading to terminal corruption. After interruption, cursor/mouse movements display corrupted ANSI escape sequences (e.g., [^[[H for cursor home, [^[[2J for clear screen). The screen remains with opencode content, but keyboard partially loses control. Upon closing and reopening the terminal, opencode is no longer in PATH (even though set persistently), requiring manual re-addition. ### Steps to Reproduce 1. Start opencode in CMD or PowerShell. 2. During session, press Ctrl+C to interrupt. 3. Observe terminal corruption (ANSI escape codes on cursor/mouse input). 4. Close and reopen terminal. 5. opencode command not found. ### Environment - OS: Windows 11 Home (build 10.0.26220) - Terminal: CMD / PowerShell 7.5.4 - opencode version: 1.0.186 - PATH includes opencode via setx ### Expected Behavior Ctrl+C should cleanly exit without corrupting terminal or affecting PATH persistence. ### Actual Behavior Terminal corrupted with ANSI escapes, PATH changes not applied after restart. ### Additional Notes Issue may relate to signal handling or terminal integration on Windows. PATH persistence via setx works in normal cases.
yindo added the windowsopentui labels 2026-02-16 17:41:23 -05:00
yindo closed this issue 2026-02-16 17:41:24 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 22, 2025):

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

  • #5070: bug: exiting tui on windows has improper exit sequence handling
  • #5071: bug: ctrl+c exiting app even when prompt input isn't empty
  • #5936: Random Artifacts In Terminal After Running

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

@github-actions[bot] commented on GitHub (Dec 22, 2025): This issue might be a duplicate of existing issues. Please check: - #5070: bug: exiting tui on windows has improper exit sequence handling - #5071: bug: ctrl+c exiting app even when prompt input isn't empty - #5936: Random Artifacts In Terminal After Running Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Dec 22, 2025):

There is an upstream bug in bun that we hope to get fixed

@rekram1-node commented on GitHub (Dec 22, 2025): There is an upstream bug in bun that we hope to get fixed
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3763