feat(cli-tools): allow setting Claude Code max context tokens

Add a context-window selector on ClaudeToolCard that writes
CLAUDE_CODE_MAX_CONTEXT_TOKENS into settings.json (nudged 2K under the
labeled cap), and clear it on reset/default.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
decolua
2026-07-29 18:10:31 +07:00
co-authored by Claude Fable 5
parent 6d96e24bd9
commit 8b0fcf4b16
2 changed files with 45 additions and 2 deletions
+10 -1
View File
@@ -123,7 +123,7 @@ export async function GET() {
// POST - Backup old fields and write new settings
export async function POST(request) {
try {
const { env, exaMcpEnabled } = await request.json();
const { env, exaMcpEnabled, maxContextTokens } = await request.json();
if (!env || typeof env !== "object") {
return NextResponse.json(
@@ -166,6 +166,14 @@ export async function POST(request) {
},
};
// CLAUDE_CODE_MAX_CONTEXT_TOKENS — only set when a concrete value is chosen;
// "Default" removes the key so Claude Code falls back to the model's window.
if (maxContextTokens) {
newSettings.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = String(maxContextTokens);
} else {
delete newSettings.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS;
}
// Write new settings
await fs.writeFile(settingsPath, JSON.stringify(newSettings, null, 2));
@@ -195,6 +203,7 @@ const RESET_ENV_KEYS = [
"ANTHROPIC_DEFAULT_SONNET_MODEL",
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
"API_TIMEOUT_MS",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS",
];
// DELETE - Reset settings (remove env fields)