Fix write_file compact summary to show actual line/char counts

The write_file compact display was showing 1 line because it was
counting lines in the success message, not the actual written content.

Now parses the tool result (e.g. ' wrote 150 lines | 4.2k chars')
to extract and display the correct counts.

Added format_write_file_result() to parse the tool output.
This commit is contained in:
Dhanji R. Prasanna
2026-01-12 20:32:54 +05:30
parent fe67e72ddd
commit 1b051aad94
2 changed files with 20 additions and 3 deletions

View File

@@ -2204,9 +2204,9 @@ impl<W: UiWriter> Agent<W> {
match tool_call.tool.as_str() {
"read_file" => Some(streaming::format_read_file_summary(output_len, tool_result.len())),
"write_file" => {
// Parse the result to get line/char counts
// Result format: "✅ +N insertions | -M deletions" or similar
Some(streaming::format_write_file_summary(output_len, tool_result.len()))
// The tool result already contains the formatted summary
// Format: "✅ wrote N lines | M chars"
Some(streaming::format_write_file_result(&tool_result))
}
"str_replace" => {
// Parse insertions/deletions from result