Remove llm_provider_authenticate()

Richard Feldman created

Change summary

crates/extension_api/src/extension_api.rs           | 11 --
crates/extension_api/wit/since_v0.8.0/extension.wit |  6 -
crates/extension_host/src/wasm_host/llm_provider.rs | 58 +-------------
crates/extension_host/src/wasm_host/wit.rs          | 11 --
extensions/anthropic/src/anthropic.rs               |  8 --
extensions/copilot-chat/src/copilot_chat.rs         | 12 ---
extensions/google-ai/src/google_ai.rs               |  8 --
extensions/open-router/src/open_router.rs           |  8 --
extensions/openai/src/openai.rs                     |  8 --
9 files changed, 6 insertions(+), 124 deletions(-)

Detailed changes

crates/extension_api/src/extension_api.rs 🔗

@@ -302,13 +302,6 @@ pub trait Extension: Send + Sync {
         false
     }
 
-    /// Attempt to authenticate the provider.
-    /// This is called for background credential checks - it should check for
-    /// existing credentials and return Ok if found, or an error if not.
-    fn llm_provider_authenticate(&mut self, _provider_id: &str) -> Result<(), String> {
-        Err("`llm_provider_authenticate` not implemented".to_string())
-    }
-
     /// Start an OAuth device flow sign-in.
     /// This is called when the user explicitly clicks "Sign in with GitHub" or similar.
     /// Opens the browser to the verification URL and returns the user code that should
@@ -651,10 +644,6 @@ impl wit::Guest for Component {
         extension().llm_provider_is_authenticated(&provider_id)
     }
 
-    fn llm_provider_authenticate(provider_id: String) -> Result<(), String> {
-        extension().llm_provider_authenticate(&provider_id)
-    }
-
     fn llm_provider_start_device_flow_sign_in(provider_id: String) -> Result<String, String> {
         extension().llm_provider_start_device_flow_sign_in(&provider_id)
     }

crates/extension_api/wit/since_v0.8.0/extension.wit 🔗

@@ -183,12 +183,6 @@ world extension {
     /// Check if the provider is authenticated.
     export llm-provider-is-authenticated: func(provider-id: string) -> bool;
 
-    /// Attempt to authenticate the provider.
-    /// This is called for background credential checks - it should check for
-    /// existing credentials and return Ok if found, or an error if not.
-    /// For interactive OAuth flows, use the device flow functions instead.
-    export llm-provider-authenticate: func(provider-id: string) -> result<_, string>;
-
     /// Start an OAuth device flow sign-in.
     /// This is called when the user explicitly clicks "Sign in with GitHub" or similar.
     ///

crates/extension_host/src/wasm_host/llm_provider.rs 🔗

@@ -206,59 +206,13 @@ impl LanguageModelProvider for ExtensionLanguageModelProvider {
     }
 
     fn authenticate(&self, cx: &mut App) -> Task<Result<(), AuthenticateError>> {
-        let extension = self.extension.clone();
-        let provider_id = self.provider_info.id.clone();
-        let state = self.state.clone();
-
-        cx.spawn(async move |cx| {
-            let result = extension
-                .call({
-                    let provider_id = provider_id.clone();
-                    |extension, store| {
-                        async move {
-                            extension
-                                .call_llm_provider_authenticate(store, &provider_id)
-                                .await
-                        }
-                        .boxed()
-                    }
-                })
-                .await;
-
-            match result {
-                Ok(Ok(Ok(()))) => {
-                    // After successful auth, refresh the models list
-                    let models_result = extension
-                        .call({
-                            let provider_id = provider_id.clone();
-                            |ext, store| {
-                                async move {
-                                    ext.call_llm_provider_models(store, &provider_id).await
-                                }
-                                .boxed()
-                            }
-                        })
-                        .await;
-
-                    let new_models: Vec<LlmModelInfo> = match models_result {
-                        Ok(Ok(Ok(models))) => models,
-                        _ => Vec::new(),
-                    };
+        // Check if already authenticated via is_authenticated
+        if self.is_authenticated(cx) {
+            return Task::ready(Ok(()));
+        }
 
-                    cx.update(|cx| {
-                        state.update(cx, |state, cx| {
-                            state.is_authenticated = true;
-                            state.available_models = new_models;
-                            cx.notify();
-                        });
-                    })?;
-                    Ok(())
-                }
-                Ok(Ok(Err(e))) => Err(AuthenticateError::Other(anyhow!("{}", e))),
-                Ok(Err(e)) => Err(AuthenticateError::Other(e)),
-                Err(e) => Err(AuthenticateError::Other(e)),
-            }
-        })
+        // Not authenticated - return error indicating credentials not found
+        Task::ready(Err(AuthenticateError::CredentialsNotFound))
     }
 
     fn configuration_view(

crates/extension_host/src/wasm_host/wit.rs 🔗

@@ -1230,17 +1230,6 @@ impl Extension {
         }
     }
 
-    pub async fn call_llm_provider_authenticate(
-        &self,
-        store: &mut Store<WasmState>,
-        provider_id: &str,
-    ) -> Result<Result<(), String>> {
-        match self {
-            Extension::V0_8_0(ext) => ext.call_llm_provider_authenticate(store, provider_id).await,
-            _ => anyhow::bail!("`llm_provider_authenticate` not available prior to v0.8.0"),
-        }
-    }
-
     pub async fn call_llm_provider_start_device_flow_sign_in(
         &self,
         store: &mut Store<WasmState>,

extensions/anthropic/src/anthropic.rs 🔗

@@ -521,14 +521,6 @@ impl zed::Extension for AnthropicProvider {
         llm_get_credential("anthropic").is_some()
     }
 
-    fn llm_provider_authenticate(&mut self, _provider_id: &str) -> Result<(), String> {
-        if llm_get_credential("anthropic").is_some() {
-            Ok(())
-        } else {
-            Err("No API key configured".to_string())
-        }
-    }
-
     fn llm_provider_settings_markdown(&self, _provider_id: &str) -> Option<String> {
         Some(
             "To use Anthropic, you need an API key. You can create one [here](https://console.anthropic.com/settings/keys).".to_string(),

extensions/copilot-chat/src/copilot_chat.rs 🔗

@@ -451,18 +451,6 @@ impl zed::Extension for CopilotChatProvider {
         )
     }
 
-    fn llm_provider_authenticate(&mut self, _provider_id: &str) -> Result<(), String> {
-        // Check if we have existing credentials
-        if llm_get_credential("copilot-chat").is_some() {
-            return Ok(());
-        }
-
-        // No credentials found - return error for background auth checks.
-        // The device flow will be triggered by the host when the user clicks
-        // the "Sign in with GitHub" button, which calls llm_provider_start_device_flow_sign_in.
-        Err("CredentialsNotFound".to_string())
-    }
-
     fn llm_provider_start_device_flow_sign_in(
         &mut self,
         _provider_id: &str,

extensions/google-ai/src/google_ai.rs 🔗

@@ -598,14 +598,6 @@ impl zed::Extension for GoogleAiProvider {
         llm_get_credential("google-ai").is_some()
     }
 
-    fn llm_provider_authenticate(&mut self, _provider_id: &str) -> Result<(), String> {
-        if llm_get_credential("google-ai").is_some() {
-            Ok(())
-        } else {
-            Err("No API key configured".to_string())
-        }
-    }
-
     fn llm_provider_settings_markdown(&self, _provider_id: &str) -> Option<String> {
         Some(
             "To use Google AI, you need an API key. You can create one [here](https://aistudio.google.com/apikey).".to_string(),

extensions/open-router/src/open_router.rs 🔗

@@ -566,14 +566,6 @@ impl zed::Extension for OpenRouterProvider {
         llm_get_credential("open_router").is_some()
     }
 
-    fn llm_provider_authenticate(&mut self, _provider_id: &str) -> Result<(), String> {
-        if llm_get_credential("open_router").is_some() {
-            Ok(())
-        } else {
-            Err("No API key configured".to_string())
-        }
-    }
-
     fn llm_provider_settings_markdown(&self, _provider_id: &str) -> Option<String> {
         Some(
             "To use OpenRouter, you need an API key. You can create one [here](https://openrouter.ai/keys).".to_string(),

extensions/openai/src/openai.rs 🔗

@@ -476,14 +476,6 @@ impl zed::Extension for OpenAiProvider {
         llm_get_credential("openai").is_some()
     }
 
-    fn llm_provider_authenticate(&mut self, _provider_id: &str) -> Result<(), String> {
-        if llm_get_credential("openai").is_some() {
-            Ok(())
-        } else {
-            Err("No API key configured".to_string())
-        }
-    }
-
     fn llm_provider_settings_markdown(&self, _provider_id: &str) -> Option<String> {
         Some(
             "To use OpenAI, you need an API key. You can create one [here](https://platform.openai.com/api-keys).".to_string(),