Open
Conversation
…ript-go into watcher-lsp-integration
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the internal polling-based watcher (internal/vfs/vfswatch) so it can be shared by both the watch CLI and the LSP, and wires it into the LSP as a fallback polling watcher when the client doesn’t support didChangeWatchedFiles.
Changes:
- Refactors
vfswatch.FileWatcherto watch directories (recursive/non-recursive) and emitWatchEventdeltas viaScanForChanges/callback. - Integrates an in-process polling watcher into the project session when client-side watching is unavailable, and updates polling directories based on the current snapshot.
- Moves “watching-aware” path component logic into
tspathand updates callers/tests.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/vfs/vfswatch/vfswatch.go | Refactors watcher API to directory-based snapshots + WatchEvent, adds stop support. |
| internal/vfs/vfswatch/vfswatch_race_test.go | Updates race/fuzz tests to exercise ScanForChanges and directory watching. |
| internal/vfs/vfswatch/vfswatch_event_test.go | Adds tests for WatchEvent created/changed/deleted behavior. |
| internal/execute/watcher.go | Adapts CLI watch mode to new watcher events + directory computation and config mtime tracking. |
| internal/project/session.go | Adds polling watcher integration into LSP session and directory update logic; stops watcher on close. |
| internal/lsp/server.go | Enables polling mode automatically when server-side watch globs are disabled. |
| internal/project/polling_watcher_test.go | Adds a basic integration test for session + polling watcher. |
| internal/tspath/path.go | Introduces GetPathComponentsForWatching in tspath. |
| internal/project/watch.go | Switches common-parent computation to tspath.GetPathComponentsForWatching and removes local helper. |
| internal/project/watch_test.go | Updates tests to call the new tspath.GetPathComponentsForWatching. |
| internal/project/configfileregistrybuilder.go | Updates GetCommonParents callback to use tspath.GetPathComponentsForWatching. |
jakebailey
reviewed
Apr 22, 2026
jakebailey
reviewed
Apr 22, 2026
| "gotest.tools/v3/assert" | ||
| ) | ||
|
|
||
| func TestGetPathComponentsForWatching(t *testing.T) { |
Member
There was a problem hiding this comment.
This test should be moved to the tspath package
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.
Following up on #3217, this PR refactors
vfswatch.FileWatcherto make it useable by the LSP in addition to the CLI, and integrates it into the LSP as a polling watcher for clients that don't supportdidChangeWatchedFiles.