Skip to content

Handle locked worktree force deletion#7963

Open
Jinwoo-H wants to merge 1 commit into
mainfrom
Jinwoo-H/manual-worktree-delete
Open

Handle locked worktree force deletion#7963
Jinwoo-H wants to merge 1 commit into
mainfrom
Jinwoo-H/manual-worktree-delete

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • map explicit worktree Force Delete to Git double-force removal so locked stale worktree registrations can be removed
  • mirror the behavior in the SSH relay worktree removal path
  • offer Force Delete for locked-worktree Git errors and add a live Git repro for a locked worktree whose directory was manually deleted

Validation

  • Red repro before fix: pnpm exec vitest run --config config/vitest.config.ts src/main/git/worktree-list-paths.test.ts --testNamePattern "force-removes a locked worktree" failed with cannot remove a locked working tree... use remove -f -f
  • Green after fix: pnpm exec vitest run --config config/vitest.config.ts src/main/git/worktree-list-paths.test.ts
  • pnpm exec vitest run --config config/vitest.config.ts src/main/git/remove-worktree.test.ts src/relay/git-handler-worktree-ops.test.ts src/renderer/src/store/slices/store-cascades.test.ts
  • pnpm run typecheck
  • pre-commit hook: oxlint, react-doctor lint, oxfmt --write

Git cleanup safety

  • Non-force deletion still respects Git locks.
  • The stronger --force --force behavior is only used after Orca receives explicit force-delete intent.
  • No new scans, polling, listeners, subprocess fanout, or startup work were added. This changes only the argv for an already requested destructive Git removal.

Gaps

  • Live Git repro ran locally on macOS.
  • SSH parity is covered by relay unit coverage, but I did not run a live SSH deletion smoke.
  • I did not run a Windows Electron smoke.

Made with Orca 🐋

Co-authored-by: Orca <help@stably.ai>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ca5d332e-0c45-4be0-a829-b1926918c081

📥 Commits

Reviewing files that changed from the base of the PR and between ff661a7 and dc8d3e4.

📒 Files selected for processing (7)
  • src/main/git/remove-worktree.test.ts
  • src/main/git/worktree-list-paths.test.ts
  • src/main/git/worktree.ts
  • src/relay/git-handler-worktree-ops.test.ts
  • src/relay/git-handler-worktree-remove.ts
  • src/renderer/src/store/slices/store-cascades.test.ts
  • src/renderer/src/store/slices/worktrees.ts

📝 Walkthrough

Walkthrough

This change updates the git worktree removal logic to pass the --force flag twice (--force --force) when force-removing a worktree, matching Git's requirement for removing locked worktrees. This is applied in both the main process (worktree.ts) and relay handler (git-handler-worktree-remove.ts). Corresponding tests are updated to expect the double --force argument. A new test verifies force-removal of a locked worktree whose directory was manually deleted. The renderer store's retryable error message list gains a "cannot remove a locked working tree" entry, with an accompanying cascade test verifying force-delete eligibility on this error.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, validation, and safety notes, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, including screenshots or 'No visual change', an AI review report, a security audit summary, and a concise notes section.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: enabling locked worktree force deletion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

Comment @coderabbitai help to get the list of available commands.

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