Skip to content

fix: detach diff models before disposal#4

Merged
exKAZUu merged 2 commits into
mainfrom
fix/upstream-open-issues
Apr 18, 2026
Merged

fix: detach diff models before disposal#4
exKAZUu merged 2 commits into
mainfrom
fix/upstream-open-issues

Conversation

@exKAZUu
Copy link
Copy Markdown
Member

@exKAZUu exKAZUu commented Apr 18, 2026

Summary

Upstream issue triage

Verification

  • yarn check-for-ai
  • yarn typecheck
  • yarn build

exKAZUu and others added 2 commits April 18, 2026 18:15
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the disposeEditor function in DiffEditor.tsx to ensure more reliable cleanup of Monaco editor instances and models. Key changes include explicitly setting the model to null, disposing of the editor, and resetting internal state flags. Feedback was provided to address potential TypeError exceptions when checking the disposal status of models, as the current implementation lacks necessary safety checks for null or undefined model references.

Comment on lines +210 to 212
if (!keepCurrentOriginalModel && !models?.original.isDisposed()) {
models?.original?.dispose();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The expression models?.original.isDisposed() will throw a TypeError if models is null or undefined, because it attempts to access the .isDisposed() method on an undefined value. Since editor?.getModel() can return null if no model is set, you should verify that models.original exists before checking its disposal state.

Suggested change
if (!keepCurrentOriginalModel && !models?.original.isDisposed()) {
models?.original?.dispose();
}
if (!keepCurrentOriginalModel && models?.original && !models.original.isDisposed()) {
models.original.dispose();
}

Comment on lines +214 to 216
if (!keepCurrentModifiedModel && !models?.modified.isDisposed()) {
models?.modified?.dispose();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the original model check, models?.modified.isDisposed() will crash if models is null. Ensure safe access to the modified model before calling isDisposed().

Suggested change
if (!keepCurrentModifiedModel && !models?.modified.isDisposed()) {
models?.modified?.dispose();
}
if (!keepCurrentModifiedModel && models?.modified && !models.modified.isDisposed()) {
models.modified.dispose();
}

@exKAZUu exKAZUu merged commit f1a98ef into main Apr 18, 2026
8 checks passed
@exKAZUu exKAZUu deleted the fix/upstream-open-issues branch April 18, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant