Skip to content

TUI: extend LayoutBudget with horizontal geometry#646

Open
TZZheng wants to merge 1 commit into
Lingtai-AI:mainfrom
TZZheng:codex/issue-645-pr3-layout-budget
Open

TUI: extend LayoutBudget with horizontal geometry#646
TZZheng wants to merge 1 commit into
Lingtai-AI:mainfrom
TZZheng:codex/issue-645-pr3-layout-budget

Conversation

@TZZheng

@TZZheng TZZheng commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • extend the root-owned LayoutBudget from vertical-only sizing to one two-axis geometry contract
  • add terminal/content/rail/minimum-chat widths and rail visibility, while keeping the production rail request at zero so current UI pixels do not change
  • route both raw and synthesized resize paths through the same ChildWindowSize() content rectangle
  • exercise real nonzero-rail threshold arithmetic in the pure resolver without shipping a visible rail
  • document the new ownership in tui/internal/tui/ANATOMY.md

Part of #645 (the third independent root PR in the issue's implementation DAG). This PR does not add the rail widget, Agent selection, input rerouting, or thread/cache behavior.

Behavior and scope

resolveHorizontalLayout owns the one allowed horizontal partition. A rail is visible only for an allowed view and only when its requested width leaves at least the minimum chat width; hidden rails consume zero columns. App.layoutBudget() formally requests a zero-width rail in this PR, so Mail and non-Mail views retain the full terminal width.

The named minimumChatWidth default is 60 columns. It is currently inert because the requested rail width is zero; the threshold and exact partition behavior are covered directly for later visible-rail work.

Test-first evidence

Before implementation, the focused contract suite was written and run against base d0167c35d696654899678e5a5498df04ebab6492:

go test ./internal/tui -run 'TestLayoutBudgetOwnsHorizontalGeometryWithoutChangingCurrentWidth|TestLayoutBudgetHorizontalTinyAndThresholdWidthsAreSafe|TestRawAndSyntheticResizeShareMailHorizontalGeometry|TestNonMailViewKeepsFullTerminalWidth' -count=1

It exited 1 after compiling and executing. The intended failures were that the base LayoutBudget had no TerminalWidth, MinChatWidth, or ContentWidth fields; this was not a syntax, import, dependency, environment, or unrelated flaky-test failure. The contemporaneous RED record has SHA-256 90ead718729e5924e89a74516054f8a4df6fb9e4f882694b55b4b5bf77f25384.

The initial RED tests used reflection so they could compile against missing fields. After implementation, the committed tests were tightened to direct typed field access.

Validation

Exact candidate: 3c03fe0494870e1d8247d1c7b58b714d4996b606

# focused layout, resize, chrome, Mail, and non-Mail contract
go test ./internal/tui -run 'TestLayoutBudget|TestUpdateForwardsReducedHeight|TestUpdateNoChromeForwardsFullHeight|TestSendSize|TestRawAndSyntheticResizeShareMailHorizontalGeometry|TestNonMailViewKeepsFullTerminalWidth|TestViewComposesBannerOnce|TestVisitingDoesNotReserveRootChrome' -count=1

# full TUI module suite
go test ./...

git diff --check

All passed. The repository-shipped anatomy citation checker also passed with no missing or out-of-range targets, and the changed production-file citations were semantically inspected.

Independent read-only review of this exact HEAD:

  • Claude: PASS, no blockers; independently ran build, full tests, vet, formatting, and diff checks
  • Codex (gpt-5.6-sol, high reasoning): PASS, no blockers; independently ran focused/full tests, vet, formatting, citation, and cleanliness checks

Both reviewers explicitly judged the inactive 60-column minimum acceptable for this foundation PR.

Cleanup and bridge ledger

  • child views do not subtract rail width themselves
  • raw and synthesized resize paths share the existing root dispatcher and one computed content rectangle
  • package anatomy is updated in the same commit
  • bridge ledger: empty; the zero rail is the issue-specified behavior-preserving foundation, not a feature flag

Rollback

Reverting this commit restores the former height-only budget and single-width forwarding. No persistence or data migration is involved.

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.

1 participant