Skip to content

bug: mouse garbling after inactivity — missing SIGTSTP handler #20506

@agutmanstein-scale

Description

@agutmanstein-scale

Description

When opencode is suspended via external SIGTSTP (e.g., code-server terminal management during inactivity, job control), mouse escape sequences appear as garbled text in the shell. The bottom of the TUI display gets cut off.

This is distinct from #20458 (post-exit garbling) and #3199 (in-session fragmentation).

Root Cause

Neither @opentui/core nor opencode register a SIGTSTP handler. When SIGTSTP arrives from an external source, the process is suspended by the kernel with zero cleanup:

  • Mouse tracking remains enabled
  • Raw mode remains on
  • Shell receives mouse events as garbled escape sequences

The correct cleanup pattern already exists in the manual suspend keybind (app.tsx), which calls renderer.suspend()disableMouse()setRawMode(false) before suspending. But this only runs from the TUI command palette — an external SIGTSTP bypasses it.

Reproduction

# Terminal 1: run opencode
opencode

# Terminal 2: send SIGTSTP
kill -TSTP $(pgrep -f opencode)

# Terminal 1: move mouse → garbled text

Also reproducible in code-server when the terminal management layer suspends inactive processes.

Workaround

Register SIGTSTP/SIGCONT handlers in app.tsx that call renderer.suspend()/renderer.resume().

Upstream fix: anomalyco/opentui#907
Upstream issue: anomalyco/opentui#906

Environment

  • code-server (VS Code web terminal) on VM
  • Triggered by inactivity / external SIGTSTP

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions