Repository navigation
fix(cli): finish an interrupted directory operation before planning the next command - #967
Conversation
A remove interrupted between its state commit and the directory finalization (SIGINT/SIGTERM during "finalize grouped removal") left an open dirswap journal and a hidden .agentplugins-backup-* copy of the plugin in the Claude skills directory. Rerunning the command could not reach the transactional recovery in the mutation path: - remove planned against the committed state and stopped with "plugin is not installed", including the interactive target prompt; - add (installer facade) saw the backup manifest as an unmanaged native identity in Prepare, and Apply refuses any pending recovery anyway. Doctor tells users to rerun add, update or remove to recover, so add and remove now run the installer's transactional recovery first when open directory journals exist. Dry runs never recover, inspection failures keep the previous behavior, and the installer still recovers the complete recorded scope or refuses it (for example environment-owned journals). The native identity checks are unchanged, so a real foreign plugin with the same name still blocks add.
An update interrupted after its state commit leaves the previous version as a hidden .agentplugins-backup-* next to the new Claude package. Rerunning update or repair planned first and stopped on that backup as an unmanaged native identity, so neither reached recovery. Both commands now finish the recorded transaction first, like add and remove. After such a recovery, remove no longer says "no target was changed": it reports the finished operation and keeps the "not installed" exit. Tests cover the update window after the commit decision, repair after it, a dry run that must not recover, and a deps environment journal that imperative commands must leave for deps recovery.
|
Strix is installed on this repository, but we couldn't run this PR security review because this workspace's trial has ended. Add a card to resume code reviews here. So far, Strix has reviewed 392 pull requests, surfaced 113 security issues (1 critical/high) and blocked 3 risky merges across this workspace. |
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #967 +/- ##
==========================================
+ Coverage 63.09% 63.11% +0.01%
==========================================
Files 2254 2256 +2
Lines 135180 135246 +66
==========================================
+ Hits 85294 85354 +60
- Misses 37525 37528 +3
- Partials 12361 12364 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Follow-up to #959, found by running the installer against a real Claude Code on Linux.
If
removefor Claude (user scope) is interrupted with Ctrl+C or SIGTERM in the short window after its state commit (about 50 ms of a 0.8 s removal), the binding is already gone from the state but a directory journal stays open and a hidden.agentplugins-backup-*copy of the plugin stays in<config>/skills. Rerunning the command could not recover:removeanswered "plugin is not installed", because it plans against the already committed state and never reaches the mutation path's own recovery.addanswered "native identity is unmanaged", because the backup carries the same plugin name, and the installer's own preflight refuses pending recovery.doctorshowed the open operation and told the user to rerun exactly those commands.The fix runs the installer's existing transactional recovery (
Installer.Inspect+Recover, under the same mutation lock as any other mutation) beforeadd,update,repairandremoveplan anything, when doctor's own open-journal check finds an unfinished directory operation. Dry runs never recover. Journals owned by a deps environment are left to deps recovery, as before. Nothing about identity checks changes: a genuinely foreign directory with the same name still blocksadd. After a recovery that finished a removal, the rerun says "Finished the interrupted operation." and drops "no target was changed" from the not-installed message (exit code stays 1).Checked with real Claude Code 2.1.325 on macOS: interrupting
removeandupdatein that window, then rerunning, finishes cleanly, leaves no backup or journal and doctor reports no open operations. The Go regression tests interrupt exactly after the state commit and fail without the change (remove, interactive remove, add, update, repair); they also cover dry run and an untouched deps journal.Not covered: saved-dependency routes (
deps recover) still stop on a foreign journal as before.