This PR fixes critical issues with token tracking and provides users with
actionable warnings based on real failure data.
1. **Incorrect token counting**: The system was adding cache tokens
(cache_creation_input_tokens, cache_read_input_tokens) as if they were
new tokens, causing inflated counts like 28125% usage. Cache tokens are
cumulative state, not incremental additions.
2. **No user guidance**: Users had no warning when approaching context limits,
leading to unexpected "Prompt is too long" errors.
- Show only raw token counts from Claude API (input + output)
- Remove percentage calculations and context window estimates
- Display running totals that users can trust
Based on analysis of 29 failed sessions, implemented three warning levels:
- ✅ Safe: < 80K tokens
- ⚠️ Caution: 80K-95K tokens (yellow warning)
- 🚨 Danger: > 95K tokens (red alert)
The lowest observed failure was at 96,800 tokens, so warnings start at 80K
to give users ample time to start a new session.
- Styled clickable popover (replacing poor native tooltips)
- Token breakdown (input/output/total)
- Clear warning messages with context
- Dark mode support
- Fixed `extractTokenUsage()` to only count actual input/output tokens
- Removed hardcoded system overhead calculations
- Added contextWindowTokens tracking for future use
- Updated UI to show raw truth instead of estimates
This gives users the information they need without confusing calculations
or impossible percentages.