PR #9923 review: show a compaction as a notice

PR #9923 · Review workspace · author harshithmullapudi · head 9e57a593 · reviewed 2026-11-18

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

Minor

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.

Nit

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:

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":{}}}

claude-init-probe.txt

Not verified

Questions for the author

Test / CI notes