fix(cli): stop reprinting streamed assistant text after 'Done' in non-compact text mode#3273
Open
nankingjing wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3258.
In non-compact text mode (and the interactive REPL),
LiveCli::run_turnprints the entire assistant response twice:
emit_output = true, soAnthropicRuntimeClient::consume_streamalready streams and renders every text delta to the terminal live
(
main.rs,ContentBlockDelta::TextDelta/MessageStop).spinner.finish("✨ Done")it then callsprintln!("{final_text}"), reprinting the whole message that was just streamed.The reprint was originally added because
Spinner::finishrunsMoveToColumn(0)+Clear(ClearType::CurrentLine)and would otherwise erasethe last streamed line (the streamed tail has no trailing newline). Reprinting
the full text "fixed" the erased line but duplicated everything above it.
Fix
Protect only the last streamed line instead of reprinting the whole message:
println!()beforespinner.finishso the line-clear lands on a fresh empty line rather than thelast content line.
println!("{final_text}")reprint.final_textis still computed and used to decide whether a newline is needed,so the empty-response path (tool-only turns) is unchanged. Compact/JSON paths
use
emit_output = falseand print the message exactly once — they areuntouched.
Scope
rust/crates/rusty-claude-cli/src/main.rs(LiveCli::run_turn), +9 -4.Verification
Verified by reading and tracing the streaming path (
consume_streamwrites eachtext delta live when
emit_outputis true;prepare_turn_runtime(true)is usedby
run_turn, while the compact/JSON paths useprepare_turn_runtime(false))and by inspecting
Spinner::finish's line-clear behavior. Not compiled orexecuted in this environment (full Rust workspace build not available here).
The change is a local reordering plus removal of one
println!;final_textremains used, so no unused-variable warning is introduced.