diff --git a/codi-rs/src/agent/mod.rs b/codi-rs/src/agent/mod.rs index f28a1ab..84fc0bb 100644 --- a/codi-rs/src/agent/mod.rs +++ b/codi-rs/src/agent/mod.rs @@ -326,7 +326,7 @@ impl Agent { // Notify callback if let Some(ref on_tool_result) = self.callbacks.on_tool_result { - on_tool_result(&tool_call.id, &result.content, result.is_error.unwrap_or(false)); + on_tool_result(&tool_call.id, &tool_call.name, &result.content, result.is_error.unwrap_or(false)); } result diff --git a/codi-rs/src/agent/types.rs b/codi-rs/src/agent/types.rs index 2989ed8..91a2e06 100644 --- a/codi-rs/src/agent/types.rs +++ b/codi-rs/src/agent/types.rs @@ -71,8 +71,8 @@ pub struct AgentCallbacks { pub on_text: Option>, /// Called when a tool is about to be executed (tool_id, tool_name, input). pub on_tool_call: Option>, - /// Called when a tool execution completes (tool_id, result, is_error). - pub on_tool_result: Option>, + /// Called when a tool execution completes (tool_id, tool_name, result, is_error). + pub on_tool_result: Option>, /// Called to confirm destructive operations. Returns approval result. pub on_confirm: Option ConfirmationResult + Send + Sync>>, /// Called when context compaction starts/ends. diff --git a/codi-rs/src/tui/app.rs b/codi-rs/src/tui/app.rs index 4109a54..a004cb4 100644 --- a/codi-rs/src/tui/app.rs +++ b/codi-rs/src/tui/app.rs @@ -356,7 +356,7 @@ impl App { })), on_tool_result: Some(Arc::new({ let tx = event_tx.clone(); - move |tool_id: &str, result: &str, is_error: bool| { + move |tool_id: &str, _name: &str, result: &str, is_error: bool| { let _ = tx.send(AppEvent::ToolResult(tool_id.to_string(), result.to_string(), is_error)); } })), diff --git a/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_live_output.snap.new b/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_live_output.snap.new new file mode 100644 index 0000000..871cdfa --- /dev/null +++ b/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_live_output.snap.new @@ -0,0 +1,25 @@ +--- +source: tests/tui_exec_cell.rs +assertion_line: 157 +expression: terminal.backend() +--- +"┌ bash ────────────────────────────────────────────────────────────────────────┐" +"│ ⠋ Running... (6ms) │" +"│ Input: {"cmd":"long_running_command"} │" +"│ ┌──────────────────────────────────────────────────────────────────────────┐ │" +"│ │ Starting process... │ │" +"│ │ Loading configuration │ │" +"│ │ Connecting to database │ │" +"│ │ Executing query │ │" +"│ │ Processing results │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ └──────────────────────────────────────────────────────────────────────────┘ │" +"└──────────────────────────────────────────────────────────────────────────────┘" diff --git a/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_pending.snap.new b/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_pending.snap.new new file mode 100644 index 0000000..68ea5e4 --- /dev/null +++ b/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_pending.snap.new @@ -0,0 +1,25 @@ +--- +source: tests/tui_exec_cell.rs +assertion_line: 30 +expression: terminal.backend() +--- +"┌ read_file ───────────────────────────────────────────────────────────────────┐" +"│ ○ Running... (9ms) │" +"│ Input: {"path":"test.rs"} │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"│ │" +"└──────────────────────────────────────────────────────────────────────────────┘" diff --git a/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_running.snap.new b/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_running.snap.new new file mode 100644 index 0000000..d63f2cf --- /dev/null +++ b/codi-rs/tests/snapshots/tui_exec_cell__exec_cell_running.snap.new @@ -0,0 +1,25 @@ +--- +source: tests/tui_exec_cell.rs +assertion_line: 51 +expression: terminal.backend() +--- +"┌ bash ────────────────────────────────────────────────────────────────────────┐" +"│ ⠋ Running... (5ms) │" +"│ Input: {"cmd":"echo hello"} │" +"│ ┌──────────────────────────────────────────────────────────────────────────┐ │" +"│ │ Processing... │ │" +"│ │ Step 1 complete │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ │ │ │" +"│ └──────────────────────────────────────────────────────────────────────────┘ │" +"└──────────────────────────────────────────────────────────────────────────────┘"