mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-07-13 11:10:37 +00:00
95e874d7be
Codex caught an asymmetry in the first cut: the rebuilt side selected the tail live segment ([...].pop()) but the preserved side used querySelector() = the FIRST [data-live-assistant=1] segment. In a multi-live-segment turn (reconnect / post-tool activity boundaries — see messages.js ensureAssistantRow re-attaching to the LAST live segment), the smd parser writes into the tail segment, so swapping the first preserved segment would move the wrong node and leave the parser-owned tail detached — re-introducing the flicker for multi-segment turns. Fix: select the preserved segment from querySelectorAll, defaulting to the LAST (tail), and prefer the one whose data-live-segment-seq matches the rebuilt tail; compute _preservedLen from that segment. Added a structural regression test pinning the tail selection. Verified live: a 2-live-segment turn (seq 1 + seq 2, parser on seq 2) keeps the parser-owned tail connected across a mid-stream rebuild (was orphaned with the first-segment selection).