Add compact format for remember, take_screenshot, code_coverage, rehydrate
Extend compact single-line output to additional tools: - remember: shows '📝 memory updated (size)' - take_screenshot: shows '📸 path' - code_coverage: shows '📊 report generated' - rehydrate: shows '🔄 restored fragment_id' Tools without file_path argument use simplified format: ● tool_name | summary | tokens ◉ time
This commit is contained in:
@@ -2144,7 +2144,7 @@ impl<W: UiWriter> Agent<W> {
|
||||
}
|
||||
|
||||
// Check if this is a compact tool (file operations)
|
||||
let is_compact_tool = matches!(tool_call.tool.as_str(), "read_file" | "write_file" | "str_replace");
|
||||
let is_compact_tool = matches!(tool_call.tool.as_str(), "read_file" | "write_file" | "str_replace" | "remember" | "take_screenshot" | "code_coverage" | "rehydrate");
|
||||
|
||||
// Only print output header for non-compact tools
|
||||
if !is_compact_tool {
|
||||
@@ -2208,7 +2208,23 @@ impl<W: UiWriter> Agent<W> {
|
||||
let (ins, del) = parse_diff_stats(&tool_result);
|
||||
Some(streaming::format_str_replace_summary(ins, del))
|
||||
}
|
||||
_ => Some(streaming::format_read_file_summary(output_len, tool_result.len()))
|
||||
"remember" => {
|
||||
// Extract size from result like "Memory updated. Size: 1.2k"
|
||||
Some(streaming::format_remember_summary(&tool_result))
|
||||
}
|
||||
"take_screenshot" => {
|
||||
// Extract path from result
|
||||
Some(streaming::format_screenshot_summary(&tool_result))
|
||||
}
|
||||
"code_coverage" => {
|
||||
// Show coverage summary
|
||||
Some(streaming::format_coverage_summary(&tool_result))
|
||||
}
|
||||
"rehydrate" => {
|
||||
// Show fragment info
|
||||
Some(streaming::format_rehydrate_summary(&tool_result))
|
||||
}
|
||||
_ => Some(format!("✅ completed"))
|
||||
}
|
||||
} else if is_todo_tool {
|
||||
// Skip - todo tools print their own content
|
||||
|
||||
@@ -313,6 +313,58 @@ pub fn format_str_replace_summary(insertions: i32, deletions: i32) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Format a remember tool result summary.
|
||||
pub fn format_remember_summary(result: &str) -> String {
|
||||
// Result format: "Memory updated. Size: 1.2k" or similar
|
||||
if let Some(size_pos) = result.find("Size: ") {
|
||||
let size_str = &result[size_pos + 6..];
|
||||
let size = size_str.split_whitespace().next().unwrap_or("?");
|
||||
format!("📝 memory updated ({})", size)
|
||||
} else {
|
||||
"📝 memory updated".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Format a take_screenshot result summary.
|
||||
pub fn format_screenshot_summary(result: &str) -> String {
|
||||
// Result format: "✅ Screenshot of X saved to: /path/to/file.png"
|
||||
if let Some(path_pos) = result.find("saved to: ") {
|
||||
let path = &result[path_pos + 10..].trim();
|
||||
format!("📸 {}", path)
|
||||
} else if result.contains("❌") {
|
||||
"❌ failed".to_string()
|
||||
} else {
|
||||
"📸 saved".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Format a code_coverage result summary.
|
||||
pub fn format_coverage_summary(result: &str) -> String {
|
||||
// Try to extract coverage percentage from result
|
||||
if result.contains("❌") {
|
||||
"❌ failed".to_string()
|
||||
} else {
|
||||
"📊 report generated".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Format a rehydrate result summary.
|
||||
pub fn format_rehydrate_summary(result: &str) -> String {
|
||||
// Result format: "✅ Rehydrated fragment 'abc123' (47 messages, ~18500 tokens)"
|
||||
if let Some(start) = result.find("fragment '") {
|
||||
let after = &result[start + 10..];
|
||||
if let Some(end) = after.find("'") {
|
||||
let fragment_id = &after[..end];
|
||||
return format!("🔄 restored '{}'", fragment_id);
|
||||
}
|
||||
}
|
||||
if result.contains("❌") {
|
||||
"❌ failed".to_string()
|
||||
} else {
|
||||
"🔄 restored".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Determine if a response is essentially empty (whitespace or timing only)
|
||||
pub fn is_empty_response(response: &str) -> bool {
|
||||
response.trim().is_empty()
|
||||
|
||||
Reference in New Issue
Block a user