Skip to content

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

Closed as not planned

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Apr 1, 2026
  2. added a commit that references this issue on Apr 1, 2026
    6a53f6a
  3. added a commit that references this issue on Apr 2, 2026
    2e53f3f
  4. added a commit that references this issue on Apr 2, 2026
    1186ee4
  5. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on May 3, 2026
  6. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions