Skip to content

fix(browser): orca download saves new-tab and popup-page downloads to --path - #36397

Merged
AmoabaKelvin merged 6 commits into
mainfrom
agent-blank-download-downloads
Oct 30, 2026
Merged

AmoabaKelvin merged 6 commits into
mainfrom
agent-blank-download-downloads

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​102 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​84
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31

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.csv on a target="_blank" attachment link (or a button that calls window.open on 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:

  • Since fix(browser): save agent downloads to the requested --path and fail fast when none starts #36240, orca download claims the next download from the page it clicks (claimNextDownload), and will-download looks 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.
  • The popup policy now checks for an armed claim after its existing user-gesture and page-opened-tab budget check. If the claim belongs to the page opening the link, it calls downloadURL on 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.
  • Claims are now stored under the tab, not the exact page. A claim made with --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, while will-download looked it up under the opener tab, so those downloads also went to ~/Downloads.
  • A tab and its popups now share one claim, so a second orca download on the same tab while one is waiting fails with browser_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:

  • Hand the claim to the new tab. The renderer creates that tab, so main would have to match it back to the clicking page across IPC, then close the leftover tab once its load turned into a download.
  • Never open the tab while a claim is armed. The download starts on the page that already holds the claim.

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 download on a _blank link 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 a Content-Disposition: attachment CSV:

Before (main at dd7496b):

$ orca download --selector @e2 --path /tmp/obu-bdl-out/blank.csv
"code": "browser_download_not_started",
"message": "Clicking @e2 did not start a download within 10s."
~/Downloads: + report-bdl.csv
$ orca tab list
* [0] a430150f…  DL fixture — http://127.0.0.1:47811/
  [1] c0d50cef…   —

After (this branch):

$ orca download --selector '#blank'   --path /tmp/obu-bdl-out/blank.csv    → ok, path /tmp/obu-bdl-out/blank.csv
$ orca download --selector '#winopen' --path /tmp/obu-bdl-out/winopen.csv  → ok, path /tmp/obu-bdl-out/winopen.csv
$ orca download --selector '#same'    --path /tmp/obu-bdl-out/same.csv     → ok, path /tmp/obu-bdl-out/same.csv
~/Downloads: unchanged
$ orca tab list
* [0] a430150f…  DL fixture — http://127.0.0.1:47811/

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 _blank link, the window.open button and the same-tab link all saved to --path and 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 click on the same _blank attachment link and on a _blank page 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 becomes downloadURL, 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.
    • Both tests fail without the fix.
  • 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:

  • Round 1: Codex had no findings. Claude found that claims made on popup pages never matched. Fixed here.
  • Round 2: both reviewers found that a tab and its popup could overwrite each other's claim. Fixed with the busy check.
  • CodeRabbit (Major): a sibling popup's new-tab link could take the claim. Fixed: only the clicked page's links are converted.
  • Not acted on (P3): on a page an SSH host is driving, Orca refuses every download. A _blank click 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

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

Notes

  • Security: the new branch runs only after the gesture and budget check, and only for URLs the policy would already open as a tab: http(s), or file: from a local page. downloadURL uses the clicking page's own session.
  • Cross-platform: main-process logic only, with nothing specific to any platform.
  • Remote and SSH: when a download is routed to a client or refused for an SSH-driven page, the claim isn't consumed, the same as before. No wire shape changes; browser_download_busy is a new error code over the existing error path.
  • Mobile: no mobile surface.
  • Performance: one map lookup on the window-open path.

Waiting for blessing (judgment call: orca download on a _blank link 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:

  • Open a page with <a href="/file.csv" target="_blank"> that serves Content-Disposition: attachment, then run orca 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.
  • Click the same link yourself: a tab opens and the file goes to ~/Downloads, as before.

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)

@coderabbitai

coderabbitai Bot commented Oct 30, 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: cc7898ad-1f20-4047-a8b2-5994ae7cc34f
Commits

Reviewing files that changed from the base of the PR and between b531e8b and 1b1b82b.

Files selected for processing: 4
  • src/main/browser/browser-manager-download-creation.ts
  • src/main/browser/browser-manager-guest-popup-policy.ts
  • src/main/browser/browser-manager-popup-child.test.ts
  • src/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; 1 remain after this review.

Walkthrough

Download claims now apply to a root guest and its popups. A second claim for that root is rejected, and release removes only the matching claim. When a claim was initiated by the guest handling a target-blank link, popup policy downloads the URL through that guest and denies the popup. Tests cover the claimed save path, concurrent claims, and tab routing after claim release.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 1b1b8

The previously identified wrong-file path is addressed. No actionable merge-blocking issue remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed 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%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… 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: saving downloads from new-tab and popup-page flows to the requested --path.
Description check Passed The description is complete and relevant. It includes the required ELI5, change details, rationale, linked issue, visual proof, testing, review, scope considerations, and checklist information.
Linked Issues check Passed Issue [#36392] requires orca download to save target="_blank" and window.open attachments to --path, return that path, leave ~/Downloads unchanged, and avoid an empty tab. The popup policy r…
Out of Scope Changes check Passed The production changes support [#36392]. Root-level claim ownership enables popup downloads. The busy error prevents competing downloads from using the wrong claim. The tests verify the new routing an…
Full details: Linked Issues check

Explanation

Issue [#36392] requires orca download to save target="_blank" and window.open attachments to --path, return that path, leave ~/Downloads unchanged, and avoid an empty tab. The popup policy routes an eligible claimed URL through downloadURL on the clicking page. Claims are shared by a tab and its popup pages. The added tests cover target-blank routing, popup-page claims, claim conflicts, and normal tab opening after claim release. The PR evidence also reports that manual clicks without a claim still open tabs.

Full details: Out of Scope Changes check

Explanation

The production changes support [#36392]. Root-level claim ownership enables popup downloads. The busy error prevents competing downloads from using the wrong claim. The tests verify the new routing and preserve existing popup behavior. No unrelated change is established by the available PR evidence.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 5 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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.

@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: 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
Commits

Reviewing files that changed from the base of the PR and between 26675e7 and b531e8b.

Files selected for processing: 5
  • src/main/browser/browser-manager-download-creation.ts
  • src/main/browser/browser-manager-guest-popup-policy.ts
  • src/main/browser/browser-manager-popup-child.test.ts
  • src/main/browser/browser-manager-popup-openerless-tab.test.ts
  • src/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.
@AmoabaKelvin
AmoabaKelvin force-pushed the agent-blank-download-downloads branch from b531e8b to 1b1b82b Compare October 30, 2026 16:33
@AmoabaKelvin
AmoabaKelvin merged commit e030868 into main Oct 30, 2026
42 checks passed
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.

orca download on a target=_blank attachment link saves to ~/Downloads instead of --path

1 participant