Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Add message editor UI improvements (#29594)
Danilo Leal7e2546070879
diff --git a/crates/agent/src/active_thread.rs b/crates/agent/src/active_thread.rsindex e4c528e0046..8aab7dd0f78 100644--- a/crates/agent/src/active_thread.rs+++ b/crates/agent/src/active_thread.rs@@ -1514,8 +1514,6 @@ impl ActiveThread {let show_feedback = thread.is_turn_end(ix);- let needs_confirmation = tool_uses.iter().any(|tool_use| tool_use.needs_confirmation);-let generating_label = (is_generating && is_last_message).then(|| AnimatedLabel::new("Generating").size(LabelSize::Small));@@ -1920,7 +1918,7 @@ impl ActiveThread {parent.child(self.render_rules_item(cx))}).child(styled_message)- .when(!needs_confirmation && generating_label.is_some(), |this| {+ .when(generating_label.is_some(), |this| {this.child(h_flex().h_8()diff --git a/crates/agent/src/message_editor.rs b/crates/agent/src/message_editor.rsindex 512c38927f6..b6d768f87cc 100644--- a/crates/agent/src/message_editor.rs+++ b/crates/agent/src/message_editor.rs@@ -4,6 +4,7 @@ use std::sync::Arc;use crate::assistant_model_selector::{AssistantModelSelector, ModelType};use crate::context::{ContextLoadResult, load_context};use crate::tool_compatibility::{IncompatibleToolsState, IncompatibleToolsTooltip};+use crate::ui::AnimatedLabel;use buffer_diff::BufferDiff;use collections::HashSet;use editor::actions::{MoveUp, Paste};@@ -721,9 +722,12 @@ impl MessageEditor {let border_color = cx.theme().colors().border;let active_color = cx.theme().colors().element_selected;let bg_edit_files_disclosure = editor_bg_color.blend(active_color.opacity(0.3));+let is_edit_changes_expanded = self.edits_expanded;+ let is_generating = self.thread.read(cx).is_generating();v_flex()+ .mt_1().mx_2().bg(bg_edit_files_disclosure).border_1()@@ -758,25 +762,44 @@ impl MessageEditor {cx.notify();})),)- .child(- Label::new("Edits")- .size(LabelSize::Small)- .color(Color::Muted),- )- .child(Label::new("•").size(LabelSize::XSmall).color(Color::Muted))- .child(- Label::new(format!(- "{} {}",- changed_buffers.len(),- if changed_buffers.len() == 1 {- "file"- } else {- "files"- }- ))- .size(LabelSize::Small)- .color(Color::Muted),- ),+ .map(|this| {+ if is_generating {+ this.child(+ AnimatedLabel::new(format!(+ "Editing {} {}",+ changed_buffers.len(),+ if changed_buffers.len() == 1 {+ "file"+ } else {+ "files"+ }+ ))+ .size(LabelSize::Small),+ )+ } else {+ this.child(+ Label::new("Edits")+ .size(LabelSize::Small)+ .color(Color::Muted),+ )+ .child(+ Label::new("•").size(LabelSize::XSmall).color(Color::Muted),+ )+ .child(+ Label::new(format!(+ "{} {}",+ changed_buffers.len(),+ if changed_buffers.len() == 1 {+ "file"+ } else {+ "files"+ }+ ))+ .size(LabelSize::Small)+ .color(Color::Muted),+ )+ }+ }),).child(Button::new("review", "Review Changes")@@ -866,7 +889,7 @@ impl MessageEditor {.justify_between().bg(cx.theme().colors().editor_background).hover(|style| style.bg(hover_color))- .when(index + 1 < changed_buffers.len(), |parent| {+ .when(index < changed_buffers.len() - 1, |parent| {parent.border_color(border_color).border_b_1()}).child(@@ -882,9 +905,9 @@ impl MessageEditor {.gap_0p5().children(name_label).children(parent_label),- ) // TODO: show lines changed- .child(Label::new("+").color(Color::Created))- .child(Label::new("-").color(Color::Deleted)),+ ), // TODO: Implement line diff+ // .child(Label::new("+").color(Color::Created))+ // .child(Label::new("-").color(Color::Deleted)),).child(div().visible_on_hover("edited-code").child(