Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

sidebar: Track terminal agent thread telemetry (#56723)

Ben Brandtd4a3e0d5c9ad
diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs
index 6717695dd5d..cb2624d5311 100644
--- a/crates/agent_ui/src/agent_panel.rs
+++ b/crates/agent_ui/src/agent_panel.rs
@@ -45,7 +45,7 @@ use crate::{
ui::{AgentNotification, AgentNotificationEvent, EndTrialUpsell},
};
use crate::{
- Agent, AgentInitialContent, ExternalSourcePrompt, NewExternalAgentThread,
+ Agent, AgentInitialContent, AgentThreadSource, ExternalSourcePrompt, NewExternalAgentThread,
NewNativeAgentThreadFromSummary,
};
use agent_settings::AgentSettings;
@@ -92,6 +92,7 @@ use workspace::{
const AGENT_PANEL_KEY: &str = "agent_panel";
const MIN_PANEL_WIDTH: Pixels = px(300.);
const LAST_USED_AGENT_KEY: &str = "agent_panel__last_used_external_agent";
+const TERMINAL_AGENT_TELEMETRY_ID: &str = "terminal";
/// Maximum number of idle threads kept in the agent panel's retained list.
/// Set as a GPUI global to override; otherwise defaults to 5.
@@ -393,7 +394,7 @@ pub fn init(cx: &mut App) {
auto_submit: true,
}),
true,
- "git_panel",
+ AgentThreadSource::GitPanel,
window,
cx,
);
@@ -420,7 +421,7 @@ pub fn init(cx: &mut App) {
auto_submit: true,
}),
true,
- "git_panel",
+ AgentThreadSource::GitPanel,
window,
cx,
);
@@ -449,7 +450,7 @@ pub fn init(cx: &mut App) {
auto_submit: true,
}),
true,
- "git_panel",
+ AgentThreadSource::GitPanel,
window,
cx,
);
@@ -1023,7 +1024,7 @@ impl AgentPanel {
info.work_dirs.as_ref().map(PathList::deserialize),
info.title.clone().map(Into::into),
false,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -1255,7 +1256,7 @@ impl AgentPanel {
work_dirs,
title,
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -1266,7 +1267,7 @@ impl AgentPanel {
work_dirs,
title,
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -1280,12 +1281,12 @@ impl AgentPanel {
work_dirs: Option<PathList>,
title: Option<SharedString>,
focus: bool,
- _source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) {
let thread = self.create_agent_thread_with_server_for_external_session(
- agent, None, session_id, work_dirs, title, None, window, cx,
+ agent, None, session_id, work_dirs, title, None, source, window, cx,
);
self.set_base_view(thread.into(), focus, window, cx);
}
@@ -1316,7 +1317,7 @@ impl AgentPanel {
let old_view = std::mem::replace(&mut self.base_view, BaseView::Uninitialized);
self.retain_running_thread(old_view, cx);
self.clear_overlay_state();
- self.activate_draft(false, "agent_panel", window, cx);
+ self.activate_draft(false, AgentThreadSource::AgentPanel, window, cx);
self.serialize(cx);
cx.emit(AgentPanelEvent::ActiveViewChanged);
cx.notify();
@@ -1337,16 +1338,16 @@ impl AgentPanel {
cx: &mut Context<Self>,
) {
if self.should_create_terminal_for_new_entry(cx) {
- self.new_terminal(workspace, window, cx);
+ self.new_terminal(workspace, AgentThreadSource::AgentPanel, window, cx);
} else {
- self.activate_new_thread(true, "agent_panel", window, cx);
+ self.activate_new_thread(true, AgentThreadSource::AgentPanel, window, cx);
}
}
pub fn activate_new_thread(
&mut self,
focus: bool,
- trigger: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -1393,7 +1394,7 @@ impl AgentPanel {
self._draft_editor_observation = None;
}
}
- self.activate_draft(focus, trigger, window, cx);
+ self.activate_draft(focus, source, window, cx);
}
fn draft_has_content(&self, draft: &Entity<ConversationView>, cx: &App) -> bool {
@@ -1475,7 +1476,7 @@ impl AgentPanel {
Some(metadata.folder_paths().clone()),
metadata.title.clone(),
initial_content,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -1494,12 +1495,13 @@ impl AgentPanel {
}
self.selected_agent = action.agent.clone().into();
- self.activate_new_thread(true, "agent_panel", window, cx);
+ self.activate_new_thread(true, AgentThreadSource::AgentPanel, window, cx);
}
pub fn new_terminal(
&mut self,
workspace: Option<&Workspace>,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -1507,7 +1509,14 @@ impl AgentPanel {
return;
}
let working_directory = self.terminal_working_directory(workspace, cx);
- self.spawn_terminal(TerminalId::new(), working_directory, true, window, cx);
+ self.spawn_terminal(
+ TerminalId::new(),
+ working_directory,
+ true,
+ source,
+ window,
+ cx,
+ );
}
fn terminal_working_directory(
@@ -1545,6 +1554,7 @@ impl AgentPanel {
terminal_id: TerminalId,
working_directory: Option<PathBuf>,
focus: bool,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -1570,7 +1580,7 @@ impl AgentPanel {
let terminal_view = cx.new(|cx| {
TerminalView::new(terminal, workspace, workspace_id, project, window, cx)
});
- this.insert_terminal(terminal_id, terminal_view, focus, window, cx);
+ this.insert_terminal(terminal_id, terminal_view, focus, source, window, cx);
})?;
anyhow::Ok(())
})
@@ -1582,6 +1592,7 @@ impl AgentPanel {
terminal_id: TerminalId,
terminal_view: Entity<TerminalView>,
focus: bool,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -1632,6 +1643,7 @@ impl AgentPanel {
self.set_last_created_entry_kind(AgentPanelEntryKind::Terminal, cx);
terminal.refresh_title(cx);
self.terminals.insert(terminal_id, terminal);
+ self.emit_terminal_thread_started(source, cx);
if focus {
self.set_base_view(BaseView::Terminal { terminal_id }, true, window, cx);
}
@@ -1676,13 +1688,23 @@ impl AgentPanel {
if was_active {
self.base_view = BaseView::Uninitialized;
self.refresh_base_view_subscriptions(window, cx);
- self.activate_draft(false, "agent_panel", window, cx);
+ self.activate_draft(false, AgentThreadSource::AgentPanel, window, cx);
}
cx.emit(AgentPanelEvent::EntryChanged);
cx.notify();
}
+ fn emit_terminal_thread_started(&self, source: AgentThreadSource, cx: &App) {
+ telemetry::event!(
+ "Agent Thread Started",
+ agent = TERMINAL_AGENT_TELEMETRY_ID,
+ source = source.as_str(),
+ side = crate::agent_sidebar_side(cx),
+ thread_location = "current_worktree",
+ );
+ }
+
fn refresh_terminal_title(&mut self, terminal_id: TerminalId, cx: &mut Context<Self>) {
if let Some(terminal) = self.terminals.get_mut(&terminal_id)
&& terminal.refresh_title(cx)
@@ -2061,7 +2083,7 @@ impl AgentPanel {
pub fn activate_draft(
&mut self,
focus: bool,
- source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -2090,7 +2112,7 @@ impl AgentPanel {
fn ensure_draft(
&mut self,
- source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) -> Entity<ConversationView> {
@@ -2364,7 +2386,7 @@ impl AgentPanel {
if self.active_thread_id(cx) == Some(id) {
self.clear_overlay_state();
- self.activate_draft(false, "agent_panel", window, cx);
+ self.activate_draft(false, AgentThreadSource::AgentPanel, window, cx);
self.serialize(cx);
cx.emit(AgentPanelEvent::ActiveViewChanged);
cx.notify();
@@ -2455,7 +2477,7 @@ impl AgentPanel {
None,
Some(content),
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -2488,7 +2510,7 @@ impl AgentPanel {
title: Option<SharedString>,
initial_content: Option<AgentInitialContent>,
focus: bool,
- source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -2998,7 +3020,7 @@ impl AgentPanel {
});
}
- self.activate_new_thread(true, "agent_panel", window, cx);
+ self.activate_new_thread(true, AgentThreadSource::AgentPanel, window, cx);
if let Some((thread, model)) = self
.active_native_agent_thread(cx)
.zip(provider.default_model(cx))
@@ -3384,7 +3406,7 @@ impl AgentPanel {
None,
external_source_prompt.map(AgentInitialContent::from),
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -3397,7 +3419,7 @@ impl AgentPanel {
work_dirs: Option<PathList>,
title: Option<SharedString>,
focus: bool,
- source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -3479,7 +3501,7 @@ impl AgentPanel {
work_dirs: Option<PathList>,
title: Option<SharedString>,
initial_content: Option<AgentInitialContent>,
- source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) -> AgentThread {
@@ -3517,6 +3539,7 @@ impl AgentPanel {
work_dirs: Option<PathList>,
title: Option<SharedString>,
initial_content: Option<AgentInitialContent>,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) -> AgentThread {
@@ -3528,7 +3551,7 @@ impl AgentPanel {
work_dirs,
title,
initial_content,
- "agent_panel",
+ source,
window,
cx,
)
@@ -3543,7 +3566,7 @@ impl AgentPanel {
work_dirs: Option<PathList>,
title: Option<SharedString>,
initial_content: Option<AgentInitialContent>,
- source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) -> AgentThread {
@@ -3784,7 +3807,7 @@ impl Panel for AgentPanel {
impl AgentPanel {
fn ensure_thread_initialized(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if matches!(self.base_view, BaseView::Uninitialized) {
- self.activate_draft(false, "agent_panel", window, cx);
+ self.activate_draft(false, AgentThreadSource::AgentPanel, window, cx);
}
}
@@ -3896,7 +3919,7 @@ impl AgentPanel {
None,
None,
Some(initial_content),
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -4324,7 +4347,7 @@ impl AgentPanel {
panel.selected_agent = Agent::NativeAgent;
panel.activate_new_thread(
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -4352,6 +4375,7 @@ impl AgentPanel {
panel.update(cx, |panel, cx| {
panel.new_terminal(
Some(workspace),
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -5072,7 +5096,7 @@ impl AgentPanel {
None,
None,
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -5111,7 +5135,7 @@ impl AgentPanel {
None,
None,
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -5144,7 +5168,7 @@ impl AgentPanel {
None,
None,
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -5185,7 +5209,14 @@ impl AgentPanel {
terminal_view.update(cx, |terminal_view, cx| {
terminal_view.set_custom_title(Some(title.into()), cx);
});
- self.insert_terminal(terminal_id, terminal_view, focus, window, cx);
+ self.insert_terminal(
+ terminal_id,
+ terminal_view,
+ focus,
+ AgentThreadSource::AgentPanel,
+ window,
+ cx,
+ );
Ok(terminal_id)
}
@@ -6030,7 +6061,7 @@ mod tests {
)]);
panel.update_in(cx, |panel, window, cx| {
panel.selected_agent = Agent::Stub;
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
@@ -6220,7 +6251,7 @@ mod tests {
// 1. Create a real thread by sending a message.
panel.update_in(cx, |panel, window, cx| {
panel.selected_agent = Agent::Stub;
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
crate::test_support::send_message(&panel, cx);
@@ -6231,7 +6262,7 @@ mod tests {
// 2. Open a draft, type into it, then press Cmd-N again to
// park it into retained_threads as a *retained* draft.
panel.update_in(cx, |panel, window, cx| {
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
let retained_draft_id = crate::test_support::active_thread_id(&panel, cx);
@@ -6296,7 +6327,7 @@ mod tests {
None,
None,
false,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -6369,7 +6400,7 @@ mod tests {
None,
None,
false,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -6395,7 +6426,7 @@ mod tests {
None,
None,
false,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -6441,7 +6472,7 @@ mod tests {
crate::test_support::set_stub_agent_connection(StubAgentConnection::new());
panel.update_in(cx, |panel, window, cx| {
panel.selected_agent = Agent::Stub;
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
@@ -6536,7 +6567,7 @@ mod tests {
panel.update_in(cx, |panel, window, cx| {
panel.new_thread(&NewThread, window, cx);
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
panel.new_external_agent_thread(
&NewExternalAgentThread {
agent: AgentId::new("external-agent"),
@@ -6566,7 +6597,7 @@ mod tests {
cx.update_flags(true, vec!["agent-panel-terminal".to_string()]);
});
panel.update_in(cx, |panel, window, cx| {
- panel.new_terminal(None, window, cx);
+ panel.new_terminal(None, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
@@ -6639,7 +6670,7 @@ mod tests {
});
panel.update_in(&mut cx, |panel, window, cx| {
- panel.activate_new_thread(false, "test", window, cx);
+ panel.activate_new_thread(false, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
@@ -7075,7 +7106,7 @@ mod tests {
None,
None,
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -7124,7 +7155,7 @@ mod tests {
None,
None,
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -7878,7 +7909,7 @@ mod tests {
// Create a draft with the default NativeAgent.
panel.update_in(cx, |panel, window, cx| {
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
let first_draft_id = panel.read_with(cx, |panel, cx| {
@@ -7896,7 +7927,7 @@ mod tests {
};
panel.update_in(cx, |panel, window, cx| {
panel.selected_agent = custom_agent.clone();
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
panel.read_with(cx, |panel, cx| {
@@ -7920,7 +7951,7 @@ mod tests {
});
panel.update_in(cx, |panel, window, cx| {
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
panel.read_with(cx, |panel, _cx| {
@@ -7969,7 +8000,7 @@ mod tests {
// Create a draft using the Stub agent, which connects synchronously.
panel.update_in(cx, |panel, window, cx| {
panel.selected_agent = Agent::Stub;
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
@@ -8059,7 +8090,7 @@ mod tests {
// expect to refocus later.
panel.update_in(cx, |panel, window, cx| {
panel.selected_agent = Agent::Stub;
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
let parked_thread_id = crate::test_support::active_thread_id(&panel, cx);
@@ -8086,7 +8117,7 @@ mod tests {
None,
None,
true,
- "sidebar",
+ AgentThreadSource::Sidebar,
window,
cx,
);
@@ -8168,7 +8199,7 @@ mod tests {
// to park it — this also creates a fresh ephemeral draft (Stub).
panel.update_in(cx, |panel, window, cx| {
panel.selected_agent = Agent::Stub;
- panel.activate_draft(true, "agent_panel", window, cx);
+ panel.activate_draft(true, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
let parked_thread_id = crate::test_support::active_thread_id(&panel, cx);
@@ -8196,7 +8227,7 @@ mod tests {
None,
None,
true,
- "sidebar",
+ AgentThreadSource::Sidebar,
window,
cx,
);
@@ -8213,7 +8244,7 @@ mod tests {
// NativeAgent.
panel.update_in(cx, |panel, window, cx| {
panel.selected_agent = Agent::NativeAgent;
- panel.activate_new_thread(true, "agent_panel", window, cx);
+ panel.activate_new_thread(true, AgentThreadSource::AgentPanel, window, cx);
});
cx.run_until_parked();
@@ -8689,7 +8720,7 @@ mod tests {
None,
None,
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -9125,7 +9156,7 @@ mod tests {
None,
None,
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -9145,7 +9176,7 @@ mod tests {
None,
None,
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs
index 61fc7b0ae12..0a6bf7b97cb 100644
--- a/crates/agent_ui/src/agent_ui.rs
+++ b/crates/agent_ui/src/agent_ui.rs
@@ -58,7 +58,7 @@ use project::{AgentId, DisableAiSettings};
use prompt_store::PromptBuilder;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
-use settings::{LanguageModelSelection, Settings as _, SettingsStore};
+use settings::{LanguageModelSelection, Settings as _, SettingsStore, SidebarSide};
use std::any::TypeId;
use std::path::{Path, PathBuf};
use workspace::Workspace;
@@ -113,6 +113,31 @@ pub(crate) fn resolve_agent_image(
pub const DEFAULT_THREAD_TITLE: &str = "New Agent Thread";
const PARALLEL_AGENT_LAYOUT_BACKFILL_KEY: &str = "parallel_agent_layout_backfilled";
+
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub enum AgentThreadSource {
+ AgentPanel,
+ GitPanel,
+ Sidebar,
+}
+
+impl AgentThreadSource {
+ pub fn as_str(self) -> &'static str {
+ match self {
+ Self::AgentPanel => "agent_panel",
+ Self::GitPanel => "git_panel",
+ Self::Sidebar => "sidebar",
+ }
+ }
+}
+
+pub(crate) fn agent_sidebar_side(cx: &App) -> &'static str {
+ match AgentSettings::get_global(cx).sidebar_side() {
+ SidebarSide::Left => "left",
+ SidebarSide::Right => "right",
+ }
+}
+
actions!(
agent,
[
diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs
index 9383110e086..27225bfea88 100644
--- a/crates/agent_ui/src/conversation_view.rs
+++ b/crates/agent_ui/src/conversation_view.rs
@@ -45,11 +45,9 @@ use project::{AgentId, AgentServerStore, Project, ProjectEntryId};
use prompt_store::{PromptId, PromptStore};
use crate::message_editor::SessionCapabilities;
-use crate::{DEFAULT_THREAD_TITLE, resolve_agent_image};
+use crate::{AgentThreadSource, DEFAULT_THREAD_TITLE, resolve_agent_image};
use rope::Point;
-use settings::{
- NotifyWhenAgentWaiting, Settings as _, SettingsStore, SidebarSide, ThinkingBlockDisplay,
-};
+use settings::{NotifyWhenAgentWaiting, Settings as _, SettingsStore, ThinkingBlockDisplay};
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::Instant;
@@ -698,7 +696,7 @@ impl ConversationView {
project: Entity<Project>,
thread_store: Option<Entity<ThreadStore>>,
prompt_store: Option<Entity<PromptStore>>,
- source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
@@ -812,7 +810,7 @@ impl ConversationView {
title,
self.project.clone(),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -837,7 +835,7 @@ impl ConversationView {
title: Option<SharedString>,
project: Entity<Project>,
initial_content: Option<AgentInitialContent>,
- source: &'static str,
+ source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
) -> ServerState {
@@ -870,10 +868,7 @@ impl ConversationView {
let connect_result = connection_entry.read(cx).wait_for_connection();
- let side = match AgentSettings::get_global(cx).sidebar_side() {
- SidebarSide::Left => "left",
- SidebarSide::Right => "right",
- };
+ let side = crate::agent_sidebar_side(cx);
let thread_location = "current_worktree";
let load_task = cx.spawn_in(window, async move |this, cx| {
@@ -892,7 +887,7 @@ impl ConversationView {
telemetry::event!(
"Agent Thread Started",
agent = connection.telemetry_id(),
- source = source,
+ source = source.as_str(),
side = side,
thread_location = thread_location
);
@@ -2701,7 +2696,7 @@ impl ConversationView {
root_work_dirs.clone(),
root_title.clone(),
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
@@ -3332,7 +3327,7 @@ pub(crate) mod tests {
project,
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -3469,7 +3464,7 @@ pub(crate) mod tests {
project,
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -3551,7 +3546,7 @@ pub(crate) mod tests {
project,
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -3690,7 +3685,7 @@ pub(crate) mod tests {
project.clone(),
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -3991,7 +3986,7 @@ pub(crate) mod tests {
project.clone(),
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -4089,7 +4084,7 @@ pub(crate) mod tests {
project.clone(),
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -4158,7 +4153,7 @@ pub(crate) mod tests {
project.clone(),
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -4280,7 +4275,7 @@ pub(crate) mod tests {
project1.clone(),
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -4502,7 +4497,7 @@ pub(crate) mod tests {
project,
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -5152,7 +5147,7 @@ pub(crate) mod tests {
project.clone(),
Some(thread_store.clone()),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
@@ -7720,7 +7715,7 @@ pub(crate) mod tests {
project,
Some(thread_store),
None,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
)
diff --git a/crates/agent_ui/src/conversation_view/thread_view.rs b/crates/agent_ui/src/conversation_view/thread_view.rs
index c9ef4921542..045cdf07f17 100644
--- a/crates/agent_ui/src/conversation_view/thread_view.rs
+++ b/crates/agent_ui/src/conversation_view/thread_view.rs
@@ -18,7 +18,7 @@ use gpui::List;
use gpui::TaskExt;
use heapless::Vec as ArrayVec;
use language_model::{LanguageModelEffortLevel, Speed};
-use settings::{SidebarSide, update_settings_file};
+use settings::update_settings_file;
use ui::{ButtonLike, SpinnerLabel, SpinnerVariant, SplitButton, SplitButtonStyle, Tab};
use workspace::SERIALIZATION_THROTTLE_TIME;
@@ -1120,10 +1120,7 @@ impl ThreadView {
})
.detach();
- let side = match AgentSettings::get_global(cx).sidebar_side() {
- SidebarSide::Left => "left",
- SidebarSide::Right => "right",
- };
+ let side = crate::agent_sidebar_side(cx);
let task = cx.spawn_in(window, async move |this, cx| {
let Some((contents, tracked_buffers)) = contents_task.await? else {
diff --git a/crates/agent_ui/src/threads_archive_view.rs b/crates/agent_ui/src/threads_archive_view.rs
index ebd8c3d94f0..f751c9ca1d6 100644
--- a/crates/agent_ui/src/threads_archive_view.rs
+++ b/crates/agent_ui/src/threads_archive_view.rs
@@ -759,14 +759,10 @@ impl ThreadsArchiveView {
.on_click({
let thread = thread.clone();
cx.listener(move |this, _, window, cx| {
- let side = match AgentSettings::get_global(cx).sidebar_side() {
- settings::SidebarSide::Left => "left",
- settings::SidebarSide::Right => "right",
- };
telemetry::event!(
"Archived Thread Opened",
agent = thread.agent_id.as_ref(),
- side = side
+ side = crate::agent_sidebar_side(cx)
);
this.unarchive_thread(thread.clone(), window, cx);
})
diff --git a/crates/agent_ui/src/ui/mention_crease.rs b/crates/agent_ui/src/ui/mention_crease.rs
index 902196657e3..49b294f3a77 100644
--- a/crates/agent_ui/src/ui/mention_crease.rs
+++ b/crates/agent_ui/src/ui/mention_crease.rs
@@ -269,7 +269,7 @@ fn open_thread(
window: &mut Window,
cx: &mut Context<Workspace>,
) {
- use crate::{Agent, AgentPanel, thread_metadata_store::ThreadMetadataStore};
+ use crate::{Agent, AgentPanel, AgentThreadSource, thread_metadata_store::ThreadMetadataStore};
let Some(panel) = workspace.panel::<AgentPanel>(cx) else {
return;
@@ -286,7 +286,7 @@ fn open_thread(
None,
Some(name.into()),
true,
- "agent_panel",
+ AgentThreadSource::AgentPanel,
window,
cx,
);
diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs
index 13dc930debf..877b37c59e2 100644
--- a/crates/sidebar/src/sidebar.rs
+++ b/crates/sidebar/src/sidebar.rs
@@ -14,8 +14,8 @@ use agent_ui::threads_archive_view::{
};
use agent_ui::{
AcpThreadImportOnboarding, Agent, AgentPanel, AgentPanelEvent, AgentPanelTerminalInfo,
- ArchiveSelectedThread, CrossChannelImportOnboarding, DEFAULT_THREAD_TITLE, NewThread,
- TerminalId, ThreadId, ThreadImportModal, channels_with_threads,
+ AgentThreadSource, ArchiveSelectedThread, CrossChannelImportOnboarding, DEFAULT_THREAD_TITLE,
+ NewThread, TerminalId, ThreadId, ThreadImportModal, channels_with_threads,
import_threads_from_other_channels,
};
use chrono::{DateTime, Utc};
@@ -2684,7 +2684,7 @@ impl Sidebar {
Some(metadata.folder_paths().clone()),
metadata.title.clone(),
focus,
- "sidebar",
+ AgentThreadSource::Sidebar,
window,
cx,
);
@@ -4763,7 +4763,7 @@ impl Sidebar {
let draft_id = workspace.update(cx, |workspace, cx| {
let panel = workspace.panel::<AgentPanel>(cx)?;
let draft_id = panel.update(cx, |panel, cx| {
- panel.activate_new_thread(true, "sidebar", window, cx);
+ panel.activate_new_thread(true, AgentThreadSource::Sidebar, window, cx);
panel.active_thread_id(cx)
});
workspace.focus_panel::<AgentPanel>(window, cx);
@@ -4800,7 +4800,7 @@ impl Sidebar {
workspace.update(cx, |workspace, cx| {
if let Some(panel) = workspace.panel::<AgentPanel>(cx) {
panel.update(cx, |panel, cx| {
- panel.new_terminal(Some(workspace), window, cx);
+ panel.new_terminal(Some(workspace), AgentThreadSource::Sidebar, window, cx);
});
}
workspace.focus_panel::<AgentPanel>(window, cx);
diff --git a/crates/sidebar/src/sidebar_tests.rs b/crates/sidebar/src/sidebar_tests.rs
index 3421704e4b8..4817ab5ebc6 100644
--- a/crates/sidebar/src/sidebar_tests.rs
+++ b/crates/sidebar/src/sidebar_tests.rs
@@ -3856,7 +3856,7 @@ async fn test_all_ephemeral_drafts_in_group_are_hidden_from_sidebar(cx: &mut Tes
None,
None,
false,
- "agent_panel",
+ agent_ui::AgentThreadSource::AgentPanel,
window,
cx,
);