anomalyco / anomalyco/opencode
TUI flickers and disconnects on repeated resize over Termux mobile SSH
@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
- Run
opencodeon a remote Linux server via SSH from Termux (Android) - Type a query to start a streaming response
- Press the Home button (or swipe to switch away) — the app hides, keyboard collapses, terminal grows
- Switch back to Termux — the keyboard reappears, terminal shrinks
- Observe:
- Flicker: text disappears/reappears during the resize; sidebar/status bar garbled
- Scrollback corruption: prompt jumps to top of visible area
- Repeat steps 3–5 5–10 times
- 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:
-
#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).
-
#44055 — Resize listener leak. Each app switch adds new
SIGWINCHlisteners 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+Lworkaround 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.