From 8042408df4d6859b40aac307884a53530ce34c4d Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Thu, 28 May 2026 08:59:56 -0400 Subject: [PATCH] ep: Collect data for staff in Zed Industries repos (#57733) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - N/A or Added/Fixed/Improved ... --- crates/edit_prediction/src/edit_prediction.rs | 33 +++++++++++++++---- crates/edit_prediction/src/zeta.rs | 13 ++------ 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index f6faa7d7123..b5449ff5390 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -2551,11 +2551,24 @@ impl EditPredictionStore { EditPredictionsMode::Subtle => PredictEditsMode::Subtle, }; - let is_open_source = snapshot - .file() - .map_or(false, |file| self.is_file_open_source(&project, file, cx)) - && events.iter().all(|event| event.in_open_source_repo()) - && related_files.iter().all(|file| file.in_open_source_repo); + let buffer_id = active_buffer.read(cx).remote_id(); + let repo_url = project + .read(cx) + .git_store() + .read(cx) + .repository_and_path_for_buffer_id(buffer_id, cx) + .and_then(|(repo, _)| repo.read(cx).default_remote_url()); + + let is_staff_zed_repo = cx.is_staff() + && repo_url + .as_ref() + .is_some_and(|url| is_zed_industries_repo(url)); + let is_open_source = is_staff_zed_repo + || (snapshot + .file() + .map_or(false, |file| self.is_file_open_source(&project, file, cx)) + && events.iter().all(|event| event.in_open_source_repo()) + && related_files.iter().all(|file| file.in_open_source_repo)); let can_collect_data = !cfg!(test) && is_open_source @@ -2594,7 +2607,7 @@ impl EditPredictionStore { ) }); - zeta::request_prediction_with_zeta(self, inputs, capture_events, cx) + zeta::request_prediction_with_zeta(self, inputs, capture_events, repo_url, cx) } EditPredictionModel::Fim { format } => fim::request_prediction(inputs, format, cx), EditPredictionModel::Mercury => { @@ -3286,3 +3299,11 @@ pub fn init(cx: &mut App) { }) .detach(); } + +fn is_zed_industries_repo(url: &str) -> bool { + url.strip_prefix("https://github.com/zed-industries/") + .or_else(|| url.strip_prefix("http://github.com/zed-industries/")) + .or_else(|| url.strip_prefix("git@github.com:zed-industries/")) + .or_else(|| url.strip_prefix("ssh://git@github.com/zed-industries/")) + .is_some_and(|repo| !repo.is_empty()) +} diff --git a/crates/edit_prediction/src/zeta.rs b/crates/edit_prediction/src/zeta.rs index f20e5786de1..28aa1229517 100644 --- a/crates/edit_prediction/src/zeta.rs +++ b/crates/edit_prediction/src/zeta.rs @@ -53,6 +53,7 @@ pub fn request_prediction_with_zeta( Vec, Task, Entity>>>, )>, + repo_url: Option, cx: &mut Context, ) -> Task>> { let settings = &all_language_settings(None, cx).edit_predictions; @@ -73,17 +74,7 @@ pub fn request_prediction_with_zeta( let excerpt_path = buffer_path_with_id_fallback(snapshot.file(), &snapshot.text, cx); - let repo_url = if can_collect_data { - let buffer_id = buffer.read(cx).remote_id(); - project - .read(cx) - .git_store() - .read(cx) - .repository_and_path_for_buffer_id(buffer_id, cx) - .and_then(|(repo, _)| repo.read(cx).default_remote_url()) - } else { - None - }; + let repo_url = repo_url.filter(|_| can_collect_data); let client = store.client.clone(); let llm_token = store.llm_token.clone(); let organization_id = store