Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent_ui: Add some fixes to tool calling display (#45252)
Danilo Leal61dd6a8f3185
diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rsindex fe6a3a30870..ed61141b0ab 100644--- a/crates/agent_ui/src/acp/thread_view.rs+++ b/crates/agent_ui/src/acp/thread_view.rs@@ -2113,6 +2113,7 @@ impl AcpThreadView {chunks,indented: _,}) => {+ let mut is_blank = true;let is_last = entry_ix + 1 == total_entries;let style = default_markdown_style(false, false, window, cx);@@ -2122,36 +2123,55 @@ impl AcpThreadView {.children(chunks.iter().enumerate().filter_map(|(chunk_ix, chunk)| match chunk {AssistantMessageChunk::Message { block } => {- block.markdown().map(|md| {- self.render_markdown(md.clone(), style.clone())- .into_any_element()+ block.markdown().and_then(|md| {+ let this_is_blank = md.read(cx).source().trim().is_empty();+ is_blank = is_blank && this_is_blank;+ if this_is_blank {+ return None;+ }++ Some(+ self.render_markdown(md.clone(), style.clone())+ .into_any_element(),+ )})}AssistantMessageChunk::Thought { block } => {- block.markdown().map(|md| {- self.render_thinking_block(- entry_ix,- chunk_ix,- md.clone(),- window,- cx,+ block.markdown().and_then(|md| {+ let this_is_blank = md.read(cx).source().trim().is_empty();+ is_blank = is_blank && this_is_blank;+ if this_is_blank {+ return None;+ }++ Some(+ self.render_thinking_block(+ entry_ix,+ chunk_ix,+ md.clone(),+ window,+ cx,+ )+ .into_any_element(),)- .into_any_element()})}},)).into_any();- v_flex()- .px_5()- .py_1p5()- .when(is_first_indented, |this| this.pt_0p5())- .when(is_last, |this| this.pb_4())- .w_full()- .text_ui(cx)- .child(message_body)- .into_any()+ if is_blank {+ Empty.into_any()+ } else {+ v_flex()+ .px_5()+ .py_1p5()+ .when(is_last, |this| this.pb_4())+ .w_full()+ .text_ui(cx)+ .child(message_body)+ .into_any()+ }}AgentThreadEntry::ToolCall(tool_call) => {let has_terminals = tool_call.terminals().next().is_some();@@ -2183,7 +2203,7 @@ impl AcpThreadView {div().relative().w_full()- .pl(rems_from_px(20.0))+ .pl_5().bg(cx.theme().colors().panel_background.opacity(0.2)).child(div()@@ -2447,25 +2467,25 @@ impl AcpThreadView {| ToolCallStatus::Completed| ToolCallStatus::Failed| ToolCallStatus::Canceled => v_flex()- .mt_1p5()- .w_full()- .child(- v_flex()- .ml(rems(0.4))- .px_3p5()- .pb_1()- .gap_1()- .border_l_1()- .border_color(self.tool_card_border_color(cx))- .child(input_output_header("Raw Input".into()))- .children(tool_call.raw_input_markdown.clone().map(|input| {- self.render_markdown(- input,- default_markdown_style(false, false, window, cx),- )- }))- .child(input_output_header("Output:".into())),- )+ .when(!is_edit && !is_terminal_tool, |this| {+ this.mt_1p5().w_full().child(+ v_flex()+ .ml(rems(0.4))+ .px_3p5()+ .pb_1()+ .gap_1()+ .border_l_1()+ .border_color(self.tool_card_border_color(cx))+ .child(input_output_header("Raw Input:".into()))+ .children(tool_call.raw_input_markdown.clone().map(|input| {+ self.render_markdown(+ input,+ default_markdown_style(false, false, window, cx),+ )+ }))+ .child(input_output_header("Output:".into())),+ )+ }).children(tool_call.content.iter().enumerate().map(|(content_ix, content)| {div().child(self.render_tool_call_content(@@ -2751,18 +2771,19 @@ impl AcpThreadView {v_flex().gap_2()- .when(!card_layout, |this| {- this.ml(rems(0.4))- .px_3p5()- .border_l_1()- .border_color(self.tool_card_border_color(cx))- })- .when(card_layout, |this| {- this.px_2().pb_2().when(context_ix > 0, |this| {- this.border_t_1()- .pt_2()+ .map(|this| {+ if card_layout {+ this.when(context_ix > 0, |this| {+ this.pt_2()+ .border_t_1()+ .border_color(self.tool_card_border_color(cx))+ })+ } else {+ this.ml(rems(0.4))+ .px_3p5()+ .border_l_1().border_color(self.tool_card_border_color(cx))- })+ }}).text_xs().text_color(cx.theme().colors().text_muted)