Skip to content

[Tui] Force full re-render on terminal resize#784

Open
ruttydm wants to merge 22 commits intofabpot:tuifrom
OpenCompanyApp:fix/tui-resize-force-render
Open

[Tui] Force full re-render on terminal resize#784
ruttydm wants to merge 22 commits intofabpot:tuifrom
OpenCompanyApp:fix/tui-resize-force-render

Conversation

@ruttydm
Copy link
Copy Markdown

@ruttydm ruttydm commented Mar 30, 2026

When the terminal is resized (SIGWINCH), requestRender() is called without force: true. This means the ScreenWriter performs differential rendering against its cached previousLines — but those lines were rendered at the old terminal width, so the diff is invalid.

Symptoms:

  • Misaligned box-drawing borders after resize
  • Wrapped lines that should now fit (or vice versa)
  • Leftover characters from the previous layout

Fix: Pass force: true to requestRender() in the resize callback, which calls screenWriter->reset() and forces a clean full render with the new terminal dimensions.

One-line change.

fabpot and others added 22 commits March 26, 2026 16:01
Instead of adding a 'root' style class to the root widget (which could
conflict with other widgets using the same class name), the root widget
is now identified by the :root pseudo-class, matching CSS semantics.

Changes:
- AbstractWidget::getStateFlags() returns 'root' when the widget has no parent
- StyleSheet::resolve() supports standalone :state selectors (e.g. :root)
- Tui no longer adds the 'root' style class to the root container
- Users should use ':root' instead of '.root' in their stylesheets
When the terminal is resized (SIGWINCH), the ScreenWriter's cached
previousLines contain lines rendered at the old terminal width. A
non-forced requestRender() performs differential rendering against
these stale lines, producing visual glitches — misaligned borders,
wrapped lines, and leftover characters.

Pass force: true to requestRender() in the resize callback so the
ScreenWriter resets its cache and performs a clean full render with
the new terminal dimensions.
@ruttydm
Copy link
Copy Markdown
Author

ruttydm commented Mar 30, 2026

Building a MIT coding agent using the TUI framework and came upon this resize issue.

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.

2 participants