Repository navigation
fix: memory leak in notebook text diff editor - #331805
Dmitriy Vasyura (dmitrivMS) merged 11 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes notebook diff editor model leaks by aligning disposables with each editor input’s lifetime.
Changes:
- Disposes layout work during model detachment.
- Registers diff view models in the input-specific disposable store.
- Reuses model-detachment cleanup when clearing input.
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Mohammad javad Dianat (dianatofficial)
left a comment
There was a problem hiding this comment.
Verified the diff. Changes align with project standards.
P3: reset the current-change index when clearing an inputThe new Previously, clearing the input spliced the list while that subscription was still alive. With this change, a cached pane can retain the previous input's current-change index. This observable is consumed by the chat notebook-diff integration, including navigation-boundary decisions, so it is not just an unused field. Suggested repro / regression test (source-derived; not executed):
Could the detach path explicitly reset the observable, with a focused clear/reuse test? That would preserve the new input-specific ownership without depending on a listener that has already been disposed. Validation limit: the ordering and only-writer relationship were checked statically; I have not reproduced a visible chat-navigation failure. The pane's own next/previous navigation uses list focus and is not claimed broken. |
Race-coverage request: clearing the layout token before the final set-input continuationThis is a lower-confidence validation concern, not a reproduced user-visible regression. The new assignment clearing the layout cancellation source needs to be considered alongside the await of modified-webview creation and the subsequent unguarded Suggested deterministic interleaving for a scoped test (not executed):
An input/model-staleness check after the await, before accessing the source, would make the intended close-during-open behavior explicit. Scope/limitations: the real helper currently has no internal await, so normal UI reachability of this microtask interleaving is unverified; the proposed test deliberately controls it. There is already a similar earlier-await failure involving a cleared model, so this is not a claim that the PR introduced the broader cancellation problem. Please treat this as a narrowly scoped test/guard request, not a confirmed general cancellation regression. |
Dmitriy Vasyura (dmitrivMS)
left a comment
There was a problem hiding this comment.
Please see inline comments
|
Created a separate PR to handle cancellation of diffEditorInputs better: #339389 |
P3: the change index still survives input clearing at the current headFollowing up on the earlier index-reset finding: this remains present at current head The new
Previously, Suggested repro / regression test (source-derived; not executed):
Please explicitly reset Validation limit: both independent source reviews identified the ordering regression, but no Code OSS reproduction or visible chat-navigation failure was demonstrated. The pane's own next/previous commands use list focus and are not claimed broken. This is a low-severity observable-state regression, not a claim of a broad navigation outage. |
Dmitriy Vasyura (dmitrivMS)
left a comment
There was a problem hiding this comment.
Please consider new review comment
|
Should be resolved with PR #339389, which is now merged. |
|
Addressed minor Copilot feedback! |
|
Simon Siefke (@SimonSiefke) Thank you! |



Details
Notebook diff view models were registered in the editor pane's lifetime disposable store, so closing a notebook diff editor left every previous view model and its notebook models reachable.
Change
Register each notebook diff view model in the input-specific store and run the existing model-detach cleanup when the editor input is cleared.
Before
When opening and closing a notebook diff editor 37 times, notebook diff view models and their notebook models grow once or twice per run:
After
No more notebook diff view model or notebook model leak is detected.
Test Video
test-video.webm