The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 12:00 UTC
fix(client-runtime): goal token counts no longer read 1000k (#21594)
Co-authored-by: maria-rcks <maria@kuuro.net>
Marcel Jiron · MarMarLabs committed
Oct 30, 2026 at 15:28 UTC
a0d6cc8ba9ed036745e2d9c747d7d82eeae1de84
2 files changed
+28
-1
packages/client-runtime/src/state/threadExecution.test.ts
+26
@@ -25,6 +25,7 @@ import {
25
deriveRunlessWorkStartedAt,
26
deriveThreadActivityRun,
27
deriveThreadRuntime,
28
+ presentProviderGoal,
29
presentRunStop,
30
threadRuntimeHasInterruptibleRun,
31
} from "./threadExecution.ts";
@@ -462,3 +463,28 @@ describe("provider-reported model selection", () => {
463
).toBeNull();
464
});
465
});
466
+
467
+describe("presentProviderGoal", () => {
468
+ it("rolls token counts that round to 1000k over to 1m", () => {
469
+ const usage = (tokensUsed: number) =>
470
+ presentProviderGoal(
471
+ { objective: "Ship the feature", status: "active", tokensUsed, tokenBudget: 2_000_000 },
472
+ true,
473
+ ).usage;
474
+ expect(usage(999_499)).toBe("999k / 2m tokens");
475
+ expect(usage(999_500)).toBe("1m / 2m tokens");
476
+ expect(usage(999_999)).toBe("1m / 2m tokens");
477
+ expect(usage(1_000_000)).toBe("1m / 2m tokens");
478
+ expect(
479
+ presentProviderGoal(
480
+ {
481
+ objective: "Ship the feature",
482
+ status: "paused",
483
+ tokensUsed: 999_500,
484
+ tokenBudget: 999_500,
485
+ },
486
+ false,
487
+ ).usage,
488
+ ).toBe("1m / 1m tokens");
489
+ });
490
+});
packages/client-runtime/src/state/threadExecution.ts
+2
-1
@@ -428,7 +428,8 @@ const PROVIDER_GOAL_TITLES: Record<OrchestrationV2ProviderGoal["status"], string
428
429
function formatGoalTokens(tokens: number): string {
430
if (tokens < 1_000) return `${tokens}`;
431
- if (tokens < 1_000_000) return `${Math.round(tokens / 1_000)}k`;
431
+ const thousands = Math.round(tokens / 1_000);
432
+ if (thousands < 1_000) return `${thousands}k`;
433
return `${(tokens / 1_000_000).toFixed(1).replace(/\.0$/, "")}m`;
434
}
435