mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-01 16:51:53 +03:00
refactor(webui): infer fallback from active model
This commit is contained in:
@@ -400,7 +400,7 @@ function toModelBadgeInfo(
|
||||
);
|
||||
return {
|
||||
label,
|
||||
model: toModelBadgeLabel(model),
|
||||
model: model?.trim() || null,
|
||||
provider,
|
||||
providerLabel: provider ? providerDisplayLabel(settings?.providers ?? [], provider) : null,
|
||||
needsSetup,
|
||||
@@ -959,9 +959,12 @@ export function ThreadShell({
|
||||
setFallbackModelName(null);
|
||||
return client.onChat(chatId, (event) => {
|
||||
if (event.event !== "turn_model_updated") return;
|
||||
setFallbackModelName(event.is_fallback ? event.model_name : null);
|
||||
const activeModel = event.model_name.trim();
|
||||
setFallbackModelName(
|
||||
modelBadge.model && activeModel !== modelBadge.model ? activeModel : null,
|
||||
);
|
||||
});
|
||||
}, [chatId, client]);
|
||||
}, [chatId, client, modelBadge.model]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!historyKey || !chatId || loading) return;
|
||||
@@ -1451,7 +1454,7 @@ export function ThreadShell({
|
||||
: t("thread.composer.placeholderThread")
|
||||
}
|
||||
modelLabel={modelBadgeLabel}
|
||||
modelDetail={modelBadge.model}
|
||||
modelDetail={toModelBadgeLabel(modelBadge.model)}
|
||||
modelPreset={activeModelPreset}
|
||||
modelPresets={modelPresetOptions}
|
||||
onModelPresetChange={handleModelPresetChange}
|
||||
@@ -1498,7 +1501,7 @@ export function ThreadShell({
|
||||
: t("thread.composer.placeholderHero")
|
||||
}
|
||||
modelLabel={modelBadgeLabel}
|
||||
modelDetail={modelBadge.model}
|
||||
modelDetail={toModelBadgeLabel(modelBadge.model)}
|
||||
modelPreset={activeModelPreset}
|
||||
modelPresets={modelPresetOptions}
|
||||
onModelPresetChange={handleModelPresetChange}
|
||||
|
||||
@@ -1313,7 +1313,6 @@ export type InboundEvent =
|
||||
chat_id: string;
|
||||
model_name: string;
|
||||
model_preset?: string | null;
|
||||
is_fallback?: boolean;
|
||||
}
|
||||
| ({
|
||||
event: "turn_end";
|
||||
|
||||
@@ -1724,7 +1724,6 @@ describe("NanobotClient", () => {
|
||||
chat_id: "chat-a",
|
||||
model_name: "deepseek/deepseek-chat",
|
||||
model_preset: "Deep Research",
|
||||
is_fallback: true,
|
||||
});
|
||||
|
||||
expect(chatHandler).toHaveBeenCalledWith({
|
||||
@@ -1732,7 +1731,6 @@ describe("NanobotClient", () => {
|
||||
chat_id: "chat-a",
|
||||
model_name: "deepseek/deepseek-chat",
|
||||
model_preset: "Deep Research",
|
||||
is_fallback: true,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -720,7 +720,6 @@ describe("ThreadShell", () => {
|
||||
event: "turn_model_updated",
|
||||
chat_id: "fallback-model",
|
||||
model_name: "openai-codex/gpt-5.5",
|
||||
is_fallback: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -731,7 +730,6 @@ describe("ThreadShell", () => {
|
||||
event: "turn_model_updated",
|
||||
chat_id: "fallback-model",
|
||||
model_name: "deepseek/deepseek-chat",
|
||||
is_fallback: true,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user