Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(usage): ChatGPT and other unpriced models show in "Where it went" (#3845)

Aditya Umale95661138d647
diff --git a/src/components/UsageSection.tsx b/src/components/UsageSection.tsx
index 6c9419552d..028b8b09cb 100644
--- a/src/components/UsageSection.tsx
+++ b/src/components/UsageSection.tsx
@@ -76,10 +76,8 @@ function useUsageGroups(range: { from: string; to: string }, groupBy: UsageGroup
export function GroupBars({ groupBy, groups }: { groupBy: UsageGroupBy; groups: readonly UsageGroup[] }) {
const { state } = useStore();
- const priced = groups.some((group) => hasFiniteCost(group.costUsd) && group.costUsd > 0);
- const value = (group: UsageGroup) => priced ? group.costUsd ?? 0 : headlineTokens(group);
- const top = [...groups].sort((a, b) => value(b) - value(a)).slice(0, 6);
- const max = Math.max(...top.map(value), 0);
+ const top = [...groups].sort((a, b) => headlineTokens(b) - headlineTokens(a)).slice(0, 6);
+ const max = Math.max(...top.map(headlineTokens), 0);
if (!top.length || max <= 0) return <p className="text-[13px] text-ink-secondary">{t("usage.page.whereEmpty")}</p>;
return (
<ul className="flex flex-col gap-2.5">
@@ -92,10 +90,11 @@ export function GroupBars({ groupBy, groups }: { groupBy: UsageGroupBy; groups:
<span className="truncate">{groupBy === "model" ? modelName(group.label, state.instances) : usageGroupLabel(groupBy, group)}</span>
</span>
<span className="h-2 overflow-hidden rounded-full bg-raised">
- <span className="block h-full rounded-full bg-accent/70" style={{ width: `${Math.max(2, (value(group) / max) * 100)}%` }} />
+ <span className="block h-full rounded-full bg-accent/70" style={{ width: `${Math.max(2, (headlineTokens(group) / max) * 100)}%` }} />
</span>
<span className="min-w-[4.5rem] text-right tabular-nums text-ink-secondary">
- {priced ? formatCost(group.costUsd) : formatTokens(headlineTokens(group))}
+ {formatTokens(headlineTokens(group))}
+ {hasFiniteCost(group.costUsd) && group.costUsd > 0 && ` · ${formatCost(group.costUsd)}`}
</span>
</li>
);
diff --git a/src/lib/usage-trace.test.ts b/src/lib/usage-trace.test.ts
index dfc9661ced..474e604455 100644
--- a/src/lib/usage-trace.test.ts
+++ b/src/lib/usage-trace.test.ts
@@ -9,7 +9,7 @@ vi.mock("@/state/store", async (original) => {
return { ...actual, useStore: () => ({ state: actual.initialState, dispatch: vi.fn() }), api: vi.fn(() => new Promise(() => {})) };
});
const { TraceWaterfall } = await import("../components/usage/TraceWaterfall");
-const { usageGroupLabel } = await import("../components/UsageSection");
+const { GroupBars, usageGroupLabel } = await import("../components/UsageSection");
const T0 = Date.UTC(2026, 9, 22, 9, 0, 0);
const turn = (id: string, botName: string, start: number, end: number | undefined, children: TraceTurn["children"], extra: Partial<TraceTurn> = {}): TraceTurn => ({
@@ -71,6 +71,16 @@ describe("trace helpers", () => {
expect(usageGroupLabel("routine", { key: "manual", label: "Not from a routine" })).toBe("Not from a routine");
});
+ it("ranks models by tokens, so a subscription model with no price still shows", () => {
+ const group = (label: string, input: number, costUsd: number | null) => ({ key: label, label, turns: 1, input, output: 0, cachedInput: 0, costUsd });
+ const priced = ["claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5", "gemini-3.8-pro", "claude-opus-4-8", "claude-sonnet-4-8"].map((label, index) => group(label, 1_000 * (index + 1), 10 + index));
+ const html = renderToStaticMarkup(createElement(GroupBars, { groupBy: "model", groups: [...priced, group("gpt-5.5", 5_000_000, null)] }));
+ expect(html).toContain("gpt-5.5");
+ expect(html).toContain("5M");
+ expect(html).not.toContain("claude-opus-5-5");
+ expect(html).toContain("$15.00");
+ });
+
it("picks calendar periods in UTC days", () => {
const now = new Date(Date.UTC(2026, 9, 22, 15));
expect(usagePeriodRange("today", now)).toEqual({ from: "2026-10-22", to: "2026-10-22" });