feat: add dialog detection and document dialog commands (#999)
Fixes #992 When a JavaScript dialog (alert/confirm/prompt) blocks the page, agents had no way to detect it — all commands just timed out with generic errors. - Add `dialog status` command to check for pending dialogs - Track dialog state via CDP Page.javascriptDialogOpening/Closed events - Auto-inject `warning` field into all command responses when a dialog is pending, so agents can distinguish dialog-blocked timeouts from other issues - Document dialog commands in SKILL.md (was missing entirely), README.md, docs site, and --help output Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
This commit is contained in:
@@ -177,6 +177,12 @@ agent-browser clipboard write "Hello, World!" # Write text to clipboard
|
||||
agent-browser clipboard copy # Copy current selection
|
||||
agent-browser clipboard paste # Paste from clipboard
|
||||
|
||||
# Dialogs (alert, confirm, prompt)
|
||||
agent-browser dialog accept # Accept dialog
|
||||
agent-browser dialog accept "my input" # Accept prompt dialog with text
|
||||
agent-browser dialog dismiss # Dismiss/cancel dialog
|
||||
agent-browser dialog status # Check if a dialog is currently open
|
||||
|
||||
# Diff (compare page states)
|
||||
agent-browser diff snapshot # Compare current vs last snapshot
|
||||
agent-browser diff snapshot --baseline before.txt # Compare current vs saved file
|
||||
@@ -522,6 +528,26 @@ agent-browser wait 5000
|
||||
|
||||
When dealing with consistently slow websites, use `wait --load networkidle` after `open` to ensure the page is fully loaded before taking a snapshot. If a specific element is slow to render, wait for it directly with `wait <selector>` or `wait @ref`.
|
||||
|
||||
## JavaScript Dialogs (alert / confirm / prompt)
|
||||
|
||||
When a page opens a JavaScript dialog (`alert()`, `confirm()`, or `prompt()`), it blocks all other browser commands (snapshot, screenshot, click, etc.) until the dialog is dismissed. If commands start timing out unexpectedly, check for a pending dialog:
|
||||
|
||||
```bash
|
||||
# Check if a dialog is blocking
|
||||
agent-browser dialog status
|
||||
|
||||
# Accept the dialog (dismiss the alert / click OK)
|
||||
agent-browser dialog accept
|
||||
|
||||
# Accept a prompt dialog with input text
|
||||
agent-browser dialog accept "my input"
|
||||
|
||||
# Dismiss the dialog (click Cancel)
|
||||
agent-browser dialog dismiss
|
||||
```
|
||||
|
||||
When a dialog is pending, all command responses include a `warning` field indicating the dialog type and message. In `--json` mode this appears as a `"warning"` key in the response object.
|
||||
|
||||
## Session Management and Cleanup
|
||||
|
||||
When running multiple agents or automations concurrently, always use named sessions to avoid conflicts:
|
||||
|
||||
Reference in New Issue
Block a user