anomalyco / anomalyco/opencode

TUI does not re-layout on terminal shrink (only on grow), leaving stale width

Open
#42,225 6 comments 0 reactions 1 assignee View on GitHub

@kommander is already working on this.

Since Aug 13, 2026.

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

Description

Summary

When the terminal is resized, the opencode TUI re-layouts on grow but not on
shrink, and not on the initial attach. The drawn width stays at its previous
value, so the TUI either leaves blank space or overflows the terminal.

Measured in a browser-hosted terminal (xterm.js over a WebSocket PTY, opencode
1.18.16):

terminal columns columns opencode actually draws result
100 (initial) 78 under-fills — blank space on the right
119 (grown) 117 correct, follows the resize
68 (shrunk) 117 stale — overflows the terminal

The resize does reach the process

This is not a missing-notification problem. The chain was verified layer by layer:

  • the terminal element resizes
  • xterm.js recomputes its grid (26 -> 15 -> 31 rows)
  • the frontend sends the new size over the WebSocket:
    {"type":"resize","data":{"cols":68,"rows":27}}
  • the PTY receives it and delivers SIGWINCH — a plain bash on the same host over
    the same transport re-wraps correctly, so the signal is being delivered

Only the last step fails: opencode receives the new size and re-layouts on grow, but
keeps the old width on shrink and on the initial draw.

Workaround

Forcing a redraw inside the TUI (e.g. Ctrl+L) restores the correct layout, which is
consistent with "the size is known, but no re-layout is scheduled".

Environment

  • opencode-ai 1.18.16 (release notes for 1.18.17 and 1.18.18 contain no
    resize-related changes, so this is likely still present)
  • Linux x86_64; the terminal is xterm.js in a browser, over a WebSocket PTY bridge
  • Reproduces on every attach; not specific to a model or provider

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.