* Picks the usage window that currently constrains the agent and formats it as * " limit XX% · resets ". * * The smallest window (5hr) is the one actively in use, so we show it by * default. We only escalate to a larger window once it has hit its cap (100%): * a capped larger
(tu: AxonCodeTieredUsage | undefined)
| 62 | * Returns null when tiered usage is unavailable so the line can be hidden. |
| 63 | */ |
| 64 | function usageSummary(tu: AxonCodeTieredUsage | undefined): string | null { |
| 65 | if (!tu) return null; |
| 66 | // Largest-to-smallest, so `find` returns the largest capped window and the |
| 67 | // last entry is the smallest available window. |
| 68 | const windows: Array<{ label: string; usage?: AxonCodeWindowUsage }> = [ |
| 69 | { label: "monthly limit", usage: tu.monthly }, |
| 70 | { label: "weekly limit", usage: tu.weekly }, |
| 71 | { label: "5hr limit", usage: tu.fiveHour }, |
| 72 | ]; |
| 73 | const available = windows.filter( |
| 74 | (w): w is { label: string; usage: AxonCodeWindowUsage } => Boolean(w.usage), |
| 75 | ); |
| 76 | if (available.length === 0) return null; |
| 77 | const binding = |
| 78 | available.find((w) => w.usage.percentage >= 100) ?? |
| 79 | available[available.length - 1]; |
| 80 | const { percentage, resetsAt } = binding.usage; |
| 81 | return `${binding.label} ${Math.round(percentage)}% · resets ${formatRelativeTime(resetsAt)}`; |
| 82 | } |
| 83 | |
| 84 | export function StatusBar({ |
| 85 | modelId, |
no test coverage detected