Context reads against the compact window Claude Code names (/ 400K, not / 1M)

Merged
TE
3d ago
+73-13

Leo, 2026-11-02, on the composer's Context window card and Session Info's Context section both reading / 1M on a chat that compacts at 400K:

whatever a user set their compact window to it should be that instead of always showing the defautl (e.g. we should be seieng 400k)

likewise for the session info thing too

What changed

compactingUsage (usageStats.ts) picks the window the context meter, its hover card, Session Info's Context (web and native) and the harness status card read against. It already used acpmux's autocompact cap (#31936), but only when acpmux reported usageStats with autocompact: "capped" for the chat. In Leo's capture the /context breakdown's shares were already against 400K (Messages 232.4K = 58.2%), while the headline still said 310.6K / 1M. The headline had dropped back to the model's window.

Now the window Claude Code's own /context names (contextBreakdown.maxTokens) comes first, because it already reflects the person's autocompact setting. acpmux's cap comes next, and the model's window is the fallback. Either replaces the model's window only when it is smaller. All five callers pass the breakdown.

The card's percent follows from the new window: 339.9K reads 85% of 400K, not 34% of 1M.

References (cmux-design-references)

  • claude/live/panel-context-breakdown: Claude Code desktop's Context reads 153.2k / 400k on a 400K-compact session. This is the target.
  • claude/live/status-context-window-usage-popover-2: Claude's popover, the layout the card follows (unchanged here).
  • cmux/live/status-context-window-usage-popover: the earlier cmux card reading 131.4K / 1M.

Mock scenes

  • agent-pane.context-ring / card-autocompact-window: the composer card reads 339.9K / 400K. Its play asserts that.
  • agent-pane.chat-inspector / context-autocompact-window: Session Info's Context reads 171.4K / 400K on a 1M model. Its play asserts that and fails on / 1M.

Tests

UsageStats.test.ts covers four cases: the breakdown with no usageStats, the breakdown winning over acpmux's cap, a 1M breakdown falling back to the cap, and a malformed maxTokens. Also run: ContextCard and session-info tests, 54 pass. Web lint passes.

Agent session: agent session

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Makes the context meters read against the window Claude Code's own /context names instead of the model's default, so a chat that compacts at 400K shows 339.9K / 400K rather than / 1M.

  • compactingUsage now prefers the /context breakdown's maxTokens, which already reflects the user's autocompact setting; acpmux's cap and the model's window remain fallbacks.
  • Passes the breakdown through all callers: the composer's context ring and card, Session Info (web and native), and the harness status card.
  • Adds gallery scenes and test cases asserting the new window for both the composer card and Session Info's Context.