feat(webui): show persisted fallback preset on replies (NAN-133)

This commit is contained in:
Xubin Ren committed 2026-09-20 15:16:35 +08:00
1 parent db675a43b6
commit 8d0430c761
43 files changed
+919 -95

No files matched your search

+6
View File
@@ -1106,6 +1106,9 @@ class WebSocketChannel(BaseChannel):
) -> bool:
"""Persist one canonical turn event and retain unsafe owners on failure."""
if not self._temporary_chats.should_persist_transcript(chat_id):
self._transcripts.prepare_event(
chat_id, event, metadata=metadata, phase=phase, include_source=include_source,
)
return True
persisted = self._transcripts.prepare_and_append(
chat_id,
@@ -1150,6 +1153,9 @@ class WebSocketChannel(BaseChannel):
) -> bool:
"""Persist the canonical end of a live stream, never its wire chunks."""
if not self._temporary_chats.should_persist_transcript(chat_id):
self._transcripts.prepare_event(
chat_id, event, metadata=metadata, phase=phase, include_source=include_source,
)
return True
persisted = self._transcripts.prepare_and_append_stream_event(
chat_id,
@@ -6032,9 +6032,15 @@ def test_handle_webui_thread_get_accepts_pagination_query(tmp_path, monkeypatch)
assert body["page"]["before_cursor"]
@pytest.mark.parametrize("sources", [
None,
[],
[{"provider": "xai", "model": "grok", "preset": "saved backup", "fallback": True}],
])
def test_handle_webui_thread_get_negotiates_client_event_projection(
tmp_path,
monkeypatch,
sources,
) -> None:
from urllib.parse import quote
@@ -6051,7 +6057,10 @@ def test_handle_webui_thread_get_negotiates_client_event_projection(
)
append_transcript_object(
key,
{"event": "message", "chat_id": "event-route", "text": "answer"},
{
"event": "message", "chat_id": "event-route", "text": "answer",
**({"response_sources": sources} if sources is not None else {}),
},
)
append_transcript_object(key, {"event": "turn_end", "chat_id": "event-route"})
@@ -6074,6 +6083,11 @@ def test_handle_webui_thread_get_negotiates_client_event_projection(
"message",
"turn_end",
]
answer = body["events"][1]
if sources is None:
assert "response_sources" not in answer
else:
assert answer["response_sources"] == sources
def test_handle_file_preview_returns_workspace_file(tmp_path) -> None: