Currently, TerminalViewport uses a 32-char probe heuristic to find the overlap between the trimmed rawOutput buffer and the live xterm state, then replays only the new tail. This works for most output but has a known failure mode: if the probe matches the wrong repeated region, the delta arithmetic is wrong, lastRawOutputRef advances past the true match, and content is silently dropped from xterm.
The right fix is to surface trimmedFront from appendTerminalRawOutput — the exact byte count removed on each cap-trim. With that value, the replay offset is arithmetic (rawOutput.length - trimmedFront) rather than a string search, and the heuristic can be removed entirely.
Tracked from: #156
Currently,
TerminalViewportuses a 32-char probe heuristic to find the overlap between the trimmedrawOutputbuffer and the live xterm state, then replays only the new tail. This works for most output but has a known failure mode: if the probe matches the wrong repeated region, the delta arithmetic is wrong,lastRawOutputRefadvances past the true match, and content is silently dropped from xterm.The right fix is to surface
trimmedFrontfromappendTerminalRawOutput— the exact byte count removed on each cap-trim. With that value, the replay offset is arithmetic (rawOutput.length - trimmedFront) rather than a string search, and the heuristic can be removed entirely.Tracked from: #156