# Arena
Arena hands one task to several coding agents at once, each in its own git worktree,
then lays their results out as cards: status, latest answer, `+ins −del · N files` and
time. You keep the best lane, or fuse the strongest ones into a new result. The others'
work is saved to git refs before their worktrees go.

## What you see
- **Launcher** (`mod.open:arena`, a dialog 760px wide and 86% tall, on `popover`, 18px
padding):
- A header: **Run in parallel** (15px semibold), the repo and folder in `dim`. In a tab
that belongs to a run, a ghost button **Open this run** goes to its overview.
- A title field (32px, `input` border; placeholder *Parallel run*; left empty, the
prompt's first line is used).
- The prompt: a textarea that grows from 5 to 14 rows. With more than one variant, A, B,
… tabs above it show each variant's run count and an ×; **+ Prompt variant** adds one
(four at most) with the current prompt and agents copied.
- Sections titled in 10.5px `dim` capitals:
- **AGENTS**: one chip per agent (its program icon, its name, `−`, the count, `+`) and
**+ Add agent**. That opens a list in the dialog: installed agents first, missing ones
dimmed as *not installed*, then **OR A COMMAND**, a field for any command
(`claude --model haiku`) that Enter adds. Five lanes at most; at five the button reads
*5 runs at most*.
- **WHERE THE RUNS WORK**: two radio cards, *Separate worktrees* and *Project
directory*, each with a one-line hint. Outside git the first is disabled and a note
says the runs share the folder.
- With worktrees only: **BASE BRANCH** (a button `⎇ develop`, opening the local
branches, the checked-out one first; on a detached HEAD, *HEAD (detached)*) and
**SETUP COMMANDS** (a 3-row textarea, one command per line).
- **FUSION**: radio cards *Off* and *Automatic*; with Automatic, *Fuse with* and a
button that opens the same agent list.
- A footer above a `border` line: the summary (`3 runs · Separate worktrees · fuses with
Claude Code`) or the error in `ansi1`, `⌘↵`, a ghost **Cancel** and a solid
**Run (N)**, dimmed while it can't start.
- **Overview**: the only pane of the run's tab, **Arena · *title***, on `background`.
Content is centered, 1024px at most, 24px side padding.
- The title (17px semibold; turns `accent` on hover, click to rename). Under it in
11.5px `muted`: `N runs` (and `· N prompt variants`), `⎇ Separate worktrees from
` or `⎇ Shared directory`, one glyph and count per status in the order waiting,
failed, working, without an answer, stopped, not started, finished, then `✦ Fuses with
X when all finish`, or `✦ Automatic fusion skipped: `. On the right: **+ Add a
model** (outline; with several variants it sits on each variant instead), **▥ Side by
side** and **Archive run** (ghost).
- **✦ Fused result**: fusion cards, full width, borders in `accent` at 40%.
- Per variant: its letter chip (with several), the prompt on one line in `muted`, with
**Show all** / **Show less** in `accent` for long ones, then a grid of cards: as many
280px-minimum columns as fit, 10px apart.
- A card: `raised`, 12px radius, 12px padding, 184px tall at least.
- Its head: the agent's icon, its label in 12.5px semibold (`Claude Code`, `Codex #2`,
`Claude Code · B`, `Fusion · Claude Code`), `⎇ ` in `dim`, a 7px `accent`
dot when it finished unseen, and the status glyph.
- Its body (12px, clipped at 96px): the latest answer, or what stands in for it. Answers
read off a terminal screen are drawn in JetBrains Mono, 10.5px.
- A meta line in 11px `muted`: `+ins` in `ansi2`, `−del` in `ansi1`, `· N files`, or
*No file changes*, then `◷ 1m 12s`.
- Buttons: **Open chat**, **✓ Keep this** (settled lanes with a worktree), **⇄ Diff**
(when files changed), then two icon buttons, `↗` (leave the run) and `⌫` (archive this
lane), each with a tooltip.
- A floating bar 16px above the bottom (`popover`, `input` border, 12px radius, shadow,
896px at most) that says, by priority: *Runs waiting for you: N. The run can't finish
until you answer them.*, *2 of 3 finished*, *Starting fusion…* or *Fuse the answers into
one result*. On the right is a solid **✦ Fuse results**, enabled with two finished lanes.
- **Diff** (a dialog, 85% × 85%): a 44px header (icon, label, `⎇ branch · since `,
`N files`, **Esc**), then the unified diff in the terminal font at 11.5px: 26px file rows
on `raised`, 20px lines numbered, `+` rows tinted `ansi2`, `−` rows `ansi1`, hunks on
`hover`.
- **Side by side** (a dialog, 96% × 92%): a 40px bar on `chrome` with **Arena · *title***,
*Live terminals, side by side. Type into any of them.*, **Overview** and **✕ Close**, then
one column per live lane: a 28px head (icon, label, status glyph) over its terminal.
## How it behaves
- **Agent statuses.** Each card goes by its terminal and the agent's report:
- `working` → *Working*: the glyph spins (`⠋⠙⠹…` every 90ms in `working`), the body reads
*Working…* (or the live screen for agents without a transcript) and the time counts up.
- `blocked` → *Waiting for you*: `!` in `blocked`, *Waiting for you to go on. Open the chat
to answer.*, and the bar names how many wait.
- `done` → *Finished*, `✓` in `muted` (grey, never green: it says the turn ended, not that
the work is good), with the `accent` dot until you look at that tab.
- `idle` → *Finished* once a turn has ended; before the first turn, *Not started* (`◷`).
- No agent reported yet and no turn: *Not started*, whether setup commands are running
(`sh -c …`) or the agent is starting (`zsh -ic …`). Once only a bare shell is left at
its prompt, the agent quit: *Stopped* (`■`), or *Finished without an answer* (`⚠` in
`working`) if a turn ended. A terminal that ended: *Stopped*, or *Failed* (`✕` in `ansi1`)
with an error code.
- **Launch.** ⌘↵ (Ctrl+Enter) or **Run (N)**, both checked the same way: not on another
machine, a space and folder, a repo looked up, an agent, text in every variant, a fuse
agent when Automatic. The run is saved, then its overview tab, then one lane at a time:
`git worktree add -b arena//- ~/.herdr/worktrees//`, then `tab.new` with the lane's folder, the agent's argv (wrapped
as `sh -c 'set -e; ; exec "$@"'` when there are setup commands) and the prompt as
its `task`. A folder inside the repo (`git rev-parse --show-prefix`, so symlinks don't
matter) runs in the same folder of each worktree; one missing from the base commit runs
at the top, with a notice. A lane that fails removes its empty worktree; the others
start. If none start, the run and its tab are taken back and the launcher stays open with
the error. The overview tab is shown last.
- **Reading a lane.** Once a second the overview compares each lane's terminal state, turn
count and agent status. When they move and the lane isn't working, it reads the answer
and the changes. A read with no answer text yet, or a failed one, is tried again every 3
seconds, 4 times at most: an agent can report done before its answer is written. A read
from an earlier turn never decides a status.
- Answer: for Claude Code, `hc get` gives the foreground pid, `~/.claude/sessions/.json`
the session and cwd, and the tail of `~/.claude/projects//.jsonl` the newest text message of the last turn (found by session id if
that folder isn't there). The path is kept, so the answer stays after the agent quits.
Other agents: the end of `hc read`, marked *screen*.
- Changes: a copy of the worktree's index (its stat cache spares hashing every file),
`git add -A` into it, `write-tree`, then `git diff --numstat `. Untracked
files count; the real index is never touched.
- **Clicks and keys.** **Open chat** selects the lane's tab and focuses its terminal. The
title renames the run and every tab of it. Hovering a card raises its border to `input`.
Launcher: Esc closes an open list first, then the dialog. Diff: Esc or `q` closes.
- **Keep this** turns the bar into *Keep ? The other N runs are archived and their
worktrees removed. Their work stays recoverable.* with **Cancel** and **Keep and clean
up**. Every other member's tab is closed at once and each agent awaited (herdr-core must
say it ended; 8s at most, else it is left alone). Then, one by one, its worktree is saved
(`commit-tree` of that tree onto its HEAD, at `refs/herdr-arena/runs///
archive-