diff --git a/Cargo.lock b/Cargo.lock index b22d1710eb..754d7f72f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1340,7 +1340,6 @@ dependencies = [ "anyhow", "async-compression", "async-tar", - "client", "collections", "context_menu", "futures 0.3.25", @@ -1353,7 +1352,6 @@ dependencies = [ "serde_derive", "settings", "smol", - "staff_mode", "theme", "util", "workspace", diff --git a/crates/copilot/Cargo.toml b/crates/copilot/Cargo.toml index 1c37b6e298..9d68edd6b5 100644 --- a/crates/copilot/Cargo.toml +++ b/crates/copilot/Cargo.toml @@ -10,7 +10,6 @@ doctest = false [features] test-support = [ - "client/test-support", "collections/test-support", "gpui/test-support", "language/test-support", @@ -26,11 +25,9 @@ gpui = { path = "../gpui" } language = { path = "../language" } settings = { path = "../settings" } theme = { path = "../theme" } -staff_mode = { path = "../staff_mode" } lsp = { path = "../lsp" } node_runtime = { path = "../node_runtime"} util = { path = "../util" } -client = { path = "../client" } async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] } async-tar = "0.4.2" anyhow = "1.0" @@ -47,5 +44,4 @@ language = { path = "../language", features = ["test-support"] } settings = { path = "../settings", features = ["test-support"] } lsp = { path = "../lsp", features = ["test-support"] } util = { path = "../util", features = ["test-support"] } -client = { path = "../client", features = ["test-support"] } workspace = { path = "../workspace", features = ["test-support"] } diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index c0c5afc068..553da88cf1 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -4,7 +4,6 @@ mod sign_in; use anyhow::{anyhow, Context, Result}; use async_compression::futures::bufread::GzipDecoder; use async_tar::Archive; -use client::Client; use collections::HashMap; use futures::{future::Shared, Future, FutureExt, TryFutureExt}; use gpui::{ @@ -18,8 +17,6 @@ use node_runtime::NodeRuntime; use request::{LogMessage, StatusNotification}; use settings::Settings; use smol::{fs, io::BufReader, stream::StreamExt}; -use staff_mode::{not_staff_mode, staff_mode}; - use std::{ ffi::OsString, ops::Range, @@ -27,7 +24,8 @@ use std::{ sync::Arc, }; use util::{ - fs::remove_matching, github::latest_github_release, http::HttpClient, paths, ResultExt, + channel::ReleaseChannel, fs::remove_matching, github::latest_github_release, http::HttpClient, + paths, ResultExt, }; const COPILOT_AUTH_NAMESPACE: &'static str = "copilot_auth"; @@ -36,33 +34,23 @@ actions!(copilot_auth, [SignIn, SignOut]); const COPILOT_NAMESPACE: &'static str = "copilot"; actions!(copilot, [NextSuggestion, PreviousSuggestion, Reinstall]); -pub fn init(client: Arc, node_runtime: Arc, cx: &mut MutableAppContext) { - staff_mode(cx, { - move |cx| { - cx.update_global::(|filter, _cx| { - filter.filtered_namespaces.remove(COPILOT_NAMESPACE); - filter.filtered_namespaces.remove(COPILOT_AUTH_NAMESPACE); - }); - - let copilot = cx.add_model({ - let node_runtime = node_runtime.clone(); - let http = client.http_client().clone(); - move |cx| Copilot::start(http, node_runtime, cx) - }); - cx.set_global(copilot.clone()); - - observe_namespaces(cx, copilot); - - sign_in::init(cx); - } - }); - not_staff_mode(cx, |cx| { +pub fn init(http: Arc, node_runtime: Arc, cx: &mut MutableAppContext) { + // Disable Copilot for stable releases. + if *cx.global::() == ReleaseChannel::Stable { cx.update_global::(|filter, _cx| { filter.filtered_namespaces.insert(COPILOT_NAMESPACE); filter.filtered_namespaces.insert(COPILOT_AUTH_NAMESPACE); }); - }); + return; + } + let copilot = cx.add_model({ + let node_runtime = node_runtime.clone(); + move |cx| Copilot::start(http, node_runtime, cx) + }); + cx.set_global(copilot.clone()); + + sign_in::init(cx); cx.add_global_action(|_: &SignIn, cx| { if let Some(copilot) = Copilot::global(cx) { copilot @@ -87,29 +75,6 @@ pub fn init(client: Arc, node_runtime: Arc, cx: &mut Mutabl }); } -fn observe_namespaces(cx: &mut MutableAppContext, copilot: ModelHandle) { - cx.observe(&copilot, |handle, cx| { - let status = handle.read(cx).status(); - cx.update_global::( - move |filter, _cx| match status { - Status::Disabled => { - filter.filtered_namespaces.insert(COPILOT_NAMESPACE); - filter.filtered_namespaces.insert(COPILOT_AUTH_NAMESPACE); - } - Status::Authorized => { - filter.filtered_namespaces.remove(COPILOT_NAMESPACE); - filter.filtered_namespaces.remove(COPILOT_AUTH_NAMESPACE); - } - _ => { - filter.filtered_namespaces.insert(COPILOT_NAMESPACE); - filter.filtered_namespaces.remove(COPILOT_AUTH_NAMESPACE); - } - }, - ); - }) - .detach(); -} - enum CopilotServer { Disabled, Starting { diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index c2c9e7f232..fd7e0f22c7 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -161,7 +161,7 @@ fn main() { terminal_view::init(cx); theme_testbench::init(cx); recent_projects::init(cx); - copilot::init(client.clone(), node_runtime, cx); + copilot::init(http.clone(), node_runtime, cx); cx.spawn(|cx| watch_themes(fs.clone(), themes.clone(), cx)) .detach();