Repository navigation
fix(runtime): resolve folder workspace file selectors (#6357) - #6569
Conversation
Folder-workspace selectors (`folder:<id>`) threw `selector_not_found` in the file explorer because every file op routed through `resolveWorktreeSelector` / `resolveRuntimeGitTarget`, which only match real git worktrees. Folder workspaces (project-group/monorepo sessions) have no backing worktree record, so opening any file or directory failed with "Unable to load file — selector_not_found". Add `resolveRuntimeFileTarget`, which first resolves folder workspaces via the existing `resolveFolderWorkspaceLaunchScope` path (the same special-casing the terminal launch path already uses) and otherwise falls back to the worktree-selector path. The file/search/markdown commands now route through it, so folder-workspace sessions list and preview files for both local and SSH-backed workspaces. Git diff/status for folder workspaces still routes through `resolveRuntimeGitTarget` and is intentionally out of scope: a folder workspace spans N child repos, so there is no single git target. Supersedes #6363. Fixes #6357 Co-authored-by: bennewell35 <[email protected]>
|
Warning Review limit reached
More reviews will be available in 11 minutes and 26 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
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 |
Evidence — before / after1. Regression reproduced (BEFORE) — production source reverted to
|
🧑🤝🧑 Impact & ELI5
1) What's broken today (ELI5). If you open a folder that contains several separate projects inside it (Orca calls this a "monorepo / project group" — for example a
workfolder holding your API, your admin app, and your portal as four sibling git repos) and let one agent work across all of them at once, the file panel is effectively dead. Clicking any file in the file tree — or trying to preview one — just shows "Unable to load file — selector_not_found." It fails on 100% of files, every time, with a Retry button that doesn't help. So a user who deliberately chose this "one agent, many related projects" setup can't browse or read a single file. It's a hard blocker for that workflow, but it's niche: it only hits people using the folder/project-group import, not the normal "open one repo" path.2) What this PR does (ELI5). Think of every file request as a delivery that needs an address. Orca looks up the address by asking "which git repo is this?" — but a folder workspace isn't itself a git repo (it's just a container holding repos), so the lookup came back "no such address" and the delivery was dropped. The terminal already knew how to handle these container folders; the file panel didn't. This PR teaches the file panel the same trick: when it sees a folder-workspace request, it first resolves it as a container folder (and figures out whether that folder lives locally or on a remote SSH machine) before looking anything up. So now you click a file and it opens, instead of failing — for both local folders and SSH-hosted ones.
3) Tradeoffs / regressions — honest answer. Two things to be honest about, neither of which makes existing behavior worse:
selector_not_foundfor folder workspaces when you try to open a file's diff. That's called out as intentionally out of scope: a folder workspace spans N child repos, so there's no single git target to point at, and solving that needs a separate design. So a user on this setup gets working file browsing but still can't view diffs in the Git tab — that limitation is unchanged, not newly introduced.repo/localGitOptionsfield), but those callers never used that field — the WSL-distro detail they need is recomputed locally — so behavior is identical. Nothing is disabled, no new setup or settings, no feature is removed, and invalid selectors are still rejected exactly as before.Summary
Fixes the monorepo / project-group bug where folder-workspace sessions could not list or preview files: clicking any file in the tree (or opening the file explorer preview) failed with "Unable to load file — selector_not_found".
Folder-workspace selectors use the key
folder:<id>and have no backing git worktree record. Every file op inRuntimeFileCommandsresolved its target throughresolveWorktreeSelector/resolveRuntimeGitTarget, which only match real git worktrees and throwselector_not_foundfor folder workspaces — even though the terminal launch path already special-cases folder workspaces viaresolveFolderWorkspaceLaunchScope.This adds
OrcaRuntimeService.resolveRuntimeFileTarget(selector), which:resolveFolderWorkspaceLaunchScopepath and returns a synthesizedResolvedWorktree(folderWorkspaceToResolvedWorktree, wrapping the sharedfolderWorkspaceToWorktree) plus the inferredconnectionId;repo.connectionIdpath.The file/search/markdown commands (
resolveFileExplorerPath,listMobileFiles,openMobileFile,openMobileDiff,readMobileFile,resolveTerminalPath,searchRuntimeFiles,listRuntimeFiles,listRuntimeMarkdownDocuments) now route through it. As a result, folder-workspace sessions list and preview files for both local and SSH-backed workspaces.This supersedes #6363 (community PR by @bennewell35) — the code is taken over and re-verified here; their PR is left open and credited via
Co-authored-by:.Out of scope (intentional): git diff/status and the Git tab for folder workspaces still route through
resolveRuntimeGitTarget, which has no folder handling. A folder workspace spans N child repos, so there is no single git target — that is a separate, larger design question (Bug 1 in the issue) and this PR deliberately does not touch it.Screenshots
Backend resolution fix (no new UI). Verified end-to-end through the real runtime RPC stack in a dev Electron build — see the PR comment for the before/after evidence (reverted-source failure vs. live RPC success against a real multi-repo folder workspace).
Testing
pnpm lint(oxlint on the 5 changed files — clean)pnpm typecheck(tsgo --noEmit -p config/tsconfig.node.json— clean)pnpm test(changed suites + RPC method suite — see below)pnpm buildTests run (vitest,
config/vitest.config.ts):orca-runtime.test.ts— 489 passed (incl. new local + SSH folder-workspace file-explorer cases)orca-runtime-files.test.ts+orca-runtime-files-watch.test.ts— 29 passedrpc/methods/files.test.ts— 37 passed (no regression in the RPC layer)Regression proof: with the production source reverted to
main(new tests kept), the new folder-workspace tests fail withError: selector_not_foundfromresolveWorktreeSelectorviaRuntimeFileCommands.resolveFileExplorerPath. With the fix, they pass.AI Review Report
Reviewed correctness, edge cases, cross-platform behavior, and SSH/remote. Key checks:
resolveFolderWorkspaceLaunchScopefirst, worktree fallback otherwise); normal per-repo worktree selectors are unaffected (folder check returnsnullfor non-folder:keys).joinWorktreeRelativePathhelper. Windows WSL search test and UNC-path status test still pass. SSH folder-workspace routing covered by a dedicated test.connectionIdflows from the folder scope to the SSH filesystem provider; droppinglocalGitOptions/repofrom the three search/list/markdown sites is safe — they only consumetarget.connectionIdandtarget.worktree.path, andsearchLocalRuntimeFilesrecomputeswslDistroitself.Security Audit
parseWorkspaceKeyand a folder workspace must already exist in the store. Verified live that a nonexistentfolder:<id>still rejects withselector_not_found— the change does not broaden which selectors are accepted, only resolves valid folder workspaces.isSafeMobileRelativePath,normalizeRuntimeRelativePath) are unchanged. No traversal surface added.Notes
Co-authored-by:); that PR is intentionally left open.resolveRuntimeGitTargetdoes not hold. Tracked as Bug 1 in [Bug] Worktree in a monorepo, can not see files and git changes #6357.Made with Orca 🐋