Skip to content

context_window block shows cumulative tokens, not actual context usage #823

Description

@lexfrei

The statusline's 🧠 block (context window usage) displays misleading information on long sessions.

Problem

The percentage calculation uses context_window.total_input_tokens which is a cumulative session counter — it never resets, even after Claude Code's "compact" operation.

This means:

  • On long sessions, the percentage grows unbounded (I've seen 1000%+)
  • After compact, it still shows high usage even though context was cleared
  • The displayed number doesn't represent actual context window utilization

Expected behavior

The block should show current context window usage — how much of the model's context limit is currently occupied.

Technical details

In statusline.ts, the calculation:

const percentage = Math.round((inputTokens / contextLimit) * 100);

Uses cumulative total_input_tokens rather than current context consumption.

Also note: the fallback path in data-loader.ts has clamping (Math.min(100, ...)), but the primary hook path doesn't, allowing >100% display.

Workaround

Currently filtering out this block entirely via sed in my statusline script.

Activity

  1. ryoppippi commented on May 19, 2026

    @ryoppippi
    Member

    Thank you for the report/suggestion and for the related TypeScript-era work.

    I am sorry that the Rust migration made the original TypeScript implementation no longer mergeable as-is. The production CLI has moved from the TypeScript implementation to the Rust implementation under rust/crates/ccusage. The related TypeScript PR has been closed as obsolete, so I am closing this issue as well to keep the tracker focused.

    If this behavior is still needed, please open a fresh issue or PR against the current Rust CLI with current-version output and a minimal reproduction or concrete use case.

  2. willma-andela commented on May 20, 2026

    @willma-andela

    Programming language aside, this is still an issue. #666 should be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions