# Open with Zed Herdr's `+` menu, the popup that opens from the `+` button in the tab bar, with one extra row: **Open with Zed**, right below **Terminal**, with the Zed logo. Clicking it opens the focused terminal's folder in [Zed](https://zed.dev). Everything else in the menu is Herdr's own: Terminal, the agents, New space and the worktree entries. This is a piece you add to your current window, not a whole layout. ![Open with Zed](preview.png) This file is the brief: enough to build Open with Zed from an empty folder. The files next to it are one build of it. If they don't work on your Herdr, or you want it different, build it again from here. ## What you see - The same popup as Herdr's `+` menu, opened from the tab bar's `+` button: 250px wide, the theme's `popover` background, 5px padding, 12.8px text. - **Rows**, top to bottom, each 31px high, 9px side padding, 10px gap, 7px rounded corners, hover in the theme's `selected` color. Icon 14px on the left, the name, and an 11px hint in the dim color on the right: 1. **Terminal**, the shell icon, hint: its `tab.new` shortcut (e.g. `Ctrl+Shift+T`). 2. **Open with Zed**, the Zed logo (a square with a diagonal "Z" stroke) tinted with the theme's `foreground`, no hint. Disabled in the dim color when there's no focused folder or the space is on another machine. 3. "Start an agent" label: 11px dim, 9px side padding, 8px above, 4px below. 4. Each agent Herdr knows: installed ones first, with hints `1`–`9`, then at most two not-installed ones, dimmed, hint "not installed". "Checking installed agents…" while loading, "Could not load agents" on failure. 5. A 1px divider in the theme's `border` color, 4px side margin, 5px vertical margin. 6. **New space** (`+`, its shortcut), **New worktree…** and **Open worktree…** (branch icon, disabled without a space). - The menu's height is `min(522, 198 + 31 × max(1, agents shown))`px; the agent list scrolls past that. ## How it behaves | Action | Result | | --- | --- | | Click **Open with Zed** | Closes the menu and opens the focused pane's current folder (its live `cwd`, not the space's starting folder) in Zed | | Click **Terminal** | New tab with a shell in the active space | | Click an agent, or press `1`–`9` | New tab running that agent | | Click **New space** / a worktree entry | Same as Herdr's own menu | | Disabled row | Nothing | There are no agent statuses in this menu. The mod has no keys of its own beyond the shipped `1`–`9`, so there is no `keys.json`. ## Built from - **One mod**, `mods/herdr-open-with-zed/`. Its `main.js` is a copy of Herdr's shipped `new-menu` mod (0.1.11) with these changes: - imports `exec` and `notify` from `herdr` as well; - an `openInZed(folder)` function that tries, in order, `exec("zed", [folder])`, `exec("zeditor", [folder])`, `exec("flatpak", ["run", "dev.zed.Zed", folder])` and, on macOS (`window().platform === "macos"`), `exec("open", ["-a", "Zed", folder])`. It stops at the first one that exits 0 and ignores the ones that can't start. If none works, it calls `notify({ title: "Could not open Zed", …, level: "error" })`; - in `render()`, `const cwd = panes().find(p => p.focused)?.cwd;`, also passed as `folder` to both worktree overlays instead of looking up the focused pane again; - a new row right after the Terminal row: `this.row("zed", svg("mods/herdr-open-with-zed/zed.svg").size(14).text_color(t.foreground), "Open with Zed", () => openInZed(cwd), "", Boolean(cwd) && !space?.machine)`; - the menu's height goes up by one row: `Math.min(491, 167 + …)` becomes `Math.min(522, 198 + …)`. - `mod.json`: `"place": "none"` (it only appears when something opens it), `"title": "Open with Zed"`, and `"cloned_from": { "name": "new-menu", "version": "0.1.11" }`. - `zed.svg`: the Zed logo from [Simple Icons](https://simpleicons.org) (`zedindustries`, CC0), a single 24×24 path with no fill, drawn with `svg()` so it tints. - **The tab bar opens it.** The `+` button lives in the `tabs` mod: `openOverlay({ mod: "new-menu", kind: "popup", width: 250, height: 512 })`. In a copy of it, change `mod` to `"herdr-open-with-zed"` and `height` to `543`, then point your layout's tab bar block (`"id": "tabs"`) at that copy. Shipped mods and layouts are read-only, so clone them first: ```sh herdr-app do mod.clone '{"name":"tabs","as":"my-tabs"}' herdr-app do layout.clone '{"name":"main","as":"my-main"}' ``` - **`herdr` functions** (as the shipped mod): `theme`, `spaces`, `panes`, `knownAgents`, `run`, `openOverlay`, `closeOverlay`, `props`, `window`, `keys`, plus `exec` and `notify`. Commands: `tab.new`, `space.new`. From gpui-kit: `View`, `div`, `svg`, `image`; from gpui-base: `h_flex`, `v_flex`. - **Programs it runs:** `zed`, `zeditor`, `flatpak` or `open` (macOS), only when you click the row, with the focused folder as the only argument. No network. It reads no files. ## Watch out - **The `zed` CLI isn't always there.** On macOS it only exists after Zed > Install CLI, so the `open -a Zed` fallback is what works on a fresh Mac. Arch's package calls it `zeditor`; the Flatpak only exposes `dev.zed.Zed`, so it's run via `flatpak run`. On Windows the installer puts `zed.exe` in `%LOCALAPPDATA%\Programs\Zed\bin`, which is on `PATH`. - **`exec` rejects when the program can't start.** Catch each try, or one missing CLI stops the fallbacks. - **Remote spaces:** the focused folder is on another machine, so a local Zed can't open it. The row is disabled when `space.machine` is set. - **Use the pane's `cwd`**, not `space.folder`: the person expects the folder they `cd`'d into. - **Bump both heights.** The popup's height comes from the tab bar's `openOverlay` (512 → 543) and the menu's own `h(...)` (491/167 → 522/198); missing either clips the last row. - `layout.clone` also switches Herdr to the new layout. - Never edit the shipped `new-menu` or `tabs` mods in place: on the next start Herdr moves an edited shipped mod to `-edited` and restores its own. Start from a copy of the installed `mods/new-menu/main.js` so the rest of the menu matches your Herdr version. - `herdr-app check` writes `gpui-kit.d.ts` and `jsconfig.json` into the mod folder; they're not part of the mod. - Follow the installed `herdr.d.ts` and `gpui-kit.d.ts`. ## Done when - `herdr-app check mods/herdr-open-with-zed` passes. - Clicking the tab bar's `+` shows **Open with Zed** with the Zed logo right below **Terminal**, and the last row (**Open worktree…**) isn't clipped. - With a terminal focused in a folder, clicking **Open with Zed** closes the menu and that folder opens in Zed, after `cd`-ing elsewhere too. - On a Mac without Zed's CLI installed, it still opens Zed. - In a remote space the row is dimmed and clicking it does nothing. - Terminal, the agents, `1`–`9`, New space and the worktree entries work as in Herdr's own menu.