fix(ui): include cache tokens in contextPercent calculation#70530
fix(ui): include cache tokens in contextPercent calculation#70530vmanuelort-sys wants to merge 1 commit into
Conversation
Greptile SummaryFixes Confidence Score: 5/5Safe to merge — single-line arithmetic fix with no side effects. No logic, syntax, or security issues. The fix correctly accounts for all token categories in the context percentage calculation, and the zero-guard is preserved. No files require special attention. Reviews (1): Last reviewed commit: "fix(ui): include cache tokens in context..." | Re-trigger Greptile |
|
Related work from PRtags group Title: Control UI context percent ignores cached prompt tokens
|
|
Thanks for the fix. This is now covered by the landed #70532 / commit 6415e35. #70532 fixes the same Control UI footer context-percent bug in ui/src/ui/chat/grouped-render.ts, using input + cacheRead + cacheWrite and adding regression coverage for both cached prompt tokens and output-token exclusion. Closing this PR as a duplicate. |
Summary
extractGroupMetainui/src/ui/chat/grouped-render.tscomputedcontextPercentfrom freshinputtokens only, ignoringcacheRead+cacheWrite. With Anthropic prompt caching, most of the context window arrives as cached tokens, soinputis routinely in the single digits while cached tokens make up the real load — the UI renders "0% ctx" even on near-full sessions.Fix
Use
input + cacheRead + cacheWriteas the numerator. Matches the intent of thectx %indicator (how full the context window is), and the values are already aggregated in the same function.Evidence
Live session (
agent:main:main, 2026-04-23):inputTokens: 3cacheWrite: 93,056contextTokens: 200,0000%47%Gates
pnpm check:changed(typecheck core + core-test, lint, import-cycles, webhook/pairing guards, 171 ui tests)pnpm buildscripts/committer