Disable Copilot entirely for stable releases
This lets us remove the logic for detecting whether a user is a staff member.
This commit is contained in:
parent
781d065d0b
commit
15b26e10d4
4 changed files with 15 additions and 56 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1340,7 +1340,6 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-compression",
|
"async-compression",
|
||||||
"async-tar",
|
"async-tar",
|
||||||
"client",
|
|
||||||
"collections",
|
"collections",
|
||||||
"context_menu",
|
"context_menu",
|
||||||
"futures 0.3.25",
|
"futures 0.3.25",
|
||||||
|
@ -1353,7 +1352,6 @@ dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"settings",
|
"settings",
|
||||||
"smol",
|
"smol",
|
||||||
"staff_mode",
|
|
||||||
"theme",
|
"theme",
|
||||||
"util",
|
"util",
|
||||||
"workspace",
|
"workspace",
|
||||||
|
|
|
@ -10,7 +10,6 @@ doctest = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = [
|
test-support = [
|
||||||
"client/test-support",
|
|
||||||
"collections/test-support",
|
"collections/test-support",
|
||||||
"gpui/test-support",
|
"gpui/test-support",
|
||||||
"language/test-support",
|
"language/test-support",
|
||||||
|
@ -26,11 +25,9 @@ gpui = { path = "../gpui" }
|
||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
staff_mode = { path = "../staff_mode" }
|
|
||||||
lsp = { path = "../lsp" }
|
lsp = { path = "../lsp" }
|
||||||
node_runtime = { path = "../node_runtime"}
|
node_runtime = { path = "../node_runtime"}
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
client = { path = "../client" }
|
|
||||||
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
|
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
|
||||||
async-tar = "0.4.2"
|
async-tar = "0.4.2"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
@ -47,5 +44,4 @@ language = { path = "../language", features = ["test-support"] }
|
||||||
settings = { path = "../settings", features = ["test-support"] }
|
settings = { path = "../settings", features = ["test-support"] }
|
||||||
lsp = { path = "../lsp", features = ["test-support"] }
|
lsp = { path = "../lsp", features = ["test-support"] }
|
||||||
util = { path = "../util", features = ["test-support"] }
|
util = { path = "../util", features = ["test-support"] }
|
||||||
client = { path = "../client", features = ["test-support"] }
|
|
||||||
workspace = { path = "../workspace", features = ["test-support"] }
|
workspace = { path = "../workspace", features = ["test-support"] }
|
||||||
|
|
|
@ -4,7 +4,6 @@ mod sign_in;
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use async_compression::futures::bufread::GzipDecoder;
|
use async_compression::futures::bufread::GzipDecoder;
|
||||||
use async_tar::Archive;
|
use async_tar::Archive;
|
||||||
use client::Client;
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use futures::{future::Shared, Future, FutureExt, TryFutureExt};
|
use futures::{future::Shared, Future, FutureExt, TryFutureExt};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
|
@ -18,8 +17,6 @@ use node_runtime::NodeRuntime;
|
||||||
use request::{LogMessage, StatusNotification};
|
use request::{LogMessage, StatusNotification};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use smol::{fs, io::BufReader, stream::StreamExt};
|
use smol::{fs, io::BufReader, stream::StreamExt};
|
||||||
use staff_mode::{not_staff_mode, staff_mode};
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
|
@ -27,7 +24,8 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use util::{
|
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";
|
const COPILOT_AUTH_NAMESPACE: &'static str = "copilot_auth";
|
||||||
|
@ -36,33 +34,23 @@ actions!(copilot_auth, [SignIn, SignOut]);
|
||||||
const COPILOT_NAMESPACE: &'static str = "copilot";
|
const COPILOT_NAMESPACE: &'static str = "copilot";
|
||||||
actions!(copilot, [NextSuggestion, PreviousSuggestion, Reinstall]);
|
actions!(copilot, [NextSuggestion, PreviousSuggestion, Reinstall]);
|
||||||
|
|
||||||
pub fn init(client: Arc<Client>, node_runtime: Arc<NodeRuntime>, cx: &mut MutableAppContext) {
|
pub fn init(http: Arc<dyn HttpClient>, node_runtime: Arc<NodeRuntime>, cx: &mut MutableAppContext) {
|
||||||
staff_mode(cx, {
|
// Disable Copilot for stable releases.
|
||||||
move |cx| {
|
if *cx.global::<ReleaseChannel>() == ReleaseChannel::Stable {
|
||||||
cx.update_global::<collections::CommandPaletteFilter, _, _>(|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| {
|
|
||||||
cx.update_global::<collections::CommandPaletteFilter, _, _>(|filter, _cx| {
|
cx.update_global::<collections::CommandPaletteFilter, _, _>(|filter, _cx| {
|
||||||
filter.filtered_namespaces.insert(COPILOT_NAMESPACE);
|
filter.filtered_namespaces.insert(COPILOT_NAMESPACE);
|
||||||
filter.filtered_namespaces.insert(COPILOT_AUTH_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| {
|
cx.add_global_action(|_: &SignIn, cx| {
|
||||||
if let Some(copilot) = Copilot::global(cx) {
|
if let Some(copilot) = Copilot::global(cx) {
|
||||||
copilot
|
copilot
|
||||||
|
@ -87,29 +75,6 @@ pub fn init(client: Arc<Client>, node_runtime: Arc<NodeRuntime>, cx: &mut Mutabl
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn observe_namespaces(cx: &mut MutableAppContext, copilot: ModelHandle<Copilot>) {
|
|
||||||
cx.observe(&copilot, |handle, cx| {
|
|
||||||
let status = handle.read(cx).status();
|
|
||||||
cx.update_global::<collections::CommandPaletteFilter, _, _>(
|
|
||||||
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 {
|
enum CopilotServer {
|
||||||
Disabled,
|
Disabled,
|
||||||
Starting {
|
Starting {
|
||||||
|
|
|
@ -161,7 +161,7 @@ fn main() {
|
||||||
terminal_view::init(cx);
|
terminal_view::init(cx);
|
||||||
theme_testbench::init(cx);
|
theme_testbench::init(cx);
|
||||||
recent_projects::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))
|
cx.spawn(|cx| watch_themes(fs.clone(), themes.clone(), cx))
|
||||||
.detach();
|
.detach();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue