Skip to content

feat(browser): let agents drive sign-in and payment popups as pages - #36253

Merged
AmoabaKelvin merged 8 commits into
mainfrom
agent-window-open-oauth
Oct 30, 2026
Merged

AmoabaKelvin merged 8 commits into
mainfrom
agent-window-open-oauth

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​170 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​170
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​316 $\color{#cf222e}{\Huge{\mathbf{−}}}$​48 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​268

ELI5

When a page opens a sign-in or payment popup, the person sees it, but an agent driving Orca's browser could not: tab list showed only the original tab and no command could reach the popup, so OAuth flows stalled until someone clicked through by hand. Now each popup shows up in tab list next to the tab that opened it, the agent can snapshot, fill and click in it with --page popup-<n>, and when the popup closes itself the agent carries on in the tab that opened it. The popup window looks and works exactly as before for the person.

What Changed

Before: window.open with features (OAuth, payment) creates a native child window that keeps window.opener. Its webContents was tracked only as "owned by tab X" (popupOwnerContextByGuestId and the route-guest popup registry), so the agent bridge's page registry, which backs tab list, --page, tab switch and tab close, never contained it.

After:

  • BrowserManager.getPopupPages() lists live popups as pages popup-<webContentsId> owned by their opener tab. Workspace, profile and load errors for a popup id resolve through the owner. A tab created with a popup-shaped id keeps it.
  • The bridge appends popups after the tabs in getRegisteredTabs and tab list (with openerBrowserPageId). All --page commands, tab switch, tab show and tab close therefore work on popups unchanged.
  • The agent's default page never moves when a popup opens. When a popup the agent switched into closes, routing goes back to its opener (not the first tab), the agent's "using this page" claim moves with it so a person's held tab pick keeps waiting, and the popup's agent-browser session ends after any in-flight command settles. The Approve click that makes the popup close itself reports Clicked, not "Tab was closed".
  • tab close on a popup (by page, index or the routed default) closes its window and returns once it is gone.
  • Remote paths: SSH-host CLI scope maps a popup id to its opener for the renderer's workspace check. The orcad Electron-sidecar registry adopts listed popups into the opener's workspace, orders them after tabs and hands back to the opener. Commands on a popup that already closed fail at once instead of waiting 8s for a renderer tab that never registers.
  • The orca-cli browser guide tells agents to check tab list when a click seems to do nothing.

Why

Three ways to reach popups were considered; the coordinator picked the first:

  • Popups stay native windows and the agent sees them as pages tied to their opener (this PR). The person's OAuth flows stay exactly as they are, and every existing command works on the popup.
  • The default page could auto-follow a new popup, the way Playwright MCP and browser-use do. That moves the agent's target silently, which [Feature]: Conversation-owned side browser with per-agent page isolation #29511 removed for a reason. The browser-action-effects work can report "popup opened" by diffing tab list before and after an action.
  • Popups could become real Orca tabs that keep window.opener. That needs webview tabs to adopt an existing webContents, a large renderer change that also alters the person's sign-in UX.

The fix sits at the owner of popup ownership (BrowserManager) and the owner of agent page routing (the bridge), so local, SSH-routed, client-hosted and sidecar paths share one mechanism.

Linked Issue

Fixes #12718
Fixes #19159

#7034 (closed) asked for Target.createTarget through the CDP proxy. This PR does not add that; tabs are still created with orca tab create.

Visual Proof

The browser UI does not change: popups open in the same window with the same origin bar. The behaviour change is in the agent CLI, so here are transcripts from a hidden dev build against a local fixture (an opener page with a "Sign in with Popup" button whose popup posts the username back to window.opener and calls window.close() on Approve).

Before (main):

$ orca click --element @e2
Clicked @e2
$ orca tab list
* [0] 88daf986-…  Opener — http://127.0.0.1:8792/

The popup existed (CDP showed page http://127.0.0.1:8792/auth.html Auth Provider), but nothing could address it.

After (this branch):

$ orca click --element @e2
Clicked @e2
$ orca tab list
  [0] f1d56d88-…  Opener — http://127.0.0.1:8792/
* [1] d7f6bff5-…  Opener — http://127.0.0.1:8792/
  [2] popup-4  Auth Provider — http://127.0.0.1:8792/auth.html  (popup opened by d7f6bff5-…)
$ orca snapshot --page popup-4
- textbox "Username " [ref=e3]
- button "Approve" [ref=e2]
$ orca fill --page popup-4 --element @e3 --value kelvin
Filled @e3
$ orca click --page popup-4 --element @e2
Clicked @e2
$ orca tab list
  [0] f1d56d88-…  Opener — http://127.0.0.1:8792/
* [1] d7f6bff5-…  Opener — http://127.0.0.1:8792/
$ orca snapshot
  - StaticText "Signed in as kelvin"

$ orca tab switch --page popup-6
Switched to tab 2 (popup-6)
$ orca click --element @e2      # Approve; the popup closes itself
Clicked @e2
$ orca snapshot
page: d7f6bff5-…                # the opener, not tab [0]
  - StaticText "Signed in as second"

Testing

  • Live, hidden dev build on macOS (ORCA_BACKGROUND_LAUNCH=1, own CDP port and profile): --page driving, screenshot of the hidden popup, window.opener intact, self-close via Approve, tab switch into the popup then self-close (3 runs), tab close by page and by default target with the opener not first, an immediate no-page command after tab close, and a command against an already-closed popup (instant not-found). No orca-tab-popup-* agent-browser daemons were left behind.
  • Regression tests, each shown to fail without its fix:
    • bridge routing: popup listed with its opener; --page routing; switch in, the in-flight Approve click still resolves, the agent lands on the opener despite a held person pick, and the session closes;
    • BrowserManager: a popup child is enumerated, resolves its opener's workspace and profile, closes, and disappears when the opener retires;
    • agent activity hand-over refreshes the opener's idle window;
    • sidecar registry scopes, orders and hands back popups.
  • Focused runs of every dependent test file (75 files, 898 tests), check:code-quality:changed and check:react-doctor:changed. Linux, Windows and a real SSH host were not run by hand; CI covers the suites.

To try (worktree /Users/kelvinamoaba/orca/workspaces/orca/browser-popups-for-agents, dev build):

  1. Open a page with a window.open(url, 'auth', 'width=500,height=600') button in an Orca tab, then orca click --element <ref> on it.
  2. orca tab list shows popup-<n> … (popup opened by <tab>); orca snapshot --page popup-<n>, then fill and click inside it.
  3. Approve so the popup calls window.close(), then run orca snapshot with no --page: it lands on the opener.
  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Four review rounds with Codex and Claude. Accepted and fixed: SSH --page popup-<n> scope, Electron-sidecar adoption/order/hand-back, implicit tab close, popup load errors, popup-shaped tab id collisions, the 8s wake-up stall, the held-pick hand-over and its idle refresh, and tab close settling before it returns. Left as is: after a routed popup closes itself over the Electron sidecar, the first command without --page can return not-found once before landing on the opener, because orcad pins the last active page; pointer and focus-guard calls for a popup resolve to the opener's pane, which is cosmetic.

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: popups keep their existing admission, session and origin-bar policy. SSH-host commands are still gated by the opener's workspace and the popup's own routed session.
  • Cross-platform: no platform-specific code. Popup windows stay hidden under background launch as before.
  • Remote/SSH: covered above. openerBrowserPageId is an optional result field, so older CLIs simply list popups as extra tabs and newer CLIs against an older desktop see no popups.
  • Mobile: the phone's session tab rows come from the renderer and offscreen backend, so popups do not appear there; no mobile change.
  • Folder workspaces: popups inherit their opener's workspace, whatever its type.
  • Performance: one scan over live popups (usually none) per page lookup; no polling.

Checklist

  • This PR is small and focused (focused on one feature, but it touches the bridge, BrowserManager, runtime close, SSH scope and the sidecar registry)
  • 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: bb125721-853d-42a3-a0d1-6f057d98ecee
Commits

Reviewing files that changed from the base of the PR and between f96d802 and 812c441.

Files selected for processing: 10
  • skill-guides/orca-cli/references/browser.md
  • src/cli/browser-format.ts
  • src/cli/bundled-skill-guides.ts
  • src/main/browser/agent-browser-bridge-state.ts
  • src/main/browser/agent-browser-bridge-tab-routing.test.ts
  • src/main/browser/agent-browser-bridge-test-harness.ts
  • src/main/browser/browser-agent-activity.ts
  • src/main/browser/browser-manager-visibility.ts
  • src/main/runtime/browser/browser-command-targets.ts
  • src/shared/runtime-browser-contracts.ts
Files skipped from review as they are similar to previous changes: 1
  • src/cli/bundled-skill-guides.ts

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

Walkthrough

The change adds popup page IDs and opener ownership to browser tab data. Popup pages can appear in tab listings, be targeted by browser commands, and be closed through the browser tab-close path. The agent bridge tracks popup closure, retargets routing to the opener when possible, and hands over agent activity. Tests cover popup discovery, listing, targeting, closure, registry behavior, and activity handoff.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Low · up to 812c4

Some popup and tab workflows have bounded gaps, and the requested creation event is missing. These warrant owner awareness before merge.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning [#19159] is addressed. Live popups appear in tab list, accept popup page IDs, and return routing to the opener after close. [#12718] is only partly addressed. getPopupPages() discovers popups by s… For #12718, add and emit a typed popup-created event that contains the stable popup page ID and opener page ID. Add automated regression tests for popup navigation/process swaps, blocked-popup policy, nested popups, Cmd/Ctrl-click, and ordi…
Docstring Coverage Warning Docstring coverage is 20.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. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: making browser sign-in and payment popups usable as agent-controlled pages.
Description check Passed The description is complete and directly addresses the required sections. It explains the user impact, implementation, rationale, linked issues, behavior evidence, testing, compatibility consideration…
Out of Scope Changes check Passed The changed production files implement popup page IDs, ownership, listing, page routing, close handling, activity hand-over, SSH workspace resolution, sidecar adoption, and CLI guidance. The tests cov…
Full details: Description check

Explanation

The description is complete and directly addresses the required sections. It explains the user impact, implementation, rationale, linked issues, behavior evidence, testing, compatibility considerations, and known limitations. Some checklist items remain unchecked, but the description is mostly complete.

Full details: Out of Scope Changes check

Explanation

The changed production files implement popup page IDs, ownership, listing, page routing, close handling, activity hand-over, SSH workspace resolution, sidecar adoption, and CLI guidance. The tests cover these same behaviors. No unrelated implementation or #7034 Target.createTarget work is present.

Full details: Linked Issues check

Explanation

[#19159] is addressed. Live popups appear in tab list, accept popup page IDs, and return routing to the opener after close. [#12718] is only partly addressed. getPopupPages() discovers popups by scanning ownership maps; the reviewed changes add no typed popup-created event with target and opener identifiers. The added tests cover listing, explicit routing, self-close, opener retirement, and sidecar ordering. They do not cover navigation/process swaps, blocked-popup policy, nested popups, Cmd/Ctrl-click, or ordinary target=_blank links required by #12718.

Resolution

For #12718, add and emit a typed popup-created event that contains the stable popup page ID and opener page ID. Add automated regression tests for popup navigation/process swaps, blocked-popup policy, nested popups, Cmd/Ctrl-click, and ordinary target=_blank links. Retain coverage for creation, discovery, operation, self-close, and opener close.

Full details: Docstring Coverage

Explanation

Docstring coverage is 20.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 5 functions across 21 files. (1 skipped: 1 unsupported.)

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.

@AmoabaKelvin
AmoabaKelvin force-pushed the agent-window-open-oauth branch from 8d32975 to f96d802 Compare October 30, 2026 15:29

@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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Preserve the immediate opener for nested popup handoff. · browser-manager-queries.ts:64-88

src/main/browser/browser-manager-queries.ts:64-88
Minor · Functional Correctness · Quick win

Preserve the immediate opener for nested popup handoff.

When popup A opens popup B, B inherits the root tab's PopupOwnerContext. getPopupPages() therefore publishes the root tab as B's openerBrowserPageId. When B closes, watchPopupClose() retargets the agent and calls handOverAgentActivity() with that root ID, so the agent skips live popup A.

Keep the root tab for workspace/profile ownership and nested listing. Store the immediate opener separately and use it for openerBrowserPageId and close handoff. Preserve separate root-owner metadata for sidecar adoption so B remains listable even when A is enumerated later.


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: cc44475e-4a94-410d-98db-b4d175af5cd0
Commits

Reviewing files that changed from the base of the PR and between 04dcdcf and f96d802.

Files selected for processing: 6
  • skill-guides/orca-cli/references/browser.md
  • src/cli/bundled-skill-guides.ts
  • src/main/browser/agent-browser-bridge-lifecycle.ts
  • src/main/browser/agent-browser-bridge-state.ts
  • src/main/browser/agent-browser-bridge-tabs.ts
  • src/main/runtime/browser/browser-command-targets.ts

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

// The renderer never registers popups, so waking it for a closed one only stalls.
if (
bridge &&
browserPopupPageWebContentsId(browserPageId) === null &&

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.

Minor · Functional Correctness · Quick win

Use collision-aware popup detection.

browserPopupPageWebContentsId() treats every popup-<positive integer> string as a popup. The browser manager also permits a regular tab to keep a popup-shaped ID. If that regular tab is persisted but unmounted, this condition skips ensureBrowserPageActive(). The bridge can then return browser_tab_not_found instead of remounting the regular tab. Use collision-aware popup classification so regular tabs with popup-shaped IDs still activate. (raw.githubusercontent.com)

…ages

window.open popups that keep their opener stay native windows, but the
agent bridge now lists each one in tab list as popup-<n> with its opener,
so --page, tab switch and tab close reach it. When a popup the agent
switched into closes, its next command lands on the opener.
@AmoabaKelvin
AmoabaKelvin force-pushed the agent-window-open-oauth branch from f96d802 to 812c441 Compare October 30, 2026 15:41
@AmoabaKelvin
AmoabaKelvin merged commit dd7496b into main Oct 30, 2026
70 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

1 participant