fix: prevent interactive stream crash on node removal

This commit is contained in:
Kevin
2026-04-01 11:23:47 +08:00
parent ba5e1f07af
commit c957d495ac
2 changed files with 9 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@gitlawb/openclaude",
"version": "0.1.1",
"version": "0.1.2",
"description": "Claude Code opened to any LLM — OpenAI, Gemini, DeepSeek, Ollama, and 200+ models",
"type": "module",
"bin": {

View File

@@ -227,19 +227,21 @@ function collectRemovedRects(
removed: DOMNode,
underAbsolute = false,
): void {
if (removed.nodeName === '#text') return
const elem = removed as DOMElement
if (!removed || removed.nodeName === '#text') return
const elem = removed as Partial<DOMElement>
// If this node or any ancestor in the removed subtree was absolute,
// its painted pixels may overlap non-siblings — flag for global blit
// disable. Normal-flow removals only affect direct siblings, which
// hasRemovedChild already handles.
const isAbsolute = underAbsolute || elem.style.position === 'absolute'
const cached = nodeCache.get(elem)
const isAbsolute = underAbsolute || elem.style?.position === 'absolute'
const cached = nodeCache.get(elem as DOMElement)
if (cached) {
addPendingClear(parent, cached, isAbsolute)
nodeCache.delete(elem)
nodeCache.delete(elem as DOMElement)
}
for (const child of elem.childNodes) {
const childNodes = Array.isArray(elem.childNodes) ? [...elem.childNodes] : []
for (const child of childNodes) {
if (!child) continue
collectRemovedRects(parent, child, isAbsolute)
}
}