Skip to content

[Windows] Hard-killed TUI leaves mouse reporting enabled; next launch does not reset terminal state #18901

Closed as not planned

Description

@janah01

Description

When the TUI is force-killed externally on Windows, the terminal can be left with mouse reporting enabled. After that, moving the mouse floods the prompt with raw escape sequences such as ^[[<35;62;19M. Relaunching opencode does not clear it, because the new renderer inherits the terminal's dirty state.

This is different from #6912 and #13301, which are about Ctrl+C cleanup. With taskkill /F, the process gets no chance to run exit handlers.

Possible fix: disable mouse tracking on TUI startup before enabling it again.

Plugins

none

OpenCode version

1.3.0

Steps to reproduce

  1. Launch opencode in Windows Terminal (PowerShell)
  2. Force-kill it with taskkill /F /PID <pid>
  3. Move the mouse in the terminal — raw escape sequences appear
  4. Relaunch opencode
  5. Move the mouse again — raw escape sequences still appear

Operating System

Windows 11

Terminal

Windows Terminal (PowerShell)

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Mar 24, 2026
  2. github-actions commented on Mar 24, 2026

    @github-actions
    Contributor

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

    Note: The author already distinguishes this from #13301 (Ctrl+C) — the key difference here is taskkill /F with no exit handlers. If the underlying fix is the same (reset mouse tracking on startup), these may still be related enough to consolidate.

  3. kommander commented on Apr 12, 2026

    @kommander
    Contributor

    There is nothing any app that activates mouse can do when killed like that, same would happen for lazygit for example.

  4. MrCorsario commented on Jun 16, 2026

    @MrCorsario

    Same symptom, different trigger — not just force-kill.

    This also happens during startup if MCP server connections block TUI initialization.

    Setup:

    • Linux (Fedora 44 / Bazzite), xterm-256color
    • opencode v1.17.7
    • MCP server configured in opencode.jsonc with "type": "remote" and "timeout": 30000
    • The server was unreachable (wrong URL/auth at the time)

    What happens:
    On launch, opencode enables mouse tracking (\x1b[?1003h, \x1b[?1006h) but then blocks trying to connect to the MCP server. During the 30s timeout window, any mouse movement floods the terminal with raw SGR sequences like [<35;116;3M. The TUI hasn't finished initializing its input handler yet, so events go unhandled and get echoed.

    Once the MCP connection times out, the TUI completes init and works normally. But the window between "mouse tracking ON" and "TUI ready to consume events" is unprotected.

    Root cause:
    Startup ordering problem — mouse tracking is enabled synchronously during init, but MCP connections are attempted inline (blocking the event loop). If they stall, mouse events arriving before the TUI's StdinParser is active leak as visible text.

    Recovery: Once MCP connects or times out, everything works normally. No terminal reset needed.

    Workaround: fix MCP connection.

    Relevance to #18901: Same mechanism — mouse events leaking because tracking is enabled without the TUI being ready to consume them. PR #18902 (reset mouse tracking on startup) would cover this case too. The fix should ensure \x1b[?1003l / \x1b[?1006l is sent before \x1b[?1003h / \x1b[?1006h, OR defer the enablement until after async connections settle.

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

Metadata

Metadata

Assignees

Labels

opentuiThis 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