Skip to content
TypeScript

fix(web): center usage models without a breakdown bar (#21247)

Afonso Ferreirac3608512f0fc
diff --git a/apps/web/src/components/usage/UsagePage.tsx b/apps/web/src/components/usage/UsagePage.tsx
index 5728616edf8..e7db92cc370 100644
--- a/apps/web/src/components/usage/UsagePage.tsx
+++ b/apps/web/src/components/usage/UsagePage.tsx
@@ -946,6 +946,7 @@ function UsageOverview({
breakdownModels.map((model, index) => {
const key = `${model.provider}:${model.model}`;
const value = metric === "tokens" ? model.totalTokens : model.costUsd;
+ const hasBar = value > 0 && breakdownPeak > 0;
const share = modelShare(model, metric === "tokens" ? "tokens" : "cost");
const rowFigures = figureClass(loadingProviders.has(model.provider));
return (
@@ -958,23 +959,25 @@ function UsageOverview({
<button
type="button"
onClick={() => onSelectModel(key)}
- className="flex items-center gap-2 text-left text-foreground outline-none after:absolute after:inset-0"
+ className={cn(
+ "flex items-center gap-2 text-left text-foreground outline-none after:absolute after:inset-0",
+ !hasBar && "py-1",
+ )}
>
<ProviderMark provider={model.provider} className="size-3.5" />
{model.model}
</button>
- <div aria-hidden className={cn("mt-1.5 h-0.5 max-w-48", rowFigures)}>
- <div
- className="h-full rounded-full"
- style={{
- width:
- value > 0 && breakdownPeak > 0
- ? `max(0.5rem, ${(value / breakdownPeak) * 100}%)`
- : 0,
- backgroundColor: PROVIDER_PRESENTATION[model.provider].color,
- }}
- />
- </div>
+ {hasBar ? (
+ <div aria-hidden className={cn("mt-1.5 h-0.5 max-w-48", rowFigures)}>
+ <div
+ className="h-full rounded-full"
+ style={{
+ width: `max(0.5rem, ${(value / breakdownPeak) * 100}%)`,
+ backgroundColor: PROVIDER_PRESENTATION[model.provider].color,
+ }}
+ />
+ </div>
+ ) : null}
</td>
<td className={cn("py-2.5 pl-6 text-foreground", rowFigures)}>
{isModelCostUnknown(model) ? (