PR #9923 review: show a compaction as a notice
Summary
After a resume, import or fork of a Claude chat, the compaction summary that Claude Code stores as a user message ("This session is being continued…") showed up as a user bubble. The PR advertises session.compaction, maps compaction_update / compaction_summary_chunk to one upserted notice item per compaction (live and on replay, main session and subagents), and asks claude-acp for ACP v1, because the ACP SDK's v2→v1 router replaces the client's capabilities with a fixed set that has no compaction. Steers still wait while a compaction is in progress.
Verdict
Minor issues The approach is right and I reproduced the fix end to end against the real claude-agent-acp 0.107.0. One small gap: a compaction notice that never gets a terminal update keeps saying "Compacting conversation history" after the turn ends.
Findings
A compaction notice left in_progress is never closed
packages/chat-runtime/src/harness/acp/acpAdapter.ts:1572 (endCompactions) and sessionStream.ts:523 (setCompaction)
endCompactions() releases the steer gate at turn end, failure, exit and dispose. It does not touch the notice. If the agent sends no terminal compaction_update, the notice stays "Compacting conversation history" with no completedAtMs after the turn completes. NoticeRow has no spinner, so the transcript reads as if compaction is still running. I confirmed this with a local test: in_progress → releasePrompts("end_turn") → turn completed, notice still in progress.
claude-agent-acp 0.107 sends cancelled on its own turn boundary, and codex-acp's finishTurn sends a terminal status, so the normal path is fine. The gap is the crash, failed-prompt and older-adapter paths. The old comment on endCompactions says claude-agent-acp leaves a compaction in_progress at turn end, so the case is known.
Fix: add SessionStream.settleCompactions(status), which re-emits every non-terminal compaction notice as cancelled. Call it from finishTurn/failTurn/handleExit next to endCompactions(), and add one test.
v1ClientCapabilities also builds the v2 request
packages/chat-runtime/src/harness/acp/acpAdapter.ts:124
Codex and the other agents use the same helper with protocolVersion: 2, so the name reads like it is only for the v1 path. Something like clientCapabilitiesFor(protocolVersion) would say what it does. Optional.
Checked and fine:
- The v1 request gives claude-agent-acp exactly what the SDK router used to grant, plus
session.compaction. I patched aninitializeprobe into a copy of the adapter and compared the two requests (below).auth.terminalstaysfalse.clientInfois not read by the agent, so sendinginfoon v1 loses nothing. - Codex: codex-acp 2.1.0 receives our
clientCapabilitiesas sent, without the router. It getssession.compactionnow, so the "applies to Codex too" note in the PR is accurate. - Quiet resumes (
resume.quiet) drop items inemit(), so reattaching a chat does not add duplicate compaction notices. - The protocol already has
noticeKind: "compaction", and desktopNoticeRowand mobilechatRowsalready draw notices. No UI change is needed. - The English notice text bypasses Lingui. This matches the other runtime notices, and the PR description says so.
Evidence
Chat runtime + real claude-agent-acp (end to end, at 9e57a593)
I wrote a Claude Code transcript by hand (prompt, reply, compact_boundary, isCompactSummary user message, prompt, reply) into a temp CLAUDE_CONFIG_DIR. Then I resumed it through this branch's AcpAdapter with the bundled claude-agent-acp 0.107.0 and CLAUDE_AGENT_ACP_PROTOCOL=v1, as host-service does. The first run uses the PR's protocolVersion: 1. The second run asks for v2, which is the request before this PR.
protocolVersion asked: 1
user_message user_message:…:a0…01 [{"type":"text","text":"fix the flaky test"}]
agent_message agent_message:…:msg_1 On it.
notice compaction compaction:a0…04 Conversation history was compacted
user_message user_message:…:a0…05 [{"type":"text","text":"is it fixed?"}]
agent_message agent_message:…:msg_2 Fixed.
protocolVersion asked: 2 (adapter default — the pre-PR request)
user_message user_message:…:a0…01 [{"type":"text","text":"fix the flaky test"}]
agent_message agent_message:…:msg_1 On it.
user_message user_message:…:a0…04 [{"type":"text","text":"This session is being continued from a previous conversation that ran out of context. …
user_message user_message:…:a0…05 [{"type":"text","text":"is it fixed?"}]
agent_message agent_message:…:msg_2 Fixed.
With the fix, the summary becomes a single compaction notice in its place, between the two replies. The v2 request reproduces the reported bug.
Full output: replay-output.txt · driver: replay.ts
initialize capabilities as claude-agent-acp receives them
v2 request (before): {"fs":…,"terminal":false,"session":{"configOptions":{"boolean":{}}},"plan":{},"auth":{"terminal":false},"elicitation":{"form":{}}}
v1 request (this PR): {"fs":…,"terminal":false,"session":{"compaction":{},"configOptions":{"boolean":{}}},"plan":{},"auth":{"terminal":false},"elicitation":{"form":{}}}
Not verified
- Desktop rendering: a desktop dev instance was running in this sandbox, signed in, with no CDP port. Its dev host-service had no local workspaces. A chat session needs one, and this run may not create workspaces. I did not drive the UI.
NoticeRowis not changed by this PR. - Mobile: not attempted, for the same reason.
- Live compaction in a signed-in Claude session: not verified here. The PR author also did not verify it. Steer gating during a live compaction is covered only by the unit test.
Questions for the author
- claude-agent-acp's comments say that a compaction which streamed summary chunks but got no CLI terminal signal is closed with
cancelledat the turn boundary, even if it succeeded. It would then show "Conversation history compaction was canceled". Have you seen this in a live session? Shouldcancelledafter streamed summary chunks read as compacted? - Are you going to file the SDK router bug (v2→v1 ignores
clientCapabilities) upstream? A link in theacpCatalogue.tscomment would show when the v1 pin can go.
Test / CI notes
- Commit
9e57a59358db810d37d9aea5574e62c7ffa5bfbe. bun test src/harness/acpinpackages/chat-runtime: 231 pass, 0 fail.bun run typecheck: clean.bun test src/chat-v3inpackages/host-service: 100 pass, 0 fail.- GitHub CI: Lint, Typecheck, Test, Sherif, Boot twice, Version Sync and the deploys are green. CodeRabbit was still running when I checked.
- To check the finding, I added a local probe test (in_progress, then end_turn) and reverted it. The branch was not changed.