Skip to content

fix(mcp): clear dialog modal state when dialog is closed out of band - #42032

Merged
Dmitry Gozman (dgozman) merged 2 commits into
microsoft:mainfrom
dgozman:fix-41837-mcp
Jul 29, 2026
Merged

fix(mcp): clear dialog modal state when dialog is closed out of band#42032
Dmitry Gozman (dgozman) merged 2 commits into
microsoft:mainfrom
dgozman:fix-41837-mcp

Conversation

@dgozman

Copy link
Copy Markdown
Collaborator

Summary

  • Listen to the new dialogclosed event in the MCP tab and clear the matching dialog modal state, so dialogs closed outside of browser_handle_dialog (e.g. manually by the user in a headed browser) no longer leave a phantom modal state behind.
  • Add a test that closes the dialog through a CDP side-channel.

Fixes #41837

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Listen to the new "dialogclosed" event and clear the matching modal
state, so that dialogs closed outside of the "browser_handle_dialog"
tool, e.g. manually by the user in the headed browser, do not leave
a phantom modal state behind.

Fixes: microsoft#41837
The mcp server observes the dialog closure through its own cdp
connection, with no ordering guarantee relative to the test's
side-channel connection, so poll until the modal state clears.
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

2 failed
❌ [firefox] › mcp/cli-core.spec.ts:179 › dialog-dismiss @mcp-windows-latest-firefox
❌ [webkit] › mcp/http.spec.ts:104 › http transport browser lifecycle (isolated) @mcp-ubuntu-latest-webkit

7813 passed, 1272 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

🟢 Both failures are pre-existing flakes — the PR is clear

Hi, I'm the Playwright bot — I triaged the CI failures on the latest run.

Neither failure is this PR's own new test (dialog closed out of band passes now; 7813 passed). Both are known flakes that fail the same way on SHAs this PR can't be responsible for.

Details

Overall: the two failures in the latest merged report are both proven pre-existing flakes on unrelated code paths. This PR only wires a dialogclosed listener into tab.ts; its own added test passes on every bot it runs on.

Pre-existing flake / infra

Caused by this PR

  • None.

Uncertain

  • None.

Triaged by the Playwright bot — agent run.

Triaged by the Playwright bot - agent run

@dgozman
Dmitry Gozman (dgozman) merged commit 887b421 into microsoft:main Jul 29, 2026
16 of 18 checks passed
Yury Semikhatsky (yury-s) added a commit to microsoft/playwright-mcp that referenced this pull request Aug 6, 2026
## What's New

### Tool Improvements

- **`browser_take_screenshot` — WebP format** — New `type` option to
pick the image format (`png`, `jpeg` or `webp`); when unset, the format
is inferred from the filename extension
([#41152](microsoft/playwright#41152))
- **`--codegen` — more languages** — Code generation now supports
`python`, `java` and `csharp` in addition to `typescript`
([#42106](microsoft/playwright#42106))
- **Configurable settle delay** — New `--timeout-settle` flag (and
`timeouts.settle` config option) to control how long to wait after each
action for triggered work (navigations, requests) to settle, defaults to
500ms ([#41924](microsoft/playwright#41924))

## Fixes

- Aria snapshot capture is skipped when the response discards it
([#41923](microsoft/playwright#41923))
- New `--snapshot-boxes` flag (and `snapshot.boxes` config option) to
enable bounding boxes in snapshots globally — previously this was only
available per command
([#42102](microsoft/playwright#42102))
- Reconnect to the browser after a disconnect
([#41966](microsoft/playwright#41966))
- Report malformed JSON config instead of silently falling back to INI
parsing ([#41909](microsoft/playwright#41909))
- Clear the dialog modal state when a dialog is closed out of band
([#42032](microsoft/playwright#42032))
- Detect downloads via the download event instead of guessing from
`net::ERR_ABORTED` navigation errors
([#41933](microsoft/playwright#41933))
- Surface the missing executable path when a browser isn't installed
([#41941](microsoft/playwright#41941))
- Escape user input in codegen output
([#41962](microsoft/playwright#41962))
- Removed the stale `--output-mode` CLI option
([#41833](microsoft/playwright#41833))

### Browser Extension

- Validate `Host` and `Origin` headers on CDP relay WebSocket upgrades
([#42103](microsoft/playwright#42103))
- Launch the Chrome profile that has the extension installed
([#41939](microsoft/playwright#41939))
- Pass `noDefaults` for extension CDP connections
([#42119](microsoft/playwright#42119))
- Mention `PLAYWRIGHT_MCP_EXECUTABLE_PATH` in the error shown when the
browser executable is not found
([#42122](microsoft/playwright#42122))
- Removed support for extension protocol v1
([#41857](microsoft/playwright#41857))
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.

[BUG] Dialogs dismissed by user in headed mode are not considered dismissed

2 participants