mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-01 16:51:53 +03:00
fix(webui): only highlight actual model fallbacks
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
||||
@@ -1313,6 +1313,7 @@ export type InboundEvent =
|
||||
chat_id: string;
|
||||
model_name: string;
|
||||
model_preset?: string | null;
|
||||
is_fallback?: boolean;
|
||||
}
|
||||
| ({
|
||||
event: "turn_end";
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user