Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent_ui: Iterate on title display on the toolbar (#59162)
Danilo Lealc486f6f529de
diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rsindex 5ac65f0588d..444cb8cff78 100644--- a/crates/agent_ui/src/agent_panel.rs+++ b/crates/agent_ui/src/agent_panel.rs@@ -1178,7 +1178,6 @@ pub struct AgentPanel {_base_view_observation: Option<Subscription>,_draft_editor_observation: Option<Subscription>,_active_draft_reclaim_observation: Option<Subscription>,- _empty_thread_title_observation: Option<Subscription>,_thread_metadata_store_subscription: Subscription,last_context_source: Option<AgentContextSource>,@@ -1586,7 +1585,6 @@ impl AgentPanel {_base_view_observation: None,_draft_editor_observation: None,_active_draft_reclaim_observation: None,- _empty_thread_title_observation: None,_thread_metadata_store_subscription,last_context_source: None,is_active: false,@@ -3015,28 +3013,6 @@ impl AgentPanel {}));}- /// Re-renders the toolbar as the user types so the empty-thread- /// placeholder title tracks the message editor's content.- fn observe_message_editor_for_toolbar_title(- &mut self,- conversation_view: &Entity<ConversationView>,- cx: &mut Context<Self>,- ) {- let Some(editor) = conversation_view- .read(cx)- .root_thread_view()- .map(|tv| tv.read(cx).message_editor.clone())- else {- self._empty_thread_title_observation = None;- return;- };- self._empty_thread_title_observation = Some(cx.observe(&editor, |this, _editor, cx| {- if !this.active_thread_has_messages(cx) {- cx.notify();- }- }));- }-fn try_make_empty_draft_ephemeral(&mut self,conversation_view: Entity<ConversationView>,@@ -4247,12 +4223,10 @@ impl AgentPanel {}));let cv = conversation_view.clone();self.observe_active_draft_for_empty_editor(&cv, cx);- self.observe_message_editor_for_toolbar_title(&cv, cx);Some(cx.observe_in(&cv, window, |this, server_view, window, cx| {this._thread_view_subscription =Self::subscribe_to_active_thread_view(&server_view, window, cx);this.observe_active_draft_for_empty_editor(&server_view, cx);- this.observe_message_editor_for_toolbar_title(&server_view, cx);cx.emit(AgentPanelEvent::ActiveViewChanged);this.serialize(cx);cx.notify();@@ -4260,7 +4234,6 @@ impl AgentPanel {}BaseView::Terminal { terminal_id } => {self._thread_view_subscription = None;- self._empty_thread_title_observation = None;if let Some(terminal) = self.terminals.get(terminal_id) {let terminal_id = *terminal_id;let focus_handle = terminal.view.focus_handle(cx);@@ -4282,7 +4255,6 @@ impl AgentPanel {BaseView::Uninitialized => {self._thread_view_subscription = None;self._active_thread_focus_subscription = None;- self._empty_thread_title_observation = None;None}};@@ -6122,21 +6094,12 @@ impl AgentPanel {.flex_none().justify_between();- let empty_thread_title = if matches!(mode, ToolbarMode::EmptyThread) {- let draft_label = self- .active_thread_id(cx)- .and_then(|thread_id| self.editor_text(thread_id, cx))- .and_then(|text| crate::draft_prompt_store::truncate_draft_label(&text));- Some(match draft_label {- Some(label) => Label::new(label).truncate().into_any_element(),- None => Label::new(format!("New {} Thread", selected_agent_label))- .color(Color::Muted)- .truncate()- .into_any_element(),- })- } else {- None- };+ let empty_thread_title = matches!(mode, ToolbarMode::EmptyThread).then(|| {+ Label::new(format!("New {} Thread", selected_agent_label))+ .color(Color::Muted)+ .truncate()+ .into_any_element()+ });let toolbar_content = {let new_thread_menu = PopoverMenu::new("new_thread_menu")