GeezerVison is showing github.com — fix(core): publish filesystem.changed events for workspace file edits by twitset · Pull Request #55537 · anomalyco/opencode
Conversation
twitset
commented
Oct 14, 2026
•
edited by opencode-agent
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Refs #52941
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
The location watcher only subscribed to the exact VCS branch-metadata file (.git/HEAD or .hg/branch), so ordinary file creates, edits, and deletes inside a workspace never produced filesystem.changed events. Clients that rely on the event stream — the desktop file pane and the review tab — went stale whenever files changed on disk outside the app (terminal editors, scripts, agent tool writes).
The watcher now keeps two subscriptions per workspace instead of one:
- a directory subscription on the workspace root that publishes
filesystem.changed ({ file: <absolute path>, event: "add" | "change" | "unlink" }) for every normal file create/update/delete, with node_modules, .git, and .hg ignored;
- the existing exact branch-metadata file subscription, so branch switches still publish (exactly one event per switch, no duplicates from store churn).
Subscriptions are keyed by their full watch input, so when the user-configured watcher-ignore policy changes, only subscriptions whose inputs actually differ are restarted — entries duplicating the defaults don't cause churn. The directory subscription is unconditional, so events also flow in workspaces without git/hg.
How did you verify your code works?
bun test packages/core/test/filesystem/watcher.test.ts — 17/17 pass (new/updated tests cover the directory + branch-metadata subscriptions, policy reconciliation without duplicate restarts, and the create/update/delete → add/change/unlink publish mapping). tsgo typecheck clean.
- Manual against a server run from source, watching
/api/event while modifying files externally: add/change/unlink events carry absolute paths; 50-file .git/ churn and node_modules/ churn produce zero events; exactly one .git/HEAD change per branch switch; a 200-file burst is delivered without loss; events keep flowing after a server restart and in a non-git workspace.
- In the app UI (renderer pointed at the dev server, edits done externally, no manual refresh): file tree updates in ~40–200 ms; quick create+delete leaves no ghost entries; nested edits only refresh the affected subtree and preserve expansion state; the review diff refreshes itself (~100 ms debounce) and reacts to branch switches.
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
No UI change — server-side event coverage only.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Fixes #48451
Related: #52941, #50463, #52776
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The location watcher only subscribed to the exact VCS branch-metadata
file (.git/HEAD or .hg/branch), so ordinary file creates, edits, and
deletes inside a workspace never produced filesystem.changed events.
Clients relying on the event stream (desktop file pane, review tab)
went stale whenever files changed on disk outside the app.
The watcher now maintains a per-workspace directory subscription that
publishes every file create/update/delete, with node_modules and VCS
stores (.git/.hg) ignored, while keeping the dedicated branch-metadata
file subscription so branch switches still publish exactly one event.
A user-configured watcher-ignore policy is merged into the directory
ignore list without restarting unchanged subscriptions.
|
The following comment was made by an LLM, it may be inaccurate:
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Superseded by #55538 (reopened from my other account).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix works. Running serve from source and listening on /api/event, external create/edit/delete of a file in a git workspace now produces filesystem.changed add/change/unlink events with absolute paths. On the base it produced nothing. node_modules writes stay silent, and a branch switch still gives exactly one .git/HEAD event. watcher.test.ts (17/17) and the packages/core typecheck pass.
Public API: no schema change. filesystem.changed keeps its payload but now fires for ordinary workspace edits, not only the branch file. Backwards compatible; existing app and review-pane listeners already handle these events.
Main concern (inline): the recursive watch is unconditional for every location instance, with only node_modules/.git/.hg ignored. See the inline comment.
Fixes #48451
Related: #52941, #50463, #52776
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
// refresh open views. VCS metadata is excluded: store churn is not an
|
|
|
// edit, and the exact branch-metadata subscription below covers switches.
|
|
|
const inputs = new Map<string, Watcher.WatchInput>()
|
|
|
const directory: Watcher.WatchInput = {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This starts an always-on recursive watch of the location root for every instance: TUI, opencode run and server locations, not only clients that use filesystem.changed. It also covers folders like ~. Only node_modules/.git/.hg are skipped. The broader built-in list (dist, build, target, .venv, __pycache__, .next, coverage…) was deleted in #52658, so build output churn will now stream events to every client. Large trees can also run into the inotify watch limit (#52776) or Windows junction recursion (#50463) for users who never open the file pane. Could the folder watch be scoped more tightly? For example, skip it when the location is the home or filesystem root, restore a sensible default ignore set, and/or only subscribe while a client listens for these events.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|