Skip to content

fix: guard notebook diff input lifecycle - #339389

Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/notebook-diff-input-lifecycle
Oct 13, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/notebook-diff-input-lifecycle

Conversation

@SimonSiefke

@SimonSiefke Simon Siefke (SimonSiefke) commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

This PR is needed for #331805


Details

Closing or replacing a notebook diff input while it is opening can let the old setInput() operation resume against a cleared or replacement model. The editor pane can also keep the previous input's current-change index when model detachment removes its focus listener before clearing the list.

Change

Check cancellation and input/model identity after model resolution and each webview creation. Reset the current-change index to -1 when detaching a model or clearing an input.

Validated with all 88 notebook-diff browser tests, including 10 deterministic lifecycle regression cases, focused ESLint, and the client TypeScript check.


AI disclosure: Model: GPT-6.1. Worktime: 5 min

Copilot AI balanced review requested due to automatic review settings October 2, 2026 20:49

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

The new early-return paths can leave newly created webviews mounted and undisposed.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Guards notebook diff editor setup against stale asynchronous input operations and resets navigation state during teardown.

Changes:

  • Adds cancellation and input/model identity checks during setup.
  • Resets the current-change index when clearing or detaching models.
  • Adds lifecycle regression tests.
File Description
notebookDiffEditor.ts Adds lifecycle guards and state resets.
notebookDiffEditor.test.ts Tests clearing, replacement, and cancellation races.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

🟢 Approval recommended

The lifecycle races are addressed with scoped cleanup and comprehensive deterministic tests.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit a7bfc0f into microsoft:main Oct 13, 2026
35 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 13, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/notebook-diff-input-lifecycle branch October 13, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues notebook-diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants