Skip to content

Isolate copied notebook output items - #347117

Open
Sameer (sameerihs) wants to merge 1 commit into
microsoft:mainfrom
sameerihs:isolate-copied-notebook-output-items
Open

Sameer (sameerihs) wants to merge 1 commit into
microsoft:mainfrom
sameerihs:isolate-copied-notebook-output-items

Conversation

@sameerihs

Copy link
Copy Markdown
Contributor

Fixes #347116

Copying a running notebook cell shares its mutable output-item array. Later stream appends can therefore change the saved output of the unexecuted copy. Give each cloned output its own array while retaining the existing item buffers.

Two model/command regressions and a public API regression cover appending and saving. The API test uses a synthetic controller, Copy Cell Down and the existing serializer, then checks the written bytes. It fails on unchanged main and packaged stable 1.145.2 and passes with the fix.

Validation on macOS: 111 neighbouring unit tests pass with five existing pending cases; all 11 Notebook Kernel API tests pass. Client/API compilation, client typechecking and changed-file lint pass.

This touches the clone helper also used by #319694, whose change preserves user metadata rather than output-array ownership.

Copilot AI balanced review requested due to automatic review settings November 9, 2026 18:52

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

No active review issues were identified for the change isolating copied notebook output-item arrays.

No open issues 🎉

What changed in this PR

Fixes #347116 by giving copied notebook outputs independent item arrays, preventing later stream appends from changing the unexecuted copy’s saved output. Existing item buffers remain shared.

Changes:

  • Shallow-copy output-item arrays when cloning notebook cells.
  • Add command-level regressions for appends to both the source and copied cell.
  • Add an API regression that copies a running cell, appends output, and checks the saved bytes.
File Description
src/​vs/​workbench/​contrib/​notebook/​test/​browser/​cellOperations.test.ts Tests output isolation in both append directions.
src/​vs/​workbench/​contrib/​notebook/​common/​model/​notebookCellTextModel.ts Creates a separate output-item array for each clone.
extensions/​vscode-api-tests/​src/​singlefolder-tests/​notebook.kernel.test.ts Verifies copied output remains unchanged through serialization and saving.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copying a running notebook cell lets later output change the saved copy

3 participants