Move source property onto Agent Thread Started, remove New Thread Clicked

Katie Geer created

New Thread Clicked was redundant with Agent Thread Started for every
path that results in an actual thread. The only unique signal it carried
was source (sidebar vs agent_panel), which is now threaded through the
call chain instead.

Chain of changes:
- do_new_thread gains source: &'static str; new_thread passes
  'agent_panel', new_thread_from_sidebar passes 'sidebar'
- external_thread and create_agent_thread gain source: &'static str;
  all 11 existing external_thread call sites pass 'agent_panel'
- ConversationView::new and initial_state gain source: &'static str
- Agent Thread Started now includes source, side, thread_location
- New Thread Clicked removed from new_thread, new_thread_from_sidebar,
  and the + menu builder closure
- thread_location_str helper removed (no remaining callers)

Change summary

crates/agent_ui/src/agent_panel.rs       | 69 +++++++++++++++----------
crates/agent_ui/src/conversation_view.rs |  5 +
2 files changed, 45 insertions(+), 29 deletions(-)

Detailed changes

crates/agent_ui/src/agent_panel.rs 🔗

@@ -214,6 +214,7 @@ pub fn init(cx: &mut App) {
                                 None,
                                 initial_content,
                                 true,
+                                "agent_panel",
                                 window,
                                 cx,
                             )
@@ -351,6 +352,7 @@ pub fn init(cx: &mut App) {
                                 auto_submit: true,
                             }),
                             true,
+                            "agent_panel",
                             window,
                             cx,
                         );
@@ -377,6 +379,7 @@ pub fn init(cx: &mut App) {
                                     auto_submit: true,
                                 }),
                                 true,
+                                "agent_panel",
                                 window,
                                 cx,
                             );
@@ -405,6 +408,7 @@ pub fn init(cx: &mut App) {
                                     auto_submit: true,
                                 }),
                                 true,
+                                "agent_panel",
                                 window,
                                 cx,
                             );
@@ -1269,6 +1273,7 @@ impl AgentPanel {
             title,
             None,
             true,
+            "agent_panel",
             window,
             cx,
         );
@@ -1304,27 +1309,27 @@ impl AgentPanel {
     }
 
     pub fn new_thread(&mut self, _action: &NewThread, window: &mut Window, cx: &mut Context<Self>) {
-        telemetry::event!(
-            "New Thread Clicked",
-            source = "agent_panel",
-            thread_location = thread_location_str(cx)
-        );
-        self.do_new_thread(window, cx);
+        self.do_new_thread("agent_panel", window, cx);
     }
 
     pub fn new_thread_from_sidebar(&mut self, window: &mut Window, cx: &mut Context<Self>) {
-        telemetry::event!(
-            "New Thread Clicked",
-            source = "sidebar",
-            thread_location = thread_location_str(cx)
-        );
-        self.do_new_thread(window, cx);
+        self.do_new_thread("sidebar", window, cx);
     }
 
-    fn do_new_thread(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+    fn do_new_thread(&mut self, source: &'static str, window: &mut Window, cx: &mut Context<Self>) {
         self.reset_start_thread_in_to_default(cx);
         let initial_content = self.take_active_draft_initial_content(cx);
-        self.external_thread(None, None, None, None, initial_content, true, window, cx);
+        self.external_thread(
+            None,
+            None,
+            None,
+            None,
+            initial_content,
+            true,
+            source,
+            window,
+            cx,
+        );
     }
 
     fn take_active_draft_initial_content(
@@ -1392,6 +1397,7 @@ impl AgentPanel {
                         title: thread.title,
                     }),
                     true,
+                    "agent_panel",
                     window,
                     cx,
                 );
@@ -1409,6 +1415,7 @@ impl AgentPanel {
         title: Option<SharedString>,
         initial_content: Option<AgentInitialContent>,
         focus: bool,
+        source: &'static str,
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
@@ -1436,6 +1443,7 @@ impl AgentPanel {
             project,
             agent,
             focus,
+            source,
             window,
             cx,
         );
@@ -2443,6 +2451,7 @@ impl AgentPanel {
             None,
             external_source_prompt.map(AgentInitialContent::from),
             true,
+            "agent_panel",
             window,
             cx,
         );
@@ -2468,6 +2477,7 @@ impl AgentPanel {
             None,
             initial_content,
             focus,
+            "agent_panel",
             window,
             cx,
         );
@@ -2529,6 +2539,7 @@ impl AgentPanel {
             title,
             None,
             focus,
+            "agent_panel",
             window,
             cx,
         );
@@ -2545,6 +2556,7 @@ impl AgentPanel {
         project: Entity<Project>,
         agent: Agent,
         focus: bool,
+        source: &'static str,
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
@@ -2583,6 +2595,7 @@ impl AgentPanel {
                 project,
                 thread_store,
                 self.prompt_store.clone(),
+                source,
                 window,
                 cx,
             )
@@ -3275,6 +3288,7 @@ impl AgentPanel {
                             None,
                             Some(initial_content),
                             true,
+                            "agent_panel",
                             window,
                             cx,
                         );
@@ -3341,14 +3355,6 @@ fn agent_panel_side_str(cx: &App) -> &'static str {
     }
 }
 
-fn thread_location_str(cx: &App) -> &'static str {
-    use settings::{NewThreadLocation, Settings};
-    match AgentSettings::get_global(cx).new_thread_location {
-        NewThreadLocation::LocalProject => "current_worktree",
-        NewThreadLocation::NewWorktree => "new_worktree",
-    }
-}
-
 pub enum AgentPanelEvent {
     ActiveViewChanged,
     ThreadFocused,
@@ -3810,12 +3816,6 @@ impl AgentPanel {
             let agent_server_store = agent_server_store;
 
             Rc::new(move |window, cx| {
-                telemetry::event!(
-                    "New Thread Clicked",
-                    source = "agent_panel",
-                    thread_location = thread_location_str(cx)
-                );
-
                 let active_thread = active_thread.clone();
                 Some(ContextMenu::build(window, cx, |menu, _window, cx| {
                     menu.context(focus_handle.clone())
@@ -4709,7 +4709,18 @@ impl AgentPanel {
         };
 
         self.create_agent_thread(
-            server, None, None, None, None, workspace, project, ext_agent, true, window, cx,
+            server,
+            None,
+            None,
+            None,
+            None,
+            workspace,
+            project,
+            ext_agent,
+            true,
+            "agent_panel",
+            window,
+            cx,
         );
     }
 

crates/agent_ui/src/conversation_view.rs 🔗

@@ -522,6 +522,7 @@ impl ConversationView {
         project: Entity<Project>,
         thread_store: Option<Entity<ThreadStore>>,
         prompt_store: Option<Entity<PromptStore>>,
+        source: &'static str,
         window: &mut Window,
         cx: &mut Context<Self>,
     ) -> Self {
@@ -568,6 +569,7 @@ impl ConversationView {
                 title,
                 project,
                 initial_content,
+                source,
                 window,
                 cx,
             ),
@@ -611,6 +613,7 @@ impl ConversationView {
             title,
             self.project.clone(),
             None,
+            "agent_panel",
             window,
             cx,
         );
@@ -635,6 +638,7 @@ impl ConversationView {
         title: Option<SharedString>,
         project: Entity<Project>,
         initial_content: Option<AgentInitialContent>,
+        source: &'static str,
         window: &mut Window,
         cx: &mut Context<Self>,
     ) -> ServerState {
@@ -696,6 +700,7 @@ impl ConversationView {
             telemetry::event!(
                 "Agent Thread Started",
                 agent = connection.telemetry_id(),
+                source = source,
                 side = side,
                 thread_location = thread_location
             );