Repository navigation
fix(prompts): keep autocomplete prompts within the terminal height - #634
Open
chenxin-yan wants to merge 1 commit into
Open
chenxin-yan wants to merge 1 commit into
chenxin-yan wants to merge 1 commit into
Conversation
Count wrapped message, search, and instruction lines when sizing the option list, and pass columnPadding for the guide prefix in autocompleteMultiselect.
🦋 Changeset detectedLatest commit: 0631532 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
43081j
reviewed
Nov 10, 2026
| }); | ||
| }); | ||
|
|
||
| describe('autocomplete prompts in a narrow terminal', () => { |
Collaborator
There was a problem hiding this comment.
this doesn't belong in its own describe block
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.
What does this PR do?
autocompleteandautocompleteMultiselectsize their option list fromrows - rowPadding, butrowPaddingcounted the header and footer lines before they wrap. In a narrow terminal the message or the instructions line wraps, the frame grows taller than the terminal, and each redraw leaves stale rows above the prompt.This applies the approach
selectandmultiselectalready use:wrapTextWithPrefix, so continuation lines get the guide bar and are counted.Search:line and the instructions line withwrapTextWithPrefixbefore counting them.columnPaddingtolimitOptionsinautocompleteMultiselect, asautocompletealready does, so options are measured against the width left after│.The instructions line keeps its state-coloured bar (
barStyle). That's why it callswrapTextWithPrefixdirectly instead offormatInstructionFooter, which always uses cyan.Output at normal widths is unchanged; no existing snapshots changed.
Closes #633
Type of change
Checklist
pnpm testpasses (or targeted tests for my change)pnpm formathas been runTesting
packages/prompts/test/autocomplete.test.ts: both prompts, 40x20 output, a message that wraps, 30 long options. It asserts the first frame is no taller thanoutput.rows. Without the fix it fails (21 rows forautocomplete, 27 forautocompleteMultiselect); with it, it passes.pnpm test: core 173 passed; prompts 630 passed, 4 skipped.pnpm typesandbiome checkpass.autocompleteMultiselectoverflows at all three 60-column sizes.Notes
withGuide: false,wrapTextWithPrefixmeasures the empty continuation prefix rather than the◆start prefix, so a message's first line can still be 3 columns too wide. This copiesmultiselect's message wrapping, which behaves the same way; I left it out of scope.AI-generated code disclosure