Description
After exiting the opencode TUI (via quit, Ctrl+C, or process stop), mouse escape sequences appear as garbled text in the terminal:
35;89;19M35;84;20M35;76;22M35;71;23M35;67;23M35;67;24M35;67;25M35...
This is a separate issue from in-session mouse garbling (#3199 / PR #19520). The in-session bug is about fragmented SGR sequences leaking through StdinParser timeouts during active use. This bug occurs after the TUI has exited.
Root Cause
This is an upstream bug in @opentui/core's cleanupBeforeDestroy() method. During renderer destruction, stdin.setRawMode(false) is called (re-enabling terminal ECHO) before mouse tracking is disabled. Any mouse events arriving during this window get echoed as raw escape sequence bytes.
The correct ordering already exists in @opentui/core's suspend() method, which calls disableMouse() before setRawMode(false).
Upstream issue: anomalyco/opentui#904
Upstream fix PR: anomalyco/opentui#905
Reproduction
- Run
opencode
- Move the mouse while the TUI is active
- Exit the TUI (quit or Ctrl+C)
- Move the mouse in the shell immediately after exit
- Garbled escape sequences appear
Workaround
A patchedDependencies patch for @opentui/core can fix this by adding disableMouse() + stdin drain before setRawMode(false) in cleanupBeforeDestroy(). A PR with this patch is forthcoming.
Environment
- macOS / Linux
- Affects
@opentui/core@0.1.90 and @opentui/core@0.1.95
Description
After exiting the opencode TUI (via quit, Ctrl+C, or process stop), mouse escape sequences appear as garbled text in the terminal:
This is a separate issue from in-session mouse garbling (#3199 / PR #19520). The in-session bug is about fragmented SGR sequences leaking through StdinParser timeouts during active use. This bug occurs after the TUI has exited.
Root Cause
This is an upstream bug in
@opentui/core'scleanupBeforeDestroy()method. During renderer destruction,stdin.setRawMode(false)is called (re-enabling terminal ECHO) before mouse tracking is disabled. Any mouse events arriving during this window get echoed as raw escape sequence bytes.The correct ordering already exists in
@opentui/core'ssuspend()method, which callsdisableMouse()beforesetRawMode(false).Upstream issue: anomalyco/opentui#904
Upstream fix PR: anomalyco/opentui#905
Reproduction
opencodeWorkaround
A
patchedDependenciespatch for@opentui/corecan fix this by addingdisableMouse()+ stdin drain beforesetRawMode(false)incleanupBeforeDestroy(). A PR with this patch is forthcoming.Environment
@opentui/core@0.1.90and@opentui/core@0.1.95