Skip to content

Handle out-of-band dialog closes to unblock snapshots - #151

Merged
JustasMonkev merged 3 commits into
mainfrom
claude/mcp-accessibility-150-ccp2r9
Jul 30, 2026
Merged

JustasMonkev merged 3 commits into
mainfrom
claude/mcp-accessibility-150-ccp2r9

Conversation

@JustasMonkev

@JustasMonkev JustasMonkev commented Jul 30, 2026 •

Copy link
Copy Markdown
Owner

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 dialogclosed event introduced in Playwright 1.62.0. This prevents stale dialog modal states from blocking snapshot-bearing tools indefinitely.

Changes

  • src/tab.ts: Added _dialogClosed() handler that removes dialog modal state when a dialogclosed event is emitted, matching the dialog instance to ensure only the correct dialog state is cleared
  • tests/tab.test.ts: Added comprehensive test suite covering:
    • Dialog modal state creation and clearing
    • Snapshot unblocking after out-of-band close
    • Multiple concurrent dialogs (only closes the matching one)
    • Ignoring close events for untracked dialogs
    • Preserving non-dialog modal states
    • No-op behavior when no modal states exist
    • Proper listener cleanup on dispose
  • package.json: Updated Playwright and Playwright Core from 1.61.1 to 1.62.0
  • README.md & SKILL.md: Updated codegen command examples to reference Playwright 1.62.0

Implementation Details

The dialogclosed listener is registered alongside the existing dialog listener. 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

    • Fixed lingering dialog state after dialogs are closed outside normal snapshot handling, preventing subsequent modal-sensitive actions from remaining blocked.
    • Ensured closing one dialog does not affect other dialogs or unrelated modal states.
  • Documentation

    • Updated Playwright recording examples and instructions to use version 1.62.0.
  • Maintenance

    • Updated Playwright runtime packages to version 1.62.0.

claude added 2 commits July 30, 2026 03:41
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
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@JustasMonkev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 69d7c2fe-356a-4452-9895-5e836aa58a4f

📥 Commits

Reviewing files that changed from the base of the PR and between 3941fa0 and 4ac5499.

📒 Files selected for processing (4)
  • README.md
  • src/tab.ts
  • src/tools/dialogs.ts
  • tests/tools-dialogs.test.ts
📝 Walkthrough

Walkthrough

Playwright references and dependencies are updated to 1.62.0. Tab now clears dialog modal state when dialogs close through Playwright’s dialogclosed event, with tests covering lifecycle, filtering, and disposal behavior.

Changes

Dialog lifecycle synchronization

Layer / File(s) Summary
Playwright version alignment
package.json, README.md, SKILL.md
Playwright and Playwright Core pins and storage-state recording examples are updated from 1.61.1 to 1.62.0.
Out-of-band dialog cleanup
src/tab.ts, tests/tab.test.ts
Tab handles dialogclosed events by removing matching dialog modal state; tests cover unblocking snapshots, multiple dialogs, ignored closes, preserved non-dialog state, no-op behavior, and disposal cleanup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: claude

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main behavioral change: handling out-of-band dialog closes to unblock snapshots.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/mcp-accessibility-150-ccp2r9

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: 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".

Comment thread package.json
Comment on lines +53 to +54
"playwright": "1.62.0",
"playwright-core": "1.62.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c122ad3 and 3941fa0.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • README.md
  • SKILL.md
  • package.json
  • src/tab.ts
  • tests/tab.test.ts

Comment thread package.json Resolved
…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
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.

2 participants