Skip to content

fix(core): refresh dimensions after resize debounce - #1363

Open
dajiaohuang wants to merge 2 commits into
anomalyco:mainfrom
dajiaohuang:terminal-resize-sampling
Open

fix(core): refresh dimensions after resize debounce#1363
dajiaohuang wants to merge 2 commits into
anomalyco:mainfrom
dajiaohuang:terminal-resize-sampling

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • refresh cached TTY dimensions when a debounced SIGWINCH is handled
  • sample the refreshed dimensions when the debounce expires
  • use stdin as the size source when it is the TTY and stdout is piped
  • cover stale cached dimensions and piped-stdout setups with regression tests

Browser-hosted PTY bridges can deliver a resize signal before the runtime's cached stdout.columns and stdout.rows reflect the new kernel window size. The existing resize path captured those cached values immediately, so initial attach and shrink events could keep rendering at the previous width.

OpenTUI also always read dimensions from stdout, but some launchers pipe stdout while keeping stdin attached to the controlling terminal. In that setup the resize signal arrives, yet stdout has no terminal dimensions. The resize handler now refreshes and samples the active TTY stream after the debounce expires.

This keeps the existing debounce behavior and is related to anomalyco/opencode#42225.

Closes #1344

Testing

  • bun run test:js (5,397 passed, 23 skipped)
  • bun run test:js:node with Node.js 26.4.0 (4,664 passed, 6 skipped)
  • bun run build:lib
  • bun run fmt:check
  • bun run lint
  • Linux PTY reproduction covering initial attach, grow, and shrink

@dajiaohuang
dajiaohuang force-pushed the terminal-resize-sampling branch from 114d884 to 7f983e5 Compare August 18, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIGWINCH-based window resize silently breaks when process.stdout is not the user's real terminal (e.g. wrapped by 1Password's op run)

1 participant