From 8473538e7ad1ad2fea7ded8cba404bb3c32f5e79 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sun, 20 Sep 2026 16:05:03 +0800 Subject: [PATCH] fix(webui): show provider logos in model notices --- .../components/thread/ModelFallbackNotice.tsx | 15 +++++--- .../components/thread/ModelPresetBadge.tsx | 2 +- webui/src/components/thread/ThreadShell.tsx | 1 + .../src/tests/model-fallback-notice.test.tsx | 36 +++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 webui/src/tests/model-fallback-notice.test.tsx diff --git a/webui/src/components/thread/ModelFallbackNotice.tsx b/webui/src/components/thread/ModelFallbackNotice.tsx index 7fb35e3f6..bd1cfada4 100644 --- a/webui/src/components/thread/ModelFallbackNotice.tsx +++ b/webui/src/components/thread/ModelFallbackNotice.tsx @@ -1,11 +1,13 @@ -import { ArrowRightLeft, KeyRound, X } from "lucide-react"; +import { X } from "lucide-react"; import { useTranslation } from "react-i18next"; import { Button } from "@/components/ui/button"; +import { PresetProviderIcon } from "@/components/thread/ModelPresetBadge"; /** A live fallback is informative, not a failed message or a changed preset. */ -export function ModelFallbackNotice({ model, reauthProviderLabel, onDismiss, onOpenSettings }: { +export function ModelFallbackNotice({ model, reauthProvider, reauthProviderLabel, onDismiss, onOpenSettings }: { model: string; + reauthProvider?: string; reauthProviderLabel?: string; onDismiss: () => void; onOpenSettings?: () => void; @@ -16,9 +18,12 @@ export function ModelFallbackNotice({ model, reauthProviderLabel, onDismiss, onO role="status" className="mx-auto mb-2 flex w-full max-w-[49.5rem] items-start gap-2 rounded-control border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground/80 animate-in fade-in-0 slide-in-from-bottom-1 motion-reduce:animate-none" > - {reauthProviderLabel - ? - : } +
{reauthProviderLabel ? <> diff --git a/webui/src/components/thread/ModelPresetBadge.tsx b/webui/src/components/thread/ModelPresetBadge.tsx index aae7c828e..2d1b16990 100644 --- a/webui/src/components/thread/ModelPresetBadge.tsx +++ b/webui/src/components/thread/ModelPresetBadge.tsx @@ -584,7 +584,7 @@ function SetupPromptLabel({ label }: { label: string }) { ); } -function PresetProviderIcon({ +export function PresetProviderIcon({ label, modelDetail, provider, diff --git a/webui/src/components/thread/ThreadShell.tsx b/webui/src/components/thread/ThreadShell.tsx index 93e7647ea..e564284b3 100644 --- a/webui/src/components/thread/ThreadShell.tsx +++ b/webui/src/components/thread/ThreadShell.tsx @@ -1559,6 +1559,7 @@ export function ThreadShell({ {modelFallback?.chatId === chatId && !modelFallback.dismissed ? ( { + beforeEach(__clearLogoFallbackCacheForTests); + afterEach(cleanup); + + it.each(["openai_codex", "xai_grok", "github_copilot"])("shows the rejected %s provider, not the backup", (provider) => { + render(); + const tile = screen.getByTestId("model-fallback-notice-logo"); + const image = tile.querySelector("img")!; + expect(image).toHaveAttribute("src", providerBrand(provider)!.logoUrl); + expect(image).toHaveAttribute("alt", ""); + expect(tile).toHaveAttribute("aria-hidden", "true"); + expect(tile).toHaveClass("h-[18px]", "w-[18px]"); + fireEvent.load(image); + expect(tile).toHaveClass("bg-white"); + for (const url of providerBrand(provider)!.logoUrls) { + expect(tile.querySelector("img")).toHaveAttribute("src", url); + fireEvent.error(tile.querySelector("img")!); + } + expect(tile.querySelector("img")).toBeNull(); + expect(tile).toHaveTextContent(providerBrand(provider)!.initials.slice(0, 2)); + }); + + it("uses the fallback model's brand for a generic notice", () => { + render(); + expect(screen.getByTestId("model-fallback-notice-logo").querySelector("img")) + .toHaveAttribute("src", providerBrand("xai_grok")!.logoUrl); + }); +});