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 ...
This commit is contained in:
Ben Kunkle 2026-05-28 08:59:56 -04:00 committed by GitHub
parent 518502e5ef
commit 8042408df4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 17 deletions

View file

@ -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())
}

View file

@ -53,6 +53,7 @@ pub fn request_prediction_with_zeta(
Vec<crate::StoredEvent>,
Task<Result<collections::HashMap<Arc<Path>, Entity<BufferDiff>>>>,
)>,
repo_url: Option<String>,
cx: &mut Context<EditPredictionStore>,
) -> Task<Result<Option<EditPredictionResult>>> {
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