Skip to content

Fix remote File Explorer opening files via local fs:readFile#6506

Open
utkarshparekh wants to merge 2 commits into
stablyai:mainfrom
utkarshparekh:fix/file-explorer-runtime-open
Open

Fix remote File Explorer opening files via local fs:readFile#6506
utkarshparekh wants to merge 2 commits into
stablyai:mainfrom
utkarshparekh:fix/file-explorer-runtime-open

Conversation

@utkarshparekh

@utkarshparekh utkarshparekh commented Jun 27, 2026

Copy link
Copy Markdown

Pass the worktree runtime owner when opening files from File Explorer so editor tabs use runtime RPC instead of falling back to local file reads.

Fixes #6440

Summary

When opening a file from a paired remote runtime's File Explorer, the editor tab was created without runtimeEnvironmentId. Reads then fell back to local fs:readFile, which failed with "Access denied: path resolves outside allowed directories." Retry hit the same path.

This change passes the worktree's runtime owner when opening files from File Explorer (click and inline create), matching existing patterns in drag-and-drop and mobile file open. Editor tabs now route through runtime file RPC, and Retry uses the same owner.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — targeted tests for changed files pass (useFileExplorerHandlers.test.ts, file-explorer-drag-scroll-marker.test.tsx, 9 tests). Full suite not re-run locally on Node 26.
  • pnpm build — not run locally yet; CI will verify.
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Manual repro (from #6440):

  1. Pair a remote runtime into the desktop app.
  2. Select a runtime worktree and open File Explorer.
  3. Click a file (e.g. large.bin or README.md).
  4. Expected: Editor loads via runtime RPC (or a runtime-aware error for unsupported files).
  5. Before fix: Unable to load file with local fs:readFile access denied; Retry repeated the failure.

AI Review Report

Reviewed with Cursor agent against CONTRIBUTING.md and AGENTS.md.

Risks checked:

  • Cross-platform (macOS / Linux / Windows): Change is renderer-only TypeScript in File Explorer open paths. No keyboard shortcuts, menu accelerators, shell spawning, or path-separator assumptions added. Behavior is platform-neutral.
  • SSH / remote / local: Fix is specifically for remote-runtime-owned worktrees. Local worktrees pass runtimeEnvironmentId: null with suppressActiveRuntimeFallback: true, preserving explicit local reads.
  • Agent / integration compatibility: No agent or git-provider logic touched.
  • Performance: One extra argument on existing openFile calls; no new watchers or polling.
  • UI quality: No layout, color, or interaction changes.

Flags / verification:

Security Audit

Reviewed areas:

  • Path handling: No new path construction; uses existing File Explorer node paths and worktree-relative paths already shown in the tree.
  • IPC / auth: Fix routes reads through existing runtime file RPC when runtimeEnvironmentId is set, instead of incorrectly hitting local fs:readFile. Reduces risk of confusing cross-boundary reads rather than expanding access.
  • Command execution / secrets: Not touched.
  • Dependencies: None added.

Follow-up: None identified for this change.

Notes

Pass the worktree runtime owner when opening files from File Explorer so
editor tabs use runtime RPC instead of falling back to local file reads.

Fixes stablyai#6440
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

runtimeEnvironmentId is threaded through file explorer handling. useFileExplorerHandlers and activateFileExplorerNode now accept and forward it into openFile, with suppressActiveRuntimeFallback set when the value is null. FileExplorer passes activeRuntimeEnvironmentId into the hook, and useFileExplorerInlineInput derives and forwards a runtime environment id for newly created files. Tests were updated for the new argument flow and null handling.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preserving runtime-aware file opening in File Explorer.
Linked Issues check ✅ Passed The code updates File Explorer open paths to carry runtimeEnvironmentId and cover the retry/fallback behavior from #6440.
Out of Scope Changes check ✅ Passed The changes stay focused on File Explorer runtime-owner propagation and related tests, with no obvious unrelated edits.
Description check ✅ Passed The description follows the template and includes all required sections with clear testing, AI review, security, and notes.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3520dbb7-25e5-43b1-b1fa-3f64bd854010

📥 Commits

Reviewing files that changed from the base of the PR and between 867c57b and f5dee4a.

📒 Files selected for processing (5)
  • src/renderer/src/components/right-sidebar/FileExplorer.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-drag-scroll-marker.test.tsx
  • src/renderer/src/components/right-sidebar/useFileExplorerHandlers.test.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerHandlers.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerInlineInput.ts

Document the suppressActiveRuntimeFallback contract and treat blank
runtime IDs as no owner when opening newly created explorer files.
@utkarshparekh utkarshparekh force-pushed the fix/file-explorer-runtime-open branch from 1740e86 to 801d951 Compare June 27, 2026 17:03
@utkarshparekh

Copy link
Copy Markdown
Author

ready for review

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.

Remote runtime File Explorer open/retry can fall back to local fs:readFile

1 participant