From 5c64ecde080aaf4f0fe59b3f27a122a6fb448732 Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Sat, 22 Nov 2025 14:52:51 +0100 Subject: [PATCH] better logs for maps and sets --- extension/src/relayConnection.ts | 18 ++++++++++++++++-- playwriter/src/prompt.md | 8 ++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/extension/src/relayConnection.ts b/extension/src/relayConnection.ts index 5ec1b6d..5a98892 100644 --- a/extension/src/relayConnection.ts +++ b/extension/src/relayConnection.ts @@ -53,6 +53,20 @@ function safeSerialize(arg: any): string { if (typeof value === 'object' && value !== null) { if (seen.has(value)) return '[Circular]'; seen.add(value); + + if (value instanceof Map) { + return { + dataType: 'Map', + value: Array.from(value.entries()) + }; + } + + if (value instanceof Set) { + return { + dataType: 'Set', + value: Array.from(value.values()) + }; + } } return value; }); @@ -394,7 +408,7 @@ export class RelayConnection { // // To fix this, we intercept 'Runtime.enable' and force a reset: // 1. We send 'Runtime.disable'. This clears Chrome's internal Runtime state for this session. - // 2. We wait a brief moment (50ms) to ensure the disable command propagates. + // 2. We wait a brief moment (100ms) to ensure the disable command propagates. // 3. Then we allow the original 'Runtime.enable' command to proceed. // // This sequence forces Chrome to treat the enablement as a fresh start, causing it to @@ -404,7 +418,7 @@ export class RelayConnection { logger.debug('Runtime.enable called, disabling first to force context refresh for tab:', targetTab.debuggee.tabId); try { await chrome.debugger.sendCommand(debuggerSession, 'Runtime.disable'); - await new Promise(resolve => setTimeout(resolve, 50)); + await new Promise(resolve => setTimeout(resolve, 100)); } catch (e) { logger.debug('Error disabling Runtime (ignoring):', e); } diff --git a/playwriter/src/prompt.md b/playwriter/src/prompt.md index 1adc498..6838ce7 100644 --- a/playwriter/src/prompt.md +++ b/playwriter/src/prompt.md @@ -21,6 +21,14 @@ the chrome window can have more than one page. you can see other pages with `con you can control the browser in collaboration with the user. the user can help you get unstuck from captchas or difficult to find elements or reproducing a bug +## capabilities + +examples of things playwriter MCP can do: +- monitor logs for a page while the user reproduces a but to let you understand what is causing a bug +- monitor logs while also controlling the page, then read collected logs and debug an issue +- monitor xhr network requests while scrolling an infinite scroll page to extract data from a website +- get accessibility snapshot to see clickable elements on the page, then click or interact with them to automate a task like ordering pizza + ## finding the page to execute code in if you plan to control a specific page for an url you can store it in `state` so you can reuse it later on: