Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
acp: Simplify auth check and allow for custom /logout commands (#39867)
Ben Brandtf1d17fcfbef4
diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rsindex dc4809a4a3b..07a2366f989 100644--- a/crates/agent_ui/src/acp/thread_view.rs+++ b/crates/agent_ui/src/acp/thread_view.rs@@ -1046,32 +1046,33 @@ impl AcpThreadView {};let connection = thread.read(cx).connection().clone();- let auth_methods = connection.auth_methods();- let has_supported_auth = auth_methods.iter().any(|method| {- let id = method.id.0.as_ref();- id == "claude-login" || id == "spawn-gemini-cli"- });- let can_login = has_supported_auth || auth_methods.is_empty() || self.login.is_some();- if !can_login {+ let can_login = !connection.auth_methods().is_empty() || self.login.is_some();+ // Does the agent have a specific logout command? Prefer that in case they need to reset internal state.+ let logout_supported = text == "/logout"+ && self+ .available_commands+ .borrow()+ .iter()+ .any(|command| command.name == "logout");+ if can_login && !logout_supported {+ let this = cx.weak_entity();+ let agent = self.agent.clone();+ window.defer(cx, |window, cx| {+ Self::handle_auth_required(+ this,+ AuthRequired {+ description: None,+ provider_id: None,+ },+ agent,+ connection,+ window,+ cx,+ );+ });+ cx.notify();return;- };- let this = cx.weak_entity();- let agent = self.agent.clone();- window.defer(cx, |window, cx| {- Self::handle_auth_required(- this,- AuthRequired {- description: None,- provider_id: None,- },- agent,- connection,- window,- cx,- );- });- cx.notify();- return;+ }}self.send_impl(self.message_editor.clone(), window, cx)