Cloudflare Git

Repos/herdr-appPublic

main
51 lines · 12.5 KBRaw

mods

Each folder is a panel, copied to ~/.config/herdr-app/mods/<name>/. Leave out the app-written jsconfig.json and gpui-kit.d.ts. Read the shipped mods in the config folder as examples.

How mods work

  • main.js default-exports a class extending View (from "gpui-kit"). init(props, cx) runs once. render(cx) returns GPUI elements, not HTML. mod.json sets where the mod first docks.
  • Data and actions come from "herdr": agents(), terminals() (with labels), panes(), spaces(), theme(), run(command, args), exec. render re-runs when live data changes, so don't poll.
  • Every button gets .cursor_pointer() and a background hover (.hover(s => s.bg(t.hover).text_color(t.foreground))), not just a color change. Icon buttons are the 26px rounded(6) box.
  • No setTimeout/setInterval (use cx.timer). No top-level await (use cx.spawn). Never keep a cx. Animate with .frames/.spin/.loop/.transition, not a timer. Guard side effects with if (checking()) return;.

Gotchas

  • herdr-app check and herdr-app status can both pass while rows that render only with live data fail. A red banner in the panel is the only sign, so herdr-app shot after every change.
  • No line_clamp. For N lines: whitespace_normal().line_height("16px").max_h(16 * N).overflow_hidden(). That clips without "…".
  • A bare number in line_height is a multiplier. Use "18px" for pixels.
  • Use px text_size(n), like the shipped mods. The named sizes (text_xs, text_sm, text_base, text_lg) scale from the 13px UI font, not 16px: about 9.75, 11.4, 13 and 14.6px. Tried for the activity line and it came out too small. agents-activity instead wraps every size in px(n): n px at the default 13px UI font, scaled by settings().ui_font_size.

agents-activity

A clone of the shipped agents mod (cloned_from 0.1.16). Changes are in the row builder in render:

  • The name is bold at 14.5px.
  • Under it is an activity line at 12px (16px line height), up to three lines. It shows the terminal's kit.activity label (set by hooks/herdr-activity.sh), else the agent's title cleaned of its status glyph.
  • One flat list, no section headers and no sort menu: pinned first, then the agent that last appeared, finished or needs you on top (top, stamped by track). Starting work doesn't move a row, and neither does done turning idle when you look at it. Each row's space tile carries its status as a dot on its corner (badge, the same as the rail's; a ring when idle), which leaves the right edge to the age. Sub-agent rows keep the small marks.
  • The list doubles as the spaces list (the spaces block is gone from kit): each row shows its space's letter tile (color from shared space.colors; this mod and search assign new spaces one the same way, since the shipped spaces mod that used to is no longer in kit) instead of the program icon, and names its space; a space with several agents keeps "· tab" after its name even with an activity line, but only a tab named by hand, never a bare tab number. A hovered space tile (sidebar or rail) gets a backdrop (muted at 30%, lighter than the hover color, which barely shows in the thin band around a tile), drawn 3px past its cell into the gap so the grid doesn't shift. Every space shows as a tile in a "Spaces (N)" section at the bottom, below the agents and just above Settings, last used first like search (shared space.used; space.select on click), with a + for space.new. The grid is laid out by column (the count from its measured width, divided by settings().zoom, since the width is zoomed and the cells aren't), each column one HoverCard, so hovering a tile shows its column's card after 120ms above the column's top tile and never over a badge (the pointer on a card keeps it open): the hovered space's name (tracked with on_hover) in white on the space's color, with an arrow down the column in the same color (caret-down.svg; the built-in .tooltip waits 500ms).
  • Folded to the rail (sidebar under 160px), rail() draws it instead: open (toggleSidebar) and search (search) buttons up top, each agent as its space's 24px tile with a status badge (focuses its pane), then, at the bottom just above Settings, the last used 8 spaces' tiles, two to a row (selects it), and a "+N" toggle (this.railAll) that shows the rest or folds them back (a chevron-up), so the spaces never need a scroll bar. Hovering a tile shows a HoverCard to its right with an arrow back to the tile (caret-left.svg, drawn like the expanded cards' caret.svg): for an agent, a 236px card in its space's color (white text, no tile): a status pill in the status color, then its space and age on one line, its activity under them; for spaces, each row of two badges shares one card, opened past the right column so it never covers the other badge (the pointer on a card keeps it open): it names the badge under the pointer (tracked with on_hover) on that space's color, sized to fit. The old numbered rows and the » at the bottom are gone. ⌘B runs the same fold and open: keys.json sends agents-activity.toggleSidebar, which init reads from nextCommand().
  • A new space on this computer, from the Spaces "+" or search, starts in ~/Developer/projects (Herdr has no setting for it). On another machine it keeps Herdr's default, that machine's home.

search

A clone of the shipped picker (cloned_from 0.1.16), opened by ⌘S. It lists every space, last used first (shared space.used, stamped by agents-activity whenever the shown space changes), instead of busy-first with quiet ones folded into "earlier". It opens on the previous space, so ⌘S then Enter goes back, and that row says so with a dim "↵ previous" at its right until the selection moves or a filter is typed (this.previous). There is no separate hover style: moving the pointer onto a row selects it (on_mouse_move, which fires only on real movement, so a row that slides under a still pointer while typing or arrowing doesn't), so the selection is the one highlight and is what Enter and a click both open; ↑/↓ go on from there. The shown space is a header with its tabs indented under it on tree branches (├ to each tab, └ on the last, the line running down from under the space's tile and stopping there); every other space is one row (its tile, its name, and "— " its agent's kit.activity label or cleaned title, never a bare program name) that goes to its shown tab. While filtering, a space with several tabs lists its matching ones the same way. Every tab row starts with an icon: its program's (first agent, else first terminal; as pane-header draws it, icons/shell.svg when the program has none), or the file icon. An agent tab nobody named shows the same line as the sidebar (its kit.activity label, else its title with the status glyph stripped, else the program's name), not its number; a file tab (a file-view pane, named by its full path) shows the file icon, its name, and its folder dimmed, from the space's folder or else from ~. Only working, blocked and done get a mark; idle gets none, and the program's name is gone from the right edge. The sidebar search icon opens it too (sidebar-frame).

sidebar-frame

A clone of the shipped workspace-chrome (cloned_from 0.1.16): the sidebar's brand header and footer. The changes: the search icon opens search instead of picker, the footer has only Settings (Add machine is reachable from Settings, so its row is gone and kit's footer block is 41px), and its SVGs live in icons/. Other mods (agents-activity, search) still load their icons from mods/workspace-chrome/, which stays installed.

files-tabs

A clone of the shipped files (cloned_from 0.1.16), in kit's Files panel. The changes: clicking a file opens it in a new tab (tab.new with the file-view mod and props: { file, on }, named by the file's full path, then moves it last with tab.move, since tab.new puts it beside the selected tab, or selects the tab where it is if that file is already open in the space; tabs-files shows the file icon and name in the bar, pane-header the icon, name and folder) instead of previewing it inside the panel, so the in-panel preview code is gone; and when the focused pane has no folder (a file tab), location() keeps the folder already shown instead of falling back to the space's saved folder. Git changes: a changed file or folder's name takes the change color (added ansi2, deleted or conflicted ansi1, modified blocked), a folder shows how many changed files are under it at any depth (in a tinted pill, added only if they all are), and a file its letter; both sit in one 18px column at the right edge. Worktrees: when the repo has more than one checkout (git worktree list, asked from the pane's folder), the header's folder name becomes the shown checkout's branch with a chevron, which opens a list of them under the header. Each checkout in the list shows how many files it has changed (one git status per checkout on each refresh), and the branch button shows the total for the checkouts not shown, so an agent working in another worktree is visible without opening the list. Picking one shows it, git marks included, until you pick the checkout holding the pane's own folder again (the deepest checkout wins, since Claude Code puts worktrees inside the main one, in .claude/worktrees/). The pick is kept per pane folder and dropped once its worktree is removed. It exists because an agent's subagents work in worktrees while its pane stays in the main checkout.

file-view

Not a clone. A read-only, syntax-highlighted view of one file (props().file, props().on for another machine), shown as a tab by files-tabs. Its viewer code is the shipped files preview, moved here. A file with uncommitted changes opens on a Changes view (git diff HEAD, drawn with the shipped changes mod's diff rows), with a File toggle for the whole file. Both follow the file while the tab is open: a folder watch on its folder plus the repo's .git (HEAD, index, refs, so a commit clears the diff) when local, or every 10 seconds on another machine; the File view updates in place with set_value. Untracked files have no diff and open on the file. A Wrap toggle at the right of the bar above the file (shown on every file now, not only changed ones) wraps long lines in both views, per tab and off by default. The editor only takes soft_wrap when it's made, so toggling remakes it from its current text; wrapped diff rows vary in height, so that view drops the virtual list for a plain scrolling column (the diff is capped at 1500 rows). An image (png, jpg, gif, webp, bmp, ico, tiff) shows as a picture, fit to the tab, with no Wrap toggle. image() only reads inside the config folder (absolute paths and ../ show nothing), so it shows a copy in cache/file-view/ there, named by a hash of its content so an edited image shows anew; copies over a day old are cleared on each load. An image on another machine isn't shown. Markdown (.md, .markdown) and SVG also get a Preview, which they open on unless they have changes: Markdown rendered (TextView.markdown, selectable), SVG as a picture through the same cache (local only). The bar then reads Changes (if any), Preview, Raw; Raw is the text, with Wrap. Without a preview the last button is File.

pane-header

A clone of the shipped pane (cloned_from 0.1.16), kit's pane header. The only change: a file-view pane reads like an agent's, from its tab's name (the file's full path, set by files-tabs): the file icon (mods/files-tabs/file.svg), the file name, then its folder from ~.

tabs-files

A clone of the shipped tabs (cloned_from 0.1.16), kit's tab bar. The changes: a tab whose lead pane is file-view shows the file icon (mods/files-tabs/file.svg) and only the last part of its name (the file's name); the folder is in the pane header. An agent tab not renamed by hand shows its space's 16px letter tile (color from shared space.colors, as in agents-activity) and the space's name, instead of the program icon and the agent's live terminal title: a tab can hold several agents, so one agent's title doesn't stand for it. That counts a file tab with an agent split into it: its path name isn't a hand-given name, so its first agent's space tile and name show instead of the file. File tabs (a file-view first, no agent) always sit after every other tab: whenever a tab is found after a file tab, the bar moves it in front (tab.move), so a new agent or terminal tab never lands behind the files. File tabs keep their X when not selected, so a row of them closes quickly; other tabs show it only when selected.