Skip to content

fix(tui): refresh terminal size before resize - #42474

Closed
fancive wants to merge 2 commits into
anomalyco:devfrom
fancive:fix-tui-resize
Closed

fancive wants to merge 2 commits into
anomalyco:devfrom
fancive:fix-tui-resize

Conversation

@fancive

@fancive fancive commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #42225

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

OpenTUI reads process.stdout.columns and process.stdout.rows when handling SIGWINCH. In affected PTY hosts, Bun can leave those cached values stale until the stream refreshes its window size.

This change refreshes the TTY dimensions before OpenTUI receives the resize signal. It performs one initial refresh, installs the listener ahead of the renderer listener, and removes it when the TUI scope closes.

How did you verify your code works?

  • bun test in packages/tui: 195 passed, 1 skipped
  • bun typecheck in packages/tui
  • Manual tmux conversation resize smoke test at 68 -> 119 -> 68 columns

Screenshots / recordings

Not included. The failure is specific to live terminal resizing; the signal ordering is covered by a focused regression test and was also verified interactively in tmux.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@4elovekyc

Copy link
Copy Markdown

Confirming this fix is needed: Windows 11 + Orca IDE (xterm.js-based terminal) + opencode 1.18.18 — stale-width artifacts appear on every session completion (leftover frames, garbled panels), recoverable only by forcing a grow-resize (changing tab zoom) or restarting opencode.

Tested and ruled out: switching the terminal to DOM renderer (Orca "GPU Acceleration" → Off) does NOT fix it — the issue is the TUI resize handling, not the renderer. Please land this.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants