perf(webui): reduce repeated work and bound history rendering (#5703)
* perf(webui): reduce repeated work and bound history rendering * fix(webui): keep continuation reasoning with its answer * refactor(webui): reuse answer buffers and prepared copy text * perf(webui): restore conditional replay buffer initialization * fix(webui): remove code block pagination
This commit is contained in:
1 parent
1c451b5b5f
commit
1469d4811c
32 files changed
+1156
-361
No files matched your search
@@ -4,6 +4,8 @@ from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
import nanobot.webui.transcript as transcript_module
|
||||
from nanobot.session.history_visibility import HIDDEN_HISTORY_META
|
||||
from nanobot.webui.transcript import (
|
||||
@@ -1700,6 +1702,34 @@ def test_replay_merges_length_recovery_segments_into_one_assistant_message() ->
|
||||
assert msgs[0]["content"] == "first second"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("event", ["delta", "stream_end"])
|
||||
def test_replay_recovery_answer_does_not_overwrite_an_unfinished_turn(event: str) -> None:
|
||||
msgs = replay_transcript_to_ui_messages([
|
||||
{
|
||||
"event": "stream_end", "text": "Original answer", "turn_id": "original",
|
||||
"resuming": True, "merge_next": True,
|
||||
},
|
||||
{"event": event, "text": "Recovered answer", "turn_id": "recovery"},
|
||||
{"event": "turn_end", "turn_id": "recovery"},
|
||||
])
|
||||
|
||||
assert [(m["turnId"], m["content"]) for m in msgs] == [
|
||||
("original", "Original answer"), ("recovery", "Recovered answer"),
|
||||
]
|
||||
|
||||
|
||||
def test_replay_reasoning_after_an_ordinary_answer_preserves_the_answer_boundary() -> None:
|
||||
msgs = replay_transcript_to_ui_messages([
|
||||
{"event": "delta", "text": "First answer"},
|
||||
{"event": "reasoning_end", "text": "Consider the next answer"},
|
||||
{"event": "stream_end", "text": "Next answer"},
|
||||
{"event": "turn_end"},
|
||||
])
|
||||
|
||||
assert [m["content"] for m in msgs] == ["First answer", "Next answer"]
|
||||
assert msgs[1]["reasoning"] == "Consider the next answer"
|
||||
|
||||
|
||||
def test_replay_tool_events_dedupes_finish_after_start() -> None:
|
||||
msgs = replay_transcript_to_ui_messages([
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user