Avoid cloning MCP invocations in TUI history (#38103)

## What changed

Update MCP invocation formatting to borrow the invocation and its server and
tool names instead of cloning them when rendering TUI history cells.

GitOrigin-RevId: ac824d86d445215d6b730c6a28b4ec4dfc4f5b8c
This commit is contained in:
Charlie Marsh
2026-08-12 01:54:13 +00:00
committed by copyberry
parent c909d1bc04
commit eb9dceba1a
+5 -5
View File
@@ -164,7 +164,7 @@ impl McpToolCallCell {
.unwrap_or_else(|| "node_repl.js".to_string());
Line::from(title.cyan())
} else {
line_to_static(&format_mcp_invocation(self.invocation.clone()))
line_to_static(&format_mcp_invocation(&self.invocation))
};
let mut compact_spans = vec![bullet.clone(), " ".into(), header_text.bold(), " ".into()];
let mut compact_header = Line::from(compact_spans.clone());
@@ -296,7 +296,7 @@ impl HistoryCell for McpToolCallCell {
};
let mut lines = vec![Line::from(format!(
"{header_text} {}",
format_mcp_invocation(self.invocation.clone())
format_mcp_invocation(&self.invocation)
))];
if let Some(result) = &self.result {
@@ -745,7 +745,7 @@ impl HistoryCell for McpInventoryLoadingCell {
pub(crate) fn new_mcp_inventory_loading(animations_enabled: bool) -> McpInventoryLoadingCell {
McpInventoryLoadingCell::new(animations_enabled)
}
fn format_mcp_invocation<'a>(invocation: McpInvocation) -> Line<'a> {
fn format_mcp_invocation(invocation: &McpInvocation) -> Line<'_> {
let args_str = invocation
.arguments
.as_ref()
@@ -756,9 +756,9 @@ fn format_mcp_invocation<'a>(invocation: McpInvocation) -> Line<'a> {
.unwrap_or_default();
let invocation_spans = vec![
invocation.server.clone().cyan(),
invocation.server.as_str().cyan(),
".".into(),
invocation.tool.cyan(),
invocation.tool.as_str().cyan(),
"(".into(),
args_str.dim(),
")".into(),