From 2eeb3fac07528dc5dd081b555c126825518d25b7 Mon Sep 17 00:00:00 2001 From: Mathieu Post Date: Mon, 2 Feb 2026 23:08:38 +0100 Subject: [PATCH] fix(cli): fix Prompt.text clear when input wraps terminal lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #5978 (for Prompt.select), and applies the equivalent fix to Prompt.text. Closes #5978 --- .changeset/fix-prompt-text-wrap.md | 5 +++++ packages/cli/src/internal/prompt/text.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-prompt-text-wrap.md 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),