Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

ep: Collect data for staff in Zed Industries repos (#57733)

Ben Kunkle8042408df4d6
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("[email protected]:zed-industries/"))
+ .or_else(|| url.strip_prefix("ssh://[email protected]/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<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