acp: Better telemetry IDs for ACP agents (#44544)
We were defining these in multiple places and also weren't leveraging the ids the agents were already providing. This should make sure we use them consistently and avoid issues in the future. Release Notes: - N/A
This commit is contained in:
@@ -1372,7 +1372,7 @@ impl AcpThread {
|
|||||||
let path_style = self.project.read(cx).path_style(cx);
|
let path_style = self.project.read(cx).path_style(cx);
|
||||||
let id = update.tool_call_id.clone();
|
let id = update.tool_call_id.clone();
|
||||||
|
|
||||||
let agent = self.connection().telemetry_id();
|
let agent_telemetry_id = self.connection().telemetry_id();
|
||||||
let session = self.session_id();
|
let session = self.session_id();
|
||||||
if let ToolCallStatus::Completed | ToolCallStatus::Failed = status {
|
if let ToolCallStatus::Completed | ToolCallStatus::Failed = status {
|
||||||
let status = if matches!(status, ToolCallStatus::Completed) {
|
let status = if matches!(status, ToolCallStatus::Completed) {
|
||||||
@@ -1380,7 +1380,12 @@ impl AcpThread {
|
|||||||
} else {
|
} else {
|
||||||
"failed"
|
"failed"
|
||||||
};
|
};
|
||||||
telemetry::event!("Agent Tool Call Completed", agent, session, status);
|
telemetry::event!(
|
||||||
|
"Agent Tool Call Completed",
|
||||||
|
agent_telemetry_id,
|
||||||
|
session,
|
||||||
|
status
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ix) = self.index_for_tool_call(&id) {
|
if let Some(ix) = self.index_for_tool_call(&id) {
|
||||||
@@ -3556,8 +3561,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AgentConnection for FakeAgentConnection {
|
impl AgentConnection for FakeAgentConnection {
|
||||||
fn telemetry_id(&self) -> &'static str {
|
fn telemetry_id(&self) -> SharedString {
|
||||||
"fake"
|
"fake".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn auth_methods(&self) -> &[acp::AuthMethod] {
|
fn auth_methods(&self) -> &[acp::AuthMethod] {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ impl UserMessageId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait AgentConnection {
|
pub trait AgentConnection {
|
||||||
fn telemetry_id(&self) -> &'static str;
|
fn telemetry_id(&self) -> SharedString;
|
||||||
|
|
||||||
fn new_thread(
|
fn new_thread(
|
||||||
self: Rc<Self>,
|
self: Rc<Self>,
|
||||||
@@ -322,8 +322,8 @@ mod test_support {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AgentConnection for StubAgentConnection {
|
impl AgentConnection for StubAgentConnection {
|
||||||
fn telemetry_id(&self) -> &'static str {
|
fn telemetry_id(&self) -> SharedString {
|
||||||
"stub"
|
"stub".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn auth_methods(&self) -> &[acp::AuthMethod] {
|
fn auth_methods(&self) -> &[acp::AuthMethod] {
|
||||||
|
|||||||
@@ -777,7 +777,7 @@ impl ActionLog {
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ActionLogTelemetry {
|
pub struct ActionLogTelemetry {
|
||||||
pub agent_telemetry_id: &'static str,
|
pub agent_telemetry_id: SharedString,
|
||||||
pub session_id: Arc<str>,
|
pub session_id: Arc<str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -947,8 +947,8 @@ impl acp_thread::AgentModelSelector for NativeAgentModelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl acp_thread::AgentConnection for NativeAgentConnection {
|
impl acp_thread::AgentConnection for NativeAgentConnection {
|
||||||
fn telemetry_id(&self) -> &'static str {
|
fn telemetry_id(&self) -> SharedString {
|
||||||
"zed"
|
"zed".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_thread(
|
fn new_thread(
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ 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()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub struct UnsupportedVersion;
|
|||||||
|
|
||||||
pub struct AcpConnection {
|
pub struct AcpConnection {
|
||||||
server_name: SharedString,
|
server_name: SharedString,
|
||||||
telemetry_id: &'static str,
|
telemetry_id: SharedString,
|
||||||
connection: Rc<acp::ClientSideConnection>,
|
connection: Rc<acp::ClientSideConnection>,
|
||||||
sessions: Rc<RefCell<HashMap<acp::SessionId, AcpSession>>>,
|
sessions: Rc<RefCell<HashMap<acp::SessionId, AcpSession>>>,
|
||||||
auth_methods: Vec<acp::AuthMethod>,
|
auth_methods: Vec<acp::AuthMethod>,
|
||||||
@@ -54,7 +54,6 @@ pub struct AcpSession {
|
|||||||
|
|
||||||
pub async fn connect(
|
pub async fn connect(
|
||||||
server_name: SharedString,
|
server_name: SharedString,
|
||||||
telemetry_id: &'static str,
|
|
||||||
command: AgentServerCommand,
|
command: AgentServerCommand,
|
||||||
root_dir: &Path,
|
root_dir: &Path,
|
||||||
default_mode: Option<acp::SessionModeId>,
|
default_mode: Option<acp::SessionModeId>,
|
||||||
@@ -64,7 +63,6 @@ pub async fn connect(
|
|||||||
) -> Result<Rc<dyn AgentConnection>> {
|
) -> Result<Rc<dyn AgentConnection>> {
|
||||||
let conn = AcpConnection::stdio(
|
let conn = AcpConnection::stdio(
|
||||||
server_name,
|
server_name,
|
||||||
telemetry_id,
|
|
||||||
command.clone(),
|
command.clone(),
|
||||||
root_dir,
|
root_dir,
|
||||||
default_mode,
|
default_mode,
|
||||||
@@ -81,7 +79,6 @@ const MINIMUM_SUPPORTED_VERSION: acp::ProtocolVersion = acp::ProtocolVersion::V1
|
|||||||
impl AcpConnection {
|
impl AcpConnection {
|
||||||
pub async fn stdio(
|
pub async fn stdio(
|
||||||
server_name: SharedString,
|
server_name: SharedString,
|
||||||
telemetry_id: &'static str,
|
|
||||||
command: AgentServerCommand,
|
command: AgentServerCommand,
|
||||||
root_dir: &Path,
|
root_dir: &Path,
|
||||||
default_mode: Option<acp::SessionModeId>,
|
default_mode: Option<acp::SessionModeId>,
|
||||||
@@ -199,6 +196,13 @@ impl AcpConnection {
|
|||||||
return Err(UnsupportedVersion.into());
|
return Err(UnsupportedVersion.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let telemetry_id = response
|
||||||
|
.agent_info
|
||||||
|
// Use the one the agent provides if we have one
|
||||||
|
.map(|info| info.name.into())
|
||||||
|
// Otherwise, just use the name
|
||||||
|
.unwrap_or_else(|| server_name.clone());
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
auth_methods: response.auth_methods,
|
auth_methods: response.auth_methods,
|
||||||
root_dir: root_dir.to_owned(),
|
root_dir: root_dir.to_owned(),
|
||||||
@@ -233,8 +237,8 @@ impl Drop for AcpConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AgentConnection for AcpConnection {
|
impl AgentConnection for AcpConnection {
|
||||||
fn telemetry_id(&self) -> &'static str {
|
fn telemetry_id(&self) -> SharedString {
|
||||||
self.telemetry_id
|
self.telemetry_id.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_thread(
|
fn new_thread(
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ impl AgentServerDelegate {
|
|||||||
pub trait AgentServer: Send {
|
pub trait AgentServer: Send {
|
||||||
fn logo(&self) -> ui::IconName;
|
fn logo(&self) -> ui::IconName;
|
||||||
fn name(&self) -> SharedString;
|
fn name(&self) -> SharedString;
|
||||||
fn telemetry_id(&self) -> &'static str;
|
|
||||||
fn default_mode(&self, _cx: &mut App) -> Option<agent_client_protocol::SessionModeId> {
|
fn default_mode(&self, _cx: &mut App) -> Option<agent_client_protocol::SessionModeId> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ pub struct AgentServerLoginCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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()
|
||||||
}
|
}
|
||||||
@@ -83,7 +79,6 @@ impl AgentServer for ClaudeCode {
|
|||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<Result<(Rc<dyn AgentConnection>, Option<task::SpawnInTerminal>)>> {
|
) -> Task<Result<(Rc<dyn AgentConnection>, Option<task::SpawnInTerminal>)>> {
|
||||||
let name = self.name();
|
let name = self.name();
|
||||||
let telemetry_id = self.telemetry_id();
|
|
||||||
let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().into_owned());
|
let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().into_owned());
|
||||||
let is_remote = delegate.project.read(cx).is_via_remote_server();
|
let is_remote = delegate.project.read(cx).is_via_remote_server();
|
||||||
let store = delegate.store.downgrade();
|
let store = delegate.store.downgrade();
|
||||||
@@ -108,7 +103,6 @@ impl AgentServer for ClaudeCode {
|
|||||||
.await?;
|
.await?;
|
||||||
let connection = crate::acp::connect(
|
let connection = crate::acp::connect(
|
||||||
name,
|
name,
|
||||||
telemetry_id,
|
|
||||||
command,
|
command,
|
||||||
root_dir.as_ref(),
|
root_dir.as_ref(),
|
||||||
default_mode,
|
default_mode,
|
||||||
|
|||||||
@@ -23,10 +23,6 @@ pub(crate) mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AgentServer for Codex {
|
impl AgentServer for Codex {
|
||||||
fn telemetry_id(&self) -> &'static str {
|
|
||||||
"codex"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> SharedString {
|
fn name(&self) -> SharedString {
|
||||||
"Codex".into()
|
"Codex".into()
|
||||||
}
|
}
|
||||||
@@ -84,7 +80,6 @@ impl AgentServer for Codex {
|
|||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<Result<(Rc<dyn AgentConnection>, Option<task::SpawnInTerminal>)>> {
|
) -> Task<Result<(Rc<dyn AgentConnection>, Option<task::SpawnInTerminal>)>> {
|
||||||
let name = self.name();
|
let name = self.name();
|
||||||
let telemetry_id = self.telemetry_id();
|
|
||||||
let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().into_owned());
|
let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().into_owned());
|
||||||
let is_remote = delegate.project.read(cx).is_via_remote_server();
|
let is_remote = delegate.project.read(cx).is_via_remote_server();
|
||||||
let store = delegate.store.downgrade();
|
let store = delegate.store.downgrade();
|
||||||
@@ -110,7 +105,6 @@ impl AgentServer for Codex {
|
|||||||
|
|
||||||
let connection = crate::acp::connect(
|
let connection = crate::acp::connect(
|
||||||
name,
|
name,
|
||||||
telemetry_id,
|
|
||||||
command,
|
command,
|
||||||
root_dir.as_ref(),
|
root_dir.as_ref(),
|
||||||
default_mode,
|
default_mode,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{AgentServerDelegate, load_proxy_env};
|
use crate::{AgentServer, AgentServerDelegate, load_proxy_env};
|
||||||
use acp_thread::AgentConnection;
|
use acp_thread::AgentConnection;
|
||||||
use agent_client_protocol as acp;
|
use agent_client_protocol as acp;
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
@@ -20,11 +20,7 @@ impl CustomAgentServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::AgentServer for CustomAgentServer {
|
impl AgentServer for CustomAgentServer {
|
||||||
fn telemetry_id(&self) -> &'static str {
|
|
||||||
"custom"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> SharedString {
|
fn name(&self) -> SharedString {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
@@ -112,7 +108,6 @@ impl crate::AgentServer for CustomAgentServer {
|
|||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<Result<(Rc<dyn AgentConnection>, Option<task::SpawnInTerminal>)>> {
|
) -> Task<Result<(Rc<dyn AgentConnection>, Option<task::SpawnInTerminal>)>> {
|
||||||
let name = self.name();
|
let name = self.name();
|
||||||
let telemetry_id = self.telemetry_id();
|
|
||||||
let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().into_owned());
|
let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().into_owned());
|
||||||
let is_remote = delegate.project.read(cx).is_via_remote_server();
|
let is_remote = delegate.project.read(cx).is_via_remote_server();
|
||||||
let default_mode = self.default_mode(cx);
|
let default_mode = self.default_mode(cx);
|
||||||
@@ -139,7 +134,6 @@ impl crate::AgentServer for CustomAgentServer {
|
|||||||
.await?;
|
.await?;
|
||||||
let connection = crate::acp::connect(
|
let connection = crate::acp::connect(
|
||||||
name,
|
name,
|
||||||
telemetry_id,
|
|
||||||
command,
|
command,
|
||||||
root_dir.as_ref(),
|
root_dir.as_ref(),
|
||||||
default_mode,
|
default_mode,
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ use project::agent_server_store::GEMINI_NAME;
|
|||||||
pub struct Gemini;
|
pub struct Gemini;
|
||||||
|
|
||||||
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()
|
||||||
}
|
}
|
||||||
@@ -31,7 +27,6 @@ impl AgentServer for Gemini {
|
|||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Task<Result<(Rc<dyn AgentConnection>, Option<task::SpawnInTerminal>)>> {
|
) -> Task<Result<(Rc<dyn AgentConnection>, Option<task::SpawnInTerminal>)>> {
|
||||||
let name = self.name();
|
let name = self.name();
|
||||||
let telemetry_id = self.telemetry_id();
|
|
||||||
let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().into_owned());
|
let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().into_owned());
|
||||||
let is_remote = delegate.project.read(cx).is_via_remote_server();
|
let is_remote = delegate.project.read(cx).is_via_remote_server();
|
||||||
let store = delegate.store.downgrade();
|
let store = delegate.store.downgrade();
|
||||||
@@ -66,7 +61,6 @@ impl AgentServer for Gemini {
|
|||||||
|
|
||||||
let connection = crate::acp::connect(
|
let connection = crate::acp::connect(
|
||||||
name,
|
name,
|
||||||
telemetry_id,
|
|
||||||
command,
|
command,
|
||||||
root_dir.as_ref(),
|
root_dir.as_ref(),
|
||||||
default_mode,
|
default_mode,
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ impl ThreadFeedbackState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let session_id = thread.read(cx).session_id().clone();
|
let session_id = thread.read(cx).session_id().clone();
|
||||||
let agent = thread.read(cx).connection().telemetry_id();
|
let agent_telemetry_id = thread.read(cx).connection().telemetry_id();
|
||||||
let task = telemetry.thread_data(&session_id, cx);
|
let task = telemetry.thread_data(&session_id, cx);
|
||||||
let rating = match feedback {
|
let rating = match feedback {
|
||||||
ThreadFeedback::Positive => "positive",
|
ThreadFeedback::Positive => "positive",
|
||||||
@@ -180,7 +180,7 @@ impl ThreadFeedbackState {
|
|||||||
let thread = task.await?;
|
let thread = task.await?;
|
||||||
telemetry::event!(
|
telemetry::event!(
|
||||||
"Agent Thread Rated",
|
"Agent Thread Rated",
|
||||||
agent = agent,
|
agent = agent_telemetry_id,
|
||||||
session_id = session_id,
|
session_id = session_id,
|
||||||
rating = rating,
|
rating = rating,
|
||||||
thread = thread
|
thread = thread
|
||||||
@@ -207,13 +207,13 @@ impl ThreadFeedbackState {
|
|||||||
self.comments_editor.take();
|
self.comments_editor.take();
|
||||||
|
|
||||||
let session_id = thread.read(cx).session_id().clone();
|
let session_id = thread.read(cx).session_id().clone();
|
||||||
let agent = thread.read(cx).connection().telemetry_id();
|
let agent_telemetry_id = thread.read(cx).connection().telemetry_id();
|
||||||
let task = telemetry.thread_data(&session_id, cx);
|
let task = telemetry.thread_data(&session_id, cx);
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let thread = task.await?;
|
let thread = task.await?;
|
||||||
telemetry::event!(
|
telemetry::event!(
|
||||||
"Agent Thread Feedback Comments",
|
"Agent Thread Feedback Comments",
|
||||||
agent = agent,
|
agent = agent_telemetry_id,
|
||||||
session_id = session_id,
|
session_id = session_id,
|
||||||
comments = comments,
|
comments = comments,
|
||||||
thread = thread
|
thread = thread
|
||||||
@@ -333,6 +333,7 @@ impl AcpThreadView {
|
|||||||
project: Entity<Project>,
|
project: Entity<Project>,
|
||||||
history_store: Entity<HistoryStore>,
|
history_store: Entity<HistoryStore>,
|
||||||
prompt_store: Option<Entity<PromptStore>>,
|
prompt_store: Option<Entity<PromptStore>>,
|
||||||
|
track_load_event: bool,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -391,8 +392,9 @@ impl AcpThreadView {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
let show_codex_windows_warning = crate::ExternalAgent::parse_built_in(agent.as_ref())
|
let show_codex_windows_warning = cfg!(windows)
|
||||||
== Some(crate::ExternalAgent::Codex);
|
&& project.read(cx).is_local()
|
||||||
|
&& agent.clone().downcast::<agent_servers::Codex>().is_some();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
agent: agent.clone(),
|
agent: agent.clone(),
|
||||||
@@ -404,6 +406,7 @@ impl AcpThreadView {
|
|||||||
resume_thread.clone(),
|
resume_thread.clone(),
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
project.clone(),
|
project.clone(),
|
||||||
|
track_load_event,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
),
|
),
|
||||||
@@ -448,6 +451,7 @@ impl AcpThreadView {
|
|||||||
self.resume_thread_metadata.clone(),
|
self.resume_thread_metadata.clone(),
|
||||||
self.workspace.clone(),
|
self.workspace.clone(),
|
||||||
self.project.clone(),
|
self.project.clone(),
|
||||||
|
true,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
@@ -461,6 +465,7 @@ impl AcpThreadView {
|
|||||||
resume_thread: Option<DbThreadMetadata>,
|
resume_thread: Option<DbThreadMetadata>,
|
||||||
workspace: WeakEntity<Workspace>,
|
workspace: WeakEntity<Workspace>,
|
||||||
project: Entity<Project>,
|
project: Entity<Project>,
|
||||||
|
track_load_event: bool,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> ThreadState {
|
) -> ThreadState {
|
||||||
@@ -519,6 +524,10 @@ impl AcpThreadView {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if track_load_event {
|
||||||
|
telemetry::event!("Agent Thread Started", agent = connection.telemetry_id());
|
||||||
|
}
|
||||||
|
|
||||||
let result = if let Some(native_agent) = connection
|
let result = if let Some(native_agent) = connection
|
||||||
.clone()
|
.clone()
|
||||||
.downcast::<agent::NativeAgentConnection>()
|
.downcast::<agent::NativeAgentConnection>()
|
||||||
@@ -1133,8 +1142,8 @@ impl AcpThreadView {
|
|||||||
let Some(thread) = self.thread() else {
|
let Some(thread) = self.thread() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let agent_telemetry_id = self.agent.telemetry_id();
|
|
||||||
let session_id = thread.read(cx).session_id().clone();
|
let session_id = thread.read(cx).session_id().clone();
|
||||||
|
let agent_telemetry_id = thread.read(cx).connection().telemetry_id();
|
||||||
let thread = thread.downgrade();
|
let thread = thread.downgrade();
|
||||||
if self.should_be_following {
|
if self.should_be_following {
|
||||||
self.workspace
|
self.workspace
|
||||||
@@ -1512,6 +1521,7 @@ impl AcpThreadView {
|
|||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
let agent_telemetry_id = connection.telemetry_id();
|
||||||
|
|
||||||
// Check for the experimental "terminal-auth" _meta field
|
// Check for the experimental "terminal-auth" _meta field
|
||||||
let auth_method = connection.auth_methods().iter().find(|m| m.id == method);
|
let auth_method = connection.auth_methods().iter().find(|m| m.id == method);
|
||||||
@@ -1579,19 +1589,18 @@ impl AcpThreadView {
|
|||||||
);
|
);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
self.auth_task = Some(cx.spawn_in(window, {
|
self.auth_task = Some(cx.spawn_in(window, {
|
||||||
let agent = self.agent.clone();
|
|
||||||
async move |this, cx| {
|
async move |this, cx| {
|
||||||
let result = authenticate.await;
|
let result = authenticate.await;
|
||||||
|
|
||||||
match &result {
|
match &result {
|
||||||
Ok(_) => telemetry::event!(
|
Ok(_) => telemetry::event!(
|
||||||
"Authenticate Agent Succeeded",
|
"Authenticate Agent Succeeded",
|
||||||
agent = agent.telemetry_id()
|
agent = agent_telemetry_id
|
||||||
),
|
),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
telemetry::event!(
|
telemetry::event!(
|
||||||
"Authenticate Agent Failed",
|
"Authenticate Agent Failed",
|
||||||
agent = agent.telemetry_id(),
|
agent = agent_telemetry_id,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1675,6 +1684,7 @@ impl AcpThreadView {
|
|||||||
None,
|
None,
|
||||||
this.workspace.clone(),
|
this.workspace.clone(),
|
||||||
this.project.clone(),
|
this.project.clone(),
|
||||||
|
true,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -1730,43 +1740,38 @@ impl AcpThreadView {
|
|||||||
connection.authenticate(method, cx)
|
connection.authenticate(method, cx)
|
||||||
};
|
};
|
||||||
cx.notify();
|
cx.notify();
|
||||||
self.auth_task =
|
self.auth_task = Some(cx.spawn_in(window, {
|
||||||
Some(cx.spawn_in(window, {
|
async move |this, cx| {
|
||||||
let agent = self.agent.clone();
|
let result = authenticate.await;
|
||||||
async move |this, cx| {
|
|
||||||
let result = authenticate.await;
|
|
||||||
|
|
||||||
match &result {
|
match &result {
|
||||||
Ok(_) => telemetry::event!(
|
Ok(_) => telemetry::event!(
|
||||||
"Authenticate Agent Succeeded",
|
"Authenticate Agent Succeeded",
|
||||||
agent = agent.telemetry_id()
|
agent = agent_telemetry_id
|
||||||
),
|
),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
telemetry::event!(
|
telemetry::event!("Authenticate Agent Failed", agent = agent_telemetry_id,)
|
||||||
"Authenticate Agent Failed",
|
|
||||||
agent = agent.telemetry_id(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update_in(cx, |this, window, cx| {
|
|
||||||
if let Err(err) = result {
|
|
||||||
if let ThreadState::Unauthenticated {
|
|
||||||
pending_auth_method,
|
|
||||||
..
|
|
||||||
} = &mut this.thread_state
|
|
||||||
{
|
|
||||||
pending_auth_method.take();
|
|
||||||
}
|
|
||||||
this.handle_thread_error(err, cx);
|
|
||||||
} else {
|
|
||||||
this.reset(window, cx);
|
|
||||||
}
|
|
||||||
this.auth_task.take()
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
}));
|
|
||||||
|
this.update_in(cx, |this, window, cx| {
|
||||||
|
if let Err(err) = result {
|
||||||
|
if let ThreadState::Unauthenticated {
|
||||||
|
pending_auth_method,
|
||||||
|
..
|
||||||
|
} = &mut this.thread_state
|
||||||
|
{
|
||||||
|
pending_auth_method.take();
|
||||||
|
}
|
||||||
|
this.handle_thread_error(err, cx);
|
||||||
|
} else {
|
||||||
|
this.reset(window, cx);
|
||||||
|
}
|
||||||
|
this.auth_task.take()
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_external_agent_login(
|
fn spawn_external_agent_login(
|
||||||
@@ -1896,10 +1901,11 @@ impl AcpThreadView {
|
|||||||
let Some(thread) = self.thread() else {
|
let Some(thread) = self.thread() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
let agent_telemetry_id = thread.read(cx).connection().telemetry_id();
|
||||||
|
|
||||||
telemetry::event!(
|
telemetry::event!(
|
||||||
"Agent Tool Call Authorized",
|
"Agent Tool Call Authorized",
|
||||||
agent = self.agent.telemetry_id(),
|
agent = agent_telemetry_id,
|
||||||
session = thread.read(cx).session_id(),
|
session = thread.read(cx).session_id(),
|
||||||
option = option_kind
|
option = option_kind
|
||||||
);
|
);
|
||||||
@@ -3509,6 +3515,8 @@ impl AcpThreadView {
|
|||||||
(method.id.0.clone(), method.name.clone())
|
(method.id.0.clone(), method.name.clone())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let agent_telemetry_id = connection.telemetry_id();
|
||||||
|
|
||||||
Button::new(method_id.clone(), name)
|
Button::new(method_id.clone(), name)
|
||||||
.label_size(LabelSize::Small)
|
.label_size(LabelSize::Small)
|
||||||
.map(|this| {
|
.map(|this| {
|
||||||
@@ -3528,7 +3536,7 @@ impl AcpThreadView {
|
|||||||
cx.listener(move |this, _, window, cx| {
|
cx.listener(move |this, _, window, cx| {
|
||||||
telemetry::event!(
|
telemetry::event!(
|
||||||
"Authenticate Agent Started",
|
"Authenticate Agent Started",
|
||||||
agent = this.agent.telemetry_id(),
|
agent = agent_telemetry_id,
|
||||||
method = method_id
|
method = method_id
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -5376,47 +5384,39 @@ impl AcpThreadView {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_codex_windows_warning(&self, cx: &mut Context<Self>) -> Option<Callout> {
|
fn render_codex_windows_warning(&self, cx: &mut Context<Self>) -> Callout {
|
||||||
if self.show_codex_windows_warning {
|
Callout::new()
|
||||||
Some(
|
.icon(IconName::Warning)
|
||||||
Callout::new()
|
.severity(Severity::Warning)
|
||||||
.icon(IconName::Warning)
|
.title("Codex on Windows")
|
||||||
.severity(Severity::Warning)
|
.description("For best performance, run Codex in Windows Subsystem for Linux (WSL2)")
|
||||||
.title("Codex on Windows")
|
.actions_slot(
|
||||||
.description(
|
Button::new("open-wsl-modal", "Open in WSL")
|
||||||
"For best performance, run Codex in Windows Subsystem for Linux (WSL2)",
|
.icon_size(IconSize::Small)
|
||||||
)
|
.icon_color(Color::Muted)
|
||||||
.actions_slot(
|
.on_click(cx.listener({
|
||||||
Button::new("open-wsl-modal", "Open in WSL")
|
move |_, _, _window, cx| {
|
||||||
.icon_size(IconSize::Small)
|
#[cfg(windows)]
|
||||||
.icon_color(Color::Muted)
|
_window.dispatch_action(
|
||||||
.on_click(cx.listener({
|
zed_actions::wsl_actions::OpenWsl::default().boxed_clone(),
|
||||||
move |_, _, _window, cx| {
|
cx,
|
||||||
#[cfg(windows)]
|
);
|
||||||
_window.dispatch_action(
|
cx.notify();
|
||||||
zed_actions::wsl_actions::OpenWsl::default().boxed_clone(),
|
}
|
||||||
cx,
|
})),
|
||||||
);
|
)
|
||||||
cx.notify();
|
.dismiss_action(
|
||||||
}
|
IconButton::new("dismiss", IconName::Close)
|
||||||
})),
|
.icon_size(IconSize::Small)
|
||||||
)
|
.icon_color(Color::Muted)
|
||||||
.dismiss_action(
|
.tooltip(Tooltip::text("Dismiss Warning"))
|
||||||
IconButton::new("dismiss", IconName::Close)
|
.on_click(cx.listener({
|
||||||
.icon_size(IconSize::Small)
|
move |this, _, _, cx| {
|
||||||
.icon_color(Color::Muted)
|
this.show_codex_windows_warning = false;
|
||||||
.tooltip(Tooltip::text("Dismiss Warning"))
|
cx.notify();
|
||||||
.on_click(cx.listener({
|
}
|
||||||
move |this, _, _, cx| {
|
})),
|
||||||
this.show_codex_windows_warning = false;
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_thread_error(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Option<Div> {
|
fn render_thread_error(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Option<Div> {
|
||||||
@@ -5936,12 +5936,8 @@ impl Render for AcpThreadView {
|
|||||||
_ => this,
|
_ => this,
|
||||||
})
|
})
|
||||||
.children(self.render_thread_retry_status_callout(window, cx))
|
.children(self.render_thread_retry_status_callout(window, cx))
|
||||||
.children({
|
.when(self.show_codex_windows_warning, |this| {
|
||||||
if cfg!(windows) && self.project.read(cx).is_local() {
|
this.child(self.render_codex_windows_warning(cx))
|
||||||
self.render_codex_windows_warning(cx)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.children(self.render_thread_error(window, cx))
|
.children(self.render_thread_error(window, cx))
|
||||||
.when_some(
|
.when_some(
|
||||||
@@ -6398,6 +6394,7 @@ pub(crate) mod tests {
|
|||||||
project,
|
project,
|
||||||
history_store,
|
history_store,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -6475,10 +6472,6 @@ 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
|
||||||
}
|
}
|
||||||
@@ -6505,8 +6498,8 @@ pub(crate) mod tests {
|
|||||||
struct SaboteurAgentConnection;
|
struct SaboteurAgentConnection;
|
||||||
|
|
||||||
impl AgentConnection for SaboteurAgentConnection {
|
impl AgentConnection for SaboteurAgentConnection {
|
||||||
fn telemetry_id(&self) -> &'static str {
|
fn telemetry_id(&self) -> SharedString {
|
||||||
"saboteur"
|
"saboteur".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_thread(
|
fn new_thread(
|
||||||
@@ -6569,8 +6562,8 @@ pub(crate) mod tests {
|
|||||||
struct RefusalAgentConnection;
|
struct RefusalAgentConnection;
|
||||||
|
|
||||||
impl AgentConnection for RefusalAgentConnection {
|
impl AgentConnection for RefusalAgentConnection {
|
||||||
fn telemetry_id(&self) -> &'static str {
|
fn telemetry_id(&self) -> SharedString {
|
||||||
"refusal"
|
"refusal".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_thread(
|
fn new_thread(
|
||||||
@@ -6671,6 +6664,7 @@ pub(crate) mod tests {
|
|||||||
project.clone(),
|
project.clone(),
|
||||||
history_store.clone(),
|
history_store.clone(),
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -305,6 +305,7 @@ impl ActiveView {
|
|||||||
project,
|
project,
|
||||||
history_store,
|
history_store,
|
||||||
prompt_store,
|
prompt_store,
|
||||||
|
false,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
@@ -885,10 +886,6 @@ impl AgentPanel {
|
|||||||
|
|
||||||
let server = ext_agent.server(fs, history);
|
let server = ext_agent.server(fs, history);
|
||||||
|
|
||||||
if !loading {
|
|
||||||
telemetry::event!("Agent Thread Started", agent = server.telemetry_id());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.update_in(cx, |this, window, cx| {
|
this.update_in(cx, |this, window, cx| {
|
||||||
let selected_agent = ext_agent.into();
|
let selected_agent = ext_agent.into();
|
||||||
if this.selected_agent != selected_agent {
|
if this.selected_agent != selected_agent {
|
||||||
@@ -905,6 +902,7 @@ impl AgentPanel {
|
|||||||
project,
|
project,
|
||||||
this.history_store.clone(),
|
this.history_store.clone(),
|
||||||
this.prompt_store.clone(),
|
this.prompt_store.clone(),
|
||||||
|
!loading,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -160,16 +160,6 @@ pub enum ExternalAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ExternalAgent {
|
impl ExternalAgent {
|
||||||
pub fn parse_built_in(server: &dyn agent_servers::AgentServer) -> Option<Self> {
|
|
||||||
match server.telemetry_id() {
|
|
||||||
"gemini-cli" => Some(Self::Gemini),
|
|
||||||
"claude-code" => Some(Self::ClaudeCode),
|
|
||||||
"codex" => Some(Self::Codex),
|
|
||||||
"zed" => Some(Self::NativeAgent),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn server(
|
pub fn server(
|
||||||
&self,
|
&self,
|
||||||
fs: Arc<dyn fs::Fs>,
|
fs: Arc<dyn fs::Fs>,
|
||||||
|
|||||||
Reference in New Issue
Block a user