mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-18 18:16:38 +03:00
fix(webui): bound restored session previews
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -266,6 +267,28 @@ def test_webui_session_list_recovers_colon_chat_id_from_transcript(
|
||||
assert row["preview"] == "scoped history"
|
||||
|
||||
|
||||
def test_webui_session_list_normalizes_transcript_preview(tmp_path: Path) -> None:
|
||||
key = "websocket:long-preview"
|
||||
transcript = tmp_path / "webui" / f"{SessionManager.safe_key(key)}.jsonl"
|
||||
transcript.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"event": "user",
|
||||
"chat_id": "long-preview",
|
||||
"text": "first\n\n" + "word " * 100,
|
||||
}
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
[row] = list_webui_sessions(SessionManager(tmp_path / "workspace"))
|
||||
|
||||
assert row["preview"].startswith("first word")
|
||||
assert "\n" not in row["preview"]
|
||||
assert row["preview"].endswith("…")
|
||||
|
||||
|
||||
def test_webui_session_list_tolerates_invalid_transcript_timestamp(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user