feature_flags: Move feature flag definitions to their own module (#37956)

This PR moves the feature flag definitions to their own module so that
they aren't intermingled with the feature flag infrastructure itself.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2025-09-11 02:43:19 +00:00
committed by GitHub
parent f205732074
commit 9708c8d507
2 changed files with 64 additions and 57 deletions
+8 -57
View File
@@ -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) -> Subscription
where
+56
View File
@@ -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
}
}