Skip to content

fix(context-meter): stop guessing a 200k window for 1M Claude sessions - #121

Merged
talayash merged 1 commit into
masterfrom
fix/context-window-1m-120
Nov 10, 2026
Merged

talayash merged 1 commit into
masterfrom
fix/context-window-1m-120

Conversation

@talayash

Copy link
Copy Markdown
Owner

Fixes #120

Problem

Claude transcripts never state the context window, and both message.model and requestedModel drop the [1m] suffix. The meter only checked the launch --model arg, so a session that got 1M from the plan default, ANTHROPIC_MODEL, settings or /model read against 200k: wrong percentage, early amber/red, a needless "Type /compact" nudge, and a jump to 1M once usage passed 200k.

Fix

Backend (context_usage.rs): for Claude, get_context_usage now also returns configured_model. It's resolved in the CLI's order: --model / --model=, the terminal's ANTHROPIC_MODEL, the app's ANTHROPIC_MODEL, then model in <cwd>/.claude/settings.local.json, <cwd>/.claude/settings.json, and ~/.claude/settings.json (or CLAUDE_CONFIG_DIR). It's re-resolved only when the transcript grows. Blank, missing or broken sources are skipped.

Frontend (contextMeter.ts): the Claude window is decided in this order.

  1. Usage over 200k means 1M. This is latched per terminal (contextUsageStore.seenOver200k), so /compact doesn't shrink the window.
  2. A new Settings > Appearance override, Claude context window: Auto / 200k / 1M, saved with the app settings (default auto).
  3. A [1m] alias in the configured model or the transcript model.
  4. Otherwise the window is unknown. The chip shows the token count with a neutral ring and no percentage or warn/crit colour, the sidebar bar is hidden, and the popover points to the setting. "Type /compact" is still available.

A plain model can be 1M by plan default, so "unknown" avoids showing a made-up percentage.

Tests

  • Rust: configured_model_follows_cli_precedence, configured_model_skips_blank_broken_and_missing_sources.
  • contextMeter.test.ts: the issue's case (74.6k, claude-sonnet-5-5 + sonnet[1m] reads 7%, not 37%), unknown window, transcript [1m], latch, setting priority, and non-Claude agents ignoring the setting.
  • ContextMeter.test.tsx: 1M reading, tokens-only display with no crit class and no sidebar bar, and the latch after a usage drop.
  • Runs: npm run test:run 1393/1393, cargo test --locked 593/593, npx tsc --noEmit clean, clippy clean on the touched code, rustfmt on context_usage.rs.

Notes

  • The get_context_usage reply only gains a field. No cross-repo contract changes.
  • Not addressed: the separate "Default Claude model" setting is saved but never passed to new sessions (already like this before this PR).

🤖 Generated with Claude Code

Claude transcripts never state the window and strip [1m] from the model,
so a session that gets 1M from the plan, ANTHROPIC_MODEL, settings or
/model read against 200k until usage passed 200k, then jumped to 1M.

- Backend returns configured_model for Claude, resolved in CLI order:
  --model arg, terminal then app ANTHROPIC_MODEL, then model in the
  project's .claude/settings.local.json / settings.json and the user's
  settings.json.
- Window: usage over 200k (latched per terminal, so /compact does not
  shrink it), then the new Settings > Appearance override
  (Auto / 200k / 1M), then a [1m] alias in the configured or transcript
  model. Otherwise the window is unknown and the meter shows tokens only,
  with no percentage, warn/crit colour or sidebar bar.

Fixes #120

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ecc-tools

ecc-tools Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Security Evidence

Commit: 36c5d5d21db194814b781b4c5e2e5892f3bf0165

Security evidence gate passed (success)

No security-sensitive scanner-evidence gap detected.

Mode: enforce

Scanned 11 changed file(s). No missing scanner-evidence signal was detected.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / PR Risk Taxonomy

Commit: 36c5d5d21db194814b781b4c5e2e5892f3bf0165

PR taxonomy review recommended (neutral)

Detected 2 PR taxonomy bucket(s): CI/CD Recommendation, Cost/Token Risk.

Scanned 11 changed file(s).

Roadmap taxonomy buckets:

CI/CD Recommendation

CI, dependency, coverage, and contract signals should be routed into follow-up checks or verification work.

Signals:

  • User-facing UI changes may ship without browser coverage
  • 3 CI or workflow path(s) changed

Paths:

  • src/components/ContextMeter.test.tsx
  • src/lib/contextMeter.test.ts
  • src/store/appStore.test.ts
  • src-tauri/src/commands.rs
  • src-tauri/src/context_usage.rs
  • src/components/ContextMeter.tsx
  • src/components/settings/categories/AppearancePage.tsx
  • src/lib/contextMeter.ts

Cost/Token Risk

AI routing, usage, and token-budget changes should include budget or usage-limit evidence.

Signals:

  • Cost or token-risk changes may ship without budget evidence
  • 0 cost/token path(s) changed

Paths:

  • CLAUDE.md
  • src-tauri/src/commands.rs
  • src-tauri/src/context_usage.rs

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Reference Set Readiness

Commit: 36c5d5d21db194814b781b4c5e2e5892f3bf0165

Reference set readiness gaps detected (neutral)

Reference evidence present for 0/7 areas (0%) across 11 changed file(s).

This check is based on files changed in this PR. Repository-level readiness is still reported by /ecc-tools analyze comments and generated manifests.

Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, Zed, dmux, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Hosted Promotion Readiness

Commit: 36c5d5d21db194814b781b4c5e2e5892f3bf0165

Hosted promotion readiness passed (success)

No hosted promotion evidence gaps detected across 11 changed file(s); 0 corpus scenarios had matching evidence.

This check compares PR file changes against the evaluator/RAG promotion corpus in src/analyzers/fixtures/evaluator-rag-corpus.ts.
Hosted output scoring inspected 0 completed cached hosted job results.

No evaluator corpus scenarios matched this PR.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / PR Config Audit

Commit: 36c5d5d21db194814b781b4c5e2e5892f3bf0165

No changed-config issues detected (success)

Scanned 1 config file(s) present at this commit across 1 changed config path(s) and found no issues in the supported security rules.

Changed config files:

  • CLAUDE.md

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / PR Harness Audit

Commit: 36c5d5d21db194814b781b4c5e2e5892f3bf0165

No harness issues detected (success)

Scanned 1 changed config file(s) and found no harness issues.

Changed config files:

  • CLAUDE.md

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@talayash
talayash merged commit 01b59bf into master Nov 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context meter shows 200k window for sessions with a 1M context window

1 participant