Skip to content

Commit dc7a703

Browse files
ipanasenkoclaude
andcommitted
fix(providers): normalize the accent inside provider instance icons
The pooled usage view passes the raw snapshot accent, which can be any string. Normalize once in the web and mobile icons so an invalid accent falls back to the plain badge instead of white initials on an unknown background. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d88743d commit dc7a703

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎apps/mobile/src/components/ProviderIcon.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Image } from "expo-image";
22
import { Path, Svg } from "react-native-svg";
33
import { View } from "react-native";
44
import {
5+
normalizeProviderAccentColor,
56
providerAccentForegroundColor,
67
providerInstanceInitials,
78
} from "@t3tools/client-runtime/state/provider-instance-display";
@@ -174,14 +175,15 @@ export function ProviderInstanceIcon(props: {
174175
readonly showBadge?: boolean;
175176
readonly surfaceColor: string;
176177
}) {
178+
const accentColor = normalizeProviderAccentColor(props.accentColor);
177179
return (
178180
<View style={{ position: "relative" }}>
179181
<View style={{ opacity: 0.6 }}>
180182
<ProviderIcon iconUrl={props.iconUrl} provider={props.provider} size={props.size} />
181183
</View>
182184
{props.showBadge ? (
183185
<View
184-
className={props.accentColor ? undefined : "bg-card"}
186+
className={accentColor ? undefined : "bg-card"}
185187
style={{
186188
position: "absolute",
187189
right: -3,
@@ -192,20 +194,18 @@ export function ProviderInstanceIcon(props: {
192194
borderRadius: 999,
193195
borderWidth: 1,
194196
borderColor: props.surfaceColor,
195-
backgroundColor: props.accentColor,
197+
backgroundColor: accentColor,
196198
alignItems: "center",
197199
justifyContent: "center",
198200
}}
199201
>
200202
<Text
201-
className={props.accentColor ? undefined : "text-foreground-muted"}
203+
className={accentColor ? undefined : "text-foreground-muted"}
202204
style={{
203205
fontSize: 7,
204206
fontWeight: "600",
205207
lineHeight: 9,
206-
color: props.accentColor
207-
? providerAccentForegroundColor(props.accentColor)
208-
: undefined,
208+
color: accentColor ? providerAccentForegroundColor(accentColor) : undefined,
209209
}}
210210
>
211211
{providerInstanceInitials(props.displayName)}

‎apps/web/src/components/chat/ProviderInstanceIcon.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { type CSSProperties, memo } from "react";
22

33
import {
4+
normalizeProviderAccentColor,
45
providerAccentForegroundColor,
56
providerInstanceInitials,
67
} from "@t3tools/client-runtime/state/provider-instance-display";
@@ -76,10 +77,11 @@ export const ProviderInstanceIcon = memo(function ProviderInstanceIcon(props: {
7677
}) {
7778
const Icon = PROVIDER_ICON_BY_PROVIDER[props.driverKind] ?? null;
7879
const indicatorBackground = props.indicatorBackground ?? "var(--card)";
79-
const accentStyle = props.accentColor
80+
const accentColor = normalizeProviderAccentColor(props.accentColor);
81+
const accentStyle = accentColor
8082
? ({
81-
"--provider-accent": props.accentColor,
82-
"--provider-accent-foreground": providerAccentForegroundColor(props.accentColor),
83+
"--provider-accent": accentColor,
84+
"--provider-accent-foreground": providerAccentForegroundColor(accentColor),
8385
} as CSSProperties)
8486
: undefined;
8587
const badgeContent = props.badgeContent ?? "initials";
@@ -97,7 +99,7 @@ export const ProviderInstanceIcon = memo(function ProviderInstanceIcon(props: {
9799
props.className,
98100
)}
99101
style={accentStyle}
100-
data-provider-accent-color={props.accentColor}
102+
data-provider-accent-color={accentColor}
101103
>
102104
{isAcpRegistry ? (
103105
<AcpRegistryAgentIcon
@@ -128,7 +130,7 @@ export const ProviderInstanceIcon = memo(function ProviderInstanceIcon(props: {
128130
<span
129131
className={cn(
130132
"pointer-events-none absolute right-0 bottom-0 z-10 flex h-3.5 min-w-3.5 items-center justify-center rounded-full border px-0.5 text-4xs font-semibold leading-none shadow-sm",
131-
props.accentColor
133+
accentColor
132134
? "bg-(--provider-accent) text-(--provider-accent-foreground)"
133135
: "bg-card text-muted-foreground",
134136
props.badgeClassName,

0 commit comments

Comments
 (0)