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", "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", "description": "Claude Code opened to any LLM — OpenAI, Gemini, DeepSeek, Ollama, and 200+ models",
"type": "module", "type": "module",
"bin": { "bin": {

View File

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