Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
removed copilot from generated schema and command palette
Mikayla Maki47de4dcd327d
diff --git a/Cargo.lock b/Cargo.lockindex 38ba75f343c..b22d1710eb4 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -5952,6 +5952,7 @@ dependencies = ["serde_json","serde_path_to_error","sqlez",+ "staff_mode","theme","toml","tree-sitter",diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rsindex e0215af6226..93ab3553387 100644--- a/crates/copilot/src/copilot.rs+++ b/crates/copilot/src/copilot.rs@@ -18,7 +18,7 @@ use node_runtime::NodeRuntime;use request::{LogMessage, StatusNotification};use settings::Settings;use smol::{fs, io::BufReader, stream::StreamExt};-use staff_mode::staff_mode;+use staff_mode::{not_staff_mode, staff_mode};use std::{ffi::OsString,@@ -37,8 +37,13 @@ const COPILOT_NAMESPACE: &'static str = "copilot";actions!(copilot, [NextSuggestion, PreviousSuggestion, Reinstall]);pub fn init(client: Arc<Client>, node_runtime: Arc<NodeRuntime>, cx: &mut MutableAppContext) {- staff_mode(cx, {+ staff_mode::<staff_mode::Copilot, _>(cx, {move |cx| {+ 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();@@ -51,6 +56,12 @@ pub fn init(client: Arc<Client>, node_runtime: Arc<NodeRuntime>, cx: &mut Mutablsign_in::init(cx);}});+ not_staff_mode::<staff_mode::Copilot, _>(cx, |cx| {+ cx.update_global::<collections::CommandPaletteFilter, _, _>(|filter, _cx| {+ filter.filtered_namespaces.insert(COPILOT_NAMESPACE);+ filter.filtered_namespaces.insert(COPILOT_AUTH_NAMESPACE);+ });+ });cx.add_global_action(|_: &SignIn, cx| {if let Some(copilot) = Copilot::global(cx) {diff --git a/crates/settings/Cargo.toml b/crates/settings/Cargo.tomlindex 59728083966..fbb3ad63f34 100644--- a/crates/settings/Cargo.toml+++ b/crates/settings/Cargo.toml@@ -20,6 +20,7 @@ fs = { path = "../fs" }anyhow = "1.0.38"futures = "0.3"theme = { path = "../theme" }+staff_mode = { path = "../staff_mode" }util = { path = "../util" }json_comments = "0.2"postage = { workspace = true }diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rsindex 0988b2d6d9c..feb40170180 100644--- a/crates/settings/src/settings.rs+++ b/crates/settings/src/settings.rs@@ -177,6 +177,7 @@ pub struct EditorSettings {pub ensure_final_newline_on_save: Option<bool>,pub formatter: Option<Formatter>,pub enable_language_server: Option<bool>,+ #[schemars(skip)]pub copilot: Option<OnOff>,}@@ -436,6 +437,7 @@ pub struct SettingsFileContent {#[serde(default)]pub base_keymap: Option<BaseKeymap>,#[serde(default)]+ #[schemars(skip)]pub enable_copilot_integration: Option<bool>,}@@ -779,6 +781,7 @@ pub fn settings_file_json_schema(settings.option_add_null_type = false;});let generator = SchemaGenerator::new(settings);+let mut root_schema = generator.into_root_schema_for::<SettingsFileContent>();// Create a schema for a theme name.@@ -791,6 +794,7 @@ pub fn settings_file_json_schema(// Create a schema for a 'languages overrides' object, associating editor// settings with specific langauges.assert!(root_schema.definitions.contains_key("EditorSettings"));+let languages_object_schema = SchemaObject {instance_type: Some(SingleOrVec::Single(Box::new(InstanceType::Object))),object: Some(Box::new(ObjectValidation {diff --git a/crates/staff_mode/src/staff_mode.rs b/crates/staff_mode/src/staff_mode.rsindex 30f061466f8..bf5c0e9caf2 100644--- a/crates/staff_mode/src/staff_mode.rs+++ b/crates/staff_mode/src/staff_mode.rs@@ -11,12 +11,13 @@ impl std::ops::Deref for StaffMode {}}-/// Despite what the type system requires me to tell you, the init function will only ever be called once-pub fn staff_mode<F: FnMut(&mut MutableAppContext) + 'static>(+/// Despite what the type system requires me to tell you, the init function will only be called a once+/// as soon as we know that the staff mode is enabled.+pub fn staff_mode<S: StaffModeConfiguration, F: FnMut(&mut MutableAppContext) + 'static>(cx: &mut MutableAppContext,mut init: F,) {- if **cx.default_global::<StaffMode>() {+ if !S::staff_only() || **cx.default_global::<StaffMode>() {init(cx)} else {let mut once = Some(());@@ -28,3 +29,23 @@ pub fn staff_mode<F: FnMut(&mut MutableAppContext) + 'static>(.detach();}}++/// Immediately checks and runs the init function if the staff mode is not enabled.+pub fn not_staff_mode<S: StaffModeConfiguration, F: FnOnce(&mut MutableAppContext) + 'static>(+ cx: &mut MutableAppContext,+ init: F,+) {+ if !S::staff_only() || !**cx.default_global::<StaffMode>() {+ init(cx)+ }+}++pub trait StaffModeConfiguration {+ fn staff_only() -> bool {+ true+ }+}++pub enum Copilot {}++impl StaffModeConfiguration for Copilot {}