diff --git a/.changeset/fix-prompt-text-wrap.md b/.changeset/fix-prompt-text-wrap.md new file mode 100644 index 00000000000..3b0571b50d0 --- /dev/null +++ b/.changeset/fix-prompt-text-wrap.md @@ -0,0 +1,5 @@ +--- +"@effect/cli": patch +--- + +Fixed `Prompt.text` rendering duplicate lines when input text wraps to a new terminal line. diff --git a/packages/cli/src/internal/prompt/text.ts b/packages/cli/src/internal/prompt/text.ts index 28046770613..1cfc3560ef7 100644 --- a/packages/cli/src/internal/prompt/text.ts +++ b/packages/cli/src/internal/prompt/text.ts @@ -49,7 +49,10 @@ function renderClearScreen(state: State, options: Options) { ) }) // Ensure that the prior prompt output is cleaned up - const clearOutput = InternalAnsiUtils.eraseText(options.message, columns) + // Calculate full rendered line: "? " + message + " › " + input + const inputValue = state.value.length > 0 ? state.value : options.default + const fullLine = `? ${options.message} \u203a ${inputValue}` + const clearOutput = InternalAnsiUtils.eraseText(fullLine, columns) // Concatenate and render all documents return clearError.pipe( Doc.cat(clearOutput),