Context window: the smaller of /context's and acpmux's; a model switch drops the stale /context

Merged
TE
3d ago
+17-8

Follow-ups from the review of #32639 (receipt: https://github.com/manaflow-ai/cmux/pull/32639#pullrequestreview-5744774706). Leo, 2026-11-02: "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)".

  • compactingUsage now takes the smaller of the window Claude Code's /context names and acpmux's autocompact cap. Before, it always preferred /context, so a /context window just under the model's (say 980K on a 1M model) would have hidden a 400K cap.
  • direct.ts drops a /context breakdown taken for another model window when the usage window changes (a model switch). The meter then reads the model's own window until the next /context arrives, instead of the old model's.

Tests: UsageStats.test.ts (3 pass, adds the 980K case) and test/session-info.test.tsx pass. Web lint passes.

Changelog

none

Observed / Not run

  • Ran: the unit tests and web lint above.
  • Not run: a model switch in a live build.

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

Fixes context window calculation so the smaller of Claude Code's /context window and acpmux's autocompact cap is used, instead of always preferring /context. A /context window just under the model's (for example 980K on a 1M model) no longer hides a 400K cap.

Drops the stale /context breakdown when a model switch changes the usage window, so the meter reads the model's own window until the next /context arrives.