TUI leaves terminal in mouse-reporting/raw mode; keystrokes / mouse events print as ^[[<... after exit or crash #7581

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

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

Originally assigned to: @kommander on GitHub.

Description

Summary

After running opencode, my terminal sometimes ends up “stuck” in a broken state where input behaves incorrectly and mouse events / keystrokes print directly into the shell prompt (ex: ^[[<35;62;19M). This looks like the TUI enables mouse reporting / raw mode and doesn’t always restore terminal settings on exit/crash.

What happens

  • The TUI appears to “break” and input starts going outside of the UI.

  • After quitting or killing opencode, the terminal remains messed up:

    • Clicking/scrolling prints escape sequences like:

      ^[[<35;62;19M
      

      (This matches xterm SGR mouse reporting: ESC [ < b ; x ; y M)

    • Shell input becomes unusable until terminal is reset.

Expected behavior

When opencode exits (even after unexpected termination), terminal settings should be restored so the shell behaves normally.

Reproduction steps

  1. Run:

Unable to reproduce consistently. Opencode crash causes issue. I have to close the terminal to stop it.

Evidence / screenshot

After the issue triggers, the terminal prints sequences like:

^[[<35;62;19M ...

Environment

  • opencode version: 1.1.36
  • node: v24.12.0
  • bun: 1.3.6
  • TERM: xterm-256color
  • OS: Ubuntu WSL on Windows 11
  • Install method: bun global install

Notes / suspicion

This looks like terminal modes (raw input + mouse reporting) aren’t being cleaned up on some exit paths (crash, hang, SIGKILL, or parent/child process exit mismatch). The launcher process (node .../opencode) + native binary process might have separate lifecycle/TTY handling, leaving the terminal in mouse-reporting mode.

Plugins

No response

OpenCode version

1.1.36

Steps to reproduce

No response

Screenshot and/or share link

Image

Operating System

Ubuntu 20.04.6 LTS (Focal Fossa) / WSL Windows 11

Terminal

vscode terminal bash

Originally created by @orangeswim on GitHub (Jan 25, 2026). Originally assigned to: @kommander on GitHub. ### Description ### Summary After running `opencode`, my terminal sometimes ends up “stuck” in a broken state where input behaves incorrectly and mouse events / keystrokes print directly into the shell prompt (ex: `^[[<35;62;19M`). This looks like the TUI enables mouse reporting / raw mode and doesn’t always restore terminal settings on exit/crash. ### What happens * The TUI appears to “break” and input starts going outside of the UI. * After quitting or killing `opencode`, the terminal remains messed up: * Clicking/scrolling prints escape sequences like: ``` ^[[<35;62;19M ``` (This matches xterm SGR mouse reporting: `ESC [ < b ; x ; y M`) * Shell input becomes unusable until terminal is reset. ### Expected behavior When `opencode` exits (even after unexpected termination), terminal settings should be restored so the shell behaves normally. ### Reproduction steps 1. Run: Unable to reproduce consistently. Opencode crash causes issue. I have to close the terminal to stop it. ### Evidence / screenshot After the issue triggers, the terminal prints sequences like: ``` ^[[<35;62;19M ... ``` ### Environment * **opencode version:** `1.1.36` * **node:** `v24.12.0` * **bun:** `1.3.6` * **TERM:** `xterm-256color` * **OS:** Ubuntu WSL on Windows 11 * **Install method:** bun global install ### Notes / suspicion This looks like terminal modes (raw input + mouse reporting) aren’t being cleaned up on some exit paths (crash, hang, SIGKILL, or parent/child process exit mismatch). The launcher process (`node .../opencode`) + native binary process might have separate lifecycle/TTY handling, leaving the terminal in mouse-reporting mode. ### Plugins _No response_ ### OpenCode version 1.1.36 ### Steps to reproduce _No response_ ### Screenshot and/or share link <img width="939" height="315" alt="Image" src="https://github.com/user-attachments/assets/8cb833d2-187f-415b-b4af-e0fd375c731a" /> ### Operating System Ubuntu 20.04.6 LTS (Focal Fossa) / WSL Windows 11 ### Terminal vscode terminal bash
yindo added the windowsopentuibug labels 2026-02-16 18:07:39 -05:00
yindo closed this issue 2026-02-16 18:07:39 -05:00
Author
Owner

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

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

  • #7861: macOS: Terminal becomes unusable after opencode exits ("dead terminal") - Similar terminal state corruption issue
  • #6912: Ctrl+C does not disable mouse tracking, causing raw escape sequences to flood terminal (Windows) - Directly addresses SGR mouse tracking not being disabled on exit
  • #8908: In version 1.1.23, the issue of the mouse wheel triggering abnormal ASCII codes after exiting reappeared - Same mouse reporting escape sequence issue after exit
  • #8866: on linux server, opencode will auto type string (eg: ;23M;26M;29M) into input area - Similar escape sequences appearing in terminal

All of these appear to be related to the same root cause: terminal modes (mouse reporting and raw mode) not being properly cleaned up when opencode exits or crashes, particularly with process lifecycle mismatches between the launcher and native binary.

Feel free to ignore if your specific case differs from these, but they may provide additional context or workarounds.

@github-actions[bot] commented on GitHub (Jan 25, 2026): This issue might be a duplicate of existing issues. Please check: - #7861: macOS: Terminal becomes unusable after opencode exits ("dead terminal") - Similar terminal state corruption issue - #6912: Ctrl+C does not disable mouse tracking, causing raw escape sequences to flood terminal (Windows) - Directly addresses SGR mouse tracking not being disabled on exit - #8908: In version 1.1.23, the issue of the mouse wheel triggering abnormal ASCII codes after exiting reappeared - Same mouse reporting escape sequence issue after exit - #8866: on linux server, opencode will auto type string (eg: ;23M;26M;29M) into input area - Similar escape sequences appearing in terminal All of these appear to be related to the same root cause: terminal modes (mouse reporting and raw mode) not being properly cleaned up when opencode exits or crashes, particularly with process lifecycle mismatches between the launcher and native binary. Feel free to ignore if your specific case differs from these, but they may provide additional context or workarounds.
Author
Owner

@orangeswim commented on GitHub (Jan 25, 2026):

I've seen this happen twice now. The model I am using is GLM 4.7 on the z.ai coding plan.

@orangeswim commented on GitHub (Jan 25, 2026): I've seen this happen twice now. The model I am using is GLM 4.7 on the z.ai coding plan.
Author
Owner

@orangeswim commented on GitHub (Jan 25, 2026):

It looks like my issue is a duplicate of #7861 #8908 #6912

@orangeswim commented on GitHub (Jan 25, 2026): It looks like my issue is a duplicate of #7861 #8908 #6912
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7581