edit prediction: Hide rate completions modal behind feature flag (#23597)

This hides the ability to rate completions behind the
`predict-edits-rate-completions` feature flag

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner 2025-01-28 12:27:09 +01:00 committed by GitHub
parent dfed43ab24
commit 57a3d8c491
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 57 additions and 16 deletions

2
Cargo.lock generated
View file

@ -16728,9 +16728,11 @@ dependencies = [
"client", "client",
"clock", "clock",
"collections", "collections",
"command_palette_hooks",
"ctor", "ctor",
"editor", "editor",
"env_logger 0.11.6", "env_logger 0.11.6",
"feature_flags",
"futures 0.3.31", "futures 0.3.31",
"gpui", "gpui",
"http_client", "http_client",

View file

@ -56,6 +56,11 @@ impl FeatureFlag for PredictEditsFeatureFlag {
const NAME: &'static str = "predict-edits"; const NAME: &'static str = "predict-edits";
} }
pub struct PredictEditsRateCompletionsFeatureFlag;
impl FeatureFlag for PredictEditsRateCompletionsFeatureFlag {
const NAME: &'static str = "predict-edits-rate-completions";
}
pub struct GitUiFeatureFlag; pub struct GitUiFeatureFlag;
impl FeatureFlag for GitUiFeatureFlag { impl FeatureFlag for GitUiFeatureFlag {
const NAME: &'static str = "git-ui"; const NAME: &'static str = "git-ui";

View file

@ -2,7 +2,9 @@ use anyhow::Result;
use client::UserStore; use client::UserStore;
use copilot::{Copilot, Status}; use copilot::{Copilot, Status};
use editor::{scroll::Autoscroll, Editor}; use editor::{scroll::Autoscroll, Editor};
use feature_flags::{FeatureFlagAppExt, PredictEditsFeatureFlag}; use feature_flags::{
FeatureFlagAppExt, PredictEditsFeatureFlag, PredictEditsRateCompletionsFeatureFlag,
};
use fs::Fs; use fs::Fs;
use gpui::{ use gpui::{
actions, div, pulsating_between, Action, Animation, AnimationExt, App, AsyncWindowContext, actions, div, pulsating_between, Action, Animation, AnimationExt, App, AsyncWindowContext,
@ -463,19 +465,22 @@ impl InlineCompletionButton {
) -> Entity<ContextMenu> { ) -> Entity<ContextMenu> {
let workspace = self.workspace.clone(); let workspace = self.workspace.clone();
ContextMenu::build(window, cx, |menu, _window, cx| { ContextMenu::build(window, cx, |menu, _window, cx| {
self.build_language_settings_menu(menu, cx) self.build_language_settings_menu(menu, cx).when(
.separator() cx.has_flag::<PredictEditsRateCompletionsFeatureFlag>(),
.entry( |this| {
"Rate Completions", this.separator().entry(
Some(RateCompletions.boxed_clone()), "Rate Completions",
move |window, cx| { Some(RateCompletions.boxed_clone()),
workspace move |window, cx| {
.update(cx, |workspace, cx| { workspace
RateCompletionModal::toggle(workspace, window, cx) .update(cx, |workspace, cx| {
}) RateCompletionModal::toggle(workspace, window, cx)
.ok(); })
}, .ok();
) },
)
},
)
}) })
} }

View file

@ -21,7 +21,9 @@ anyhow.workspace = true
arrayvec.workspace = true arrayvec.workspace = true
client.workspace = true client.workspace = true
collections.workspace = true collections.workspace = true
command_palette_hooks.workspace = true
editor.workspace = true editor.workspace = true
feature_flags.workspace = true
futures.workspace = true futures.workspace = true
gpui.workspace = true gpui.workspace = true
http_client.workspace = true http_client.workspace = true

View file

@ -1,8 +1,10 @@
use crate::{CompletionDiffElement, InlineCompletion, InlineCompletionRating, Zeta}; use crate::{CompletionDiffElement, InlineCompletion, InlineCompletionRating, Zeta};
use command_palette_hooks::CommandPaletteFilter;
use editor::Editor; use editor::Editor;
use feature_flags::{FeatureFlagAppExt as _, PredictEditsRateCompletionsFeatureFlag};
use gpui::{actions, prelude::*, App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable}; use gpui::{actions, prelude::*, App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable};
use language::language_settings; use language::language_settings;
use std::time::Duration; use std::{any::TypeId, time::Duration};
use ui::{prelude::*, KeyBinding, List, ListItem, ListItemSpacing, Tooltip}; use ui::{prelude::*, KeyBinding, List, ListItem, ListItemSpacing, Tooltip};
use workspace::{ModalView, Workspace}; use workspace::{ModalView, Workspace};
@ -22,10 +24,35 @@ actions!(
pub fn init(cx: &mut App) { pub fn init(cx: &mut App) {
cx.observe_new(move |workspace: &mut Workspace, _, _cx| { cx.observe_new(move |workspace: &mut Workspace, _, _cx| {
workspace.register_action(|workspace, _: &RateCompletions, window, cx| { workspace.register_action(|workspace, _: &RateCompletions, window, cx| {
RateCompletionModal::toggle(workspace, window, cx); if cx.has_flag::<PredictEditsRateCompletionsFeatureFlag>() {
RateCompletionModal::toggle(workspace, window, cx);
}
}); });
}) })
.detach(); .detach();
feature_gate_predict_edits_rating_actions(cx);
}
fn feature_gate_predict_edits_rating_actions(cx: &mut App) {
let rate_completion_action_types = [TypeId::of::<RateCompletions>()];
CommandPaletteFilter::update_global(cx, |filter, _cx| {
filter.hide_action_types(&rate_completion_action_types);
});
cx.observe_flag::<PredictEditsRateCompletionsFeatureFlag, _>(move |is_enabled, cx| {
if is_enabled {
CommandPaletteFilter::update_global(cx, |filter, _cx| {
filter.show_action_types(rate_completion_action_types.iter());
});
} else {
CommandPaletteFilter::update_global(cx, |filter, _cx| {
filter.hide_action_types(&rate_completion_action_types);
});
}
})
.detach();
} }
pub struct RateCompletionModal { pub struct RateCompletionModal {