Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
feature_flags: Move feature flag definitions to their own module (#37956)
Marshall Bowers9708c8d50797
diff --git a/crates/feature_flags/src/feature_flags.rs b/crates/feature_flags/src/feature_flags.rsindex b97abac59c3..1b66b291b52 100644--- a/crates/feature_flags/src/feature_flags.rs+++ b/crates/feature_flags/src/feature_flags.rs@@ -1,12 +1,17 @@-use futures::channel::oneshot;-use futures::{FutureExt, select_biased};-use gpui::{App, Context, Global, Subscription, Task, Window};+mod flags;+use std::cell::RefCell;use std::rc::Rc;use std::sync::LazyLock;use std::time::Duration;use std::{future::Future, pin::Pin, task::Poll};+use futures::channel::oneshot;+use futures::{FutureExt, select_biased};+use gpui::{App, Context, Global, Subscription, Task, Window};++pub use flags::*;+#[derive(Default)]struct FeatureFlags {flags: Vec<String>,@@ -56,60 +61,6 @@ pub trait FeatureFlag {}}-pub struct PredictEditsRateCompletionsFeatureFlag;-impl FeatureFlag for PredictEditsRateCompletionsFeatureFlag {- const NAME: &'static str = "predict-edits-rate-completions";-}--pub struct BillingV2FeatureFlag {}--impl FeatureFlag for BillingV2FeatureFlag {- const NAME: &'static str = "billing-v2";-}--pub struct NotebookFeatureFlag;--impl FeatureFlag for NotebookFeatureFlag {- const NAME: &'static str = "notebooks";-}--pub struct PanicFeatureFlag;--impl FeatureFlag for PanicFeatureFlag {- const NAME: &'static str = "panic";-}--pub struct JjUiFeatureFlag {}--impl FeatureFlag for JjUiFeatureFlag {- const NAME: &'static str = "jj-ui";-}--pub struct GeminiAndNativeFeatureFlag;--impl FeatureFlag for GeminiAndNativeFeatureFlag {- // This was previously called "acp".- //- // We renamed it because existing builds used it to enable the Claude Code- // integration too, and we'd like to turn Gemini/Native on in new builds- // without enabling Claude Code in old builds.- const NAME: &'static str = "gemini-and-native";-- fn enabled_for_all() -> bool {- true- }-}--pub struct ClaudeCodeFeatureFlag;--impl FeatureFlag for ClaudeCodeFeatureFlag {- const NAME: &'static str = "claude-code";-- fn enabled_for_all() -> bool {- true- }-}-pub trait FeatureFlagViewExt<V: 'static> {fn observe_flag<T: FeatureFlag, F>(&mut self, window: &Window, callback: F) -> Subscriptionwherediff --git a/crates/feature_flags/src/flags.rs b/crates/feature_flags/src/flags.rsnew file mode 100644index 00000000000..2278848a194--- /dev/null+++ b/crates/feature_flags/src/flags.rs@@ -0,0 +1,56 @@+use crate::FeatureFlag;++pub struct PredictEditsRateCompletionsFeatureFlag;++impl FeatureFlag for PredictEditsRateCompletionsFeatureFlag {+ const NAME: &'static str = "predict-edits-rate-completions";+}++pub struct BillingV2FeatureFlag {}++impl FeatureFlag for BillingV2FeatureFlag {+ const NAME: &'static str = "billing-v2";+}++pub struct NotebookFeatureFlag;++impl FeatureFlag for NotebookFeatureFlag {+ const NAME: &'static str = "notebooks";+}++pub struct PanicFeatureFlag;++impl FeatureFlag for PanicFeatureFlag {+ const NAME: &'static str = "panic";+}++pub struct JjUiFeatureFlag {}++impl FeatureFlag for JjUiFeatureFlag {+ const NAME: &'static str = "jj-ui";+}++pub struct GeminiAndNativeFeatureFlag;++impl FeatureFlag for GeminiAndNativeFeatureFlag {+ // This was previously called "acp".+ //+ // We renamed it because existing builds used it to enable the Claude Code+ // integration too, and we'd like to turn Gemini/Native on in new builds+ // without enabling Claude Code in old builds.+ const NAME: &'static str = "gemini-and-native";++ fn enabled_for_all() -> bool {+ true+ }+}++pub struct ClaudeCodeFeatureFlag;++impl FeatureFlag for ClaudeCodeFeatureFlag {+ const NAME: &'static str = "claude-code";++ fn enabled_for_all() -> bool {+ true+ }+}