Skip to content

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

Closed

Description

@BGCIV

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[;;M) being printed as text instead of being interpreted by the TUI.

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

Activity

  1. added
    bugSomething isn't working
    on Jan 5, 2026
  2. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Jan 5, 2026
  3. thomasloockx commented on Jan 6, 2026

    @thomasloockx

    Here's a little video I captured when I was about to file the same bug:

    wezterm-gui_PhRPhWbWhi.mp4
  4. stefanoallima commented on Jan 16, 2026

    @stefanoallima

    same here

  5. fabioluissilva commented on Jan 16, 2026

    @fabioluissilva

    Also same here. I even installed Wezterm on windows. Same problem

  6. dathtd119 commented on Jan 16, 2026

    @dathtd119

    This is referenced in issue #7074 comment about bun PR, which is bun problem, I also having this also, let just wait for bun to update it, or change to our beloved npm

  7. added a commit that references this issue on Jan 28, 2026
    42f3dd3
  8. kpripper commented on Feb 1, 2026

    @kpripper

    This is referenced in issue #7074 comment about bun PR, which is bun problem, I also having this also, let just wait for bun to update it, or change to our beloved npm

    I'm using npm

  9. dathtd119 commented on Feb 2, 2026

    @dathtd119

    This is referenced in issue #7074 comment about bun PR, which is bun problem, I also having this also, let just wait for bun to update it, or change to our beloved npm

    I'm using npm

    Welp I think this is related to some terminal core function, I got this error when running on Windows or WSL2, both via Windows Termnial or Alacritty but still got the error. So I just setup my old Laptop as Ubuntu, SSH to it via Windows Terminal and it worked wonderful (yes still using bun here)

  10. Hona commented on Feb 12, 2026

    @Hona
    Member

    ctrl+c handling is now in as of 1.1.60

  11. eduardozf commented on Mar 5, 2026

    @eduardozf

    Still happening on 1.2.17

    Image

    Windows 11. Any terminal I tried have the same problem

  12. Hona commented on Mar 5, 2026

    @Hona
    Member

    @eduardozf any plugins?

    when does this happen? After /exit, ctrl+C?

    can you please do a screen recording please

  13. eduardozf commented on Mar 5, 2026

    @eduardozf

    It seems that this issue only happens on Git Bash. I tried using other terminals and couldn’t replicate it. I tested with PowerShell, CMD, and Zsh through Windows Terminal, and everything worked fine. So it appears to be specific to Git Bash

    2026-03-05.20-55-55.mp4
  14. Hona commented on Mar 6, 2026

    @Hona
    Member

    thanks this helps a lot!

  15. onigetoc commented on Apr 9, 2026

    @onigetoc

    These mouse tracking in terminal are very very annoying

  16. Hona commented on Apr 9, 2026

    @Hona
    Member

    what terminal are you using? what version of opencode?

    this should be patched as of ages ago

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentuiwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions