fix(webui): only highlight actual model fallbacks

This commit is contained in:
chengyongru
2026-08-21 16:49:30 +08:00
committed by chengyongru
parent 761e95b659
commit 7f97373490
9 changed files with 26 additions and 2 deletions
+1 -1
View File
@@ -959,7 +959,7 @@ export function ThreadShell({
setFallbackModelName(null);
return client.onChat(chatId, (event) => {
if (event.event !== "turn_model_updated") return;
setFallbackModelName(event.model_name);
setFallbackModelName(event.is_fallback ? event.model_name : null);
});
}, [chatId, client]);
+1
View File
@@ -1313,6 +1313,7 @@ export type InboundEvent =
chat_id: string;
model_name: string;
model_preset?: string | null;
is_fallback?: boolean;
}
| ({
event: "turn_end";
+2
View File
@@ -1724,6 +1724,7 @@ describe("NanobotClient", () => {
chat_id: "chat-a",
model_name: "deepseek/deepseek-chat",
model_preset: "Deep Research",
is_fallback: true,
});
expect(chatHandler).toHaveBeenCalledWith({
@@ -1731,6 +1732,7 @@ describe("NanobotClient", () => {
chat_id: "chat-a",
model_name: "deepseek/deepseek-chat",
model_preset: "Deep Research",
is_fallback: true,
});
});
+13 -1
View File
@@ -696,7 +696,7 @@ describe("ThreadShell", () => {
expect(screen.queryByRole("button", { name: "Model not configured" })).not.toBeInTheDocument();
});
it("highlights the configured model badge without replacing the preset label", async () => {
it("only highlights fallback model updates without replacing the preset label", async () => {
const client = makeClient();
render(wrap(
client,
@@ -715,11 +715,23 @@ describe("ThreadShell", () => {
expect(configuredBadge).toHaveClass("composer-model-badge");
expect(configuredBadge).not.toHaveAttribute("data-fallback");
act(() => {
client._emitChat("fallback-model", {
event: "turn_model_updated",
chat_id: "fallback-model",
model_name: "openai-codex/gpt-5.5",
is_fallback: false,
});
});
expect(configuredBadge).not.toHaveAttribute("data-fallback");
act(() => {
client._emitChat("fallback-model", {
event: "turn_model_updated",
chat_id: "fallback-model",
model_name: "deepseek/deepseek-chat",
is_fallback: true,
});
});