fix(cli): render content in promptSelect when terminal height is too small#7209
Merged
Conversation
…small When the available terminal height was 0 or negative (a small terminal, or fitToRemainingHeight with the cursor near the bottom), visibleLines collapsed to 0 and the prompt rendered only a scroll indicator with no selectable items. Clamp visibleLines to at least 1 so at least one item is always visible.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7209 +/- ##
==========================================
+ Coverage 94.57% 94.84% +0.26%
==========================================
Files 636 616 -20
Lines 52142 51419 -723
Branches 9401 9300 -101
==========================================
- Hits 49315 48766 -549
+ Misses 2249 2112 -137
+ Partials 578 541 -37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bartlomieju
approved these changes
Jul 3, 2026
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.
Problem
promptSelect()(andpromptMultipleSelect(), which sharehandlePromptSelect) could render only a scroll indicator (...) with no selectable content when there wasn't enough vertical space.This happens whenever the available terminal height is
0or negative — e.g. a small terminal, orfitToRemainingHeight: truewith the cursor near the bottom of the screen.availableHeight = rows - SAFE_PADDING(4)becomes≤ 0, which collapsesvisibleLinesto0, so no items are sliced into the visible window and only the "more content" indicator is printed.Reproduction (80×4 terminal):
Fix
Clamp
visibleLinesto at least1in both places it is computed, so at least one item is always visible:Tests
Added
promptSelect() always shows at least one item when height is too small, which stubs a 4-row terminal and asserts the active item is rendered. All existingpromptSelect/promptMultipleSelecttests still pass.