edit prediction: Allow enabling OSS data collection with no project open (#24265)

This was an leftover from when we were persisting a per-project setting.

Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga 2025-02-05 10:39:20 -03:00 committed by GitHub
parent 88b5f069fb
commit f5e8048fcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,6 @@
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};
use crate::{Zeta, ZED_PREDICT_DATA_COLLECTION_CHOICE}; use crate::ZED_PREDICT_DATA_COLLECTION_CHOICE;
use client::{Client, UserStore}; use client::{Client, UserStore};
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use feature_flags::FeatureFlagAppExt as _; use feature_flags::FeatureFlagAppExt as _;
@ -11,10 +11,9 @@ use gpui::{
}; };
use language::language_settings::{AllLanguageSettings, InlineCompletionProvider}; use language::language_settings::{AllLanguageSettings, InlineCompletionProvider};
use settings::{update_settings_file, Settings}; use settings::{update_settings_file, Settings};
use ui::{prelude::*, Checkbox, TintColor, Tooltip}; use ui::{prelude::*, Checkbox, TintColor};
use util::ResultExt; use util::ResultExt;
use workspace::{notifications::NotifyTaskExt, ModalView, Workspace}; use workspace::{notifications::NotifyTaskExt, ModalView, Workspace};
use worktree::Worktree;
/// Introduces user to Zed's Edit Prediction feature and terms of service /// Introduces user to Zed's Edit Prediction feature and terms of service
pub struct ZedPredictModal { pub struct ZedPredictModal {
@ -26,7 +25,6 @@ pub struct ZedPredictModal {
terms_of_service: bool, terms_of_service: bool,
data_collection_expanded: bool, data_collection_expanded: bool,
data_collection_opted_in: bool, data_collection_opted_in: bool,
worktrees: Vec<Entity<Worktree>>,
} }
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
@ -48,8 +46,6 @@ impl ZedPredictModal {
window: &mut Window, window: &mut Window,
cx: &mut Context<Workspace>, cx: &mut Context<Workspace>,
) { ) {
let worktrees = workspace.visible_worktrees(cx).collect();
workspace.toggle_modal(window, cx, |_window, cx| Self { workspace.toggle_modal(window, cx, |_window, cx| Self {
user_store, user_store,
client, client,
@ -59,7 +55,6 @@ impl ZedPredictModal {
terms_of_service: false, terms_of_service: false,
data_collection_expanded: false, data_collection_expanded: false,
data_collection_opted_in: false, data_collection_opted_in: false,
worktrees,
}); });
} }
@ -107,13 +102,6 @@ impl ZedPredictModal {
.inline_completion_provider = Some(InlineCompletionProvider::Zed); .inline_completion_provider = Some(InlineCompletionProvider::Zed);
}); });
if this.worktrees.is_empty() {
cx.emit(DismissEvent);
return;
}
Zeta::register(None, this.client.clone(), this.user_store.clone(), cx);
cx.emit(DismissEvent); cx.emit(DismissEvent);
}) })
}) })
@ -336,17 +324,6 @@ impl Render for ZedPredictModal {
) )
.label("Optionally share training data (OSS-only).") .label("Optionally share training data (OSS-only).")
.fill() .fill()
.when(self.worktrees.is_empty(), |element| {
element.disabled(true).tooltip(move |window, cx| {
Tooltip::with_meta(
"No Project Open",
None,
"Open a project to enable this option.",
window,
cx,
)
})
})
.on_click(cx.listener( .on_click(cx.listener(
move |this, state, _window, cx| { move |this, state, _window, cx| {
this.data_collection_opted_in = this.data_collection_opted_in =
@ -355,7 +332,6 @@ impl Render for ZedPredictModal {
}, },
)), )),
) )
// TODO: show each worktree if more than 1
.child( .child(
Button::new("learn-more", "Learn More") Button::new("learn-more", "Learn More")
.icon(accordion_icons.0) .icon(accordion_icons.0)