opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Ctrl+C does not disable mouse tracking, causing raw escape sequences to flood terminal (Windows)

Open benjigc opened this issue 1 week ago • 3 comments

Description

When pressing Ctrl+C to interrupt/exit OpenCode on Windows, the terminal is left in mouse tracking mode. This causes raw SGR mouse tracking escape sequences to be printed to the terminal on every mouse movement, rendering the terminal unusable until manually reset. Environment

Expected Behavior OpenCode should cleanly exit and restore terminal to normal state, disabling mouse tracking before terminating.

Actual Behavior Terminal remains in mouse tracking mode. Moving the mouse produces continuous output like: [555;58;25M[555;58;26M[555;57;25M[555;57;24M[555;55;24M[555;53;23M... This is raw SGR extended mouse tracking data (\e[

Root Cause Analysis OpenCode enables SGR extended mouse tracking (likely \e[?1003h for any-event tracking and \e[?1006h for SGR extended mode) but does not register a signal handler to disable these modes on SIGINT (Ctrl+C). The cleanup sequence that should run on exit: \e[?1000l # Disable normal mouse tracking \e[?1002l # Disable button-event tracking
\e[?1003l # Disable any-event tracking \e[?1006l # Disable SGR extended mode

Comparison Claude Code (Anthropic's CLI) handles Ctrl+C correctly on the same system and terminal - the terminal is properly restored on exit.

Additional Context

  • Does not occur when using the application's built-in exit commands
  • Only occurs on forced interrupt via Ctrl+C
  • Confirmed this is not caused by oh-my-opencode plugin (purely config, no terminal handling) Image

Plugins

oh-my-opencode

OpenCode version

1.1.1

Steps to reproduce

Steps to Reproduce

  1. Launch opencode in Windows Terminal (PowerShell)
  2. Wait for the UI to fully load
  3. Press Ctrl+C to interrupt/exit

Screenshot and/or share link

No response

Operating System

windows 10

Terminal

windows terminal/warp

benjigc avatar Jan 05 '26 06:01 benjigc