Skip to content

Context display should use autocompactWindow as denominator instead of full context window #540

Closed

Description

@zhangtianwei1998

Current Behavior

  • HUD shows: 7% context usage (based on 1M context window)
  • /context command shows: 70.6k/200k tokens (35%)

As you can see in the attached screenshots:

Screenshot 1 - HUD Display:

Image

Shows context at 7% using the full 1M context window as the denominator.

Screenshot 2 - /context Output:

Image

Shows the actual usage at 70.6k/200k tokens (35%), where 200k is the effective autoCompactWindow.

The Problem

When a user explicitly sets autoCompactWindow: 200k in their Claude Code configuration, they care about:

  • How close they are to triggering auto-compression (compression happens at 200k)
  • NOT how much of the theoretical 1M model capacity they're using

The 7% figure is misleading because it suggests plenty of room left, while in reality they're at 35% of the autocompact threshold.

Expected Behavior

HUD should respect the autoCompactWindow setting and use it as the denominator when:

  1. autoCompactWindow is explicitly configured
  2. Display context usage relative to when auto-compression will trigger

Ideally showing something like: "Context 70.6k/200k (35%)" to match what /context displays.

Questions

  1. Is there currently a configuration option to change the context display denominator?
  2. Would you be open to a feature where HUD respects autoCompactWindow if set?

Environment

  • Claude: 2.1.137
  • Claude Code: Opus 4.7 (1M context)
  • claude-hud: Latest
  • autoCompactWindow: 200k (configured in Claude Code settings)

Activity

  1. jarrodwatts commented on May 13, 2026

    @jarrodwatts
    Owner

    Thanks for the detailed report. There is no config option today for changing the context denominator. I am keeping this open as an enhancement.

    The main design decision is the source of truth: prefer an official stdin field for the effective auto-compact window if Claude Code exposes one; otherwise this needs an explicit HUD config instead of broad implicit reads from Claude settings. The display should preserve current defaults.

  2. truffle-dev commented on May 13, 2026

    @truffle-dev
    Contributor

    Re the stdin path: Claude Code's statusline schema doesn't expose an autoCompactWindow field. The context_window block carries context_window_size, current_usage, used_percentage, and remaining_percentage (src/types.ts:17-30) — no analog of the user's autoCompactWindow setting from ~/.claude/settings.json.

    That puts this on the "otherwise this needs an explicit HUD config" branch. Concrete shape that preserves current defaults:

    • display.autoCompactWindow: number | null (default null)
    • When null → today's behavior unchanged: prefer used_percentage from stdin, fall back to context_window_size
    • When set → ignore used_percentage (computed against the full window upstream) and use min(100, round(totalTokens / autoCompactWindow * 100)) in both getContextPercent and getBufferedPercent

    Both getters in src/stdin.ts prefer the native field today (src/stdin.ts:163-165, 181-183), so the override has to short-circuit them rather than feed through the existing fallback. Happy to ship if the shape lands right.

  3. mvanhorn commented on Jun 3, 2026

    @mvanhorn
    Contributor

    Implemented in #589. Adds an opt-in display.autoCompactWindow so the context bar, percent, and token display all use the auto-compact window as the denominator (matching /context), with default behavior unchanged when unset.

  4. added a commit that references this issue on Jun 4, 2026
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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions