Files
AgentHub/docs/claude-memory/agenthub-sandbox-browser-repro.md
nntrivi2001 9c573f1e3c docs: snapshot of the project's Claude Code memory
Decisions, environment quirks and pitfalls learned while working on AgentHub
(docs/claude-memory/, indexed by MEMORY.md). Notes holding personal account
details are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 15:27:35 +07:00

22 lines
2.7 KiB
Markdown

---
name: agenthub-sandbox-browser-repro
description: "How to reproduce an AgentHub UI bug in a real browser without the user's login or tmux — isolated server + build + playwright-core"
metadata:
node_type: memory
type: reference
originSessionId: 67840be0-27b2-4b05-b307-a9a883ff5be9
modified: 2026-10-13T08:22:48.426Z
---
Both live dashboards (:4820, :4830) need a login, and the user's tmux must never be touched (see [[never-tmux-kill-server]]). Recipe used 2026-10-10:
- `~/.cache/agenthub-repro/env.sh`: HOME, DASHBOARD_DATA_DIR, TMUX_TMPDIR, AGENTHUB_SETTINGS_FILE, XDG_* all under that dir, DASHBOARD_PORT=4899, `DISABLE_AUTOUPDATER=1` (a sandboxed `claude` must not update the real install), unset TMUX/TMUX_PANE/AGENTHUB_MODE/AGENTHUB_*/CLAUDECODE. Local mode = no login.
- **`mkdir -p` the TMUX_TMPDIR first.** A missing TMUX_TMPDIR makes tmux silently fall back to the REAL default socket (2026-10-13: sandbox panes landed beside the user's `agenthub-lane-2/3`, slot numbers interleaved with theirs). After the first start, verify `<TMUX_TMPDIR>/tmux-<uid>/default` exists and `tmux -S /private/tmp/tmux-501/default ls` gained nothing. Keep it SHORT (`mktemp -d /tmp/ahp.XXXX`): a socket path over ~104 chars (the session scratchpad is) fails every `new-session`.
- macOS (this Mac): playwright-core installed in the session scratchpad; Chrome at `~/Library/Caches/ms-playwright/chromium-1228/chrome-mac-x64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing`. Route `/api/lanes/pick-path` to 403 EREMOTE in the page, or a loopback browser opens a real osascript dialog.
- Log redirects need ABSOLUTE paths (after `source env.sh`, `~` is the sandbox HOME).
- vite dev hits EMFILE (inotify) here: build instead, `vite build --outDir ~/.cache/agenthub-repro/dist`, serve with `DASHBOARD_CLIENT_DIST`.
- Workspace: `POST /api/lanes/ensure {cwd}`; panes: `POST /api/lanes/1/start {slot:"auto"}` (needs `Origin` header) → bare unauthenticated `claude` with a real `--session-id`, so Chat UI works and no quota is spent.
- Browser: `require("~/.npm/_npx/e41f203b7505f1fb/node_modules/playwright-core")` + `executablePath` `~/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome`; HTML5 drag works with `locator.dragTo`.
- A production-mode sandbox server spawns a TRAY ICON (`scripts/tray.js`) that outlives the server by design → extra icons in the macOS menu bar (2026-10-13: user saw 3). Start the sandbox with `<data dir>/runtime/tray-off` created first, or on teardown kill tray.js pids whose environ has `DASHBOARD_PORT=4899`.
- Teardown: `tmux -S <sandbox socket> kill-session -t =name` per session (list first), kill the 4899 pid only after checking its environ's DASHBOARD_DATA_DIR. Never `pkill -f` a string your own command line contains.