Repository navigation
Recover partially deleted local worktrees - #6657
Conversation
3d44895 to
650a4da
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 650a4dabe8bbd5bef4481427945034d566b2d7b5 and aee2730. 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThe changes add guarded cleanup for unregistered Orca leftover directories in both the IPC worktrees handler and the Orca runtime flow. A new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
src/main/local-worktree-filesystem.ts (1)
106-111: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short why-comment for the WSL exit-code remap.
Normalizing
code === '2'toENOENTis a non-obvious compatibility contract for the cleanup callers. Please leave a brief “Why” comment here so this does not look like generic exit-code handling. As per coding guidelines, modified TypeScript with non-obvious behavior should include a short explanatory comment.Suggested change
].join('\n') ).catch((error) => { + // Why: this shell returns exit code 2 for our explicit "missing path" + // branch; remap it to ENOENT so callers can treat WSL like native fs. if (isWslMissingPathError(error)) { throw Object.assign(new Error(`missing ${path}`), { code: 'ENOENT' }) } throw error })Source: Coding guidelines
src/main/ipc/worktrees.ts (2)
258-287: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCentralize and document the conservative Git-repo probe.
gitStatusErrorMeansNotRepositoryis duplicated insrc/main/runtime/orca-runtime.ts; this parser now gates recursive deletion in two paths, so extract a shared helper and add a short note that unknown Git failures are treated as repository-like to fail closed. As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."Source: Coding guidelines
1467-1505: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short “why” comment for this recovery branch.
This local-only path intentionally deletes an unregistered non-repository directory without calling Git; a brief comment will preserve the safety rationale at the call site. As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Suggested comment
+ // Why: partially deleted local worktrees are no longer Git repos; only + // recursively delete targets proven to be Orca-owned leftovers. if (!repo.connectionId) {Source: Coding guidelines
src/main/runtime/orca-runtime.ts (1)
1207-1236: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueFactor the duplicated git-repo probe into one helper.
isLocalRuntimeGitRepository/isLocalGitRepositoryandgitStatusErrorMeansNotRepositoryare identical insrc/main/runtime/orca-runtime.tsandsrc/main/ipc/worktrees.ts; a shared helper would keep the repo check in sync.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: aa859222-e2f0-42d0-8154-594e29e7aa24
📥 Commits
Reviewing files that changed from the base of the PR and between ef6e643 and 3d448956fc5ad51c10ad109360aa932892318fa3.
📒 Files selected for processing (16)
config/localization-coverage-allowlist.jsonsrc/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/local-worktree-filesystem.test.tssrc/main/local-worktree-filesystem.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/worktree-removal-safety.test.tssrc/main/worktree-removal-safety.tssrc/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsxsrc/renderer/src/components/workspace-cleanup/workspace-cleanup-presentation.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/local-worktree-filesystem.ts (1)
71-78: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short why-comment for the WSL exit-code remap.
Treating WSL exit code
2asENOENTis a non-obvious contract, so this change should carry a brief rationale near the helper or the catch block.
As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."♻️ Proposed fix
function isWslMissingPathError(error: unknown): boolean { + // Why: the WSL stat probe exits 2 when the target path is missing; callers + // already branch on ENOENT, so normalize that shell-specific failure here. const code = error && typeof error === 'object' && 'code' in error ? String((error as NodeJS.ErrnoException).code) : ''Also applies to: 106-109
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d6a94094-b005-47bc-bb9e-e696e7704d05
📥 Commits
Reviewing files that changed from the base of the PR and between 3d448956fc5ad51c10ad109360aa932892318fa3 and 650a4dabe8bbd5bef4481427945034d566b2d7b5.
📒 Files selected for processing (8)
src/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/local-worktree-filesystem.test.tssrc/main/local-worktree-filesystem.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/worktree-removal-safety.test.tssrc/main/worktree-removal-safety.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- src/main/local-worktree-filesystem.test.ts
- src/main/worktree-removal-safety.test.ts
- src/main/runtime/orca-runtime.ts
- src/main/worktree-removal-safety.ts
- src/main/ipc/worktrees.test.ts
- src/main/ipc/worktrees.ts
- src/main/runtime/orca-runtime.test.ts
650a4da to
aee2730
Compare
Co-authored-by: Neil <[email protected]>
Summary
Handles the local partial-delete recovery case where Git no longer registers a worktree and the worktree
.gitmarker is gone, but the directory still exists on disk. Orca now prompts before force cleanup for Orca-owned leftover directories, then removes the leftover directory and metadata without invoking Git worktree removal on a non-repo path.The change also tightens destructive cleanup safety around WSL/runtime path translation, protected home/root paths, nested registered worktrees, and WSL missing-path stat behavior.
Design Review
Design doc created as scratch context and reviewed before implementation. The reviewed design narrowed no-marker cleanup to local paths, required directory/no-
.git/not-a-repo proof, kept SSH no-marker cleanup out of scope, and required cross-platform path checks.Implementation
.git-marker orphan cleanup.Completeness Verification
Completeness verification initially found missing coverage; added helper and integration tests. A follow-up verification pass confirmed the implementation matched the design, with only non-blocking notes about live WSL/SSH coverage.
Code Review
Two-reviewer rounds were run until both reviewers returned clean in the same round.
Actionable findings fixed during review:
.gitstat errors not shaped as ENOENT..gitorphan cleanup needed original-path danger and nested checks.Final round: both reviewers returned no issues.
Brennan Test Changes
Recommendation: land.
Validated:
.gitdirectories / still-repo paths remain rejectedNo screenshot evidence was captured because the changed behavior is backend/destructive-delete logic exercised through IPC/runtime tests with temporary filesystem fixtures. The small UI localization cleanup is covered by lint/localization checks.
Checks
pnpm test -- --run src/main/worktree-removal-safety.test.ts src/main/local-worktree-filesystem.test.ts src/main/ipc/worktrees.test.ts src/main/runtime/orca-runtime.test.ts- 680 passedpnpm test -- --run src/main/worktree-removal-safety.test.ts src/main/local-worktree-filesystem.test.ts src/main/ipc/worktrees.test.ts src/main/runtime/orca-runtime.test.ts -t "unregistered|orphan|local worktree filesystem runtime access|canCleanupUnregisteredOrcaLeftoverDirectory"- 35 passedpnpm exec tsc --noEmit --pretty false- passedpnpm run lint- passedgit diff --check- passedPost-PR Stabilization
Pending initial PR automation. Will wait for automated review/checks and update if fixes are needed.
Assumptions and Risks