Watcher build mode efficiency updates#3670
Open
johnfav03 wants to merge 16 commits intomicrosoft:mainfrom
Open
Watcher build mode efficiency updates#3670johnfav03 wants to merge 16 commits intomicrosoft:mainfrom
johnfav03 wants to merge 16 commits intomicrosoft:mainfrom
Conversation
…ript-go into watcher-lsp-integration
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors watch/build-mode change detection to use a shared polling FileWatcher + trackingvfs approach (aligned with CLI/LSP), reducing redundant scanning and improving dependency change tracking (incl. package.json-driven resolution).
Changes:
- Reworked
internal/vfs/vfswatchto watch directory sets (recursive + shallow), emit structuredWatchEvents, and support context-aware settling. - Updated build/watch orchestration to compute watched directories from
SeenFiles+ wildcard dirs and to useScanForChanges()instead of per-file watch state. - Added polling-watcher integration for LSP sessions plus new tests; updated baselines to reflect revised incremental out-of-date reasoning/log output.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-stopBuildOnErrors-is-passed-on-command-line.js | Updated expected watch output/error counts under new watcher behavior |
| testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-preserveWatchOutput-is-passed-on-command-line.js | Baseline update for watched buildinfo timestamp behavior |
| testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-preserveWatchOutput-is-not-used.js | Baseline update for watched buildinfo timestamp behavior |
| testdata/baselines/reference/tsbuildWatch/sample/incremental-updates-in-verbose-mode.js | Baseline update for “out of date because …” reasoning |
| testdata/baselines/reference/tsbuildWatch/reexport/Reports-errors-correctly.js | Baseline update for verbose out-of-date messaging |
| testdata/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js | Baseline updates adding incremental “file change detected” sections and revised reasons |
| testdata/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js | Baseline updates to reflect package.json watch behavior |
| testdata/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js | Baseline update for error out-of-date messaging + buildinfo timestamps |
| testdata/baselines/reference/tsbuild/sample/sample.js | Baseline update for referenced-project input selection message |
| testdata/baselines/reference/tsbuild/sample/explainFiles.js | Baseline update for referenced-project input selection message |
| testdata/baselines/reference/tsbuild/commandLine/emitDeclarationOnly-on-commandline.js | Baseline update for referenced-project input selection message |
| internal/vfs/vfswatch/vfswatch_race_test.go | Updated race/fuzz tests for directory-based watcher + ScanForChanges() |
| internal/vfs/vfswatch/vfswatch_event_test.go | New tests validating WatchEvent create/change/delete behavior |
| internal/vfs/vfswatch/vfswatch.go | Major refactor: directory watchers, WatchEvent, logging, ctx-aware run/settle |
| internal/tspath/pathcomponents_watching_test.go | New tests for exported watch-specific path component logic |
| internal/tspath/path.go | Exported GetPathComponentsForWatching for common-parent watch coarsening |
| internal/project/watch_test.go | Moved watch-path-component tests out of project package |
| internal/project/watch.go | Added WatchedDirectories() extraction for polling watcher directory computation |
| internal/project/session.go | Added optional in-process polling watcher + directory updates per snapshot |
| internal/project/polling_watcher_test.go | New integration test for LSP polling watcher triggering diagnostics refresh |
| internal/project/configfileregistrybuilder.go | Switched GetCommonParents callback to tspath.GetPathComponentsForWatching |
| internal/lsp/server.go | Default polling enablement when client watching is unavailable + user opt-in |
| internal/ls/lsutil/userpreferences.go | Added usePollingWatcher user preference plumbing |
| internal/execute/watcher.go | Watch-mode now computes watched dirs + filters builds via WatchEvent relevance |
| internal/execute/tsctests/tscbuild_test.go | Updated expected diffs for new behavior (removed stopBuildOnErrors diff text) |
| internal/execute/build/orchestrator.go | Build-mode watcher now uses shared FileWatcher + directory computation |
| internal/execute/build/compilerHost.go | Added trackingvfs support to collect SeenFiles during compile |
| internal/execute/build/buildtask.go | Uses trackingvfs + watch-state update + package.json dependency checks |
| _extension/package.json | Added experimental setting typescript.native-preview.usePollingWatcher |
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.
Refactors the
tsc --build --watchfunctionality to use the new sharedFileWatcherandtrackingvfsstructure from the CLI and LSP watchers, reducing code duplication and patching inefficiencies like redundant scanning of shared dependencies.Note: this PR is built on the
watcher-lsp-integrationbranch so only review commits from0655dbaonwardFixes #2666