Skip to content

fix(browser): open target=_blank links in Server (streamed) pages as new tabs - #37102

Merged
AmoabaKelvin merged 10 commits into
mainfrom
streamed-target-blank-36804
Nov 1, 2026
Merged

AmoabaKelvin merged 10 commits into
mainfrom
streamed-target-blank-36804

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​272 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​270
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​211 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​186

ELI5

When a remote server workspace is set to Server (streamed), clicking a link that opens in a new tab did nothing. Now it opens a new Orca tab in that workspace, and the person who clicked lands on it.

What Changed

Before: in a streamed page on a headless orca serve host, a target=_blank link click was dropped. Nothing opened and the tab count stayed the same.

After: the link opens as a new browser tab in the page's workspace and profile. Only the client that clicked moves to it, the way a local page brings its new tab to the front. A link no paired client opened opens in the background for everyone, and the agent keeps its current tab. That covers an agent's click, a script, or a middle-click. This applies to desktop and phone alike.

Mechanism:

  • Streamed pages are offscreen windows on the server with no renderer. openLinkInOrcaTab used to need a renderer, so it returned false and the popup policy denied the link. It now hands an offscreen page's link to a runtime opener (setOffscreenTabOpener), which calls the existing browserTabCreate for the page's workspace. Pages with no workspace (orcad's Electron browser) keep the old behaviour.
  • Who clicked: the bridge's per-page command queue records each command's RPC caller when it is queued. When activating input reaches the page, BrowserPageInputCredit credits that input to the paired client whose command delivered it. That input is mouse down/up, keys, or a phone's DOM-activated tap. Wheel, move and snapshot commands leave the credit alone, and an agent's command clears it. The credit is single use and lasts 1s, like the existing input-gesture window.
  • A credited foreground open creates the tab with navigation caller and a new opensPageLink marker. The marker sends navigationIntent: 'follow' to that one client, which desktop and mobile already honour. Any other open is created in the background, and the session tab list is announced right away without moving the agent's routing.

Why

The headless runtime already owns tab creation for these pages (orca tab create uses the same path), so links reuse it instead of adding a second tab model. A server-side open on someone's behalf has no pending focus on the client, so the server has to tell that client to follow. Telling every client to follow would move views nobody asked to move. Earlier versions recorded the click in the input RPC handlers. That missed agent commands with no explicit page and input sent through exec, fill or type, and a watcher's scroll could take credit for an agent's link. Crediting at the guest's real activating input, via the queue's runner, avoids all three.

Linked Issue

#36804. This fixes item 2 only (target=_blank links in Server (streamed) pages). The issue's other items are tracked separately.

Visual Proof

Paired desktop client on a headless orca serve host, Server (streamed) page with a target=_blank link, 4s after a real click on the streamed frame.

Before (main): nothing opens, still on the source page.
(screenshot removed: contained real product data)

After: the link opens as a new tab in front for the clicking client.
(screenshot removed: contained real product data)

Testing

  • New e2e tests/e2e/paired-remote-browser-blank-link.spec.ts: a headless serve host plus a paired Electron client. A scripted click opens the tab without moving the client's view, and a real click on the streamed frame brings the new tab to the front. It fails on main ("the server never opened the link as a tab") and passes on this branch (macOS).

  • Unit tests at the owners: browser-page-input-credit.test.ts, offscreen-browser-page-link.test.ts, the offscreen and no-workspace cases in browser-manager-popup-routing.test.ts, the background announcement in browser-tab-create-publication.test.ts, and the phone tap credit in agent-browser-bridge-mouse-input.test.ts. Each fails without its fix.

  • Repro before the fix on a hidden headless serve built from this worktree: clicking the link left orca tab list at one tab. After the fix it showed the destination as a second tab.

  • Focused and dependent suites pass (47 files). Changed-file code-quality gate passes. Full lint, typecheck and suite are left to CI.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Four review rounds (Codex plus Claude). Accepted and fixed:

  • queued clicks losing their client;
  • unpaired input not clearing an earlier client's credit;
  • background opens moving the agent's tab;
  • orcad Electron pages opening hidden tabs;
  • agent commands with no explicit page;
  • background tabs not announced until their first load;
  • watcher scrolls taking credit;
  • popup id vs root tab id;
  • phone DOM taps going uncredited.

Left as P3:

  • a scripted window.open within 1s of an unrelated click can follow that client, the same window the existing gesture check allows;
  • a failed create still reports "opened in Orca", which the renderer path also did;
  • placing the new tab beside its opener in split layouts (follow-up).

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

  • Remote and mixed versions: no wire fields added. navigationIntent: 'follow' already exists, so older clients and the phone honour it. A new client with an older server keeps today's behaviour.
  • Mobile: phone taps (browser.mouseClick, including the DOM-activated path) get the same foreground behaviour.
  • Desktop hosts with a window keep the renderer path unchanged. Folder workspaces resolve through id:<workspace>.
  • Not covered here: "This device" (client-hosted) pages may have a similar target=_blank gap. That is outside item 2.

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)

…tabs

Headless serve pages have no renderer, so a page's new-tab request was
denied. The runtime now opens the link as a tab beside the page, in front
only for the paired client whose click or key press opened it.
A click waiting in the page's command queue keeps its client until it is
delivered, input with no paired client clears an older one, and an
unattributed link no longer moves the agent's tab.
Record the paired client at the bridge's per-page command lease, which
sees the resolved page and every command kind, instead of in four RPC
handlers. A page without a workspace keeps denying new-tab links.
Credit at the guest's activating input, under the popup owner's tab, to
the command delivering it, so a watcher's scroll can't claim an agent's
link. Announce a background tab at once since bridge selection no
longer does.
A tap with a touch radius clicks the element through Runtime.evaluate,
which fires no guest input event, so credit the tapping client first.
The queue owns the page command credit instead of the agent lease, the
credit skips work while idle and shares the gesture's freshness rule,
one opener serves both link paths, and one opensPageLink marker replaces
the paired follows/leavesAgentTab flags.
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The changes track paired-device input delivered during page commands and use recent input credit when opening links from eligible offscreen browser guests. They add runtime wiring for offscreen tab creation and mark page-link tab publications so they can notify session-tab watchers without activating the bridge tab. Caller navigation now carries follow metadata for these page-link operations.

Merge Risk: Low · up to ade4d

A failed test-host launch can leave the test server running, and the new test would miss a link opening in the wrong browser profile. Both are bounded issues to address or explicitly accept before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 42.86% 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: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: opening target=_blank links in Server (streamed) pages as new tabs.
Description check Passed The description includes the required sections, explains the user-facing behavior and implementation, links the issue, provides visual proof, documents testing, and records scope and limitations. The …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the required sections, explains the user-facing behavior and implementation, links the issue, provides visual proof, documents testing, and records scope and limitations. The empty AI Disclosure and Review sections are non-critical.

Full details: Docstring Coverage

Explanation

Docstring coverage is 42.86% 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 7 functions across 25 files.

Resolution

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

Finishing Touches
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

@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

Nitpick comments: 1
tests/e2e/paired-remote-browser-blank-link.spec.ts: 1

70-85: Trivial · Functional Correctness · Quick win

Assert the scripted tab in the paired client DOM.

The scripted branch proves only that the host created a page and that the source tab stayed selected. It does not prove that the paired client rendered the new background tab. Capture the paired tabId, then assert that its visible tab contains the loaded title Blank destination.

Suggested fix
 import {
   focusMaterializedRemoteBrowserPane,
-  waitForMaterializedRemoteBrowserPane
+  waitForMaterializedRemoteBrowserPane,
+  type MaterializedRemoteBrowserPane
 } from './helpers/materialized-remote-browser-pane'
 ...
-    const waitForOpenedTab = async (before: string[]): Promise<void> => {
+    const waitForOpenedTab = async (
+      before: string[]
+    ): Promise<MaterializedRemoteBrowserPane> => {
       await expect
         .poll(async () => (await listPages()).length, {
 ...
       const remotePageId = (await listPages()).find((id) => !before.includes(id))!
-      await waitForMaterializedRemoteBrowserPane(page, { environmentId, remotePageId, worktreeId })
+      return waitForMaterializedRemoteBrowserPane(page, {
+        environmentId,
+        remotePageId,
+        worktreeId
+      })
     }
 ...
-    await waitForOpenedTab(before)
+    const scriptedTab = await waitForOpenedTab(before)
+    const scriptedTabLocator = page.locator(`[data-tab-id="${scriptedTab.tabId}"]`)
+    await expect(scriptedTabLocator).toBeVisible()
+    await expect(scriptedTabLocator).toContainText('Blank destination')

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: d56e1bac-0141-48d1-b964-5ba05e934034
Commits

Reviewing files that changed from the base of the PR and between 225db8c and 1abfe19.

Files selected for processing: 25
  • src/main/browser/agent-browser-bridge-mouse-commands.ts
  • src/main/browser/agent-browser-bridge-mouse-input.test.ts
  • src/main/browser/agent-browser-bridge-queue.ts
  • src/main/browser/agent-browser-bridge-test-harness.ts
  • src/main/browser/browser-guest-input-gesture.ts
  • src/main/browser/browser-manager-final.ts
  • src/main/browser/browser-manager-guest-popup-policy.ts
  • src/main/browser/browser-manager-popup-routing.test.ts
  • src/main/browser/browser-manager-state.ts
  • src/main/browser/browser-manager-test-harness.ts
  • src/main/browser/browser-manager-visibility.ts
  • src/main/browser/browser-page-input-credit.test.ts
  • src/main/browser/browser-page-input-credit.ts
  • src/main/runtime/browser-tab-create-publication.test.ts
  • src/main/runtime/browser-tab-create-publication.ts
  • src/main/runtime/browser/browser-tab-creation.ts
  • src/main/runtime/browser/offscreen-browser-page-link.test.ts
  • src/main/runtime/browser/offscreen-browser-page-link.ts
  • src/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.ts
  • src/main/runtime/session-tabs/structured-session-tab-close.ts
  • src/main/startup/main-process-quit-pending-writer.test.ts
  • src/main/startup/main-process-quit.ts
  • src/main/startup/main-process-ready-duplicate-pty-repair.test.ts
  • src/main/startup/main-process-runtime-service.ts
  • tests/e2e/paired-remote-browser-blank-link.spec.ts

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

}, testInfo) => {
test.setTimeout(300_000)
const { server, origin } = await startLinkServer()
const host: HeadlessPairedRuntimeHost = await launchHeadlessPairedRuntimeHost()

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 · Stability & Availability · Quick win

Close the link server when host launch fails.

If launchHeadlessPairedRuntimeHost() rejects, execution never enters the try at Line 48. The link server remains open and can keep the test worker alive. Move host launch inside the guarded lifecycle. Ensure that cleanup still closes the server if client or host disposal fails.

@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.

Follow-up Comments

Nitpick Make the new-tab assertion check profile inheritance from a non-default opener.

74-86: Trivial · Functional Correctness · Quick win

Make the new-tab assertion check profile inheritance from a non-default opener.

The test creates the opener in the default profile. A regression that opens the target=_blank destination in the default profile would still pass. Comparing the opener's and destination's profileId values does not help in that case, because both values would be the default profile. Put the opener in a non-default profile first. Then assert that the destination keeps that profile.

Add the profile setup after the opener is created:

Suggested fix
     ).result
+    const isolated = (
+      await host.client.call<{ profile: { id: string } }>('browser.profileCreate', {
+        label: 'Blank link profile',
+        scope: 'isolated'
+      })
+    ).result.profile.id
+    await host.client.call('browser.tabSetProfile', {
+      worktree: `id:${worktreeId}`,
+      page: created.browserPageId,
+      profileId: isolated
+    })
     await focusMaterializedRemoteBrowserPane(page, {

In waitForOpenedTab, assert the destination row's profile after the new ID is found. Read the rows with a helper that keeps profileId. The current readHostBrowserPageIds drops it, so add a sibling helper in tests/e2e/helpers/host-session-tabs.ts that returns { browserPageId, profileId } from the same browser.tabList call:

       const remotePageId = (await listPages()).find((id) => !before.includes(id))!
+      const opened = (await listPageRows()).find((tab) => tab.browserPageId === remotePageId)
+      expect(opened?.profileId).toBe(isolated)
       await waitForMaterializedRemoteBrowserPane(page, { environmentId, remotePageId, worktreeId })

The assertion runs for both the scripted click and the client click, so both paths are covered.

Open the source location


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: ba7fc23f-0999-47e8-a2e2-ec96ecddd624
Commits

Reviewing files that changed from the base of the PR and between 1abfe19 and ade4d76.

Files selected for processing: 1
  • tests/e2e/paired-remote-browser-blank-link.spec.ts
Files skipped from review as they are similar to previous changes: 1
  • tests/e2e/paired-remote-browser-blank-link.spec.ts

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

@AmoabaKelvin
AmoabaKelvin merged commit fcf9562 into main Nov 1, 2026
62 checks passed
Nenzyz pushed a commit to Nenzyz/orca that referenced this pull request Nov 2, 2026
…new tabs (stablyai#37102)

* fix(browser): open target=_blank links from streamed server pages as tabs

Headless serve pages have no renderer, so a page's new-tab request was
denied. The runtime now opens the link as a tab beside the page, in front
only for the paired client whose click or key press opened it.

* test: add the offscreen tab opener to browser manager fakes

* test(e2e): drive the blank-link check through the host client

* fix(browser): credit a link only to the client whose input opened it

A click waiting in the page's command queue keeps its client until it is
delivered, input with no paired client clears an older one, and an
unattributed link no longer moves the agent's tab.

* refactor(browser): credit link opens from the page's command queue

Record the paired client at the bridge's per-page command lease, which
sees the resolved page and every command kind, instead of in four RPC
handlers. A page without a workspace keeps denying new-tab links.

* fix(browser): credit a link to the client whose click reached the page

Credit at the guest's activating input, under the popup owner's tab, to
the command delivering it, so a watcher's scroll can't claim an agent's
link. Announce a background tab at once since bridge selection no
longer does.

* fix(browser): credit a phone's DOM-activated tap before it runs

A tap with a touch radius clicks the element through Runtime.evaluate,
which fires no guest input event, so credit the tapping client first.

* test(e2e): assert the blank-link tab through the page, not the store

* refactor(browser): simplify page-link credit and tab opening

The queue owns the page command credit instead of the agent lease, the
credit skips work while idle and shares the gesture's freshness rule,
one opener serves both link paths, and one opensPageLink marker replaces
the paired follows/leavesAgentTab flags.

* test(e2e): give the blank-link spec's timeout its reason
Nenzyz pushed a commit to Nenzyz/orca that referenced this pull request Nov 2, 2026
…new tabs (stablyai#37102)

* fix(browser): open target=_blank links from streamed server pages as tabs

Headless serve pages have no renderer, so a page's new-tab request was
denied. The runtime now opens the link as a tab beside the page, in front
only for the paired client whose click or key press opened it.

* test: add the offscreen tab opener to browser manager fakes

* test(e2e): drive the blank-link check through the host client

* fix(browser): credit a link only to the client whose input opened it

A click waiting in the page's command queue keeps its client until it is
delivered, input with no paired client clears an older one, and an
unattributed link no longer moves the agent's tab.

* refactor(browser): credit link opens from the page's command queue

Record the paired client at the bridge's per-page command lease, which
sees the resolved page and every command kind, instead of in four RPC
handlers. A page without a workspace keeps denying new-tab links.

* fix(browser): credit a link to the client whose click reached the page

Credit at the guest's activating input, under the popup owner's tab, to
the command delivering it, so a watcher's scroll can't claim an agent's
link. Announce a background tab at once since bridge selection no
longer does.

* fix(browser): credit a phone's DOM-activated tap before it runs

A tap with a touch radius clicks the element through Runtime.evaluate,
which fires no guest input event, so credit the tapping client first.

* test(e2e): assert the blank-link tab through the page, not the store

* refactor(browser): simplify page-link credit and tab opening

The queue owns the page command credit instead of the agent lease, the
credit skips work while idle and shares the gesture's freshness rule,
one opener serves both link paths, and one opensPageLink marker replaces
the paired follows/leavesAgentTab flags.

* test(e2e): give the blank-link spec's timeout its reason
Nenzyz pushed a commit to Nenzyz/orca that referenced this pull request Nov 2, 2026
…new tabs (stablyai#37102)

* fix(browser): open target=_blank links from streamed server pages as tabs

Headless serve pages have no renderer, so a page's new-tab request was
denied. The runtime now opens the link as a tab beside the page, in front
only for the paired client whose click or key press opened it.

* test: add the offscreen tab opener to browser manager fakes

* test(e2e): drive the blank-link check through the host client

* fix(browser): credit a link only to the client whose input opened it

A click waiting in the page's command queue keeps its client until it is
delivered, input with no paired client clears an older one, and an
unattributed link no longer moves the agent's tab.

* refactor(browser): credit link opens from the page's command queue

Record the paired client at the bridge's per-page command lease, which
sees the resolved page and every command kind, instead of in four RPC
handlers. A page without a workspace keeps denying new-tab links.

* fix(browser): credit a link to the client whose click reached the page

Credit at the guest's activating input, under the popup owner's tab, to
the command delivering it, so a watcher's scroll can't claim an agent's
link. Announce a background tab at once since bridge selection no
longer does.

* fix(browser): credit a phone's DOM-activated tap before it runs

A tap with a touch radius clicks the element through Runtime.evaluate,
which fires no guest input event, so credit the tapping client first.

* test(e2e): assert the blank-link tab through the page, not the store

* refactor(browser): simplify page-link credit and tab opening

The queue owns the page command credit instead of the agent lease, the
credit skips work while idle and shares the gesture's freshness rule,
one opener serves both link paths, and one opensPageLink marker replaces
the paired follows/leavesAgentTab flags.

* test(e2e): give the blank-link spec's timeout its reason
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.

1 participant