/platform-frontend:bytedesk-browser-test [route or task description]from platform-frontend
Drive the ByteDesk web app through real Chrome via the `agent-browser` CLI to prove frontend changes actually render and behave correctly before they ship. Required for every PR that touches `src/ByteDesk.Web/**`. Covers login, navigation, snapshot-and-ref interaction, screenshot capture, console/error inspection, network/HAR/trace capture, React DevTools, web vitals, mobile/PWA smoke, and tab management. Invoke for "browser test", "smoke the UI", "agent-browser", "render check", "frontend smoke", or whenever a PR's diff touches a `.tsx`, `.ts`, `.css`, `.json` under `src/ByteDesk.Web/`.
Ships in platform-frontend. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Wraps the agent-browser CLI for the ByteDesk local stack:
workflow-smoke by default) against the local cluster./login.The skill is the only sanctioned way to exercise the UI from a PR-ready or feature-work skill. The raw CLI is fine for ad hoc exploration, but anything that influences a ship/land decision must go through this skill so login + screenshot + console capture happen consistently.
agent-browser is installed globally on the host; no per-repo install is required. Verify with:
agent-browser --help
If the CLI is missing, install once with npm i -g agent-browser && agent-browser install. Never run npm install agent-browser inside this repo.
| Setting | Value |
|---|---|
| Base URL | http://platform.bytedesk.localhost |
| Admin email | [email protected] |
| Admin password | Admin123! |
| Session name | workflow-smoke (override per task with --session <name>) |
The admin credentials are dev-only; production access flows through Identity + Infisical and never through this skill. Do not point the skill at platform.bytedesk.ai without removing the hardcoded password first.
When the smoke follows a land/roll (or any source-mount change), the web pod is mid-rollout: the old pod is terminating and the new one is still recompiling. Navigating immediately hits stale code or a not-yet-recompiled server and fails the gate for the wrong reason. Before the first open, block on the freshly-rolled pod being Ready:
# Re-resolve the pod by label AFTER the roll (the mid-roll selector can miss it),
# then wait for Ready with a bounded timeout. Next.js dev still needs a few
# seconds to compile the first route after Ready — give it a short warm-up.
microk8s kubectl -n bytedesk rollout status deployment/web --timeout=180s
microk8s kubectl -n bytedesk wait --for=condition=Ready pod \
-l app.kubernetes.io/name=web --timeout=180s
sleep 5 # first-route compile warm-up
If the page still shows a transient error on the first hit, reload once after a short wait before treating it as a failure — a single warm-up reload is expected, a persistent error is a real block.
# 1. Open + (re)use a named session — survives across commands
agent-browser open --headed --session workflow-smoke http://platform.bytedesk.localhost/office/workflows
# 2. See what's on the page — only interactive elements, much smaller than full tree
agent-browser --session workflow-smoke snapshot -i
# 3. Act on a ref from the snapshot. Refs (@e1, @e2, ...) are re-assigned every
# snapshot and become stale the moment the DOM changes — re-snapshot before
# every ref interaction.
agent-browser --session workflow-smoke click @e3
# 4. Verify
agent-browser --session workflow-smoke screenshot /tmp/after-click.png
agent-browser --session workflow-smoke errors # page errors
agent-browser --session workflow-smoke console # console log
Use these rules for /office/workflows/**, React Flow, inspector tabs, and any
headed smoke after a long-running agent session.
DISPLAY=:0 when a resumed shell has no display. Local Xorg is :0;
older Xvfb displays like :97/:98 may exist but are not the default headed
browser target.snapshot -i before the first fill/click in a new session.
Fresh sessions do not know refs yet, and fill @e4 before a snapshot fails
with Unknown ref.eval that
finds elements by exact textContent/role over stale refs. Ref-clicks drift
during hot reloads.scripts/dev/workflow.mjs status must show localDev.repoRoot pointing at
the intended worktree, or run scripts/dev/workflow.mjs use-localdev --services web.scripts/dev/workflow.mjs sync-develop-runtime --roll web
before blaming the component.bytedesk-source; check it when the
pod serves code from the wrong checkout.@eN text in logs. Some snapshots print ref=e4 instead of
@e4; read the snapshot content and pick by label/text.Use this mode for Office Chat, customer portal, mobile navigation, installable PWA behavior, service worker changes, badges, and notification UI.
scripts/dev/workflow.mjs status
eval after open.
SESSION=bdp-mobile-1234
URL=http://platform.bytedesk.localhost/office/chat
DISPLAY=:0 agent-browser open --headed --session "$SESSION" "$URL"
agent-browser --session "$SESSION" eval "window.resizeTo(390, 844)"
TMP=/tmp/pr-smoke/$SESSION
mkdir -p "$TMP"
agent-browser --session "$SESSION" screenshot "$TMP/mobile.png"
agent-browser --session "$SESSION" errors > "$TMP/errors.txt"
agent-browser --session "$SESSION" console > "$TMP/console.txt"
errors.txt is empty.If the mobile UI still reflects old code after merge, run
scripts/dev/workflow.mjs sync-develop-runtime --roll web, wait for Web, and
repeat the smoke before debugging component code.
When the URL bounces to /login after open, log in once at the start of the session:
SESSION=workflow-smoke
agent-browser --session $SESSION snapshot -i > /tmp/login-refs.txt
# Read the refs for the two textboxes (EMAIL, PASSWORD) and the SIGN IN button
# from the snapshot — they are typically @e4 / @e5 / @e2 but DO NOT hardcode.
EMAIL_REF=$(grep -oE '@e[0-9]+' /tmp/login-refs.txt | head -1) # placeholder
PWD_REF=$(grep -oE '@e[0-9]+' /tmp/login-refs.txt | sed -n '2p') # placeholder
BTN_REF=$(grep -oE '@e[0-9]+' /tmp/login-refs.txt | sed -n '3p') # placeholder
# In practice: read the snapshot output and pick the correct refs by their
# accessible label (`textbox "EMAIL"`, `textbox "PASSWORD"`, `button "SIGN IN"`).
agent-browser --session $SESSION fill @e4 [email protected]
agent-browser --session $SESSION fill @e5 'Admin123!'
agent-browser --session $SESSION click @e2
sleep 3
agent-browser --session $SESSION get url # confirm /dashboard
The session keeps the auth cookie + bearer in the running Chrome instance, so subsequent navigations (open against any other URL in the same --session) do not re-prompt.
Every PR-gating smoke must capture at minimum the screenshot and the errors stream. Add console when chasing a parse/runtime bug; add vitals when chasing performance regressions; add react renders when chasing a re-render storm.
Interpreting the result (BDP-1491): PASS = the target route rendered (screenshot shows the expected UI, the post-nav URL is right) and the errors stream is empty. A non-empty errors stream, a page crash, or an unexpected /login bounce is a real FAIL — surface the captured errors + screenshot path in the PR body. Do not read a non-zero process exit code as a failure when errors is empty and the page rendered: an empty === ERRORS === block is a PASS regardless of exit code. The screenshot + errors stream are the source of truth, not the shell exit status.
agent-browser --session $SESSION screenshot /tmp/<route>.png
agent-browser --session $SESSION errors # JS errors on this page
agent-browser --session $SESSION console --clear # discard noise
agent-browser --session $SESSION console # capture for diagnosis
agent-browser --session $SESSION snapshot -i # see what's interactable
agent-browser --session $SESSION get text @e7 # read a node's text
agent-browser --session $SESSION get url # confirm post-nav URL
agent-browser --session $SESSION network requests --filter "/api/" > /tmp/api.log
agent-browser --session $SESSION vitals --json # LCP/CLS/INP/TTFB/FCP
agent-browser --help)Use this as the lookup index; always run agent-browser <command> --help for current flags before composing a long sequence.
| Verb | Purpose |
|---|---|
open <url> | Launch + navigate. Aliases: goto, navigate. Flags: --headed, --session, --headers <json>, --init-script, --enable react-devtools. |
click <sel> / dblclick <sel> | Click / double-click. <sel> accepts CSS or @ref. |
type <sel> <text> / fill <sel> <text> | Type into / clear-and-fill an input. |
press <key> | Send a key chord: Enter, Tab, Control+a, etc. |
keyboard type <text> / keyboard inserttext <text> | Raw keystrokes / insertion without key events. |
hover / focus / check / uncheck / select <sel> <val…> | Pointer + form-control helpers. |
drag <src> <dst> | Drag and drop between refs. |
upload <sel> <files…> / download <sel> <path> | File I/O. |
scroll <dir> [px] / scrollintoview <sel> | Viewport movement. |
wait <sel|ms> | Wait for element or timeout. Also wait --load networkidle|domcontentloaded|load. |
screenshot [path] / pdf <path> | Captures. |
snapshot | Accessibility tree with refs. -i filters to interactive elements only. |
eval <js> | Run JS in the page. Returns the last expression. |
connect <port|url> | Attach via CDP to an external Chrome. |
close [--all] | Tear down the active session (or every session). |
| Verb | Purpose |
|---|---|
back / forward / reload | Standard history controls. |
pushstate <url> | Next.js / SPA client-side nav (uses window.next.router.push when present, else history.pushState + popstate). |
agent-browser get <what> [selector] — text, html, value, attr <name>, title, url, count, box, styles, cdp-url.
agent-browser is <what> <selector> — visible, enabled, checked.
agent-browser find <locator> <value> <action> [text] — locators: role, text, label, placeholder, alt, title, testid, first, last, nth.
agent-browser mouse <action> — move <x> <y>, down [btn], up [btn], wheel <dy> [dx].
agent-browser set <setting> — viewport <w> <h>, device <name>, geo <lat> <lng>, offline [on|off], headers <json>, credentials <user> <pass>, media [dark|light] [reduced-motion].
agent-browser network <action> — route <url> [--abort|--body <json>] [--resource-type <csv>], unroute [url], requests [--clear] [--filter <pattern>], har <start|stop> [path].
cookies [get|set|clear] — set supports --url, --domain, --path, --httpOnly, --secure, --sameSite, --expires; or cookies set --curl <file> for cURL / JSON / Cookie-header dumps.storage <local|session> — get/set keys in localStorage / sessionStorage.agent-browser tab [new|list|close|<n>] — manage tabs in the running browser.
diff snapshot — compare current accessibility tree against the last snapshot.diff screenshot --baseline <path> — pixel-diff vs a baseline image.diff url <u1> <u2> — compare two pages.trace start|stop [path], profiler start|stop [path], record start <path> [url] / record stop, console [--clear], errors [--clear], highlight <sel>, inspect (open DevTools), clipboard <op> [text].
stream enable [--port <n>] / stream disable / stream status — runtime WebSocket streaming.
open --enable react-devtools)react tree — full component tree.react inspect <id> — props, hooks, state, source for one fiber.react renders start / react renders stop [--json] — re-render profile via onCommitFiberRoot.react suspense [--only-dynamic] [--json] — Suspense boundary report.agent-browser vitals [url] [--json] — LCP, CLS, TTFB, FCP, INP + React hydration timing when a profiling build is detected.
agent-browser skills [list] / skills get <name> [--full] / skills path [name] — the upstream skill catalog (electron, slack, vercel-sandbox, agentcore, dogfood, core). This ByteDesk skill wraps those; do not re-document them, just delegate when needed:
agent-browser skills get core --full # full upstream usage guide
agent-browser skills get dogfood --full # exploratory bug hunt patterns
bytedesk-pr-ready runs this skill automatically whenever the PR diff touches any of:
src/ByteDesk.Web/**
The smoke must:
src/ByteDesk.Web/src/app/(app)/<route>/page.tsx → URL /<route>)./tmp/pr-smoke/<BDP-N>/<route>.png.agent-browser errors per route — any non-empty errors stream blocks the ship.If the local cluster isn't reachable (agent-browser open 5xx / 502 / ECONNREFUSED), STOP — do not ship. Surface the cluster outage instead.
| Route | Notes |
|---|---|
/dashboard | Default post-login landing. |
/office/workflows | Library page (DB-backed admin list). |
/office/workflows/library/<id> | Detail page — renders WorkflowSurface mode="read". |
/office/workflows/library/<id>/edit | Editor — mounts WorkflowEditor + Architect sidebar. |
/office/workflows/runs/<runId> | Run mode — live SignalR via workflow:<id>:run:<runId>. |
/office/workflows/trigger-tester | Trigger-phrase tester. |
/office/workflows/analytics?window=7d | Per-workflow run analytics. |
/dev/components | Atomic-design catalog (use to verify new atoms render). |
Every invocation owns a unique --session <name> and writes temp artifacts under a session-scoped directory. Before returning (success, failure, or interruption) the skill must leave zero leaked Chrome processes.
Stop any recorders:
agent-browser --session "$SESSION" har stop 2>/dev/null || true
agent-browser --session "$SESSION" trace stop 2>/dev/null || true
agent-browser --session "$SESSION" profiler stop 2>/dev/null || true
agent-browser --session "$SESSION" record stop 2>/dev/null || true
Close the session normally:
agent-browser --session "$SESSION" close 2>/dev/null || true
Aggressive Chrome process tree kill (this is the new rule added to stop the 45+ leaked instances problem):
pkill -9 -f "user-data-dir.*${SESSION}" 2>/dev/null || true
pkill -9 -f "/tmp/agent-browser-chrome-" 2>/dev/null || true
# Nuclear option for this session only (use when the above is insufficient)
# pkill -9 -f "agent-browser.*chrome" 2>/dev/null || true
Remove the temp directory:
rm -rf "/tmp/pr-smoke/$SESSION"
SESSION="laptop-stability-2026"
TMP="/tmp/pr-smoke/$SESSION"
mkdir -p "$TMP"
cleanup() {
agent-browser --session "$SESSION" har stop 2>/dev/null || true
agent-browser --session "$SESSION" trace stop 2>/dev/null || true
agent-browser --session "$SESSION" profiler stop 2>/dev/null || true
agent-browser --session "$SESSION" record stop 2>/dev/null || true
agent-browser --session "$SESSION" close 2>/dev/null || true
# Hard kill of any leaked Chrome trees for this session (critical after 2026 memory crisis)
pkill -9 -f "user-data-dir.*${SESSION}" 2>/dev/null || true
pkill -9 -f "/tmp/agent-browser-chrome-" 2>/dev/null || true
rm -rf "$TMP"
}
trap cleanup EXIT INT TERM
# ... your smoke steps ...
Preferred global tool: Use scripts/dev/browser-reaper.sh (created as part of the laptop stability work) when you want to clean up leaks outside of a single smoke:
# Dry run (safe)
scripts/dev/browser-reaper.sh
# Actually kill everything leaked by agent-browser
scripts/dev/browser-reaper.sh --force
# Target one specific previous session
scripts/dev/browser-reaper.sh --session laptop-stability-2026 --force
Exception for artifacts: When a smoke produces a failure screenshot the PR body needs, copy it to a durable location before the trap runs, then let cleanup finish.
The old "just call close + rm -rf" pattern is no longer sufficient. The aggressive pkill step (or the dedicated reaper script) is now mandatory.
@eN refs across commands — they reset on every snapshot. Always re-snapshot, then re-pick.npm install agent-browser inside this repo — host CLI only.alert()/confirm() — they block the extension and stall the session. Use console.log + read_console_messages style instead.--session <name> per BDP key.SESSION=bdp-1234
URL=http://platform.bytedesk.localhost/office/workflows/library/<workflow-id>
TMP=/tmp/pr-smoke/$SESSION
mkdir -p "$TMP"
# Cleanup on any exit
cleanup() {
agent-browser --session "$SESSION" har stop 2>/dev/null || true
agent-browser --session "$SESSION" trace stop 2>/dev/null || true
agent-browser --session "$SESSION" profiler stop 2>/dev/null || true
agent-browser --session "$SESSION" record stop 2>/dev/null || true
agent-browser --session "$SESSION" close 2>/dev/null || true
rm -rf "$TMP"
}
trap cleanup EXIT INT TERM
# 1. Open + login if bounced
agent-browser open --headed --session "$SESSION" "$URL"
if agent-browser --session "$SESSION" get url | grep -q '/login'; then
agent-browser --session "$SESSION" snapshot -i # read EMAIL / PASSWORD / SIGN IN refs
# use the actual refs printed above:
agent-browser --session "$SESSION" fill @e4 [email protected]
agent-browser --session "$SESSION" fill @e5 'Admin123!'
agent-browser --session "$SESSION" click @e2
sleep 3
agent-browser --session "$SESSION" open "$URL"
fi
# 2. Capture (write under $TMP so the trap removes it)
agent-browser --session "$SESSION" screenshot "$TMP/detail.png"
agent-browser --session "$SESSION" errors > "$TMP/errors.txt"
agent-browser --session "$SESSION" console > "$TMP/console.txt"
# 3. Decide. On failure, copy the screenshot somewhere durable before the trap nukes $TMP.
if [ -s "$TMP/errors.txt" ]; then
cp "$TMP/detail.png" "$HOME/$SESSION-failure.png"
echo "BLOCK: page errors — screenshot: $HOME/$SESSION-failure.png"
cat "$TMP/errors.txt"
exit 1
fi
echo "OK — smoke green ($TMP/detail.png will be cleaned up on exit)"
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub bytedeskai/bytedesk-marketplace --plugin platform-frontend4 skills in this plugin
/bytedesk-atomizeByteDesk UI componentization skill using atomic design. Invoke this skill whenever the user wants to extract inline JSX into atoms/molecules/organisms, refactor large page files into smaller components, componentize any area of the ByteDesk frontend, apply atomic design principles to the application, extract repeated patterns into shared components, or clean up a page that's grown too large. Also invoke for "componentize this", "extract this into a component", "break this page into atoms", "apply atomic design to X", "componentize the UI", "run atomize on sales", or any phrasing around structuring the frontend by atomic design layers. Run this over and over until the entire UI is componentized. Use agents to attack different domains in parallel. When in doubt, invoke this rather than doing componentization work directly — it enforces the right placement rules and design system constraints./bytedesk-designByteDesk design system expert and source of frontend design truth. Use for ByteDesk UI/UX design work: component critique, token compliance, layout, visual hierarchy, atomic composition, micro-interactions, Framer Motion, and the Mission Control dark workspace aesthetic. Invoke for design, UI layout, component choice, animation patterns, design-system compliance, or requests to make a page or component look better.