fix(ui): stabilize virtual list rerender measurements

Keep visible rows mounted during follow-up measurements and clear stale refs so async message rendering no longer flickers or measures detached blocks. Coalesce per-item render notifications so content-heavy rows only trigger one remeasurement per frame.
This commit is contained in:
Shantur Rathore
2026-03-08 18:09:43 +00:00
parent c64a9a03f9
commit b33421a375
3 changed files with 49 additions and 18 deletions

View File

@@ -787,7 +787,10 @@ export default function MessageBlock(props: MessageBlockProps) {
return resultBlock
})
let measuredBlockElement: HTMLDivElement | undefined
onCleanup(() => {
measuredBlockElement = undefined
props.onMeasureElementChange?.(null)
})
@@ -797,11 +800,19 @@ export default function MessageBlock(props: MessageBlockProps) {
return resolved
})
createEffect(() => {
if (visibleBlock()) return
if (!measuredBlockElement) return
measuredBlockElement = undefined
props.onMeasureElementChange?.(null)
})
return (
<Show when={visibleBlock()}>
{(resolvedBlock) => (
<div
ref={(el) => {
measuredBlockElement = el
props.onMeasureElementChange?.(el)
}}
class="message-stream-block"