Skip to content

Refresh content mapper configuration when open watched files are saved - #65446

Merged
Andrew Branch (andrewbranch) merged 7 commits into
mainfrom
copilot/content-mappers-fix-watched-files
Nov 11, 2026
Merged

Andrew Branch (andrewbranch) merged 7 commits into
mainfrom
copilot/content-mappers-fix-watched-files

Conversation

Copilot AI commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Saving an open watchedFiles file could leave content mapper types stale: an earlier edit refreshed configuration from old disk content, while subsequent save/watch notifications were suppressed by the overlay.

  • Invalidation: Preserve disk changes hidden by overlays in FileChangeSummary.DiskChanged and include them when refreshing affected mapper projects, without marking overlay source text as changed.
  • Regression coverage: Exercise edit → request → save with save-only, watch-only, and combined notifications; verify unrelated open files do not reopen the mapper.

Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix openProject re-run on saving watchedFiles Refresh content mapper configuration when open watched files are saved Nov 11, 2026
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>

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.

🟡 Changes recommended

Configuration invalidation can be lost after save-then-edit sequences or missed through node_modules symlink aliases, leaving mapper configuration stale.

2 open issues
What changed in this PR

This PR addresses stale content mapper configuration when a watched file is saved while open in the editor, separating disk notifications from overlay source-text changes.

Changes:

  • Track overlay-hidden disk changes in FileChangeSummary.
  • Use disk changes to refresh affected mapper projects while excluding unsaved overlay edits.
  • Add regression coverage for save-only, watch-only, combined notifications, and unrelated open files.
File Description
tsc/​internal/​project/​projectcollectionbuilder.go Uses disk-change notifications for mapper configuration refreshes.
tsc/​internal/​project/​overlayfs.go Records saves and watch notifications hidden by overlays.
tsc/​internal/​project/​overlayfs_test.go Verifies disk notifications without overlay text changes.
tsc/​internal/​project/​filechange.go Adds DiskChanged tracking, cloning, merging, and emptiness checks.
tsc/​internal/​project/​contentmapper_test.go Tests mapper refresh behavior across notification combinations.

Review effort: Balanced

Comment thread tsc/internal/project/overlayfs.go Resolved
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>

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.

🔵 Needs a closer look

Observed disk events are lost when watched configuration changes are followed by opening or closing the file, leaving cached mappers stale and requiring fixes with regression coverage.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity Preserve disk invalidation when opening a watched configuration

tsc/​internal/​project/​overlayfs.go:462

If an external write and watch notification for a cached mapper configuration are immediately followed by didOpen, the open branch discards the disk invalidation. It bypasses the later DiskChanged recording, while the new overlay filter excludes the Changed entry produced by opening the file, leaving the mapper stale. Preserve observed disk events in DiskChanged before processing the open, and add a watch → open regression case.

Medium severity Record disk changes when closing a saved configuration

tsc/​internal/​project/​overlayfs.go:571

For a save-only client, saving a watched configuration and closing its tab before the next flush still leaves the mapper stale. The close removes the overlay before this check, and no Changed entry is added when the saved disk text matches the previously flushed overlay. Record the observed disk event even when the overlay is being closed, and add a save → close → request regression case.

1 resolved since last review

Review effort: Balanced

@andrewbranch

Copy link
Copy Markdown
Member

Copilot fix previously missed issues

Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Copilot fix previously missed issues

Fixed in 19cd34b. Disk invalidation now survives watch → open and save → close, with regression coverage for both and save → reopen. npx hereby validate passed. Secret scanning passed; CodeQL analysis was skipped because its database exceeded the size limit.

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.

🔵 Needs a closer look

The changed-file filter drops watched symlink aliases for real-path disk notifications when no overlay exists at the real path, leaving mapper configuration stale.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve disk-change provenance when expanding symlink aliases

tsc/​internal/​project/​projectcollectionbuilder.go:423

When a mapper watches an open symlink alias such as /project/node_modules/pkg/package.json, a watch-only notification at its real path /packages/pkg/package.json leaves DiskChanged empty because no overlay exists at that real path. Alias expansion adds the watched alias to Changed, but this filter removes it, leaving the mapper configuration stale. Preserve disk-event provenance before alias expansion, and add a regression with the overlay at the symlink path and the notification at the real path.

1 resolved since last review

Review effort: Balanced

@andrewbranch

Copy link
Copy Markdown
Member

Copilot fix previously missed issue

Copilot AI and others added 2 commits November 11, 2026 20:02
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Copilot fix previously missed issue

Fixed in 99982aa. Disk-change provenance now survives alias expansion when the overlay is at the symlink path and the watch notification is at the real path. Added a regression verifying the mapper refreshes while unsaved overlay text remains unchanged. npx hereby validate and secret scanning passed. CodeQL analysis was skipped because its database exceeded the size limit.

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.

🔵 Needs a closer look

Human assessment is needed to evaluate the performance impact of large batches of unrelated file changes triggering unnecessary mapper refreshes and project rebuilds.

No open issues 🎉

Review effort: Balanced

@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 330fad8 Nov 11, 2026
35 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the copilot/content-mappers-fix-watched-files branch November 11, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content mappers: saving a watchedFiles file that is open in the editor never re-runs openProject (stale types until the language server is restarted)

4 participants