# New Space A modal for choosing where a new Herdr space opens: this computer or a remote machine added with `hc machine add`, with the folder the first terminal starts in. It is a piece you wire into your own layout or mod, like a button that opens a dialog; it does not replace the sidebar’s + by itself. ![New Space mod](preview.png) ## What you see - A centered dialog titled **New space**, 520 px wide, on your theme’s popover background. Esc is shown at the top right. - A short explanation: choose where the first terminal starts; leave the path empty to open the machine’s home folder. - An **Environment** section: a full-width row for **This computer** (monitor icon, “local shell”), then one row per remote machine known to this Herdr connection (server icon, machine name, “remote”, “checking connection…” or “unavailable”). The selected row uses the theme’s selected background, an accent border and a check icon. - A **Path** section: one text input. The placeholder is `~/project or leave empty for home` for local, and a hint below says `Absolute path, or ~ for your home.` For a remote machine the hint says `Path on the remote machine, e.g. /home/you/project.` - A **Browse…** button on the local row only, opening the system folder picker. - A footer with **Cancel** and **Create space** (primary solid button). Create space is dimmed while the chosen remote machine is not ready. - Empty states: a machine that is unavailable stays greyed out and cannot be selected or created; a machine still loading shows a spinner and Create space stays disabled. ## How it behaves - Nothing of this mod appears in the layout by itself: `mod.json` uses `place: "none"` and opens only as a dialog. - Open it with `herdr-app do mod.open --name new-space` or from your own button/mod with `openOverlay({ mod: "new-space", kind: "dialog", modal: true, width: 520 })`. - Selecting a row chooses the environment. The local row is always available. Remote rows come from `machines()` and show `ready`, `loading` or `unavailable`. - **Create space** calls `space.new { machine, folder }`: - `machine` is `""` for this computer, the machine name for a remote one. - `folder` is the trimmed input; if empty, it is omitted so Herdr opens the machine’s home folder. - On the local machine, a leading `~` is expanded to the local home directory before creating. - **Enter** submits the form; **Esc** or **Cancel** closes the dialog. Clicking outside does not close it (`modal: true`). - The optional folder picker (`pickFolder`) is local only. There is no remote folder picker; type the path on that machine. - The dialog shows an error note instead of creating when the chosen remote machine is not ready. - Creating the space closes the dialog and lets Herdr’s normal `space.new` behavior pick the new space. ## Built from - **One mod**, `mods/new-space/`, with `main.js` and `mod.json`. The manifest has `place: "none"` and `overlay: { kind: "dialog", width: 520 }`, so there is no `layouts/` folder and no layout change. - **`gpui-kit` and `gpui-base`**: `View`, `div`, `svg`, `v_flex`, `h_flex`, `InputState`, `Input`. Icons come from the shipped `mods/workspace-chrome/` set (`monitor.svg`, `server.svg`, `spinner.svg`, `check.svg`, `folder.svg`); set `size` and theme color on each. - **`herdr` module**: `machines()` (this computer and remotes by name and `layout` state), `props()`, `run()`, `closeOverlay()`, `pickFolder()`, `home()`, `theme()`. - **Commands**: `space.new` only, with `{ machine, folder }`. - **No network, no subprocesses, no file reads or writes.** `pickFolder` asks the operating system for a folder and returns the path it chose. - **Wiring is up to the person adding it.** A `keys.json` snippet can open it, for example: ```json { "global": { "ctrl-shift-n": "mod.open:new-space" } } ``` A sidebar button opens it with `openOverlay({ mod: "new-space", kind: "dialog", modal: true, width: 520, props: { machine: "" } })`; pass `{ machine: "" }` to preselect a remote machine. ## Watch out - This mod does **not** change an existing + button. Add the open call yourself; otherwise `mod.open` is the way to see it. - Remote machines must be visible to `machines()` and in `ready` state before a space can be created there. Offline, loading or unavailable machines are shown but cannot be created. - The folder path is used as typed. Herdr does not test that a remote path exists before calling `space.new`; spell it for that machine (`/home/...`, not `H:\...`). - Windows paths with spaces are fine in the input; they are not re-escaped beyond the trim of surrounding whitespace. - `~` is expanded only for this computer. On a remote machine, type an absolute path or leave it empty for its home. - The dialog is fixed at 520 px; it should fit any window Herdr supports, but very short windows may clip the remote list. - Follow the installed `herdr.d.ts` and `gpui-kit.d.ts`; do not edit shipped mods. Keep `mod.json` `place: "none"` if you want it to open only on demand. - Before publishing or sharing, check the preview: it shows your real machine aliases. ## Done when - `herdr-app check ~/.config/herdr-app/mods/new-space` passes. - `herdr-app do mod.open --name new-space` opens the dialog and `overlay.close` or Esc dismisses it. - This computer is selectable and Create space makes a space there. - With no remotes connected, the list shows only This computer. - With a remote connected, it shows `remote` and Create space makes the space on that machine. - With a remote unavailable, it is dimmed and cannot be created. - An empty path creates a space in the machine’s home; a typed local path with `~` becomes the local absolute path; a typed remote path is sent unchanged. - The app reports no errors in `herdr-app status`, and opening/closing does not dock the mod into the layout.