Update filesystem watch filters#11464
Conversation
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR updates filesystem watch filters to separate directory-registration predicates from event-emission predicates for repository and managed-path watchers. No approved spec context was available, so the review is based on the PR description and annotated diff.
Concerns
- The committed Cargo
[patch]override pointsnotifydependencies at a developer-local/Users/...checkout, and the lockfile has been rewritten as if those packages are path dependencies. This will make builds fail or become non-reproducible outside that machine.
Verdict
Found: 0 critical, 1 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR updates filesystem watcher filters for the notify dual-predicate API and adjusts repository/git watch tests. The watcher logic generally follows the intended separation between directory registration and event emission, and I did not find security-specific findings.
Concerns
- The new
repo_watch_filtersurface pullsnotify-debouncer-fullintorepo_metadata/src/entry.rsunconditionally, but that dependency is not available for wasm builds.
Verdict
Found: 0 critical, 1 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
20fc479 to
721aa20
Compare
| // and `.git/` allowlist rules. | ||
| let emit_gitignores = gitignores.clone(); | ||
| let should_emit_event = | ||
| Arc::new(move |path: &Path| path_passes_filters(path, emit_gitignores.as_slice())); |
There was a problem hiding this comment.
I think this should just be if path matches gitignore for both emit event and should register directory
There was a problem hiding this comment.
For codebase index, for both emit event and register folder:
- Path does not match gitignore
- Path is not under .git/
| Some("worktrees") => true, | ||
| // Other top-level entries are only descendable when they are allowlisted files. | ||
| // Non-allowlisted directories such as `.git/objects`, `.git/hooks`, and `.git/logs` must be pruned. | ||
| Some("HEAD" | "index.lock" | "config" | "config.worktree") if suffix.len() == 1 => true, |
There was a problem hiding this comment.
Aren't these files? What does it mean for files to be descendable?
There was a problem hiding this comment.
Updated to be more clear + removed the file check
* Based on change to the `notify` crate warpdotdev/notify#3 (will update cargo.toml once it's merged) * Which introduces 2 filter fns within the watch filter - `should_emit_event` and `should_register_directory` * Updates all callers of `WatchFilter::with_filter` to include the right predicates * Where `should_emit_event` filters out specific files while `should_register_directory` includes ancestors to allowlisted paths such that the directories are correctly registered * Today we use a filesystem watcher to detect git changes (branch checkouts, commits, etc.) using an allowlist - this includes paths like `HEAD`, `refs/heads/*`, `index.lock`, and ignores paths like `.git/logs/` to reduce noice * The issue is that on linux, the notify crate uses `inotify` which uses the filter to decide which directories to register/watch * This meant that with out filter `should_ignore_git_path`, directories like `./git` and `./git/refs` were not getting registered * Better fix to warpdotdev#11321 * [APP-4528](https://linear.app/warpdotdev/issue/APP-4528/bug-code-review-shows-inaccurate-diffs-when-switching-commits) * I believe this also fixes the flaky test mentioned in for the same reasons [CODE-1492](https://linear.app/warpdotdev/issue/CODE-1492/fix-flaky-test-commit-related-files-excluded-from-update-lists) Tested various git commands and repo updates in a linux devbox Tested original repro steps where diffs weren't getting the events for checkout: 1. git checkout HEAD~1 2. update base branch to master in code review view 3. git checkout master 4. Bug: code review renders old/inaccurate diffs 5. Fix: code review refresh is triggered and shows clean state https://www.loom.com/share/ea1a81e5c0654fc9a6d0f20b68f7d63e Also verified that we're not properly watching changes to remote refs - so pushing commits to a remote branch is tracked: 1. git commit and git push changes to a branch 2. Bug: code review git button shows "push" as the primary action 3. Fix: code review git button shows "create pr" as the primary action - [x] I have manually tested my changes locally with `./script/run` - [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode Oz plan: https://staging.warp.dev/drive/notebook/Linux-inotify-dual-predicate-watch-filter-Warp-caller-updates-5HQUBSdF5ZqO5e8GxJmuAe CHANGELOG-BUG-FIX: Fixes linux file watcher bug where certain git events were not getting sent (cherry picked from commit cb4fe42)
Description
notifycrate Update WatchFilter API notify#3 (will update cargo.toml once it's merged)should_emit_eventandshould_register_directoryWatchFilter::with_filterto include the right predicatesshould_emit_eventfilters out specific files whileshould_register_directoryincludes ancestors to allowlisted paths such that the directories are correctly registeredHEAD,refs/heads/*,index.lock, and ignores paths like.git/logs/to reduce noiceinotifywhich uses the filter to decide which directories to register/watchshould_ignore_git_path, directories like./gitand./git/refswere not getting registeredLinked Issue
Testing
Tested various git commands and repo updates in a linux devbox
Tested original repro steps where diffs weren't getting the events for checkout:
https://www.loom.com/share/ea1a81e5c0654fc9a6d0f20b68f7d63e
Also verified that we're not properly watching changes to remote refs - so pushing commits to a remote branch is tracked:
./script/runAgent Mode
Oz plan: https://staging.warp.dev/drive/notebook/Linux-inotify-dual-predicate-watch-filter-Warp-caller-updates-5HQUBSdF5ZqO5e8GxJmuAe
Changelog Entries for Stable
CHANGELOG-BUG-FIX: Fixes linux file watcher bug where certain git events were not getting sent