anomalyco / anomalyco/opencode

TUI flickers and disconnects on repeated resize over Termux mobile SSH

Open
#44,093 0 comments 0 reactions 1 assignee View on GitHub

@simonklee is already working on this.

Since Aug 22, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

When running opencode TUI over a mobile SSH client (Termux on Android), the UI flickers severely on each app switch, and after several cycles the connection drops entirely.

This is a mobile-SSH-specific variation of #42225 (shrink-layout not re-layouted) combined with #44055 (resize listener leak). The existing issues were reported from desktop/browser contexts; this one documents the same root cause triggered by a mobile SSH client's keyboard-height change.

Reproduction

  1. Run opencode on a remote Linux server via SSH from Termux (Android)
  2. Type a query to start a streaming response
  3. Press the Home button (or swipe to switch away) — the app hides, keyboard collapses, terminal grows
  4. Switch back to Termux — the keyboard reappears, terminal shrinks
  5. Observe:
    • Flicker: text disappears/reappears during the resize; sidebar/status bar garbled
    • Scrollback corruption: prompt jumps to top of visible area
  6. Repeat steps 3–5 5–10 times
  7. After ~5–10 cycles, the TUI connection drops (terminal becomes unresponsive, reconnecting doesn't help)

Expected Behavior

  • Smooth resize without flicker or scroll jump
  • Long-running sessions survive repeated resize events without crashing or disconnecting

Actual Behavior

  • Visual corruption on every shrink/grow cycle (stale width, garbled sidebar)
  • After multiple cycles, the TUI becomes unresponsive and the SSH session drops

Environment

Component Detail
Client Termux on Android 13
SSH to Remote Linux x86_64 server
TERM xterm-256color
opencode Latest stable
Shell zsh / bash (same behavior)

Analysis

Two compounding issues:

  1. #42225 — On terminal shrink, the TUI keeps its stale width. The sidebar/status bar draw at wrong absolute columns, causing garbled text and visual flicker on every resize. Already being fixed upstream (PR #42330 / opentui#1363).

  2. #44055 — Resize listener leak. Each app switch adds new SIGWINCH listeners without cleaning up old ones. Over many cycles this causes accumulated memory/EventEmitter warnings and eventually connection instability.

The mobile SSH scenario is especially painful because every keyboard toggle triggers a resize, making the leak and stale layout visible in seconds rather than minutes.

Additional Context

  • The Ctrl+L workaround from #42225 was attempted but does not prevent the connection drop over many cycles
  • opencode web (headless) works fine over the same SSH session — only the TUI is affected
  • The flicker is most visible during streaming (assistant typing); static output briefly flashes before settling

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.