Skip to content

fix(browser): let pages use files picked, saved or dropped through File System Access - #32970

Merged
AmoabaKelvin merged 2 commits into
mainfrom
browser-file-system-access
Oct 24, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
browser-file-system-access

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​82 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​82
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46

ELI5

Web apps that open a folder or save a file through the browser's File System Access API (showDirectoryPicker(), showOpenFilePicker(), showSaveFilePicker(), dragging a file onto the page) didn't work in Orca's browser. The dialog opened, but Orca refused the page access to whatever you picked. Now the file or folder you choose works, like in Chrome.

What Changed

  • Before: showDirectoryPicker() opened the folder dialog, then rejected with AbortError: The user aborted a request. Files from showOpenFilePicker()/showSaveFilePicker() were unusable. A dropped file's getAsFileSystemHandle() handle reported read=denied and getFile() threw NotAllowedError. Dropping or picking a blocked system folder (home, ~/Library) left the promise pending forever.
  • After: picked, saved and dropped files and folders can be read, and written where the API allows. A blocked system folder fails straight away with AbortError, and the browser pane shows Orca's existing notice: "… asked for access to your files or folders, and Orca denied it."

How it works: Electron doesn't use Chromium's own File System Access grants once an app installs a permission check handler. Every grant's status comes from that handler (PermissionGrantImpl::GetStatus() in Electron's file_system_access_permission_context.cc). Orca's browser session policy said no to fileSystem, so every handle was refused, including the ones Chromium grants itself for open, save and drop. The browser session policy (browser-session-partition-policies.ts) now grants fileSystem. It also answers Electron's file-system-access-restricted event with deny, because a request with no listener never finishes.

Why

The policy is the only layer that decides this, and Electron gives it a single yes or no for each grant, so the fix is there.

Design

  • Chosen: grant fileSystem in both the request and check handlers on browsing partitions. Picking or dropping is the user's consent. Chromium still blocks pickers in cross-origin iframes, requires a user gesture to open a picker, and applies its blocklist of system folders.
  • Routed pages stay denied (fileSystemAccess: false from installBrowserRoutePartitionPolicies). Those are SSH-routed tabs and client-hosted pages of a paired runtime. Another machine can script them: an SSH host can run browser.eval. A page there could reuse a handle saved in IndexedDB to read or write files on this desktop. This follows the existing rule that stops SSH-driven pages from downloading into this desktop.
  • Blocked system folders get deny and the existing denial notice. Doc-preview partitions get a silent deny, so a drop on a preview can't hang.
  • Ruled out:
    • A Chrome-style "Let this site edit files?" prompt. Once a check handler is installed, GetStatus() only returns granted or denied, never "ask". So requestPermission() and createWritable() never reach the request handler. A save-picker write grant also looks the same as one for an opened file. Denying writes would break showSaveFilePicker().
    • tryAgain for blocked folders. Electron reopens the picker with no explanation, and it means nothing for drops.
    • A Page.fileChooserOpened → dialog.showOpenDialog bridge, as [Bug]: Embedded browser file inputs never open a native file picker (ChatGPT / any site) #15621 suggested. It isn't needed, see below.

Open questions for Kelvin

  • Writes need no prompt. A page you gave a file to through the open picker or a drop can write to it, and handles a site stores keep their access across restarts. Chrome would ask first, but Electron's API leaves no way to ask without breaking save, so I went with Electron's own default. OK?
  • On routed pages a save pick over an existing file still empties it before the write is refused. That's Chromium's order of operations, and it happens on every partition today. This PR limits it to routed pages. Opening and dropping on routed pages fails without the notice, because the check handler doesn't get a WebContents. Fine as a known limit?

Linked Issue

Fixes #25750

#15621 (<input type=file> never opens a dialog) doesn't reproduce on current main. In a hidden dev build, a real CDP click on <input type=file> opened the native macOS open panel; I saw its window appear and the input fired neither change nor cancel while it was open. The issue blamed the debugger that the old anti-detection script attached to every guest, and #18749 removed that script. Nothing here changes it, so I left it unlinked. It can be closed.

Visual Proof

Drag and drop, recorded in a hidden dev build. Each video drops a file, then a folder, then ~/Library. A native picker dialog can't be recorded without showing a window on my desktop. The pickers go through the same grant check as drops (see Testing).

Light: before

before-drop-light.mp4

Light: after

after-drop-light.mp4

Dark: before

before-drop-dark.mp4

Dark: after

after-drop-dark.mp4
Before After
before-drop-light.png after-drop-light.png

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

On macOS, in a hidden dev build, with a local test page and real CDP input:

  • <input type=file> and showDirectoryPicker(): on main the native panel opens (checked for single and the directory picker; multiple, accept= and webkitdirectory take the same chooser path). This PR doesn't touch how the dialog opens, only what the page may do with the pick.
  • Drops: a file's handle reads its contents and a folder's handle lists its entries. Before the fix both were NotAllowedError.
  • Dropping home or ~/Library now ends in an immediate AbortError plus the notice. Before, it was pending forever.

I couldn't run a full pick through the native panel. It opens as a sheet, and the sheet brings the hidden window onto the screen even after app.hide(). The pickers use the same GetStatus() check as drops, so the drop results cover them. A quick manual check would still help: on a visible build, click showDirectoryPicker() and showSaveFilePicker() on any FSA demo page.

Two tests in browser-session-partition-policies.test.ts. One checks that browsing partitions grant fileSystem and route partitions (through the real route installer) deny it with a notice. The other checks that blocked folders get deny, with a notice on browsing partitions and none on doc previews. Both fail with main's policy, and removing the route option fails the first.

Locally: pnpm tc:node, check:code-quality:changed, check:react-doctor:changed, and the focused tests. Full CI only runs once this leaves draft.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Platforms: the policy is the same on macOS, Linux and Windows. Electron's blocklist is per-platform.
  • Remote: routed tabs (SSH and client-hosted paired pages) are left as they were, see Design. Server-streamed pages run in a hidden window on the server, so a picker there would open on the server. That was already true for <input type=file> and is out of scope.
  • Mobile: the mobile browser shows server-streamed pages, so it can't pick phone files at all. Parity would need the server to catch the chooser (Page.fileChooserOpened) and the phone to upload what the user picks. That's a separate feature.
  • Compatibility: main process only. No IPC, saved-state or protocol changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@AmoabaKelvin
AmoabaKelvin marked this pull request as ready for review October 24, 2026 02:37
…Access

Electron reads every File System Access grant from the session's check handler,
which denied fileSystem, so picked, saved and dropped handles were all refused.
Routed pages stay denied: another machine can script them.

Fixes #25750
@AmoabaKelvin
AmoabaKelvin force-pushed the browser-file-system-access branch from 69dd768 to 9d8a927 Compare October 24, 2026 02:40
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46237615-3986-4219-87e7-4497b7460b01
Commits

Reviewing files that changed from the base of the PR and between 117e186 and 9d8a927.

Files selected for processing: 3
  • src/main/browser/browser-session-partition-policies.test.ts
  • src/main/browser/browser-session-partition-policies.ts
  • src/main/browser/browser-session-route-policies.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

Browsing partitions now auto-grant the fileSystem permission by default. Routed partitions disable that grant. Restricted File System Access requests are denied; the policy either reports the denial to the browser manager or denies it without a notice, based on the partition policy. Tests cover permission decisions and restricted-access callbacks.

Estimated code review effort

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 9d8a9

Browsing pages can use File System Access while routed pages remain denied. No merge-blocking issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: enabling pages to use files selected, saved, or dropped through the File System Access API.
Description check Passed The description is complete and relevant. It explains the user impact, implementation, rationale, security boundaries, linked issue, visual proof, testing, platform considerations, and known limitatio…
Linked Issues check Passed Directly linked issue #25750 asks that File System Access pickers work in the embedded browser and that the follow-on fileSystem permission be granted, as in Chrome.

Code at head (src/main/browser/br…
Out of Scope Changes check Passed All changed files relate to File System Access permission handling, which the linked issue #25750 covers:
- browser-session-partition-policies.ts: fileSystem auto-grant (in request and check handlers)…
Full details: Description check

Explanation

The description is complete and relevant. It explains the user impact, implementation, rationale, security boundaries, linked issue, visual proof, testing, platform considerations, and known limitations.

Full details: Linked Issues check

Explanation

Directly linked issue #25750 asks that File System Access pickers work in the embedded browser and that the follow-on fileSystem permission be granted, as in Chrome.

Code at head (src/main/browser/browser-session-partition-policies.ts):

  • A new helper isAutoGranted(permission) adds fileSystem when options.fileSystemAccess !== false. It is used in both the permission request handler and the permission check handler on browsing partitions. The fileSystem grant requirement is implemented in both handlers.
  • A file-system-access-restricted listener denies blocklisted system folders at once. Without it, the page waits forever. This matches the issue's need for picks to complete.
  • Doc-preview partitions (permissions === 'deny') use a silent deny listener.

Routed partitions: installBrowserRoutePartitionPolicies (src/main/browser/browser-session-route-policies.ts) passes fileSystemAccess: false. This is a deliberate restriction, and the PR explains it.

Tests (browser-session-partition-policies.test.ts): one test checks that browsing partitions grant fileSystem in request and check handlers, and that the routed partition denies it with a notice. A second test checks that blocklisted folders get deny, with a notice on browsing partitions and none on doc previews.

Native picker: the diff does not change how the dialog opens. The PR author reports a manual check on main where showDirectoryPicker() opened the native folder dialog. I could not verify this from the repository. The full native pick was not exercised. The picker-opening part of the issue therefore rests on the author's manual evidence. The coded grant requirement is met.

Full details: Out of Scope Changes check

Explanation

All changed files relate to File System Access permission handling, which the linked issue #25750 covers:

  • browser-session-partition-policies.ts: fileSystem auto-grant (in request and check handlers), the fileSystemAccess option, and the file-system-access-restricted listener. The listener denies blocklisted folders so pages do not hang, and it adds the existing permission-denied notice. Both parts are tied to the grant and pick behavior.
  • browser-session-route-policies.ts: passes fileSystemAccess: false for routed partitions. This is a scope-limiting setting for the same permission. It does not add unrelated behavior.
  • browser-session-partition-policies.test.ts: tests for the two behaviors above.

No change touches IPC, saved state, protocols, or unrelated browser features. The drop-related and blocked-folder behavior is part of the File System Access permission path that the PR describes as its scope. It is not an unrelated change.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@AmoabaKelvin
AmoabaKelvin merged commit f01eaa0 into main Oct 24, 2026
33 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the browser-file-system-access branch October 24, 2026 04:44
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.

[Bug]: showDirectoryPicker() rejects instantly with AbortError in the embedded browser (no folder dialog)

1 participant