# Devices Your iOS simulators and Android emulators in a Herdr side panel, with a live screen you can tap and swipe while your agent drives the same device. Connected iPhones and Android phones are listed too, most recently used first. Hover a device for Boot, Shut down and Screenshot. The menu adds Open URL, Run Maestro flow, Copy id, Stop app and Erase. Each row shows the device's state and the app it is running. Run Maestro flow opens a picker of the project's flows, remembers the last one and its variables, and runs it in a pane below. A second tag names the agent driving the device; clicking it jumps to that agent. ![Devices](preview.png) ## What you see One column on the `background` color, base type 13px in `foreground`. Top to bottom: - **Header**, 42px, 14px side padding, 1px `border` underneath. "Devices" at 13px semibold on the left. On the right a 24px Refresh button (radius 6, `hover` under the pointer) with a 14px refresh icon in `muted`; while the first read, a Refresh or a panel Screenshot/Copy/URL action runs, a 14px ring spinner in `muted` (Herdr's `mods/workspace-chrome/spinner.svg`, `.spin(900)`) takes its place. Background polls never show it. - **Filter field**, not in the rail: 38px in all, 8px side padding, 8px above and 2px below a 28px input (8px inner side padding, radius 7, 1px `border`, `accent` while it has the keyboard, `background` fill, 12px `foreground`), placeholder `Filter devices…`. Outside the list, so the list's click doesn't pull the keyboard back. See Filter. - **The list**, scrolling with a scrollbar, 8px bottom padding: - **Section headers** like Files' folders: 26px, 14px side padding, 6px above, 6px gaps: a 12px chevron in `dim` (Herdr's `mods/files/chevron-down.svg`, `chevron-right.svg` when folded), the title at 11px semibold `dim` (`iOS 26.5`, `Android`), and the section's device count at 11px in `dim` at 60% (`dim` + `99`). First `Running` (see Order and fold), when anything runs. Then one section per simulator runtime (`com.apple.CoreSimulator.SimRuntime.iOS-26-5` reads `iOS 26.5`; `xrOS` reads `visionOS`), iOS first then watchOS, tvOS, visionOS, newest version first; then Android. These hold only off devices; one left with none goes, unless it has an empty or error line. The count is the rows the section lists. - **Running rows**, outside the rail, 40px, the same margins, padding, slots and gaps, the glyph centered on the row. Then a column: line 1 (24px) the name as below and the icons at the right edge; line 2 (16px, 11px `dim`, 8px gaps, clipped) under the name: the detail (a simulator's section title, `iOS 26.5`; an iPhone's `iOS 26.1 · USB`; Android's `API 36`, `emulator`, `USB`, `Wi-Fi`), then `· booting…` (or another phase), then the app tag and the agent tag(s) (`runningDetail`). `selected` and `hover` fill the whole 40px. - **Rows** (off devices), 26px, 6px outer side margin, 4px right padding, radius 6, 8px gaps, 12.5px type. Left to right: a 2px wide, 14px tall bar slot (drawn empty: reserved for a per-space color later), a 14px icon slot, the name (truncated; `muted`: an off device), then a claim's agent tag (see Claims), then on the right, just before the icons, the secondary at 11px `dim` (never truncated: an AVD's `API 36`, `emulator` for an unknown AVD; a simulator's version is its section's title, so none), and the icons at the right edge, dim until the pointer is over them. The clicked row is `selected`; `hover` under the pointer. Rows carry no tint of their own. The **app tag** (Running rows only, see Apps): 16px tall, 5px side padding, radius 4, `done` at 12% (`done` + `1f`) behind 10.5px medium `done` text, at most 96px wide (truncated); the agent tag (see Drivers, Claims) has the same shape (the claim pill on a Running row: 200px at most). - **Icons** (Lucide, in `icons/`): by the device's name, `tablet` (iPad, Tablet, Fold, Pad), `watch` (Watch, Wear), `tv` (TV, Television), `glasses` (Vision), else `smartphone`. Booted/online the icon is `foreground` with a 7px `done` dot (1.5px `background` border) over its bottom-right corner, 3px out to the right and 2px down; off it is `dim`. Booting/stopping a 13px spinning ring in `working` takes its place; offline, unauthorized and other adb states a 12px filled triangle in `blocked`. - **Hover icons**, at most five, 24px squares, radius 5, `raised` under the pointer, 13px icons in `muted`: Shut down (power) when on or Boot (play) when off — simulators and AVDs, not during a phase, except Shut down while `booting` cancels the boot (a simulator always, an AVD once it has a serial); Show screen (monitor) when on and not in a phase, where there is a screen to read; Screenshot (camera) when on; More (three dots) always. - **Fold row** under a section that has more than it shows: 24px, 32px left padding (the text lines up with the names), 11.5px `muted`, `Show all (N)`, and `Show fewer` once open. - **Empty and error lines**, centered, 12px, 8px vertical padding: the text in `dim`, a `dim` `·`, and one `accent` link: `xcrun not found · Get Xcode`, `No simulators · Open Xcode`, simctl's error `· Retry`, `adb not found · Set ANDROID_HOME` (also `emulator not found`), an adb error `· Retry`, `No emulators or devices · Open Android Studio`. `Loading devices…` before the first read when nothing is cached. - **Footer**, 28px, 14px side padding, 1px `border` above, 11px `dim`, truncated: `5 simulators · 1 emulator` (only the kinds there are; `No devices` when none); `· refreshed 2m ago` (or `1h ago`) only once the last read is a minute old, as when the reads stall. - **Rail**: narrower than 160px, the header holds only Refresh (centered), each section is a 1px `border` line with 6px above and below (Running's first), rows show only the icon, centered, 26px, Running's too, with ` · booted` (or `off`, `booting…`, the adb state) as a tooltip, and there are no hover icons, fold rows, filter field or footer. Typed filter text is ignored there. **The menu** is a 250px popup at the pointer on `popover`, 5px padding, its height 30px per item, 9px per divider, plus 38px: a 24px line with the device's name at 11px `dim`, then 30px rows (radius 7, 9px gap, a 14px icon in `muted`, 12.8px text), `selected` for the keyboard choice, `hover` under the pointer; a hint at 11px `dim` after the label names the panel's key: `space` on Boot and Shut down, `S` on Screenshot. Items, in sections parted by a 1px `border` line (8px side margin, 4px above and below): Shut down or Boot | Screenshot and `Open URL…` (when on) | `Run Maestro flow…` and `Run again` | `Release claim` (when the device is claimed) | `Copy app id` and a `Stop ` per app (when on with a known app) | `Copy UDID` / `Copy serial` / `Copy name` | `Erase…` in `ansi1` (icon and text). Without `maestro` installed `Run Maestro flow…` is a `dim` row (icon and text) with a `not installed` hint in the key hints' place, no hover or click. An empty section leaves no divider. Boot and Shut down close it at once (the row spins); Screenshot reads `Working…` while it runs. **Dialogs** are 420px wide (Open URL 200px tall, Erase 212px) on `popover`, 18px padding, 10px gaps, like Herdr's prompt and confirm: a 15px semibold title (`Open URL` or `Erase ?`) with `Esc` at 11px `dim` on the right, a `muted` sentence (Erase's leads with the cost: `Removes every app and its data on .`, an AVD's adding `; it starts like new`, then how), for Open URL a 36px input (radius 9, 1px `accent` border, `background` fill, 12.8px, placeholder `https://… or myapp://…`), an error line at 12px `ansi1` when there is one, and on the right 32px buttons (radius 8, 12.5px medium): Cancel (`raised`, 1px `input` border) and the action — Open in `solid` / `solid_foreground`, Erase in `ansi1` with `background` text. The action button reads `Working…` while it runs. - **The screen view** takes the panel's place while a device's screen shows (Show screen): the panel's block in the layout becomes a column of two. - **The bar**, 42px, this mod again (its props carry `screen`), `background` with a 1px `border` underneath, 8px at the sides: a 24px Back button (15px `chevron-left` in `muted`, radius 6, `hover` under the pointer, tooltip `Back to the devices`), the device's name at 13px semibold, truncated, and at the right 24px icon buttons (14px icons in `muted`, radius 6, `hover` under the pointer, each with a tooltip): Home (`house`), Lock (`lock`), Volume down (`volume-1`), Volume up (`volume-2`), Rotate (`rotate-ccw`) and, for a simulator only, Keyboard (`keyboard`). - **The screen**, the rest: a terminal block running the viewer, which draws the picture as large as fits at the frames' aspect ratio, centered, and until the first frame one dim line in the middle (`Connecting…`, `Building the frame scaler (once)…`). ## How it behaves - Agent statuses aren't shown, except as a device's driver (below): this panel is about devices. - **Start**: the last list (kept in `localStorage` without its app tags, with when it was read) paints at once; both platforms are read behind it. - **Simulators**: `xcrun simctl list devices -j`, read again whenever `watchFolder("~/Library/Developer/CoreSimulator/Devices")` reports a `device.plist` (it is rewritten on boot and shutdown: a boot from any terminal shows within about a second), every 5 s, after Refresh and after any action. Available ones only; `Booted` is on, `Shutdown` off, `Booting` and `Shutting Down` are phases, anything else is shown with a triangle. - **iOS devices**: with each simulator read, `xcrun devicectl list devices -q --json-output /dev/stdout --timeout 5` in parallel; any failure (older Xcode, non-zero exit, unreadable JSON) means no phones, silently. Only `reality: "physical"` devices that are `transportType: "wired"` or `tunnelState: "connected"` show (paired devices that are away are dropped, like adb's); each is an `on` row `{ kind: "ios", id: udid, detail: "USB" | "Wi-Fi" }` (NBSP in names becomes a space) in the section titled ` `, created and sorted in with the simulators'; being on, it shows in Running, that title on its second line. Click does nothing; the menu has Open URL… (`xcrun devicectl device process launch --device com.apple.mobilesafari --payload-url `, Safari only), Run Maestro flow… and Copy UDID. No apps are asked for. - **Polls**: both platforms every 5 s (`poll`), and every third tick once a platform's list has read the same six times in a row (`pollDue`); a change, a watcher, Refresh or an action reads at once. - **Android**: every 5 s, after Refresh and after any action: `adb devices -l`, and for each running `emulator-NNNN` not named yet `adb -s emu avd name` (first line), all at once and not awaited (a hung one can't hold up the read; the row shows by serial until a later read). A name is kept until adb stops listing its serial. The AVDs are the `.ini` files of the AVD home (`readdir` from `fs/promises`; avd home `$ANDROID_AVD_HOME`, else `~/.android/avd`) with `target=android-NN` from each, listed again only when `watchFolder` on the AVD home reports an `.ini` outside a `.avd/` folder, or on Refresh. Every AVD shows, on (with its serial) when a running emulator reports its name; other serials are phones by `model:` (underscores as spaces). Each platform's reads never overlap; one asked for meanwhile runs right after. - **Apps**: after each successful read, every booted device (simulator `on`, adb state `device`) is asked which app runs, all at once, in the background (a slow one can't hold up a read; the result is cached per device key in `actions.js` and put on the row as `d.apps`, shown from the next read; a change nudges the panels to read again). The cache entry goes when the device isn't on; a failed call means no suffix. Simulator: `xcrun simctl spawn launchctl list`, each `UIKitApplication:[` line, `com.apple.*` dropped (it lists every running app, not only the front one); then one `ps -o pid=,%cpu=,etime= -p ` orders them by %cpu descending (under 0.5 is 0: the simulator suspends backgrounded apps), then newest launch (etime), then id; apps ps doesn't print go last, and if ps fails the order is by id. Android: `adb -s shell dumpsys activity activities`, the package of `topResumedActivity=ActivityRecord{... /...}` (older APIs: `mResumedActivity`), hidden when it matches `^(com\.android\.|com\.google\.android\.(apps\.nexuslauncher|gms|googlequicksearchbox)|android$)` or ends in `launcher`. The row shows the last dot-segment of the first id as the app tag, its tooltip all the full ids; nothing without an app. - **Drivers**: which terminal drives a device. With each simulator read, one `ps -axo pid=,ppid=,time=,command=` (`time` is CPU time, `[dd-][hh:]mm:ss.ss`, minutes past 59 on macOS): every `simulator-server ios --id ` (Maestro MCP starts one per simulator or iPhone it drives) has its parents walked, 50 at most and never past pid 1, until one is a live terminal's `pid` or `foreground.pid` in `terminals()`. It is active when its CPU time grew since the previous read (the panel keeps each server's last CPU time; a first sighting isn't) and its terminal's agent, if it is one, is `working`: an idle agent's server still ticks 0.01 to 0.5 s now and then. Otherwise attached. This panel's Run Maestro pane (`isMaestroPane`) drives its device, active, while its `foreground.argv` is still the `sh -c … maestro --device` command; once it execs the shell, it drives nothing. One driver per terminal (the pane wins over its own run's server); the first is the active one, then the agent whose status changed last (`agents()`' `seq`). The row's tag (`deviceTags`, one pill, see Claims) shows the first: its terminal's `program.key` (`claude`, `codex`), else its address; the pane reads `maestro`. With a driver it brightens under the pointer (`hover` on `raised`, `foreground` text; or the tone at `40`), the row's only tag that does. Color is liveness: active `working` (`working` + `1f` behind), attached with its agent `blocked` likewise in `blocked`, else `muted` on `raised`. The tooltip has a line per driver: `Click to focus · / · · driving now` (or `attached, idle`) `· via Maestro MCP` (or `· this panel's Run Maestro pane`), then `Not claimed` when no claim. A click runs `agent.focus {terminal}` for an agent, else `pane.focus {terminal}`, without the row's click; right-click opens the row's menu. Not in the rail. Android via Maestro MCP is not tagged: no per-device process was found to read (no emulator was running to look). - **Claims**: which agent holds a device. A claim is the folder `~/.cache/herdr-devices/claims/`, made by the agent with a plain `mkdir` (one creator wins) and holding `pid` (the agent's process), optionally `owner` (its first line, 40 characters at most, is the tag's label) and `start` (the process's start as `LC_ALL=C TZ=UTC ps -o lstart=` prints it, so a pid reused by another process later isn't taken for the holder). The `pid` file's mtime is the holder's last use (the hook touches it on every call): `readClaims` gets every claim's at once from one `sh -c 'cd ; stat -f "%m %N" */pid || stat -c "%Y %n" */pid'` (`pidMtimesArgv`, `parsePidMtimes`; `fs` has no stat), as `used` (ms); a failure leaves it unknown. `` is `claimId(d)`: what Maestro's `--device` takes, the UDID for `sim` and `ios`, the serial for `avd` and `phone`; an off AVD has none. At start the panel runs `mkdir -p` on the folder through `exec` (`fs/promises` writes only under the app's folder), reads it (`readClaims` -> `claimsFrom`), and reads again on every `watchFolder(dir)` change and every iOS read. On the iOS read, before the one `ps` (which lists `lstart=` too), the claims are read; `staleClaims(claims, rows)` are those whose `pid` is absent from the rows, or present with another start than the claim's `start` (compared only when both are known), `dropClaims` removes each (`dropClaimArgv`: ids must pass `CLAIM_ID`; under the hook's `.takeover.` lock folder, and only while the `pid` file still names that holder, so a takeover since keeps its claim), and the claims are read once more. No usable `pid`: kept. No ps rows: nothing dropped. Then the same rows give each claim's **holder** (`claimHolders`, by pid): the terminal whose `pid` or `foreground.pid` the claim's pid is, or whose its parents reach (the Drivers walk); none without ps rows. The row has one agent pill, not in the rail (same shape as the app tag: 16px tall, 5px side padding, radius 4, 10.5px medium, 96px at most, truncated; the claim pill on a 40px Running row 200px), a 10px icon, 3px gap, then on a claim the holder's `program` icon at 10px when it has one (`svg` when `tint`, else `image`), the text (truncated), the idle text in `dim` and a `×`. Icon = relationship: `lock` claimed, `link` a driver and no claim, `triangle` mismatch. Color = liveness, as under Drivers (claimed with no driver: idle; idle too once the claim can be taken over). Text: the holder agent's `title`, else its `tab_name`, else `space_name` (trimmed), else the claim's owner, else the first driver's key; a claim with none shows the icon alone. Idle text (`idleText(used, now)`, `now` the render's): under 2 minutes none, then `idle 14m`, from an hour `idle 2h`; only on a claim with a `pid`, a `start` (the hook's: one made by hand never goes idle) and a known `used`. From 15 minutes (the hook's default; the env var isn't read) the pill is idle-toned. The 10 s re-render (the footer's) keeps it current. Mismatch: with a holder, there are drivers and none is in the holder's terminal; without, the claim has an owner and no driver's key equals it, case-insensitively (a pane driver reads `maestro`). Then two pills, the claim (`lock`, idle) then the driver (`triangle`, `blocked`, key, clickable). Ids `tag-` and `driver-`. A claim pill with a holder clicks to it, driving or not (`agent.focus {terminal}` for an agent, else `pane.focus {terminal}`); without one, only when it stands for the first driver (no mismatch), to that driver. Hover only with a click. Tooltip: with a holder `Click to focus `, then `Claimed by ` (or `Claimed`) `· / · · pid · idle 14m` (each when known) `· another agent can take it over` (from 15 minutes), then the driver lines (one per line), or `· not attached`. The claim pill's `×` (11px `dim`, `foreground` under the pointer, 2px side padding, its own hit area, tooltip `Release claim`) stops the click there and runs the release; not on the link or triangle pill. Hover is style only: no `cx.notify()`. The menu gets `Release claim` (icon `square`) after the Maestro items while the device is claimed: `rm -r /`, refused unless the id passes `CLAIM_ID` and the folder is absolute. **Hook** (`hooks/claim.sh