Skip to content

fix(cli): fix Prompt.text clear when input wraps terminal lines#6022

Merged
IMax153 merged 1 commit intoEffect-TS:mainfrom
m9tdev:fix/prompt-text-line-wrap
Feb 3, 2026
Merged

fix(cli): fix Prompt.text clear when input wraps terminal lines#6022
IMax153 merged 1 commit intoEffect-TS:mainfrom
m9tdev:fix/prompt-text-line-wrap

Conversation

@m9tdev
Copy link
Contributor

@m9tdev m9tdev commented Feb 2, 2026

Summary

When the user's input in Prompt.text exceeds the terminal width and wraps to a new line, renderClearScreen miscalculates lines to erase because it only considers options.message, not the full rendered line including the input value.

This causes duplicate prompt lines to be printed on each keystroke after the text wraps:

? What would you like to say? › what do you propose to add to play around with? it can be
? What would you like to say? › what do you propose to add to play around with? it can be
? What would you like to say? › what do you propose to add to play around with? it can be
...

Root Cause

In renderClearScreen, line erasure is calculated based only on options.message:

const clearOutput = InternalAnsiUtils.eraseText(options.message, columns)

But the actual rendered line includes: "? " + message + " › " + inputValue

Fix

Calculate the full rendered line length:

const inputValue = state.value.length > 0 ? state.value : options.default
const fullLine = `? ${options.message}${inputValue}`
const clearOutput = InternalAnsiUtils.eraseText(fullLine, columns)

Related

This is the same root cause as #5978 (for Prompt.select), and applies the equivalent fix from #5979 to Prompt.text.

Closes #5978

@m9tdev m9tdev requested a review from IMax153 as a code owner February 2, 2026 22:10
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Feb 2, 2026
@changeset-bot
Copy link

changeset-bot bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: 2eeb3fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/cli Patch

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

When the user's input in `Prompt.text` exceeds the terminal width and
wraps to a new line, `renderClearScreen` miscalculates lines to erase
because it only considers `options.message`, not the full rendered line
including the input value.

This causes duplicate prompt lines to be printed on each keystroke after
the text wraps.

The fix calculates the full rendered line length:
`"? " + message + " › " + inputValue`

This is the same root cause as Effect-TS#5978 (for Prompt.select), and applies
the equivalent fix to Prompt.text.

Closes Effect-TS#5978
@m9tdev m9tdev force-pushed the fix/prompt-text-line-wrap branch from a7640b2 to 2eeb3fa Compare February 2, 2026 22:12
@IMax153
Copy link
Member

IMax153 commented Feb 3, 2026

Thanks @m9tdev ! Would you be willing to test the Prompt impl in Effect v4 to see if a similar issue exists and open an issue there if so? If not, I can take a look.

@IMax153
Copy link
Member

IMax153 commented Feb 3, 2026

Thanks @m9tdev ! Would you be willing to test the Prompt impl in Effect v4 to see if a similar issue exists and open an issue there if so? If not, I can take a look.

Actually, nevermind. I think Tim's lalph bot is picking up backports we need to do. Effect-TS/effect-smol#1159

@IMax153 IMax153 merged commit 5df4da1 into Effect-TS:main Feb 3, 2026
10 of 11 checks passed
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Feb 3, 2026
@github-actions github-actions bot mentioned this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Prompt.select renders duplicate lines when choice descriptions cause terminal line wrapping

2 participants