test(chat): refresh terminal recovery source-shape guards (#5224)

This commit is contained in:
Rod Boev authored and nesquena-hermes committed 2026-06-30 03:33:55 +00:00
1 parent c17f222427
commit 42cc02634a
3 files changed
+8 -7

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ def test_done_and_restore_filters_recovery_messages_from_frontend_state():
def test_apererror_recovers_on_recovery_control_event():
assert "isRecoveryControlMessage=isInterrupted && (d.recovery_control===true || _streamRecoveryControlMessageText(d.message));" in MESSAGES_JS
assert "Stream recovery signal received. Restoring transcript..." in MESSAGES_JS
assert "if(await _restoreSettledSession(source)) return;" in MESSAGES_JS
assert "if(await _restoreSettledSession(source, {preserveVisibleOnShorterTerminalSnapshot:true})) return;" in MESSAGES_JS
def test_ui_rejects_recovery_control_as_visible_assistant_content():
@@ -611,10 +611,11 @@ def test_stream_end_restore_attaches_projected_anchor_scene_before_render():
restore = _function_body(MESSAGES_JS, "_restoreSettledSession")
assert "function _attachProjectedAnchorSceneToLastAssistant" in MESSAGES_JS
attach_idx = restore.index("_attachProjectedAnchorSceneToLastAssistant(_nextMsgs3018);")
carry_idx = restore.index("S.messages=_carryForwardEphemeralTurnFields")
carry_idx = restore.index("const _stagedMessages=_carryForwardEphemeralTurnFields(_currentMessages, _nextMsgs3018);")
filter_idx = restore.index("S.messages=_filterRecoveryControlMessages(_resolvedMessages || []);")
attach_idx = restore.index("_attachProjectedAnchorSceneToLastAssistant(S.messages);")
render_idx = restore.index("syncTopbar();renderMessages({preserveScroll:true})")
assert attach_idx < carry_idx < render_idx
assert carry_idx < filter_idx < attach_idx < render_idx
def test_cancel_settlement_attaches_projected_anchor_scene_before_render():
@@ -656,7 +657,7 @@ def test_connection_error_terminal_message_attaches_projected_anchor_scene_befor
error = _function_body(MESSAGES_JS, "_handleStreamError")
assert "_applyToAnchor('error'" in error
push_idx = error.index("S.messages.push({role:'assistant',content:'**Connection interrupted:**")
push_idx = error.index("_appendTerminalStreamErrorMarkerIfMissing(S.messages);")
attach_idx = error.index("_attachProjectedAnchorSceneToLastAssistant(S.messages);")
render_idx = error.index("renderMessages({preserveScroll:true});")
assert push_idx < attach_idx < render_idx
+2 -2
View File
@@ -91,5 +91,5 @@ def test_deferred_hidden_stream_error_reattaches_or_restores_before_inline_error
assert "api(`/api/chat/stream/status?stream_id=${encodeURIComponent(streamId)}`)" in recovery_block
assert "if(st.active)" in recovery_block
assert "_wireSSE(new EventSource" in recovery_block
assert "if(await _restoreSettledSession(source)) return;" in recovery_block
assert recovery_block.find("if(await _restoreSettledSession(source)) return;") < recovery_block.rfind("_handleStreamError(source)")
assert "if(await _restoreSettledSession(source, {preserveVisibleOnShorterTerminalSnapshot:true})) return;" in recovery_block
assert recovery_block.find("if(await _restoreSettledSession(source, {preserveVisibleOnShorterTerminalSnapshot:true})) return;") < recovery_block.rfind("_handleStreamError(source)")