feat(acp): honor Claude auto-compaction window - #237
Conversation
Forward the configured Claude Code auto-compaction limit into ACP session metadata and show the effective limit in the status bar.
|
Thanks for this — and sorry for the slow review. 🙏 I dug into it properly (including disassembling the bundled Claude engine to check the actual precedence rules), and I want to say up front: you found the right lever. That part is genuinely good work:
So the direction is right. But I don't think it's ready to land yet — here's what I found. Blocking1. It no longer merges, and the frontend file is gone. The PR is from early June and 2. The
3. The The engine resolves the window like this: function resolveAutoCompactWindow(model, settingsValue) {
const detected = detectWindow(model, betas);
if (process.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW) {
...
return { window: Math.min(detected, c), configured: c, source: "env" }; // ← returns here
}
if (settingsValue !== undefined)
return { window: Math.min(detected, settingsValue), configured: settingsValue, source: "settings" };
...
}The env var is checked first and short-circuits; the engine's own And that env var is already reaching the engine without this PR: codeg puts it in Net effect: only the 4.
It's also unnecessary on its own terms: SDK Two things it does cost:
5. Production code reads
6. The status bar can end up showing a number that isn't true. The engine's effective threshold is const contextMax = configuredAutoCompactWindow ?? liveContextMax ?? sessionStats?.… ?? nullso the configured value unconditionally beats the window the agent actually reports. When the model doesn't support 1M, or a gateway falls back to 200K, the bar reads To be clear, the motivation is right — with a 1M model and a 300K configured window, today's bar shows 7. The beta header goes out unconditionally.
Non-blocking notes
What I'd suggestI'd love to land the core of this. The smallest version that works:
Happy to take it in pieces if that's easier — even just steps 1–3 would be a good standalone PR. Thanks again for digging into this corner; it's a real gap and you clearly did the homework on it. 🙌 中文摘要结论:方向和核心杠杆都抓对了( 阻塞项:
建议的最小形态:rebase → 只保留 beta 注入 → 三个 builder 全接上(含 resume)→ 前端在 |
Summary
CLAUDE_CODE_AUTO_COMPACT_WINDOWinto Claude Code ACP session metadata asoptions.settings.autoCompactWindow.~/.claude/settings.jsonwhile merging the configured auto-compaction window.Test plan
cargo test --manifest-path src-tauri/Cargo.toml --lib build_new_session_requestcargo test --manifest-path src-tauri/Cargo.toml --lib build_load_session_requestcargo check --manifest-path src-tauri/Cargo.tomlcargo check --manifest-path src-tauri/Cargo.toml --bin codeg-server --no-default-featurespnpm eslint src/components/layout/status-bar-tokens.tsx摘要
CLAUDE_CODE_AUTO_COMPACT_WINDOW写入 Claude Code ACP 会话 metadata,即options.settings.autoCompactWindow。~/.claude/settings.json中已有的 Claude Code 用户 SDK options。测试计划
cargo test --manifest-path src-tauri/Cargo.toml --lib build_new_session_requestcargo test --manifest-path src-tauri/Cargo.toml --lib build_load_session_requestcargo check --manifest-path src-tauri/Cargo.tomlcargo check --manifest-path src-tauri/Cargo.toml --bin codeg-server --no-default-featurespnpm eslint src/components/layout/status-bar-tokens.tsx