Skip to content

feat(gui): add a Context accounting control to the Claude Code page - #6782

Merged
lidge-jun merged 4 commits into
devfrom
claude/1m-04-context-accounting-gui
Oct 9, 2026
Merged

lidge-jun merged 4 commits into
devfrom
claude/1m-04-context-accounting-gui

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the dashboard control for claudeCode.contextAccounting (#6781) on the Claude Code settings page.

  • A Context accounting select: 1M (default) / 200k.
  • Under 200k, the "Use big context automatically" and "Auto-summarize point" rows are hidden because they have no effect there. Their saved values stay, so they come back unchanged when you return to 1M.
  • The manual-setup block stops exporting CLAUDE_CODE_AUTO_COMPACT_WINDOW under 200k, matching what the runtime injects.
  • A state cached by, or read from, an older proxy with no such field normalizes to the 1M default (normalizeContextAccounting, used by normalizeFirstPartyState for both the session cache and the GET).
  • The field takes part in the draft identity, Save body, revert and rebase paths (EDITABLE_KEYS).
  • The new strings are in all eleven locales. 200k is allowlisted in the zh-TW placeholder test as a token count.

Stack (merge bottom-up):

# Layer Review focus
4 Dashboard control for context accounting ← you are here GUI
3 #6781 claudeCode.contextAccounting: "200k" opt-in policy chain
2 #6780 Long-window eligibility on every Claude surface marking rules
1 #6778 Overflow worded as prompt is too long error envelopes

Depends on #6781. Review this PR's diff only.

Screenshots

Default (1M):

Context accounting, default 1M

200k selected (auto-context rows hidden, unsaved draft):

Context accounting, 200k

Verification

  • bun run typecheck; in gui/: bun run lint, bun run lint:i18n, bun x tsc -b, bun run build.
  • GUI tests (claude-code-save, claude-code-sidecar-draft, anthropic-instance-helper-controls, claude-code-types, claude-code-first-party, i18n-locales, locale-parity): 100 pass, 0 fail. tests/gui/claude-manual-env.test.ts and claude-context-accounting.test.ts: 15 pass.
  • Rendered on an isolated proxy (temporary HOME/CODEX_HOME/OPENCODEX_HOME). I checked the default state and the 200k draft state (rows hidden, "Unsaved changes") and reverted without saving. Persistence is covered by the management API round-trip test in feat(claude): add a 200k context-accounting opt-in #6781.
  • Full suite: exact-head CI. An independent review returned GO-WITH-FIXES with no blockers. Its two minors (description precision, fixtures) are fixed in the last commit.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (The user guide for the setting landed in feat(claude): add a 200k context-accounting opt-in #6781.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (UI only.)

🤖 Generated with Claude Code

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 9, 2026 00:11
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

lidge-jun added a commit that referenced this pull request Oct 9, 2026
…, en, light)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T00:14:14.663820Z fd9b47e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd9b47ea94

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread gui/src/pages/claude-manual-env.ts Outdated
const marker = state.authMode === "auto" ? (state.markerMode ?? "subscription") : state.authMode;
const autoCompactActive = state.autoContext && state.maxContextTokens === null;
// The 200k opt-in injects no compact window, so the pasted block must not either.
const autoCompactActive = state.contextAccounting !== "200k" && state.autoContext && state.maxContextTokens === null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the manual snippet on one accounting snapshot

When the loaded 1M state has server-derived effectiveModelEnv entries ending in [1m], selecting 200k makes this condition remove CLAUDE_CODE_AUTO_COMPACT_WINDOW immediately, while modelEnvExports still emits those stale 1M-marked model IDs. This inconsistency also persists after a successful save if the refresh fails, because the save acknowledgement preserves server-derived fields. Copying the Quickstart block then launches an explicitly 1M-accounted model without the matching compaction threshold, contrary to the selected policy; derive both parts from the same confirmed state or refresh/recompute the effective model environment before exposing the snippet.

AGENTS.md reference: gui/AGENTS.md:L10-L10

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a real mix. gui/src/pages/claude-manual-env.ts dropped CLAUDE_CODE_AUTO_COMPACT_WINDOW as soon as the draft was 200k, while effectiveModelEnv was still the server's 1M snapshot, including after a save whose refresh had not landed (gui/src/pages/claude-code-save.ts keeps server-derived fields). eb0c7e50a builds both parts from one snapshot: a 200k draft strips automatic [1m] marks, keeps a marker already on the configured selector, and omits unset native tier fills. A 1m draft over a 200k env does not add the compact window until that env is rebuilt.

@lidge-jun
lidge-jun force-pushed the claude/1m-03-context-accounting branch from 68b46e3 to 2688bb0 Compare October 9, 2026 00:54
@lidge-jun
lidge-jun force-pushed the claude/1m-04-context-accounting-gui branch from fb5e7d4 to 3d7efed Compare October 9, 2026 00:54
@cursor
cursor Bot force-pushed the claude/1m-04-context-accounting-gui branch from 3d7efed to eb0c7e5 Compare October 9, 2026 19:48
@cursor
cursor Bot force-pushed the claude/1m-03-context-accounting branch 2 times, most recently from d5af50e to bd2f44c Compare October 9, 2026 19:59
@cursor
cursor Bot force-pushed the claude/1m-04-context-accounting-gui branch from eb0c7e5 to 857c660 Compare October 9, 2026 19:59
@cursor
cursor Bot force-pushed the claude/1m-03-context-accounting branch from bd2f44c to a1b7037 Compare October 9, 2026 20:02
@cursor
cursor Bot force-pushed the claude/1m-04-context-accounting-gui branch from 857c660 to acf923e Compare October 9, 2026 20:02
@cursor
cursor Bot force-pushed the claude/1m-03-context-accounting branch from a1b7037 to 1e445a4 Compare October 9, 2026 20:46
@cursor
cursor Bot force-pushed the claude/1m-04-context-accounting-gui branch from acf923e to 2ba95bc Compare October 9, 2026 20:46
@cursor
cursor Bot force-pushed the claude/1m-03-context-accounting branch from 1e445a4 to 041b580 Compare October 9, 2026 21:36
@cursor
cursor Bot force-pushed the claude/1m-04-context-accounting-gui branch from 2ba95bc to 5790ac8 Compare October 9, 2026 21:36
Base automatically changed from claude/1m-03-context-accounting to dev October 9, 2026 21:38
lidge-jun and others added 4 commits October 9, 2026 21:38
The Claude Code settings page gets a 1M (default) / 200k select for
claudeCode.contextAccounting. Under 200k the auto-context and
auto-summarize rows are hidden (they have no effect there) and the
manual env block stops exporting a compact window, matching what the
runtime injects. A state cached by an older proxy, or read from one,
normalizes to the 1m default. Strings are added to all eleven locales.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up: the description now says 200k only stops automatic 1M
marking (an explicit 1M row and a context override still apply), and the
two component fixtures that mount the settings card directly carry the
new field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nch guard

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selecting 200k dropped the compact window while the pasted model ids
still carried the server's automatic [1m] marks. The snippet now strips
those marks, keeps an explicit [1m], and omits the compact window until
the model env was built under the same policy.

Co-authored-by: JUN <jun@lidgeai.com>
@cursor
cursor Bot force-pushed the claude/1m-04-context-accounting-gui branch from 5790ac8 to 6611945 Compare October 9, 2026 21:39
@lidge-jun
lidge-jun merged commit 006cec9 into dev Oct 9, 2026
26 of 27 checks passed
@lidge-jun
lidge-jun deleted the claude/1m-04-context-accounting-gui branch October 9, 2026 21:40
@lidge-jun lidge-jun mentioned this pull request Oct 10, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants