refactor(session): unify model and display history storage (#6336)

* refactor(session): persist display history in SQLite

* fix(session): preserve new fork activity timestamps

* test(agent): use SQLite-owned model failure recovery fixture

* test(agent): isolate session slash routing from loop shutdown

Exercise the real inbound dispatcher and await its session worker. Keep response deadlines and behavioral assertions, while leaving full SQLite cleanup to the existing async fixture rather than an unrelated two-second shutdown deadline.

* fix(webui): admit direct deliveries to display history

* docs: clarify session history migration guidance
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-21 16:13:59 +08:00
1 parent d617b723aa
commit b32b1327ce
50 files changed
+2123 -3235

No files matched your search

+4 -7
View File
@@ -28,8 +28,6 @@ from nanobot.webui.transcript import WebUITranscriptRecorder
async def test_committed_model_failure_continues_with_tool_results_without_resending(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setattr("nanobot.webui.transcript.get_webui_dir", lambda: tmp_path / "webui")
monkeypatch.setattr("nanobot.webui.session_list_index.get_webui_dir", lambda: tmp_path / "webui")
bus = MessageBus()
sessions = SessionManager(tmp_path)
session = sessions.get_or_create("websocket:chat")
@@ -146,8 +144,7 @@ async def test_recovery_continuation_runs_without_a_sustained_goal(
async def test_recovery_preserves_turn_origin_until_the_next_user_turn(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, late_result: bool,
) -> None:
monkeypatch.setattr("nanobot.webui.transcript.get_webui_dir", lambda: tmp_path / "webui")
monkeypatch.setattr("nanobot.webui.session_list_index.get_webui_dir", lambda: tmp_path / "webui")
monkeypatch.setattr("nanobot.webui.history.get_webui_dir", lambda: tmp_path / "webui")
bus = MessageBus()
provider = MagicMock(aclose=AsyncMock())
provider.get_default_model.return_value = "test-model"
@@ -208,12 +205,12 @@ async def test_recovery_preserves_turn_origin_until_the_next_user_turn(
"message_id": None if late_result else "user-message",
"turn_id": delivery.route.turn_id,
}
recorder = WebUITranscriptRecorder()
recorder = WebUITranscriptRecorder(loop.sessions)
async def record_progress(content, **kwargs):
recorder.prepare_and_append(
await recorder.prepare_and_append(
"chat", {"event": "message", "chat_id": "chat", "text": content, "kind": "progress"},
metadata=delivery.route.metadata, phase="activity",
metadata=delivery.delivery_message.metadata, phase="activity",
)
task = asyncio.create_task(loop._process_message(