Skip to content

feat(firefox): port upload_file tool with downloadId and user picker …#350

Merged
esokullu merged 4 commits into
webbrain-one:mainfrom
Elijah-hash7:feat/firefox-upload-file
Jul 13, 2026
Merged

feat(firefox): port upload_file tool with downloadId and user picker …#350
esokullu merged 4 commits into
webbrain-one:mainfrom
Elijah-hash7:feat/firefox-upload-file

Conversation

@Elijah-hash7

Copy link
Copy Markdown
Contributor

Implements upload_file for Firefox, closing #293.
Firefox can't replicate Chrome's CDP-based DOM.setFileInputFiles for arbitrary local paths, but two practical flows are now supported:
Flow 1 β€” downloadId re-fetch: Looks up an already-downloaded file via browser.downloads.search, re-fetches the bytes (same eTLD+1 cookie policy as readDownloadedFile), converts to base64, reconstructs a File object via DataTransfer in the page context, and dispatches bubbling input + change events.
Flow 2 β€” User file picker: When no downloadId is provided, emits an upload_picker request to the sidepanel, which opens a hidden , reads the selected file as base64 via FileReader, and routes it back through background.js to the agent.
Not supported (documented): filePath uploads β€” Firefox extensions have no general filesystem read access and no CDP equivalent.
Other changes:

Added Capability.UPLOAD permission gate
25MB file size cap enforced on both flows
749 tests passing

Closes #293

@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

@Elijah-hash7 is attempting to deploy a commit to the esokullu's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI 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.

Pull request overview

Ports upload_file to Firefox using download re-fetching or a user file picker.

Changes:

  • Adds Firefox upload execution, permissions, and tool exposure.
  • Adds sidepanel picker and background response routing.
  • Updates tests and changelog.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/firefox/src/agent/agent.js Implements both upload flows.
src/firefox/src/agent/tools.js Defines and exposes the tool.
src/firefox/src/agent/permission-gate.js Adds upload permissions.
src/firefox/src/background.js Routes picker responses.
src/firefox/src/ui/sidepanel.js Implements picker UI.
src/firefox/src/ui/sidepanel.html Adds hidden file input.
test/run.js Updates exposure and permission assertions.
CHANGELOG.md Documents Firefox support.

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/firefox/src/ui/sidepanel.js Outdated
Comment thread src/firefox/src/ui/sidepanel.js
Comment thread src/firefox/src/ui/sidepanel.js
Comment thread src/firefox/src/agent/agent.js Outdated
Comment thread src/firefox/src/agent/agent.js Outdated
Comment thread src/firefox/src/agent/agent.js
Comment thread src/firefox/src/ui/sidepanel.js Outdated
@esokullu

Copy link
Copy Markdown
Collaborator

@Elijah-hash7 thank you. Pls confirm these are all addressed

@Elijah-hash7

Copy link
Copy Markdown
Contributor Author

Fixed all 8 Copilot review comments redirect now uses manual hop validation with eTLD+1 boundary checks, file size checked before reading, FileReader.onerror handled, XSS fixed with textContent, all strings localized across 15 locales,

@esokullu

Copy link
Copy Markdown
Collaborator

ok i'm taking over from hre, thanks!

@Elijah-hash7 Elijah-hash7 force-pushed the feat/firefox-upload-file branch from e93882e to bc88f91 Compare July 13, 2026 01:28
Enforce the size limit while reading the response body so a missing or
lying Content-Length cannot buffer an unbounded download. Update Firefox
architecture notes and add a regression test for the streaming path.
@esokullu

Copy link
Copy Markdown
Collaborator

Copilot review + merge status

Verified against the latest commits (bc88f91a + b1c7b28c):

# Copilot finding Status
1 XSS via file.name in innerHTML Fixed β€” status uses textContent + t(...)
2 Check file.size before FileReader Fixed β€” 25MB guard before read
3 FileReader.onerror never resolves picker Fixed β€” onerror/onabort cancel responses
4 Redirect follow without hop validation Fixed β€” redirect: 'manual', per-hop validateFetchUrl, drop cookies across eTLD+1
5 Size limit only after full arrayBuffer() Fixed in b1c7b28c β€” stream with hard 25MB cap + Content-Length pre-check
6 No handler execution tests Fixed β€” downloadId/redirect/DataTransfer, picker cancel, Content-Length, streaming size tests
7 Unlocalized upload picker UI Fixed β€” sp.upload_picker.* keys + t(...) across locales

Merge conflicts with main were already cleared by the contributor rebase; PR is MERGEABLE / CLEAN. Tests: 764 passed.

Reject non-complete downloads, wrap re-fetch/inject in try/catch, validate
picker base64 and size, require input[type=file], and make the sidepanel
picker one-shot with a per-card file input. Update site adapters and
scratchpad guidance for Firefox upload_file, translate picker strings, and
extend regression tests.
@esokullu esokullu merged commit 59c5a45 into webbrain-one:main Jul 13, 2026
1 check failed
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.

feat(firefox): port upload_file tool from Chrome

3 participants