Auto gui debug loop
Skill ChrisLamDev/cua-desktop-automation-skills/skills/auto-gui-debug-loop
Router Learning System + macOS desktop automation skills for AI agents using Cua Driver — task routing, fallback chains, self-learning history.
npx -y skills add ChrisLamDev/cua-desktop-automation-skills --skill auto-gui-debug-loopAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
General-purpose GUI debugging loop — use Cua Driver + Vision AI to automate any desktop GUI app with screenshot analysis and automated click/verify flow
SKILL.md
9.8 KB, as published. Nobody here has run it
Auto GUI Debug Loop
General-purpose GUI debugging loop — Cua Driver (macOS Accessibility) + Vision AI (screenshot analysis) for automated control of any desktop GUI app.
Flow
Cap → Vision → Act → Verify → Loop (until success or user stops)
Supported Scenarios (all tested working)
- Cocos Creator 3.8.8 (scene editing, build debug, rendering errors)
- WeChat Developer Tools (mini program simulator, console debug)
- VS Code (extension debugging, code review)
- Chrome DevTools (console, network, elements)
- macOS System Settings
- Any app with a visible GUI window
Key Learnings (2026-06-16, tested on macOS 26.5.1, M1, Cua v0.5.3)
Cua Tool Details
get_window_state(pid, window_id)→ returns BOTH accessibility tree AND base64 PNG screenshothotkey(pid, keys=["Meta","R"])— use ARRAY format for key combos (NOT string like "cmd+r")press_key(pid, key)— single key ONLY, does NOT support modifierslaunch_app()needs eitherbundle_idorname(exact macOS app name)clickneeds either(x,y)pixel coords +window_id, orelement_indexarray- Electron apps (Cocos Creator, WeChat DevTools, VS Code) — accessibility sees MenuBar only; WebView internals invisible
Error Recovery
| Failure Mode | Detection | Recovery Strategy |
|---|---|---|
| Cua hotkey timeout | No response after 5s | Retry with different window_id (Electron apps sometimes shift window IDs) |
| Cua move_cursor/click JSON parse error (Cua v0.5.3 proxy bug) | JSON parse error: expected value at line 1 column 92 | Switch to Hermes browser tool instead of Cua for that action. Cua proxy has intermittent JSON parsing failures with large window_ids or unicode titles. |
| Cua click requires both (x,y) and window_id, OR element_index array | Provide either (element_index + window_id) or (x + y). pid is always required. | Pass "x":N,"y":N for pixel coords, or "element_index":[N] for accessibility element. Both need pid + window_id. |
| Vision AI can't parse screenshot | API returns unclear result | Cap again with different window state (e.g. after a click, or switch tab first) |
| Patch fails | Lint error or file not found | Read file first, verify path, try search_files to locate. If lint is unrelated (e.g. tsc not installed), ignore it. |
| Build fails | CLI exit code != 0 | Read last 50 lines of build log, look for ERROR patterns. Cocos CLI exits with SIGTERM (code 36) on success — not a real failure. |
| DevTools not responding | get_window_state returns 0 windows | kill -9 old PID, relaunch via open -a |
| Multiple app instances | list_windows has >1 main window | Match by title string (e.g. "佛心 - 微信开发者工具"). Grep `ps aux |
| Cocos Creator project.json not updated | Build uses wrong scene | Verify startScene UUID matches expected scene. project.json scenes dict only lists known scenes — add new scenes there. |
| Google OAuth popup in headless browser | Popup opens in a new window headless can't handle | DO NOT use Hermes browser tool for Google OAuth. Instead, navigate to the service directly (e.g. github.com/login), click "Continue with Google", type email in the embedded popup, then let user type password manually. |
Vision AI Screenshot Analysis
- Screenshots are 600KB-900KB base64 PNG (from get_window_state)
- Vision AI analysis takes ~3-5 seconds per screenshot
- Can read console errors, UI element positions, button labels
- Can distinguish platform-level errors (WAService timeout) from code errors
- Can read Chinese/Cantonese text in UI
Performance Benchmarks
- Full debug loop (cap → analyze → fix → rebuild → reload → verify): ~30-60 seconds
- CLI build (Cocos Creator): 7s (lean modules) to 49s (full modules)
- Cua hotkey: ~1s
- Cua click (pixel): ~2s
- Cua get_window_state: ~3s
Cocos Creator 3.8.8 + WeChat Mini Game
Cannot set property 'w' of undefined→ Cocos engine known bug (rendering pipeline init)- Root cause:
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENTin OpenGL framebuffer setup - Disabling video/webview engine modules does NOT fix it (error is in pipeline init, not video/webview)
- Confirmed: Bootstrapper mounts successfully, 7 menu buttons created, but black screen due to rendering fail
- Build via CLI workaround:
/Applications/Cocos/Creator/3.8.8/CocosCreator.app/Contents/MacOS/CocosCreator --project . --build "platform=wechatgame" - Resolution: needs scene/engine config change, or Cocos official patch
WeChat Mini Program Debug Loop (fully verified ✅)
- Cua
get_window_state→ cap DevTools window - Vision AI → read console errors + simulator state
- Terminal → read/analyze source code (JS/WXML/WXSS)
patch→ fix source- Cua
hotkey(keys=["Meta","R"])→ reload DevTools - Cua
get_window_state→ cap new state - Vision AI → verify fix worked
- Loop if still broken
Real-World Session Log (2026-06-16)
Session covered: WeChat DevTools mini-program debug + Cocos Creator build + Vision AI analysis + GitHub repo creation.
What Actually Happened
- VS Code Extension built (0.1.0), installed via CLI
code --install-extension, tested → user decided to skip (Telegram is better workflow) - Cocos Creator project
BuddhaHeart_Gamebuilt via CLI in 42s (first), then 7s (after engine module optimization) - WeChat Developer Tools loaded the build →
Cannot set property 'w' of undefinederror (Cocos engine bug, not code) - WeChat Mini Program (BuddhaHeart_MiniApp) opened →
Error: timeoutin WAServiceMainContext (platform-level, not critical) - Vision AI successfully read Chinese/Cantonese console messages, stack traces, and simulator UI state
- Cua hotkey(keys=["Meta","R"]) works for reloading DevTools; Cua
get_window_statereturns screenshot + accessibility tree - GitHub account creation started via browser (user chose Google OAuth)
Key Technical Discoveries
- Cua v0.5.3 press_key doesn't support modifiers — always use
hotkey(keys=["Meta","R"])instead - Cocos Creator on WeChat mini game: rendering pipeline fails (
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) → black screen despite successful bootstrapper - WeChat Mini Program selectors work differently:
wx.createSelectorQuery().select('#id')can timeout if called before DOM ready — addsetTimeoutsafeguard +clearTimeoutin callback - macOS app bundle IDs: Cocos Creator =
com.cocos.creator, notcom.cocos.CocosCreator - Multiple DevTools instances: Each
open -a wechatwebdevtools --args <path>opens a separate window; old windows remain. Need to track PID.
Debug Loop Timing (real measurements)
- Hotkey reload + wait for compile: ~8s
- get_window_state capture: ~3s
- Vision AI analysis: ~5s
- Patch + lint check: ~2s
- Full loop (cap → analyze → fix → reload → verify): ~30-60s
Method Priority
- CLI command (fastest — git, build commands, npm)
- Hotkey (Cmd+R for reload, Cmd+Shift+I for DevTools)
- Accessibility click (menu bar items by element_index)
- Pixel click + Vision AI (slowest but most universal — works on any UI)
Common Pitfalls
- Cua get_window_state returns 0 windows for Electron apps — try different PIDs (main process vs renderer). The main electron process usually has windows; the renderer process may not show in list_windows.
- Vision AI can't read terminal output from screenshots (white-on-dark text in terminal is fine; but Cua cap is of GUI, not terminal) — use terminal tool directly for CLI output.
- Google OAuth popup in headless browser — the popup opens in a new window that the headless browser can't handle. Use Cua to operate the real browser instead. Even then, the user MUST type their password — the agent should navigate to the login page, fill email, then let the user handle the password field manually for security.
- Headless browser session resets between page navigations — a new
browser_navigate()call starts a fresh browser context. Google OAuth state from a previous step is lost. Complete OAuth in one continuous session, or use Cua on the real Chrome browser instead. - Cua v0.5.3 proxy JSON parse errors — intermittent failures when the cua-driver proxy can't parse JSON with unicode content. Retry the same command; it's non-deterministic.
- Multiple WeChat DevTools instances — each instance has its own PID. Track by grepping
ps aux | grep wechatdevtools | grep '--opened-file'to find which PID has which project. - Cocos Creator project.json only contains startScene — if you open a different scene (e.g., ZenScene) but startScene points to MainScene, the build will use MainScene unless you update project.json.
- WeChat DevTools compileType mismatch —
project.config.jsonmust have"compileType": "miniprogram"for mini programs,"compileType": "game"for mini games. Wrong type = blank simulator. - Dynamic require() in WeChat mini program —
require('./path/' + variable + '.js')can cause timeout errors. Use staticrequire()or wrap in try-catch. - Canvas 2D selector timeout —
wx.createSelectorQuery().select('#id').fields({node:true,size:true})called before DOM ready = timeout. Always addsetTimeoutsafeguard +clearTimeouton callback.
Checklist Before Publishing Skill
- Skill name is unique and descriptive ✓
- README explains the concept without assuming domain knowledge ✓
- All tested scenarios documented with real results ✓
- Error recovery strategies included ✓ (added)
- Version number bumped on significant changes ✓ (v1.0)
- License file included ✓ (MIT)
- Examples directory has working demo script ✓
- Technical guide covers Cua API details ✓