Skip to content

fix(worktrees): offer a safe, explicit retry for populated submodules - #25979

Closed
nwparker wants to merge 2 commits into
mainfrom
fix/submodule-removal-explicit-consent
Closed

nwparker wants to merge 2 commits into
mainfrom
fix/submodule-removal-explicit-consent

Conversation

@nwparker

@nwparker nwparker commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​159 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​159
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37

ELI5

When Git refuses to delete a workspace containing initialized submodules, Orca now explains why and offers Force Delete. The warning states: “Force Delete may permanently discard submodule files and unpublished commits.”

What Changed

  • Classify the specific submodule-removal refusal as its own force-retry reason, shared by local and SSH error handling.
  • Show the existing Force Delete action with the same submodule loss warning in the failure toast and delete dialog.
  • Translate the warning into all six supported languages.
  • Keep Git locks authoritative and suppress another force offer after a forced attempt fails.

Why

Follow-up to #7354. A parent worktree can report clean even when a submodule contains unpublished commits. Automatically retrying with --force after checking parent status can discard those commits. This change preserves the local and SSH non-force refusal and lets the user make an informed, explicit retry through the existing force action.

Thanks to @soichisumi for identifying the issue and the original recovery work in #7354. Credited as co-author on the commit.

Visual Proof

Isolated renderer component previews using the actual toast component and app styles. The before preview uses the previous unclassified refusal state; the after preview uses the new classifier and warning.

Before:
Before: raw refusal without a force action

After:
After: submodule warning and explicit Force Delete

Testing

  • 75 tests pass across seven focused suites: force classification, real Git submodule behavior, warning consistency, toast rendering/click behavior, local removal, and relay removal.
  • The real Git test creates an unpublished submodule commit, records its gitlink in the parent, verifies parent status is clean, and confirms removal remains refused until explicitly forced.
  • pnpm lint passes, including localization checks.
  • Browser preview: verified visible warning and force button; callback count stays zero until clicking Force Delete, then becomes one.
  • pnpm typecheck and pnpm build are blocked by an existing TS2741 error in structured-agent-session-codex-stopped-send-order.test.ts:170: missing resolveLaunchArgs in runtime test dependencies. This file is unchanged by this PR.
  • Executed on macOS. Local and SSH removal guards are covered by automated tests; live SSH and Linux/Windows UI were not exercised. Full test suite and native packaging were not completed locally.

Review

No automatic force retry or deletion backend changes. Uses the existing host-qualified force action; Git locks continue to require explicit unlocking. Current local and relay Git executors already pin untranslated output for stderr classification. No new dependencies or Git-provider assumptions.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • Small and focused; user-facing behavior and safety rationale explained.
  • Before/after visual proof attached.
  • Self-reviewed for correctness, security, and performance.
  • Cross-platform and SSH behavior considered.
  • Lint and focused tests pass; typecheck/build limitations documented above.

Warn about submodule files and unpublished commits before the user retries Git's refusal. Preserve the non-force safety checks on local and SSH hosts.

Co-authored-by: soichisumi <[email protected]>
@nwparker
nwparker requested a review from brennanb2025 as a code owner October 6, 2026 21:55
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a88548c3-2fc5-45a3-84c5-0eb1edc521f1
📥 Commits

Reviewing files that changed from the base of the PR and between 6d1a49b and 26fc10d.

📒 Files selected for processing (9)
  • src/renderer/src/components/sidebar/delete-worktree-failure-toast.test.tsx
  • src/renderer/src/components/sidebar/submodule-removal-warning.test.ts
  • src/renderer/src/components/sidebar/submodule-removal-warning.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 376711a7-3274-4a0e-a7da-e5d008f01f03
📥 Commits

Reviewing files that changed from the base of the PR and between 51062e6 and 6d1a49b.

📒 Files selected for processing (14)
  • src/renderer/src/components/sidebar/delete-worktree-failure-toast.test.tsx
  • src/renderer/src/components/sidebar/delete-worktree-toast.ts
  • src/renderer/src/components/sidebar/submodule-removal-warning.test.ts
  • src/renderer/src/components/sidebar/submodule-removal-warning.ts
  • src/renderer/src/components/sidebar/worktree-delete-error-display.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/worktree/removal-force-classification.test.ts
  • src/shared/worktree/removal-submodule-git.test.ts
  • src/shared/worktree/removal.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The worktree removal classifier now recognizes Git refusals involving initialized submodules as a force-delete reason. The renderer displays translated warnings that advise backing up submodule files and publishing local commits before force deletion. Tests cover error classification, warning copy, and the force-delete interaction.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 6d1a4

Deleting a workspace with initialized submodules now shows a clear warning and an explicit Force Delete option. No merge-blocking risk was found. Live SSH and Linux/Windows UI behavior were not exercised.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 8 files. (6 skipped: 6… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: offering an explicit, safer retry for worktrees with populated submodules.
Description check ✅ Passed The description explains the user-facing change, rationale, implementation, visual proof, tests, platform coverage, and known typecheck/build limitation. It identifies follow-up issue #7354, but omits…
Full details: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 8 files. (6 skipped: 6 unsupported.)

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

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

@maxsumrall

Copy link
Copy Markdown

Worktrees with submodules seem like there is no way to remove now them after #24602 was merged, besides using the orca cli to remove it.

If I do understand this correctly, then this fix is (to me personally :D) very important.

@alexytsu

alexytsu commented Oct 8, 2026

Copy link
Copy Markdown

+1 on this. It looks like this was supported previously #9096 but as @maxsumrall points out, #24602 (perhaps inadvertantly?) removed it

@OrcaWin

OrcaWin commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Closing as fully superseded by merged #28878 (23b60a5d07b25a73193efd705fe620da7f6aef04). I read this PR's complete body and all 14 changed-file diffs, including its classifier, real-Git, dialog/toast and six-language changes, then compared the current implementations and relevant HEAD→origin/main updates at e630f2794096602818181d48a2129f28ba66da42.

Every core behavior is present: worktree/removal.ts recognizes the specific initialized-submodule Git refusal as submodules, after the Git-lock and already-forced guards, so a locked checkout is not offered a force bypass and a failed forced attempt is not offered another retry. The current renderer's getSubmoduleRemovalRefusalCopy explicitly says Force Delete permanently removes unpushed commits, local branches and stashes. The failure toast and worktree-delete-error-display.ts reuse that same warning; the existing user-invoked Force Delete action remains the retry. The shared classifier applies to local/SSH/paired error text without requiring a wire update. All six languages changed here already contain the corresponding warning; subsequent main localization edits do not change those entries.

#28878 also removed automatic force retry and has a real-Git regression with a local-only submodule commit: ordinary removal refuses and preserves registration/history, while explicit force succeeds. Its extra dirty-submodule detection broadens the warning beyond this proposal rather than leaving a missing core. The tests and extracted warning helper proposed here support those same behaviors and add no independent product change. No part of this PR still needs merging. This was a source/test comparison; I did not run tests or an app during the audit.

@OrcaWin OrcaWin closed this Oct 26, 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.

4 participants