import * as React from "react"; import { USAGE_CRITICAL_PERCENT, USAGE_WARN_PERCENT } from "./model/agentUsageThresholds"; /** * Maps a used-percent to a meter bar color: healthy (green) below the warn * threshold, warning (amber) past it, and critical (red) near the limit. */ export function agentUsageBarColor(percentUsed: number): string { if (percentUsed >= USAGE_CRITICAL_PERCENT) { return "var(--state-danger)"; } if (percentUsed >= USAGE_WARN_PERCENT) { return "var(--state-warning)"; } return "var(--state-success)"; } export function AgentUsageMeter({ label, value, percent, barColor, testId }: { label: string; value: string; percent: number | null; /** Overrides the bar fill color; defaults to the neutral primary text color. */ barColor?: string; testId?: string; }): React.JSX.Element { const clampedPercent = typeof percent === "number" && Number.isFinite(percent) ? Math.max(0, Math.min(100, percent)) : null; return (
{label} {value}
{clampedPercent !== null ? (
); }