Repository navigation
Fix remote File Explorer opening files via local fs:readFile (#6440) - #6562
Conversation
File Explorer row activation and inline file creation opened editor tabs without a runtimeEnvironmentId. In store.openFile, an absent owner falls back to the ambient settings.activeRuntimeEnvironmentId, so a tab for a remote-runtime-owned worktree could be created with no/incorrect owner. The editor read path then routed through local fs:readFile and failed with "Access denied: path resolves outside allowed directories"; Retry reloaded the same tab and repeated the identical local read. Pass the worktree-owned runtime owner (getRuntimeEnvironmentIdForWorktree) when opening from File Explorer, mirroring the existing useGlobalFileDrop and mobile file-open patterns. Explicit local opens pass suppressActiveRuntimeFallback so they are not retargeted to a focused runtime. This fixes both the initial load and Retry. Supersedes community PR #6506. Fixes #6440 Co-authored-by: Utkarsh Parekh <145644114+utkarshparekh@users.noreply.github.com>
|
Warning Review limit reached
More reviews will be available in 15 minutes and 25 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 |
Verification evidenceUnit tests (vitest)
Regression coverage for the read path:
The new
Lint / typecheck
Store-level CDP proof of the fix contractA full UI repro needs a paired remote runtime ( Before the fix, File Explorer opens behaved like caseC: a remote-worktree file tab could be created with the wrong/ambient owner (or none), so the read fell back to local |
…i#6440) (stablyai#6562) Co-authored-by: Utkarsh Parekh <145644114+utkarshparekh@users.noreply.github.com>
🧑🤝🧑 Impact & ELI5
1) What's broken today (ELI5). If you connect Orca to a remote machine (a "paired runtime" — for example a server you SSH into) and then click a file in that remote project's File Explorer, the editor often just shows "Unable to load file." Clicking "Retry" does nothing — it keeps failing the same way. Orca is mistakenly trying to read the file from your own laptop's disk instead of from the remote machine where the file actually lives, so it hits a permission wall ("Access denied: path resolves outside allowed directories"). This affects people working against remote/headless runtimes; it doesn't hit purely-local users. For those who do use remote runtimes, it's a hard blocker on a basic action — opening a file to look at it.
2) What this PR does (ELI5). Think of every open file as a package that needs a "return address" saying which machine it came from. The File Explorer was sending files off with the address left blank, so Orca guessed — and often guessed "the laptop," which was wrong for remote files. This PR makes the File Explorer write the correct return address (the remote runtime that owns the file) right on the package when you click it. Now the editor knows to fetch the file over the remote connection instead of the local disk. For files that really are local, it stamps an explicit "this one is genuinely local" flag so Orca won't accidentally re-route it to whatever remote machine happens to be focused. Oh, so it now reads remote files from the remote machine instead of silently looking on your laptop and failing.
3) Tradeoffs / regressions — honest answer. No regressions — nothing is disabled, no new setup, no behavior is lost. The change is one extra piece of information ("which machine owns this file") passed along an existing call; no GPU flag, fast path, or feature is turned off, and there are no new network calls, watchers, or polling. There is one subtle behavior correction worth naming honestly: for a local worktree, the old code would fall back to "whatever runtime is currently focused" when the owner was blank, which could route a local file's read to a focused remote runtime. This PR now marks local opens as explicitly local so they stay local. That is strictly the intended behavior (the old fallback was the bug), and it mirrors the already-shipped drag-and-drop and mobile file-open paths, so it's consistent rather than a new special case. Net: remote-runtime users gain a working file open/retry; local users are unaffected.
Summary
Fixes #6440.
Opening a file from the File Explorer of a remote-runtime-owned worktree created the editor tab without a
runtimeEnvironmentId. Instore.openFile, an absent owner falls back to the ambientsettings.activeRuntimeEnvironmentId, which is fragile: a tab for a remote worktree could be created with no/incorrect owner. The editor read path (useEditorPanelContentState->settingsForRuntimeOwner->readRuntimeFileContent) then routed through localfs:readFileand failed withAccess denied: path resolves outside allowed directories. Retry reloaded the same tab and repeated the identical local read.This change passes the worktree-owned runtime owner (
getRuntimeEnvironmentIdForWorktree) when opening files from File Explorer (row click/keyboard activation and inline file creation), mirroring the existinguseGlobalFileDropand mobile file-open patterns. Explicit local opens passsuppressActiveRuntimeFallback: trueso they stay local and are not retargeted to a focused runtime. Editor tabs now route through runtime file RPC, and Retry reuses the same owner.This PR supersedes community PR #6506 (the original author is credited via
Co-authored-by). #6506 is left open for the maintainers to close.Screenshots
No visual change. This is a renderer-only logic fix to file-open owner routing.
Testing
pnpm lint(oxlint on changed files — clean)pnpm typecheck(tsgo -p config/tsconfig.tc.web.json— exit 0)pnpm test— targeted suites pass:useFileExplorerHandlers.test.ts,file-explorer-drag-scroll-marker.test.tsx(9 tests), pluseditor.test.ts+useEditorPanelContentState.test.tsx(166 tests) as regression coverage for the read pathpnpm build— not run locally; CI will verifyuseFileExplorerHandlerscase asserts a local file open emitsruntimeEnvironmentId: undefinedwithsuppressActiveRuntimeFallback: true; the symlink case now asserts the owner is stamped andsuppressActiveRuntimeFallback: falseElectron verification: A full UI repro requires pairing a real remote/headless runtime (
orca://pair), which was infeasible in this environment (no runtime environments present; all repos arelocal). Instead I verified the exactstore.openFileowner-stamping contract over CDP against the running app, proving the three cases the fix depends on (see PR comment for output): a stamped remote owner is preserved on the tab; an explicit local open withsuppressActiveRuntimeFallbackstays local; and the old no-owner path inherits the ambient focused runtime (the buggy behavior this fix avoids).AI Review Report
Reviewed adversarially as an adopted community contribution (assumed the original author could be malicious) and against
AGENTS.md.runtimeEnvironmentId: nullwithsuppressActiveRuntimeFallback: true, preserving explicit local reads and avoiding retarget to a merely focused runtime.openFilecalls; no new watchers, polling, or IPC.useGlobalFileDropruntime-owner propagation pattern (runtimeEnvironmentId ?? undefined+suppressActiveRuntimeFallback: runtimeEnvironmentId === null).Security Audit
fullPath. No path-traversal surface introduced.fs:readFile. This narrows cross-boundary reads rather than widening access.eval, no shell, no secret access, no network. TheruntimeEnvironmentIdoriginates from trusted store-derived owner functions, not user input.No follow-up security work identified.
Notes
src/renderer/src/lib/search-match-open.ts) likely has the same class of missing-owner bug and can be fixed in a separate issue/PR.Made with Orca 🐋