You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Windows] Hard-killed TUI leaves mouse reporting enabled; next launch does not reset terminal state #18901
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
Launch opencode in Windows Terminal (PowerShell)
Force-kill it with taskkill /F /PID <pid>
Move the mouse in the terminal — raw escape sequences appear
Relaunch opencode
Move the mouse again — raw escape sequences still appear
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.
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.
Activity
github-actions commentedon Mar 24, 2026
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 /Fwith no exit handlers. If the underlying fix is the same (reset mouse tracking on startup), these may still be related enough to consolidate.kommander commentedon Apr 12, 2026
There is nothing any app that activates mouse can do when killed like that, same would happen for lazygit for example.
MrCorsario commentedon Jun 16, 2026
Same symptom, different trigger — not just force-kill.
This also happens during startup if MCP server connections block TUI initialization.
Setup:
xterm-256coloropencode.jsoncwith"type": "remote"and"timeout": 30000What 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[?1006lis sent before\x1b[?1003h/\x1b[?1006h, OR defer the enablement until after async connections settle.