chromedevtools--chrome-devtools-mcp
2c16ac311b
Follow-up to #2304 (the "note" part discussed there). When the selected page disappears from the page list, `createPagesSnapshot()` silently re-selects the first page. The agent gets no signal: if its next call is `list_pages` (which is what the closed-page error message recommends), the listing already shows the new selection and every subsequent tool call runs against a page the agent never picked. This PR records the automatic fallback and surfaces it as a one-line note in the pages section of the same response: ``` ## Pages Note: the previously selected page was closed. Page 1 is now selected. 1: about:blank [selected] ``` For a selected page that is missing from the list without being closed, the note reads "is no longer listed" instead. If the expectation from #2304 holds (a page stays listed as long as it is not closed), that wording never renders; if the transient case discussed there does occur in the wild, the note will make it visible. The fallback behavior itself is unchanged (as discussed in #2304, closed tabs keep the browser-like auto-selection). No note is emitted on first connect, when nothing was selected before. Tests: two unit tests for the fallback bookkeeping (closed page, regular selection), one for the missing-but-open case via a stubbed page list, and the one affected snapshot updated (`close_page` now includes the note). Refs: #2304
52 行
3.3 KiB
Plaintext
52 行
3.3 KiB
Plaintext
exports[`pages > close_page > when dialog is open 1`] = `
|
|
{"content":[{"type":"text","text":"Note: the previously selected page was closed. Page 1 is now selected.\\n## Pages\\n1: about:blank [selected]"}],"structuredContent":{"pages":[{"id":1,"url":"about:blank","title":"","selected":true}]}}
|
|
`;
|
|
|
|
exports[`pages > list_pages > list pages for extension pages with --category-extensions 1`] = `
|
|
## Pages
|
|
1: about:blank [selected]
|
|
## Extension Pages
|
|
2: chrome-extension://<extension-id>/popup.html
|
|
`;
|
|
|
|
exports[`pages > list_pages > list pages for extension service workers with --category-extensions 1`] = `
|
|
## Pages
|
|
1: about:blank [selected]
|
|
## Extension Service Workers
|
|
sw-1: chrome-extension://<extension-id>/sw.js
|
|
`;
|
|
|
|
exports[`pages > list_pages > list pages for extension service workers without --category-extensions 1`] = `
|
|
## Pages
|
|
1: about:blank [selected]
|
|
`;
|
|
|
|
exports[`pages > list_pages > list pages for side panels with --category-extensions 1`] = `
|
|
## Pages
|
|
1: about:blank
|
|
## Extension Pages
|
|
2: Side Panel (chrome-extension://<extension-id>/sidepanel.html) [selected]
|
|
## Extension Service Workers
|
|
sw-1: chrome-extension://<extension-id>/sw.js
|
|
`;
|
|
|
|
exports[`pages > list_pages > when dialog is open 1`] = `
|
|
{"content":[{"type":"text","text":"# Open dialog\\nalert: test dialog.\\nCall handle_dialog to handle it before continuing.\\n## Pages\\n1: about:blank [selected]"}],"structuredContent":{"dialog":{"type":"alert","message":"test dialog","defaultValue":""},"pages":[{"id":1,"url":"about:blank","title":"","selected":true}]}}
|
|
`;
|
|
|
|
exports[`pages > navigate_page > when dialog is open 1`] = `
|
|
{"content":[{"type":"text","text":"Successfully navigated to data:text/html,<div>Navigated</div>.\\n# Open dialog\\nalert: test dialog.\\nCall handle_dialog to handle it before continuing.\\n## Pages\\n1: data:text/html,<div>Navigated</div> [selected]"}],"structuredContent":{"message":"Successfully navigated to data:text/html,<div>Navigated</div>.","dialog":{"type":"alert","message":"test dialog","defaultValue":""},"pages":[{"id":1,"url":"data:text/html,<div>Navigated</div>","title":"","selected":true}]}}
|
|
`;
|
|
|
|
exports[`pages > new_page with isolatedContext > when dialog is open 1`] = `
|
|
{"content":[{"type":"text","text":"# Open dialog\\nalert: test dialog.\\nCall handle_dialog to handle it before continuing.\\n## Pages\\n1: about:blank\\n2: about:blank [selected]"}],"structuredContent":{"dialog":{"type":"alert","message":"test dialog","defaultValue":""},"pages":[{"id":1,"url":"about:blank","title":"","selected":false},{"id":2,"url":"about:blank","title":"","selected":true}]}}
|
|
`;
|
|
|
|
exports[`pages > resize > when dialog is open 1`] = `
|
|
{"content":[{"type":"text","text":"# Open dialog\\nalert: test dialog.\\nCall handle_dialog to handle it before continuing.\\n## Pages\\n1: about:blank [selected]"}],"structuredContent":{"dialog":{"type":"alert","message":"test dialog","defaultValue":""},"pages":[{"id":1,"url":"about:blank","title":"","selected":true}]}}
|
|
`;
|
|
|
|
exports[`pages > select_page > when dialog is open 1`] = `
|
|
{"content":[{"type":"text","text":"# Open dialog\\nalert: test dialog.\\nCall handle_dialog to handle it before continuing.\\n## Pages\\n1: about:blank [selected]"}],"structuredContent":{"dialog":{"type":"alert","message":"test dialog","defaultValue":""},"pages":[{"id":1,"url":"about:blank","title":"","selected":true}]}}
|
|
`;
|