Repository navigation
feat(mod): report compacting while Claude Code compacts the conversation - #57
Merged
Merged
Conversation
This was referenced Oct 9, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client side of the session-state contract's new
compactingstate (lichdotdev/lich#687).What
hooks/mod-compacting.js(registered byhooks/lich.js) bracketssession.compact:compactingbefore the compaction runs, then the state the session returns to oncenext(e)settles, whether it resolved or rejected. A manual/compactcloses withdone, an automatic one withbusy, because its turn is still running and the turn'sown Stop reports
done. Only themanualandautotriggers are hooked, each throughits own matcher. A subagent's compaction (
agentId) is passed through, and so is anon-interactive run.
Measured (Claude Code 2.1.295, interactive PTY, stub lich)
session.compact:{trigger: "manual"|"auto", messages}.next(e)resolves to{messages}after the summary (manual ~6s, auto ~14s)./compactmakesnext(e)reject with "Request was aborted". An autocompaction the engine gives up on rejects within ~40ms with "reactive compaction
did not settle ok", and the turn continues.
PostCompactfires in neither case,which is why this is a mod and not a settings hook.
/compactleft the card ondone(noUserPromptSubmit),and an auto compaction showed a bare spinner.
compacting → done; auto givesbusy → compacting → busy → done.Discarded
session.end(reason): the existingSessionEnd → idlealready covers /clear,/resume, /branch and exit. Claude Code awaits it before
SessionStart, soidlealways lands before the new
/session-startid, and the card ends up right.session.attach/detach: never fired in a PTY session. Tested with RemoteControl opened from claude.ai. Only a stream-json
ui_attachfrom a remoterender surface raises it.
Notes for review
tests/lich-refstays at v0.61.0.tests/refresh-fixtures.shreadssession-state.jsonlalone at
f4481848, the commit where feat: show a Claude Code card's compaction as "Compacting..." lich#687 was merged into lich's main andwhich no release includes yet. Once a lich release includes that merge, move
lich-refto that release and put the file back in the loop.tests/hooks.test.mjspinned the old state vocabulary. Theynow expect
compactingin the fixtures, and scripts are no longer expected toregister it, since Claude Code reports it from the mod and no other harness
reports it.
to 0.20.0). There is no version bump here.
node --test tests/*.test.mjs: 356/356.claude plugin validate .claude-plugin/plugin.json: passes; the warnings are the "gating hook without .catch" ones the other mods already have.