Repository navigation
fix(browser): orca download saves new-tab and popup-page downloads to --path - #36397
Conversation
|
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 1

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:
59579d95-bd15-4d05-af12-f2a27ce6f806
Files selected for processing: 5-
src/main/browser/browser-manager-download-creation.tssrc/main/browser/browser-manager-guest-popup-policy.tssrc/main/browser/browser-manager-popup-child.test.tssrc/main/browser/browser-manager-popup-openerless-tab.test.tssrc/main/browser/browser-manager-state.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
-
…--path A new-tab link opened while an agent download claim is armed is downloaded on the claiming page, so the file lands at --path instead of ~/Downloads and no empty tab is left behind.
A claim made through --page popup-N was stored under the popup's id while will-download looks it up under the opener tab's, so the file went to ~/Downloads.
A tab and its popups share one claim, so a second concurrent orca download would take the first one's file.
… agent download A sibling popup's new-tab link no longer takes the tab's claim; it opens as a tab as before.
b531e8b to
1b1b82b
Compare
ELI5
When an agent asked Orca to download a file from a link that opens in a new tab, the file went to your Downloads folder, an empty tab was left open, and the agent was told nothing downloaded. Now the file goes where the agent asked, and no tab opens.
What Changed
Before:
orca download --selector <link> --path /out/report.csvon atarget="_blank"attachment link (or a button that callswindow.openon one) opened a new, empty Orca tab, saved the file to ~/Downloads, and failed after 10 s with "did not start a download".After: the command returns
{ "path": "/out/report.csv" }in under a second, the file is at that path, ~/Downloads is untouched, and no tab is opened.Mechanism:
orca downloadclaims the next download from the page it clicks (claimNextDownload), andwill-downloadlooks the claim up by the page's tab. A new-tab link is handed to the renderer, which makes a brand-new tab with no link back to the page, so its download never found the claim.downloadURLon that page instead of opening the tab, so the download starts on the page that holds the claim. New-tab links from other popups of the same tab still open as tabs.--page popup-N(popups became agent pages in feat(browser): let agents drive sign-in and payment popups as pages #36253) used to sit under the popup's own id, whilewill-downloadlooked it up under the opener tab, so those downloads also went to ~/Downloads.orca downloadon the same tab while one is waiting fails withbrowser_download_busy. Without this check it would take the first command's file.Why
The claim has to reach the download. There were two ways to do that:
The second way is a few lines in main and leaves no stray tab. User clicks never have a claim, so they behave exactly as before. The popup security rules are unchanged: the download branch runs only after the same gesture and budget check that would have allowed the tab.
One behaviour to know about:
orca downloadon a_blanklink to an ordinary web page now saves that page to--path, like "Save link as". Before, it opened a tab and failed.Linked Issue
Fixes #36392
Follow-up from the third point of #20373 and from #36240.
Visual Proof
N/A: nothing in the UI changes for users. Agent-side before and after, from a hidden dev build against a local page with a
target="_blank"link to aContent-Disposition: attachmentCSV:Before (main at dd7496b):
After (this branch):
Testing
On macOS, with a hidden dev build (
ORCA_BACKGROUND_LAUNCH=1, own profile and CDP port) driven by the dev CLI:Reproduced the bug on main: the command failed after 10 s, the file landed in ~/Downloads, and an empty tab was left behind.
On this branch, the
_blanklink, thewindow.openbutton and the same-tab link all saved to--pathand returned it, with ~/Downloads unchanged and no new tab. I ran this again after the last change to the rule.With no download pending,
orca clickon the same_blankattachment link and on a_blankpage link still opened new tabs and downloaded to ~/Downloads, as before.New tests:
browser-manager-popup-openerless-tab.test.ts: a new-tab link with a claim armed becomesdownloadURL, and opens a tab again once the claim is released.browser-manager-popup-child.test.ts: a claim made on a popup page saves to its path, and a second claim on the same tab is refused.Ran the focused popup and download suites and the changed-file checks. Typecheck and the full suite are left to CI.
Not tested live: a claim on a native popup page. On a hidden build a native popup window would show on screen, so the unit test covers that case.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Reviewed with Codex and Claude over two rounds:
_blankclick there during a pending agent download now does nothing, where before it opened a tab. The agent gets the same "did not start" error as before.Agent skill upstream boundary
Notes
file:from a local page.downloadURLuses the clicking page's own session.browser_download_busyis a new error code over the existing error path.Waiting for blessing (judgment call:
orca downloadon a_blanklink to an ordinary page now saves the page instead of failing). To try, from a dev build of/Users/kelvinamoaba/orca/workspaces/orca/browser-download-blank-followup:<a href="/file.csv" target="_blank">that servesContent-Disposition: attachment, then runorca snapshot.orca download --selector <ref> --path /tmp/x.csv: it returns the path at once, the file is at/tmp/x.csv, ~/Downloads is unchanged and no tab opens.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)