From 8df616e28bb34e8dab899747acae118788af4c1b Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 19 Sep 2025 15:55:32 -0700 Subject: [PATCH] Suppress the 'Agent Thread Started' event when initializing the panel (#38535) Release Notes: - N/A --- crates/agent_ui/src/agent_panel.rs | 9 ++++++++- crates/gpui/src/app.rs | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index ba71fd84ab5b9d666256afeb0a2c5677aac9adb1..ca6a5fb2f6c216e7886394da069c93e5029a5ed0 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -408,6 +408,7 @@ impl ActiveView { pub struct AgentPanel { workspace: WeakEntity, + loading: bool, user_store: Entity, project: Entity, fs: Arc, @@ -513,6 +514,7 @@ impl AgentPanel { cx, ) }); + panel.as_mut(cx).loading = true; if let Some(serialized_panel) = serialized_panel { panel.update(cx, |panel, cx| { panel.width = serialized_panel.width.map(|w| w.round()); @@ -527,6 +529,7 @@ impl AgentPanel { panel.new_agent_thread(AgentType::NativeAgent, window, cx); }); } + panel.as_mut(cx).loading = false; panel })?; @@ -726,6 +729,7 @@ impl AgentPanel { acp_history, acp_history_store, selected_agent: AgentType::default(), + loading: false, } } @@ -857,6 +861,7 @@ impl AgentPanel { agent: crate::ExternalAgent, } + let loading = self.loading; let history = self.acp_history_store.clone(); cx.spawn_in(window, async move |this, cx| { @@ -898,7 +903,9 @@ impl AgentPanel { } }; - telemetry::event!("Agent Thread Started", agent = ext_agent.name()); + if !loading { + telemetry::event!("Agent Thread Started", agent = ext_agent.name()); + } let server = ext_agent.server(fs, history); diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index e6c3e3b8deea9b82514b5ac932c4f204fa081e14..07ff04e32abc19dbe681ab6214d06469fe7917ff 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -2401,6 +2401,20 @@ impl<'a, T: 'static> std::borrow::BorrowMut for GpuiBorrow<'a, T> { } } +impl<'a, T: 'static> std::ops::Deref for GpuiBorrow<'a, T> { + type Target = T; + + fn deref(&self) -> &Self::Target { + self.inner.as_ref().unwrap() + } +} + +impl<'a, T: 'static> std::ops::DerefMut for GpuiBorrow<'a, T> { + fn deref_mut(&mut self) -> &mut T { + self.inner.as_mut().unwrap() + } +} + impl<'a, T> Drop for GpuiBorrow<'a, T> { fn drop(&mut self) { let lease = self.inner.take().unwrap();