fixed newline character messup

This commit is contained in:
Dhanji Prasanna
2025-10-03 14:04:17 +10:00
parent dfa54f20ec
commit 54e2a66b7d
2 changed files with 57 additions and 20 deletions

View File

@@ -91,7 +91,11 @@ pub struct RetroTuiWriter {
impl RetroTuiWriter {
pub fn new(tui: RetroTui) -> Self {
Self { tui, current_tool_name: Mutex::new(None), current_tool_output: Mutex::new(Vec::new()) }
Self {
tui,
current_tool_name: Mutex::new(None),
current_tool_output: Mutex::new(Vec::new()),
}
}
}
@@ -127,20 +131,32 @@ impl UiWriter for RetroTuiWriter {
// Start collecting tool output
*self.current_tool_name.lock().unwrap() = Some(tool_name.to_string());
self.current_tool_output.lock().unwrap().clear();
self.current_tool_output.lock().unwrap().push(format!("Tool: {}", tool_name));
self.current_tool_output
.lock()
.unwrap()
.push(format!("Tool: {}", tool_name));
}
fn print_tool_arg(&self, key: &str, value: &str) {
self.current_tool_output.lock().unwrap().push(format!("{}: {}", key, value));
self.current_tool_output
.lock()
.unwrap()
.push(format!("{}: {}", key, value));
}
fn print_tool_output_header(&self) {
self.current_tool_output.lock().unwrap().push(String::new());
self.current_tool_output.lock().unwrap().push("Output:".to_string());
self.current_tool_output
.lock()
.unwrap()
.push("Output:".to_string());
}
fn print_tool_output_line(&self, line: &str) {
self.current_tool_output.lock().unwrap().push(line.to_string());
self.current_tool_output
.lock()
.unwrap()
.push(line.to_string());
}
fn print_tool_output_summary(&self, hidden_count: usize) {
@@ -152,21 +168,24 @@ impl UiWriter for RetroTuiWriter {
}
fn print_tool_timing(&self, duration_str: &str) {
self.current_tool_output.lock().unwrap().push(format!("⚡️ {}", duration_str));
self.current_tool_output
.lock()
.unwrap()
.push(format!("⚡️ {}", duration_str));
// Now send the complete tool output as a box
if let Some(tool_name) = self.current_tool_name.lock().unwrap().as_ref() {
let content = self.current_tool_output.lock().unwrap().join("\n");
self.tui.tool_output(tool_name, &content);
self.tui.tool_output(tool_name, "...", &content);
}
// Clear the buffers
*self.current_tool_name.lock().unwrap() = None;
self.current_tool_output.lock().unwrap().clear();
}
fn print_agent_prompt(&self) {
self.tui.output("🤖 ");
self.tui.output("💬 ");
}
fn print_agent_response(&self, content: &str) {