Skip to content

fix: arrange the tree on every render pass, not only on a resize - #185

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/133-arrange-every-render
Sep 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/133-arrange-every-render

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #133

What was wrong

UIApplication.SyncRootToConsole ran ArrangeTree only when the root had no size yet or the terminal had been resized. After the first frame, any other change to the tree kept its old layout:

  • an element shown with IsVisible = true kept its empty size and was never drawn
  • a root the host sized itself skipped arrange completely, so its children were never drawn
  • text that changed length didn't move its siblings

Change

  • The rules for adopting the terminal size are unchanged. The terminal size still applies when the root has no size or the terminal is resized, and a size the host assigns is still kept between resizes.
  • ArrangeTree(root) now runs on every pass. Each pass already clears and redraws the whole screen, so an extra arrange costs little by comparison.
  • The CLAUDE.md note on the rendering flow is updated to match.

Tests

  • UIApplicationLayoutTests adds three tests: the two reproductions from the issue, and one where text grows and moves its sibling.
  • With the fix reverted, all three fail. With the fix in place, all three pass.
  • The full TUI.Test suite passes, 224 tests, including the existing resize tests and RenderWithoutAResizeLeavesAHostAssignedRootSizeAlone.

🤖 Generated with Claude Code

https://claude.ai/code/session_01F4JLDZ8V6BpUZBB9ZnsaNt


Generated by Claude Code

Layout only ran when the root had no size yet or the terminal was
resized, so an element shown after the first frame, text that changed
length, or a root the host sized itself were drawn with stale geometry.
SyncRootToConsole now adopts the terminal size under the same rules as
before but always walks the tree.

Fixes #133

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F4JLDZ8V6BpUZBB9ZnsaNt
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 5cbb49b into main Sep 30, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/133-arrange-every-render branch September 30, 2026 06:12
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.

Layout is only re-run on a terminal resize: showing an element, changing text, or a host-assigned root size are never laid out

2 participants