Skip to content

Commit cabf189

Browse files
authored
agent: Render subagent labels as they stream in (zed-industries#50306)
Release Notes: - N/A
1 parent 6796539 commit cabf189

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

crates/agent/src/tools/spawn_agent_tool.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,14 @@ impl AgentTool for SpawnAgentTool {
8383
input: Result<Self::Input, serde_json::Value>,
8484
_cx: &mut App,
8585
) -> SharedString {
86-
input
87-
.map(|i| i.label.into())
88-
.unwrap_or_else(|_| "Spawning agent".into())
86+
match input {
87+
Ok(i) => i.label.into(),
88+
Err(value) => value
89+
.get("label")
90+
.and_then(|v| v.as_str())
91+
.map(|s| SharedString::from(s.to_owned()))
92+
.unwrap_or_else(|| "Spawning agent".into()),
93+
}
8994
}
9095

9196
fn run(

crates/agent_ui/src/connection_view/thread_view.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6365,22 +6365,25 @@ impl ThreadView {
63656365
ToolCallStatus::Canceled | ToolCallStatus::Failed | ToolCallStatus::Rejected
63666366
);
63676367

6368-
let has_title = thread
6368+
let thread_title = thread
63696369
.as_ref()
6370-
.is_some_and(|t| !t.read(cx).title().is_empty());
6370+
.map(|t| t.read(cx).title())
6371+
.filter(|t| !t.is_empty());
6372+
let tool_call_label = tool_call.label.read(cx).source().to_string();
6373+
let has_tool_call_label = !tool_call_label.is_empty();
6374+
6375+
let has_title = thread_title.is_some() || has_tool_call_label;
63716376
let has_no_title_or_canceled = !has_title || is_canceled_or_failed;
63726377

6373-
let title = thread
6374-
.as_ref()
6375-
.map(|t| t.read(cx).title())
6376-
.unwrap_or_else(|| {
6377-
if is_canceled_or_failed {
6378-
"Subagent Canceled"
6379-
} else {
6380-
"Spawning Subagent…"
6381-
}
6382-
.into()
6383-
});
6378+
let title: SharedString = if let Some(thread_title) = thread_title {
6379+
thread_title
6380+
} else if !tool_call_label.is_empty() {
6381+
tool_call_label.into()
6382+
} else if is_canceled_or_failed {
6383+
"Subagent Canceled".into()
6384+
} else {
6385+
"Spawning agent…".into()
6386+
};
63846387

63856388
let card_header_id = format!("subagent-header-{}", entry_ix);
63866389
let diff_stat_id = format!("subagent-diff-{}", entry_ix);

0 commit comments

Comments
 (0)