- Merged latest main branch changes into token-tracking feature branch
- Resolved conflicts in session types, database schema, and UI components
- Combined token tracking features with commit mode functionality
- Added new commit mode columns to database and session interfaces
- Integrated project view and commit mode indicator components
- Preserved token usage display functionality from PR
- Updated session creation to include base commit/branch parameters
๐ค Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
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.