diff --git a/apps/web/src/components/chat/ThreadActivityBanners.tsx b/apps/web/src/components/chat/ThreadActivityBanners.tsx index ff4ee1ef7078e..deceadf29483d 100644 --- a/apps/web/src/components/chat/ThreadActivityBanners.tsx +++ b/apps/web/src/components/chat/ThreadActivityBanners.tsx @@ -102,15 +102,14 @@ export function goalNowItem(input: { title: ( }> - {presentation.title} - {presentation.usage === null ? null : ` · ${presentation.usage}`} + {`${presentation.title}: ${presentation.objective}`}

{presentation.objective}

), - description: presentation.objective, + description: presentation.usage ?? undefined, // Clear stops goal work; Resume would stop unrelated work, so it waits. actions: ( <> diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index ea6de929b4cb7..d38bf752e0d0b 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -41,6 +41,38 @@ import { const now = DateTime.makeUnsafe("2026-07-28T10:00:00.000Z"); +describe("provider goal usage", () => { + it("labels goal tokens as excluding cache and identifies the elapsed duration", () => { + expect( + presentProviderGoal( + { + objective: "keep going", + status: "active", + tokensUsed: 30_072_613, + timeUsedSeconds: 230_271, + }, + true, + ).usage, + ).toBe("30.1m uncached tokens · 63h 57m 51s elapsed"); + }); + + it("uses the same token accounting label for a goal budget", () => { + expect( + presentProviderGoal( + { objective: "Ship it", status: "paused", tokensUsed: 12_000, tokenBudget: 50_000 }, + false, + ).usage, + ).toBe("12k / 50k uncached tokens"); + }); + + it("keeps Claude checks and goals without usage independent of token accounting", () => { + expect( + presentProviderGoal({ objective: "Ship it", status: "active", checks: 2 }, true).usage, + ).toBe("2 checks"); + expect(presentProviderGoal({ objective: "Ship it", status: "active" }, false).usage).toBeNull(); + }); +}); + function request( id: string, status: OrchestrationV2RuntimeRequest["status"], @@ -727,10 +759,10 @@ describe("presentProviderGoal", () => { { objective: "Ship the feature", status: "active", tokensUsed, tokenBudget: 2_000_000 }, true, ).usage; - expect(usage(999_499)).toBe("999k / 2m tokens"); - expect(usage(999_500)).toBe("1m / 2m tokens"); - expect(usage(999_999)).toBe("1m / 2m tokens"); - expect(usage(1_000_000)).toBe("1m / 2m tokens"); + expect(usage(999_499)).toBe("999k / 2m uncached tokens"); + expect(usage(999_500)).toBe("1m / 2m uncached tokens"); + expect(usage(999_999)).toBe("1m / 2m uncached tokens"); + expect(usage(1_000_000)).toBe("1m / 2m uncached tokens"); expect( presentProviderGoal( { @@ -741,7 +773,7 @@ describe("presentProviderGoal", () => { }, false, ).usage, - ).toBe("1m / 1m tokens"); + ).toBe("1m / 1m uncached tokens"); }); }); diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.ts index 622db98a2903a..244b6ac612b44 100644 --- a/packages/client-runtime/src/state/threadExecution.ts +++ b/packages/client-runtime/src/state/threadExecution.ts @@ -672,14 +672,15 @@ export function presentProviderGoal( ): ProviderGoalPresentation { const usage: Array = []; if (goal.tokensUsed !== undefined && goal.tokensUsed > 0) { + // Codex goal accounting excludes cached input, unlike total thread usage. usage.push( goal.tokenBudget == null - ? `${formatGoalTokens(goal.tokensUsed)} tokens` - : `${formatGoalTokens(goal.tokensUsed)} / ${formatGoalTokens(goal.tokenBudget)} tokens`, + ? `${formatGoalTokens(goal.tokensUsed)} uncached tokens` + : `${formatGoalTokens(goal.tokensUsed)} / ${formatGoalTokens(goal.tokenBudget)} uncached tokens`, ); } if (goal.timeUsedSeconds !== undefined && goal.timeUsedSeconds >= 60) { - usage.push(formatDuration(goal.timeUsedSeconds * 1_000)); + usage.push(`${formatDuration(goal.timeUsedSeconds * 1_000)} elapsed`); } if (goal.checks !== undefined && goal.checks > 0) { usage.push(`${goal.checks} ${goal.checks === 1 ? "check" : "checks"}`);