Skip to content

fix(runtime): resolve folder workspace file selectors (#6357) - #6569

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-6357
Jun 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-6357

Conversation

@nwparker

@nwparker nwparker commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

🧑‍🤝‍🧑 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 work folder 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:

  • This only fixes half the reported issue. The user reported two bugs. This PR fixes Bug 2 (browsing/previewing files in the file tree). It deliberately does not fix Bug 1 — the Git/diff tab still shows selector_not_found for 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.
  • For everyone else: no regressions. Normal single-repo sessions are untouched — the new code returns "not a folder workspace" for ordinary selectors and falls straight through to the exact same lookup as before. Three file-search/list functions were switched to the new resolver, which returns slightly less data than the old one (it drops a repo/localGitOptions field), 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 in RuntimeFileCommands resolved its target through resolveWorktreeSelector / resolveRuntimeGitTarget, which only match real git worktrees and throw selector_not_found for folder workspaces — even though the terminal launch path already special-cases folder workspaces via resolveFolderWorkspaceLaunchScope.

This adds OrcaRuntimeService.resolveRuntimeFileTarget(selector), which:

  1. first resolves folder workspaces via the existing resolveFolderWorkspaceLaunchScope path and returns a synthesized ResolvedWorktree (folderWorkspaceToResolvedWorktree, wrapping the shared folderWorkspaceToWorktree) plus the inferred connectionId;
  2. otherwise falls back to the existing worktree-selector + repo.connectionId path.

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 build
  • Added or updated high-quality tests that would catch regressions

Tests 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 passed
  • rpc/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 with Error: selector_not_found from resolveWorktreeSelector via RuntimeFileCommands.resolveFileExplorerPath. With the fix, they pass.

AI Review Report

Reviewed correctness, edge cases, cross-platform behavior, and SSH/remote. Key checks:

  • Resolution order matches the established terminal pattern (resolveFolderWorkspaceLaunchScope first, worktree fallback otherwise); normal per-repo worktree selectors are unaffected (folder check returns null for non-folder: keys).
  • Cross-platform: no hardcoded path separators introduced; path joining uses the existing joinWorktreeRelativePath helper. Windows WSL search test and UNC-path status test still pass. SSH folder-workspace routing covered by a dedicated test.
  • Connection inference: connectionId flows from the folder scope to the SSH filesystem provider; dropping localGitOptions/repo from the three search/list/markdown sites is safe — they only consume target.connectionId and target.worktree.path, and searchLocalRuntimeFiles recomputes wslDistro itself.
  • Flagged and confirmed out-of-scope: git diff/status for folder workspaces (no single git target).

Security Audit

  • Input handling / IPC: selectors are parsed by parseWorkspaceKey and a folder workspace must already exist in the store. Verified live that a nonexistent folder:<id> still rejects with selector_not_found — the change does not broaden which selectors are accepted, only resolves valid folder workspaces.
  • Path handling: no new path construction; relative-path safety checks (isSafeMobileRelativePath, normalizeRuntimeRelativePath) are unchanged. No traversal surface added.
  • No command execution, eval, secret access, or new dependencies. Adopting fix(runtime): resolve folder workspace file selectors #6363: re-audited the diff as if hostile — no exfiltration, injection, or suspicious behavior; it is a pure routing change.

Notes

Made with Orca 🐋

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]>
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@nwparker, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 110f54c6-2723-489a-9523-bfc73ed32ecc

📥 Commits

Reviewing files that changed from the base of the PR and between 5712cf9 and a2b8b93.

📒 Files selected for processing (5)
  • src/main/runtime/orca-runtime-files-watch.test.ts
  • src/main/runtime/orca-runtime-files.test.ts
  • src/main/runtime/orca-runtime-files.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

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.

@nwparker

Copy link
Copy Markdown
Contributor Author

Evidence — before / after

1. Regression reproduced (BEFORE) — production source reverted to main, new tests kept

FAIL  orca-runtime.test.ts > reads file explorer paths for a 'canonical folder workspace selector'
FAIL  orca-runtime.test.ts > reads file explorer paths for a 'id-prefixed folder workspace selector'
FAIL  orca-runtime.test.ts > routes SSH folder workspace file explorer paths through the filesystem provider
AssertionError: promise rejected "Error: selector_not_found" instead of resolving

Caused by: Error: selector_not_found
 ❯ OrcaRuntimeService.resolveWorktreeSelector        src/main/runtime/orca-runtime.ts:16151:11
 ❯ RuntimeFileCommands.resolveFileExplorerPath       src/main/runtime/orca-runtime-files.ts:947:22
 ❯ RuntimeFileCommands.readFileExplorerDir           src/main/runtime/orca-runtime-files.ts:371:20

 Tests  3 failed | 486 skipped (489)

This is the exact user-visible failure: the file explorer dir/preview call rejects with selector_not_found.

2. Fixed (AFTER) — unit tests

$ vitest run --config config/vitest.config.ts \
    src/main/runtime/orca-runtime-files.test.ts \
    src/main/runtime/orca-runtime-files-watch.test.ts \
    src/main/runtime/orca-runtime.test.ts
 Test Files  3 passed (3)
      Tests  518 passed (518)

$ vitest run --config config/vitest.config.ts src/main/runtime/rpc/methods/files.test.ts
 Test Files  1 passed (1)
      Tests  37 passed (37)

3. End-to-end in a dev Electron build (real runtime RPC stack)

Launched the dev app (nwparker/fix-6357, worktree /private/tmp/orca-bb/6357), created a real project group + folder workspace over a container folder with two independent git repos (repoA, repoB), then drove the actual file-explorer RPC the renderer uses (window.api.runtime.call → files.readDir / files.readPreview / files.search / files.listMarkdownDocuments / files.list):

// files.readDir  worktree="folder:<id>"  relativePath=""
{ "ok": true, "result": [ { "name": "repoA", "isDirectory": true }, { "name": "repoB", "isDirectory": true } ] }

// files.readDir  relativePath="repoA"
{ "ok": true, "result": [ { "name": ".git" }, { "name": "src" }, { "name": "README.md" } ] }

// files.readPreview  relativePath="repoA/README.md"
{ "ok": true, "result": { "content": "# Repo A\n\nDemo readme for repoA\n", "isBinary": false } }

// files.search  query="export const"  -> cross-repo matches
{ "ok": true, "result": { "files": [
    { "relativePath": "repoB/src/b.ts", "matches": [ { "lineContent": "export const b = 2" } ] },
    { "relativePath": "repoA/src/a.ts", "matches": [ { "lineContent": "export const a = 1" } ] }
  ], "totalMatches": 2 } }

// files.listMarkdownDocuments  -> [ "repoA/README.md" ]
// files.list (mobile quick-open)  -> ok, rootPath = "/tmp/orca-bb/group-demo"

Negative check (no over-broad acceptance): a nonexistent folder selector still correctly rejects —

// files.readDir  worktree="folder:does-not-exist-xyz"
{ "ok": false, "error": { "code": "selector_not_found", "message": "selector_not_found" } }

Gates

  • oxlint on the 5 changed files — clean (exit 0)
  • tsgo --noEmit -p config/tsconfig.node.json — clean (exit 0)
  • oxfmt --write — no changes (already formatted)

@nwparker
nwparker merged commit 396f9c3 into main Jun 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant