fix(npcs): stop TipTap crash black screen in secondary windows

Guard TipTap getHTML under StrictMode, wrap secondary window roots in WindowErrorBoundary, and add stability regression tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ivan Fontosh
2026-07-30 09:10:47 +08:00
parent e687303c57
commit 04c75cd725
15 changed files with 305 additions and 64 deletions
@@ -0,0 +1,38 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { readTipTapHtmlSafe } from './tiptapEditorSafe';
void test('readTipTapHtmlSafe: null / destroyed → null', () => {
assert.equal(readTipTapHtmlSafe(null), null);
assert.equal(readTipTapHtmlSafe(undefined), null);
assert.equal(
readTipTapHtmlSafe({
isDestroyed: true,
getHTML: () => '<p>x</p>',
}),
null,
);
});
void test('readTipTapHtmlSafe: getHTML throw → null', () => {
assert.equal(
readTipTapHtmlSafe({
isDestroyed: false,
getHTML: () => {
throw new TypeError("Cannot read properties of null (reading 'cached')");
},
}),
null,
);
});
void test('readTipTapHtmlSafe: ok → html', () => {
assert.equal(
readTipTapHtmlSafe({
isDestroyed: false,
getHTML: () => '<p>ok</p>',
}),
'<p>ok</p>',
);
});