Skip to content

Update WatchFilter API#3

Merged
MaggieShan merged 1 commit into
warpdotdev/notify-8.0.0from
maggs/update-watchfilter-api
May 21, 2026
Merged

Update WatchFilter API#3
MaggieShan merged 1 commit into
warpdotdev/notify-8.0.0from
maggs/update-watchfilter-api

Conversation

@MaggieShan
Copy link
Copy Markdown

@MaggieShan MaggieShan commented May 21, 2026

Description

  • Updates the WatchFilter API to support more granular filter fns - should_emit_event and should_watch_directory
  • This is to fix a linux/inotify-specific bug where the filter was being used at watcher registration time rather than at event emission - so filtering out a directory would silently drop all of the child events from the directory

Oz plan: https://staging.warp.dev/drive/notebook/Linux-inotify-dual-predicate-watch-filter-Warp-caller-updates-5HQUBSdF5ZqO5e8GxJmuAe

Testing

Copy link
Copy Markdown
Member

@kevinyang372 kevinyang372 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment thread notify/src/inotify.rs
)?;
watch_self = false;
.into_iter();
while let Some(entry_result) = iter.next() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooc why do we need to rewrite the for iterator into while let?

My understanding is we should just change should_watch in the original filter to should_watch_directory right?

Copy link
Copy Markdown
Author

@MaggieShan MaggieShan May 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iiuc the previous filter_map and filter would evaluate the entry/directory after it's already been explored, whereas WalkDir::skip_current_dir ensures that we're skipping entries before exploring them

I believe we can similarly use WalkDir::filter_entry to be slightly more ergonomic but I don't have a strong opinion

Comment thread notify/src/inotify.rs
}
}

/// return `DirEntry` when it is a directory
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above but I think we should be able to keep the original logic here

@MaggieShan MaggieShan merged commit 91b7198 into warpdotdev/notify-8.0.0 May 21, 2026
MaggieShan added a commit to warpdotdev/warp that referenced this pull request May 21, 2026
## Description
* 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 #11321  

## Linked Issue
*
[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)

## 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:
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`

## Agent Mode
- [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 Entries for Stable
CHANGELOG-BUG-FIX: Fixes linux file watcher bug where certain git events
were not getting sent
zouyonghe pushed a commit to zouyonghe/warp that referenced this pull request May 22, 2026
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants