Ao desktop dev

From gabrielmoreira/agent-skills-mirror · View interactive version

Ao desktop dev is an AI agent skill from the GitHub repository gabrielmoreira/agent-skills-mirror. Launch, restart, or troubleshoot the real AO Electron desktop app from this repository; run a checkout against isolated or real local AO data; combine PR branches for local UI review; and diagnose stale Electron processes, port conflicts, or preload bridge mismatches. Use whenever asked to run, open

How to use this skill

Skill file

AO Desktop Dev

Run the Electron application from the current checkout and verify it in the native window. Keep the dev daemon, renderer, Electron preload, and selected data mode explicit so the user never reviews a mock or stale build by accident.

Choose the data mode

Ask only when the request does not make the desired data source clear.

Preflight

  1. Work from the repository root and inspect git status --short --branch.
  2. Read frontend/package.json, frontend/src/main.ts, and frontend/forge.config.ts when the launch behavior may have changed. Treat source as authoritative over this skill.
  3. Confirm Node/npm and the Go version required by backend/go.mod are available. Before every launch, run npm run dev:warm in frontend/. It clones a cached real install for an identical lockfile (or runs npm ci) and restores cached predev outputs, so a fresh checkout is ready in seconds and an already-warm one is a no-op. It ends with ready for npm run dev. If it fails, report the error and fall back to npm ci.
  4. Check for an existing dev instance from this exact checkout before starting another. Do not kill by process name alone, and never terminate every Electron process.

On macOS/Linux, inspect checkout-scoped processes and listeners with finite commands:

ps -axo pid=,ppid=,pgid=,lstart=,command= | rg 'frontend/(node_modules/.bin/electron-forge|node_modules/electron/dist/Electron)'
lsof -nP -iTCP:3002 -sTCP:LISTEN

Use the full command paths and start times to distinguish this checkout from other AO worktrees. On Windows, use Get-CimInstance Win32_Process and Get-NetTCPConnection; preserve the same exact-target rule.

Launch the app

Keep Electron Forge's output and restart input available: run it in a foreground interactive process, or, on macOS/Linux, in a tmux session on its own socket (the default below) so you can read its log and send rs. Do not append &, use a bare detached shell, or start a browser preview instead.

Isolated mode (default)

Give each checkout its own data directory, run file, Electron profile and port, so it never collides with another worktree's dev app or with the installed app. On macOS/Linux, from the repository root after npm run dev:warm:

NAME=$(basename "$(git rev-parse --show-toplevel)" | tr ".:" "--")
BASE=$HOME/.ao/dev/run-$NAME
PORT=$(for p in $(seq 3500 3599); do lsof -nP -iTCP:$p -sTCP:LISTEN >/dev/null || { echo $p; break; }; done)
mkdir -p "$BASE"
cd frontend
tmux -L ao-dev new-session -d -s "$NAME" \
  "env -u AO_SESSION_ID AO_DATA_DIR=$BASE/data AO_RUN_FILE=$BASE/running.json AO_DEV_ELECTRON_DIR=$BASE/electron AO_PORT=$PORT npm run dev 2>&1 | tee $BASE.log"

Wait for Launched Electron app and daemon listening on $PORT in $BASE.log (about 25 s from a warm checkout). Restart the main process with tmux -L ao-dev send-keys -t "$NAME" rs Enter. Report the branch, port and data directory.

Without tmux, or on Windows, run Forge in the foreground with the shared isolated dev paths instead:

cd frontend
env -u AO_DATA_DIR -u AO_RUN_FILE -u AO_PORT npm run dev

On PowerShell:

Set-Location frontend
Remove-Item Env:AO_DATA_DIR, Env:AO_RUN_FILE, Env:AO_PORT -ErrorAction SilentlyContinue
npm run dev

Real-data mode

First resolve and report the actual data directory. In an AO worker session, AO_DATA_DIR normally already identifies it. Otherwise the repository default is the absolute path corresponding to ~/.ao/data.

Keep the real data directory but remove inherited port/run-file overrides so the dev app retains its own daemon handshake and port:

cd frontend
env -u AO_RUN_FILE -u AO_PORT AO_DATA_DIR="${AO_DATA_DIR:-$HOME/.ao/data}" npm run dev

PowerShell equivalent:

Set-Location frontend
$realAoData = if ($env:AO_DATA_DIR) { $env:AO_DATA_DIR } else { Join-Path $HOME ".ao/data" }
Remove-Item Env:AO_RUN_FILE, Env:AO_PORT -ErrorAction SilentlyContinue
$env:AO_DATA_DIR = $realAoData
npm run dev

Do not print unrelated environment variables: Orchestrator-managed sessions may carry credentials. It is safe to report only AO_DATA_DIR, AO_RUN_FILE, and AO_PORT.

Confirm the correct app is ready

Wait for all of these signals:

If several AO windows exist, identify the newest Electron main process belonging to this checkout. On macOS, foreground that exact PID only when needed:

osascript -e 'tell application "System Events" to set frontmost of first process whose unix id is <verified-pid> to true'

Do not claim real data from appearance alone. Verify the selected data directory and successful API responses. Do not claim visual success from compilation alone; interact with the requested flow in Electron or ask the user for a screenshot when screen capture is unavailable.

Reload changes correctly

After a restart, confirm the new Electron PID/start time and re-check the logs for the original error.

Preview multiple PRs locally

When the user wants to see multiple unmerged PRs together:

  1. Require a clean worktree and fetch each PR head.
  2. Create a clearly named local-only integration branch using the session/repository branch convention.
  3. Merge or cherry-pick the requested PR heads without rewriting or pushing either source branch.
  4. Resolve overlaps according to the requested combined behavior and run focused typechecks/tests.
  5. Let renderer changes hot reload; restart Electron if either PR changes main/preload/IPC code.
  6. State that the integration branch is local-only. Do not push it unless the user explicitly requests a combined PR.

Once one PR merges, prefer rebasing the remaining PR onto current main; the normal PR branch then contains both views without a local integration merge.

Stop without collateral damage

  1. Send Ctrl+C to the dev process (tmux -L ao-dev send-keys -t "$NAME" C-c for the default launch) and wait briefly for Electron and its managed daemon to exit. Then kill the tmux session with tmux -L ao-dev kill-session -t "$NAME".
  2. Re-run the checkout-scoped process query. If the exact process group remains, identify the group created by this launch before sending TERM to that group.
  3. On Windows, terminate the verified parent tree only. Never use a broad Electron, Node, Go, or port-based kill.
  4. Confirm the captured Electron PID and dev daemon listener are gone. Leave installed AO and other worktrees untouched.

Common mistakes

singleton lock lives in the profile, so a second checkout's npm run dev

loses requestSingleInstanceLock() and exits immediately with code 0. To run

two worktrees at once, give each its own daemon port, profile, run file, and

data dir:

```bash

AO_PORT=<free-port> \

AO_DEV_ELECTRON_DIR="$HOME/.ao/dev/<name>/electron" \

AO_RUN_FILE="$HOME/.ao/dev/<name>/running.json" \

AO_DATA_DIR="$HOME/.ao/dev/<name>/data" \

npm run dev

```

Without all four the instances still collide, on the profile lock, the run

file, the daemon's SQLite data, or the daemon port: with AO_PORT unset

every dev instance uses 3002, and the one that starts second shuts down the

first one's daemon to take the port.

Completion report

Report:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.