diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 687a9d0fea7d0f063398b9f05a50a192e8e23168..085e0d893d95fb441e919d4fb1f3683901c3c422 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -1304,29 +1304,19 @@ impl AgentPanel { } pub fn new_thread(&mut self, _action: &NewThread, window: &mut Window, cx: &mut Context) { - 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 + thread_location = thread_location_str(cx) ); self.do_new_thread(window, cx); } pub fn new_thread_from_sidebar(&mut self, window: &mut Window, cx: &mut Context) { - 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 = "sidebar", - thread_location = thread_location + thread_location = thread_location_str(cx) ); self.do_new_thread(window, cx); } @@ -3344,6 +3334,14 @@ fn agent_panel_dock_position(cx: &App) -> DockPosition { AgentSettings::get_global(cx).dock.into() } +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, @@ -3374,7 +3372,7 @@ impl Panel for AgentPanel { fn set_position(&mut self, position: DockPosition, _: &mut Window, cx: &mut Context) { let side = match position { DockPosition::Left => "left", - _ => "right", + DockPosition::Right | DockPosition::Bottom => "right", }; telemetry::event!("Agent Panel Side Changed", side = side); settings::update_settings_file(self.fs.clone(), cx, move |settings, _| { @@ -3805,15 +3803,10 @@ impl AgentPanel { let agent_server_store = agent_server_store; Rc::new(move |window, cx| { - 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 + thread_location = thread_location_str(cx) ); let active_thread = active_thread.clone(); diff --git a/crates/workspace/src/multi_workspace.rs b/crates/workspace/src/multi_workspace.rs index 596a3d2ac936411a53507062a75bbbbc8679cdb6..5f1f47a4042bae4d8fbd72f04934777bee9c509c 100644 --- a/crates/workspace/src/multi_workspace.rs +++ b/crates/workspace/src/multi_workspace.rs @@ -473,6 +473,16 @@ impl MultiWorkspace { SidebarSide::Right => "right", }; telemetry::event!("Sidebar Toggled", action = "open", side = side); + self.apply_open_sidebar(cx); + } + + /// Restores the sidebar to open state from persisted session data without + /// firing a telemetry event, since this is not a user-initiated action. + pub(crate) fn restore_open_sidebar(&mut self, cx: &mut Context) { + self.apply_open_sidebar(cx); + } + + fn apply_open_sidebar(&mut self, cx: &mut Context) { self.sidebar_open = true; if let ActiveWorkspace::Transient(workspace) = &self.active_workspace { let workspace = workspace.clone(); diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index e6244f63b8b45e39b61b2a1c3f4cf2ff27c8609a..0075de7656a7a3a09559ccd69863521c390f4d6c 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -8808,7 +8808,7 @@ pub async fn restore_multiworkspace( if sidebar_open { window_handle .update(cx, |multi_workspace, _, cx| { - multi_workspace.open_sidebar(cx); + multi_workspace.restore_open_sidebar(cx); }) .ok(); }