fix(editor): dispose compose DiffEditor models after widget reset (#1828)

Closing the compose or git diff dialog threw a Monaco console error
because the library disposed TextModels while DiffEditorWidget still
held them.
This commit is contained in:
Anso
2026-08-13 10:32:26 -04:00
committed by GitHub
parent f5178889eb
commit 93a5ba9f21
5 changed files with 132 additions and 6 deletions
@@ -3,8 +3,8 @@ import { render, screen } from '@testing-library/react';
import { ComposeDiffPreviewDialog } from '../ComposeDiffPreviewDialog';
import { resolveComposeDiffActionLabel } from '../resolveComposeDiffActionLabel';
vi.mock('@/lib/monacoLoader', () => ({
DiffEditor: () => <div data-testid="diff-editor" />,
vi.mock('@/lib/SafeDiffEditor', () => ({
SafeDiffEditor: () => <div data-testid="diff-editor" />,
}));
describe('resolveComposeDiffActionLabel', () => {
@@ -45,4 +45,24 @@ describe('ComposeDiffPreviewDialog', () => {
);
expect(screen.getByRole('button', { name: 'Save & reapply' })).toBeInTheDocument();
});
it('unmounts the diff editor without throwing', () => {
const { unmount } = render(
<ComposeDiffPreviewDialog
open
onOpenChange={vi.fn()}
stackName="sencho"
fileName="docker-compose.yml"
language="yaml"
original="a"
modified="b"
actionLabel="Save"
confirming={false}
isDarkMode={false}
onConfirm={vi.fn()}
/>,
);
expect(screen.getByTestId('diff-editor')).toBeInTheDocument();
expect(() => unmount()).not.toThrow();
});
});