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.

acp_thread: Share v2 authentication definitions (#65235)

Ben Brandt85b3aa83a2e3
diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs
index c4a5a54d43b..f56cea650ca 100644
--- a/crates/acp_thread/src/acp_thread.rs
+++ b/crates/acp_thread/src/acp_thread.rs
@@ -1,3 +1,4 @@
+pub mod auth_methods;
pub mod commands;
pub mod config_options;
mod connection;
@@ -17090,7 +17091,7 @@ mod tests {
#[derive(Clone, Default)]
struct FakeAgentConnection {
- auth_methods: Vec<acp_v1::AuthMethod>,
+ auth_methods: Vec<acp_v2::AuthMethod>,
supports_truncate: bool,
sessions: Arc<parking_lot::Mutex<HashMap<acp_v1::SessionId, WeakEntity<AcpThread>>>>,
set_title_calls: Rc<RefCell<Vec<SharedString>>>,
@@ -17124,7 +17125,7 @@ mod tests {
}
#[expect(unused)]
- fn with_auth_methods(mut self, auth_methods: Vec<acp_v1::AuthMethod>) -> Self {
+ fn with_auth_methods(mut self, auth_methods: Vec<acp_v2::AuthMethod>) -> Self {
self.auth_methods = auth_methods;
self
}
@@ -17152,7 +17153,7 @@ mod tests {
"fake".into()
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&self.auth_methods
}
@@ -17194,10 +17195,14 @@ mod tests {
fn authenticate(
&self,
- method: acp_v1::AuthMethodId,
+ method: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
- if self.auth_methods().iter().any(|m| m.id() == &method) {
+ if self
+ .auth_methods()
+ .iter()
+ .any(|candidate| candidate.method_id() == &method)
+ {
Task::ready(Ok(()))
} else {
Task::ready(Err(anyhow!("Invalid Auth Method")))
diff --git a/crates/acp_thread/src/auth_methods.rs b/crates/acp_thread/src/auth_methods.rs
new file mode 100644
index 00000000000..75311b1d16c
--- /dev/null
+++ b/crates/acp_thread/src/auth_methods.rs
@@ -0,0 +1,122 @@
+use agent_client_protocol::schema::{v1 as acp_v1, v2 as acp_v2};
+use anyhow::{Result, bail};
+
+pub fn from_v1(methods: Vec<acp_v1::AuthMethod>) -> Result<Vec<acp_v2::AuthMethod>> {
+ methods
+ .into_iter()
+ .map(|method| {
+ Ok(match method {
+ acp_v1::AuthMethod::Agent(method) => acp_v2::AuthMethod::Agent(
+ acp_v2::AuthMethodAgent::new(method.id.0, method.name)
+ .description(method.description)
+ .meta(method.meta),
+ ),
+ acp_v1::AuthMethod::Terminal(method) => {
+ let mut environment: Vec<_> = method
+ .env
+ .into_iter()
+ .map(|(name, value)| acp_v2::EnvVariable::new(name, value))
+ .collect();
+ environment.sort_by(|left, right| left.name.cmp(&right.name));
+ acp_v2::AuthMethod::Terminal(
+ acp_v2::AuthMethodTerminal::new(method.id.0, method.name)
+ .description(method.description)
+ .args(method.args)
+ .env(environment)
+ .meta(method.meta),
+ )
+ }
+ _ => bail!("Unsupported legacy authentication method"),
+ })
+ })
+ .collect()
+}
+
+pub fn is_supported(method: &acp_v2::AuthMethod) -> bool {
+ matches!(
+ method,
+ acp_v2::AuthMethod::Agent(_) | acp_v2::AuthMethod::Terminal(_)
+ )
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use serde_json::json;
+
+ #[test]
+ fn legacy_definitions_preserve_authentication_data() -> Result<()> {
+ let methods = from_v1(vec![
+ serde_json::from_value(json!({"id": "/opaque.login", "name": "Default login"}))?,
+ acp_v1::AuthMethod::Agent(
+ acp_v1::AuthMethodAgent::new("empty", "")
+ .description("")
+ .meta(acp_v1::Meta::new()),
+ ),
+ acp_v1::AuthMethod::Agent(
+ acp_v1::AuthMethodAgent::new("legacy", "Legacy login")
+ .description("Interactive login")
+ .meta(acp_v1::Meta::from_iter([
+ (
+ "terminal-auth".into(),
+ json!({
+ "label": "Legacy login",
+ "command": "agent",
+ "args": ["auth", "--interactive"],
+ "env": {"AUTH_MODE": "interactive"}
+ }),
+ ),
+ ("extension".into(), json!({"nested": [null, true]})),
+ ])),
+ ),
+ acp_v1::AuthMethod::Terminal(acp_v1::AuthMethodTerminal::new("terminal", "Login")),
+ acp_v1::AuthMethod::Terminal(
+ acp_v1::AuthMethodTerminal::new("terminal/opaque", "Terminal login")
+ .description("Sign in")
+ .args(vec!["auth".into(), "--interactive".into(), "".into()])
+ .env(std::collections::HashMap::from_iter([
+ ("SHARED".into(), "override".into()),
+ ("EMPTY".into(), "".into()),
+ ]))
+ .meta(acp_v1::Meta::from_iter([(
+ "extension".into(),
+ json!({"nested": [1, "retained"]}),
+ )])),
+ ),
+ ])?;
+ assert!(methods.iter().all(is_supported));
+ assert_eq!(
+ serde_json::to_value(methods)?,
+ json!([
+ {"type": "agent", "methodId": "/opaque.login", "name": "Default login"},
+ {
+ "type": "agent", "methodId": "empty", "name": "",
+ "description": "", "_meta": {}
+ },
+ {
+ "type": "agent", "methodId": "legacy", "name": "Legacy login",
+ "description": "Interactive login",
+ "_meta": {
+ "terminal-auth": {
+ "label": "Legacy login", "command": "agent",
+ "args": ["auth", "--interactive"],
+ "env": {"AUTH_MODE": "interactive"}
+ },
+ "extension": {"nested": [null, true]}
+ }
+ },
+ {"type": "terminal", "methodId": "terminal", "name": "Login"},
+ {
+ "type": "terminal", "methodId": "terminal/opaque", "name": "Terminal login",
+ "description": "Sign in", "args": ["auth", "--interactive", ""],
+ "env": [
+ {"name": "EMPTY", "value": ""},
+ {"name": "SHARED", "value": "override"}
+ ],
+ "_meta": {"extension": {"nested": [1, "retained"]}}
+ }
+ ])
+ );
+ Ok(())
+ }
+}
diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rs
index 2abc8fffd7e..ec20734b03b 100644
--- a/crates/acp_thread/src/connection.rs
+++ b/crates/acp_thread/src/connection.rs
@@ -164,17 +164,17 @@ pub trait AgentConnection {
false
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod];
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod];
fn terminal_auth_task(
&self,
- _method: &acp_v1::AuthMethodId,
+ _method: &acp_v2::AuthMethodId,
_cx: &App,
) -> Option<Task<Result<SpawnInTerminal>>> {
None
}
- fn authenticate(&self, method: acp_v1::AuthMethodId, cx: &mut App) -> Task<Result<()>>;
+ fn authenticate(&self, method: acp_v2::AuthMethodId, cx: &mut App) -> Task<Result<()>>;
fn supports_logout(&self) -> bool {
false
@@ -1078,7 +1078,7 @@ mod test_support {
self.telemetry_id.clone()
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
@@ -1126,7 +1126,7 @@ mod test_support {
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
unimplemented!()
diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs
index c26f7621796..d09d22b083d 100644
--- a/crates/agent/src/agent.rs
+++ b/crates/agent/src/agent.rs
@@ -2809,11 +2809,11 @@ impl acp_thread::AgentConnection for NativeAgentConnection {
.update(cx, |agent, cx| agent.open_thread(session_id, project, cx))
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[] // No auth for in-process
}
- fn authenticate(&self, _method: acp_v1::AuthMethodId, _cx: &mut App) -> Task<Result<()>> {
+ fn authenticate(&self, _method: acp_v2::AuthMethodId, _cx: &mut App) -> Task<Result<()>> {
Task::ready(Ok(()))
}
diff --git a/crates/agent_servers/src/acp.rs b/crates/agent_servers/src/acp.rs
index 07cd62d8c07..78a9ac60a59 100644
--- a/crates/agent_servers/src/acp.rs
+++ b/crates/agent_servers/src/acp.rs
@@ -275,7 +275,7 @@ pub struct AcpConnection {
connection: ConnectionTo<Agent>,
sessions: Rc<RefCell<HashMap<acp::SessionId, AcpSession>>>,
pending_sessions: RefCell<HashMap<acp::SessionId, PendingAcpSession>>,
- auth_methods: Vec<acp::AuthMethod>,
+ auth_methods: Vec<acp_v2::AuthMethod>,
agent_server_store: WeakEntity<AgentServerStore>,
agent_capabilities: acp::AgentCapabilities,
request_elicitations: Entity<ElicitationStore>,
@@ -959,14 +959,14 @@ impl AcpConnection {
"args": gemini_args,
"env": original_command.env.unwrap_or_default(),
});
- let meta = acp::Meta::from_iter([("terminal-auth".to_string(), value)]);
- vec![acp::AuthMethod::Agent(
- acp::AuthMethodAgent::new(GEMINI_TERMINAL_AUTH_METHOD_ID, "Login")
+ let meta = acp_v2::Meta::from_iter([("terminal-auth".to_string(), value)]);
+ vec![acp_v2::AuthMethod::Agent(
+ acp_v2::AuthMethodAgent::new(GEMINI_TERMINAL_AUTH_METHOD_ID, "Login")
.description("Login with your Google or Vertex AI account")
.meta(meta),
)]
} else {
- response.auth_methods
+ acp_thread::auth_methods::from_v1(response.auth_methods)?
};
let defaults = AcpConnectionDefaults::new(default_mode, default_config_options);
let settings_subscription = cx.update({
@@ -1519,17 +1519,17 @@ impl Drop for AcpConnection {
}
}
-fn terminal_auth_task_id(agent_id: &AgentId, method_id: &acp::AuthMethodId) -> String {
+fn terminal_auth_task_id(agent_id: &AgentId, method_id: &acp_v2::AuthMethodId) -> String {
format!("external-agent-{}-{}-login", agent_id.0, method_id.0)
}
fn terminal_auth_task(
command: &AgentServerCommand,
agent_id: &AgentId,
- method: &acp::AuthMethodTerminal,
+ method: &acp_v2::AuthMethodTerminal,
) -> SpawnInTerminal {
acp_thread::build_terminal_auth_task(
- terminal_auth_task_id(agent_id, &method.id),
+ terminal_auth_task_id(agent_id, &method.method_id),
method.name.clone(),
command.path.to_string_lossy().into_owned(),
command.args.clone(),
@@ -1540,8 +1540,8 @@ fn terminal_auth_task(
/// Used to support the _meta method prior to stabilization
fn meta_terminal_auth_task(
agent_id: &AgentId,
- method_id: &acp::AuthMethodId,
- method: &acp::AuthMethod,
+ method_id: &acp_v2::AuthMethodId,
+ method: &acp_v2::AuthMethod,
) -> Option<SpawnInTerminal> {
#[derive(Deserialize)]
struct MetaTerminalAuth {
@@ -1789,22 +1789,22 @@ impl AgentConnection for AcpConnection {
)
}
- fn auth_methods(&self) -> &[acp::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&self.auth_methods
}
fn terminal_auth_task(
&self,
- method_id: &acp::AuthMethodId,
+ method_id: &acp_v2::AuthMethodId,
cx: &App,
) -> Option<Task<Result<SpawnInTerminal>>> {
let method = self
.auth_methods
.iter()
- .find(|method| method.id() == method_id)?;
+ .find(|method| method.method_id() == method_id)?;
match method {
- acp::AuthMethod::Terminal(terminal) => {
+ acp_v2::AuthMethod::Terminal(terminal) => {
let agent_id = self.id.clone();
let terminal = terminal.clone();
let store = self.agent_server_store.clone();
@@ -1814,9 +1814,14 @@ impl AgentConnection for AcpConnection {
let agent = store
.get_external_agent(&agent_id)
.context("Agent server not found")?;
+ let environment = terminal
+ .env
+ .iter()
+ .map(|variable| (variable.name.clone(), variable.value.clone()))
+ .collect();
anyhow::Ok(agent.get_command(
terminal.args.clone(),
- HashMap::from_iter(terminal.env.clone()),
+ environment,
&mut cx.to_async(),
))
})?
@@ -1825,17 +1830,28 @@ impl AgentConnection for AcpConnection {
Ok(terminal_auth_task(&command, &agent_id, &terminal))
}))
}
- _ => meta_terminal_auth_task(&self.id, method_id, method)
+ acp_v2::AuthMethod::Agent(_) => meta_terminal_auth_task(&self.id, method_id, method)
.map(|task| Task::ready(Ok(task))),
+ _ => None,
}
}
- fn authenticate(&self, method_id: acp::AuthMethodId, cx: &mut App) -> Task<Result<()>> {
+ fn authenticate(&self, method_id: acp_v2::AuthMethodId, cx: &mut App) -> Task<Result<()>> {
+ if !self.auth_methods.iter().any(|method| {
+ matches!(method, acp_v2::AuthMethod::Agent(agent) if agent.method_id == method_id)
+ }) {
+ return Task::ready(Err(anyhow!(
+ "Authentication method is not supported for agent-managed login"
+ )));
+ }
+
let conn = self.connection.clone();
cx.foreground_executor().spawn(async move {
- conn.send_request(acp::AuthenticateRequest::new(method_id))
- .block_task()
- .await?;
+ conn.send_request(acp::AuthenticateRequest::new(acp::AuthMethodId::new(
+ method_id.0,
+ )))
+ .block_task()
+ .await?;
Ok(())
})
}
@@ -2212,19 +2228,19 @@ pub mod test_support {
.resume_session(session_id, project, work_dirs, title, cx)
}
- fn auth_methods(&self) -> &[acp::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
self.inner.auth_methods()
}
fn terminal_auth_task(
&self,
- method: &acp::AuthMethodId,
+ method: &acp_v2::AuthMethodId,
cx: &App,
) -> Option<Task<Result<SpawnInTerminal>>> {
self.inner.terminal_auth_task(method, cx)
}
- fn authenticate(&self, method: acp::AuthMethodId, cx: &mut App) -> Task<Result<()>> {
+ fn authenticate(&self, method: acp_v2::AuthMethodId, cx: &mut App) -> Task<Result<()>> {
self.inner.authenticate(method, cx)
}
@@ -2343,14 +2359,18 @@ pub mod test_support {
.on_receive_request(
async move |req: acp::InitializeRequest, responder, _cx| {
responder.respond(
- acp::InitializeResponse::new(req.protocol_version).agent_capabilities(
- acp::AgentCapabilities::default()
- .load_session(true)
- .session_capabilities(
- acp::SessionCapabilities::default()
- .close(acp::SessionCloseCapabilities::new()),
- ),
- ),
+ acp::InitializeResponse::new(req.protocol_version)
+ .agent_capabilities(
+ acp::AgentCapabilities::default()
+ .load_session(true)
+ .session_capabilities(
+ acp::SessionCapabilities::default()
+ .close(acp::SessionCloseCapabilities::new()),
+ ),
+ )
+ .auth_methods(vec![acp::AuthMethod::Agent(acp::AuthMethodAgent::new(
+ "login", "Login",
+ ))]),
)
},
agent_client_protocol::on_receive_request!(),
@@ -2361,7 +2381,8 @@ pub mod test_support {
let auth_elicitation_request = auth_elicitation_request.clone();
let auth_elicitation_response = auth_elicitation_response.clone();
let auth_elicitation_completion = auth_elicitation_completion.clone();
- async move |_req: acp::AuthenticateRequest, responder, cx| {
+ async move |req: acp::AuthenticateRequest, responder, cx| {
+ assert_eq!(req.method_id, acp::AuthMethodId::new("login"));
authenticate_count.fetch_add(1, Ordering::SeqCst);
let request = auth_elicitation_request
.lock()
@@ -2479,6 +2500,7 @@ pub mod test_support {
.await?;
let agent_capabilities = response.agent_capabilities;
+ let auth_methods = acp_thread::auth_methods::from_v1(response.auth_methods)?;
let request_elicitations = cx.new(|_| ElicitationStore::default());
let dispatch_context = ClientContext {
@@ -2517,6 +2539,8 @@ pub mod test_support {
anyhow::Ok(())
});
+ let mut connection = connection;
+ connection.auth_methods = auth_methods;
Ok(FakeAcpConnectionHarness {
connection: Rc::new(connection),
load_session_count,
@@ -3239,7 +3263,7 @@ mod tests {
.await;
let connection = harness.connection.clone();
let auth_task =
- cx.update(|cx| connection.authenticate(acp::AuthMethodId::new("login"), cx));
+ cx.update(|cx| connection.authenticate(acp_v2::AuthMethodId::new("login"), cx));
cx.run_until_parked();
let store = connection
@@ -3322,7 +3346,7 @@ mod tests {
.await;
let connection = harness.connection.clone();
let auth_task =
- cx.update(|cx| connection.authenticate(acp::AuthMethodId::new("login"), cx));
+ cx.update(|cx| connection.authenticate(acp_v2::AuthMethodId::new("login"), cx));
cx.run_until_parked();
assert!(
@@ -3444,7 +3468,7 @@ mod tests {
);
let auth_task =
- cx.update(|cx| connection.authenticate(acp::AuthMethodId::new("login"), cx));
+ cx.update(|cx| connection.authenticate(acp_v2::AuthMethodId::new("login"), cx));
cx.run_until_parked();
let store = connection
@@ -3560,11 +3584,42 @@ mod tests {
fs.insert_tree("/", serde_json::json!({ "project": {} }))
.await;
let project = project::Project::test(fs, [std::path::Path::new("/project")], cx).await;
- let mut harness = test_support::connect_fake_acp_connection(project, cx).await;
- let method_id = acp::AuthMethodId::new("login");
- let method = acp::AuthMethod::Terminal(
- acp::AuthMethodTerminal::new(method_id.clone(), "First-class login")
- .args(vec!["first-class-auth".into()])
+ let mut harness = test_support::connect_fake_acp_connection(project.clone(), cx).await;
+ cx.update(|cx| {
+ AllAgentServersSettings::override_global(
+ AllAgentServersSettings(HashMap::from_iter([(
+ "test".to_string(),
+ settings::CustomAgentServerSettings::Custom {
+ path: PathBuf::from("test-agent"),
+ args: vec!["--acp".into(), "--verbose".into()],
+ env: HashMap::from_iter([
+ ("BASE".into(), "1".into()),
+ ("SHARED".into(), "base".into()),
+ ]),
+ default_mode: None,
+ default_config_options: HashMap::default(),
+ favorite_config_option_values: HashMap::default(),
+ }
+ .into(),
+ )])),
+ cx,
+ );
+ });
+ cx.run_until_parked();
+ assert_eq!(
+ harness.connection.auth_methods(),
+ &[acp_v2::AuthMethod::Agent(acp_v2::AuthMethodAgent::new(
+ "login", "Login"
+ ))]
+ );
+ let method_id = acp_v2::AuthMethodId::new("login");
+ let mut methods = acp_thread::auth_methods::from_v1(vec![acp::AuthMethod::Terminal(
+ acp::AuthMethodTerminal::new(method_id.0.clone(), "First-class login")
+ .args(vec!["first-class-auth".into(), "".into()])
+ .env(std::collections::HashMap::from_iter([
+ ("SHARED".into(), "override".into()),
+ ("EMPTY".into(), "".into()),
+ ]))
.meta(acp::Meta::from_iter([(
"terminal-auth".to_string(),
serde_json::json!({
@@ -3573,10 +3628,21 @@ mod tests {
"args": ["legacy-auth"],
}),
)])),
+ )])
+ .expect("terminal authentication should adapt");
+ let Some(acp_v2::AuthMethod::Terminal(terminal)) = methods.first_mut() else {
+ panic!("expected a shared terminal authentication method");
+ };
+ terminal.env.push(
+ acp_v2::EnvVariable::new("EXTRA", "2").meta(acp_v2::Meta::from_iter([(
+ "extension".into(),
+ serde_json::json!({"nested": [null, true]}),
+ )])),
);
+ let advertised_methods = methods.clone();
Rc::get_mut(&mut harness.connection)
.expect("test harness should have the only connection handle")
- .auth_methods = vec![method];
+ .auth_methods = methods;
let terminal_task = cx
.update(|cx| {
@@ -3594,9 +3660,64 @@ mod tests {
harness.connection.terminal_auth_task(&method_id, cx)
})
.expect("first-class terminal auth should be routed without ACP beta");
- terminal_task
+ let terminal_task = terminal_task
.await
- .expect_err("first-class routing should resolve the test agent's external command");
+ .expect("first-class routing should resolve the test agent's external command");
+ assert_eq!(terminal_task.command.as_deref(), Some("test-agent"));
+ assert_eq!(
+ terminal_task.args,
+ vec!["--acp", "--verbose", "first-class-auth", ""]
+ );
+ assert_eq!(terminal_task.env.get("BASE").map(String::as_str), Some("1"));
+ assert_eq!(
+ terminal_task.env.get("SHARED").map(String::as_str),
+ Some("override")
+ );
+ assert_eq!(terminal_task.env.get("EMPTY").map(String::as_str), Some(""));
+ assert_eq!(
+ terminal_task.env.get("EXTRA").map(String::as_str),
+ Some("2")
+ );
+ assert_eq!(terminal_task.label, "First-class login");
+ assert_eq!(harness.connection.auth_methods(), advertised_methods);
+ cx.update(|cx| harness.connection.authenticate(method_id.clone(), cx))
+ .await
+ .expect_err("terminal auth must not use the agent-managed login RPC");
+
+ let unknown = serde_json::json!({
+ "type": "_future_login",
+ "methodId": "unknown",
+ "name": "Unknown login",
+ "custom": {"nested": [null, true]},
+ "_meta": {"terminal-auth": {"label": "Not executable", "command": "agent"}}
+ });
+ Rc::get_mut(&mut harness.connection)
+ .expect("test harness should have the only connection handle")
+ .auth_methods = vec![serde_json::from_value(unknown.clone()).expect("unknown method")];
+ let unknown_id = acp_v2::AuthMethodId::new("unknown");
+ cx.update(|cx| {
+ assert!(
+ harness
+ .connection
+ .terminal_auth_task(&unknown_id, cx)
+ .is_none()
+ );
+ harness.connection.authenticate(unknown_id, cx)
+ })
+ .await
+ .expect_err("unknown auth must not use the agent-managed login RPC");
+ assert_eq!(
+ serde_json::to_value(harness.connection.auth_methods()).expect("shared methods"),
+ serde_json::json!([unknown])
+ );
+
+ Rc::get_mut(&mut harness.connection)
+ .expect("test harness should have the only connection handle")
+ .auth_methods
+ .clear();
+ cx.update(|cx| harness.connection.authenticate(method_id, cx))
+ .await
+ .expect_err("unadvertised auth must not use the agent-managed login RPC");
assert_eq!(harness.authenticate_count.load(Ordering::SeqCst), 0);
}
@@ -3612,7 +3733,7 @@ mod tests {
("EXTRA".into(), "2".into()),
])),
};
- let method = acp::AuthMethodTerminal::new("login", "Login");
+ let method = acp_v2::AuthMethodTerminal::new("login", "Login");
let task = terminal_auth_task(&command, &AgentId::new("test-agent"), &method);
@@ -3632,19 +3753,21 @@ mod tests {
#[test]
fn legacy_terminal_auth_task_parses_meta_and_retries_session() {
- let method_id = acp::AuthMethodId::new("legacy-login");
- let method = acp::AuthMethod::Agent(
- acp::AuthMethodAgent::new(method_id.clone(), "Login").meta(acp::Meta::from_iter([(
- "terminal-auth".to_string(),
- serde_json::json!({
- "label": "legacy /auth",
- "command": "legacy-agent",
- "args": ["auth", "--interactive"],
- "env": {
- "AUTH_MODE": "interactive",
- },
- }),
- )])),
+ let method_id = acp_v2::AuthMethodId::new("legacy-login");
+ let method = acp_v2::AuthMethod::Agent(
+ acp_v2::AuthMethodAgent::new(method_id.clone(), "Login").meta(acp_v2::Meta::from_iter(
+ [(
+ "terminal-auth".to_string(),
+ serde_json::json!({
+ "label": "legacy /auth",
+ "command": "legacy-agent",
+ "args": ["auth", "--interactive"],
+ "env": {
+ "AUTH_MODE": "interactive",
+ },
+ }),
+ )],
+ )),
);
let task = meta_terminal_auth_task(&AgentId::new("test-agent"), &method_id, &method)
@@ -3662,14 +3785,16 @@ mod tests {
#[test]
fn legacy_terminal_auth_task_returns_none_for_invalid_meta() {
- let method_id = acp::AuthMethodId::new("legacy-login");
- let method = acp::AuthMethod::Agent(
- acp::AuthMethodAgent::new(method_id.clone(), "Login").meta(acp::Meta::from_iter([(
- "terminal-auth".to_string(),
- serde_json::json!({
- "label": "legacy /auth",
- }),
- )])),
+ let method_id = acp_v2::AuthMethodId::new("legacy-login");
+ let method = acp_v2::AuthMethod::Agent(
+ acp_v2::AuthMethodAgent::new(method_id.clone(), "Login").meta(acp_v2::Meta::from_iter(
+ [(
+ "terminal-auth".to_string(),
+ serde_json::json!({
+ "label": "legacy /auth",
+ }),
+ )],
+ )),
);
assert!(
@@ -3679,15 +3804,12 @@ mod tests {
#[test]
fn first_class_terminal_auth_takes_precedence_over_legacy_meta() {
- let method_id = acp::AuthMethodId::new("login");
- let method = acp::AuthMethod::Terminal(
- acp::AuthMethodTerminal::new(method_id, "Login")
+ let method_id = acp_v2::AuthMethodId::new("login");
+ let method = acp_v2::AuthMethod::Terminal(
+ acp_v2::AuthMethodTerminal::new(method_id, "Login")
.args(vec!["/auth".into()])
- .env(std::collections::HashMap::from_iter([(
- "AUTH_MODE".into(),
- "first-class".into(),
- )]))
- .meta(acp::Meta::from_iter([(
+ .env(vec![acp_v2::EnvVariable::new("AUTH_MODE", "first-class")])
+ .meta(acp_v2::Meta::from_iter([(
"terminal-auth".to_string(),
serde_json::json!({
"label": "legacy /auth",
@@ -3710,7 +3832,7 @@ mod tests {
};
let task = match &method {
- acp::AuthMethod::Terminal(terminal) => {
+ acp_v2::AuthMethod::Terminal(terminal) => {
terminal_auth_task(&command, &AgentId::new("test-agent"), terminal)
}
_ => unreachable!(),
diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs
index 9be2911aca0..5ef03a5a8ed 100644
--- a/crates/agent_ui/src/agent_panel.rs
+++ b/crates/agent_ui/src/agent_panel.rs
@@ -7209,11 +7209,15 @@ mod tests {
Task::ready(Ok(()))
}
- fn auth_methods(&self) -> &[acp::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
- fn authenticate(&self, _method_id: acp::AuthMethodId, _cx: &mut App) -> Task<Result<()>> {
+ fn authenticate(
+ &self,
+ _method_id: acp_v2::AuthMethodId,
+ _cx: &mut App,
+ ) -> Task<Result<()>> {
Task::ready(Ok(()))
}
@@ -14069,11 +14073,15 @@ mod tests {
Task::ready(Ok(()))
}
- fn auth_methods(&self) -> &[acp::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
- fn authenticate(&self, _method_id: acp::AuthMethodId, _cx: &mut App) -> Task<Result<()>> {
+ fn authenticate(
+ &self,
+ _method_id: acp_v2::AuthMethodId,
+ _cx: &mut App,
+ ) -> Task<Result<()>> {
Task::ready(Ok(()))
}
diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs
index 4b582aca150..a3bd29d1ef3 100644
--- a/crates/agent_ui/src/conversation_view.rs
+++ b/crates/agent_ui/src/conversation_view.rs
@@ -804,7 +804,11 @@ pub struct ConversationView {
impl ConversationView {
pub fn has_auth_methods(&self) -> bool {
self.as_connected().map_or(false, |connected| {
- !connected.connection.auth_methods().is_empty()
+ connected
+ .connection
+ .auth_methods()
+ .iter()
+ .any(acp_thread::auth_methods::is_supported)
})
}
@@ -936,7 +940,7 @@ enum AuthState {
Ok,
Unauthenticated {
description: Option<Entity<Markdown>>,
- pending_auth_method: Option<acp_v1::AuthMethodId>,
+ pending_auth_method: Option<acp_v2::AuthMethodId>,
},
}
@@ -2174,7 +2178,7 @@ impl ConversationView {
fn authenticate(
&mut self,
- method: acp_v1::AuthMethodId,
+ method: acp_v2::AuthMethodId,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -2185,6 +2189,11 @@ impl ConversationView {
return;
};
let connection = connected.connection.clone();
+ if !connection.auth_methods().iter().any(|advertised| {
+ advertised.method_id() == &method && acp_thread::auth_methods::is_supported(advertised)
+ }) {
+ return;
+ }
let AuthState::Unauthenticated {
pending_auth_method,
@@ -2374,7 +2383,7 @@ impl ConversationView {
login: task::SpawnInTerminal,
workspace: Entity<Workspace>,
project: Entity<Project>,
- method: acp_v1::AuthMethodId,
+ method: acp_v2::AuthMethodId,
previous_attempt: bool,
window: &mut Window,
cx: &mut App,
@@ -2513,11 +2522,15 @@ impl ConversationView {
&self,
connection: &Rc<dyn AgentConnection>,
description: Option<&Entity<Markdown>>,
- pending_auth_method: Option<&acp_v1::AuthMethodId>,
+ pending_auth_method: Option<&acp_v2::AuthMethodId>,
window: &mut Window,
cx: &Context<Self>,
) -> impl IntoElement {
- let auth_methods = connection.auth_methods();
+ let auth_methods = connection
+ .auth_methods()
+ .iter()
+ .filter(|method| acp_thread::auth_methods::is_supported(method))
+ .collect::<Vec<_>>();
let agent_display_name = self
.agent_server_store
@@ -2530,43 +2543,34 @@ impl ConversationView {
let auth_buttons = || {
h_flex().justify_end().flex_wrap().gap_1().children(
- connection
- .auth_methods()
- .iter()
- .enumerate()
- .rev()
- .map(|(ix, method)| {
- let (method_id, name) = (method.id().0.clone(), method.name().to_string());
- let agent_telemetry_id = connection.telemetry_id();
-
- Button::new(method_id.clone(), name)
- .label_size(LabelSize::Small)
- .map(|this| {
- if ix == 0 {
- this.style(ButtonStyle::Tinted(TintColor::Accent))
- } else {
- this.style(ButtonStyle::Outlined)
- }
- })
- .when_some(method.description(), |this, description| {
- this.tooltip(Tooltip::text(description.to_string()))
- })
- .on_click({
- cx.listener(move |this, _, window, cx| {
- telemetry::event!(
- "Authenticate Agent Started",
- agent = agent_telemetry_id,
- method = method_id
- );
-
- this.authenticate(
- acp_v1::AuthMethodId::new(method_id.clone()),
- window,
- cx,
- )
- })
+ auth_methods.iter().enumerate().rev().map(|(ix, method)| {
+ let (method_id, name) = (method.method_id().clone(), method.name().to_string());
+ let agent_telemetry_id = connection.telemetry_id();
+
+ Button::new(method_id.0.clone(), name)
+ .label_size(LabelSize::Small)
+ .map(|this| {
+ if ix == 0 {
+ this.style(ButtonStyle::Tinted(TintColor::Accent))
+ } else {
+ this.style(ButtonStyle::Outlined)
+ }
+ })
+ .when_some(method.description(), |this, description| {
+ this.tooltip(Tooltip::text(description.to_string()))
+ })
+ .on_click({
+ cx.listener(move |this, _, window, cx| {
+ telemetry::event!(
+ "Authenticate Agent Started",
+ agent = agent_telemetry_id,
+ method = method_id.0
+ );
+
+ this.authenticate(method_id.clone(), window, cx)
})
- }),
+ })
+ }),
)
};
@@ -5765,13 +5769,13 @@ pub(crate) mod tests {
}
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
Task::ready(Ok(()))
@@ -6368,7 +6372,7 @@ pub(crate) mod tests {
let connection = AuthGatedAgentConnection::new();
let (conversation_view, cx) =
- setup_conversation_view(StubAgentServer::new(connection), cx).await;
+ setup_conversation_view(StubAgentServer::new(connection.clone()), cx).await;
// When new_session returns AuthRequired, the server should transition
// to Connected + Unauthenticated rather than getting stuck in Loading.
@@ -6376,6 +6380,53 @@ pub(crate) mod tests {
let connected = view
.as_connected()
.expect("Should be in Connected state even though auth is required");
+ assert!(view.has_auth_methods());
+ assert_eq!(
+ connected.connection.auth_methods(),
+ connection.auth_methods()
+ );
+ let [unknown, agent, terminal] = connected.connection.auth_methods() else {
+ panic!("expected the complete mixed authentication advertisement");
+ };
+ assert!(matches!(unknown, acp_v2::AuthMethod::Other(_)));
+ assert_eq!(
+ serde_json::to_value(unknown).expect("unknown auth method must serialize"),
+ json!({
+ "type": "_future_login",
+ "methodId": AuthGatedAgentConnection::OTHER_AUTH_METHOD_ID,
+ "name": "Future Login",
+ "description": "Not supported by this client",
+ "_meta": {
+ "terminal-auth": {"command": "must-not-run", "args": ["login"]}
+ },
+ "args": ["must-not-run"],
+ "details": {"nested": [1, {"preserve": true}]}
+ })
+ );
+ assert_eq!(
+ agent.method_id(),
+ &acp_v2::AuthMethodId::new(AuthGatedAgentConnection::AUTH_METHOD_ID)
+ );
+ assert_eq!(agent.name(), "Test Login");
+ assert_eq!(agent.description(), Some("Sign in with the test provider"));
+ assert_eq!(
+ agent.meta().and_then(|meta| meta.get("fixture")),
+ Some(&json!({"nested": ["retain", 7]}))
+ );
+ assert_eq!(terminal.name(), "Terminal Login");
+ assert_eq!(
+ connected
+ .connection
+ .auth_methods()
+ .iter()
+ .filter(|method| acp_thread::auth_methods::is_supported(method))
+ .map(|method| method.method_id().clone())
+ .collect::<Vec<_>>(),
+ vec![
+ acp_v2::AuthMethodId::new(AuthGatedAgentConnection::AUTH_METHOD_ID),
+ acp_v2::AuthMethodId::new(AuthGatedAgentConnection::TERMINAL_AUTH_METHOD_ID),
+ ]
+ );
assert!(
!connected.auth_state.is_ok(),
"Auth state should be Unauthenticated"
@@ -6425,23 +6476,76 @@ pub(crate) mod tests {
assert!(view.has_pending_selections());
});
+ for method_id in [
+ AuthGatedAgentConnection::OTHER_AUTH_METHOD_ID,
+ "unadvertised:login",
+ ] {
+ conversation_view.update_in(cx, |view, window, cx| {
+ view.authenticate(acp_v2::AuthMethodId::new(method_id), window, cx);
+ assert!(view.auth_task.is_none());
+ assert!(matches!(
+ &view
+ .as_connected()
+ .expect("connection must remain")
+ .auth_state,
+ AuthState::Unauthenticated {
+ pending_auth_method: None,
+ ..
+ }
+ ));
+ });
+ }
+ cx.run_until_parked();
+ assert!(connection.authenticate_calls.lock().is_empty());
+ assert!(connection.terminal_auth_calls.lock().is_empty());
+ assert!(!*connection.authenticated.lock());
+ conversation_view.read_with(cx, |view, _cx| {
+ assert!(view.active_thread().is_none());
+ assert!(view.has_pending_selections());
+ });
+
// Authenticate using the real authenticate flow on ConnectionView.
// This calls connection.authenticate(), which flips the internal flag,
// then on success triggers reset() -> new_session() which now succeeds.
conversation_view.update_in(cx, |view, window, cx| {
- view.authenticate(
- acp_v1::AuthMethodId::new(AuthGatedAgentConnection::AUTH_METHOD_ID),
- window,
- cx,
- );
+ let method_id = acp_v2::AuthMethodId::new(AuthGatedAgentConnection::AUTH_METHOD_ID);
+ view.authenticate(method_id.clone(), window, cx);
+ let AuthState::Unauthenticated {
+ pending_auth_method,
+ ..
+ } = &view
+ .as_connected()
+ .expect("connection must remain")
+ .auth_state
+ else {
+ panic!("authentication should be pending before reset");
+ };
+ assert_eq!(pending_auth_method.as_ref(), Some(&method_id));
+ assert!(view.auth_task.is_some());
});
cx.run_until_parked();
+ assert_eq!(
+ *connection.authenticate_calls.lock(),
+ vec![acp_v2::AuthMethodId::new(
+ AuthGatedAgentConnection::AUTH_METHOD_ID
+ )]
+ );
+ assert_eq!(
+ *connection.terminal_auth_calls.lock(),
+ vec![acp_v2::AuthMethodId::new(
+ AuthGatedAgentConnection::AUTH_METHOD_ID
+ )]
+ );
// After auth, the server should have an active thread in the Ok state.
conversation_view.read_with(cx, |view, cx| {
let connected = view
.as_connected()
.expect("Should still be in Connected state after auth");
+ assert_eq!(
+ connected.connection.auth_methods(),
+ connection.auth_methods()
+ );
assert!(connected.auth_state.is_ok(), "Auth state should be Ok");
assert!(
view.supports_logout(),
@@ -6511,6 +6615,55 @@ pub(crate) mod tests {
});
}
+ #[gpui::test]
+ async fn test_auth_unavailable_without_supported_methods(cx: &mut TestAppContext) {
+ init_test(cx);
+
+ let connection = AuthGatedAgentConnection::new();
+ let unsupported_methods = connection
+ .auth_methods()
+ .iter()
+ .filter(|method| !acp_thread::auth_methods::is_supported(method))
+ .cloned()
+ .collect::<Vec<_>>();
+ for auth_methods in [unsupported_methods, Vec::new()] {
+ let mut connection = connection.clone();
+ connection.auth_methods = auth_methods;
+ let (conversation_view, cx) =
+ setup_conversation_view(StubAgentServer::new(connection.clone()), cx).await;
+ conversation_view.update_in(cx, |view, window, cx| {
+ assert!(!view.has_auth_methods());
+ assert!(!view.supports_logout());
+ assert_eq!(
+ view.as_connected()
+ .expect("auth-required connection must remain")
+ .connection
+ .auth_methods(),
+ connection.auth_methods()
+ );
+ view.authenticate(
+ acp_v2::AuthMethodId::new(AuthGatedAgentConnection::OTHER_AUTH_METHOD_ID),
+ window,
+ cx,
+ );
+ assert!(view.auth_task.is_none());
+ assert!(matches!(
+ &view
+ .as_connected()
+ .expect("connection must remain")
+ .auth_state,
+ AuthState::Unauthenticated {
+ pending_auth_method: None,
+ ..
+ }
+ ));
+ });
+ cx.run_until_parked();
+ assert!(connection.authenticate_calls.lock().is_empty());
+ assert!(connection.terminal_auth_calls.lock().is_empty());
+ }
+ }
+
#[gpui::test]
async fn test_notification_for_tool_authorization(cx: &mut TestAppContext) {
init_test(cx);
@@ -7969,13 +8122,13 @@ pub(crate) mod tests {
Task::ready(Ok(thread))
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
Task::ready(Ok(()))
@@ -8100,13 +8253,13 @@ pub(crate) mod tests {
Some(self.store.clone())
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
Task::ready(Ok(()))
@@ -8212,13 +8365,13 @@ pub(crate) mod tests {
Some(self.store.clone())
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
Task::ready(Ok(()))
@@ -8284,13 +8437,13 @@ pub(crate) mod tests {
Task::ready(Ok(thread))
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
Task::ready(Ok(()))
@@ -8317,19 +8470,54 @@ pub(crate) mod tests {
#[derive(Clone)]
struct AuthGatedAgentConnection {
authenticated: Arc<Mutex<bool>>,
- auth_method: acp_v1::AuthMethod,
+ auth_methods: Vec<acp_v2::AuthMethod>,
+ authenticate_calls: Arc<Mutex<Vec<acp_v2::AuthMethodId>>>,
+ terminal_auth_calls: Arc<Mutex<Vec<acp_v2::AuthMethodId>>>,
}
impl AuthGatedAgentConnection {
- const AUTH_METHOD_ID: &str = "test-login";
+ const AUTH_METHOD_ID: &str = "login:provider/β?scope=team";
+ const TERMINAL_AUTH_METHOD_ID: &str = "terminal:login/opaque";
+ const OTHER_AUTH_METHOD_ID: &str = "future:login/opaque";
fn new() -> Self {
Self {
authenticated: Arc::new(Mutex::new(false)),
- auth_method: acp_v1::AuthMethod::Agent(acp_v1::AuthMethodAgent::new(
- Self::AUTH_METHOD_ID,
- "Test Login",
- )),
+ auth_methods: vec![
+ acp_v2::AuthMethod::Other(
+ acp_v2::OtherAuthMethod::new(
+ "_future_login",
+ Self::OTHER_AUTH_METHOD_ID,
+ "Future Login",
+ std::collections::BTreeMap::from([
+ ("args".into(), json!(["must-not-run"])),
+ ("details".into(), json!({"nested": [1, {"preserve": true}]})),
+ ]),
+ )
+ .description("Not supported by this client")
+ .meta(serde_json::Map::from_iter([(
+ "terminal-auth".into(),
+ json!({"command": "must-not-run", "args": ["login"]}),
+ )])),
+ ),
+ acp_v2::AuthMethod::Agent(
+ acp_v2::AuthMethodAgent::new(Self::AUTH_METHOD_ID, "Test Login")
+ .description("Sign in with the test provider")
+ .meta(serde_json::Map::from_iter([(
+ "fixture".into(),
+ json!({"nested": ["retain", 7]}),
+ )])),
+ ),
+ acp_v2::AuthMethod::Terminal(
+ acp_v2::AuthMethodTerminal::new(
+ Self::TERMINAL_AUTH_METHOD_ID,
+ "Terminal Login",
+ )
+ .description("Sign in with the terminal"),
+ ),
+ ],
+ authenticate_calls: Arc::new(Mutex::new(Vec::new())),
+ terminal_auth_calls: Arc::new(Mutex::new(Vec::new())),
}
}
}
@@ -8377,16 +8565,26 @@ pub(crate) mod tests {
})))
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
- std::slice::from_ref(&self.auth_method)
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
+ &self.auth_methods
+ }
+
+ fn terminal_auth_task(
+ &self,
+ method_id: &acp_v2::AuthMethodId,
+ _cx: &App,
+ ) -> Option<Task<Result<task::SpawnInTerminal>>> {
+ self.terminal_auth_calls.lock().push(method_id.clone());
+ None
}
fn authenticate(
&self,
- method_id: acp_v1::AuthMethodId,
+ method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
- if &method_id == self.auth_method.id() {
+ self.authenticate_calls.lock().push(method_id.clone());
+ if method_id == acp_v2::AuthMethodId::new(Self::AUTH_METHOD_ID) {
*self.authenticated.lock() = true;
Task::ready(Ok(()))
} else {
@@ -8460,13 +8658,13 @@ pub(crate) mod tests {
})))
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
unimplemented!()
@@ -8575,13 +8773,13 @@ pub(crate) mod tests {
Task::ready(Ok(thread))
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
Task::ready(Ok(()))
@@ -17139,13 +17337,13 @@ pub(crate) mod tests {
Task::ready(Ok(()))
}
- fn auth_methods(&self) -> &[acp_v1::AuthMethod] {
+ fn auth_methods(&self) -> &[acp_v2::AuthMethod] {
&[]
}
fn authenticate(
&self,
- _method_id: acp_v1::AuthMethodId,
+ _method_id: acp_v2::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
Task::ready(Ok(()))
diff --git a/crates/agent_ui/src/conversation_view/thread_view.rs b/crates/agent_ui/src/conversation_view/thread_view.rs
index 143e7f37233..937e574904f 100644
--- a/crates/agent_ui/src/conversation_view/thread_view.rs
+++ b/crates/agent_ui/src/conversation_view/thread_view.rs
@@ -1816,7 +1816,10 @@ impl ThreadView {
let text = text.trim();
if text == "/login" || text == "/logout" {
let connection = thread.read(cx).connection().clone();
- let can_login = !connection.auth_methods().is_empty();
+ let can_login = connection
+ .auth_methods()
+ .iter()
+ .any(acp_thread::auth_methods::is_supported);
// Does the agent have a specific logout command? Prefer that in case they need to reset internal state.
let logout_supported = text == "/logout"
&& self