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

View file

@ -1,8 +1,10 @@
use crate::{CompletionDiffElement, InlineCompletion, InlineCompletionRating, Zeta};
use command_palette_hooks::CommandPaletteFilter;
use editor::Editor;
use feature_flags::{FeatureFlagAppExt as _, PredictEditsRateCompletionsFeatureFlag};
use gpui::{actions, prelude::*, App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable};
use language::language_settings;
use std::time::Duration;
use std::{any::TypeId, time::Duration};
use ui::{prelude::*, KeyBinding, List, ListItem, ListItemSpacing, Tooltip};
use workspace::{ModalView, Workspace};
@ -22,10 +24,35 @@ actions!(
pub fn init(cx: &mut App) {
cx.observe_new(move |workspace: &mut Workspace, _, _cx| {
workspace.register_action(|workspace, _: &RateCompletions, window, cx| {
RateCompletionModal::toggle(workspace, window, cx);
if cx.has_flag::<PredictEditsRateCompletionsFeatureFlag>() {
RateCompletionModal::toggle(workspace, window, cx);
}
});
})
.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 {