Skip to content

Commit 2f92e4d

Browse files
committed
fix(usage): align unavailable-cost bars and table cells
When rates are missing, provider bars now follow tokenShare so they match token ranking. Table dollar cells use an em dash instead of repeating "Cost unavailable", and the chart placeholder keeps the same footprint as the real chart.
1 parent 5cfd468 commit 2f92e4d

3 files changed

Lines changed: 18 additions & 27 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ function ProviderSection(props: {
322322
return (
323323
<SettingsSection title="Providers" card>
324324
{ordered.map((provider, index) => {
325-
const share = metric === "cost" ? provider.costShare : provider.tokenShare;
325+
const share =
326+
metric === "cost" && !costUnavailable ? provider.costShare : provider.tokenShare;
326327
return (
327328
<View
328329
key={provider.provider}

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ export function UsagePage() {
214214
</div>
215215

216216
{orderedProviders.map((provider) => {
217-
const share = metric === "cost" ? provider.costShare : provider.tokenShare;
217+
const share =
218+
metric === "cost" && !costUnavailable
219+
? provider.costShare
220+
: provider.tokenShare;
218221
return (
219222
<div key={provider.provider} className="flex flex-col gap-1.5">
220223
<div className="flex items-baseline justify-between">
@@ -279,8 +282,13 @@ export function UsagePage() {
279282
</div>
280283
</div>
281284
{metric === "cost" && costUnavailable ? (
282-
<div className="flex h-56 items-center justify-center text-sm text-muted-foreground">
283-
Cost unavailable
285+
<div className="flex flex-col gap-1">
286+
<div className="flex h-56 items-center justify-center text-sm text-muted-foreground">
287+
Cost unavailable
288+
</div>
289+
<div className="flex justify-between pl-16 text-[10px] text-muted-foreground uppercase">
290+
<span>&nbsp;</span>
291+
</div>
284292
</div>
285293
) : (
286294
<UsageProviderChart
@@ -388,7 +396,7 @@ export function UsagePage() {
388396
</span>
389397
</td>
390398
<td className="py-2 text-right text-foreground tabular-nums">
391-
{formatCost(model.costUsd)}
399+
{costUnavailable ? "—" : formatUsd(model.costUsd)}
392400
</td>
393401
<td className="py-2 text-right text-muted-foreground tabular-nums">
394402
{costUnavailable ? "—" : formatPercent(model.costShare)}
@@ -438,11 +446,13 @@ export function UsagePage() {
438446
key={provider}
439447
className="py-2 text-right text-muted-foreground tabular-nums"
440448
>
441-
{formatCost(period.byProvider.get(provider)?.costUsd ?? 0)}
449+
{costUnavailable
450+
? "—"
451+
: formatUsd(period.byProvider.get(provider)?.costUsd ?? 0)}
442452
</td>
443453
))}
444454
<td className="py-2 text-right text-foreground tabular-nums">
445-
{formatCost(period.costUsd)}
455+
{costUnavailable ? "—" : formatUsd(period.costUsd)}
446456
</td>
447457
<td className="py-2 text-right text-muted-foreground tabular-nums">
448458
{formatTokens(period.totalTokens)}

‎apps/web/src/components/usage/usageCost.test.ts‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)