Repository navigation
fix(browser): let agents and users answer page alert, confirm and prompt dialogs on their page - #36268
Conversation
…mpt dialogs on their page
|
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 3

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:
6b6817ff-8a88-4ebe-b12f-2421d3969f58
Files selected for processing: 46-
skill-guides/orca-cli/references/browser.mdsrc/cli/bundled-skill-guides.tssrc/main/browser/agent-browser-bridge-javascript-dialog.test.tssrc/main/browser/agent-browser-bridge-queue.tssrc/main/browser/agent-browser-bridge-utility-commands.tssrc/main/browser/agent-browser-process-environment.tssrc/main/browser/browser-javascript-dialogs.test.tssrc/main/browser/browser-javascript-dialogs.tssrc/main/browser/browser-page-prompts.tssrc/main/browser/browser-screencast-cdp-events.tssrc/main/browser/browser-screencast-dialog-settlement.test.tssrc/main/browser/browser-screencast-lifecycle.test.tssrc/main/browser/browser-screencast-live-frame-allocation.test.tssrc/main/browser/browser-screencast-stream-types.tssrc/main/browser/browser-screencast-stream.test.tssrc/main/browser/browser-screencast-stream.tssrc/main/browser/offscreen-browser-backend.tssrc/main/runtime/browser-dialog-settlement.test.tssrc/main/runtime/browser-dialog-settlement.tssrc/main/runtime/browser/browser-commands.tssrc/main/runtime/browser/browser-dialogs.tssrc/main/runtime/browser/browser-screencast-contracts.tssrc/main/runtime/browser/browser-screencasts.test.tssrc/main/runtime/browser/browser-screencasts.tssrc/main/window/createMainWindow.test.tssrc/main/window/main-window-webview-security.test.tssrc/main/window/main-window-webview-security.tssrc/preload/browser-window-close.tssrc/preload/browser-window-prompt-installation.tssrc/renderer/src/components/browser-pane/browser-javascript-dialog-prompt.tssrc/renderer/src/components/browser-pane/browser-page-prompts.tsxsrc/renderer/src/components/confirmation-dialog-context.tssrc/renderer/src/components/confirmation-dialog.tsxsrc/renderer/src/i18n/locales/de.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/pt.jsonsrc/renderer/src/i18n/locales/ru.jsonsrc/renderer/src/i18n/locales/tr.jsonsrc/renderer/src/i18n/locales/zh-Hant.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/browser-javascript-dialog.tssrc/shared/browser-page-prompt.ts
Files with no reviewable changes: 5-
- src/main/browser/browser-screencast-dialog-settlement.test.ts
- src/main/browser/browser-screencast-stream-types.ts
- src/main/runtime/browser-dialog-settlement.ts
- src/main/runtime/browser/browser-screencasts.ts
- src/main/runtime/browser-dialog-settlement.test.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.
-
There was a problem hiding this comment.
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:
9b0682cb-afe2-499a-b0f9-ce2bcecd6950
Files selected for processing: 2-
src/main/browser/agent-browser-bridge-queue.tssrc/renderer/src/components/browser-pane/browser-javascript-dialog-prompt.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.
-
ELI5
When a web page in Orca's built-in browser pops up an
alert,confirmorprompt, Orca now owns that pop-up. It shows it inside Orca, tied to the page that opened it, and agents can read and answer it. Before, Electron showed its own sheet over the whole Orca window. An agent never saw the alert's text,prompt()didn't work at all, and some commands hung for a minute behind an open dialog.What Changed
Before, verified live on main:
orca evalhung for 60 s withTimed out waiting for the Orca runtime to respond.orca dialog acceptwas queued behind whatever command was stuck.prompt() is not supportedbecause Electron replaceswindow.promptin every webview frame.orca dialog acceptthen saidNo dialog is showing.After:
src/main/browser/browser-javascript-dialogs.tsreplaces Electron's private-run-dialoglistener on every browsing guest (did-attach-webview) and onorca servepages. It records the open dialog per page and answers through Electron's callback.javascript-dialogkind. It is titled with the origin of the frame that asked, so an embedded frame can't speak as the site, and a prompt has an input with its default text. These dialogs have no timeout and aren't quieted or refused like permission prompts.A JavaScript confirm is open on this page: "Delete everything?". Answer it with `orca dialog accept --page …` or `orca dialog dismiss --page …`, then retry.orca dialog accept [--text]andorca dialog dismissanswer the owner directly instead of going through the queue. An accepted prompt with no--textgets its default text, as in Chrome.AGENT_BROWSER_NO_AUTO_DIALOG=1, so alerts wait to be answered like confirms do.window.promptthat calls the nativepromptof a short-lived same-originabout:blankiframe, which Electron leaves alone. A prompt is now a real Chromium dialog, so the owner, CDP and the phone all see it.settleDialog) is removed. The card keeps showing the held dialog when a second frame's dialog is turned away.skill-guides/orca-cli/references/browser.md) lists the dialog commands and thebrowser_dialog_open/browser_dialog_openedrecoveries.Why
The root cause: no Orca component owned guest JavaScript dialogs. Electron's default handler, agent-browser's CDP auto-answer, the mobile screencast and Orca's direct-CDP
evaleach acted on the same dialog on their own.I hook Electron's embedder dialog callback because it is the one place that sees every dialog, whether or not a CDP client is attached, and its answer needs no CDP session. That also avoids the "only the reporting session can answer" problem that #21799 worked around for mobile. A CDP-events-only design would miss dialogs opened before a client attaches, and it would leave the stale native sheet.
I reused the existing page-prompt framework rather than build a new in-pane overlay as the closed community PR #11959 did. That keeps UI, IPC, preload and i18n changes small, and it is how HTTP auth and site-permission prompts already show. Thanks to @dgk-dev for #11959, which first mapped the
-run-dialogroute.Linked Issue
Fixes #17577
Visual Proof
The old native sheet can't be captured from a hidden dev build. Before, as live CLI output on main (the native "Hello alert" sheet text was read back through macOS Accessibility after the page had continued):
After:
In-app prompt (default text pre-filled) and confirm (OK focused, so Enter accepts):
Testing
Live on macOS, on a hidden dev build of this branch (
ORCA_BACKGROUND_LAUNCH=1) driven by the dev CLI:clickand througheval: each surfaces its text. Accept, dismiss andaccept --textreach the page, and an accepted prompt without text returns its default.dialog accept --page Bsays no dialog is open.click+eval, the eval fails fast. Awaitinterrupted by a delayed alert returns at once.orca servepage: confirm and alert surface and are answerable.Automated:
browser-javascript-dialogs.test.tscovers the owner.agent-browser-bridge-javascript-dialog.test.tscovers fail-fast, early answer without overtaking, commands queued behind a dialog being dropped, and SSH-host admission before dialog text is quoted. I watched each case fail without its fix.Not tested on Linux or Windows; nothing here is platform-specific.
AI Disclosure
Review
Ran
review-loop(Codex + Claude) for 4 rounds. Accepted and fixed:orca servepages had no owner;tab switchwaited behind a blocked command;The fourth round's two findings were one-line fixes, applied after it; there was no fifth round (the loop caps at four).
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Security:
window.closeguard.Cross-platform: no platform branches.
-run-dialogis the same on every OS.Remote / mixed versions: RPC shapes are unchanged:
browser.dialogAcceptandbrowser.dialogDismissstill return{ accepted }. Older CLIs and phones work unchanged. Error texts are new.Mobile: answers reach the owner through the same RPCs. The card has no text field yet, so a prompt accepted from the phone takes its default text. That is a follow-up.
Known limits / follow-ups:
prompt()onorca serveoffscreen pages still throws, because those windows have no preload.dialog acceptis no longer used.orca exec "dialog accept", Orca's record stays untilorca dialog acceptordismissclears it, or the page navigates.-run-dialogis a private event; Electron has no public hook for this.Overlap:
getBrowserJavaScriptDialogandonBrowserJavaScriptDialogOpenedare the reusable dialog state for reporting "dialog opened" in action results.To try (needs blessing: new in-app dialog UI and agent dialog behavior): build this branch (worktree
~/orca/workspaces/orca/browser-dialogs,pnpm dev) and open a browser tab on a page with<button onclick="out.textContent=confirm('Delete everything?')">, analert()and aprompt('Your name?','def')button.orca click --page <id> --element <ref>on the same buttons. The command returns the dialog's text at once, any other command on the page fails fast with it, andorca dialog accept --page <id> --text Adaanswers it and closes the in-app dialog.Product question for review: dialogs show in the app-wide prompt modal like HTTP auth and permission prompts, titled with the asking origin. Closed PR fix(browser): scope JavaScript dialogs to their page #11959 drew them inside the page's own pane instead.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)