-
Notifications
You must be signed in to change notification settings - Fork 155
Open
Description
Context widgets should use context_window data from Claude Code input when available
Problem
Context-related widgets (Context Length, Context %, Context % usable) currently calculate token usage by parsing the transcript JSONL file. This approach has limitations:
- It's slower because it requires reading and parsing the transcript file
- It can be inaccurate when API errors occur (synthetic messages with zero tokens)
- It requires complex model-based context window size lookups
Background
Claude Code v2.0.65+ now provides a context_window object directly in the status JSON input with accurate token metrics:
{
"context_window": {
"total_input_tokens": 12345,
"total_output_tokens": 678,
"context_window_size": 200000
}
}This data comes directly from Claude Code and is more reliable than parsing transcript files.
Expected behavior
When context_window data is available in the input (Claude Code v2.0.65+):
- Context Length widget should use
total_input_tokensinstead of calculating from transcript - Context % widget should use
total_input_tokens / context_window_size - Context % (usable) widget should use
total_input_tokens / (context_window_size * 0.8)
When context_window data is not available (older Claude Code versions), widgets should fall back to the existing transcript-based calculation for backward compatibility.
Affected widgets
- Context Length (
context-length) - Context % (
context-percentage) - Context % (usable) (
context-percentage-usable)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels