Skip to content

fix(tui): per-route vertical reserve + required panel props (#1069 round-2 follow-up) - #1071

Open
saravmajestic wants to merge 1 commit into
mainfrom
fix/AI-1067-welcome-panel-reserve-split
Open

fix(tui): per-route vertical reserve + required panel props (#1069 round-2 follow-up)#1071
saravmajestic wants to merge 1 commit into
mainfrom
fix/AI-1067-welcome-panel-reserve-split

Conversation

@saravmajestic

@saravmajestic saravmajestic commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the merged #1069, addressing @sahrizvi's round-2 review. Also passed a 2-model consensus panel (Claude + Gemini) — both SOUND.

What changed (from the round-2 comments)

MINOR — reserve fit only session, under-reserved home. Split into per-route constants that match each route's actual chrome:

  • HOME_VERTICAL_RESERVE = 10 (top spacer 2 + prompt wrapper 1 + prompt ~4 + footer ~3)
  • SESSION_VERTICAL_RESERVE = 7 (gaps 2 + paddingBottom 1 + prompt ~4; no top spacer/footer in that column)

Thresholds re-expressed in usable terms (MEDIUM_MIN_HEIGHT 13, FULL_MIN_HEIGHT 34) so full still engages at a ~44-row terminal on home, and the classic 80×24 clears the medium floor with margin (the cliff the review flagged now sits at 23, off the common size).

MINOR — optional props silently defaulted to raw terminal. Made availableWidth/availableHeight required and dropped the component's own useTerminalDimensions + fallback. A call site that forgets to scale is now a compile error, not a silent regression — this is the type-level guard for the "no render test" finding.

NITs

  • Medium copy wording clarified (one line on a wide terminal, two at the narrow end).
  • Height now uses the same available-space model as width, so short windows shrink instead of crowding the prompt.
  • Per-route note: full engages ~3 rows sooner on session (≥41) than home (≥44) — intentional (session has less chrome, so more usable height).

From the consensus panel (both models endorsed)

  • Centralized PANEL_HORIZONTAL_PADDING = 4 — was a bare -4 in the home call site + test helper (vertical reserves were already named constants).
  • Added the sidebar-toggle transition test: session(150,50,false) → full vs session(150,50,true) → medium — pins the exact home_logo slot always visible and cannot be dismissed in TUI #1067 case directly.

Effective terminal → variant (verified)

Terminal Route Variant
120×44 home full (the chosen "full at 44")
106×31 / 80×24 home medium
120×22 home compact (short-terminal height fix)
130×50 + sidebar session medium (blocker-1)
130×50 no sidebar session full

Verification

tsgo clean · 12 unit + 11 render/adjacent tests pass · oxlint 0/0 · prettier. Gate-isolation tests still kill mutants (deleting or <<=-flipping any gate fails a test).

Deferred (noted by both reviewers): a session-with-sidebar render test as the true call-site regression guard — happy to add as a follow-up.

🤖 Generated with Claude Code


Summary by cubic

Fixes welcome panel sizing (AI-1067) so variants are chosen by available space, not raw terminal size. Prevents “full” from appearing with the session sidebar or on short terminals.

  • Bug Fixes

    • Split vertical reserves: HOME_VERTICAL_RESERVE = 10, SESSION_VERTICAL_RESERVE = 7.
    • Rebased thresholds on available height: MEDIUM_MIN_HEIGHT = 13, FULL_MIN_HEIGHT = 34.
    • Height now uses the same available-space model as width.
    • Centralized PANEL_HORIZONTAL_PADDING = 4.
    • Results: 80×24 → medium; home full at ~44 rows; session full at ~41; 120×22 → compact.
    • Added tests for the session sidebar toggle and common terminal sizes.
  • Migration

    • WelcomePanel now requires availableWidth and availableHeight.
    • Pass usable sizes: width minus padding/sidebar; height minus HOME_VERTICAL_RESERVE or SESSION_VERTICAL_RESERVE.

Written for commit 2eac798. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Improvements
    • Improved welcome panel sizing across Home and Session views.
    • Responsive layouts now account for each view’s available space, including surrounding interface elements and sidebars.
    • Updated height thresholds provide more accurate compact, medium, and full panel layouts.
    • Panel dimensions now adjust more reliably as the available terminal space changes.

…nd-2 review)

Follow-up to the merged #1069, addressing the round-2 review.

- Split the vertical reserve per route: HOME_VERTICAL_RESERVE (10) and
  SESSION_VERTICAL_RESERVE (7) accurately reflect each route's chrome (home has a
  top spacer + footer; session doesn't), instead of one constant that fit only
  session. Thresholds re-expressed in usable terms (MEDIUM_MIN_HEIGHT 13,
  FULL_MIN_HEIGHT 34) so `full` still engages at a ~44-row terminal on home and
  the classic 80x24 clears the medium floor with margin.
- Make WelcomePanel's availableWidth/availableHeight props REQUIRED (drop the
  raw-terminal fallback + the component's own useTerminalDimensions), so a call
  site that forgets to scale is a compile error, not a silent regression.
- Height now gets the same available-space treatment as width (terminal minus
  the route's prompt/footer chrome), so a short window shrinks the panel instead
  of crowding the prompt.
- Centralize PANEL_HORIZONTAL_PADDING (4) — was a bare `-4` in the home call site
  and test helper.

Tests: add the sidebar-toggle transition (session 150x50 full -> medium when the
sidebar opens — the exact #1067 case), the classic 80x24 on both routes, and keep
the isolated-gate / boundary / degenerate coverage. tsgo clean; oxlint 0/0.

Reviewed by a 2-model consensus panel (both SOUND); the PANEL_HORIZONTAL_PADDING
and sidebar-toggle test came out of that review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c083e71-11b5-4221-b06e-aadb33de3b8b

📥 Commits

Reviewing files that changed from the base of the PR and between 03b9459 and 2eac798.

📒 Files selected for processing (5)
  • packages/tui/src/component/welcome-panel-utils.ts
  • packages/tui/src/component/welcome-panel.tsx
  • packages/tui/src/routes/home.tsx
  • packages/tui/src/routes/session/index.tsx
  • packages/tui/test/component/welcome-panel-utils.test.ts

📝 Walkthrough

Walkthrough

Welcome panel sizing now uses caller-provided available dimensions. Home and session routes apply separate vertical reserves and shared horizontal padding. Responsive height thresholds and route-specific boundary tests were updated.

Changes

Welcome Panel Sizing

Layer / File(s) Summary
Panel sizing constants and component contract
packages/tui/src/component/welcome-panel-utils.ts, packages/tui/src/component/welcome-panel.tsx
The utilities define separate home and session reserves, shared horizontal padding, and lower height thresholds. WelcomePanel now requires available width and height.
Route dimension calculations
packages/tui/src/routes/home.tsx, packages/tui/src/routes/session/index.tsx
The routes calculate panel dimensions with route-specific vertical reserves and shared horizontal padding.
Route sizing validation
packages/tui/test/component/welcome-panel-utils.test.ts
Tests cover route-specific dimensions, responsive boundaries, sidebar width changes, and compact behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Home
  participant SessionRoute
  participant WelcomePanel
  participant welcomePanelVariant
  Home->>WelcomePanel: provide available width and height
  SessionRoute->>WelcomePanel: provide available width and height
  WelcomePanel->>welcomePanelVariant: calculate responsive variant
Loading

Possibly related PRs

  • AltimateAI/altimate-code#1069: Refines welcome-panel sizing and responsive breakpoint implementation across the same utilities, component, routes, and tests.

Poem

I’m a rabbit sizing panels with care,
Home and session now reserve their share.
Width and height arrive just right,
Thresholds guide the layout’s flight.
Tests hop through each boundary bright.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the route-specific vertical reserves and required panel props, which are the main changes.
Description check ✅ Passed The description clearly explains the changes, rationale, affected behavior, and verification results, despite omitted template checkboxes and screenshots.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/AI-1067-welcome-panel-reserve-split

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kilo-code-bot

kilo-code-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/tui/src/component/welcome-panel-utils.ts
  • packages/tui/src/component/welcome-panel.tsx
  • packages/tui/src/routes/home.tsx
  • packages/tui/src/routes/session/index.tsx
  • packages/tui/test/component/welcome-panel-utils.test.ts

Notes:

  • Per-route reserves (HOME_VERTICAL_RESERVE=10, SESSION_VERTICAL_RESERVE=7) and the centralized PANEL_HORIZONTAL_PADDING=4 match the actual chrome in each route (verified against home.tsx top-spacer/prompt/footer and session/index.tsx contentWidth).
  • Making availableWidth/availableHeight required is a sound type-level guard; both call sites now pass both props, so a future caller that forgets to scale is a compile error rather than a silent regression.
  • Threshold math verified: home(120,44)→full, home(120,43)→medium, home(80,24)→medium, home(120,22)→compact, and the #1067 session sidebar toggle (session(150,50,false)→full, session(150,50,true)→medium) all hold against the strict < gates.
  • Test helpers (home/session) mirror the production contentWidth computation exactly (dimensions().width - (sidebar ? 42 : 0) - 4).

Reviewed by glm-5.2 · Input: 59.7K · Output: 9.9K · Cached: 379.6K

Review guidance: REVIEW.md from base branch main

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/tui/test/component/welcome-panel-utils.test.ts">

<violation number="1" location="packages/tui/test/component/welcome-panel-utils.test.ts:21">
P3: The session test helper duplicates the exact width formula (including the magic sidebar width 42) that lives inline in routes/session/index.tsx:275. If the sidebar width or content-column math changes in the component, this mirror silently diverges and the #1067 pin no longer guards the real path. Consider exporting the sidebar width/formula from welcome-panel-utils (as was done for PANEL_HORIZONTAL_PADDING) and importing it in both the component and this test so they stay in sync.</violation>
</file>

<file name="packages/tui/src/component/welcome-panel-utils.ts">

<violation number="1" location="packages/tui/src/component/welcome-panel-utils.ts:37">
P3: The padding centralization is incomplete: PANEL_HORIZONTAL_PADDING is used at the home call site, but the session route's contentWidth still hardcodes the bare `- 4` rather than referencing the constant (the new doc comment even acknowledges session "applies the same 4 as part of its own content-column math"). If this constant ever changes, the session width math won't follow and drifts out of sync; consider having session/index.tsx import PANEL_HORIZONTAL_PADDING so both routes share one source of truth.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


// Map a terminal size to the AVAILABLE size each route feeds the pure function.
const home = (w: number, h: number) => welcomePanelVariant(w - PANEL_HORIZONTAL_PADDING, h - HOME_VERTICAL_RESERVE)
const session = (w: number, h: number, sidebar: boolean) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The session test helper duplicates the exact width formula (including the magic sidebar width 42) that lives inline in routes/session/index.tsx:275. If the sidebar width or content-column math changes in the component, this mirror silently diverges and the #1067 pin no longer guards the real path. Consider exporting the sidebar width/formula from welcome-panel-utils (as was done for PANEL_HORIZONTAL_PADDING) and importing it in both the component and this test so they stay in sync.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/tui/test/component/welcome-panel-utils.test.ts, line 21:

<comment>The session test helper duplicates the exact width formula (including the magic sidebar width 42) that lives inline in routes/session/index.tsx:275. If the sidebar width or content-column math changes in the component, this mirror silently diverges and the #1067 pin no longer guards the real path. Consider exporting the sidebar width/formula from welcome-panel-utils (as was done for PANEL_HORIZONTAL_PADDING) and importing it in both the component and this test so they stay in sync.</comment>

<file context>
@@ -2,18 +2,25 @@ import { expect, test } from "bun:test"
 
+// Map a terminal size to the AVAILABLE size each route feeds the pure function.
+const home = (w: number, h: number) => welcomePanelVariant(w - PANEL_HORIZONTAL_PADDING, h - HOME_VERTICAL_RESERVE)
+const session = (w: number, h: number, sidebar: boolean) =>
+  welcomePanelVariant(w - (sidebar ? 42 : 0) - PANEL_HORIZONTAL_PADDING, h - SESSION_VERTICAL_RESERVE)
+
</file context>

// Columns the home slot spends on its own left/right padding (2 + 2); the caller
// subtracts this to get the panel's usable width. (Session's contentWidth applies
// the same 4 as part of its own content-column math.)
export const PANEL_HORIZONTAL_PADDING = 4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The padding centralization is incomplete: PANEL_HORIZONTAL_PADDING is used at the home call site, but the session route's contentWidth still hardcodes the bare - 4 rather than referencing the constant (the new doc comment even acknowledges session "applies the same 4 as part of its own content-column math"). If this constant ever changes, the session width math won't follow and drifts out of sync; consider having session/index.tsx import PANEL_HORIZONTAL_PADDING so both routes share one source of truth.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/tui/src/component/welcome-panel-utils.ts, line 37:

<comment>The padding centralization is incomplete: PANEL_HORIZONTAL_PADDING is used at the home call site, but the session route's contentWidth still hardcodes the bare `- 4` rather than referencing the constant (the new doc comment even acknowledges session "applies the same 4 as part of its own content-column math"). If this constant ever changes, the session width math won't follow and drifts out of sync; consider having session/index.tsx import PANEL_HORIZONTAL_PADDING so both routes share one source of truth.</comment>

<file context>
@@ -7,36 +7,46 @@
+// Columns the home slot spends on its own left/right padding (2 + 2); the caller
+// subtracts this to get the panel's usable width. (Session's contentWidth applies
+// the same 4 as part of its own content-column math.)
+export const PANEL_HORIZONTAL_PADDING = 4
 
-/** Minimum usable size for the medium panel; below either → compact (one line). */
</file context>

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.

1 participant