MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / usageSummary

Function usageSummary

src/ui/components/StatusBar.tsx:64–82  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

62 * Returns null when tiered usage is unavailable so the line can be hidden.
63 */
64function 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
84export function StatusBar({
85 modelId,

Callers 1

StatusBarFunction · 0.85

Calls 1

formatRelativeTimeFunction · 0.70

Tested by

no test coverage detected