Skip to content

fix: token counter undercounted cached requests; Forge clarify UI polish - #80

Merged
tomasz-zajac-oss merged 1 commit into
mainfrom
fix/forge-clarify-ui-polish
Sep 12, 2026
Merged

tomasz-zajac-oss merged 1 commit into
mainfrom
fix/forge-clarify-ui-polish

Conversation

@tomasz-zajac-oss

Copy link
Copy Markdown
Collaborator

Summary

  • Token counter fix: providers/claude.ts's parseUsage only read Anthropic's input_tokens field as the total input token count — but Anthropic deliberately reports input_tokens as only the fresh, non-cached portion of the prompt, moving cached tokens into separate cache_read_input_tokens/cache_creation_input_tokens fields. Since the recent 5-point optimization PR (feat: 5-point token/latency optimization for the AI integration #78) put caching on nearly every request, the displayed session/stage token counters were silently undercounting real spend — sometimes drastically. Now folds both into inputTokens, matching how OpenAI's prompt_tokens already reports the full total with the cached portion as a subset (cachedInputTokens stays available separately for the "N served from cache" tooltip).
  • Close button overlap: .ai-settings-close is absolutely positioned in the Forge panel header and doesn't reserve any space, so a wide token badge (e.g. "25.9K tokens") ran underneath it. Added padding-right to .forge-title-row to clear it.
  • Duplicate "Continue" label: the clarify form's submit button and the wizard footer's "Continue →" button did different things (confirm clarify answers for the current stage vs. advance to the next stage) but shared the same word, which read as confusing/redundant when both were visible at once. Renamed the clarify form's button to "Confirm answers".

Test plan

  • npm run typecheck clean
  • npm run test — 371 passing; updated Anthropic usage-parsing assertions to the corrected (larger, now-correct) totals, and added a case covering cache_creation_input_tokens folding specifically (a cache write, which happens on essentially every first request in a session)

🤖 Generated with Claude Code

…ify UI polish

The token counter silently dropped cache_read_input_tokens and
cache_creation_input_tokens from Anthropic's usage response, counting only
the fresh/non-cached portion as `inputTokens` — since the recent caching
optimizations mean nearly every request now involves a cache read or
write, the displayed total badly undercounted real spend. Folds both into
`inputTokens`, matching how OpenAI's `prompt_tokens` already reports the
full total with cached tokens as a subset.

Also fixes two UI issues in the Radical Forge wizard: the absolutely-
positioned close button overlapped the token-count badge once it grew
wide (e.g. "25.9K tokens"), and the clarify form's submit button was
labeled "Continue" — the same word as the footer's "Continue →" button,
which does something different (advances the wizard step vs. confirms
clarify answers for the current stage).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tomasz-zajac-oss
tomasz-zajac-oss merged commit 74766aa into main Sep 12, 2026
2 checks passed
@tomasz-zajac-oss
tomasz-zajac-oss deleted the fix/forge-clarify-ui-polish branch September 12, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant