fix(cli): resolve duplicate assistant text printing after 'Done' in non-compact text mode
评估
调研方向
从 rust/crates/rusty-claude-cli/src/main.rs 中的 LiveCli::run_turn 开始,检查 streamed text、final_assistant_text 和 spinner.finish 在非紧凑文本模式下如何交互。在该模式下让 claw 运行并返回一条响应,然后确认 assistant 文本只出现一次、最后一行得到保留,并且 Done 状态仍然显示。
由索引模型根据 Issue 内容生成。
描述
Description
When running claw in non-compact text mode, the entire assistant response is printed twice.
- First, the text chunks are streamed and printed in real-time during the API call.
- Second, after
✔ ✨ Doneis printed, the full assistant text (final_text) is printed again.
This causes a large amount of redundant output in the console, especially for long responses.
Cause
In LiveCli::run_turn (inside main.rs), spinner.finish("✨ Done") is called right after the conversation stream finishes.
Because spinner.finish moves the cursor to column 0 and clears the current line, it would erase the last line of the streamed text if we do not print a newline first.
To prevent this, the previous commit introduced a secondary full-text reprint:
let final_text = final_assistant_text(&summary);
if !final_text.is_empty() {
let renderer = TerminalRenderer::new();
println!("{}", renderer.markdown_to_ansi(&final_text));
}
However, this reprints the entire assistant message instead of just protecting the last line, causing the duplicate response.
Solution
- Print a newline before
spinner.finishif thefinal_textis not empty. This moves the cursor to a new line, ensuring the line-clearing operation inspinner.finishonly clears the empty line and does not corrupt the last line of the streamed text. - Remove the redundant
final_textreprint logic inrun_turn.
Here is the proposed diff in rust/crates/rusty-claude-cli/src/main.rs:
@@ -7763,15 +7763,15 @@
match result {
Ok(summary) => {
self.replace_runtime(runtime)?;
- spinner.finish(
- "✨ Done",
- TerminalRenderer::new().color_theme(),
- &mut stdout,
- )?;
let final_text = final_assistant_text(&summary);
if !final_text.is_empty() {
- let renderer = TerminalRenderer::new();
- println!("{}", renderer.markdown_to_ansi(&final_text));
- }
+ println!();
+ }
+ spinner.finish(
+ "✨ Done",
+ TerminalRenderer::new().color_theme(),
+ &mut stdout,
+ )?;
println!();
if let Some(event) = summary.auto_compaction {
- 主要语言
- Rust
- 星标
- 195k
- 派生
- 108k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ultraworkers/claw-code 的其他 Issue
-
Fix markdown formatting issues in TUI streaming: block-level element newline omission and consecutive empty line accumulation可能重新可做 @Aditaya08 于 50 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
ultraworkers/claw-code#3259 · 7 条评论 ·
-
bug: Missing newlines before paragraphs and code blocks in streamed Markdown rendering可能已有人在做 @nankingjing 于 89 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
ultraworkers/claw-code#3257 · 2 条评论 ·
-
[CRITICAL][SECURITY] Untrusted project hooks bypass read-only mode for arbitrary command execution未关闭
难度 4/5 3-5 天 新手友好度 68/100
ultraworkers/claw-code#3301 · 4 条评论 ·
-
难度 4/5 3-5 天 新手友好度 20/100
ultraworkers/claw-code#3300 · 2 条评论 ·
-
Pin all third-party GitHub Actions to immutable commit SHAs across CI workflows可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 72/100
ultraworkers/claw-code#3287 · 6 条评论 · 1 个 reaction ·
查看 ultraworkers/claw-code 的全部 Issue
相似的 Issue
-
enhancement user-priority/P2
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:npm priority:p1
难度 2/5 1-3 小时 新手友好度 85/100
SocketDev/socket-patch#1127 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复