fix(webui): sync model badge after preset switch
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
Xubin Ren
co-authored by
Cursor
parent
b61c6304c3
commit
c92345bbb1
@@ -229,6 +229,26 @@ async def test_send_delivers_json_message_with_media_and_reply() -> None:
|
||||
assert payload["buttons"] == [["Yes", "No"]]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_includes_webui_model_name_metadata() -> None:
|
||||
bus = MagicMock()
|
||||
channel = WebSocketChannel({"enabled": True, "allowFrom": ["*"]}, bus)
|
||||
mock_ws = AsyncMock()
|
||||
channel._attach(mock_ws, "chat-1")
|
||||
|
||||
await channel.send(
|
||||
OutboundMessage(
|
||||
channel="websocket",
|
||||
chat_id="chat-1",
|
||||
content="switched",
|
||||
metadata={"_webui_model_name": "openai/gpt-4.1"},
|
||||
)
|
||||
)
|
||||
|
||||
payload = json.loads(mock_ws.send.call_args[0][0])
|
||||
assert payload["model_name"] == "openai/gpt-4.1"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_stages_external_media_as_signed_url(monkeypatch, tmp_path) -> None:
|
||||
bus = MagicMock()
|
||||
|
||||
@@ -64,7 +64,8 @@ async def test_model_command_lists_current_and_available_presets(tmp_path) -> No
|
||||
assert "Active preset: `(none)`" in out.content
|
||||
assert "`default`" in out.content
|
||||
assert "`fast`" in out.content
|
||||
assert out.metadata == {"render_as": "text"}
|
||||
assert out.metadata["render_as"] == "text"
|
||||
assert out.metadata["_webui_model_name"] == "base-model"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -75,6 +76,7 @@ async def test_model_command_switches_preset(tmp_path) -> None:
|
||||
|
||||
assert "Switched model preset to `fast`." in out.content
|
||||
assert "Model: `openai/gpt-4.1`" in out.content
|
||||
assert out.metadata["_webui_model_name"] == "openai/gpt-4.1"
|
||||
assert loop.model_preset == "fast"
|
||||
assert loop.model == "openai/gpt-4.1"
|
||||
assert loop.subagents.model == "openai/gpt-4.1"
|
||||
@@ -90,6 +92,7 @@ async def test_model_command_switches_back_to_default(tmp_path) -> None:
|
||||
out = await cmd_model(_ctx(loop, "/model default", args="default"))
|
||||
|
||||
assert "Switched model preset to `default`." in out.content
|
||||
assert out.metadata["_webui_model_name"] == "base-model"
|
||||
assert loop.model_preset == "default"
|
||||
assert loop.model == "base-model"
|
||||
assert loop.context_window_tokens == 1000
|
||||
|
||||
Reference in New Issue
Block a user