Move UI for copilot sign in to copilot_button

Piotr Osiewicz created

Change summary

Cargo.lock                                  | 2 +-
crates/copilot/Cargo.toml                   | 1 -
crates/copilot/src/copilot.rs               | 3 ---
crates/copilot_button/Cargo.toml            | 1 +
crates/copilot_button/src/copilot_button.rs | 6 ++++++
crates/copilot_button/src/sign_in.rs        | 3 ++-
crates/zed/src/main.rs                      | 1 +
7 files changed, 11 insertions(+), 6 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -1684,7 +1684,6 @@ dependencies = [
  "settings",
  "smol",
  "theme",
- "ui",
  "util",
 ]
 
@@ -1702,6 +1701,7 @@ dependencies = [
  "settings",
  "smol",
  "theme",
+ "ui",
  "util",
  "workspace",
  "zed_actions",

crates/copilot/Cargo.toml 🔗

@@ -28,7 +28,6 @@ theme = { path = "../theme" }
 lsp = { path = "../lsp" }
 node_runtime = { path = "../node_runtime"}
 util = { path = "../util" }
-ui = { path = "../ui" }
 async-compression.workspace = true
 async-tar = "0.4.2"
 anyhow.workspace = true

crates/copilot/src/copilot.rs 🔗

@@ -1,6 +1,4 @@
 pub mod request;
-mod sign_in;
-
 use anyhow::{anyhow, Context as _, Result};
 use async_compression::futures::bufread::GzipDecoder;
 use async_tar::Archive;
@@ -98,7 +96,6 @@ pub fn init(
     })
     .detach();
 
-    sign_in::init(cx);
     cx.on_action(|_: &SignIn, cx| {
         if let Some(copilot) = Copilot::global(cx) {
             copilot

crates/copilot_button/Cargo.toml 🔗

@@ -17,6 +17,7 @@ gpui = { path = "../gpui" }
 language = { path = "../language" }
 settings = { path = "../settings" }
 theme = { path = "../theme" }
+ui = { path = "../ui" }
 util = { path = "../util" }
 workspace = {path = "../workspace" }
 anyhow.workspace = true

crates/copilot_button/src/copilot_button.rs 🔗

@@ -1,3 +1,5 @@
+mod sign_in;
+
 use anyhow::Result;
 use copilot::{Copilot, SignOut, Status};
 use editor::{scroll::autoscroll::Autoscroll, Editor};
@@ -25,6 +27,10 @@ const COPILOT_SETTINGS_URL: &str = "https://github.com/settings/copilot";
 const COPILOT_STARTING_TOAST_ID: usize = 1337;
 const COPILOT_ERROR_TOAST_ID: usize = 1338;
 
+pub fn init(cx: &mut AppContext) {
+    sign_in::init(cx);
+}
+
 pub struct CopilotButton {
     editor_subscription: Option<(Subscription, usize)>,
     editor_enabled: Option<bool>,

crates/copilot/src/sign_in.rs → crates/copilot_button/src/sign_in.rs 🔗

@@ -1,4 +1,4 @@
-use crate::{request::PromptUserDeviceFlow, Copilot, Status};
+use copilot::{request::PromptUserDeviceFlow, Copilot, Status};
 use gpui::{
     div, size, svg, AppContext, Bounds, ClipboardItem, Element, GlobalPixels, InteractiveElement,
     IntoElement, ParentElement, Point, Render, Styled, ViewContext, VisualContext, WindowBounds,
@@ -80,6 +80,7 @@ pub struct CopilotCodeVerification {
     connect_clicked: bool,
 }
 
+//impl ModalView for CopilotCodeVerification {}
 impl CopilotCodeVerification {
     pub fn new(status: Status) -> Self {
         Self {

crates/zed/src/main.rs 🔗

@@ -158,6 +158,7 @@ fn main() {
             node_runtime.clone(),
             cx,
         );
+        copilot_button::init(cx);
         assistant::init(cx);
 
         cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))