Skip to content

Conversation

@Jaahuo
Copy link

@Jaahuo Jaahuo commented Feb 3, 2026

Summary

  • Extract token metrics from the context_window object provided by Claude Code v2.0.65+ instead of parsing transcript JSONL files
  • Add input-parsers.ts utility with extractTokenMetricsFromContextWindow() function
  • Update ContextPercentage and ContextPercentageUsable widgets to use new data source
  • Fall back to JSONL parsing when context_window is not available for backward compatibility

Test plan

  • Unit tests added for extractTokenMetricsFromContextWindow() in input-parsers.test.ts
  • Updated tests for ContextPercentage and ContextPercentageUsable widgets
  • Manual testing with bun run example using updated payload
  • Verify backward compatibility with older Claude Code versions (no context_window)

Closes #126

🤖 Generated with Claude Code

Extract token metrics from the context_window object provided by Claude Code
v2.0.65+ instead of parsing transcript JSONL files. This provides more accurate
and faster context percentage calculations.

- Add input-parsers.ts utility with extractTokenMetricsFromContextWindow()
- Update ContextPercentage and ContextPercentageUsable widgets to use new data
- Fall back to JSONL parsing when context_window is not available
- Update types to include context_window in StatusJSON

Closes sirmalloc#126

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Feature request: use context_window from Claude Code input when available

1 participant