Also record repo relative file path

This commit is contained in:
Michael Sloan 2025-08-26 00:03:46 -06:00
parent b9cd8f5d2a
commit aaaba05ef7
No known key found for this signature in database
2 changed files with 11 additions and 3 deletions

View file

@ -156,6 +156,9 @@ pub struct PredictEditsBody {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PredictEditsGitInfo {
/// Repo-relative path to the file that contains the input excerpt.
#[serde(skip_serializing_if = "Option::is_none", default)]
pub input_file_path: Option<String>,
/// SHA of git HEAD commit at time of prediction.
#[serde(skip_serializing_if = "Option::is_none", default)]
pub head_sha: Option<String>,
@ -165,13 +168,16 @@ pub struct PredictEditsGitInfo {
/// URL of the remote called `upstream`.
#[serde(skip_serializing_if = "Option::is_none", default)]
pub remote_upstream_url: Option<String>,
/// Recently active files that may be within this repository.
#[serde(skip_serializing_if = "Option::is_none", default)]
pub recent_files: Option<Vec<PredictEditsRecentFile>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PredictEditsRecentFile {
pub repo_path: String,
/// Path to a file within the repository.
pub path: String,
/// Milliseconds between the editor for this file being active and the request time.
pub active_to_now_ms: u32,
}

View file

@ -1146,8 +1146,9 @@ and then another
}
let git_store = project.git_store().read(cx);
let (repository, _repo_path) =
let (repository, repo_path) =
git_store.repository_and_path_for_project_path(&project_path, cx)?;
let repo_path_str = repo_path.to_str()?;
let repository = repository.read(cx);
let head_sha = repository
@ -1163,6 +1164,7 @@ and then another
let recent_files = self.recent_files(&buffer_snapshotted_at, repository, cx);
Some(PredictEditsGitInfo {
input_file_path: Some(repo_path_str.to_string()),
head_sha,
remote_origin_url,
remote_upstream_url,
@ -1231,7 +1233,7 @@ and then another
continue;
};
results.push(PredictEditsRecentFile {
repo_path: repo_path_str.to_string(),
path: repo_path_str.to_string(),
active_to_now_ms,
});
} else {