Phase 2: Enhanced browser — dialog handling, upload, state checks, snapshots

- CircularBuffer O(1) ring buffer for console/network/dialog (was O(n) array+shift)
- Async buffer flush with Bun.write() (was appendFileSync)
- Dialog auto-accept/dismiss with buffer + prompt text support
- File upload command (upload <sel> <file...>)
- Element state checks (is visible/hidden/enabled/disabled/checked/editable/focused)
- Annotated screenshots with ref labels overlaid (-a flag)
- Snapshot diffing against previous snapshot (-D flag)
- Cursor-interactive element scan for non-ARIA clickables (-C flag)
- Snapshot scoping depth limit (-d N flag)
- Health check with page.evaluate + 2s timeout
- Playwright error wrapping — actionable messages for AI agents
- Fix useragent — context recreation preserves cookies/storage/URLs
- wait --networkidle / --load / --domcontentloaded flags
- console --errors filter (error + warning only)
- cookie-import <json-file> with auto-fill domain from page URL
- 166 integration tests (was ~63)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-03-12 13:33:43 -07:00
parent 3d901066cd
commit f3ebd0adbf
16 changed files with 2007 additions and 157 deletions
+10
View File
@@ -14,6 +14,16 @@ export function startTestServer(port: number = 0): { server: ReturnType<typeof B
hostname: '127.0.0.1',
fetch(req) {
const url = new URL(req.url);
// Echo endpoint — returns request headers as JSON
if (url.pathname === '/echo') {
const headers: Record<string, string> = {};
req.headers.forEach((value, key) => { headers[key] = value; });
return new Response(JSON.stringify(headers, null, 2), {
headers: { 'Content-Type': 'application/json' },
});
}
let filePath = url.pathname === '/' ? '/basic.html' : url.pathname;
// Remove leading slash