From c5a8249905fbd518fe651d27d86dcfdc628ebf40 Mon Sep 17 00:00:00 2001 From: Pixel Perfect Date: Sun, 25 Oct 2026 13:23:07 -0700 Subject: [PATCH 1/3] fix(web): clarify goal usage and objective labels --- .../components/chat/ThreadActivityBanners.tsx | 7 ++-- .../src/state/threadExecution.test.ts | 33 +++++++++++++++++++ .../src/state/threadExecution.ts | 7 ++-- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/apps/web/src/components/chat/ThreadActivityBanners.tsx b/apps/web/src/components/chat/ThreadActivityBanners.tsx index b9de23227e7c9..2bb31a7305ec0 100644 --- a/apps/web/src/components/chat/ThreadActivityBanners.tsx +++ b/apps/web/src/components/chat/ThreadActivityBanners.tsx @@ -63,11 +63,8 @@ export function goalBannerItem(input: { variant: "default", priority: "activity", icon: , - title: - presentation.usage === null - ? presentation.title - : `${presentation.title} · ${presentation.usage}`, - description: presentation.objective, + title: `${presentation.title}: ${presentation.objective}`, + description: presentation.usage === null ? undefined : `· ${presentation.usage}`, actions: isWorking ? undefined : ( <> {presentation.canResume ? ( diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index 8ef37f959cd40..97068e0ea81d1 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -25,11 +25,44 @@ import { deriveRunlessWorkStartedAt, deriveThreadActivityRun, deriveThreadRuntime, + presentProviderGoal, threadRuntimeHasInterruptibleRun, } from "./threadExecution.ts"; const now = DateTime.makeUnsafe("2026-07-28T10:00:00.000Z"); +describe("provider goal usage", () => { + it("labels goal tokens as excluding cache and identifies the active 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 active"); + }); + + 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 run(id: string, ordinal: number, status: OrchestrationV2RunStatus) { return { id: RunId.make(id), diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.ts index accf5c98df9a9..0da65ff9b6644 100644 --- a/packages/client-runtime/src/state/threadExecution.ts +++ b/packages/client-runtime/src/state/threadExecution.ts @@ -388,14 +388,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)} active`); } if (goal.checks !== undefined && goal.checks > 0) { usage.push(`${goal.checks} ${goal.checks === 1 ? "check" : "checks"}`); From bbfd688451b6da30f76d1351bc702b8143dd96dd Mon Sep 17 00:00:00 2001 From: maria-rcks Date: Fri, 30 Oct 2026 08:34:07 +0000 Subject: [PATCH 2/3] fix(web): label goal duration as elapsed time --- packages/client-runtime/src/state/threadExecution.test.ts | 4 ++-- packages/client-runtime/src/state/threadExecution.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index d14789d4a52a2..2f8845dc8c1ef 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -33,7 +33,7 @@ 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 active duration", () => { + it("labels goal tokens as excluding cache and identifies the elapsed duration", () => { expect( presentProviderGoal( { @@ -44,7 +44,7 @@ describe("provider goal usage", () => { }, true, ).usage, - ).toBe("30.1m uncached tokens · 63h 57m 51s active"); + ).toBe("30.1m uncached tokens · 63h 57m 51s elapsed"); }); it("uses the same token accounting label for a goal budget", () => { diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.ts index 54b0dc7a6dfe7..0bf57acbc9e59 100644 --- a/packages/client-runtime/src/state/threadExecution.ts +++ b/packages/client-runtime/src/state/threadExecution.ts @@ -446,7 +446,7 @@ export function presentProviderGoal( ); } if (goal.timeUsedSeconds !== undefined && goal.timeUsedSeconds >= 60) { - usage.push(`${formatDuration(goal.timeUsedSeconds * 1_000)} active`); + usage.push(`${formatDuration(goal.timeUsedSeconds * 1_000)} elapsed`); } if (goal.checks !== undefined && goal.checks > 0) { usage.push(`${goal.checks} ${goal.checks === 1 ? "check" : "checks"}`); From 3d87f22968e688abdfe2e435b11bc2213e99e16c Mon Sep 17 00:00:00 2001 From: maria-rcks Date: Sun, 1 Nov 2026 01:27:15 +0000 Subject: [PATCH 3/3] test: preserve goal rounding coverage with clarified labels --- .../client-runtime/src/state/threadExecution.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index 72a1f83079f2b..d548e18ba7413 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -504,10 +504,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( { @@ -518,7 +518,7 @@ describe("presentProviderGoal", () => { }, false, ).usage, - ).toBe("1m / 1m tokens"); + ).toBe("1m / 1m uncached tokens"); }); });