feat(browser-test): persistence + screenshots + smarter AI loop (v0.7.9) #19
Reference in New Issue
Block a user
Delete Branch "release/v0.7.9"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
4 problèmes utilisateur sur la fonctionnalité Tests pilotés par l'IA
Bug 1 + 2 — connexion perdue à chaque reload / nouvelle page
Cause : token à usage unique (
ConsumeTokensupprimait le token à la 1ʳᵉ connexion) + TTL 5 min.Fix :
ConsumeTokenrefresh la TTL au lieu de supprimer)ws.onclose→setTimeout(connect, 500 * retry)avec backoff (max ~2,5s). Couvre les drops transitoires.Bug 3 — captures d'écran
Nouvelle action
screenshot:foreignObject+ canvas → base64 PNG~/.muyue/screenshots/<filename>.png(nom personnalisable viafilename, sinon timestamp)Bug 4 — l'IA boucle sur 150 appels
Cause : la stratégie disait
list_clickables → click → list_clickables → click → ...à chaque action. Liste de 50+ éléments × 30 itérations = explosion du contexte.Fix :
<browser_test_strategy>re-écrite dans le system prompt Studio :list_clickablesaprès chaque clicsummarycheap,evalciblé >list_clickablescomplet)clickretourneelement not foundInclut aussi v0.7.8 (PR #18)
unsafe.Pointer(uintptr(hPC))au lieu deunsafe.Pointer(&hPC)dansUpdateProcThreadAttribute— corrige les terminaux Windows qui s'ouvraient en fenêtre externe (régression v0.7.6). Cherry-pick depuis PR #18 ; PR #18 peut être fermée après merge de celui-ci.Versioning
Test plan
selector, fichier sauvé dans~/.muyue/screenshots/User reported regression introduced in v0.7.6: PowerShell / cmd open in a separate external console window instead of attaching to the xterm.js tab (v0.7.5 worked). Root cause: the ConPTY wiring used attrList.Update(PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, unsafe.Pointer(&hPC), // ← wrong unsafe.Sizeof(hPC)) The PSEUDOCONSOLE attribute is a Win32 API quirk: lpValue must be the HPCON *value* (cast to PVOID), not a pointer to the local variable holding the handle. With &hPC the kernel reads garbage, silently drops the attribute, and CreateProcessW spawns the child with a fresh console — hence the external window. Fix is one line: unsafe.Pointer(uintptr(hPC)) Confirmed against Microsoft's EchoCon sample and Go libraries that work in production (UserExistsError/conpty, aymanbagabas/go-pty). - internal/version/version.go: 0.7.7 → 0.7.8 - CHANGELOG.md: v0.7.8 entry with the diagnostic write-upFour user-reported issues with the AI-driven browser test feature: 1. WS dies on every page reload / navigation (token was single-use, 5 min TTL → AI loses session permanently). 2. AI can't see new pages opened by its actions (same root cause). 3. No screenshot capability — AI cannot capture page state visually. 4. AI burns ~150 tool calls for what's 5 human actions, mostly list_clickables loops. Fixes: - Token sliding TTL (60 min): ConsumeToken no longer deletes the token; it refreshes its expiration on each successful WS connect. Same token survives reload / re-paste / navigation as long as there's no 60-min idle gap. - Snippet auto-reconnect: WS onclose schedules reconnect with 500ms × attempt backoff (max ~2.5s). Handles transient drops, server restarts, and WS hiccups without user intervention. Full navigation kills the JS context and is unrecoverable from JS — but the user just re-pastes the snippet, same token works. - New 'screenshot' action: snippet captures via SVG foreignObject + canvas → base64 PNG → sent back over the existing WS reply channel. Server decodes and writes to ~/.muyue/screenshots/ <filename>.png (sanitized name, timestamp default). Filename characters limited to a safe charset to prevent path escape. Best-effort: external CSS / cross-origin images / iframes won't inline. - Studio system prompt rewritten <browser_test_strategy>: - Explicit rule: don't list_clickables after every click - Action cost table (cheap vs expensive) - When to re-list (URL change, dialog, click-not-found only) - Standard final report format ✓ / ✗ / ⚠ / 📸 Also bundles v0.7.8 (cherry-picked): unsafe.Pointer(uintptr(hPC)) instead of unsafe.Pointer(&hPC) in UpdateProcThreadAttribute, so PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE is correctly applied and the spawned shell attaches to the embedded xterm.js instead of opening a separate external console window (regression fix from v0.7.6). - internal/api/browsertest.go: token sliding, screenshot save, param schema, snippet rewrite, helpers - internal/agent/prompts/studio_system.md: strategy rewrite - internal/version/version.go: 0.7.7 → 0.7.9 - CHANGELOG.md: v0.7.9 entry covering all fixesPull request closed