* fix(browser): harden existing-session driver validation, session lifecycle, and code quality Fix config validation rejecting existing-session profiles that lack cdpPort/cdpUrl (they use Chrome MCP auto-connect instead). Fix callTool tearing down the MCP session on tool-level errors (element not found, script error), which caused expensive npx re-spawns. Skip unnecessary CDP port allocation for existing-session profiles. Remove redundant ensureChromeMcpAvailable call in isReachable. Extract shared ARIA role sets (INTERACTIVE_ROLES, CONTENT_ROLES, STRUCTURAL_ROLES) into snapshot-roles.ts so both the Playwright and Chrome MCP snapshot paths stay in sync. Add usesChromeMcp capability flag and replace ~20 scattered driver === "existing-session" string checks with the centralized flag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(browser): harden existing-session driver validation and session lifecycle (#45682) (thanks @odysseus0) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
64 lines
1.2 KiB
TypeScript
64 lines
1.2 KiB
TypeScript
/**
|
|
* Shared ARIA role classification sets used by both the Playwright and Chrome MCP
|
|
* snapshot paths. Keep these in sync — divergence causes the two drivers to produce
|
|
* different snapshot output for the same page.
|
|
*/
|
|
|
|
/** Roles that represent user-interactive elements and always get a ref. */
|
|
export const INTERACTIVE_ROLES = new Set([
|
|
"button",
|
|
"checkbox",
|
|
"combobox",
|
|
"link",
|
|
"listbox",
|
|
"menuitem",
|
|
"menuitemcheckbox",
|
|
"menuitemradio",
|
|
"option",
|
|
"radio",
|
|
"searchbox",
|
|
"slider",
|
|
"spinbutton",
|
|
"switch",
|
|
"tab",
|
|
"textbox",
|
|
"treeitem",
|
|
]);
|
|
|
|
/** Roles that carry meaningful content and get a ref when named. */
|
|
export const CONTENT_ROLES = new Set([
|
|
"article",
|
|
"cell",
|
|
"columnheader",
|
|
"gridcell",
|
|
"heading",
|
|
"listitem",
|
|
"main",
|
|
"navigation",
|
|
"region",
|
|
"rowheader",
|
|
]);
|
|
|
|
/** Structural/container roles — typically skipped in compact mode. */
|
|
export const STRUCTURAL_ROLES = new Set([
|
|
"application",
|
|
"directory",
|
|
"document",
|
|
"generic",
|
|
"grid",
|
|
"group",
|
|
"ignored",
|
|
"list",
|
|
"menu",
|
|
"menubar",
|
|
"none",
|
|
"presentation",
|
|
"row",
|
|
"rowgroup",
|
|
"table",
|
|
"tablist",
|
|
"toolbar",
|
|
"tree",
|
|
"treegrid",
|
|
]);
|