Skip to content

fix(browser): show streamed pages' JavaScript dialogs on the desktop - #41960

Merged
AmoabaKelvin merged 1 commit into
mainfrom
fix-streamed-browser-dialogs
Nov 13, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
fix-streamed-browser-dialogs

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When a web page asks "Are you sure?" inside a remote browser tab that streams from a server, the desktop never showed the question. The page just froze. Now the desktop shows the same dialog the local browser shows, and your answer goes back to the page.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​166 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​156

What Changed

Before: on a "Server (streamed)" page, alert(), confirm() or prompt() blocked the page and nothing appeared on the desktop. Clicks then showed a toast meant for agents ("Answer it with orca dialog accept --page …"), and only an agent or a phone could unblock the page.

After: the desktop shows the dialog with the local browser's existing dialog UI (javaScriptDialogPrompt on the confirmation dialog). OK and Cancel are sent to the host through browser.dialogAccept and browser.dialogDismiss, which is the path the phone and agents already use. When the host closes the dialog some other way (an agent or the phone answered it, or the stream stopped and the host dismissed it), the desktop's dialog closes too. The agent-only toast no longer shows when your own click or key opened the dialog.

Mechanism: the screencast stream already sends dialog and dialogClosed events, and the phone already renders them. The desktop's subscription (remote-browser-screencast-subscription.ts) dropped every event type except ready, end and error. Each stream now owns one RemoteBrowserJavaScriptDialog. It asks once per held dialog (the host repeats the held one when a turned-away nested dialog closes), and it closes when the stream unsubscribes or closes. A pending answer is cancelled if the dialog closes before the answer is sent.

Why

The person on the desktop had no way to answer a page's dialog, which they can do on a local page and on the phone. The fix lives in the desktop subscription that dropped the events. It reuses the host's answer RPCs and the local dialog component, with no new protocol and no new UI.

Linked Issue

None. Found while auditing the remote browser hosting modes.

Visual Proof

A paired desktop showing a streamed page whose button calls confirm('Proceed?'), after the person clicks it.

Before After
before-1-person-click.png after-1-person-click.png

Probe numbers from a real headless serve plus a hidden paired desktop (Playwright, page title read from the host with browser.tabShow):

Step Before After
Person clicks the button no desktop dialog, agent toast shown desktop dialog shown, no toast
Person presses OK not possible; an agent had to accept page gets confirm:true, dialog gone
Person presses Cancel not possible page gets confirm:false, dialog gone
Agent runs browser.dialogAccept while the desktop dialog is open n/a page gets confirm:true, desktop dialog clears

Testing

  • Ran a throwaway e2e spec (deleted) with launchHeadlessPairedRuntimeHost and launchPairedElectronClient on macOS, on main and on this branch, giving the numbers above.

  • Added two lifecycle tests: one checks that a stream dialog event asks once and answers with browser.dialogAccept on the right page, and one checks that dialogClosed drops the ask. Both fail when the subscription drops the events again.

  • I manually tested these changes locally

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

  • Every added test fails without this change and avoids the test anti-patterns

Risk

The change is in the desktop renderer, and only for streamed panes. Older servers already send these events (the phone uses them), so mixed versions work. The riskiest part is the dialog closing at the wrong time. The desktop closes it when the stream stops, because the host's screencast stop already dismisses the page's dialog. Two gaps are left for follow-ups. First, an answer already in flight when another client answers can still land on the page's next dialog, because the answer RPC doesn't name the dialog it answers. Agents have the same gap today. Second, hiding the Orca window parks the stream, and that dismisses the dialog, as it already did on main. To back it out, do a plain revert.

Level: Low

AI Disclosure

Review

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

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

The dialog text comes from the page. It is shown as text in the existing confirmation dialog, never as markup. The title stays "This page says" because the stream event carries no frame origin. Phones and SSH are unchanged.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

The desktop's screencast subscription dropped the stream's dialog and
dialogClosed events, so an alert, confirm or prompt on a Server
(streamed) page froze it with nothing to answer. Ask with the local
browser's dialog, answer through browser.dialogAccept/dialogDismiss,
and close it when the host closes the dialog or the stream stops.
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Remote browser streams now handle alert, confirm, and prompt events through a confirmation prompt. Accepting or dismissing a prompt sends the corresponding host RPC. Closing the dialog aborts its prompt or pending RPC. Pointer and keyboard input handlers do not show a pane notice when the remote browser reports that a dialog is open.

Merge Risk: Moderate · up to 8faed

Desktop display of streamed-page dialogs works, but an answer sent while another client is also answering can in rare cases land on a later dialog. A large paste cut short by a dialog is also not reported to the user. Consider fixing the first, which needs a dialog identity across the stream event, the RPC, and the host, before merge or accept it explicitly.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: streamed remote browser pages now show their JavaScript dialogs on the desktop. The diff adds a desktop dialog handler, subscription routing for dialog events, and ans…
Description check Passed The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checkl…
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: Title check

Explanation

The title names the main change: streamed remote browser pages now show their JavaScript dialogs on the desktop. The diff adds a desktop dialog handler, subscription routing for dialog events, and answer RPCs that match this. The 'fix(browser):' prefix is a conventional-commit scope and does not reduce clarity. The title is 68 characters, within a reasonable length for a single-line subject.

Full details: Description check

Explanation

The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It explains the before and after behavior, the mechanism, the risks, and a rollback path. Visual proof includes before and after images and a probe table. Gaps: the Linked Issue section says 'None' and does not link an issue, and the template says an issue should always exist for outside contributors. The Testing section lists two lifecycle tests but does not name the commands run. The AI Disclosure section is empty, though it is optional for StablyAI team members.

Resolution

Optional: link an issue in the Linked Issue section if the author is an outside contributor, since the template requires one. Also state whether pnpm lint, typecheck, test, and build were run, and fill in AI Disclosure if an AI model was used.

  • 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: 2

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: 29cc1223-b003-4b49-b90e-405bfc37e83b
Commits

Reviewing files that changed from the base of the PR and between 7e10540 and 8faed48.

Files selected for processing: 11

  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-javascript-dialog.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-session.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-screencast-subscription.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-stream-errors.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-stream-lifecycle-deps.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-stream-lifecycle-test-harness.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-stream-lifecycle.test.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-stream-lifecycle.ts
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.ts
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-keyboard.ts
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-lifecycle.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.

// Closing it elsewhere first must not let this answer reach the page's next dialog.
signal: AbortSignal
): Promise<unknown> {
const params = { worktree, page: pageId }

@coderabbitai coderabbitai Bot Nov 13, 2026 •

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.

Major · Data Integrity & Integration · Heavy lift

Bind each dispatched dialog answer to the dialog it answers.

The answer RPC identifies only the page. The host applies the answer to whichever dialog is open when it executes. If another client answers dialog A while this answer is in flight, and the page opens dialog B before the host receives this answer, the host can answer B with A's response. For a confirm, that can accept a prompt the user did not see.

close() aborts only the renderer-side call. The host applies an answer synchronously when it receives it, so the abort does not stop an answer that has already arrived.

A fix needs a dialog identity across three layers:

  • The host assigns an identity to each opened dialog and includes it in the dialog stream event. CDP's dialog-opening event carries no identifier, so the host must generate it.
  • The answer RPC accepts that identity. answerDialog rejects an answer whose identity no longer matches the open dialog.
  • The identity field stays optional, so that the agent CLI's page-only dialog accept and dialog dismiss keep working.

This change spans the shared event type, the DialogAccept schema, and the host answer path. It does not have a localized diff.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declining for this PR, with a follow-up. The race is real, but it predates this change and isn't specific to the desktop: the phone (use-mobile-browser-commands.ts sendDialogCommand) and the agent CLI (orca dialog accept/dismiss) send the same page-only browser.dialogAccept/browser.dialogDismiss, and the host's answerDialog (agent-browser-bridge-page-commands.ts:82) answers whichever dialog is open. As you say, closing it needs a host-minted dialog id in the stream event, the DialogAccept schema and the host answer path. That's a cross-layer protocol change, so it shouldn't ride in a renderer fix. This PR already cancels an answer that hasn't been sent when the dialog closes (the RPC gets the dialog's abort signal), and the PR's Risk section lists the dispatched-answer case as a follow-up.

Comment on lines +184 to +186
if (isRemoteBrowserInputOpenedDialogError(error)) {
return
}

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 · Data Integrity & Integration · Quick win

Report a paste that a dialog cuts short.

A large paste is sent as several browser.keyboardInsertText requests. If a page dialog interrupts one request, the error exits the chunk loop and the remaining text is not inserted. The dialog-opened branch returns without a notice, so the user is not told the paste is incomplete.

Suggested fix

--- "a/src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-keyboard.ts"
+++ "b/src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-keyboard.ts"
@@ -181,9 +181,15 @@
             closeMissingRemotePage(pageId)
             return
           }
           if (isRemoteBrowserInputOpenedDialogError(error)) {
+            if (input.method === 'browser.keyboardInsertText') {
+              setPaneNotice({
+                kind: 'consequence',
+                text: 'Paste stopped because a page dialog opened. The remaining text was not inserted.'
+              })
+            }
             return
           }
           setPaneNotice({
             kind: 'consequence',
             text: error instanceof Error ? error.message : 'Remote keyboard input failed.'
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
if (isRemoteBrowserInputOpenedDialogError(error)) {
return
}
if (isRemoteBrowserInputOpenedDialogError(error)) {
if (input.method === 'browser.keyboardInsertText') {
setPaneNotice({
kind: 'consequence',
text: 'Paste stopped because a page dialog opened. The remaining text was not inserted.'
})
}
return
}

@AmoabaKelvin
AmoabaKelvin merged commit 86fea2e into main Nov 13, 2026
47 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.

1 participant