Repository navigation
Fix browser showOpenFilePicker support - #4122
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Greptile SummaryThis PR restores
Confidence Score: 5/5Safe to merge. The shim is narrowly scoped to main-frame pages, guards against double-installation, and the three settlement paths are mutually exclusive thanks to the settled flag. The JavaScript bridge is logically sound, the single-settle invariant holds across all three settlement paths (change / cancel / focus-return), and the new tests exercise the non-obvious dismissal flows correctly using callAsyncJavaScript. No files require special attention. BrowserPanel.swift continues to grow, but the addition here is self-contained. Important Files Changed
Sequence DiagramsequenceDiagram
participant Page as "Web Page JS"
participant Bridge as "BrowserFileSystemAccessBridge"
participant Input as "hidden input[type=file]"
participant OS as "OS File Picker"
participant Win as "window focus"
Page->>Bridge: "showOpenFilePicker(options)"
Bridge->>Input: "createElement + configure"
Bridge->>Input: "addEventListener(change, cancel)"
Bridge->>Win: "addEventListener(focus)"
Bridge->>Input: "appendChild + click()"
Input->>OS: "open native picker"
alt "User selects file(s)"
OS-->>Input: "change event"
Input->>Bridge: "handleChange()"
Bridge-->>Page: "resolve [FileSystemFileHandle...]"
else "User dismisses (cancel event)"
OS-->>Input: "cancel event"
Input->>Bridge: "handleCancel()"
Bridge-->>Page: "reject AbortError"
else "Window regains focus (fallback)"
OS-->>Win: "focus event"
Win->>Bridge: "handleWindowFocus()"
Bridge->>Bridge: "setTimeout(0) — defer one turn"
alt "change already settled"
Bridge->>Bridge: "settled=true, no-op"
else "no files — true dismissal"
Bridge-->>Page: "reject AbortError"
end
end
Bridge->>Input: "cleanup: remove listeners + DOM node"
Reviews (4): Last reviewed commit: "fix: avoid element-focus file picker dis..." | Re-trigger Greptile |
|
Greptile note checked: cmux targets macOS 14.0 or later ( |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit dde0ebf. Configure here.
|
Greptile's latest pass reports this is safe to merge and that no files require special attention. I verified the remaining note is housekeeping around file placement; I'm leaving the bridge in BrowserPanel for this PR so the functional fix and regression coverage stay stable, and the extraction can be handled separately if we want that cleanup. |

Summary
window.showOpenFilePickeris installed in WKWebView pagesshowOpenFilePicker()with WebKit's native file-input picker and lightweight file handle objects so selected files exposegetFile()Fixes #4050.
Testing
Note
Medium Risk
Injects new JavaScript into every main-frame page load and changes file-picker behavior in the embedded browser, which could impact site compatibility or event-handling edge cases despite being scoped to a shim.
Overview
Restores
window.showOpenFilePicker()support in the browserWKWebViewby injecting a newBrowserFileSystemAccessBridgeuser script at document start (main frame only).The bridge implements a minimal File System Access API shim backed by a hidden
<input type="file">, returning lightweightFileSystemFileHandle-like objects withgetFile()and ensuring the picker promise settles once (including anAbortErrordismissal path with focus-return fallback) while cleaning up DOM inputs.Adds regression tests to verify the API is installed in loaded pages and that the picker rejects/cleans up correctly when focus returns without a native cancel event.
Reviewed by Cursor Bugbot for commit 82f05ca. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Restore
window.showOpenFilePickerinWKWebViewby injecting a minimal File System Access bridge that uses the native file input picker. Ensures the promise settles once, avoids element-focus false cancels, and cleans up; fixes #4050.BrowserFileSystemAccessBridgeviaWKUserScriptat document start (main frame) soshowOpenFilePicker()is available on all pages.multipleandtypes.accept, returns lightweightFileSystemFileHandlewithgetFile(), and uses a window-focus fallback to resolve or reject withAbortErroron dismissal; ignores element-focus events.AbortError, no rejection on element focus, and cleanup of hidden inputs.Written for commit 82f05ca. Summary will update on new commits.