Add option to sign in to copilot from welcome screen (#8853)

Joseph T. Lyons created

Fixes: https://github.com/zed-industries/zed/issues/8851


https://github.com/zed-industries/zed/assets/19867440/5d391289-34e8-4abc-9337-b7e253f4e513

Release Notes:

- Added GitHub Copilot sign in on welcome screen
([#8851](https://github.com/zed-industries/zed/issues/8851)).

Change summary

Cargo.lock                              |  1 +
crates/copilot_ui/src/copilot_button.rs |  2 +-
crates/copilot_ui/src/copilot_ui.rs     |  2 +-
crates/welcome/Cargo.toml               |  1 +
crates/welcome/src/welcome.rs           | 11 +++++++++++
5 files changed, 15 insertions(+), 2 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -11937,6 +11937,7 @@ version = "0.1.0"
 dependencies = [
  "anyhow",
  "client",
+ "copilot_ui",
  "db",
  "editor",
  "fuzzy",

crates/copilot_ui/src/copilot_button.rs 🔗

@@ -332,7 +332,7 @@ fn hide_copilot(fs: Arc<dyn Fs>, cx: &mut AppContext) {
     });
 }
 
-fn initiate_sign_in(cx: &mut WindowContext) {
+pub fn initiate_sign_in(cx: &mut WindowContext) {
     let Some(copilot) = Copilot::global(cx) else {
         return;
     };

crates/welcome/Cargo.toml 🔗

@@ -14,6 +14,7 @@ test-support = []
 [dependencies]
 anyhow.workspace = true
 client.workspace = true
+copilot_ui.workspace = true
 db.workspace = true
 fuzzy.workspace = true
 gpui.workspace = true

crates/welcome/src/welcome.rs 🔗

@@ -2,6 +2,7 @@ mod base_keymap_picker;
 mod base_keymap_setting;
 
 use client::{telemetry::Telemetry, TelemetrySettings};
+use copilot_ui;
 use db::kvp::KEY_VALUE_STORE;
 use gpui::{
     svg, AnyElement, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement,
@@ -134,6 +135,16 @@ impl Render for WelcomePage {
                                             })
                                             .detach_and_log_err(cx);
                                     })),
+                            )
+                            .child(
+                                Button::new("sign-in-to-copilot", "Sign in to GitHub Copilot")
+                                    .full_width()
+                                    .on_click(cx.listener(|this, _, cx| {
+                                        this.telemetry.report_app_event(
+                                            "welcome page: sign in to copilot".to_string(),
+                                        );
+                                        copilot_ui::initiate_sign_in(cx);
+                                    })),
                             ),
                     )
                     .child(