diff --git a/Cargo.lock b/Cargo.lock index bb860f669acc5aea09ee382cbc97dec2e102b196..4a273b97345e64e7a5e6e8cbdd69e35148d06055 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21781,6 +21781,7 @@ dependencies = [ "cloud_zeta2_prompt", "edit_prediction", "edit_prediction_context", + "feature_flags", "futures 0.3.31", "gpui", "indoc", @@ -21813,6 +21814,7 @@ dependencies = [ "collections", "edit_prediction_context", "editor", + "feature_flags", "futures 0.3.31", "gpui", "indoc", diff --git a/crates/zed/src/zed/edit_prediction_registry.rs b/crates/zed/src/zed/edit_prediction_registry.rs index a9bd0395347dadcb9caa706fcbcc81f58d6af944..fd16478b5a7ade4b8ef86924d2ce737cb2f62c56 100644 --- a/crates/zed/src/zed/edit_prediction_registry.rs +++ b/crates/zed/src/zed/edit_prediction_registry.rs @@ -3,6 +3,7 @@ use codestral::CodestralCompletionProvider; use collections::HashMap; use copilot::{Copilot, CopilotCompletionProvider}; use editor::Editor; +use feature_flags::FeatureFlagAppExt; use gpui::{AnyWindowHandle, App, AppContext as _, Context, Entity, WeakEntity}; use language::language_settings::{EditPredictionProvider, all_language_settings}; use language_models::MistralLanguageModelProvider; @@ -11,6 +12,7 @@ use std::{cell::RefCell, rc::Rc, sync::Arc}; use supermaven::{Supermaven, SupermavenCompletionProvider}; use ui::Window; use zeta::ZetaEditPredictionProvider; +use zeta2::Zeta2FeatureFlag; pub fn init(client: Arc, user_store: Entity, cx: &mut App) { let editors: Rc, AnyWindowHandle>>> = Rc::default(); @@ -217,7 +219,7 @@ fn assign_edit_prediction_provider( } if let Some(project) = editor.project() { - if std::env::var("ZED_ZETA2").is_ok() { + if cx.has_flag::() { let zeta = zeta2::Zeta::global(client, &user_store, cx); let provider = cx.new(|cx| { zeta2::ZetaEditPredictionProvider::new( diff --git a/crates/zeta2/Cargo.toml b/crates/zeta2/Cargo.toml index 2342d062979f459c23441d8a57c0a640f5ce41b2..f2ab34b2fb80036ff1e29393f2e9eaac1f85f444 100644 --- a/crates/zeta2/Cargo.toml +++ b/crates/zeta2/Cargo.toml @@ -20,6 +20,7 @@ cloud_llm_client.workspace = true cloud_zeta2_prompt.workspace = true edit_prediction.workspace = true edit_prediction_context.workspace = true +feature_flags.workspace = true futures.workspace = true gpui.workspace = true indoc.workspace = true diff --git a/crates/zeta2/src/zeta2.rs b/crates/zeta2/src/zeta2.rs index 2e07122d26e55ec7bd716a18d0a2cee210c4a584..6e92443b8b4c91ce6bb168d3c87ce4ddce49bc35 100644 --- a/crates/zeta2/src/zeta2.rs +++ b/crates/zeta2/src/zeta2.rs @@ -11,6 +11,7 @@ use edit_prediction_context::{ DeclarationId, DeclarationStyle, EditPredictionContext, EditPredictionContextOptions, EditPredictionExcerptOptions, EditPredictionScoreOptions, SyntaxIndex, SyntaxIndexState, }; +use feature_flags::FeatureFlag; use futures::AsyncReadExt as _; use futures::channel::{mpsc, oneshot}; use gpui::http_client::{AsyncBody, Method}; @@ -66,6 +67,16 @@ pub const DEFAULT_OPTIONS: ZetaOptions = ZetaOptions { file_indexing_parallelism: 1, }; +pub struct Zeta2FeatureFlag; + +impl FeatureFlag for Zeta2FeatureFlag { + const NAME: &'static str = "zeta2"; + + fn enabled_for_staff() -> bool { + false + } +} + #[derive(Clone)] struct ZetaGlobal(Entity); diff --git a/crates/zeta2_tools/Cargo.toml b/crates/zeta2_tools/Cargo.toml index c600b3b86e4f3f8477431275d7f85591ccb22ac7..1cc9fa561a5cad964e2ef9617aaf9dde67407faf 100644 --- a/crates/zeta2_tools/Cargo.toml +++ b/crates/zeta2_tools/Cargo.toml @@ -18,6 +18,7 @@ cloud_llm_client.workspace = true collections.workspace = true edit_prediction_context.workspace = true editor.workspace = true +feature_flags.workspace = true futures.workspace = true gpui.workspace = true language.workspace = true diff --git a/crates/zeta2_tools/src/zeta2_tools.rs b/crates/zeta2_tools/src/zeta2_tools.rs index 0834fd18d8da9ff63b5de8ca19d7b5584425972b..005a3f1e48b56332d83aa127781f6dd5d95daa0d 100644 --- a/crates/zeta2_tools/src/zeta2_tools.rs +++ b/crates/zeta2_tools/src/zeta2_tools.rs @@ -8,6 +8,7 @@ use client::{Client, UserStore}; use cloud_llm_client::predict_edits_v3::{DeclarationScoreComponents, PromptFormat}; use collections::HashMap; use editor::{Editor, EditorEvent, EditorMode, ExcerptRange, MultiBuffer}; +use feature_flags::FeatureFlagAppExt as _; use futures::{StreamExt as _, channel::oneshot}; use gpui::{ CursorStyle, Entity, EventEmitter, FocusHandle, Focusable, Subscription, Task, WeakEntity, @@ -20,7 +21,7 @@ use ui::{ContextMenu, ContextMenuEntry, DropdownMenu, prelude::*}; use ui_input::SingleLineInput; use util::{ResultExt, paths::PathStyle, rel_path::RelPath}; use workspace::{Item, SplitDirection, Workspace}; -use zeta2::{PredictionDebugInfo, Zeta, ZetaOptions}; +use zeta2::{PredictionDebugInfo, Zeta, Zeta2FeatureFlag, ZetaOptions}; use edit_prediction_context::{ DeclarationStyle, EditPredictionContextOptions, EditPredictionExcerptOptions, @@ -676,17 +677,25 @@ impl Zeta2Inspector { } fn render_content(&self, cx: &mut Context) -> AnyElement { + if !cx.has_flag::() { + return Self::render_message("`zeta2` feature flag is not enabled"); + } + match self.last_prediction.as_ref() { - None => v_flex() - .size_full() - .justify_center() - .items_center() - .child(Label::new("No prediction").size(LabelSize::Large)) - .into_any(), + None => Self::render_message("No prediction"), Some(prediction) => self.render_last_prediction(prediction, cx).into_any(), } } + fn render_message(message: impl Into) -> AnyElement { + v_flex() + .size_full() + .justify_center() + .items_center() + .child(Label::new(message).size(LabelSize::Large)) + .into_any() + } + fn render_last_prediction(&self, prediction: &LastPrediction, cx: &mut Context) -> Div { match &self.active_view { ActiveView::Context => div().size_full().child(prediction.context_editor.clone()),