diff --git a/crates/agent/src/tools/spawn_agent_tool.rs b/crates/agent/src/tools/spawn_agent_tool.rs index f46e85ce26d9194047ef62223393db0ac30f0f4b..2c5c40c704464639ca43b7da32ab8ae0239e3b6a 100644 --- a/crates/agent/src/tools/spawn_agent_tool.rs +++ b/crates/agent/src/tools/spawn_agent_tool.rs @@ -83,9 +83,14 @@ impl AgentTool for SpawnAgentTool { input: Result, _cx: &mut App, ) -> SharedString { - input - .map(|i| i.label.into()) - .unwrap_or_else(|_| "Spawning agent".into()) + match input { + Ok(i) => i.label.into(), + Err(value) => value + .get("label") + .and_then(|v| v.as_str()) + .map(|s| SharedString::from(s.to_owned())) + .unwrap_or_else(|| "Spawning agent".into()), + } } fn run( diff --git a/crates/agent_ui/src/connection_view/thread_view.rs b/crates/agent_ui/src/connection_view/thread_view.rs index ddeabf46c9ed85ea2a70f1d935f53a764ba66323..20d860c5c14fd8c5c50be3b2bc8eefb89d9d7db6 100644 --- a/crates/agent_ui/src/connection_view/thread_view.rs +++ b/crates/agent_ui/src/connection_view/thread_view.rs @@ -6365,22 +6365,25 @@ impl ThreadView { ToolCallStatus::Canceled | ToolCallStatus::Failed | ToolCallStatus::Rejected ); - let has_title = thread + let thread_title = thread .as_ref() - .is_some_and(|t| !t.read(cx).title().is_empty()); + .map(|t| t.read(cx).title()) + .filter(|t| !t.is_empty()); + let tool_call_label = tool_call.label.read(cx).source().to_string(); + let has_tool_call_label = !tool_call_label.is_empty(); + + let has_title = thread_title.is_some() || has_tool_call_label; let has_no_title_or_canceled = !has_title || is_canceled_or_failed; - let title = thread - .as_ref() - .map(|t| t.read(cx).title()) - .unwrap_or_else(|| { - if is_canceled_or_failed { - "Subagent Canceled" - } else { - "Spawning Subagent…" - } - .into() - }); + let title: SharedString = if let Some(thread_title) = thread_title { + thread_title + } else if !tool_call_label.is_empty() { + tool_call_label.into() + } else if is_canceled_or_failed { + "Subagent Canceled".into() + } else { + "Spawning agent…".into() + }; let card_header_id = format!("subagent-header-{}", entry_ix); let diff_stat_id = format!("subagent-diff-{}", entry_ix);