Skip to content

Commit 8f258f0

Browse files
dfakkeldyclaudemaria-rcks
authored
fix(usage): use each account accent colour in limit bars (#24630)
Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent 5e0d0fd commit 8f258f0

6 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎apps/mobile/src/features/threads/ComposerUsageLimits.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export function ComposerUsageLimits({
4444
dense
4545
first={index === 0}
4646
driver={account.driver}
47+
accentColor={account.accentColor}
4748
label={driverLabel}
4849
instanceLabel={
4950
account.instanceId

‎apps/mobile/src/features/usage/UsageLimitsPooled.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useAtomValue } from "@effect/atom-react";
22
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
33
import { EnvironmentId } from "@t3tools/contracts";
4+
import { normalizeProviderAccentColor } from "@t3tools/client-runtime/state/provider-instance-display";
45
import {
56
collectLimitAccounts,
67
collectExternalUsageLinks,
@@ -253,7 +254,7 @@ function PoolWindowCard({
253254
<View className="absolute inset-0 overflow-hidden rounded-md">
254255
<AccountSegment
255256
remaining={remainingPercent(window)}
256-
color={color}
257+
color={normalizeProviderAccentColor(account.accentColor) ?? color}
257258
refillPercent={window.resetsAt ? member.refillPercent : 0}
258259
/>
259260
</View>
@@ -324,6 +325,7 @@ function PoolWindowCard({
324325
<View>
325326
{pool.columns.map(({ account, window }, index) => {
326327
if (!window) return null;
328+
const segmentColor = normalizeProviderAccentColor(account.accentColor) ?? color;
327329
const credits = account.limits.resetCredits?.availableCount ?? 0;
328330
const resetsIn = formatResetsIn(window, now);
329331
return (
@@ -335,7 +337,12 @@ function PoolWindowCard({
335337
onPress={() => openAccount(account)}
336338
className="min-h-[44px] flex-row items-center gap-2 active:opacity-60"
337339
>
338-
<View className="size-5 items-center justify-center overflow-hidden rounded-md bg-subtle-strong">
340+
<View className="relative size-5 items-center justify-center overflow-hidden rounded-md bg-subtle-strong">
341+
<View
342+
pointerEvents="none"
343+
className="absolute inset-0"
344+
style={{ backgroundColor: segmentColor, opacity: 0.35 }}
345+
/>
339346
<Text className="text-xs font-t3-medium tabular-nums text-foreground">
340347
{index + 1}
341348
</Text>

‎apps/mobile/src/features/usage/UsageLimitsSection.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as Dialog from "../../components/ui/Dialog";
22
import { RegistryContext, useAtomMount, useAtomValue } from "@effect/atom-react";
3+
import { normalizeProviderAccentColor } from "@t3tools/client-runtime/state/provider-instance-display";
34
import {
45
AuthProvidersManageScope,
56
type EnvironmentId,
@@ -157,6 +158,7 @@ function AccountInstanceLabel({ value }: { readonly value: string }) {
157158

158159
export function AccountLimits(props: {
159160
readonly driver: Driver;
161+
readonly accentColor?: string | undefined;
160162
readonly label: string;
161163
readonly instanceLabel: string;
162164
readonly detail: string | undefined;
@@ -168,7 +170,8 @@ export function AccountLimits(props: {
168170
readonly footer?: ReactNode;
169171
}) {
170172
const { limits, now, dense = false } = props;
171-
const color = useBarColor(props.driver);
173+
const providerColor = useBarColor(props.driver);
174+
const color = normalizeProviderAccentColor(props.accentColor) ?? providerColor;
172175
if (!limits) return null;
173176
const notice = limitsNotice(limits);
174177
const externalUsage = limits.externalUsage;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ function UsageLimitsBannerBody({
132132
<LimitWindows
133133
compact
134134
driver={account.driver}
135+
accentColor={account.accentColor}
135136
windows={account.limits.windows}
136137
now={now}
137138
/>

‎apps/web/src/components/usage/UsageLimits.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
UsageProviderKind,
1010
} from "@t3tools/contracts";
1111
import { useAtomValue } from "@effect/atom-react";
12+
import { normalizeProviderAccentColor } from "@t3tools/client-runtime/state/provider-instance-display";
1213
import {
1314
formatDuration,
1415
formatResetsIn,
@@ -186,16 +187,18 @@ function WindowBar({
186187

187188
export function LimitWindows({
188189
driver,
190+
accentColor,
189191
windows,
190192
now,
191193
compact = false,
192194
}: {
193195
readonly driver: ServerProvider["driver"];
196+
readonly accentColor?: string | undefined;
194197
readonly windows: ReadonlyArray<ServerProviderUsageWindow>;
195198
readonly now: number;
196199
readonly compact?: boolean;
197200
}) {
198-
const color = barColor(driver);
201+
const color = normalizeProviderAccentColor(accentColor) ?? barColor(driver);
199202
return (
200203
<div
201204
className={

‎apps/web/src/components/usage/UsageLimitsPooled.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
remainingPercent,
1616
} from "@t3tools/shared/usageLimits";
1717
import type { Popover as PopoverPrimitive } from "@base-ui/react/popover";
18+
import { normalizeProviderAccentColor } from "@t3tools/client-runtime/state/provider-instance-display";
1819
import { AlertTriangleIcon, ExternalLinkIcon, TicketIcon } from "lucide-react";
1920
import {
2021
createContext,
@@ -515,7 +516,7 @@ function PoolBar({
515516
window={member.window}
516517
reset={restores.get(member.account.key)}
517518
refillPercent={member.refillPercent}
518-
color={color}
519+
color={normalizeProviderAccentColor(member.account.accentColor) ?? color}
519520
now={now}
520521
index={position + 1}
521522
showAccountName={pool.columns.length > 1}

0 commit comments

Comments
 (0)