Skip to content

fix(cli): finish an interrupted directory operation before planning the next command - #967

Merged
777genius merged 2 commits into
mainfrom
fix/claude-user-remove-recovery
Nov 17, 2026
Merged

777genius merged 2 commits into
mainfrom
fix/claude-user-remove-recovery

Conversation

@777genius

Copy link
Copy Markdown
Owner

Follow-up to #959, found by running the installer against a real Claude Code on Linux.

If remove for 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:

  • remove answered "plugin is not installed", because it plans against the already committed state and never reaches the mutation path's own recovery.
  • add answered "native identity is unmanaged", because the backup carries the same plugin name, and the installer's own preflight refuses pending recovery.
  • doctor showed 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) before add, update, repair and remove plan 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 blocks add. 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 remove and update in 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.

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-security

Copy link
Copy Markdown

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.

@777genius
777genius merged commit db082da into main Nov 17, 2026
76 of 77 checks passed
@777genius
777genius deleted the fix/claude-user-remove-recovery branch November 17, 2026 01:20
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.11%. Comparing base (726899a) to head (91a0559).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
cli/internal/agentpluginscli/lifecycle_commands.go 33.33% 2 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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