# Herdr Main + Usage Herdr's own `main` layout with three additions: a status bar that shows how much Claude and Codex quota is left, a Files panel that renders Markdown (and can open it in its own preview pane), and a History panel that lists past Claude Code, Codex and Pi sessions and resumes them in a new tab. ## What you see Same regions as Herdr `main` (0.1.11), left to right: - **Sidebar, 268px** (`chrome` background): brand row 46px (`workspace-chrome`), spaces and agents lists sharing the height (`spaces`, `agents`, min 90px each), footer 69px (`workspace-chrome` with `footer: true`). - **Work column**: - **Tab bar, 42px** (`tabs-history`): tabs as pills, then panel buttons **Files**, **Changes** and **History** on the right. - **Body**: the active tab's panes as cards (30px header from `pane`, 1px `border`, 1px `accent` focus ring, radius 10, gap 8, padding 8), and a hidden-by-default right panel, 368px (280–900), a stack of `files-md`, `changes`, `history`. - **Status bar, 28px** (`status-usage`): machine, branch, agent count and "N needs you" on the left; on the right `Claude 5h 96% · 7d 35%`, `Codex 5h … · 7d …`, a small `Q0` badge, and the command-palette hint. Each number is the share *left*: muted above 30%, yellow (`ansi3`) at 30% or less, `blocked` red at 10% or less. ## How it behaves - **Agent statuses** are shown by the shipped `agents` and `pane` mods as in Herdr `main`. The status bar counts all agents and shows `· N needs you` in `blocked` red when any are blocked. - **Quota**: refreshed every 5 minutes. Hover shows when each window resets (`5h resets in 2h13m`). Click retries/refreshes. `…` while loading, `—` on error (tooltip names it, e.g. `not logged in`, `HTTP 401`). - **Q0 badge**: mirrors agent states and quota onto a Quote/0 e-ink screen via a local bridge (see Watch out). Checked every 20 s, pushed at most once a minute, plus a 15-minute heartbeat. Click pushes now. - **Files panel** (`files-md`): like the shipped Files panel. Selecting a `.md/.markdown/.mdx` file renders it as Markdown, with **Preview / Source** chips and `↗`, which splits the focused pane right with `md-preview` for that file. Relative `.md` links open inside the panel; `http(s)`/`mailto` links open in the browser. - **md-preview pane**: header with file name, folder, ← back (after following a link), Preview/Source. Re-renders on save (folder watch locally, 3 s poll on remote machines). Files over 300 000 chars are truncated. - **History panel**: search box, scope chips **This folder** (git root of the focused pane's folder, else that folder) / **All**, per-agent chips with counts, refresh button (spins while loading). Rows: agent icon, title, age, prompt count (+ folder in All). Hovering a row turns its ▶ into a **Resume** button. Clicking a row opens the transcript (last 400 entries; tool calls collapsed to 6 lines) with a **Resume** button. With two or more prompts, a thin rail on the transcript's right edge shows one dot per prompt; the dot of the turn at the top of the view is lit (accent). Hover a dot for `3/12 · `; click it to read from that prompt: the transcript restarts there, with a `↑ Show N earlier entries` bar above to go back to the full list. (The lazy `list` can't be scrolled from code, hence the restart.) Resume runs `claude --resume `, `codex resume ` or `pi --session ` in a new tab in the session's folder. Esc leaves the search, then the transcript. The list reloads every 20 s; shows the 100 most recent. - Tab-bar panel buttons: click selects that stack child and shows the panel; clicking the active one hides it. ## Built from - `layouts/main-usage.json`: a `layout.clone` of `main` 0.1.11 with three changes: `tabs` → `tabs-history`, `workspace-status` → `status-usage`, and the `panel-body` stack gains `files` → `files-md` plus a `history` block. - Shipped mods used as-is: `workspace-chrome`, `spaces`, `agents`, `pane`, `changes`. - `mods/tabs-history`: clone of `tabs`. Always adds `"history"` to `shared("workspace.panels")` and draws its button when the layout has a `history` node. Uses `layout.select`, `layout.show`, `layout.hide`. - `mods/status-usage`: clone of `workspace-status`. - Claude: OAuth token from the macOS keychain item `Claude Code-credentials` (`security find-generic-password`), else `~/.claude/.credentials.json`; `GET https://api.anthropic.com/api/oauth/usage` with `anthropic-beta: oauth-2025-04-20`; windows `five_hour`, `seven_day`. - Codex: `~/.codex/auth.json` tokens; `GET https://chatgpt.com/backend-api/wham/usage`; `rate_limit.primary_window` / `secondary_window`. - `quote0.js`: builds `{quotas, total, blocked, working, agents[≤4], more}` and `POST`s it to `http://127.0.0.1:47800/model`; if that fails, runs `open -g ~/Applications/Quote0Bridge.app`. - `mods/files-md`: clone of `files` with Markdown rendering (`TextView.markdown`), `pane.split {direction:"right", mod:"md-preview", props:{file, on}}`. - `mods/md-preview`: props `{file: absolute path, on?: machine}`; uses `readTextFile`, `watchFolder`, `EditorState` (readonly, markdown) for Source. - `mods/history`: `main.js` runs `python3 mods/history/history.py list` and `… show `; resumes with `run("tab.new", {argv, folder})`. `history.py` reads `~/.claude/projects/*/*.jsonl`, `~/.codex/sessions/*/*/*/*.jsonl`, Pi sessions (`$PI_CODING_AGENT_SESSION_DIR` or `~/.pi/agent/sessions`), and caches an index at `~/.cache/herdr-history/index.json` keyed by mtime and size. Icons: Herdr's `icons/claude.svg`, `icons/codex.svg`, `icons/pi.svg`. ## Watch out - **Reads credentials and reaches the network**: `status-usage` reads your Claude Code and Codex login tokens and sends them only to their own usage endpoints. These endpoints are undocumented and may change. - **Q0 is personal hardware**: without the Quote0Bridge app and a Quote/0 device, the badge turns red and the mod tries `open -g ~/Applications/Quote0Bridge.app` about every 20 s (harmless, fails quietly). Remove `quote0Badge` and `syncQuote0` from `status-usage/main.js` if you don't have one. - **Runs programs**: `security`, `python3`, `git`, `open`/`xdg-open`, and the agent CLIs on Resume. `python3` must be on PATH for History. - **Reads files outside its folder**: History reads agent transcripts in your home; Files reads the space's folder. - `files-md` was cloned from `files` 0.1.11. Later Herdr releases of `files` have fixes it doesn't (Windows UTF-8 listing, symlinked folders, untracked files mode), so prefer re-cloning `files` and re-applying the Markdown parts. - The layout has no theme of its own; it uses the person's `settings.json` (built with `"theme": "graphite"`). - macOS-first: the keychain lookup is macOS; Linux falls back to the file. ## Done when - `herdr-app check` passes for `files-md`, `md-preview`, `history`, `status-usage`, `tabs-history`. - `herdr-app do layout.switch '{"name":"main-usage"}'` shows the sidebar, tab bar with Files / Changes / History buttons, and the status bar. - Status bar shows `Claude 5h N% · 7d N%` (and Codex) when logged in, `—` with a `not logged in` tooltip otherwise. - Clicking a `README.md` in Files renders Markdown; `↗` opens an md-preview pane that updates on save. - History lists past sessions for this folder; **Resume** opens a new tab running the agent's resume command in the session's folder.