Skip to content

Conversation

@kingstarfly
Copy link

Summary

Fixes #5978

When using Prompt.select with choices that have long descriptions, navigating between options causes duplicate prompt lines to appear instead of updating in place. This happens because handleClear doesn't account for terminal line wrapping.

Changes

  • Modified handleClear in select.ts to calculate actual rendered line lengths
  • Pass state to handleClear to determine which choice has its description displayed
  • Calculate wrapped lines using actual content (prefix + title + description) instead of empty newlines

Root Cause

The previous implementation used:

const text = "\n".repeat(Math.min(options.choices.length, options.maxPerPage)) + options.message

This assumes each choice takes exactly 1 terminal row. However:

  1. Choices render as prefix (2 chars) + title + description
  2. Descriptions are only shown for the selected item
  3. When content length > terminal width, the line wraps to multiple rows

The fix calculates actual content length per choice to properly determine rows to erase.

Testing

Tested locally with long descriptions in a narrow terminal - navigation now updates cleanly without leaving artifacts.

@kingstarfly kingstarfly requested a review from IMax153 as a code owner January 14, 2026 03:46
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Jan 14, 2026
@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

🦋 Changeset detected

Latest commit: fca11fb

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

@IMax153 IMax153 requested a review from kitlangton January 19, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

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

1 participant