📝 docs(testing): clarify electron dev app targeting

This commit is contained in:
Arvin Xu
2026-06-13 20:12:07 +08:00
parent aa903406ee
commit b5122dcea2
2 changed files with 38 additions and 16 deletions
+4
View File
@@ -306,4 +306,8 @@ agent-testing/
- agent-browser: see [references/agent-browser.md](./references/agent-browser.md#gotchas)
- Electron: see [ui/electron.md](./ui/electron.md#electron-gotchas)
- **Electron dev app is not `LobeHub`** — do not drive desktop dev validation with
`osascript tell application "LobeHub"` or by selecting the installed product app.
Start/attach through `electron-dev.sh` + CDP, and verify the renderer target,
worktree, and branch before sending input.
- osascript: see [references/osascript.md](./references/osascript.md#gotchas)
+34 -16
View File
@@ -30,6 +30,12 @@ After `start` succeeds, connect with: `agent-browser --cdp 9222 snapshot -i`
**Always run `$SCRIPT stop` when done testing**`pkill -f "Electron"` alone won't catch all helper processes.
**Do not attach by macOS app name `LobeHub` for dev testing.** The installed
product app may be named `LobeHub`, but the development Electron instance is
not that app. Driving `osascript tell application "LobeHub"` can silently
target the wrong instance, worktree, or branch. Use CDP (`agent-browser --cdp
9222`) and `app-probe.sh` as the source of truth.
#### Environment Variables
| Variable | Default | Description |
@@ -47,26 +53,26 @@ instead of hand-rolling `__LOBE_STORES` eval snippets** for these common needs:
```bash
PROBE=".agents/skills/agent-testing/scripts/app-probe.sh"
$PROBE auth # login check (Step 0.3) → { isSignedIn, userId }
$PROBE route # current SPA route
$PROBE ops # running chat operations (type / startTime)
$PROBE goto /settings # jump the SPA straight to a route (full reload)
$PROBE errors-install # install console.error interceptor
$PROBE errors # dump captured errors
$PROBE auth # login check (Step 0.3) → { isSignedIn, userId }
$PROBE route # current SPA route
$PROBE ops # running chat operations (type / startTime)
$PROBE goto /settings # jump the SPA straight to a route (full reload)
$PROBE errors-install # install console.error interceptor
$PROBE errors # dump captured errors
```
`goto` lets a test enter the state under test directly instead of clicking
through the UI. Common desktop routes:
| Route | Where it lands |
| ----------------------------- | ------------------------------------ |
| `/` | Home (has a chat input) |
| `/agent/<agentId>` | Agent conversation (latest topic) |
| `/agent/<agentId>/<topicId>` | Specific topic in a conversation |
| `/task` · `/task/<taskId>` | Task list / task detail |
| `/page` | Documents (文稿) |
| `/settings` | Settings |
| `/community` | Discover / community |
| Route | Where it lands |
| ---------------------------- | --------------------------------- |
| `/` | Home (has a chat input) |
| `/agent/<agentId>` | Agent conversation (latest topic) |
| `/agent/<agentId>/<topicId>` | Specific topic in a conversation |
| `/task` · `/task/<taskId>` | Task list / task detail |
| `/page` | Documents (文稿) |
| `/settings` | Settings |
| `/community` | Discover / community |
Targets default to Electron (`--cdp 9222`); set `AB_TARGET="--session <name>"`
for web sessions. For deeper or one-off state inspection, fall back to raw
@@ -140,15 +146,27 @@ agent-browser --cdp 9222 eval "JSON.stringify(window.__CAPTURED_ERRORS)"
## Electron Gotchas
- **Always use `electron-dev.sh stop` to clean up** — `pkill -f "Electron"` only kills the main process; helper processes (GPU, renderer, network) survive. The script finds and kills all of them via PID matching against the project's electron binary path.
- **Dev app name is not `LobeHub`** — local desktop validation must target the
Electron dev instance started by `electron-dev.sh`, usually via CDP on port
`9222`. Do not use `tell application "LobeHub"` for dev validation; that can
activate an installed app or another worktree. If OS-level capture/control is
unavoidable, first enumerate windows and verify the process/window, current
route or topic, bottom-bar repo, and branch. Any mismatch means the UI test is
blocked, not passed.
- **`npx electron-vite dev` must run from `apps/desktop/`** — running from project root fails silently. The `electron-dev.sh` script handles this automatically.
- **Dev build auto-opens DevTools, which hijacks the CDP target** — `agent-browser --cdp 9222` may attach to the DevTools page (`devtools://…`) instead of the app (`app://renderer/`). Symptom: `get url` returns a `devtools://` URL. Fix: close the DevTools target and reconnect:
```bash
DT_ID=$(curl -s http://localhost:9222/json/list | python3 -c "import json,sys; ts=json.load(sys.stdin); print(next(t['id'] for t in ts if t['type']=='page' and t['url'].startswith('devtools://')))")
curl -s "http://localhost:9222/json/close/$DT_ID" > /dev/null
agent-browser close --all && agent-browser --cdp 9222 get url # expect app://renderer/
agent-browser close --all && agent-browser --cdp 9222 get url # expect app://renderer/
```
- **Don't resize the Electron window after load** — resizing triggers full SPA reload
- **Store is at `window.__LOBE_STORES`** not `window.__ZUSTAND_STORES__`
- **Streaming / ticking UI needs GIF evidence** — see `scripts/record-gif.sh`; a static screenshot cannot prove time-based behavior.