Skip to content

Terminal becomes unresponsive/corrupted after exiting with /exit command (mouse control lost, garbage printed) #34940

Closed as not planned

Description

@cqmhhh

Description

my version is

Image

Description:

When I install opencode on either UCRT64 (MSYS2) or WSL environments and then exit the program using /exit, the terminal becomes completely broken:

Mouse control is lost – moving the mouse prints raw coordinate data (e e.g., 35;45;4M) directly to the terminal instead of being handled properly.

Keyboard input is garbled – typing produces unexpected characters or no visible output.

The terminal remains in a corrupted state until manually reset.

This issue occurs consistently in both:

Windows UCRT64 environment (MSYS2)

WSL (Windows Subsystem for Linux)

Root Cause Analysis (my understanding):

This is a client-side bug in the opencode TUI application, not an issue with the LLM itself.

Here's what's happening under the hood:

Normal terminal vs. TUI programs

Normal terminals operate in "line mode" – input is buffered until you press Enter.

opencode uses a TUI (Terminal User Interface) which switches the terminal into "raw mode" to enable features like arrow-key navigation, mouse interaction, and real-time rendering.

What raw mode does:

Disables local echo (the program controls what to display).

Captures mouse events – every click or movement is sent to the program as an escape sequence (e.g., 35;45;4M for a mouse click at coordinates X:35, Y:45).

The bug – why it happens:

A well-behaved TUI program must restore terminal state on exit:

Release mouse control back to the terminal.

Exit raw mode and restore normal line mode.

opencode appears to crash or panic on exit (possibly triggered by a missing default config file, as shown in the error log).

The crash bypasses the cleanup code that should restore terminal settings, leaving the terminal in a "stuck" raw mode state.

Result:

The terminal believes it's still under opencode's control.

Mouse movements are interpreted as text and printed to the screen.

Keyboard input is processed incorrectly because the terminal is still in raw mode.

em

QQ20260702-214752.mp4

advices

I have two feature suggestions that would significantly improve the user experience in different scenarios.

  1. TUI: Add quick page navigation / scrollbar
    Currently, navigating through long conversations or large code blocks in the TUI can be quite slow as it only supports line-by-line scrolling.

Proposed improvements:

Support for PageUp / PageDown keys to jump by pages.

Support for Home / End keys to jump to the very top or bottom of the output.

(Optional) A visual scrollbar indicator showing current position within the entire content.

This would make reviewing lengthy outputs much more efficient.

Image

Plugins

no

OpenCode version

1.17.13

Steps to reproduce

  1. download opencode in wsl or msys
  2. open opencode in bash
  3. /exit
  4. error

Screenshot and/or share link

Image

Operating System

ucrt(msys) and wsl(debian)

Terminal

windows terminal or tabby

Activity

  1. github-actions commented on Sep 1, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions