Repository navigation
Handle out-of-band dialog closes to unblock snapshots - #151
Conversation
Mirror microsoft/playwright#42032: listen for the dialogclosed page event and clear the matching dialog modal state, so an out-of-band dismissal (manual close in headed mode, CDP side-channel) no longer leaves a phantom modal state that blocks every snapshot-bearing tool. The event ships in Playwright 1.63; on the pinned 1.61.1 (and current stable 1.62.0, which predates the upstream branch cut) the listener is registered but never fires, which is harmless — it activates automatically on the next Playwright bump. The listener is registered through the tracked listen() helper so dispose() removes it on shared CDP contexts. Fixes #150 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014k8at4qpjdQnMfRVXX7Xz8
Update the pinned codegen command in README.md and SKILL.md to match (enforced by the tools-axe docs-sync test), and refresh the dialogclosed comment in tab.ts to reference the new pin. The dialogclosed event itself remains a 1.63+ feature, so that listener stays inert on 1.62.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014k8at4qpjdQnMfRVXX7Xz8
|
Warning Review limit reached
Next review available in: 20 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughPlaywright references and dependencies are updated to 1.62.0. ChangesDialog lifecycle synchronization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3941fa039d
ℹ️ 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".
| "playwright": "1.62.0", | ||
| "playwright-core": "1.62.0", |
There was a problem hiding this comment.
Pin a version that emits dialogclosed
When a dialog is dismissed manually or through a CDP side channel—the scenario this change is intended to fix—the pinned Playwright 1.62.0 runtime never emits dialogclosed (as the new comment in src/tab.ts also notes). Consequently, the new listener cannot clear the stale modal state and snapshot-bearing tools remain blocked. Pin both Playwright packages to a version that provides this event, such as 1.63+, or implement a fallback supported by 1.62.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 4ac5499, taking the fallback option rather than the version bump: dialogclosed only exists in 1.63.0-alpha builds (it merged upstream after the 1.62 branch cut — verified against the published npm packages, including the 1.62.1 betas), so pinning a version that emits it would mean shipping an alpha in a stable package.
The fallback works on the pinned 1.62.0: an out-of-band-closed dialog fails accept()/dismiss() with Protocol error (Page.handleJavaScriptDialog): No dialog is showing (or the already handled client-side guard on a repeat), both verified against 1.62.0 Chromium. browser_handle_dialog now treats those as a successful close — it reports the dialog as already closed and the modal state stays cleared, so snapshot-bearing tools unblock. A real-browser test in tests/tools-dialogs.test.ts reproduces the full scenario via a CDP side-channel close. The dialogclosed listener stays in place and takes over as the immediate path once the pin reaches 1.63+.
Generated by Claude Code
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Around line 53-54: Upgrade playwright and playwright-core in package.json to
the next release supporting Page.on('dialogclosed'), retain the listener in
src/tab.ts, and add real Playwright coverage for out-of-band dialog closure in
tests/tab.test.ts. Update the pinned codegen command versions in README.md and
SKILL.md to match the upgraded dependency version.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 583ab15b-332b-4db0-af88-41f60ba9d1a2
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
README.mdSKILL.mdpackage.jsonsrc/tab.tstests/tab.test.ts
…ight Address review feedback on the dialogclosed listener being inert on 1.62.0 (the event ships in 1.63, which has no stable release yet): browser_handle_dialog now treats the two errors an already-closed dialog produces (the 'No dialog is showing' protocol error and the 'already handled' client-side guard, both verified against 1.62.0 Chromium) as a successful close, reporting the dialog as already closed instead of failing. The modal state is cleared either way, so the session recovers on the pinned version; the event listener takes over once Playwright is bumped to 1.63+. Adds unit coverage for the fallback and a real-browser test that reproduces the phantom-dialog scenario end to end: a CDP side-channel closes the dialog behind the tab's back, snapshots show only the stale dialog state, and browser_handle_dialog unblocks the session. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014k8at4qpjdQnMfRVXX7Xz8
Summary
Adds support for handling dialogs that close out-of-band (e.g., dismissed manually in headed mode or via CDP side-channel) by listening to the
dialogclosedevent introduced in Playwright 1.62.0. This prevents stale dialog modal states from blocking snapshot-bearing tools indefinitely.Changes
_dialogClosed()handler that removes dialog modal state when adialogclosedevent is emitted, matching the dialog instance to ensure only the correct dialog state is clearedImplementation Details
The
dialogclosedlistener is registered alongside the existingdialoglistener. When a dialog closes out-of-band, the handler finds the matching modal state by comparing both the type and dialog instance, then clears it. This approach safely handles edge cases like multiple concurrent dialogs and ignores close events for dialogs that were never tracked.https://claude.ai/code/session_014k8at4qpjdQnMfRVXX7Xz8
Summary by CodeRabbit
Bug Fixes
Documentation
Maintenance