# Cubicles A Herdr layout where your agents work in a pixel-art office. Every space is a cubicle with its own wall colour; every agent is a small developer in a suit sitting at a wooden desk. Sub-agents show up as speech bubbles that come out of the developer's laptop and vanish when they finish. The office grows with your spaces and shrinks its pixels to fit. ![Cubicles](preview.png) ## What you see - **Left sidebar, 240px** (min 44, max 480, `chrome` background, not resizable): brand header 46px (`workspace-chrome`), then the Spaces and Agents lists in equal halves (`spaces`, `agents`, min 90px each), then a 69px footer (`workspace-chrome` with `footer: true`). - **Right column** (`chrome` background, padding 8, gap 6), top to bottom: - **Office, 304px** (min 160, max 900, radius 12, draggable window area, mod `cubicles`). Carpet `#171a21`. One cubicle per space, laid out left to right and wrapping into rows. - **Tab bar, 42px** (mod `tabs`): the space's tabs and a "+" that opens Herdr's `new-menu` (terminal or any installed agent). Without this bar the layout has no way to start an agent. - **Desks, remaining height**: the active tab's panes (`{tab:"active"}`), pane gap 8, radius 10, 1px `#22262e` border, `#f59e0b` focus border, 30px `pane` header always visible, `lone: true`. - Root: theme `graphite`, Geist 13px, no titlebar, traffic lights at 12,16, terminal padding 10x12, background `#0b0d11`. - **One cubicle** is a 168x144 art-pixel scene (wall, floor, one desk). A space with several agents is that many desks side by side on one continuous wall. Wall colour comes from `hash(space id)` over six pastels `#c5e3ec #e6d8f0 #f3e4c4 #d2ecd5 #f1d6dc #d4dbf0`. The space name is drawn small at the top-left of the wall and the tab name on the floor, both in a 3x5 pixel font. - **Desk scene, front view:** striped wall, baseboard and floor planks; a picture frame at the left (the running agent's pixel logo); a blue chair; the developer (suit `#2b1f2a`, white collar, red tie `#d62d3a`); an orange desk with two drawers; a laptop whose lid faces the viewer; a potted plant, a sheet of paper with a pen, a blue mug with steam; a brown briefcase at the lower left. - **Who is who (hair colour):** Claude brown `#8a4b1f`, Codex blue `#2f6fe0`, Kimi black `#26262f`, Ollama white `#f6f7f9`; any other agent gets one of four hair colours picked by a hash of its address. Skin (five tones) and shirt colour also come from the address hash. - **Wall picture:** a pixel logo per agent, 11 columns wide, drawn at 2x: Claude (orange crab mascot), Codex (blue cloud with `>_`), Kimi (white K on black), Ollama (white llama on slate `#5b6b7c`), anything else (grey placeholder). A space without an agent shows a blank sheet. ## How it behaves - **working**: the developer types (hands alternate 160ms), the laptop lid light blinks `#38bdf8` / `#bae6fd`, eyes open and blinking now and then, the mug steams (4 frames, 260ms). - **blocked**: an amber `#f59e0b` "!" badge bobs above the head and the lid light blinks amber. - **done**: a green `#34d399` check badge and a steady green lid light. - **idle (asleep)**: eyes stay closed, grey "z", "zz", "zzz" floats above the head, lid light grey `#d1d5db`. - **Empty space**: the desk with an empty chair and a closed laptop. - **Sub-agents** are bubbles stacked top to bottom at the right of the wall, starting 108px (art) from the left and 8px from the top, 24px apart. Each has a 7x7 pixel icon (drawn at 2x) and a short word: find (explore/search/research), plan, rev (review), test, fix, docs, bot (general/agent); anything else shows `chat` and its first four letters. Up to four bubbles; with more, the first three are shown and the last says `+N`. Three white dots appear one after another from the laptop's top-right to the bubbles ("they come out of the computer"). While the agent works the bubbles bob 2 art pixels in two frames (280ms, offset per bubble). A bubble that finishes blinks out over 600ms. - **Clicks:** a developer runs `agent.focus {terminal}`; an empty cubicle runs `space.select {id}`. The active space has a 2px `#f59e0b` outline. Nothing reacts to hover or keys. - **Size:** everything is drawn on integer pixel steps. `MAX_U = 2` screen px per art pixel is the biggest allowed; it falls to 1 when the cubicles do not fit (wider rows, up to two rows in 304px). Desks of 336px (2px) fit about four across at 1560px wide. ## Built from Layout `layouts/cubicles.json`: root `row` (`cubicles-root`) with children `sidebar` (column, 240px) holding blocks `brand`, a `sidebar-lists` column (`spaces`, `agents`) and `sidebar-footer`; and `cubicles-work` (column) holding blocks `cubicles-office` (`content: {mod: "cubicles"}`, 304px), `cubicles-tabs` (`content: {mod: "tabs"}`, 42px) and `cubicles-desks` (`content: {tab: "active", pane: {...}}`). Shipped mods used: `workspace-chrome`, `spaces`, `agents`, `tabs`, `pane`. The custom mod is `mods/cubicles/` (`mod.json` is `{"place":"none"}`; `main.js` is one `View`). `mods/cubicles/main.js`: - Imports `View, div` from `gpui-kit` and `agents, spaces, terminals, run, exec, home` from `herdr`. - **Data:** `agents()` and `spaces()` each tick (130ms); `terminals()` for terminals started by an agent (`parent` = sub-agent) and for matching a self-reported agent to its space (label `herdr.space`, else the `where` label `"Space / Tab"`, matching the tab name too because two unnamed spaces can share a folder name). - **Hook files** (see `neurons-hook.py`), read every 2s with one `exec("sh", ["-c", ...])` that prints `\t\t` per file, never two reads at once: `~/.config/herdr-app/data/neurons/sub/*.json` = `{terminal, app, label, t}` per live sub-agent (deleted after 6h); `.../main/*.json` = `{terminal, app, status: "working"|"idle", t}` per agent Herdr did not recognise (a `working` entry older than 15 min counts as idle, any entry older than 30 min is deleted). They are merged with `agents()`. - **Art:** every pixel is a rect in a run-length-encoded sprite. A sprite is a retained child view created with `cx.new(Sprite, props)` and refreshed with `set_props` only when its signature changes. Sprites: the static scene (wall, desk, character, items, texts), arms (2 typing frames), lid light, blink overlay, steam (4 frames), badge, one per bubble, three dots. The 3x5 font, the 7x7 icons, the 11-wide logos and the head bitmap are string grids in the file. The parent `render()` only places sprites. - **Per-agent logo and hair:** from `agent.app` / `program.key` / `program.name` matched against claude, codex|openai, kimi|moonshot, ollama. `neurons-hook.py` (usage `start|stop ` for sub-agents, `working|idle|end ` for the agent itself): reads the hook JSON on stdin, takes the terminal from `HC_TERMINAL_ID`, and writes or deletes the files above. It exits silently when `HC_TERMINAL_ID` is unset. Hook install. Claude Code, in `~/.claude/settings.json` under `"hooks"`, each entry `{ "hooks": [{ "type": "command", "command": "python3 ~/.config/herdr-app/neurons-hook.py claude", "async": true, "timeout": 5 }] }`: `SubagentStart` -> `start`, `SubagentStop` -> `stop`, `SessionStart` -> `idle`, `UserPromptSubmit` -> `working`, `Stop` -> `idle`, `SessionEnd` -> `end`. Codex, in `~/.codex/hooks.json` (same shape): the same events with app `codex`, except there is no `SessionEnd`. ## Watch out - **Hot reload:** after saving the mod Herdr often shows "this Entity has been released and can no longer be mounted" and a blank office. Save the file a second time. - **Released sprites:** Herdr releases a retained child that is no longer mounted. Never reuse one (`set_props` on it throws "released and can no longer be updated"); drop it from your map and create a new one when needed, release the old one after a short delay, and redraw (notify) every tick so the mounted frame never keeps a dropped sprite. - **`exec` is slow:** one process per cycle for all folders, and guard against overlapping cycles, or the reads never finish and hook-reported agents never appear. - **Use `>>>` for hash-based array indexes:** `hash >> 3` can be negative and gives `undefined`. - Herdr does not recognise agents started from the "+" menu (`reported: false`), so without the hooks they never appear. Claude Code reads its hooks when a session starts: sessions opened before installing them do not report. Codex asks the user to trust new hooks the first time. - Sub-agents only appear if the agent started them with `hc run` (they are terminals with a `parent`) or a hook is installed. Kimi and Ollama have no sub-agent events. - The hooks only work inside a Herdr terminal (`HC_TERMINAL_ID`). A crashed agent can leave a sub-agent file behind until the 6h cleanup. The mod runs `sh`, `cat`, `ls` and `rm` on `~/.config/herdr-app/data/neurons/`. - At 1px per art pixel the 3x5 text is about 5px tall and hard to read. Kimi's black hair and Ollama's white hair are defined but were not tested with those agents running. - The hook path in the snippets assumes `~/.config/herdr-app/`; adjust it if `HERDR_APP_HOME` differs. ## Done when 1. `layout.switch {name: "cubicles"}` shows the sidebar, a 304px office strip, a tab bar with a "+" and the active tab's terminal below. 2. With two spaces there are two cubicles with different wall colours, the active one outlined in amber. 3. An agent running in a space shows a developer at the desk with the right hair colour and its logo in the wall picture; its tab name is on the floor. 4. While it works the developer types and the lid light blinks; when it goes idle the eyes close and "zzz" appears. 5. `echo '{"agent_id":"a1","agent_type":"Explore"}' | HC_TERMINAL_ID= python3 neurons-hook.py start claude` makes a "find" bubble appear within a few seconds, with dots leading from the laptop; the same with `stop` makes it blink out. 6. A fourth and fifth space either fit at 2px or drop to 1px with the same scene, and clicking an empty cubicle selects that space.