From 1fc57ea9f5b3219d7169ffd5536cc2f1cd14a4ad Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Sat, 3 May 2025 16:16:25 -0400 Subject: [PATCH] feature_flags: Add a constant to control Agent-related feature flags (#29853) This PR adds a singular constant that controls the Agent-related feature flags. This way we can tweak this one value when we're ready to build the final build for the launch. Release Notes: - N/A --- crates/feature_flags/src/feature_flags.rs | 31 +++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/crates/feature_flags/src/feature_flags.rs b/crates/feature_flags/src/feature_flags.rs index 9751dd4148..3bb05d5d4f 100644 --- a/crates/feature_flags/src/feature_flags.rs +++ b/crates/feature_flags/src/feature_flags.rs @@ -19,12 +19,11 @@ pub static ZED_DISABLE_STAFF: LazyLock = LazyLock::new(|| { impl FeatureFlags { fn has_flag(&self) -> bool { - if self.staff && T::enabled_for_staff() { + if T::enabled_for_all() { return true; } - #[cfg(debug_assertions)] - if T::enabled_in_development() { + if self.staff && T::enabled_for_staff() { return true; } @@ -48,21 +47,38 @@ pub trait FeatureFlag { true } - fn enabled_in_development() -> bool { - Self::enabled_for_staff() && !*ZED_DISABLE_STAFF + /// Returns whether this feature flag is enabled for everyone. + /// + /// This is generally done on the server, but we provide this as a way to entirely enable a feature flag client-side + /// without needing to remove all of the call sites. + fn enabled_for_all() -> bool { + false } } +/// Controls the values of various feature flags for the Agent launch. +/// +/// Change this to `true` when we're ready to build the release candidate. +const AGENT_LAUNCH: bool = false; + pub struct Assistant2FeatureFlag; impl FeatureFlag for Assistant2FeatureFlag { const NAME: &'static str = "assistant2"; + + fn enabled_for_all() -> bool { + AGENT_LAUNCH + } } pub struct AgentStreamEditsFeatureFlag; impl FeatureFlag for AgentStreamEditsFeatureFlag { const NAME: &'static str = "agent-stream-edits"; + + fn enabled_for_all() -> bool { + AGENT_LAUNCH + } } pub struct NewBillingFeatureFlag; @@ -70,8 +86,8 @@ pub struct NewBillingFeatureFlag; impl FeatureFlag for NewBillingFeatureFlag { const NAME: &'static str = "new-billing"; - fn enabled_for_staff() -> bool { - false + fn enabled_for_all() -> bool { + AGENT_LAUNCH } } @@ -144,7 +160,6 @@ where if self .try_global::() .is_some_and(|f| f.has_flag::()) - || cfg!(debug_assertions) && T::enabled_in_development() { self.defer_in(window, move |view, window, cx| { callback(view, window, cx);