You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(browser): show streamed pages' JavaScript dialogs on the desktop - #41960
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
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.
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: 4
Check name
Status
Explanation
Title check
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
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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 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.
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.
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.'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
What Changed
Before: on a "Server (streamed)" page,
alert(),confirm()orprompt()blocked the page and nothing appeared on the desktop. Clicks then showed a toast meant for agents ("Answer it withorca 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 (
javaScriptDialogPrompton the confirmation dialog). OK and Cancel are sent to the host throughbrowser.dialogAcceptandbrowser.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
dialoganddialogClosedevents, 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 oneRemoteBrowserJavaScriptDialog. 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.Probe numbers from a real headless serve plus a hidden paired desktop (Playwright, page title read from the host with
browser.tabShow):confirm:true, dialog goneconfirm:false, dialog gonebrowser.dialogAcceptwhile the desktop dialog is openconfirm:true, desktop dialog clearsTesting
Ran a throwaway e2e spec (deleted) with
launchHeadlessPairedRuntimeHostandlaunchPairedElectronClienton macOS, on main and on this branch, giving the numbers above.Added two lifecycle tests: one checks that a stream
dialogevent asks once and answers withbrowser.dialogAccepton the right page, and one checks thatdialogCloseddrops 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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)