Add source and thread_location properties to New Thread Clicked

Katie Geer created

Enriches the existing event with two new properties:

- source: 'agent_panel' when triggered from the toolbar + button in the
  agent panel, 'sidebar' when triggered from the sidebar thread list.

- thread_location: 'current_worktree' or 'new_worktree', read from
  AgentSettings::new_thread_location at event-fire time in both call
  sites. This reflects the user's active preference for where new
  threads land, matching NewThreadLocation::LocalProject and
  NewThreadLocation::NewWorktree respectively.

Change summary

crates/agent_ui/src/agent_panel.rs | 11 ++++++++++-
crates/sidebar/src/sidebar.rs      | 12 +++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)

Detailed changes

crates/agent_ui/src/agent_panel.rs 🔗

@@ -3777,7 +3777,16 @@ impl AgentPanel {
             let agent_server_store = agent_server_store;
 
             Rc::new(move |window, cx| {
-                telemetry::event!("New Thread Clicked");
+                use settings::{NewThreadLocation, Settings};
+                let thread_location = match AgentSettings::get_global(cx).new_thread_location {
+                    NewThreadLocation::LocalProject => "current_worktree",
+                    NewThreadLocation::NewWorktree => "new_worktree",
+                };
+                telemetry::event!(
+                    "New Thread Clicked",
+                    source = "agent_panel",
+                    thread_location = thread_location
+                );
 
                 let active_thread = active_thread.clone();
                 Some(ContextMenu::build(window, cx, |menu, _window, cx| {

crates/sidebar/src/sidebar.rs 🔗

@@ -30,7 +30,7 @@ use remote::RemoteConnectionOptions;
 use ui::utils::platform_title_bar_height;
 
 use serde::{Deserialize, Serialize};
-use settings::Settings as _;
+use settings::{NewThreadLocation, Settings as _};
 use std::collections::{HashMap, HashSet};
 use std::mem;
 use std::rc::Rc;
@@ -3171,6 +3171,16 @@ impl Sidebar {
             return;
         };
 
+        let thread_location = match AgentSettings::get_global(cx).new_thread_location {
+            NewThreadLocation::LocalProject => "current_worktree",
+            NewThreadLocation::NewWorktree => "new_worktree",
+        };
+        telemetry::event!(
+            "New Thread Clicked",
+            source = "sidebar",
+            thread_location = thread_location
+        );
+
         self.active_entry = Some(ActiveEntry::Draft(workspace.clone()));
 
         multi_workspace.update(cx, |multi_workspace, cx| {