# New Workspace Flow: one agent, one worktree, one PR A one-dialog way to start an agent on new work, following the pattern of agentic workspace apps such as Paradev (formerly Superset): one agent lives in one git worktree, which becomes one PR, so parallel agents stay isolated. You pick an agent and a model and write a prompt (screenshots and PDFs can come along). It makes a git worktree, opens it as a Herdr space, runs the repo's setup in a `setup` tab, and starts the agent on the prompt in the tab beside it. Nobody types a branch name: it comes from the prompt. ![New Workspace Flow](preview.png) ## What you see A dialog, 680×640, `popover` background, 13 px text: - **Header:** a folder-plus tile (34 px, `selected`, `accent` icon), "New workspace" (15 px semibold), and under it the repo name · branch icon · base branch. An × closes the dialog. - **Agent:** one pill per installed agent (from `knownAgents()`, with its icon) plus "Terminal only". The selected one is on `raised`. - **Model:** for Claude, segmented Default / Fable / Opus / Sonnet / Haiku. For other agents, a text field (blank means the agent's default). - **Prompt:** a 6-row textarea. Under it, an "Attach" button with "Images & PDFs · drop or paste anywhere", and attached files as 44 px thumbnails (a PDF gets a file tile) showing name, type and size, each with a remove button. - **Summary card (`surface`):** "Starts as · the agent renames it after the issue, then the PR", and either "Setup runs " or "No .superset/config.json, so no setup tab". - **Footer:** "esc to cancel", Cancel, and a solid **Create workspace ⌘↵** button (a spinner while it works). - **Errors:** shown in `blocked`. ## How it behaves - **Which repo:** the focused space's, or props `{ space }` / `{ folder }`. If the folder isn't in a repo, it says so. Spaces on other machines aren't supported. - **Name and branch:** the space is named from the prompt (`issue 12 Fix the login bug` when the prompt mentions `#12` or an issue URL, otherwise its first few words). The branch is the same name slugified (`issue-12-fix-the-login-bug`), with `-2`, `-3` and so on added if it's taken. The worktree goes to `~/.herdr/worktrees//`, the same place Herdr's shipped worktree mod uses, so sidebars nest it under its repo. - **Setup:** if the repo has `.superset/config.json` with a `setup` array, those commands run in a `setup` tab with `SUPERSET_ROOT_PATH` and `SUPERSET_WORKSPACE_NAME` set, and the agent starts in a second tab. Without setup, the agent is the only tab. - **Attachments:** drop files on the dialog, paste a screenshot into the prompt, or click Attach (macOS file picker). Images and PDFs are copied into the worktree's `.herdr-attachments/`, which is added to the repo's `info/exclude` so it never gets committed. The prompt then lists their paths for the agent. - **Keys:** `cmd-enter` creates and Esc cancels. ## Built from - `mods/new-workspace/main.js` plus its SVG icons. `mod.json` has `place: "none"` and a dialog overlay of 680×640. - **Herdr calls used:** `knownAgents()`, `spaces()`, `panes()`, `focused()`, `readTextFile`, `exec`, `space.new {name, folder, tab, argv, task}`, `tab.new {space, folder, name, argv, task}`, `nextCommand()` for `new-workspace.create`. - `keys.json`: `cmd-shift-n` → `mod.open:new-workspace`, and in `mod:new-workspace` `cmd-enter` → `new-workspace.create`. - Sidebars can open it with `{ space }` (for example, a repo row's `+` in space-streams). ## Watch out - **Runs programs:** `git` (worktree add, show-ref, rev-parse), `cp`, `rm`, `stat`, `test`, `sh`, and `osascript` for the file picker and clipboard paste. It writes into the new worktree, the repo's `.git/info/exclude`, and its own staging folder `data/new-workspace/` in the Herdr home, which is cleaned on open and close. - **macOS:** Attach and paste use AppleScript. Dropping files works everywhere. - **Models:** only Claude has a fixed model list (it passes `--model `). Other agents take a typed model name. - It never asks for a branch. Agents are expected to rename the space (and branch) once they know the issue or PR. ## Done when - `cmd-shift-n` in a repo's space opens the dialog showing that repo and its base branch. - Writing "Fix #12 login redirect" and pressing `cmd-enter` makes `~/.herdr/worktrees//issue-12-fix-login-redirect` and a space "issue 12 Fix login redirect" with the agent running the prompt. - With `.superset/config.json` present, a `setup` tab runs its commands first. - A pasted screenshot ends up in `.herdr-attachments/` and the prompt lists it. - `herdr-app check` passes.