fix(watcher): filter ignored paths before publishing events, handle worktree git dirs#21453
Open
drrcool wants to merge 3 commits intoanomalyco:devfrom
Open
fix(watcher): filter ignored paths before publishing events, handle worktree git dirs#21453drrcool wants to merge 3 commits intoanomalyco:devfrom
drrcool wants to merge 3 commits intoanomalyco:devfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes excessive UI refresh/flicker caused by unfiltered filesystem watcher events, especially from ignored build artifacts and git worktree .git paths. It tightens backend event filtering before publishing and improves frontend filtering for absolute git-dir paths.
Changes:
- Backend: filter watcher events via
FileIgnore.match()before publishing, and restrict git-dir publishing toHEADonly. - Backend: add a
rel()helper to safely compute paths relative to the subscribed directory for filtering decisions. - Frontend: normalize path separators and ignore both relative
.git/...and absolute.../.git/...watcher events before triggeringrefreshVcs().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/opencode/src/file/watcher.ts | Filters ignored paths prior to publishing file.watcher.updated and narrows git-dir events to HEAD to avoid noisy updates. |
| packages/app/src/pages/session.tsx | Prevents spurious VCS refreshes by correctly identifying .git paths in worktree/absolute and Windows path forms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
…orktree git dirs
The parcel/watcher callback was shared and published all filesystem events
without re-filtering through FileIgnore. Build artifacts and lock files in
ignored directories (out/, .turbo/, etc.) fired watcher events that drove
repeated refreshVcs() calls and made the review panel flicker.
Also fixes the frontend listener to handle absolute .git/worktrees/... paths
produced by git worktrees, which bypassed the old startsWith('.git/') check.
Fixes anomalyco#21452
036a100 to
ca5e4bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #21452
Type of change
What does this PR do?
The review panel was flickering/rerenderering every few seconds when
OPENCODE_EXPERIMENTAL_FILEWATCHER=true(which the desktop app forces on). Two bugs compounded each other:Backend (
watcher.ts): The parcel/watcher callback was shared across both subscriptions (worktree dir and git dir) and published every incoming event without filtering throughFileIgnore.match(). So build artifacts likeout/renderer/index.jsor.turbo/lock files firedfile.watcher.updatedevents and triggeredrefreshVcs()even though those paths match the ignore patterns. Fix: move the callback insidesubscribe()so each subscription gets its own; run non-git events throughFileIgnore.match()before publishing; only letHEADthrough on the git-dir subscription (the only file there that signals a real branch/commit change).Frontend (
session.tsx): Thefile.watcher.updatedlistener skipped paths withstartsWith(".git/"), but in git worktrees the git dir is an absolute path like/path/to/.git/worktrees/<branch>/HEAD, so those events slipped through. Fix: also checkincludes("/.git/")and normalize Windows backslashes first.How did you verify your code works?
Ran the desktop app with
electron-vite devrunning alongside (which writes toout/, a pathFileIgnoreshould suppress). Before the fix,/vcs/diffwas being fetched in a tight loop — confirmed via browser devtools network tab. After the fix,refreshVcs()is only called on actual source file changes.Screenshots / recordings
N/A — this is a flicker fix, the change is the absence of spurious network requests.
Checklist