From feadf052f7a1bdb7131b50b739eb4ec0e7ecc9aa Mon Sep 17 00:00:00 2001 From: tanzhenxin Date: Fri, 17 Apr 2026 12:49:47 +0800 Subject: [PATCH] fix(cli): append newline to text-mode emitResult so zsh PROMPT_SP doesn't erase the line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Headless text mode wrote `resultMessage.result` without a trailing newline. In a TTY, zsh themes that use PROMPT_SP (powerlevel10k, agnoster, …) detect the missing `\n` and emit `\r\033[K` before drawing the next prompt, which wipes the final line off the screen. Pipe-captured output was unaffected, so the bug only surfaced for interactive shell users — most visibly in the background-agent flow where the drain-loop's final assistant message is the *only* stdout write in text mode. Append `\n` to both the success (stdout) and error (stderr) writes. --- packages/cli/src/nonInteractive/io/JsonOutputAdapter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/nonInteractive/io/JsonOutputAdapter.ts b/packages/cli/src/nonInteractive/io/JsonOutputAdapter.ts index 68633675b..5d36ac7f0 100644 --- a/packages/cli/src/nonInteractive/io/JsonOutputAdapter.ts +++ b/packages/cli/src/nonInteractive/io/JsonOutputAdapter.ts @@ -67,9 +67,9 @@ export class JsonOutputAdapter if (this.config.getOutputFormat() === 'text') { if (resultMessage.is_error) { - process.stderr.write(`${resultMessage.error?.message || ''}`); + process.stderr.write(`${resultMessage.error?.message || ''}\n`); } else { - process.stdout.write(`${resultMessage.result}`); + process.stdout.write(`${resultMessage.result}\n`); } } else { // Emit the entire messages array as JSON (includes all main agent + subagent messages)