Skip to content

feat: auto handle dialogs during script evaluation#1792

Closed
Lightning00Blade wants to merge 10 commits intomainfrom
feat/auto-handle-dialogs-script-eval-14699412192638290372
Closed

feat: auto handle dialogs during script evaluation#1792
Lightning00Blade wants to merge 10 commits intomainfrom
feat/auto-handle-dialogs-script-eval-14699412192638290372

Conversation

@Lightning00Blade
Copy link
Copy Markdown
Collaborator

@Lightning00Blade Lightning00Blade commented Apr 1, 2026

Fixes #919 by automatically accepts dialogs, when actions happen due to Script exection.

@google-labs-jules

This comment was marked as outdated.

Lightning00Blade and others added 6 commits April 2, 2026 15:16
Added a new option `dialog` to `waitForEventsAfterAction` to automatically handle dialogs that trigger during execution. We hardcode it to `'accept'` for the `evaluate_script` tool so that `alert()` or `confirm()` don't block and timeout script evaluation.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Moved `dialogHandler` inside the `if (options?.dialog)` block to avoid unnecessarily declaring it when it is not needed. Also imported the correct `Dialog` type from Puppeteer.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Removed the unnecessary type cast by typing `#page` properly as `Page`. Casts to `CdpPage` are now isolated to where `_client()` is required.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Reverted the type of `#page` back to `CdpPage` and handled the `Dialog` compatibility issue locally using `@ts-expect-error` instead of a cast.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@Lightning00Blade Lightning00Blade force-pushed the feat/auto-handle-dialogs-script-eval-14699412192638290372 branch from bdfc5aa to 95d377b Compare April 2, 2026 13:18
@Lightning00Blade Lightning00Blade requested a review from OrKoN April 2, 2026 13:20
Lightning00Blade and others added 4 commits April 2, 2026 15:21
Replaced `alert()` with `setTimeout(() => alert(), 10)` in `script.test.ts` to prevent headless Chromium deadlocks during `evaluate` in CI environments. Additionally added `.catch(logger)` when resolving dialog actions to prevent unhandled promise rejections if the dialog closes too quickly or fails.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Removed `test_dialog.js`, `test_dialog.mjs`, and `test_dialog2.mjs` which were accidentally left in the workspace and caused `npm run check-format` to fail.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Updated README.md formatting to match latest requirements to fix `check-format` CI job.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@Lightning00Blade Lightning00Blade deleted the feat/auto-handle-dialogs-script-eval-14699412192638290372 branch April 9, 2026 08:53
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.

Configure dialog behavior for script evaluation

1 participant