diff --git a/static/messages.js b/static/messages.js index 8295794d..220ab1a6 100644 --- a/static/messages.js +++ b/static/messages.js @@ -7092,7 +7092,7 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){ // identical turns make BOTH comparisons succeed, preferring the prefix // splices at the wrong offset and silently drops/duplicates rows // (#7628). Never prefer prefix when truncation is active. - const _truncatedRecovery=!!_messagesTruncated||!!(_oldestIdx>0); + const _truncatedRecovery=(typeof _messagesTruncated!=='undefined'&&!!_messagesTruncated)||(typeof _oldestIdx!=='undefined'&&!!(_oldestIdx>0)); const _preserveCurrentTranscript=preserveVisibleOnShorterTerminalSnapshot&&(_truncatedRecovery?_stagedMatchesCurrentSuffix:_stagedMatchesCurrentPrefix); const _resolvedMessages=_preserveCurrentTranscript ? [..._stagedMessages,..._currentVisibleMessages.slice(_truncatedRecovery?_stagedSuffixStart+_stagedMessages.length:_stagedMessages.length)] diff --git a/tests/test_session_default_window.py b/tests/test_session_default_window.py index b10e63bb..3676d061 100644 --- a/tests/test_session_default_window.py +++ b/tests/test_session_default_window.py @@ -158,7 +158,7 @@ def test_settle_truncation_signal_decides_match_strategy(): BOTH comparisons succeed; the prefix branch then splices at the wrong offset and silently drops/duplicates rows) (#7628).""" restore = _restore_settled_session_body() - assert "_truncatedRecovery=!!_messagesTruncated||!!(_oldestIdx>0)" in restore + assert "_truncatedRecovery=(typeof _messagesTruncated!=='undefined'&&!!_messagesTruncated)||(typeof _oldestIdx!=='undefined'&&!!(_oldestIdx>0))" in restore # The splice offset must follow the SAME truncation decision as the match # strategy — no fallthrough to prefix when both match. assert "_truncatedRecovery?_stagedSuffixStart+_stagedMessages.length:_stagedMessages.length" in restore