# Plannotator Inbox Your [Plannotator](https://github.com/backnotprop/plannotator) Inbox inside Herdr: the threads your coding agents left you, their questions as cards you answer in place, and a reply box that sends your answers back to the agent. A small "Inbox" piece in the status bar watches from the moment Herdr starts, shows how many threads wait on you, and pops a notification when an agent asks you something new. It talks to the Inbox on your own computer the way the Inbox's own browser window does: no pairing, nothing leaves the machine. Unofficial; not part of Plannotator. ![Plannotator Inbox](preview.png) ## What you see One mod, `plannotator-inbox`, in two modes: the **pane** (the default) and the **indicator** (`props.mode: "indicator"`). Colors are theme names; text is 13 px unless stated. **The pane**, filling its block on `background`: - **Header**, 36 px, `chrome`, 1 px `border` line under it, 10 px side padding, 8 px gaps: - in a thread, a 24 px back button (`mods/workspace-chrome/chevron-left.svg`, 14 px, `muted`, `hover` background); - the title, semibold, truncated: "Inbox", or the thread's name or subject; - on the list, when threads wait on you, an 18 px `accent` pill "N waiting" (11 px semibold `accent_foreground`, radius 9); - "Open in browser ↗", 12 px `muted`, 24 px high, radius 5, `hover` background. - **List**, scrolling. Sections in the Inbox's own order (stopped, holding, waiting, new, sent, quiet), empty ones left out, each a 28 px header: an 11 px chevron (`dim`), the Inbox's label uppercased (11 px semibold; `foreground` for stopped, holding and waiting, else `muted`), and its count (`dim`). Quiet starts folded. Each thread is a row, 12 px side and 7 px vertical padding, `hover` background: - a 6 px dot when it's unread or has messages you haven't seen (`blocked` for stopped and holding, else `accent`), and the name, semibold when the dot shows; - a meta line, 11.5 px `dim` (`blocked` for stopped and holding): project · "N open questions" or "answered, not sent" · age ("just now", "5m", "3h", "2d", then the date); - the first open question, 11.5 px `muted`, when there is one. - With nothing open: "Nothing in your Inbox." in `muted`. - **Thread**, scrolling, then the reply area pinned at the bottom. Each message is a block with 14 px side and 10 px vertical padding and a `border` line under it: - the author (12 px semibold: the agent's name in `foreground`, "You" in `accent`) and the age (`dim`); - the body as Markdown (selectable), with its `:::question`, `:::question-multi`, `:::question-text` and `:::action` blocks taken out, and every image written as `[image: alt]`; - each question as a card: 10 px padding, radius 8, `surface`, a 1 px border in `accent` while it's open, else `border`; the prompt semibold, any context 12 px `muted`. - Single and multiple choice: one row per choice, 8 by 6 px padding, radius 6, `border` border (`accent` and `selected` background when picked), a marker (○ / ● for single, ☐ / ☑ for multiple) and the label; a "recommended" chip (10.5 px `muted` on `hover`, radius 4) on the agent's recommendation; a description below in 11.5 px `muted`. - Free text: a 2-row text box, "Your answer…", and any suggested text below it in 11.5 px `dim`. - Already answered: a 12 px icon (`circle-check` when sent, else `clock`), "Sent", "Answered, not sent", "Closed" or "Replaced by a newer question", and what was answered. - An action item: "An action item: open it in the browser to mark it done." - **Reply area**: `chrome`, 1 px `border` line above, 10 px padding: a 3-row text box, "Reply to the agent…", then a status line (11.5 px; `blocked` for an error, else `dim`) and a 28 px Send button (radius 6, semibold; `solid` / `solid_foreground` when there's something to send, else `hover` / `dim`) that reads "Send", "Send N answers" or "Sending…". - **No Inbox**: "The Plannotator Inbox isn't running." (`muted`, 18 px padding), a 28 px `solid` button "Start the Inbox", and "It also starts by itself when an agent sends you something." (12 px `dim`). While it looks: "Connecting to the Plannotator Inbox…". **The indicator**, filling its block (about 104 px wide in a 28 px status bar): 12 px side padding, 6 px gaps, centered, a 1 px `border` line on top, background `props.background` (a theme color name; default `chrome`, as Herdr's own status bar), 11.8 px text: - a 12 px inbox icon (`mods/plannotator-inbox/inbox.svg`), `accent` when threads wait, else `muted`; - "Inbox" (`foreground` when threads wait, else `muted`; `foreground` on hover); - when threads wait, a 16 px `accent` pill with the count (10.5 px semibold `accent_foreground`, radius 8); - "off" in `dim` when the Inbox isn't running, "…" while it connects. ## How it behaves - **Finding the Inbox.** It reads the port from Plannotator's own record, `/inbox/inbox.json`, where the data dir is `props.dataDir`, else `~/.local/share/plannotator`, else `~/.plannotator`. It only ever talks to `http://127.0.0.1:`, and checks `GET /api/inbox/health` first. The record is read again after any failure. - **Live.** Every 3 seconds it asks what changed since its last look (`GET /api/inbox/events?cursor=N&once=1`). Any change reloads the list, and the open thread when the change touches it. A new server session (the Inbox restarted) reconnects; no answer shows "isn't running" (or "off") until it answers again. Archived threads aren't listed. - **Opening a thread** marks it seen (`POST /api/inbox/threads/:id/seen` through its newest message): the dot and "new since you looked" clear. It never marks a thread read: that would close its open questions unanswered. - **Answering.** Click a choice to pick it (single: one; again to unpick; multiple: any), or type in a free-text box. Send posts one reply per message that asked: the picks and text for that message's open questions, with any words in the reply box on the last one (`POST /api/inbox/messages/:id/reply`). Words alone go to the newest agent message. The agent gets one message with your words and an "Answers to your questions" section, as from the Inbox's window. Each Send carries a key kept for its retries, so a second click on the same content never posts twice. If the question changed meanwhile, the thread reloads and says so. - **Open in browser ↗** opens the same thread in the Inbox's window (`…/#thread=`), for what the pane doesn't draw: images, attachments, action items, the board, settings. A link in a message opens in the browser when it's `http(s)`; others do nothing. - **Start the Inbox** runs `plannotator inbox --background` (with `PLANNOTATOR_DATA_DIR` set when `props.dataDir` is). - **Notifications.** When an agent asks something new (an open question or action item it hasn't announced before), a Herdr notification: " asks you" (or "needs you to do something", or "N new questions in your Inbox") with the question, at most 200 characters. Each is announced once, remembered across reloads (the last 500). Answering or sending never announces again. The indicator does the notifying whenever it's in the layout (`props.indicator`, default node id `inbox-indicator`); the pane then stays quiet, so nothing notifies twice. Clicking a notification runs `plannotator-inbox.open` (the indicator opens the pane), or `props.openCommand`; it has no click when the pane already shows. - **The indicator's click** opens the pane, or closes it when it already shows: it selects the pane's node in its stack and shows the container (`layout.select`, `layout.show`, `layout.hide`). - **Commands**: `plannotator-inbox.open` and `plannotator-inbox.toggle` do the same from a key or another mod. Herdr delivers mod commands to shown copies only; the indicator always is. - **Badges.** The number of threads waiting on you is kept in shared state `plannotator-inbox.waiting` (null when none), for a tab-bar button's badge. - A copy with `props.dataDir` set (a test against a throwaway Inbox) never notifies and never writes the badge. ## Built from - **One mod**, `mods/plannotator-inbox/`: - `mod.json`: `{ "place": "none", "title": "Inbox" }`: it shows only where a layout puts it. - `main.js`: the view, both modes. Network work only in `cx.spawn`, never in `render`; a 3 s `cx.timer`. - `api.js`: finding the Inbox (`readTextFile`, `home`) and its routes, with `fetch` and no Origin header (the Inbox refuses a foreign Origin with 403; Herdr's fetch sends none). Thread and message ids are checked against `^msg_[0-9A-Z]{26}$` before they go into a path. - `model.js`: pure helpers (no Herdr): the body without question blocks and with images as text, sections and counts, the reply plan, the event-stream parser, which records announce a notification. - `inbox.svg` (Lucide "inbox", ISC; `LICENSE-lucide.txt`), `LICENSE`. - **The Inbox's routes**, the ones its own window uses: `GET /api/inbox/health`, `GET /api/inbox/threads?archived=exclude`, `GET /api/inbox/threads/:id`, `POST /api/inbox/threads/:id/seen` `{idempotency_key, through_seq}`, `POST /api/inbox/messages/:id/reply` `{idempotency_key, words?, questions: [{key, revision, answer: {v: 1, key, kind, prompt, selected, text?}}]}`, `GET /api/inbox/events?cursor=N&once=1` (a finished event stream: a `hello` frame with the next cursor and the server session, then one `record` frame per change). - **Herdr**: `props`, `theme`, `layout`, `run` (`layout.select`, `layout.show`, `layout.hide`), `nextCommand`, `notify`, `shared` / `setShared`, `exec` (`plannotator`, or `env` with `PLANNOTATOR_DATA_DIR`), `readTextFile`, `home`; `localStorage` for announced question ids; `TextView.markdown`, `TextareaState` / `Textarea`. - **Props**: | Prop | Default | | |---|---|---| | `mode` | pane | `"indicator"` for the status-bar piece | | `dataDir` | the locations above | Plannotator's data dir, when `PLANNOTATOR_DATA_DIR` names another (mods can't read environment variables) | | `thread` | | a thread id to open straight away (pane) | | `panel` / `stack` / `node` | `panel` / `panel-body` / `inbox` | the container the indicator shows, the stack in it, and the pane's node in that stack | | `indicator` | `inbox-indicator` | the indicator's node id (the pane stays quiet while it's in the layout) | | `openCommand` | `plannotator-inbox.open` from the indicator | what a notification's click runs | | `background` | `chrome` | the indicator's background, a theme color name | - **Placement** (Herdr's shipped `main` layout already has a hidden `panel` column holding a `panel-body` stack of Files and Changes; clone it first, as shipped layouts are read-only): - the pane, as a third child of that stack: `{ "id": "inbox", "type": "block", "content": { "mod": "plannotator-inbox" } }`; - the indicator, in the status bar. In `main` the status bar is a bare 28 px block (`"id": "status"`, `workspace-status`) in the `work` column; replace it with a row holding it and the indicator: `{ "id": "status-bar", "type": "row", "size": { "px": 28 }, "children": [ { "id": "status", "type": "block", "content": { "mod": "workspace-status" } }, { "id": "inbox-indicator", "type": "block", "size": { "px": 104 }, "content": { "mod": "plannotator-inbox", "props": { "mode": "indicator" } } } ] }`. A layout whose status bar isn't `chrome` passes its color as `"background"`; - optionally a tab-bar button, with a tab bar that takes configured buttons (Better Tabs: `{ "id": "inbox", "label": "Inbox", "icon": "mods/plannotator-inbox/inbox.svg", "badge": { "shared": "plannotator-inbox.waiting" }, "action": { "type": "panel", "container": "panel", "stack": "panel-body", "target": "inbox" } }`). - **Keys** (`keys.json`, merged into the person's): `"global": { "cmd-shift-i": "plannotator-inbox.toggle" }`. It reaches the indicator, so it needs one in the layout. - **Tests** (`tests/`, bun): `notify.test.ts` (pure) and `inbox.test.ts`, end to end against a throwaway Inbox: `INBOX_DATA_DIR= bun test tests/`, after `PLANNOTATOR_DATA_DIR= plannotator inbox --background`. ## Watch out - **These are the Inbox window's own routes, not a documented API.** Plannotator ships often; a release can change them. Built and tested with Plannotator 0.28.48 and Herdr app 0.1.12, on macOS only. - **Why not the phone ("device") API.** It is documented, but it's off until the Inbox is restarted with Phones on, needs a pairing code, and pairing a device registers it with Plannotator's hosted relay (`relay.plannotator.ai`), which then gets encrypted copies of Inbox records for it. A pane on the same computer needs none of that; the window routes answer any local client that sends no foreign Origin. - **Never call `/read`**: it closes the thread's open questions unanswered and tells the agent they were set aside. Opening uses `/seen`. - **A mod starts the first time its block shows.** The pane in a hidden panel doesn't run until it's opened once after Herdr starts, so without the indicator there are no notifications or badge until then. The indicator, always shown, runs from the start. - **Mod commands reach shown copies only.** A notification's click goes to the indicator; a pane notifying alone (no indicator) has no click unless `props.openCommand` names a command that works from anywhere. - **Images aren't drawn.** `TextView` would try to load them, and the Inbox serves message images only to its window. They're written as `[image: alt]`; Open in browser shows them. - **Answers are checked by the Inbox**: the prompt and kind must match the question as served, labels must be its choices, and `revision` the current one. A pick in the Inbox's window between your load and Send makes Send fail with a revision conflict; the pane reloads. - **Seeding test threads**: `plannotator inbox call --session send_message` refuses a session other than the shell's own inside an agent's shell (`PLANNOTATOR_SESSION_TAG`); run it with that variable unset. One session sending to the same subject again continues the same thread, so each test run uses its own session. - **`herdr-app check` blocks `fetch`**: it proves the first screen ("Connecting…"), not the list or a thread. - Agent messages in the Inbox render as Markdown; treat them as untrusted: only `http(s)` links open. ## Done when - `herdr-app check mods/plannotator-inbox` passes, and `bun test tests/` passes (9 tests) against a throwaway Inbox. - With the pane in a side panel: the list shows the threads waiting on you under their sections, with dots, counts and first questions; clicking one opens it with its messages and question cards, and the dot clears. - Picking choices and typing an answer, then Send, posts one reply the agent sees as "Answers to your questions"; the cards turn to "Sent"; a second Send of the same content posts nothing new. - With the indicator in the status bar: it shows the waiting count; a new agent question pops one notification within about 3 seconds (only one with the pane open too); clicking it, the indicator or ⌘⇧I opens the pane on the Inbox. - With the Inbox stopped: the indicator says "off", the pane offers "Start the Inbox", and clicking it brings the Inbox back.