Skip to content

fix(cli): render content in promptSelect when terminal height is too small#7209

Merged
crowlKats merged 1 commit into
mainfrom
fix-prompt-select-small-height
Jul 3, 2026
Merged

fix(cli): render content in promptSelect when terminal height is too small#7209
crowlKats merged 1 commit into
mainfrom
fix-prompt-select-small-height

Conversation

@crowlKats

Copy link
Copy Markdown
Member

Problem

promptSelect() (and promptMultipleSelect(), which share handlePromptSelect) 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 0 or negative — e.g. a small terminal, or fitToRemainingHeight: true with the cursor near the bottom of the screen. availableHeight = rows - SAFE_PADDING(4) becomes ≤ 0, which collapses visibleLines to 0, so no items are sliced into the visible window and only the "more content" indicator is printed.

Reproduction (80×4 terminal):

Please select a browser:
  ...

Fix

Clamp visibleLines to at least 1 in both places it is computed, so at least one item is always visible:

Please select a browser:
❯ safari
  ...

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 existing promptSelect/promptMultipleSelect tests still pass.

…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.
@github-actions github-actions Bot added the cli label Jul 2, 2026
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.84%. Comparing base (cdf74a8) to head (ab1c486).
⚠️ Report is 18 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@crowlKats crowlKats merged commit 41d6b67 into main Jul 3, 2026
19 checks passed
@crowlKats crowlKats deleted the fix-prompt-select-small-height branch July 3, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants