Skip to content

integrated filewatcher with lsp#3505

Open
johnfav03 wants to merge 6 commits intomicrosoft:mainfrom
johnfav03:watcher-lsp-integration
Open

integrated filewatcher with lsp#3505
johnfav03 wants to merge 6 commits intomicrosoft:mainfrom
johnfav03:watcher-lsp-integration

Conversation

@johnfav03
Copy link
Copy Markdown
Contributor

Following up on #3217, this PR refactors vfswatch.FileWatcher to 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 support didChangeWatchedFiles.

Copilot AI review requested due to automatic review settings April 22, 2026 17:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.FileWatcher to watch directories (recursive/non-recursive) and emit WatchEvent deltas via ScanForChanges/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 tspath and 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.

Comment thread internal/vfs/vfswatch/vfswatch.go
Comment thread internal/project/polling_watcher_test.go Outdated
Comment thread internal/project/polling_watcher_test.go Outdated
"gotest.tools/v3/assert"
)

func TestGetPathComponentsForWatching(t *testing.T) {
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.

This test should be moved to the tspath package

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.

3 participants