refactor(webui): remove legacy message projection (#5823)
* refactor(webui): defer oversized replay traces as events * fix(webui): type deferred trace index set * refactor(webui): remove legacy message projection * fix(webui): type event protocol boundaries * test(webui): assert canonical thread events
This commit is contained in:
1 parent
756c8bb7ed
commit
0983762fe5
23 files changed
+943
-2839
No files matched your search
@@ -1,54 +0,0 @@
|
||||
"""WebUI replay behavior for structured context-compaction events."""
|
||||
|
||||
import pytest
|
||||
|
||||
from nanobot.webui.transcript import replay_transcript_to_ui_messages
|
||||
|
||||
|
||||
@pytest.mark.parametrize("phase", ["succeeded", "cancelled"])
|
||||
def test_replay_folds_compaction_lifecycle_into_one_stable_message(phase) -> None:
|
||||
messages = replay_transcript_to_ui_messages([
|
||||
{
|
||||
"event": "context_compaction",
|
||||
"compaction_id": "compact-1",
|
||||
"phase": "started",
|
||||
"created_at_ms": 1_700_000_000_000,
|
||||
},
|
||||
{
|
||||
"event": "context_compaction",
|
||||
"compaction_id": "compact-1",
|
||||
"phase": phase,
|
||||
"created_at_ms": 1_700_000_001_000,
|
||||
},
|
||||
])
|
||||
|
||||
assert messages == [{
|
||||
"id": "compaction-compact-1",
|
||||
"role": "assistant",
|
||||
"content": "",
|
||||
"kind": "compaction",
|
||||
"createdAt": 1_700_000_000_000,
|
||||
"turnPhase": "activity",
|
||||
"compaction": {
|
||||
"id": "compact-1",
|
||||
"phase": phase,
|
||||
},
|
||||
}]
|
||||
|
||||
|
||||
def test_replay_keeps_distinct_compactions_in_one_turn() -> None:
|
||||
messages = replay_transcript_to_ui_messages([
|
||||
{
|
||||
"event": "context_compaction",
|
||||
"compaction_id": compaction_id,
|
||||
"phase": phase,
|
||||
}
|
||||
for compaction_id in ("compact-1", "compact-2")
|
||||
for phase in ("started", "succeeded")
|
||||
])
|
||||
|
||||
assert [message["id"] for message in messages] == [
|
||||
"compaction-compact-1",
|
||||
"compaction-compact-2",
|
||||
]
|
||||
assert all(message["compaction"]["phase"] == "succeeded" for message in messages)
|
||||
@@ -202,7 +202,11 @@ async def test_gateway_webui_bootstrap_message_and_thread_hydration(tmp_path: Pa
|
||||
f"{base_url}/api/sessions/{encoded_key}/webui-thread",
|
||||
token=api_token,
|
||||
)
|
||||
contents = [str(message.get("content") or "") for message in thread["messages"]]
|
||||
contents = [
|
||||
str(event.get("text") or "")
|
||||
for event in thread["events"]
|
||||
if event.get("event") in {"user_message", "message", "stream_end"}
|
||||
]
|
||||
assert "/model" in contents
|
||||
assert any("Current model: `custom/smoke-model`" in text for text in contents)
|
||||
assert "!printf shell-ok" in contents
|
||||
|
||||
Reference in new issue
Block a user