Skip to content

Preserve inferred project ATA state - #64327

Draft
Jake Bailey (jakebailey) wants to merge 6 commits into
microsoft:mainfrom
jakebailey:preserve-inferred-ata
Draft

Jake Bailey (jakebailey) wants to merge 6 commits into
microsoft:mainfrom
jakebailey:preserve-inferred-ata

Conversation

@jakebailey

Copy link
Copy Markdown
Member

I noticed in our scripts dir (no tsconfig), that clicking on a file flashed errors. I closed it, opened another file, and the errors appeared and disappeared again! If I opened another file without closing the first, that one was fine.

The issue is that we lose the ATA state when inferred projects go away, so reopening causes ATA to happen again.

Save the state and apply it directly to inferred projects if present.

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.

Copilot review overview

🟡 Changes recommended

Cached ATA state can be incorrectly reused across unrelated roots or changed manifests.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Preserves ATA results when inferred projects are recreated.

Changes:

  • Stores and restores inferred-project typings state.
  • Adds a reopening regression test.
File Description
projectcollectionbuilder.go Transfers cached ATA state.
projectcollection.go Stores cached ATA state.
project.go Defines ATA state capture/application.
ata/​ata_test.go Tests immediate typings restoration.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread tsc/internal/project/projectcollectionbuilder.go Outdated

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.

Copilot review overview

🟡 Changes recommended

Cache validation misses filesystem invalidation and changed ATA inputs, and content-mapped roots use incompatible hashes.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Invalidate ATA cache when inferred-project options change

tsc/​internal/​project/​project.go:214

Root names and contents are not the complete ATA input. If inferred-project compiler options change while no inferred project exists, the cached state is left untouched; reopening the same roots applies typings computed under the old options before ATA is queued in the background (and resolution-affecting options can also change the unresolved-import set). Preserve and compare the relevant command-line/mapping inputs, or invalidate this cache when those inputs change.

Comment thread tsc/internal/project/project.go Outdated
Comment thread tsc/internal/project/projectcollectionbuilder.go Outdated
@jakebailey
Jake Bailey (jakebailey) marked this pull request as draft September 19, 2026 03:54

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.

Copilot review overview

🟡 Changes recommended

Stale ATA results can still overwrite invalidated configured or synthetic project state, and key new branches lack regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 2 Low severity

Open (3)
Resolved since last review (3)

logger.Embed(ataChange.Logs)
if _, ok := projectID.Inferred(); ok {
updateProject(b.inferredProject, ataChange)
if ataChange.SnapshotID < b.inferredProjectATAInvalidationSnapshotID {
packageNameToTypingLocation.Range(func(name string, typing *CachedTyping) bool {
registryEntry := typesRegistry[name]
if inferredTypings[name] == "" && registryEntry != nil && isTypingUpToDate(typing, registryEntry) {
if inferred, ok := inferredTypings[name]; ok && inferred == "" && registryEntry != nil && isTypingUpToDate(typing, registryEntry) {
}
if b.inferredProject.Value() != nil {
updateProject(b.inferredProject, ataChange)
} else {
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

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants