zeta2: Support edit prediction: clear history (#38808)

Release Notes:

- N/A

Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
Bennet Bo Fenner
2025-09-24 17:44:03 +00:00
committed by GitHub
co-authored by Agus Zubiaga
parent e653cc90c5
commit 6b646e3a14
2 changed files with 12 additions and 0 deletions
@@ -97,6 +97,8 @@ pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
fn clear_zeta_edit_history(_: &zeta::ClearHistory, cx: &mut App) {
if let Some(zeta) = zeta::Zeta::global(cx) {
zeta.update(cx, |zeta, _| zeta.clear_history());
} else if let Some(zeta) = zeta2::Zeta::try_global(cx) {
zeta.update(cx, |zeta, _| zeta.clear_history());
}
}
+10
View File
@@ -108,6 +108,10 @@ pub enum Event {
}
impl Zeta {
pub fn try_global(cx: &App) -> Option<Entity<Self>> {
cx.try_global::<ZetaGlobal>().map(|global| global.0.clone())
}
pub fn global(
client: &Arc<Client>,
user_store: &Entity<UserStore>,
@@ -162,6 +166,12 @@ impl Zeta {
self.options = options;
}
pub fn clear_history(&mut self) {
for zeta_project in self.projects.values_mut() {
zeta_project.events.clear();
}
}
pub fn usage(&self, cx: &App) -> Option<EditPredictionUsage> {
self.user_store.read(cx).edit_prediction_usage()
}