feat(tui): use measureElement for PickerMenu pagination#252
Merged
Conversation
Replace the hardcoded PICKER_CHROME_ROWS=16 constant with Ink's measureElement() so pagination math reflects the actually-rendered header height. On narrow or resized terminals the PromptLabel can wrap, which the old heuristic ignored — leading to off-by-one cropping or the focused row scrolling off-screen. The hardcoded constant is retained as a first-frame fallback before Ink's first layout pass completes. After that we re-measure on every render so wrapping changes propagate on the next paint. The pagination math is extracted into a pure computeVisibleCount() helper and unit tested. Audit task #13. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit task #13 follow-up. Replaces
PickerMenu's hardcodedPICKER_CHROME_ROWS = 16heuristic with Ink'smeasureElement(), so pagination math reflects the actually-rendered header height instead of a fixed guess.Why
On narrow or resized terminals,
PromptLabelcan wrap to multiple rows. The old heuristic always assumed 16 chrome rows, which caused off-by-one cropping — the focused option could scroll off-screen because we over-counted the available area.The new path measures the picker's header
<Box>after layout and re-derivesvisibleCounton each render. The hardcoded constant is retained as a first-frame fallback for the initial paint beforemeasureElementhas a layout to read.The pagination math is extracted into a pure
computeVisibleCount(termRows, measuredHeader, totalOptionRows)helper and unit tested.Non-goals
LogViewer.tsxmigration is deferred. It's part of PR fix: review-panel fixes for #85 #86's open diff — a parallel migration here would create a merge collision. Suggested follow-up: doLogVieweras a separate PR once fix: review-panel fixes for #85 #86 lands.Files NOT touched
To keep this PR mergeable alongside other in-flight work:
src/ui/tui/screens/,src/ui/tui/components/,src/ui/tui/hooks/,src/ui/tui/store.ts,src/ui/tui/router.tsbin.ts,src/commands/*PickerMenu.tsxplus a new co-located testTest plan
pnpm tsc --noEmit— cleanpnpm test— 1245 passing (8 newcomputeVisibleCounttests)pnpm lint— cleanpnpm build+ smoke test (node ./dist/bin.js --help) — passes/regionslash command picker on a tall terminal still shows full list without scroll indicators when it fits🤖 Generated with Claude Code
Note
Low Risk
Low risk: scoped to TUI picker pagination math and layout measurement, with a conservative first-frame fallback and added unit coverage. Main risk is minor UI regressions (off-by-one scrolling) on unusual terminal sizes/wrapping behavior.
Overview
PickerMenu pagination now measures real layout height instead of relying on a fixed chrome-row constant.
PickerMenuwraps the header in a ref’dBoxand uses Ink’smeasureElementto derive how many option rows fit, retaining the old constant as a first-frame fallback.Extracts the visible-row calculation into a pure
computeVisibleCount()helper (including minimum visible rows and footer reserve) and adds vitest unit tests covering fallback, wrapped-header, and clamping scenarios.Reviewed by Cursor Bugbot for commit 96fba2c. Bugbot is set up for automated code reviews on this repo. Configure here.