Fix agent rules files for remote project by loading via buffer (#29440)

When using the agent with a project shared by a collaborator, rules file
loading didn't work as it was trying to read from the client's
filesystem

Release Notes:

- Fixed rules file loading when using the agent with a project shared by
a collaborator.
This commit is contained in:
Michael Sloan 2025-04-25 14:06:40 -06:00 committed by GitHub
parent 7623fce4b4
commit cfb7a30724
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 67 additions and 41 deletions

View file

@ -64,8 +64,11 @@ pub struct WorktreeContext {
#[derive(Debug, Clone, Serialize)]
pub struct RulesFileContext {
pub path_in_worktree: Arc<Path>,
pub abs_path: Arc<Path>,
pub text: String,
// This used for opening rules files. TODO: Since it isn't related to prompt templating, this
// should be moved elsewhere.
#[serde(skip)]
pub project_entry_id: usize,
}
#[derive(Serialize)]
@ -403,8 +406,8 @@ mod test {
root_name: "path".into(),
rules_file: Some(RulesFileContext {
path_in_worktree: Path::new(".rules").into(),
abs_path: Path::new("/some/path/.rules").into(),
text: "".into(),
project_entry_id: 0,
}),
}];
let default_user_rules = vec![UserRulesContext {