# Space groups Herdr's spaces sidebar with folding groups of the person's own: a header per group ("shop", "blog") with its spaces under it, made and filled from the right-click menu. Folded, a group still shows the most urgent agent status of its spaces. ![Space groups](preview.png) ## What you see - Herdr's spaces sidebar as shipped (colored avatars, worktrees under their repo, git tail, a header per machine when there are several), plus group headers inside each machine's section. - A group header: 26px high, 8px side padding, 7px gap, 12px `muted` medium text, rounded 7: chevron (`chevron-down`/`chevron-right` 11px, `dim`), `folder.svg` 13px `dim`, the name (truncated), and on the right the number of spaces in it (11px `dim`, worktree rows not counted). Hover: `hover` background. - A group's space rows follow the header, indented to 18px on the left (instead of 8). - Folded: only the header; a 7px round dot in `tone(status)` (the theme's `blocked`, `done`, `working`, `idle`) before the count when any space has a status; the header has the `selected` background when the shown space is in the group. - Narrow rail (< 160px): header 22px high, centered: the name's first two letters (10.5px) and the same dot when folded. Folded members' numbers are skipped, so the numbers stay Herdr's `space.select:N`. - The right-click menu (Herdr's menu look: popover background, 31px rows, rounded 7, 14px `muted` icon, key hint on the right): Rename, New/Open/Remove worktree as Herdr's, a rule, `Move to ` per other group (`folder.svg`, sorted by name), `New group…` (`folder-plus.svg`), `Remove from ` (`minus.svg`) when in one, a rule, Close. - On a group header: `Rename group` (`square-pen.svg`), `Ungroup` (`x.svg`). - New group… / Rename group turn the popup into a name field: an 11.5px `dim` line ("New group: name, then Enter") and a 32px input with an `accent` border. ## How it behaves - Click a group header: fold/unfold (per screen, `localStorage` "groups.folded"). - Move to / New group put the space in the group and, if the group has other spaces on its machine, `space.move` it right after the last of them. Remove from takes it out and moves it after the group's last remaining space (out of the middle). So a group is always one run in Herdr's order, and `space.next`/`prev` follow the list. - Ungroup forgets the group; its spaces stay in place. - Drag (expanded list): dropping a space on a row lands it next to that row (Herdr's drag) and gives it that row's group, or none for an ungrouped row. - A group shows at its first space's place; a worktree row belongs to the group of the row it is nested under. - Agent statuses: a folded group's dot is the most urgent of its spaces' `status` (blocked > done > working > idle); no status, no dot. Unfolded, rows look as in Herdr. ## Built from - `mods/space-groups`: `herdr-app do mod.clone '{"name":"spaces","as":"space-groups"}'`, then: `section()` splits a machine's rows into groups, `groupHead()` draws a header, `pruneGroups()` (in the 250ms `checkNew` timer) drops closed spaces and empty groups, `row()`'s mouse-up sets the dragged space's group, right-click opens `space-groups-menu` (popup 220×420) with `{tab: "space", target: {id}}` or `{tab: "group", target: {group}}`. - `mods/space-groups-menu`: `mod.clone` of `menu`, keeping only the space items, plus the `group.*` items handled in the mod (`act`), and an `InputState`/`Input` name field. - State: `shared("space-groups")` = `{ names: { : name }, of: { : } }`, written by both mods with `setShared`. Group ids are `g` + base-36 time. Space ids as `spaces()` gives them (`/…` for another machine). - A layout clone of `main` whose `spaces` block has `content.mod: "space-groups"`. - herdr: `spaces()`, `machines()`, `shared`/`setShared`, `openOverlay`, `closeOverlay`, `run("space.move" | "space.select" | "space.rename" | "space.close")`; the menu's worktree items run `git rev-parse` (`exec`, on the space's machine), as Herdr's. - Icons: Herdr's `mods/workspace-chrome/*.svg`. ## Watch out - `space.move {id, index}`: `index` is the 1-based place the space ends at, in the whole `spaces()` list: after the last member at 0-based `last`, that is `last + 1` when the space comes from above it, `last + 2` from below. - Prune closed spaces only for machines whose `machines()` layout is `ready`: while a machine's layout isn't readable, its spaces may be missing from `spaces()` without being closed. - `setShared` from `render()` didn't reliably stick here; prune from a timer. - Mods can't import across mod folders, so the group state shape is written in both mods. - `herdr-app check` runs with no spaces; code in `init` must cope with that. - A popup menu has no submenus: one `Move to ` item per group. ## Done when - `herdr-app check` passes for both mods; `herdr-app status` shows no errors. - New group… on a space makes a header with that space under it. - Move to on a space elsewhere in the list moves it right after the group's spaces (`herdr-app ls` order) and under the header. - Remove from on a middle member puts it right after the group, ungrouped. - A folded group with a working agent in it shows the `working` dot; with the shown space in it, the `selected` background. - Closing a group's last space removes the group from `shared.json`.