fix(worktrees): prevent session purge on inaccessible repositories
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.
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.tssrc/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.
Comment @coderabbitai help to get the list of available commands.
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:
listRepoWorktreesForDetectedScanroutes authoritative detection throughlistWorktreesSharedStrictAllowingTrueEmpty; 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: falsewithout 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.