Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

Rebuilt build mode around fswatch package - #4326

Merged
Jake Bailey (jakebailey) merged 11 commits into
microsoft:mainfrom
johnfav03:build-mode-fswatch-integration
Jun 17, 2026
Merged

Jake Bailey (jakebailey) merged 11 commits into
microsoft:mainfrom
johnfav03:build-mode-fswatch-integration

Conversation

@johnfav03

Copy link
Copy Markdown
Contributor

With the addition of the fswatch package (PR #3980) and the CLI watcher rebuild (PR #4026), we can rebuild the build mode watcher around the same event-driven architecture, which similarly results in an idle CPU usage of <1% on average in the vscode repo.

This PR also extracts shared watch infrastructure into a new internal/execute/watchmanager package, used by both the CLI watcher and build mode.

Copilot AI review requested due to automatic review settings June 15, 2026 19:36
}

// Extended config file directories
for _, cfgPath := range task.resolved.ExtendedSourceFiles() {

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.

checkTasksForEventChanges has a similar structure to this func, but I don't think they can really be reconciled...

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 build/watch infrastructure to use the new fswatch event-driven watcher (matching the CLI watcher architecture) and centralizes shared watch logic into internal/execute/watchmanager. It also updates tsbuild watch baselines to snapshot watch registrations.

Changes:

  • Added internal/execute/watchmanager to own directory watch reconciliation, event coalescing, and DoCycle signaling.
  • Switched build mode watch (internal/execute/build) from polling to fswatch-driven event loops, and updated CLI watch mode to use the shared manager.
  • Updated tsbuildWatch reference baselines to include deterministic “Watch Registrations” output; hardened incremental buildinfo access with bounds checking.

Reviewed changes

Copilot reviewed 70 out of 70 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
testdata/baselines/reference/tsbuildWatch/sample/watches-config-files-that-are-not-present.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/skips-builds-downstream-projects-if-upstream-projects-have-errors-with-stopBuildOnErrors.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/skips-builds-downstream-projects-if-upstream-projects-have-errors-with-stopBuildOnErrors-when-test-does-not-reference-core.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/should-not-trigger-recompilation-because-of-program-emit.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/should-not-trigger-recompilation-because-of-program-emit-with-outDir-specified.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-stopBuildOnErrors-is-passed-on-command-line.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-preserveWatchOutput-is-passed-on-command-line.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-preserveWatchOutput-is-not-used.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/non-local-change-does-not-start-build-of-referencing-projects.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/non-local-change-does-not-start-build-of-referencing-projects-with-circular-references.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/incremental-updates-in-verbose-mode.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/change-builds-changes-and-reports-found-errors-message.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/change-builds-changes-and-reports-found-errors-message-with-circular-references.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/builds-when-new-file-is-added,-and-its-subsequent-updates.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/sample/builds-when-new-file-is-added,-and-its-subsequent-updates-with-circular-references.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/roots/when-root-file-is-from-referenced-project.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/roots/when-root-file-is-from-referenced-project-and-shared-is-first.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/reexport/Reports-errors-correctly.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/projectsBuilding/when-there-are-8-projects-in-a-solution.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/projectsBuilding/when-there-are-8-projects-in-a-solution-with---builders-3.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/projectsBuilding/when-there-are-5-projects-in-a-solution.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/projectsBuilding/when-there-are-5-projects-in-a-solution-with---builders-2.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/projectsBuilding/when-there-are-3-projects-in-a-solution.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/projectsBuilding/when-there-are-3-projects-in-a-solution-with---builders-1.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/projectsBuilding/when-there-are-23-projects-in-a-solution.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/projectsBuilding/when-there-are-23-projects-in-a-solution-with---builders-3.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/works-with-extended-source-files.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/works-when-noUnusedParameters-changes-to-false.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/works-correctly-when-project-with-extended-config-is-removed.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/when-referenced-project-change-introduces-error-in-the-down-stream-project-and-then-fixes-it.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/tsbuildinfo-has-error.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/declarationEmitErrors-when-fixing-error-files-all-files-are-emitted.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/declarationEmitErrors-when-file-with-no-error-changes.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/declarationEmitErrors-introduceError-when-fixing-errors-only-changed-file-is-emitted.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/programUpdates/declarationEmitErrors-introduceError-when-file-with-no-error-changes.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmitOnError/noEmitOnError.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmitOnError/noEmitOnError-with-incremental.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmitOnError/noEmitOnError-with-declaration.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmitOnError/noEmitOnError-with-declaration-with-incremental.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/syntax-errors.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/syntax-errors-with-incremental.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/syntax-errors-with-incremental-as-modules.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/semantic-errors.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/semantic-errors-with-incremental.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/semantic-errors-with-incremental-as-modules.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/dts-errors.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/dts-errors-without-dts-enabled.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/dts-errors-without-dts-enabled-with-incremental.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/dts-errors-without-dts-enabled-with-incremental-as-modules.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/dts-errors-with-incremental.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/dts-errors-with-incremental-as-modules.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/does-not-go-in-loop-when-watching-when-no-files-are-emitted.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/noEmit/does-not-go-in-loop-when-watching-when-no-files-are-emitted-with-incremental.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/moduleResolution/handles-the-cache-correctly-when-two-projects-use-different-module-resolution-settings.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/libraryResolution/with-config.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/libraryResolution/with-config-with-libReplacement.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/extends/configDir-template.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/demo/updates-with-circular-reference.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js Baseline updated to include watch registration snapshot output
testdata/baselines/reference/tsbuildWatch/configFileErrors/reports-syntax-errors-in-config-file.js Baseline updated to include watch registration snapshot output
internal/execute/watchmanager/watchmanager.go New shared watch manager (dir watches + event coalescing + run loop)
internal/execute/watchmanager/watchbackend.go Watch backend abstraction, ignore logic, and watchability heuristics
internal/execute/watcher.go CLI watch mode refactored to use WatchManager
internal/execute/tsctests/sys.go Test sys watch-backend wiring updated for new interface
internal/execute/tsctests/mock_watch_backend.go Mock backend updated to implement watchmanager.WatchBackend
internal/execute/incremental/buildInfo.go Bounds-check buildinfo fileInfos access
internal/execute/build/orchestrator.go Build-mode watch converted from polling ticker to event-driven watches
internal/execute/build/buildtask.go Removed polling-based watch bookkeeping from build tasks

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 69 out of 69 changed files in this pull request and generated 4 comments.

Comment thread internal/execute/watcher.go Resolved
Comment thread internal/execute/build/orchestrator.go Resolved
Comment thread internal/execute/build/orchestrator.go Resolved
Comment thread internal/execute/build/orchestrator.go Resolved
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Jun 17, 2026
Merged via the queue into microsoft:main with commit 2fb5d4c Jun 17, 2026
21 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants