-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Problem
The context remaining percentage in the session input bar always shows 0% when using Claude Opus 4.6 with 1M context window. The actual context usage is only ~20%, but the UI clamps it to 0%.
Root Cause
MAX_CONTEXT_SIZE is hardcoded to 190000 in AgentInput.tsx, which is appropriate for 200K context models (Sonnet) but not for 1M context models (Opus 4.6 [1m]).
Code pointers
-
packages/happy-app/sources/sync/reducer/reducer.ts:1115—contextSizeis calculated correctly:contextSize: (usage.cache_creation_input_tokens || 0) + (usage.cache_read_input_tokens || 0) + usage.input_tokens
-
packages/happy-app/sources/components/AgentInput.tsx:78, 286-287— percentage uses hardcoded limit:const MAX_CONTEXT_SIZE = 190000; const percentageUsed = (contextSize / MAX_CONTEXT_SIZE) * 100; const percentageRemaining = Math.max(0, Math.min(100, 100 - percentageUsed));
Example
With Opus 4.6 (1M context), a session at ~205K context:
percentageUsed = 205000 / 190000 * 100 = 107.8%percentageRemaining = Math.max(0, 100 - 107.8) = 0%- Actual remaining: ~79.5% (205K / 1M)
Suggested Fix
Make MAX_CONTEXT_SIZE dynamic based on the model in use. The CLI's usage-report doesn't currently include model info, so the model name may need to be passed through or inferred.
Known context window sizes:
- Claude Sonnet / Haiku: 200K → ~190K effective
- Claude Opus 4.6
[1m]: 1M → ~950K effective
Impact
- UI-only: does not affect functionality or billing
- Users on 1M context models see 0% for entire session, losing visibility into actual context usage