From 7633bbf55a79d29acd9feb330f17f323a9de800f Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Wed, 3 Sep 2025 14:08:48 +0200 Subject: [PATCH] acp: Fix issue with claude code /logout command (#37452) ### First issue In the scenario where you have an API key configured in Zed and you run `/logout`, clicking on `Use Anthropic API Key` would show `Method not implemented`. This happened because we were only intercepting the `Use Anthropic API Key` click if the provider was NOT authenticated, which would not be the case when the user has an API key set. ### Second issue When clicking on `Reset API Key` the modal would be dismissed even though you picked no Authentication Method (which means you still would be unauthenticated) --- This PR fixes both of these issues Release Notes: - N/A --- crates/agent_ui/src/acp/thread_view.rs | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 589633ae250580f6eb66a513534c79a898fdc0d6..992e12177abe144b1ba00b7a5e2a9c8806866593 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -666,6 +666,10 @@ impl AcpThreadView { move |_, ev, window, cx| { if let language_model::Event::ProviderStateChanged(updated_provider_id) = &ev && &provider_id == updated_provider_id + && LanguageModelRegistry::global(cx) + .read(cx) + .provider(&provider_id) + .map_or(false, |provider| provider.is_authenticated(cx)) { this.update(cx, |this, cx| { this.thread_state = Self::initial_state( @@ -1365,11 +1369,11 @@ impl AcpThreadView { .read(cx) .provider(&language_model::ANTHROPIC_PROVIDER_ID) .unwrap(); - if !provider.is_authenticated(cx) { - let this = cx.weak_entity(); - let agent = self.agent.clone(); - let connection = connection.clone(); - window.defer(cx, |window, cx| { + let this = cx.weak_entity(); + let agent = self.agent.clone(); + let connection = connection.clone(); + window.defer(cx, move |window, cx| { + if !provider.is_authenticated(cx) { Self::handle_auth_required( this, AuthRequired { @@ -1381,9 +1385,21 @@ impl AcpThreadView { window, cx, ); - }); - return; - } + } else { + this.update(cx, |this, cx| { + this.thread_state = Self::initial_state( + agent, + None, + this.workspace.clone(), + this.project.clone(), + window, + cx, + ) + }) + .ok(); + } + }); + return; } else if method.0.as_ref() == "vertex-ai" && std::env::var("GOOGLE_API_KEY").is_err() && (std::env::var("GOOGLE_CLOUD_PROJECT").is_err()