Skip to content

fix(compacting): close an idle compaction with done - #77

Merged
omartelo merged 1 commit into
mainfrom
fix/idle-compaction-done
Oct 15, 2026
Merged

omartelo merged 1 commit into
mainfrom
fix/idle-compaction-done

Conversation

@omartelo

Copy link
Copy Markdown
Collaborator

Summary

Claude Code 2.1.300 compacts an idle conversation before its prompt cache expires and hands session.compact to the mod as trigger: "auto", the same trigger as a compaction inside a turn. hooks/mod-compacting.js closed every auto with busy; with no turn open and no Stop to follow, the lich card showed the session running until the next prompt.

The mod now closes with the turn's state: it follows turn.start / turn.complete and reports busy while a turn is open, done when none is. Contract: omartelo/lich#767.

The two turn hooks match { turnId: /^/ }: Claude Code refuses a plugin's second hook on an event with no matcher, and mod-control.js already holds those. A RegExp matcher firing beside an unmatched hook was checked under claude plugin test with a minimal plugin.

Test changes: the auto cases that expect busy now open a turn first (the contract changed: the closing state is keyed on the turn), and the fake engine tests a RegExp matcher value as the engine does.

Test plan

  • node --test tests/*.test.mjs: 419 pass. The new idle test fails against the old mod.
  • claude plugin test .: 32 pass (the module loads beside the other mods).
  • A live idle compaction: not run; the testing kit's $.session.compact always fires with trigger: "plugin", so auto cannot be driven there.

Claude Code 2.1.300 compacts an idle conversation before its prompt cache
expires and reports it as `auto`, the trigger of a compaction inside a
turn. The mod closed every `auto` with `busy`, and with no turn open and
no Stop to follow, the card sat on the spinner until the next prompt.

The closing state is now the turn's: the mod follows turn.start and
turn.complete and closes with `busy` while a turn is open, `done` when
none is. The existing `auto` tests open a turn first, since the contract
now keys the closing state on it (omartelo/lich#767).
@omartelo
omartelo merged commit bceabc7 into main Oct 15, 2026
2 checks passed
@omartelo
omartelo deleted the fix/idle-compaction-done branch October 15, 2026 14:47
@omartelo omartelo mentioned this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant