Skip to content

Preserve snapshot identity across no-op updates - #64373

Merged
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:api/snapshot-stable-identity
Sep 21, 2026
Merged

Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:api/snapshot-stable-identity

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Missed this in #64204

Copilot AI balanced review requested due to automatic review settings September 21, 2026 16:22
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 21, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 21, 2026

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

Same-ID updates leak the additional server-side snapshot reference.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 High severity

Open (2)
What changed in this PR

Preserves client snapshot identity when no-op updates return the existing snapshot ID.

Changes:

  • Reuses the base snapshot for matching IDs.
  • Adds sync and async identity tests.
File Description
packages/​typescript/​src/​api/​sync/​api.ts Reuses snapshots in sync and generator paths.
packages/​typescript/​src/​api/​async/​api.ts Reuses snapshots in the async path.
packages/​typescript/​test/​sync/​api.test.ts Tests sync identity preservation.
packages/​typescript/​test/​async/​api.test.ts Tests async identity preservation.

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

Comment thread packages/typescript/src/api/async/api.ts
Comment thread packages/typescript/src/api/sync/api.ts

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

🔵 Needs a closer look

Same-ID responses can contain request-specific operation results that are currently discarded.

Review effort: Balanced
Findings: None

Resolved since last review (2)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Retain openedFiles results for state-level no-op updates

packages/​typescript/​src/​api/​async/​api.ts:413

Returning baseSnapshot discards the operation results associated with this update request. A state-level no-op can still have openedFiles results, so callers may receive the base object's stale operation and even a runtime tuple shape that contradicts this overload's inferred type. Preserve identity only when both response operation fields are absent.

Medium severity Preserve operation results when reusing snapshot IDs

packages/​typescript/​src/​api/​sync/​api.ts:645

Returning baseSnapshot here discards data.operation, although operation results are correlated with the current request. A no-state-change request can still carry results (for example, repeated/subset openFiles, including an empty tuple), so this can return stale results from the base request and violate the inferred tuple type. Reuse identity only when the response has no operation fields; otherwise construct the new wrapper for this server snapshot ID.

This issue also appears on line 673 of the same file.

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Sep 21, 2026
@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Sep 21, 2026
Merged via the queue into microsoft:main with commit 4000050 Sep 21, 2026
28 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the api/snapshot-stable-identity branch September 21, 2026 17:34
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Sep 21, 2026
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: Done

Development

Successfully merging this pull request may close these issues.

3 participants