acp: Add telemetry (#36894)
Release Notes: - N/A --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
c786c0150f
commit
59af2a7d1f
10 changed files with 93 additions and 22 deletions
|
@ -22,6 +22,10 @@ impl NativeAgentServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AgentServer for NativeAgentServer {
|
impl AgentServer for NativeAgentServer {
|
||||||
|
fn telemetry_id(&self) -> &'static str {
|
||||||
|
"zed"
|
||||||
|
}
|
||||||
|
|
||||||
fn name(&self) -> SharedString {
|
fn name(&self) -> SharedString {
|
||||||
"Zed Agent".into()
|
"Zed Agent".into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1685,6 +1685,7 @@ async fn test_truncate_second_message(cx: &mut TestAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
#[cfg_attr(target_os = "windows", ignore)] // TODO: Fix this test on Windows
|
||||||
async fn test_title_generation(cx: &mut TestAppContext) {
|
async fn test_title_generation(cx: &mut TestAppContext) {
|
||||||
let ThreadTest { model, thread, .. } = setup(cx, TestModel::Fake).await;
|
let ThreadTest { model, thread, .. } = setup(cx, TestModel::Fake).await;
|
||||||
let fake_model = model.as_fake();
|
let fake_model = model.as_fake();
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub trait AgentServer: Send {
|
||||||
fn name(&self) -> SharedString;
|
fn name(&self) -> SharedString;
|
||||||
fn empty_state_headline(&self) -> SharedString;
|
fn empty_state_headline(&self) -> SharedString;
|
||||||
fn empty_state_message(&self) -> SharedString;
|
fn empty_state_message(&self) -> SharedString;
|
||||||
|
fn telemetry_id(&self) -> &'static str;
|
||||||
|
|
||||||
fn connect(
|
fn connect(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -43,6 +43,10 @@ use acp_thread::{AcpThread, AgentConnection, AuthRequired, LoadError, MentionUri
|
||||||
pub struct ClaudeCode;
|
pub struct ClaudeCode;
|
||||||
|
|
||||||
impl AgentServer for ClaudeCode {
|
impl AgentServer for ClaudeCode {
|
||||||
|
fn telemetry_id(&self) -> &'static str {
|
||||||
|
"claude-code"
|
||||||
|
}
|
||||||
|
|
||||||
fn name(&self) -> SharedString {
|
fn name(&self) -> SharedString {
|
||||||
"Claude Code".into()
|
"Claude Code".into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ impl CustomAgentServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::AgentServer for CustomAgentServer {
|
impl crate::AgentServer for CustomAgentServer {
|
||||||
|
fn telemetry_id(&self) -> &'static str {
|
||||||
|
"custom"
|
||||||
|
}
|
||||||
|
|
||||||
fn name(&self) -> SharedString {
|
fn name(&self) -> SharedString {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,10 @@ pub struct Gemini;
|
||||||
const ACP_ARG: &str = "--experimental-acp";
|
const ACP_ARG: &str = "--experimental-acp";
|
||||||
|
|
||||||
impl AgentServer for Gemini {
|
impl AgentServer for Gemini {
|
||||||
|
fn telemetry_id(&self) -> &'static str {
|
||||||
|
"gemini-cli"
|
||||||
|
}
|
||||||
|
|
||||||
fn name(&self) -> SharedString {
|
fn name(&self) -> SharedString {
|
||||||
"Gemini CLI".into()
|
"Gemini CLI".into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -892,6 +892,8 @@ impl AcpThreadView {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
|
let agent_telemetry_id = self.agent.telemetry_id();
|
||||||
|
|
||||||
self.thread_error.take();
|
self.thread_error.take();
|
||||||
self.editing_message.take();
|
self.editing_message.take();
|
||||||
self.thread_feedback.clear();
|
self.thread_feedback.clear();
|
||||||
|
@ -936,6 +938,9 @@ impl AcpThreadView {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
drop(guard);
|
drop(guard);
|
||||||
|
|
||||||
|
telemetry::event!("Agent Message Sent", agent = agent_telemetry_id);
|
||||||
|
|
||||||
thread.send(contents, cx)
|
thread.send(contents, cx)
|
||||||
})?;
|
})?;
|
||||||
send.await
|
send.await
|
||||||
|
@ -1246,30 +1251,44 @@ impl AcpThreadView {
|
||||||
pending_auth_method.replace(method.clone());
|
pending_auth_method.replace(method.clone());
|
||||||
let authenticate = connection.authenticate(method, cx);
|
let authenticate = connection.authenticate(method, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
self.auth_task = Some(cx.spawn_in(window, {
|
self.auth_task =
|
||||||
let project = self.project.clone();
|
Some(cx.spawn_in(window, {
|
||||||
let agent = self.agent.clone();
|
let project = self.project.clone();
|
||||||
async move |this, cx| {
|
let agent = self.agent.clone();
|
||||||
let result = authenticate.await;
|
async move |this, cx| {
|
||||||
|
let result = authenticate.await;
|
||||||
|
|
||||||
this.update_in(cx, |this, window, cx| {
|
match &result {
|
||||||
if let Err(err) = result {
|
Ok(_) => telemetry::event!(
|
||||||
this.handle_thread_error(err, cx);
|
"Authenticate Agent Succeeded",
|
||||||
} else {
|
agent = agent.telemetry_id()
|
||||||
this.thread_state = Self::initial_state(
|
),
|
||||||
agent,
|
Err(_) => {
|
||||||
None,
|
telemetry::event!(
|
||||||
this.workspace.clone(),
|
"Authenticate Agent Failed",
|
||||||
project.clone(),
|
agent = agent.telemetry_id(),
|
||||||
window,
|
)
|
||||||
cx,
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.auth_task.take()
|
|
||||||
})
|
this.update_in(cx, |this, window, cx| {
|
||||||
.ok();
|
if let Err(err) = result {
|
||||||
}
|
this.handle_thread_error(err, cx);
|
||||||
}));
|
} else {
|
||||||
|
this.thread_state = Self::initial_state(
|
||||||
|
agent,
|
||||||
|
None,
|
||||||
|
this.workspace.clone(),
|
||||||
|
project.clone(),
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
this.auth_task.take()
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn authorize_tool_call(
|
fn authorize_tool_call(
|
||||||
|
@ -2776,6 +2795,12 @@ impl AcpThreadView {
|
||||||
.on_click({
|
.on_click({
|
||||||
let method_id = method.id.clone();
|
let method_id = method.id.clone();
|
||||||
cx.listener(move |this, _, window, cx| {
|
cx.listener(move |this, _, window, cx| {
|
||||||
|
telemetry::event!(
|
||||||
|
"Authenticate Agent Started",
|
||||||
|
agent = this.agent.telemetry_id(),
|
||||||
|
method = method_id
|
||||||
|
);
|
||||||
|
|
||||||
this.authenticate(method_id.clone(), window, cx)
|
this.authenticate(method_id.clone(), window, cx)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2804,6 +2829,8 @@ impl AcpThreadView {
|
||||||
.icon_color(Color::Muted)
|
.icon_color(Color::Muted)
|
||||||
.icon_position(IconPosition::Start)
|
.icon_position(IconPosition::Start)
|
||||||
.on_click(cx.listener(move |this, _, window, cx| {
|
.on_click(cx.listener(move |this, _, window, cx| {
|
||||||
|
telemetry::event!("Agent Install CLI", agent = this.agent.telemetry_id());
|
||||||
|
|
||||||
let task = this
|
let task = this
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, cx| {
|
.update(cx, |workspace, cx| {
|
||||||
|
@ -2861,6 +2888,8 @@ impl AcpThreadView {
|
||||||
.icon_color(Color::Muted)
|
.icon_color(Color::Muted)
|
||||||
.icon_position(IconPosition::Start)
|
.icon_position(IconPosition::Start)
|
||||||
.on_click(cx.listener(move |this, _, window, cx| {
|
.on_click(cx.listener(move |this, _, window, cx| {
|
||||||
|
telemetry::event!("Agent Upgrade CLI", agent = this.agent.telemetry_id());
|
||||||
|
|
||||||
let task = this
|
let task = this
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, cx| {
|
.update(cx, |workspace, cx| {
|
||||||
|
@ -3708,6 +3737,8 @@ impl AcpThreadView {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
|
telemetry::event!("Follow Agent Selected", following = !following);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_follow_toggle(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render_follow_toggle(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
|
@ -5323,6 +5354,10 @@ pub(crate) mod tests {
|
||||||
where
|
where
|
||||||
C: 'static + AgentConnection + Send + Clone,
|
C: 'static + AgentConnection + Send + Clone,
|
||||||
{
|
{
|
||||||
|
fn telemetry_id(&self) -> &'static str {
|
||||||
|
"test"
|
||||||
|
}
|
||||||
|
|
||||||
fn logo(&self) -> ui::IconName {
|
fn logo(&self) -> ui::IconName {
|
||||||
ui::IconName::Ai
|
ui::IconName::Ai
|
||||||
}
|
}
|
||||||
|
|
|
@ -1026,6 +1026,8 @@ impl AgentPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_prompt_editor(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn new_prompt_editor(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
|
telemetry::event!("Agent Thread Started", agent = "zed-text");
|
||||||
|
|
||||||
let context = self
|
let context = self
|
||||||
.context_store
|
.context_store
|
||||||
.update(cx, |context_store, cx| context_store.create(cx));
|
.update(cx, |context_store, cx| context_store.create(cx));
|
||||||
|
@ -1118,6 +1120,8 @@ impl AgentPanel {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
telemetry::event!("Agent Thread Started", agent = ext_agent.name());
|
||||||
|
|
||||||
let server = ext_agent.server(fs, history);
|
let server = ext_agent.server(fs, history);
|
||||||
|
|
||||||
this.update_in(cx, |this, window, cx| {
|
this.update_in(cx, |this, window, cx| {
|
||||||
|
@ -2327,6 +2331,8 @@ impl AgentPanel {
|
||||||
.menu({
|
.menu({
|
||||||
let menu = self.assistant_navigation_menu.clone();
|
let menu = self.assistant_navigation_menu.clone();
|
||||||
move |window, cx| {
|
move |window, cx| {
|
||||||
|
telemetry::event!("View Thread History Clicked");
|
||||||
|
|
||||||
if let Some(menu) = menu.as_ref() {
|
if let Some(menu) = menu.as_ref() {
|
||||||
menu.update(cx, |_, cx| {
|
menu.update(cx, |_, cx| {
|
||||||
cx.defer_in(window, |menu, window, cx| {
|
cx.defer_in(window, |menu, window, cx| {
|
||||||
|
@ -2505,6 +2511,8 @@ impl AgentPanel {
|
||||||
let workspace = self.workspace.clone();
|
let workspace = self.workspace.clone();
|
||||||
|
|
||||||
move |window, cx| {
|
move |window, cx| {
|
||||||
|
telemetry::event!("New Thread Clicked");
|
||||||
|
|
||||||
let active_thread = active_thread.clone();
|
let active_thread = active_thread.clone();
|
||||||
Some(ContextMenu::build(window, cx, |mut menu, _window, cx| {
|
Some(ContextMenu::build(window, cx, |mut menu, _window, cx| {
|
||||||
menu = menu
|
menu = menu
|
||||||
|
|
|
@ -175,6 +175,15 @@ enum ExternalAgent {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExternalAgent {
|
impl ExternalAgent {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::NativeAgent => "zed",
|
||||||
|
Self::Gemini => "gemini-cli",
|
||||||
|
Self::ClaudeCode => "claude-code",
|
||||||
|
Self::Custom { .. } => "custom",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn server(
|
pub fn server(
|
||||||
&self,
|
&self,
|
||||||
fs: Arc<dyn fs::Fs>,
|
fs: Arc<dyn fs::Fs>,
|
||||||
|
|
|
@ -361,6 +361,7 @@ impl TextThreadEditor {
|
||||||
if self.sending_disabled(cx) {
|
if self.sending_disabled(cx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
telemetry::event!("Agent Message Sent", agent = "zed-text");
|
||||||
self.send_to_model(window, cx);
|
self.send_to_model(window, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue