@devries-cameron20 / t3code-1 / commits / 58d253231d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): context meter no longer reads 1000k just under a million tokens (#17539)

luke committed Oct 12, 2026 at 09:13 UTC 58d253231d83f669a2cdfefa5fe479751d22c582
2 files changed +12 -1
apps/web/src/lib/contextWindow.test.ts
+10
@@ -58,6 +58,16 @@ describe("V2 context window presentation", () => {
58 it("formats compact token values", () => {
59 expect(formatContextWindowTokens(1_500)).toBe("1.5k");
60 });
61 +
62 + it.each([
63 + [999_499, "999k"],
64 + [999_500, "1m"],
65 + [999_999, "1m"],
66 + [1_000_000, "1m"],
67 + [1_100_000, "1.1m"],
68 + ])("formats %d tokens as %s at the million boundary", (tokens, expected) => {
69 + expect(formatContextWindowTokens(tokens)).toBe(expected);
70 + });
71 });
72
73 describe("live provider-turn usage (#8144)", () => {
apps/web/src/lib/contextWindow.ts
+2 -1
@@ -171,7 +171,8 @@ export function formatContextWindowTokens(value: number | null): string {
171 if (value < 10_000) {
172 return `${(value / 1_000).toFixed(1).replace(/\.0$/, "")}k`;
173 }
174 - if (value < 1_000_000) {
174 + // Anything from 999,500 rounds to 1000k, so it belongs to the next unit.
175 + if (value < 999_500) {
176 return `${Math.round(value / 1_000)}k`;
177 }
178 return `${(value / 1_000_000).toFixed(1).replace(/\.0$/, "")}m`;