Skip to content

Feature request: use context_window from Claude Code input when available #126

@alex-on-java

Description

@alex-on-java

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+):

  1. Context Length widget should use total_input_tokens instead of calculating from transcript
  2. Context % widget should use total_input_tokens / context_window_size
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions