Repository navigation
Conversation
The Project scope sent one path per worktree. A repo with more than 64 of them had its list scanned partially and its search refused outright, which the panel showed as "Could not search this computer". Sibling worktree paths now fold into their parent directory once the project is past the cap; Orca keeps a repo's worktrees under one directory of their own and both the scanner and the index match by prefix, so the parent covers what the siblings did. The search request also trims to the cap instead of throwing, matching what the list already did.
📝 WalkthroughWalkthroughThe change adds Priority: ➖ Normal Merge Risk: 🔵 Low · up to At scale, unusual POSIX filenames or UNC share-root worktrees can produce incorrect AI vault scopes, causing searches and session listings to include or omit paths unexpectedly. The cases are narrow but should be corrected. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description clearly explains the bug, fix, scope, and tests, but it omits required template sections, including the linked issue, visual proof or an explicit N/A explanation, testing checklist, AI disclosure, review, boundary confirmation, notes, and final checklist. Resolution Add the required template sections. Include the linked issue after “Fixes #”. Add visual proof or write
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: e5402e62-3cc1-4fec-a139-115b173b34bd
📒 Files selected for processing (3)
src/renderer/src/components/right-sidebar/ai-vault-scope-paths.test.tssrc/renderer/src/components/right-sidebar/ai-vault-scope-paths.tssrc/renderer/src/components/right-sidebar/use-ai-vault-search.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| /** The directory holding `pathValue`, or null when that would be a filesystem root. */ | ||
| function runtimeParentDirectory(pathValue: string): string | null { | ||
| const trimmed = pathValue.replace(/[\\/]+$/g, '') | ||
| const separator = Math.max(trimmed.lastIndexOf('/'), trimmed.lastIndexOf('\\')) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not parse backslashes as POSIX separators.
On POSIX, \ is valid in a filename. If more than 64 paths include /foo\one and /foo\two, Line 134 assigns both paths the parent /foo and folds them. These are top-level paths and must remain separate. Only treat \ as a separator when the path has Windows semantics. Add a POSIX regression test.
Based on learnings: a backslash is a valid literal filename character on POSIX.
Source: Learnings
| const parent = trimmed.slice(0, separator) | ||
| // `//server/share/x` and `C:\x` both sit directly under a root; `/x` was caught above. | ||
| if (/^[a-zA-Z]:$/.test(parent) || /^[\\/]{2}[^\\/]+[\\/][^\\/]+$/.test(parent)) { | ||
| return null |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Detect UNC share roots before deriving their parent.
If an over-cap list contains \\server\share-a and \\server\share-b, Line 138 derives \\server. Line 140 checks that derived value, so it does not preserve either share root. The function then folds both roots into \\server, which violates the root-handling contract. Detect UNC share roots from trimmed before slicing the parent and add a regression test.
There was a problem hiding this comment.
Important
The fold assumes every worktree's parent directory is repo-specific, which only holds for the nested layout. With nestWorkspaces: false or SSH worktrees that parent is shared across repos, so folding widens the Project scope — and, because search hits bypass the panel's client-side project filter, the search results — to unrelated projects. Detail inline.
Reviewed changes
- Fold siblings past the cap —
deriveAiVaultScopeSessionPathsnow returnsfoldSiblingScopePathsUnderCap(accumulator.paths), grouping paths by immediate parent and replacing any group of two or more with the parent. - Trim the search request — the panel slices
scopePathstoAI_VAULT_SCOPE_PATHS_MAX_COUNTrather than letting the schema reject the request. - Tests — fold unit tests (under-cap unchanged, siblings fold, Windows drive/UNC roots, top-level directories), an end-to-end over-cap case through
deriveAiVaultScopeSessionPaths, and the at-scale timing guard now asserts the folded result.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| * covers what the siblings did. Below the cap nothing changes; a path with no | ||
| * sibling, or whose parent is a filesystem root, stays as it is. | ||
| */ | ||
| export function foldSiblingScopePathsUnderCap(paths: readonly string[]): string[] { |
There was a problem hiding this comment.
The coverage argument here ("Orca keeps a repo's worktrees under one directory of their own") only holds for the nested layout. With nestWorkspaces: false worktrees land at <workspaceDir>/<name>, and SSH worktrees at <repoParent>/<repoName>-<name> — both share a parent with other repos. Folding 65 worktrees to that parent widens the scope to sibling repos, and search hits are not re-filtered by project, so unrelated projects' sessions appear in Project-scope search results.
Technical details
# Folding to a shared parent widens the Project scope
## Affected sites
- `src/renderer/src/components/right-sidebar/ai-vault-scope-paths.ts:100` — `foldSiblingScopePathsUnderCap` folds any parent with >1 member without checking that the parent belongs to the active repo.
- `src/renderer/src/components/right-sidebar/use-ai-vault-search.ts:161` — the folded paths become the search `scopePaths`.
- `src/renderer/src/components/right-sidebar/ai-vault-session-filters.ts:45` — `useAiVaultPanelSessions` returns search hits unfiltered (`searching ? sessions : filterAiVaultSessions(...)`), so the list's project-attribution filter never runs for search.
## Evidence
- `computeWorktreePathFromWorkspaceRoot` (`src/main/ipc/worktree-logic.ts:126`): nested → `<workspaceDir>/<repo>/<name>`; flat → `<workspaceDir>/<name>`. Default is `nestWorkspaces: true` (`src/shared/default-global-settings.ts:35`), but the setting is user-settable.
- `computeRemoteWorktreePath` (`src/main/ipc/worktree-logic.ts:202`) places SSH worktrees at `<repoParent>/<repoName>-<name>` when `workspaceDir` is absolute (the desktop default).
- `sessionRowFilter` (`src/main/ai-vault-search/session-search-row-filter.ts:81`) matches by `cwdKey` prefix, so a parent scope matches every repo beneath it.
## Required outcome
Folding must not pull in sessions whose cwd belongs to a different project/repo. Either restrict the fold to parents that are provably repo-specific, or carry an explicit project/repo filter alongside the widened scope in the search request.
## Open questions for the human
- Are the flat (`nestWorkspaces: false`) and SSH layouts in scope for this fix, or is the over-inclusion considered an acceptable trade above the cap?|
Superseded by #21509, which resolves Workspace and Project scope on the host instead of folding paths under the cap. |

Bug
In the Agent Session History panel, choosing the Project scope and typing a query showed "Could not search this computer. Check its connection and try again." on any repo with more than 64 worktrees. The Project scope sends one scope path per worktree; the search request schema caps that list at 64 and refused the request, and the panel rendered the rejection as a connection failure. The session list had the same problem in a quieter form: it scanned the first 64 paths and warned.
Fix
deriveAiVaultScopeSessionPathsfolds sibling worktree paths into their parent directory once the project is past the cap. Orca keeps a repo's worktrees under one directory of their own, and both the scanner and the index match a scope by prefix, so the parent covers exactly what the siblings did. Below the cap nothing changes; a path with no sibling, or whose parent is a filesystem, drive, or share root, stays as it is.Tests
/.deriveAiVaultScopeSessionPathswith a repo root plus more worktrees than the cap.