From 436ebc8e62bda6c1ddea304e272bb4e802be3156 Mon Sep 17 00:00:00 2001 From: Katie Geer Date: Wed, 8 Apr 2026 12:12:34 -0700 Subject: [PATCH] Move source property onto Agent Thread Started, remove New Thread Clicked 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) --- crates/agent_ui/src/agent_panel.rs | 69 ++++++++++++++---------- crates/agent_ui/src/conversation_view.rs | 5 ++ 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 658f31766ba165d20814b2614321cf90653a0556..04d545c1ce964cad45a67018be38ea25eca7c488 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/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) { - 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) { - 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) { + fn do_new_thread(&mut self, source: &'static str, window: &mut Window, cx: &mut Context) { 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, initial_content: Option, focus: bool, + source: &'static str, window: &mut Window, cx: &mut Context, ) { @@ -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, agent: Agent, focus: bool, + source: &'static str, window: &mut Window, cx: &mut Context, ) { @@ -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, ); } diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs index 85e73685dca14feef5aea529a77befe2cc6eabd6..7d23bcdf44e6274d1869a953902d54b5ad0f7a49 100644 --- a/crates/agent_ui/src/conversation_view.rs +++ b/crates/agent_ui/src/conversation_view.rs @@ -522,6 +522,7 @@ impl ConversationView { project: Entity, thread_store: Option>, prompt_store: Option>, + source: &'static str, window: &mut Window, cx: &mut Context, ) -> 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, project: Entity, initial_content: Option, + source: &'static str, window: &mut Window, cx: &mut Context, ) -> ServerState { @@ -696,6 +700,7 @@ impl ConversationView { telemetry::event!( "Agent Thread Started", agent = connection.telemetry_id(), + source = source, side = side, thread_location = thread_location );