# wrangler T3 Code style agent threads for Herdr, built on Herdr's own spaces. Working agents keep going in the background while the ones that need you rise to the top. Save spaces as projects, search and hop between them, and flip to any agent with a quick switcher. Prefix key bindings for anyone who loved the herdr TUI or tmux. ![wrangler](preview.png) ## What you see Left to right, a row on the `canvas` background, no title bar (`"titlebar": "none"`, traffic lights at `[12, 16]`), 1px `border` dividers, terminal padding `[14, 12]`. No theme of its own: it uses the person's theme. **Sidebar**, 342px (min 44, max 480, not resizable), background `chrome`, a column: 1. **Brand**, 42px (the tabs bar's height, so the gradient's edge meets the tabs line): `my-chrome`, drags the window. The block paints a left-to-right gradient (`#89b4fa38` to `#89b4fa00`, angle 90) over `chrome`; the mod draws the Herdr logo, "Herdr" semibold 14px, and the sidebar toggle. 2. **Spaces** (weight 0.854, min 90). A 28px header: "Spaces" at 11.5px `dim`, medium, then 22px icon buttons (14px icons, `dim`, rounded 5): `search` (`projects.pick`) and `plus` (`projects.new-menu`, opened at the click). Rows 30px, rounded 8, `selected` when active, `hover` otherwise. Each row: an 18px avatar (rounded 5, the space's first letter, white bold 10.5px) in one of `#22a99a`, `#e3814f`, `#5b8def`, `#8b7cf6`, `#3fae6a`, `#d9649a` (assigned least-used first, kept in shared `space.colors`; a space that isn't a saved project gets a hollow avatar instead: 1px `dim` border, `dim` letter; the `~` space shows `mods/my-spaces/house.svg` and "Home"), the name (max 150px) and, right-aligned at 11.5px `dim`, `repo · branch` only where unusual (main and master hidden, repo hidden when the name says it), then `↑n` in `ansi2` and `↓n` in `ansi1`. A repo with worktree spaces ends its row with a fold chip (count and chevron, 11px `dim`; folded state in localStorage `repos.folded`; folded keeps the active worktree). A worktree space is a 28px row under it, name in `muted` lined up with the repo's name (27px in), only `↑n ↓n` on the right, its branch as the tooltip; a connector in `dim` at 33% (1px, left 16) runs down from the repo's avatar and curves into each row (rounded 8 elbow, 11px wide). With other machines known, each machine is a 28px foldable row (10px above all but the first): an 18px tile (rounded 5, the icon in its color on a 18% tint of it; `monitor` in `accent` for "This computer" first, then `server` in a color picked from the avatar colors by name), the name, a connected dot in `ansi2` (or the state), a `+` on hover, the count when folded and a chevron; its spaces sit 10px in under it. The Home tile is `muted`. 3. **Agents** (weight 1.546, min 90), top border `border`. A 28px header: "Agents" at 11.5px `dim`, medium, then 22px icon buttons: `search` (`projects.switch`), sort (`mods/my-chrome/filter.svg`, the sort popup), `clock` (`projects.history`) and `square-pen` (`projects.compose`); in the rail, just the `square-pen` on top. Rows grouped under 26px section headers (Needs you, Done, Working, Idle; or, sorted "Grouped by project", one per project with its 14px letter badge, else per space, in order of each group's first agent). In Priority, Needs you, Done and Idle (everything waiting on you) fill from the top and scroll; Working sits at the bottom of the list, showing 3 agents then a "N more" / "Show less" row. Waiting agents show time since their last change ("3m ago", "just now"); Working shows how long it has run. Hovering an Idle row adds an x ("Close agent"): `pane.close` on its pane, or `space.close` with `confirmed: true` when that pane is the only one in its space (counted from `spaces()` tab `panes`). When that space is also the only one, it runs `tab.new` in it first and closes just the pane: closing the last space quits the app. Each agent is a card (padding 5 x 10, rounded 10, no gap between cards, `selected` when focused, `hover` otherwise): - The session line first, 22px: Claude's terminal title (its current task), else a named tab, at 13.5px (`foreground`, `muted` when idle, medium when focused); with sub-agents, a fold chip after it: a 12px `mods/my-agents/bot.svg` and the count (`dim` open, the most urgent sub-agent's color folded). On hover, a pin button and (Idle) an x end it, so they stay put whatever the state shows. - The project line 20px at 12px: a 14px letter badge (rounded 4) in the project's color (else the space's), the project name (else the space name) in `muted`, a `server` icon for another machine, a small pin when pinned; on the right the state: a spinner and "Working 4m" in `working`, a "Needs you" pill in `blocked`, a `circle-check` and "Done" in `done`, or "3m ago" / "just now" in `dim`. A waiting Claude agent's prompt cache adds a 17px pill (rounded 9, 11px medium, tone on tone at alpha `22`, an 11px icon): in its last `cache.warn` minutes an amber (`working`) `mods/my-agents/hourglass.svg` and the minutes left, in place of the time; past `cache.ttl` a blue (`ansi4`) `mods/my-agents/snowflake.svg` and "cold" before the time; after "Needs you" / "Done" when they have one. An idle Claude agent with no reply yet shows the same pill in `muted` with `mods/my-agents/pencil.svg` and "draft" instead of the time. - For a project agent, a branch line at 11.5px `dim`: a 12px `branch` icon and the branch (the folder name when detached). - The program icon (13px) ends the card's last line, right-aligned; Claude gets `mods/my-agents/claude.svg` (the Anthropic spark, `#d97757`). - Under a project or space header (Grouped by project, not pinned) there is no project line: the state ends the branch line (else the session line, before the hover buttons), and the `server` icon follows the session. - Sub-agents under it as 22px rows at 12px (rounded 6, `hover` only), lined up under the session text (33px, plus 12px per nesting level): a 12px icon, the name in `muted`, the state on the right. Two kinds: terminals the agent started with `hc run` (program icon; click peeks) and Claude's own Agent-tool sub-agents (`bot` icon in `dim`, named by their description, else their type; click focuses the parent's pane, or peeks a paneless parent). A card with Claude sub-agents starts folded. 4. **Footer**, 69px: `my-chrome` with `{ "footer": true }`. **Work column** (not resizable): 1. **Tabs**, 42px: the shipped `tabs` mod, drags the window. 2. **Body**, a row with padding 8 and gap 8: - **Main**: the active tab. Panes have a 30px `pane` header always on top, `background` fill, 1px `border` border, 1px `accent` when focused, radius 10, gap 8, `lone: true`. - **Panel**, hidden, 499px (min 280, max 900): a stack of `files` and `my-changes`, `my-changes` active. 3. **Status**, 28px: `workspace-status`. 4. **Projects host**, 0px: draws nothing. **Popups** (all from `projects-ui`, background `popover`): - Menus (the new space menu 290 x 560, space right-click 340 x 260, agent right-click 280 wide and 44 + 33 per row (+43 for the delete row), project menu 260 x 290): `popover`, rows 32px (rounded 8, 13px text, 15px `muted` icons in an 18px box or a project badge, a dim hint on the right), the selected row `hover`; uppercase 10.5px semibold `dim` section labels (a path heading keeps its case); 1px `border` separators. A menu with a project list (the new space menu) has a 40px search line on top ("Type to find a project"; typing filters the list, name matches above folder-only ones, Backspace edits, Esc clears then closes) and a footer of key chips (↵ open, tab worktree, esc close). A project row's New worktree (`branch` icon) and Remove buttons show on hover or selection only. New space menu content: "Empty space", PROJECTS (up to 8 rows, wheel scrolls, each with a dim summary like "2 tabs"), then "Save this space's layout to " (greyed when the focused space isn't a project), "Add project…", "Add current space as project". - Projects picker, 560 wide, 0.6 of the window tall, 40px from the top: title "Projects" 15px semibold, a 36px search field with an `accent` border, 32px rows (badge, name, folder, layout summary), then "Add current space as project" and "Add folder…", and a hint line "↵ open · tab new worktree". - Dialogs share `dialog.js`: a header (a 26px icon tile in `accent` at alpha `22`, the title 15px semibold, a dim subtitle, an esc chip), form rows with 54px `dim` captions, a one-line dim note under the fields, and a footer with a top `border`: key chips on the left, a bordered Cancel and a solid primary button with a ↵ chip. Padding 16, gaps 10-12. - New agent, a 560 dialog (subtitle: the project folder): Project (a 308px dropdown) and Agent (150px) on one row, Mode (Claude only, else a dimmed "Claude only": a four-segment toggle, Default `shield`, Auto `sparkles`, Edit `pencil`, Full Access `lock-open`), Where (a two-segment toggle with `folder` / `git-branch` icons), Branch (placeholder "optional: auto-named if empty") and From. Branch and From always show; in This folder mode they are dimmed stand-ins (clicking one switches to New worktree), so the dialog keeps its height. The note says what Open will do ("In its open space, Claude in a new tab."). Open swaps the form for progress: a list (rounded 10, `background`) of steps from the host's stages, Fetching and Creating worktree (New worktree only), Opening space, Starting : done ones a `circle-check` in `done`, the current one a spinner on `hover`, the rest a hollow dot. A failure turns the header `blocked` ("Couldn't start the agent"), shows the error under the failed step (or on its own line when no step started) and offers Back (↵) and Close. While it runs, Close (or Esc) hides the dialog and the work goes on. - New worktree, a 520 dialog: "New worktree of ", Branch and From, a note ("New branch at …", "Branch exists: checks it out at …", "Worktree exists: opens …"), Cancel and Create; Create shows the same progress (Fetching, Creating worktree, Opening space). - Delete worktree (460) and Remove project (420) dialogs: the same header in `blocked`, what it does, a red line with the count of uncommitted changes, Cancel and a `blocked` Delete / Force delete / Remove button. - Agent switcher, 680 wide, 40px from the top: a 46px search line (16px `search` icon, "Switch to an agent…", the agent count on the right, a bottom border); a list of 36px rows (up to 10 shown, rounded 8, `hover` on the selected one): a row number 1-9, project badge (else the space's avatar color), the program icon, name (max 140) with a small "here" tag on the focused agent, task in `muted`, a `branch` icon and branch (max 150) in `dim`, then on the right the state: spinner and "Working 3m", "Needs you", `circle-check` and "Done", or a ring and "Idle 6m". Footer: key chips for ↵ go, ⇧↵ peek, 1-9 jump, esc close. - History, 780 wide, 40px from the top: the switcher's 46px search line ("Search past conversations…", then a "Titles" / "In messages" pill and the count, "30+" when more load); a chip row that never wraps (24px chips, max 150, `selected` on the picked one): All, Other, up to 4 projects (the focused space's, tagged "here", then recent picks; the picked one always among them) with 14px badges, and "N more ˅"; 48px two-line rows (up to 9, windowed): the project badge (dimmed when the folder is gone), title (13.5) and age on the right, then project name in `muted`, `branch` icon and branch, the folder when it isn't the project's, and "worktree gone · opens in ". "N more" or `@` swaps the rows for a project picker (36px rows: badge, name, folder, "here", a check on the picked one; type to filter). Footer chips: ↵ resume, ⌃↵ in messages, tab project, @ all projects, esc close. - Cache (`view: "cache"`, `cache.js`, self-contained): a dialog 420 wide, opened by my-agents: a 28px tile (snowflake on blue when cold, hourglass on amber when cooling), "Prompt cache expired" / "Prompt cache expires in Nm" over the agent's title; how long since the last reply and the tokens the next message re-sends (input + cache creation + cache read of the transcript's last real reply, read once on open); when cold, a /clear tip in `dim`. "Got it ↵"; Enter or Esc close. - Peek (`projects.peek:`): a dialog 0.86 x 0.84 of the window, a layout overlay: a 46px `projects-ui` bar (`view: "peek"`: status mark, program icon, name, the state word, "from " for a sub-agent; on the right "Go to" ("Keep as tab" without a pane) with a ⌃⇧↵ chip and "Close" with a ⌃⇧Q chip) over the terminal. The bar refreshes `globalThis.__wranglerPeek` every 100 ms; `projects.peek-go` / `peek-close` act only while it is fresh. **Prefix** (`prefix` mod): a frameless overlay over the whole window. Default "side": a 290px card in the bottom right (14px margin), rounded 10, `popover`, monospace 12px: an `accent` pill with the bound prefix key (from `keys.json`, else "prefix"), then 21px lines: group titles uppercase 10.5px `dim`, items as the key (46px, `accent`), "→", and the label. Footer "esc close" (and "^d/^u scroll" when it scrolls). "top": a grid up to 1000px (never wider than the window) at the top with groups as columns and 20px keycaps. "hint": only the " prefix" tag. ## How it behaves **Agent status**, in the switcher and the Agents list: - working: a 12px `spinner.svg` in `working`, spinning every 900 ms. - blocked: "Needs you" pill (18px, `blocked` text on `blocked` at alpha `26`), or a 14px "!" box where space is short (priority sections, the switcher). The peek bar says "Needs you". - done: a 7px `done` dot ("finished"). - idle: a 7px ring, 1.5px `idle` border. - Sub-agents without a pane: `error` shows as blocked, `done` as idle. **Claude sub-agents.** No hooks: `mods/my-agents/subagents.sh ~/.claude` reads Claude's own files, so any Claude in a herdr terminal counts, however it was started. For each `~/.claude/sessions/.json`, the terminal is that process's `HC_TERMINAL_ID` (from `/proc//environ`) and its sub-agents are `projects/*//subagents/agent-.meta.json` (description, type) without `"finished": true` and touched (meta or `.jsonl`) in the last 15 min, since an interrupted one is never marked finished. It also prints one line per session: `S`, terminal, `status`, `statusUpdatedAt`, session id. The Agents list runs it every 1.5 s while any agent is working or a sub-agent is listed, else every 30 s, and redraws only when the output changes. **Prompt cache.** A waiting Claude agent's cache clock starts at its transcript's last assistant entry (not ``), read backwards (`tac`, else `tail -r`) only when the session's `statusUpdatedAt` changes; none means nothing was ever sent: no cache mark, a draft pill instead. An agent on another machine uses when it last stopped working here. `projects.json` `settings.cache` {ttl 60, warn 10} (minutes). Checked every 1.5 s: crossing into the warning (within 2 min of it, not focused) posts a warning toast whose click focuses the pane; focus moving onto a cooling or cold agent opens the cache popup (judged by a session scan started after the switch, within 10 s, so a new or restarted session isn't judged by stale data; a local agent with no session read yet has no cache clock). The toast once per agent and last reply; the popup once while cooling and once more when cold. Remembered in localStorage (newest 200). **Spaces list.** Click selects, drag reorders, right-click opens the projects menu for that row: - main checkout: Rename, New worktree, Open worktree (the shipped `worktree` dialog), Close; - linked worktree: Rename, New worktree from this branch, Remove worktree (`worktree` dialog), Close; - not in git: Rename, Close; - plus "Add as project" when the repo (or folder) isn't saved. The `+` opens the projects menu. Clicking a project opens it: its open space is selected, or a new space is built from its saved layout (tabs, splits, weights, programs, mod panes). The branch button opens New worktree; hovering a project shows an x that opens a "Remove ?" confirm dialog (Cancel / Remove, Enter removes, Esc closes; files stay); right-click on a project opens its project menu (Open, Open new space anyway, Open in new worktree, Save layout here, Clear layout, Remove project). ↑↓ Enter Esc work, and Tab or ctrl-Enter runs the row's branch button. **Agents list.** Click focuses the agent. Right-click opens Copy branch, Copy path and, in a linked worktree, Delete worktree…. The `+` opens New agent. In Priority, a section header click folds it; a finished agent you look at stays in Done until you leave it, then moves to Idle. The Idle x closes the agent's pane (its space too when it was the only pane); the row disappears. **New agent.** Project defaults to the focused space's saved project. Tab / shift-Tab move between fields; ←→ or Space flips Where and cycles Mode. Mode passes `--permission-mode auto|acceptEdits`, or `--dangerously-skip-permissions` for Full Access, Default nothing (settings' `defaultMode`); the dialog opens with the agent and mode of the last start (the host keeps them in its localStorage `composed`, written only when they change; overlay localStorage isn't kept between opens). The note names a non-default mode ("Claude (auto) in a new tab."); ↓ or Space opens a dropdown, where typing filters (projects: name prefix, then name, then folder), ↑↓ move, Enter or Tab picks, Esc closes the list. Enter (or ctrl-Enter) starts; Esc cancels. The From list is "Current HEAD · @ " then `origin/*` newest first, each with its age, the project default marked "default". "Add project…" or "Add current space as project" from the Project list adds it and selects it. While working the footer shows a spinner and stage ("Fetching origin/main…", "Creating worktree…", "Opening space…", "Starting claude…"); the dialog closes when done. - This folder: selects the project's open space and adds a tab running the agent, named after it (Claude's tab is left unnamed, so Herdr titles it with the session name). With no space open, it builds one from the layout and uses the layout's first pane running that agent, else adds the tab. - New worktree: makes the worktree (remote base fetched, `--no-track`), opens it in a new space with the project layout; the agent is the layout's first pane running it, else a new tab. An empty Branch gets `/<8 hex>` (default prefix `wr`), marked with git config `branch..wranglerTemp true`; only marked branches are renamed. **Temp branch rename.** On Claude's first real prompt in that worktree (not empty, not starting with `/`), the branch becomes `/` from the naming model (default `haiku`; the shipped prompt allows `feat`, `fix`, `chore`, `refactor`, `docs`, `test`, `poc`, any lowercase type is accepted; `-2`, `-3` on a clash), and the space is renamed to it if it still had the temp name or folder name. The folder keeps its name. **Delete worktree.** Only a click on the button deletes. It closes the spaces in the worktree, kills terminals left in it, runs `git worktree remove` (`--force` only as Force delete), then `git worktree prune`. The branch stays. **Switcher.** Order: blocked first, then most recently focused (a 250 ms poll of focus, 50 kept, saved in localStorage), the focused agent last as "here". It opens on the previous agent, so open + Enter flips between two. Typing filters (space-separated words, each a subsequence of project, space, task, branch, program and sub-agent names); ↑↓, ctrl-j/k, ctrl-n/p move; Enter focuses (`agent.focus`), shift-Enter peeks (`projects.peek`); 1-9 with an empty filter jump; Backspace, ctrl-w, ctrl-u delete a char, a word, all; Esc clears the filter, then closes. `projects.switch-last` flips without the popup. **History.** `mods/projects/history.sh [-v] [folder...]` keeps `data/projects/history.tsv` (id, mtime, path, cwd, JSON of cwd, branch, custom/AI title, last prompt; `-` for non-interactive) newest first, reading only new or changed transcripts (last 64 KiB) and dropping deleted ones; then prints the matches as JSON lines (`"gone": true` when cwd is missing) and `next N` when more remain. Kept: entrypoint `cli`, not in a live `~/.claude/sessions/.json`, not under a `history-ignore` folder, under the folders (outside them with `-v`, for Other). A project's folders: its folder and `/`. Search: query words (split at non-alphanumerics) all match, each scored 4 title word start, 3 title with spaces removed, 2 prompt/folder/branch, 1 letters in order in the title (3+ letters); sorted by score, then newest. Messages: grep for the longest word, then user records without `tool_use_id` holding every word. The popup reads 30 rows, 30 more near the end (max 300), one read at a time, 150 ms after typing stops; a row's project is the deepest project folder holding its cwd, else its worktree folder's repo name. ↵ sends `projects.resume` with the project folder as `home`; the host greps the transcript's last `"permissionMode"` and passes it back to Claude. **Prefix.** Bound by the person (for example `"ctrl-a": "mod.open:prefix"`). The next key runs its action and closes it; any unbound key, Esc or a click cancels. ctrl-d / ctrl-u and the wheel scroll the side panel when it's taller than the window. Its keys: Projects `a` switcher, `r` history, `⇧O` picker, `⇧A` New agent, `g` new worktree, `⇧S` save layout; Tabs `c n p , 1-9 ⇧X`; Panes `; " hjkl ⇧←↓↑→ z x`; Spaces `o ⇧N ⇧W ⇧D`; App `b ⇧H s ? d`. **What moves.** A new worktree space appears under its main checkout (it waits up to 1.5 s for its git before showing). Branch and ahead/behind update after a command or an agent turn ends and every 60 s while the window is in front. A renamed temp branch shows in the Agents branch line and the space name. ## Built from **Layout `layouts/wrangler.json`** (`"preview": "layouts/wrangler-preview.svg"`, cloned from `main` 0.1.7): ``` root row (background canvas) ├─ sidebar column 342px, min 44, max 480, background chrome, resizable false │ ├─ brand block my-chrome 42px, window_drag, gradient │ ├─ sidebar-lists column │ │ ├─ spaces block my-spaces weight 0.854, min 90 │ │ └─ agents block my-agents weight 1.546, min 90 │ └─ sidebar-footer block my-chrome {footer: true} 69px └─ work column, resizable false ├─ tabs block tabs 42px, window_drag ├─ work-body row, padding 8, gap 8 │ ├─ main block {tab: "active", pane: {header: pane mod, reveal always, 30, top; radius 10; gap 8; lone}} │ └─ panel column 499px, min 280, max 900, hidden │ └─ panel-body stack (files, my-changes), active my-changes ├─ status block workspace-status 28px └─ projects block projects {view: "host"} 0px ``` **Mods:** - `projects` (`place: none`): the host. Lives in the 0px block, renders an empty `div`, and takes every `projects.*` command from `nextCommand()`: `pick`, `switch`, `switch-last`, `history[:query[|messages]]`, `resume:`, `compose[:id[|where[|pick]]]`, `agent-start:`, `branch-name:id|prompt[|model[|timeout]]`, `new-menu`, `space-menu:id[|main|plain]`, `row-menu:id`, `add-space:id`, `agent-menu:term`, `agent-copy:term|branch|path`, `agent-delete:term`, `wt-delete:term[|force]`, `add-folder`, `wt-from:spaceId[|branch[|base]]`, `save[:id]`, `add[:folder]`, `menu:id`, `open:id`, `open-new:id`, `clear:id`, `worktree[:id[|mode[|branch]]]`, `wt-create:id|branch[|base]`, `remove:id`, and overlay requests `overlay:`, `bases`, `wt-run`, `agent-run`, `agent-info`, `wt-delete-run`. `lib.js`: projects.json, layout capture and apply, checkouts, bases, worktrees. `agent.js`: agent argv from `knownAgents`, `--settings` for Claude, temp branch names, Haiku naming. `prefix.json`: its prefix group. `naming-prompt.txt`: the naming system prompt. - `projects-ui` (overlay popup at top, offset 40, 560 x 0.6): only draws. `props.view` picks the view and the file it loads: `picker`, `new`, `menu`, `space-menu`, `agent-menu` (`menus.js`), `worktree`, `agent-delete` (`worktree.js`), `compose` (`compose.js`), `switch` (`switcher.js`), `peek` (`peek.js`, self-contained), `cache` (`cache.js`, self-contained); shared helpers in `ui.js`, dialog pieces in `dialog.js` (loaded only by the dialogs: every overlay open keeps the modules it loaded). Reads the host's cache on `globalThis.__wranglerProjects` and sends `projects.*` commands; long work is a request with a `req` id whose `{stage, done, value, error}` the host publishes. - `my-chrome`: a clone of shipped `workspace-chrome` 0.1.11: the brand row without its own background (the layout paints the gradient) and without the picker button, and the footer (`props.footer`, unchanged). Icons still come from `mods/workspace-chrome/`, plus its own `filter.svg` (used by `my-agents`). - `my-spaces`: a clone of shipped `spaces` 0.1.10. Edits marked `// personal:`: the header's find and `+` buttons, the machine grouping and worktree connectors described above, repo fold chips; right-click runs `projects.space-menu:` (plus `|main` for a main checkout) for a git row, else `projects.row-menu:`; plain spaces (no saved project at the main checkout, or holding the folder when not git) get a hollow avatar. - `my-agents`: a clone of shipped `agents` 0.1.7. Edits marked `// personal:`: agent cards (the session on top with the hover buttons, then project and state, then the branch line, the agent icon ending the last line), the header's switcher, sort and new agent buttons, right-click running `projects.agent-menu:
`, project rows for agents on other machines too (git run there) with a `server` icon after the name (tooltip "On ") in place of the machine's name, the rail (compact rows) chosen by the sidebar's width (< 160px) like newer stock, not the `sidebar.collapsed` flag. Reads `data/projects/projects.json` every 30 s; `props.sortMenu` draws the sort popup. - `my-changes`: a clone of shipped `changes` 0.1.15, reworked into a review panel (edits marked `// personal:`; `"focusable"` reaches it with `pane.go`). Header: a `panel-left` button toggling the file sidebar (b), an Uncommitted / Branch toggle (tab), the file count, +/−. Branch diffs the working tree against the merge-base with a base branch, so it shows the whole branch like a PR plus local edits and untracked files. Its 26px caption row: "vs", the base as a button (default `origin/HEAD`, else origin/main, origin/master, main, master; clicking lists the 80 most recently committed local and remote branches in place of the body, the pick remembered per repo), " · N commits", and an amber (`working`) "uncommitted" legend. Body: a sidebar (230px, its right edge drags it between 140 and 560, width remembered): "All files" (a), then two-line file rows (name, folder in `dim`) that each show just that file (n/p step through files then) and one virtual list with every file's diff (one `git diff`, split by `diff --git` header; at most 30,000 rows, 3,000 per file, 40 new files read) under 32px file headers. Diff rows 22px at 12.5px: old and new line numbers, a +/− column, `ansi2`/`ansi1` at alpha `1f`; hunk rows "⋯ line N" in `accent` and the function context. Code colored per line by `highlight.js` (regex tokens, no parser: keyword `ansi5`, string `ansi2`, number and type `ansi3`, call and key `ansi4`, comment `dim` italic; comment marker by extension), only for rows on screen. `wrap` in the header (w) splits long lines at a column count from the diff's width (7.6px a character) so row heights stay known; the setting is remembered. In Branch, files with uncommitted edits get a 7px amber dot and those lines a 3px amber bar (added lines by `git diff HEAD -U0` number, removed ones by text). Comments: click a line (shift-click stretches within the file) or move with j/k (J/K stretch, n/p files, ctrl-d/u, g/G) and press c; a popup over the diff's bottom (accent border, multi-line box) adds it with Ctrl+Enter, Esc cancels. Comments show as accent rows under their last line (click to edit) and on file rows; the footer's pill ("N comments · M files") opens the pending list. Send (s) pastes one message with `hc send` to the agent in the focused pane (else tab, else space) and focuses it: only `path:lines: comment` per line, no code, removed lines named by the base side's numbers. Row clicks go through the list's `on_item_click`: virtual list rows can't register handlers, and `.when()` needs a real boolean. No commit box. - `my-worktree`: a clone of shipped `worktree` (herdr-app 0.1.16), opened by `projects.wt-open` and the space menu's Open / Remove worktree. Edit marked `// personal:`: a `ScrollHandle` on the Open list, so ↑↓ scroll the highlighted row into view (filtering scrolls back to the top). - `prefix` (overlay popup at top, offset 0, width 1, height 1, frame none): reads `mods/prefix/defaults.json`, every installed `mods//prefix.json`, and `data/prefix/config.json` (`show`, `defaults`, `groups`, `mods`) on each open; runs actions with `run(name, {firstArg: value})` using `commands()` for the argument name. **Shipped mods it uses:** `workspace-chrome` (every icon: `mods/workspace-chrome/.svg` for search, chevron-down, chevron-right, spinner, circle-check, branch, plus, folder, folder-plus, layers, minus, x, square-pen, server, monitor, pin, pin-off, check, clock), `tabs`, `pane`, `files`, `workspace-status`, `worktree` (Open and Remove worktree, `props {space, action: "open" | "remove"}`), `picker` (prefix `o`). **herdr functions:** `agents`, `terminals`, `spaces`, `panes`, `focused`, `machines`, `layout`, `window`, `run`, `commands`, `nextCommand`, `notify`, `openOverlay`, `closeOverlay`, `props`, `exec`, `hc`, `pickFolder`, `watchFolder`, `readTextFile`, `writeTextFile`, `appHome`, `home`, `knownAgents`, `shared`, `setShared`, `setAgentOrder`, `settings`, `theme`; `cx.bind_keys`, `cx.timer`, `cx.write_to_clipboard`, `localStorage`. **Commands it runs:** `space.new`, `space.select`, `space.close`, `space.rename`, `space.move`, `tab.new`, `tab.select`, `tab.close`, `pane.split`, `pane.focus`, `terminal.open`, `terminal.kill`, `terminal.keep`, `agent.focus`, `layout.resize`, `mod.open`. **Programs:** `git` (rev-parse, status, for-each-ref, worktree add/list/remove/prune, fetch, check-ref-format), `hc` (`read`, `get --json`, `run --bg`, `rm`, `kill`, `machine ls --json`, `connect` for `doc.get`), `claude -p --model ` (exec's own time limit), `sh`, `readlink -f`, `mkdir`, `test`, `sleep`. The hook `mods/projects/hooks/rename-branch.sh` (bash) uses `git`, `jq`, `git hash-object` for lock keys, `timeout`/`gtimeout` or a kill fallback, `setsid` or `nohup`, `claude`, `herdr-app ls` and `herdr-app do space.rename`. **Data:** `/data/projects/projects.json` (`{version: 1, settings?: {worktreeRoot, branchPrefix, remote, naming: {enabled, model}}, projects: [{id, name, folder, machine, defaultBase, branchPrefix?, worktreeRoot?, remote?, layout}]}`, watched), `/data/projects/claude-settings.json` (generated: a `UserPromptSubmit` hook to this checkout's script, timeout 5), worktrees at `//`, the hook's log and locks in `${XDG_STATE_HOME:-~/.local/state}/wrangler/`. **Art:** `layouts/wrangler-preview.svg` (320 x 200), the workspace-chrome icons above, `icons/claude.svg` for Claude in the agent list. ## Watch out - **Overlays only draw.** Herdr keeps every overlay's modules in memory after it closes, so the host does the work and `projects-ui` loads only the file for its view. Lists build only their visible rows (a hand-rolled windowed list) instead of a virtual list, and cached values are reused when unchanged so closed overlays share one copy. - **Re-rendering from a view.** A timer started inside a spawned task (a view's `start`) fires but can't re-render. `projects-ui/main.js` runs one 100 ms timer from `init` that calls the view's `tick`; views watch the cache's `ver` counter. - **An overlay opened by a closing overlay doesn't show.** Menus route the next overlay through the host (`projects.overlay:`). For keys, bind `projects.*` commands, not `mod.open:projects-ui`. - **Tab and Esc in dialogs.** Without `cx.bind_keys` for `tab`, `shift-tab`, `escape` in a `WranglerDialog` key context (actions `wrangler::Next`, `wrangler::Prev`, `wrangler::Back`), Tab leaves the dialog and Esc closes it from inside an open dropdown. Bind once (guarded by a global flag). - **One host.** The 0px `projects` block is the only one. A second visible `projects` view makes every command run twice. - **Layout capture is undocumented.** Splits and weights come from `doc.get` on `herdr-app` through `hc connect`. If that fails the save falls back to each tab's panes side by side and warns. Shells are saved as `argv: null`, other programs by their foreground argv; `cwd` is relative to the repo. - **Building a saved layout** waits for each new space, tab and pane by polling (`until`: 60 tries, 50 ms apart, so 3 s) and fails with "The space didn't appear in time." A layout whose first pane is a mod gets a placeholder first tab that is closed afterwards. Weights are applied with `layout.resize` after building. - **`exec` stops at 30 s.** A slow `git fetch` is retried as a hidden `hc run --bg` terminal, polled every 0.5 s for up to 5 minutes. - **The hook lives in the mod.** `agent.js` runs `/mods/projects/hooks/rename-branch.sh` with `bash` (no exec bit needed); the hook reads `naming-prompt.txt` from the folder above its `hooks/`. It is never used for projects on another machine. - **Programs on another machine start through the login shell.** Herdr runs a machine's argv with plain `sh`, which misses the profile's PATH (`~/.local/bin`). Every argv wrangler starts there (agents, layout panes) becomes `sh -c 'exec "${SHELL:-/bin/sh}" -lic '\''exec "$@"'\'' sh "$@"' sh `: a fixed script, the program, its arguments and the task stay `"$@"`, never shell text. The New agent dialog asks the same login shell which agents are installed there. - **The hook must print nothing** (stdout reaches Claude) and return at once: it detaches the work. It unsets `CLAUDECODE`, `CLAUDE_*` session variables and `HC_*` before the nested `claude -p`, or that run misbehaves. It only matches branches `^[A-Za-z0-9._-]+/[0-9a-f]{8}$`, so a `branchPrefix` with a `/` is never renamed. Once per worktree and branch (a lock dir per md5 of both). - **Close, don't quit.** Pressing ctrl-c to end an agent races its exit: an extra press lands in the new shell (raw `9;5u` text under the kitty keyboard protocol, or a ^C that interrupts the shell's rc file). Closing the pane avoids it. `pane.close` refuses the last pane of a space; close the space instead, unless it's the last space (the app quits). - **Copy, don't symlink.** `image()` fails on a symlinked file and Herdr remembers the failure for that path until restart (an empty layout card in Settings). Herdr also doesn't watch symlink targets, so edits wouldn't reload anyway. - **Clones go stale.** `my-spaces`, `my-agents`, `my-changes` and `my-worktree` don't get Herdr's later fixes to `spaces`, `agents` and `changes`; re-clone and re-apply the `// personal:` edits. - **Limits:** branch names cut to 64 chars, slugs at most 5 words, naming timeout 20 s, prompt sent to the hook cut to 4000 chars, hook locks pruned after 30 days, tab titles from a prompt (non-Claude agents) at most 28 chars, MRU 50 agents, 50 request states kept, menus show 8 rows, dropdowns 8 (Project 7, Agent 6), switcher 10 rows, Agents Working section 3 rows (then "N more"), bases refetched when older than 30 s, host warms caches every 2 s. - **Assumes:** git with the configured remote (default `origin`; bases are `HEAD` or `/`), `claude` on the PATH for naming, `jq` for the hook, the shipped mods listed above. ## Done when - `herdr-app check` passes for `projects`, `projects-ui`, `my-spaces`, `my-agents`, `my-changes`, `prefix`, and `layout.switch` to `wrangler` shows the sidebar, tabs, status bar and no visible projects block. - Spaces header `+` > Add current space as project in a repo adds it to `data/projects/projects.json` with `defaultBase` from `origin/HEAD`, and the project shows in the menu with a colored badge. - Splitting that space and running a program, then prefix `⇧S`, toasts "Saved layout to "; closing the space and clicking the project rebuilds the same tabs, splits and program. - Prefix `g`, a branch name and an `origin/*` base makes `//` and opens it in a new space listed under the main checkout with a branch icon. - New agent with New worktree and an empty Branch starts Claude on `wr/<8 hex>`; after the first prompt the branch, the space name and the Agents branch line change to a `/` name. - The Agents card for that agent shows the project name with its color, Claude's task after the Claude icon, and the branch. - Right-click on that agent > Delete worktree… closes its space, removes the folder and keeps the branch; with an uncommitted change the button reads Force delete. - In Priority, a working agent sits at the bottom under Working with a spinner and its run time; when it finishes it moves to Done at the top with "just now"; after you look at it and leave, it moves to Idle. Hovering it there shows an x; clicking it closes the agent's pane, or its space when that was the only pane. With 4 working agents, Working shows 3 and a "1 more" row. - Prefix `a` opens the switcher on the previously focused agent; Enter goes there; opening it again and pressing Enter goes back. A blocked agent sorts first with the "!" mark. - Prefix shows the side panel with the Tabs, Panes, Spaces, App and Projects groups; `"show": "top"` in `data/prefix/config.json` switches to the grid on the next open, and `"mods": {"projects": {"a": null}}` removes Switch agent.