feat: show MCP tool calls in TUI (#836)

Adds logic for the `McpToolCallBegin` and `McpToolCallEnd` events in
`codex-rs/tui/src/chatwidget.rs` so they get entries in the conversation
history in the TUI.

Building on top of https://github.com/openai/codex/pull/829, here is the
result of running:

```
cargo run --bin codex -- 'what is the weather in san francisco tomorrow'
```


![image](https://github.com/user-attachments/assets/db4a79bb-4988-46cb-acb2-446d5ba9e058)
This commit is contained in:
Michael Bolin
2025-05-06 16:12:15 -07:00
committed by GitHub
parent 147a940449
commit 88e7ca5f2b
5 changed files with 172 additions and 3 deletions

View File

@@ -328,6 +328,25 @@ impl ChatWidget<'_> {
.record_completed_exec_command(call_id, stdout, stderr, exit_code);
self.request_redraw()?;
}
EventMsg::McpToolCallBegin {
call_id,
server,
tool,
arguments,
} => {
self.conversation_history
.add_active_mcp_tool_call(call_id, server, tool, arguments);
self.request_redraw()?;
}
EventMsg::McpToolCallEnd {
call_id,
success,
result,
} => {
self.conversation_history
.record_completed_mcp_tool_call(call_id, success, result);
self.request_redraw()?;
}
event => {
self.conversation_history
.add_background_event(format!("{event:?}"));