Skip to content

feat(browser): surface observed dialogs - #83099

Merged
steipete merged 1 commit into
mainfrom
feat/browser-observable-dialogs
May 17, 2026
Merged

steipete merged 1 commit into
mainfrom
feat/browser-observable-dialogs

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • track managed-browser modal dialogs as pending/recent browser state and expose that state through action, snapshot, and debug responses
  • let browser dialog actions answer a still-pending dialog by id while preserving arm-next-dialog behavior
  • guard dialog state with current-URL policy, reject unsupported existing-session dialog ids, and document the CLI/docs behavior

Verification

  • node scripts/run-vitest.mjs extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser/pw-session.dialogs.test.ts extensions/browser/src/browser/pw-tools-core.interactions.evaluate.abort.test.ts extensions/browser/src/browser/server.agent-contract-core.test.ts extensions/browser/src/browser/server.agent-contract-form-layout-act-commands.test.ts extensions/browser/src/browser/routes/agent.existing-session.test.ts
  • node scripts/run-vitest.mjs extensions/browser/src/browser/client.test.ts extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser/pw-session.dialogs.test.ts extensions/browser/src/browser/server.agent-contract-core.test.ts
  • git diff --check
  • env CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_TEST_PROJECTS_PARALLEL=6 OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 pnpm check:changed
  • /Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-review

Behavior addressed: Managed browser actions and snapshots now expose pending modal dialog state, and dialog actions can target a still-pending dialog id.
Real environment tested: local browser test harness and local changed gate in this checkout
Exact steps or command run after this patch: see Verification
Evidence after fix: focused dialog/control-server/browser-tool tests passed; pnpm check:changed passed for extensions, extensionTests, and docs lanes; Codex review reported no actionable findings
Observed result after fix: action-triggered dialogs return blockedByDialog with pending ids, pending dialog text is URL-policy guarded, unsupported existing-session dialog ids fail closed, and blocked AI snapshots preserve recovery state
What was not tested: live Chrome UI session; Blacksmith Testbox changed gate was blocked because the configured hydrate workflow has no testbox step, and AWS fallback was a raw box without pnpm

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL maintainer Maintainer-authored PR labels May 17, 2026
@clawsweeper

clawsweeper Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by maintainer comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors can comment @clawsweeper re-review or @clawsweeper re-run on their own open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
The PR adds managed-browser modal dialog observation, pending/recent dialog state in action/snapshot/debug responses, dialogId handling for browser dialog actions, docs, tests, and a changelog entry.

Reproducibility: yes. from source inspection: PR head 8530d2f returns browserState from /act when blockedByDialog is set, while the route is not entered with enforceCurrentUrlAllowed. The PR adds snapshot-side denied-URL coverage but not action-side coverage.

Real behavior proof
Override: A maintainer applied proof: override for this PR.

Mantis proof suggestion
A visible browser proof would help maintainers verify the managed modal-dialog flow after the security guard is fixed. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

visual task: verify managed browser alert/confirm flow returns blockedByDialog with a pending dialog id and can answer it by dialog id.

Next step before merge
Human maintainer or author follow-up is needed because the PR has a protected label and the remaining blocker is a security-sensitive browser URL-policy guard.

Security
Needs attention: The patch can expose modal dialog text from a denied current tab URL through /act.

Review findings

  • [P1] Guard blocked-dialog act responses with URL policy — extensions/browser/src/browser/routes/agent.act.ts:657-661
Review details

Best possible solution:

Keep the dialog observability feature, but gate blocked /act dialog responses with the same current-tab URL policy before returning dialog state and add a denied-current-URL regression test for that path.

Do we have a high-confidence way to reproduce the issue?

Yes, from source inspection: PR head 8530d2f returns browserState from /act when blockedByDialog is set, while the route is not entered with enforceCurrentUrlAllowed. The PR adds snapshot-side denied-URL coverage but not action-side coverage.

Is this the best way to solve the issue?

No. Surfacing observed dialogs is a reasonable feature, but the action response must fail closed or redact dialog state through current-URL policy before this is the maintainable solution.

Full review comments:

  • [P1] Guard blocked-dialog act responses with URL policy — extensions/browser/src/browser/routes/agent.act.ts:657-661
    When executeActViaPlaywright reports blockedByDialog, this route returns browserState.dialogs.pending directly even though /act is not entered with enforceCurrentUrlAllowed. That state includes dialog messages/default values, so a tab currently on a URL denied by the browser SSRF policy can still leak page content through the blocked action response; snapshot/debug paths already gate this. Check the current target URL before including dialog state, or fail closed/redact it.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.86

Security concerns:

  • [high] Dialog state can bypass current-URL policy — extensions/browser/src/browser/routes/agent.act.ts:660
    browserState.dialogs.pending includes dialog messages and optional default values, but the new blocked action response returns that state from an action route that only redacts response URLs and does not fail closed on a denied current tab URL.
    Confidence: 0.86

What I checked:

  • Protected PR label and proof override: The provided GitHub context shows this PR is open with the protected maintainer label and proof: override, so it should stay open for explicit maintainer handling and the real-behavior-proof gate is overridden. (8530d2f26b55)
  • Blocked /act response returns dialog state directly: PR head returns blockedByDialog and browserState immediately from the action route when executeActViaPlaywright reports a dialog block. (extensions/browser/src/browser/routes/agent.act.ts:657, 8530d2f26b55)
  • Current route helper distinguishes enforcement from redaction: Current main documents resolveSafeRouteTabUrl as response-only URL redaction and says execution gates should use enforceCurrentUrlAllowed; /act enters withRouteTabContext without that flag. (extensions/browser/src/browser/routes/agent.shared.ts:127, 57da466ecbb5)
  • Snapshot path was guarded, but /act was not: The PR adds a current-tab URL policy check before snapshot dialog-state collection and a denied-URL snapshot regression test, which highlights the missing equivalent guard on blocked action responses. (extensions/browser/src/browser/server.agent-contract-core.test.ts:418, 8530d2f26b55)
  • Dialog payload contains sensitive page text: The PR's observed dialog record includes message and optional defaultValue, and Playwright 1.60.0 documents that dialog listeners expose and must handle modal dialogs, so this is page content rather than a harmless status bit. (extensions/browser/src/browser/pw-session.ts:71, 8530d2f26b55)
  • Browser security/history provenance: Feature history ties this area to prior browser SSRF and action-route work: snapshot SSRF enforcement, interaction navigation guards, and the /act route contract refactor. (extensions/browser/src/browser/routes/agent.act.ts:385, f096fc440686)

Likely related people:

  • steipete: GitHub commit metadata maps the bundled browser plugin/runtime migration to this handle; that commit introduced the broad browser runtime surface now being extended, beyond this PR alone. (role: recent browser runtime contributor; confidence: high; commits: 8eeb7f082975; files: extensions/browser/src/browser/pw-session.ts, extensions/browser/src/browser/routes/agent.act.ts, extensions/browser/src/browser/routes/agent.shared.ts)
  • eleqtrizit: GitHub commit metadata maps the interaction-driven navigation guard and existing-session navigation guard work to this handle, which is adjacent to the missing policy check in this PR. (role: browser navigation guard contributor; confidence: high; commits: 049acf23cb03, 5f5b3d733bdd, daeb74920d5a; files: extensions/browser/src/browser/pw-tools-core.interactions.ts, extensions/browser/src/browser/routes/agent.act.ts)
  • pgondhi987: GitHub commit metadata maps the snapshot/screenshot/tab SSRF enforcement commit to this handle; the PR reuses that policy boundary for snapshots but misses it on /act. (role: browser SSRF route contributor; confidence: medium; commits: b75ad800a590; files: extensions/browser/src/browser/routes/agent.snapshot.ts)
  • joshavant: GitHub commit metadata maps the /act route action execution and contract error refactor to this handle, making them relevant for routing the blocked-action response fix. (role: action route refactor contributor; confidence: medium; commits: f096fc440686; files: extensions/browser/src/browser/routes/agent.act.ts)

Remaining risk / open question:

  • I did not execute the PR's test commands in this read-only review; the blocking verdict is based on source inspection of the latest public diff and current main.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 57da466ecbb5.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9532dc686

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +657 to +660
if (result.blockedByDialog) {
return await jsonOk({
blockedByDialog: true,
browserState: result.browserState,

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.

P1 Badge Guard blocked-dialog act responses with URL policy

When executeActViaPlaywright reports blockedByDialog, this branch returns browserState directly even though /act does not enforce enforceCurrentUrlAllowed. In environments with SSRF/navigation policy enabled, a request against a disallowed current tab URL can still return dialog text from that page via browserState.dialogs.pending, which leaks blocked-page content that snapshot/debug routes explicitly guard against.

Useful? React with 👍 / 👎.

@steipete steipete added the proof: override Maintainer override for the external PR real behavior proof gate. label May 17, 2026
@steipete
steipete force-pushed the feat/browser-observable-dialogs branch from f9532dc to 8530d2f Compare May 17, 2026 22:59
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. labels May 17, 2026
@steipete
steipete merged commit 7afac60 into main May 17, 2026
124 of 126 checks passed
@steipete
steipete deleted the feat/browser-observable-dialogs branch May 17, 2026 23:05
@steipete

Copy link
Copy Markdown
Contributor Author

Landed in 7afac60.

Verification:

  • Local focused browser tests: node scripts/run-vitest.mjs extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser/pw-session.dialogs.test.ts extensions/browser/src/browser/pw-tools-core.interactions.evaluate.abort.test.ts extensions/browser/src/browser/server.agent-contract-core.test.ts extensions/browser/src/browser/server.agent-contract-form-layout-act-commands.test.ts extensions/browser/src/browser/routes/agent.existing-session.test.ts — 6 files, 116 tests passed.
  • Local changed gate: env CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_TEST_PROJECTS_PARALLEL=6 OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 pnpm check:changed — passed.
  • GitHub checks on rebased head 8530d2f26b555c598a8bd65141d0f9ac047a4fc3 — passed, including Real behavior proof with maintainer override, check, check-additional, check-prod-types, check-test-types, check-additional-extension-package-boundary, and Critical Quality network runtime boundary.

Known proof gap: no live Chrome UI session; Testbox wrapper was unavailable for this checkout before local/CI proof.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8530d2f26b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1630 to +1633
const dialogAbort = createObservedDialogAbortSignalForPage({
page,
parentSignal: opts.signal,
});

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.

P1 Badge Let close actions bypass dialog-block abort signal

executeActViaPlaywright now wraps all actions with createObservedDialogAbortSignalForPage, which aborts immediately when any pending dialog exists. That means act with kind: "close" never reaches closePageViaPlaywright and instead returns blockedByDialog, so a tab can get stuck in a modal state with no /act close recovery path (notably the tool uses /act close when no targetId is provided). Please bypass the dialog abort guard for close (or run close before installing that signal) so users can always dismiss a wedged tab.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: override Maintainer override for the external PR real behavior proof gate. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant