herdr-web-ui / src
AGENTS.md459 starsChanged 2 months agoMITView on GitHub
React 18 + xterm.js browser client. The render-state machine, xterm lifecycle and mobile-keyboard handling live only here.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- AGENTS.mdAGENTS.md
- server/AGENTS.mdAGENTS.md
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 6
Never persist the auth token client-side: the HttpOnly cookie is the only storage.
- Distinctive: line 8
Never hardcode a color in component CSS: the light theme is only token overrides.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
src/
React 18 + xterm.js browser client. The render-state machine, xterm lifecycle and mobile-keyboard handling live only here.
ANTI-PATTERNS
- Never persist the auth token client-side: the HttpOnly cookie is the only storage; no localStorage/sessionStorage anywhere.
- Key bar taps and Stop go through
term.input(); Composer and TerminalInput sends go throughsocket.submit()(WSsubmitwhen the snapshot advertisesfeatures:["submit"], elseinput+\r). Never add another send path or a directsocket.sendKeysfrom KeyBar or Composer. Prompt-card answers go through the server (/api/pane/prompt/answer), because the key semantics per agent live there. - Never hardcode a color in component CSS: the light theme is only token overrides.
term.reset()fires only in the paneId effect, never mid-stream.- Output ACKs run in xterm's write callback and capture the connection and pane subscription; never queue them across reconnects or pane switches. A 4008 overload close stops automatic reconnect and shows a notice; selecting another pane explicitly reconnects. Normal reconnect replays stored role/attach/geometry once, without a second control-frame queue.
REMOTE TARGET OWNERSHIP
MachineContextbinds every pane/workspace API call to a PC; PaneTerminal and CommandPalette remount on machine changes. Never use a mutable global target for async work.- Local storage keeps legacy keys for local panes; remote drafts, held queues, lenses and caches use
paneStorageId(machineId, paneId). Held messages require Send now, including after reconnect/reload. - App consumes a combined machine roster over SSE with a periodic GET backstop. A local herdr failure must never hide remote PCs or Add PC (Settings → Remote PCs; the row does not wait for
/api/machines/settings, only the bridge switch does); auth discovery uses healthscope=bridge.
CONVENTIONS
- main.tsx owns the side-effect imports:
./styles.cssand./lib/viewport.tsload there, never inside components../styles.cssis imported BEFORE./App.tsx: Vite emits CSS in import order, and a component stylesheet's single-class override of a primitive (.sidebar-footer-actionover.btn) only wins when the primitive comes first (2026-09-21: the reversed order silently centered footer buttons and centered the palette). - Component CSS is colocated (
X.cssnext toX.tsx); new component styles go there, not into styles.css. Override primitives at the same specificity and rely on order, never on!importantor selector stacking. - Status surfaces (conn pill, banners, tree states) use
role="status"; only the sidebar error block usesrole="alert". - index.html owns document meta (
interactive-widget=resizes-content,theme-color, manifest link); client code never re-declares it.
WHERE TO LOOK
| Task | Location | Notes |
| Remote PCs UI | components/MachineSidebar.tsx + MachineDialog.tsx | server side is in server/AGENTS.md; docs/remote-pcs.md |
| App shell + render states | App.tsx | locked === null → connecting shell (no WebSocket yet); locked → AccessGate (pairing code, ?pair=CODE, or token); else full shell. 5s health+session poll (POLL_MS) as backstop; pushes (pane-status/pane-exited/session-changed) merge instantly via handleServerMessage + a debounced refetch; a selection that left the snapshot falls back to herdr's focus; view (chat/terminal) is per-pane state (herdr-web-ui:view:<pane>, agent panes default to chat); builds the AppActions object (lib/actions.ts) the header, sidebar, palette, settings and shortcuts all call; mounts NewSessionDialog / SettingsDialog / CommandPalette |
| Terminal view/lifecycle | components/PaneTerminal.tsx | one xterm per mount; term.reset() + re-attach on paneId change; theme + font size applied through term.options (no remount) and re-fit; the grid re-fits when the lens returns to terminal; ended / reconnecting pills only under the terminal lens (ChatView says them inline) |
| Roles / observe mode | components/PaneTerminal.tsx | NO UI control — App connects as interact and never asks for another role; role-ack still applies the consequences if one arrives: stdin gate (disableStdin), pane-geometry adoption, force-refit + resize when returning to interact |
| Held-input draft | components/PaneTerminal.tsx + lib/draft.ts | input during a disconnect accumulates in a draft (printable only); the review banner offers Send/Discard after reconnect |
| Geometry/fit | components/PaneTerminal.tsx | fit on attach, ResizeObserver on the host, visibilitychange refit — all SKIPPED while observing; single-finger touch drag becomes synthetic wheel events (listeners passive: false only there) |
| Key bar | components/KeyBar.tsx + lib/keys.ts | taps call term.input(keySequence(key, term.modes.applicationCursorKeysMode)), reusing the onData → WS path; one-shot Ctrl is armed in PaneTerminal; hidden while observing |
| Chat composer | components/Composer.tsx + lib/compose.ts + lib/mentions.ts | Enter or Mod+Enter sends per settings.enterSends, IME Enter never sends; / slash commands are cached 60s per pane, @ file search is debounced 150ms; Stop is Escape into the pty via onAbort; Queue when a send would land mid-run; disabled (text held, never queued) while disconnected |
| Session panel | components/SessionPanel.tsx + lib/activity.ts | derived client-side from the turns ChatView already has (onActivity); task state comes from the tool part's task; open state lives in App (herdr-web-ui:session-panel); phones (≤640px) show neither the panel nor its strip |
| Chat lens | components/ChatView.tsx + Markdown.tsx (lib/markdown.ts) + lib/workBlocks.ts + PromptCard.tsx | splitTurn folds tools/thinking/narration into one .work-block and honors explicit Codex commentary/final phases; duration = end_ts − ts; conversation polls run serially, a send refresh preserves history/scroll, a pane change resets; PromptCard polls /api/pane/prompt every 2s while blocked and answers through /api/pane/prompt/answer (409 → re-read) |
| Sidebar roster | components/Sidebar.tsx + TabStrip.tsx | rendered only inside MachineSidebar, one per PC; grouping is a setting (SidebarGrouping, by workspace or by folder); a row shows the roll-up of its panes' states (rollupStatus, lib/status.ts); workspace reorder is workspace.move, optimistic; other panes of a workspace are reached from the TabStrip, the palette and Needs you; no search or filter here on purpose, the command palette is the search; Add PC lives in Settings → Remote PCs and the palette (actions.openAddPc) |
| New workspace / New tab | components/NewSessionDialog.tsx | createWorkspace, or createTab (POST /api/tab/create) when given a tab prop; agent start may take 60s and the dialog stays open while pending; agent_started:false + error offers to open the already-created workspace |
| Command palette | components/CommandPalette.tsx + lib/paletteSearch.ts | Mod+Shift+K; panes (recent first, fuzzy ranked) + actions with .kbd hints; Escape closes |
| Settings | components/SettingsDialog.tsx + lib/settings.ts | SettingsProvider wraps App in main.tsx and writes data-theme / data-density on <html>; PhonePanel.tsx picks the address that works through lib/phone.ts phonePlan; QrCode.tsx is always dark-on-white |
| Shortcuts | lib/shortcuts.ts | useShortcuts(actions, enabled): capture-phase window keydown; every binding is Mod+Shift+key so the pty keeps Ctrl+<key>; SHORTCUTS drives the hint tables |
| OSC 52 clipboard | lib/osc52.ts + PaneTerminal parser.registerOscHandler(52) | client half of a clipboard bridge; DORMANT on herdr 0.9.x (herdr's screen-diff attach stream consumes OSC 52 before clients — live-verified); fires as a transient pill once sequences arrive |
| Sidebar badges | components/Sidebar.tsx StatusBadge + lib/status.ts | ONE vocabulary for every surface (sidebar, palette, composer status line): idle→READY, working→RUN, blocked→INPUT, done→DONE, unknown→— (STATUS_WORD, knownStatus); the composer alone reads a blank state as READY (a shell is always ready); pushed statuses land through applyPaneStatus (lib/snapshot.ts) |
| Notifications | lib/notifications.ts | tab alerts: policy re-exported from shared/notify-policy.ts; hidden-tab guard; shown via registration.showNotification (Android has no new Notification()), constructor only as fallback; skipped when this device has push (pushOnRef) |
| Web push | lib/push.ts + App bell + public/sw.js | ensurePushSubscription (SINGLE-FLIGHT: overlapping callers share one attempt, because two concurrent subscribe() calls make Chrome issue two subscriptions and keep only the later; idempotent; replaces a subscription made for another server key; runs on every load when permission is granted) and removePushSubscription (lock, before signOut); bell = off / push on / tab-only / in the app only (permission not granted; a tap asks while it is unanswered, else switches off); SW posts {type:"select-pane"} on a tapped alert, a closed app opens /?pane=<id> (App reads it as the initial selection, then strips it) |
| HTTP client | lib/api.ts | fetchSession / fetchHealth / authenticate / signOut; ApiError carries status + code |
| App updates | lib/updates.ts + components/UpdateControls.tsx | authenticated status polling; Settings check/install + header notice; compare build-time Git revision to running server, offer Reload app explicitly so unsent drafts survive bridge updates |
| WS client | lib/ws.ts | HerdrSocket; role replays before attaches on reconnect; input/keys are NEVER queued — the UI draft owns them |
| Mobile keyboard | lib/viewport.ts | publishes visualViewport.height as --app-height and pins scroll to (0,0); pairs with interactive-widget=resizes-content in index.html |
| PWA | pwa.ts | registers /sw.js in secure contexts only; a plain-http LAN IP runs uncached by design |
| Styling | styles.css + colocated .css | styles.css = :root tokens (+ [data-theme="light"], [data-density="compact"]) + shell + shared primitives (.icon-button .btn .pill .badge .segmented .kbd .modal .field .input .select .menu); component looks live in their own .css; tokens only — no color literals |
| Icons | lucide-react | the one icon set; AgentMark.tsx keeps the provider brand marks |
| Workspace drawer / a11y | App.tsx | toggle is aria-expanded + aria-controls="workspace-drawer"; scrim closes on tap; conn pill and banners are live regions |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

