orca icon indicating copy to clipboard operation
orca copied to clipboard

fix(worktrees): prevent session purge on inaccessible repositories

Open AmethystLiang opened this issue 4 months ago â€ĸ 1 comments

Summary

  • use the throwing Git scanner for authoritative local worktree detection so filesystem and Git failures reach the existing non-authoritative fallback
  • leave failed scans out of the detected-worktree cache so a restored permission grant is retried immediately
  • add an EPERM regression covering the macOS Documents/TCC failure and recovery path

Root cause

A LaunchServices-started Orca without Documents access could make git worktree list fail with EPERM. The ordinary scanner converted that failure to an empty array, worktrees:listDetected labeled it authoritative, and renderer reconciliation treated every local worktree as deleted. Preserving the scan error breaks that deletion chain while keeping genuine successful empty scans authoritative.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/worktrees.test.ts src/renderer/src/store/slices/store-session-cascades.test.ts (252 tests passed)
  • pnpm run typecheck
  • pnpm exec oxlint src/main/ipc/worktrees.ts src/main/ipc/worktrees.test.ts
  • pnpm exec oxfmt --check src/main/ipc/worktrees.ts src/main/ipc/worktrees.test.ts
  • pnpm run check:reliability-gates
  • pnpm run check:max-lines-ratchet

Full pnpm run lint reaches a pre-existing switch-exhaustiveness error in the unchanged src/renderer/src/components/skills/skill-freshness-group.tsx:101.

AmethystLiang avatar Jul 22 '26 05:07 AmethystLiang

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: 3f8bbd0a-8107-4170-b7c7-589338f04742

đŸ“Ĩ Commits

Reviewing files that changed from the base of the PR and between 5d0c29f7299c10e4e1e021ba930353db35f0520f and 632411a1a0fcab6f3ad8acb08837d47b38b16b20.

📒 Files selected for processing (2)
  • src/main/ipc/worktrees.test.ts
  • src/main/ipc/worktrees.ts

📝 Walkthrough

Walkthrough

Authoritative detected-worktree scans now call listGitWorktreesStrict, passing local Git options only for WSL repositories. Tests add a strict scanner mock and verify that an EPERM failure returns a non-authoritative empty metadata fallback, clears in-flight cache statistics, and retries successfully on the next request with an authoritative result.

đŸšĨ Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check âš ī¸ Warning The description covers summary, root cause, and testing, but it omits required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, including Screenshots, AI Review Report, Security Audit, and Notes, or explicitly mark no visual change where applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: avoiding session purge on inaccessible repositories.
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.

coderabbitai[bot] avatar Jul 22 '26 05:07 coderabbitai[bot]

Closing as already implemented on current main (a93e31a93395). The failure-preservation and retry behavior this PR targets are now covered by the current scan pipeline:

  • listRepoWorktreesForDetectedScan routes authoritative detection through listWorktreesSharedStrictAllowingTrueEmpty; the strict scanner rethrows permission/Git failures and only permits confirmed missing paths or non-repositories to return an authoritative empty list.
  • The detected scan cache publishes a cache entry only after the scan resolves, and clears in-flight bookkeeping in finally, so failed scans are retried immediately.
  • The listing failure path returns authoritative: false without running successful-scan pruning. Existing failure-authority coverage checks that failures prune nothing.

I reviewed both changed files and the current scanner/cache/fallback implementation. The core fix is preserved in the newer implementation, so this branch no longer has a remaining functional change to land.

OrcaWin avatar Oct 26 '26 22:10 OrcaWin