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 mode_id to telemetry (#43045)
Bennet Bo Fennera910c594d6c5
diff --git a/crates/agent_ui/src/acp/mode_selector.rs b/crates/agent_ui/src/acp/mode_selector.rsindex aed151de728..83ab9c29997 100644--- a/crates/agent_ui/src/acp/mode_selector.rs+++ b/crates/agent_ui/src/acp/mode_selector.rs@@ -56,6 +56,10 @@ impl ModeSelector {self.set_mode(all_modes[next_index].id.clone(), cx);}+ pub fn mode(&self) -> acp::SessionModeId {+ self.connection.current_mode()+ }+pub fn set_mode(&mut self, mode: acp::SessionModeId, cx: &mut Context<Self>) {let task = self.connection.set_mode(mode, cx);self.setting_mode = true;diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rsindex 82237d86ba9..312ca136a2b 100644--- a/crates/agent_ui/src/acp/thread_view.rs+++ b/crates/agent_ui/src/acp/thread_view.rs@@ -1135,6 +1135,7 @@ impl AcpThreadView {self.is_loading_contents = true;let model_id = self.current_model_id(cx);+ let mode_id = self.current_mode_id(cx);let guard = cx.new(|_| ());cx.observe_release(&guard, |this, _guard, cx| {this.is_loading_contents = false;@@ -1169,7 +1170,8 @@ impl AcpThreadView {"Agent Message Sent",agent = agent_telemetry_id,session = session_id,- model = model_id+ model = model_id,+ mode = mode_id);thread.send(contents, cx)@@ -1182,6 +1184,7 @@ impl AcpThreadView {agent = agent_telemetry_id,session = session_id,model = model_id,+ mode = mode_id,status,turn_time_ms,);@@ -5405,6 +5408,16 @@ impl AcpThreadView {)}+ fn current_mode_id(&self, cx: &App) -> Option<Arc<str>> {+ if let Some(thread) = self.as_native_thread(cx) {+ Some(thread.read(cx).profile().0.clone())+ } else if let Some(mode_selector) = self.mode_selector() {+ Some(mode_selector.read(cx).mode().0)+ } else {+ None+ }+ }+fn current_model_id(&self, cx: &App) -> Option<String> {self.model_selector.as_ref()