Support remote project rules through repo metadata standing results#11460
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
7038a4a to
1ba7f81
Compare
1ba7f81 to
a2f59d3
Compare
c6a0eaa to
c880386
Compare
c880386 to
c4e9f90
Compare
c4e9f90 to
eae0db2
Compare
5e6b798 to
477221e
Compare
d4b8589 to
8f15075
Compare
556a682 to
085de16
Compare
8f15075 to
b70ba1c
Compare
085de16 to
356c1d5
Compare
b70ba1c to
5969b7d
Compare
5a3fa42 to
ffe55c1
Compare
ffe55c1 to
969dfcf
Compare
87fc220 to
abc3a4b
Compare
969dfcf to
617b784
Compare
abc3a4b to
7f2c34d
Compare
617b784 to
cee7204
Compare
8da6468 to
b4f0407
Compare
cee7204 to
d51751f
Compare
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
b4f0407 to
3fe0616
Compare
d51751f to
38aa924
Compare
Co-Authored-By: Oz <oz-agent@warp.dev>
38aa924 to
34f37c3
Compare
|
|
||
| use crate::remote_server::manager::RemoteServerManager; | ||
|
|
||
| pub(crate) fn read_project_rule_contents( |
There was a problem hiding this comment.
aka ProjectRuleContentReader
| /// App-provided transport for reading the exact rule paths discovered by repository metadata. | ||
| /// | ||
| /// This remains injected because remote file reads are implemented in the app crate. | ||
| pub type ProjectRuleContentReader = fn( |
There was a problem hiding this comment.
aka read_project_rule_contents which is used to read the actual project rule contents
| .get(&project_root) | ||
| .cloned() | ||
| .unwrap_or_default(); | ||
| let rule_paths = standing_project_rule_paths( |
There was a problem hiding this comment.
converts standing query results into local or remote values
| } else { | ||
| None | ||
| }; | ||
| let project_rules = current_working_directory_location |
There was a problem hiding this comment.
we're already typed, that simplifies this logic here
| ProjectRule { | ||
| path: file_path.clone(), | ||
| // Global rule sources are watched under the local home directory. | ||
| path: LocalOrRemotePath::Local(file_path.clone()), |
There was a problem hiding this comment.
purposefully keeping local
| } | ||
|
|
||
| #[cfg(feature = "local_fs")] | ||
| fn apply_project_rules( |
There was a problem hiding this comment.
this is pulling out the logic from the original callsite
| }, | ||
| ); | ||
|
|
||
| let remote_repo_ids = RepoMetadataModel::as_ref(ctx) |
There was a problem hiding this comment.
Will we even have any remote repos on app startup (this is called on initialize_app yeah?)
There was a problem hiding this comment.
Usually there will not be remote repos on a cold startup, but RepoMetadataModel is registered before ProjectContextModel, and a remote snapshot can arrive before ProjectContextModel subscribes to metadata events. Refreshing already-tracked remote IDs closes that race and hydrates any preexisting snapshots. I added a comment explaining this.
There was a problem hiding this comment.
^added this comment

Description
WARP.md/AGENTS.mdpaths fromRepoMetadataModelstanding-query results.ProjectContextModellistens for repository and standing-result changes, then updates its sharedpath_to_rulescache for either a local repository or a host-qualified remote repository.read_project_rule_contentsfunction reads local files withasync_fsand remote files throughRemoteServerManager.ProjectContextModelowns refresh ordering and reconciliation, including per-repository generation checks so an older asynchronous read cannot overwrite a newer refresh.LocalOrRemotePaththroughout rule lookup, agent context, and the Rules UI so identical remote paths on different hosts remain distinct. Global rules and persisted rule records remain local-only.WorkspaceAddedis emitted. If the workspace is a standalone folder that is not already tracked, that indexing call first registers it withRepoMetadataModel; an already-detected repository skips registration but still receives the explicit initial refresh.RepoMetadataModelstanding-query results and uses the same sharedProjectContextModelrefresh path as later metadata events. Subsequent rule changes refresh from metadata events for both local and remote repositories.Pathvalues as local and replace the stored optionalArc<dyn Fn>reader with a stateless function pointer passed to refresh operations.Linked Issue
No issue
Testing
./script/formatcargo check -p ai -p warp --all-targetscargo nextest run -p ai project_context::model::tests— 28 passedcargo nextest run -p warp ai::metadata_project_rules::tests— 3 passedcargo nextest run -p warp ai::blocklist::context_model::tests— 11 passedcargo clippy -p ai -p warp --all-targets -- -D warningsgit diff --check./script/runAgent Mode
CHANGELOG-IMPROVEMENT: Remote sessions now discover and apply project rules such as WARP.md and AGENTS.md.
Co-Authored-By: Oz oz-agent@warp.dev