Revise Copilot auth

Richard Feldman created

Change summary

crates/extension/src/extension_manifest.rs          |  3 +
crates/extension_host/src/extension_host.rs         |  8 ----
crates/extension_host/src/wasm_host/llm_provider.rs | 25 ++++++++++++---
extensions/copilot-chat/extension.toml              |  7 +--
4 files changed, 27 insertions(+), 16 deletions(-)

Detailed changes

crates/extension/src/extension_manifest.rs 🔗

@@ -350,6 +350,9 @@ pub struct OAuthConfig {
     /// The text to display on the sign-in button (e.g., "Sign in with GitHub").
     #[serde(default)]
     pub sign_in_button_label: Option<String>,
+    /// The icon to display on the sign-in button (e.g., "github").
+    #[serde(default)]
+    pub sign_in_button_icon: Option<String>,
 }
 
 impl ExtensionManifest {

crates/extension_host/src/extension_host.rs 🔗

@@ -58,7 +58,7 @@ use std::{
     cmp::Ordering,
     path::{self, Path, PathBuf},
     sync::Arc,
-    time::{Duration, Instant},
+    time::Duration,
 };
 use url::Url;
 use util::{ResultExt, paths::RemotePathBuf};
@@ -1298,11 +1298,6 @@ impl ExtensionStore {
             return Task::ready(());
         }
 
-        let reload_count = extensions_to_unload
-            .iter()
-            .filter(|id| extensions_to_load.contains(id))
-            .count();
-
         let extension_ids = extensions_to_load
             .iter()
             .filter_map(|id| {
@@ -1786,7 +1781,6 @@ impl ExtensionStore {
         let index_path = self.index_path.clone();
         let proxy = self.proxy.clone();
         cx.background_spawn(async move {
-            let start_time = Instant::now();
             let mut index = ExtensionIndex::default();
 
             fs.create_dir(&work_dir).await.log_err();

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

@@ -891,6 +891,12 @@ impl gpui::Render for ExtensionProviderConfigurationView {
                 let button_label = oauth_config
                     .and_then(|c| c.sign_in_button_label.clone())
                     .unwrap_or_else(|| "Sign In".to_string());
+                let button_icon = oauth_config
+                    .and_then(|c| c.sign_in_button_icon.as_ref())
+                    .and_then(|icon_name| match icon_name.as_str() {
+                        "github" => Some(ui::IconName::Github),
+                        _ => None,
+                    });
 
                 let oauth_in_progress = self.oauth_in_progress;
 
@@ -899,14 +905,23 @@ impl gpui::Render for ExtensionProviderConfigurationView {
                 content = content.child(
                     v_flex()
                         .gap_2()
-                        .child(
-                            ui::Button::new("oauth-sign-in", button_label)
-                                .style(ui::ButtonStyle::Filled)
+                        .child({
+                            let mut button = ui::Button::new("oauth-sign-in", button_label)
+                                .full_width()
+                                .style(ui::ButtonStyle::Outlined)
                                 .disabled(oauth_in_progress)
                                 .on_click(cx.listener(|this, _, _window, cx| {
                                     this.start_oauth_sign_in(cx);
-                                })),
-                        )
+                                }));
+                            if let Some(icon) = button_icon {
+                                button = button
+                                    .icon(icon)
+                                    .icon_position(ui::IconPosition::Start)
+                                    .icon_size(ui::IconSize::Small)
+                                    .icon_color(Color::Muted);
+                            }
+                            button
+                        })
                         .when(oauth_in_progress, |this| {
                             let user_code = self.device_user_code.clone();
                             this.child(

extensions/copilot-chat/extension.toml 🔗

@@ -8,9 +8,8 @@ repository = "https://github.com/zed-industries/zed"
 
 [language_model_providers.copilot-chat]
 name = "Copilot Chat"
-
-[language_model_providers.copilot-chat.auth]
-env_var = "GH_COPILOT_TOKEN"
+icon = "icons/copilot.svg"
 
 [language_model_providers.copilot-chat.auth.oauth]
-sign_in_button_label = "Sign in with GitHub"
+sign_in_button_label = "Sign in to use GitHub Copilot"
+sign_in_button_icon = "github"