agentleFS
devswhadevswha/herdr-web-ui/src/AGENTS.md

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.

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
  1. Distinctive:

    Never persist the auth token client-side: the HttpOnly cookie is the only storage.

    line 6
  2. Distinctive:

    Never hardcode a color in component CSS: the light theme is only token overrides.

    line 8

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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 through socket.submit() (WS submit when the snapshot advertises features:["submit"], else input + \r). Never add another send path or a direct socket.sendKeys from 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

  • MachineContext binds 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 health scope=bridge.

CONVENTIONS

  • main.tsx owns the side-effect imports: ./styles.css and ./lib/viewport.ts load there, never inside components. ./styles.css is imported BEFORE ./App.tsx: Vite emits CSS in import order, and a component stylesheet's single-class override of a primitive (.sidebar-footer-action over .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.css next to X.tsx); new component styles go there, not into styles.css. Override primitives at the same specificity and rely on order, never on !important or selector stacking.
  • Status surfaces (conn pill, banners, tree states) use role="status"; only the sidebar error block uses role="alert".
  • index.html owns document meta (interactive-widget=resizes-content, theme-color, manifest link); client code never re-declares it.

WHERE TO LOOK

TaskLocationNotes
Remote PCs UIcomponents/MachineSidebar.tsx + MachineDialog.tsxserver side is in server/AGENTS.md; docs/remote-pcs.md
App shell + render statesApp.tsxlocked === 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/lifecyclecomponents/PaneTerminal.tsxone 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 modecomponents/PaneTerminal.tsxNO 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 draftcomponents/PaneTerminal.tsx + lib/draft.tsinput during a disconnect accumulates in a draft (printable only); the review banner offers Send/Discard after reconnect
Geometry/fitcomponents/PaneTerminal.tsxfit 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 barcomponents/KeyBar.tsx + lib/keys.tstaps call term.input(keySequence(key, term.modes.applicationCursorKeysMode)), reusing the onData → WS path; one-shot Ctrl is armed in PaneTerminal; hidden while observing
Chat composercomponents/Composer.tsx + lib/compose.ts + lib/mentions.tsEnter 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 panelcomponents/SessionPanel.tsx + lib/activity.tsderived 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 lenscomponents/ChatView.tsx + Markdown.tsx (lib/markdown.ts) + lib/workBlocks.ts + PromptCard.tsxsplitTurn 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 rostercomponents/Sidebar.tsx + TabStrip.tsxrendered 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 tabcomponents/NewSessionDialog.tsxcreateWorkspace, 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 palettecomponents/CommandPalette.tsx + lib/paletteSearch.tsMod+Shift+K; panes (recent first, fuzzy ranked) + actions with .kbd hints; Escape closes
Settingscomponents/SettingsDialog.tsx + lib/settings.tsSettingsProvider 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
Shortcutslib/shortcuts.tsuseShortcuts(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 clipboardlib/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 badgescomponents/Sidebar.tsx StatusBadge + lib/status.tsONE 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)
Notificationslib/notifications.tstab 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 pushlib/push.ts + App bell + public/sw.jsensurePushSubscription (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 clientlib/api.tsfetchSession / fetchHealth / authenticate / signOut; ApiError carries status + code
App updateslib/updates.ts + components/UpdateControls.tsxauthenticated 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 clientlib/ws.tsHerdrSocket; role replays before attaches on reconnect; input/keys are NEVER queued — the UI draft owns them
Mobile keyboardlib/viewport.tspublishes visualViewport.height as --app-height and pins scroll to (0,0); pairs with interactive-widget=resizes-content in index.html
PWApwa.tsregisters /sw.js in secure contexts only; a plain-http LAN IP runs uncached by design
Stylingstyles.css + colocated .cssstyles.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
Iconslucide-reactthe one icon set; AgentMark.tsx keeps the provider brand marks
Workspace drawer / a11yApp.tsxtoggle is aria-expanded + aria-controls="workspace-drawer"; scrim closes on tap; conn pill and banners are live regions

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.