Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(site): dispose Monaco diff models on unmount (#28503) - #28809

Merged
mtojek merged 2 commits into
release/2.37from
jakehwll/DEVEX-736-backport-2.37
Sep 1, 2026
Merged

fix(site): dispose Monaco diff models on unmount (#28503)#28809
mtojek merged 2 commits into
release/2.37from
jakehwll/DEVEX-736-backport-2.37

Conversation

@jakehwll

@jakehwll jakehwll commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was written by Coder Agents on behalf of Jake Howell.

Backport of #28503 to release/2.37.

Refs DEVEX-736. This carries the Monaco diff-model lifecycle cleanup and Storybook regression coverage into 2.37, preventing template-version navigation from retaining models until the editor becomes unusable.

The original patch applies cleanly to this release branch.

Backport of #28503 to release/2.37.

`SyntaxHighlighter` sets `keepCurrentOriginalModel` /
`keepCurrentModifiedModel`, so `@monaco-editor/react` never disposes the
diff editor's text models. Without stable model paths, every render of a
template version created fresh anonymous models that were never freed,
so navigating between versions leaked models until the tab hung.

Move the diff editor into a `DiffFile` component that captures the
original and modified models in `onMount` and disposes them when the
diff editor unmounts, including the diff to plain switch while
`SyntaxHighlighter` stays mounted. Disposal is deferred with
`queueMicrotask` because freeing the models in the same synchronous
teardown throws `TextModel got disposed before DiffEditorWidget model
got reset`. The `keepCurrent*Model` flags stay, since removing them
reintroduces that mid-teardown throw.

Adds `SyntaxHighlighter.stories.tsx` with a `DisposesModelsOnDiffToggle`
play test asserting the model count returns to baseline across diff and
plain toggles.

(cherry picked from commit 5008603)
@jakehwll jakehwll added the backport/v2.37 Backport PR targeting release/2.37 label Sep 1, 2026
@jakehwll jakehwll self-assigned this Sep 1, 2026
@linear-code

linear-code Bot commented Sep 1, 2026

Copy link
Copy Markdown

DEVEX-736

@jakehwll
jakehwll marked this pull request as ready for review September 1, 2026 07:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T07:33:59.052535Z b0a52db Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mtojek
mtojek self-requested a review September 1, 2026 07:37
@mtojek
mtojek merged commit 046189d into release/2.37 Sep 1, 2026
26 checks passed
@mtojek
mtojek deleted the jakehwll/DEVEX-736-backport-2.37 branch September 1, 2026 12:35
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/v2.37 Backport PR targeting release/2.37

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants