feat(webui): show persisted fallback preset on replies (NAN-133)
This commit is contained in:
1 parent
db675a43b6
commit
8d0430c761
43 files changed
+919
-95
No files matched your search
@@ -975,7 +975,11 @@ class ChannelManager:
|
||||
is_delta = isinstance(next_event, StreamDeltaEvent)
|
||||
is_end = isinstance(next_event, StreamEndEvent)
|
||||
|
||||
if same_target and (is_delta or (is_end and next_msg.content)):
|
||||
same_response_sources = (
|
||||
next_msg.metadata.get("response_sources")
|
||||
== first_msg.metadata.get("response_sources")
|
||||
)
|
||||
if same_target and same_response_sources and (is_delta or (is_end and next_msg.content)):
|
||||
# Accumulate content
|
||||
combined_content += next_msg.content
|
||||
# If we see stream_end, remember it and stop coalescing this stream
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user