# Files Open With Herdr's Files panel, plus a right-click menu that opens the clicked file or folder in your own apps: VS Code, Preview, Quick Look, the default app, Finder, or any app you add. The panel otherwise looks and behaves exactly like Herdr's shipped Files panel. macOS only. ![Files Open With](preview.png) ## What you see - The Files panel as Herdr ships it (0.1.11): a 42px header with "Files" and the folder name, 28px rows, 18px indentation per level, chevrons, folder and file icons, Git letters (A, M, D, U) on the right. - Right-clicking a row opens a pointer popup, 240px wide, in Herdr's popover color with 5px padding and 12.8px text. Its first line is the clicked entry's name in 11px dim text. Below it are 31px rows, each with a 14px muted icon and a label. The first row starts highlighted (`selected`); a hovered row uses `hover`. - Default items for a file: Open in VS Code, Open in Preview, Quick Look, Open with default app, Reveal in Finder, Copy path. For a folder: Open in VS Code, Open with default app, Reveal in Finder, Copy path. - An app item shows only when that app is installed. For a file on another machine (an ssh space), only Copy path shows. - The popup's height fits its items exactly: 10 + 26 + 31 per item + 4 px. ## How it behaves - Right-click a file or folder row: the menu for that entry. Right-click the file name in the header while a file preview is open: the menu for that file; with no preview, the menu for the panel's root folder. - Up/Down move the highlight (wrapping), Enter runs the highlighted item, Esc closes, a click on a row runs it, a click elsewhere closes it. - Running an item closes the popup first, then runs its command on this Mac, without a shell: - app items: `open -a ` - Quick Look: `qlmanage -p ` (stays open until its window closes) - Open with default app: `open `; Reveal in Finder: `open -R ` - Copy path: `printf %s | pbcopy` - A command that exits non-zero posts an error notification with its stderr (except Quick Look). - Installed apps are checked when the menu opens, at most once a minute: `/Applications`, `/Applications/Utilities`, `/System/Applications`, `/System/Applications/Utilities`, `~/Applications`, `/Applications/Setapp`, then Spotlight (`mdfind`) by bundle name. - On Linux and Windows a right-click does nothing. - Agent statuses are not shown or changed: the panel is a file browser. ## Built from One mod folder, `mods/files-open-with/`, with two roles chosen by `props().role`: - `main.js`: the `View`. With no role it creates `Panel` (panel.js); with `role: "menu"` it creates `Menu` (menu.js). It forwards `init(props, cx)` and `render(cx)` to that plain class. - `panel.js`: Herdr 0.1.11's shipped `files` mod (Apache-2.0), unchanged except: a plain class instead of a `View`, its asset paths under `mods/files-open-with/`, `.on_mouse_down("right", …)` on each row and on the header's name, and a `menu(path, dir, cx)` method. That method returns at once unless `window().platform === "macos"`, awaits `available(target)`, and calls `openOverlay({ mod: "files-open-with", kind: "popup", width: 240, height: menuHeight(n), props: { role: "menu", path, dir, on, items } })`. `items` are indexes into `ITEMS`. - `menu.js`: the popup. It reads `props()`, focuses itself, draws the rows and runs the chosen item with `exec(cmd, args)` and `closeOverlay(props().overlay)`; errors go to `notify`. - `items.js`: `ITEMS` (each `{ label, icon, app? | argv?, when?, local? }`), `argvOf`, `menuHeight` and `available` (filters by `when`, by `on` for `local` and app items, and by the installed-app check, run with `exec("sh", …)`). - `mod.json`: `{ "place": "none", "cloned_from": { "name": "files", "version": "0.1.11" } }`. It never docks itself: a layout's Files block points at it. - Art: Herdr's Lucide icons (ISC): `chevron-down`, `chevron-right`, `file`, `folder` for the tree, and `menu-square-pen`, `menu-file-text`, `menu-search`, `menu-folder`, `menu-files` for the menu. - herdr functions: `spaces`, `panes`, `focused`, `exec`, `readTextFile`, `watchFolder`, `theme`, `settings`, `window`, `openOverlay`, `closeOverlay`, `props`, `notify`. ## Watch out - A popup's async work dies with its view. Do the installed-app check in the panel (long-lived), before opening the popup, not inside the popup. - Copy the folder into `mods/` in one move, with `mod.json` already there. If Herdr sees `main.js` before `mod.json`, it docks the mod into the shown layout as a new 320px block. - `open -R -a App` reveals the app in Finder: don't use it to test whether an app exists. - Herdr has no text-clipboard function for mods, so Copy path uses `pbcopy`. - Paths of files on another machine are that machine's paths: only Copy path makes sense there. - Limits are the shipped panel's: 500 entries per folder, 5,000 in all. - This is a copy of the shipped panel and does not follow Herdr's updates to it. ## Done when - `herdr-app check mods/files-open-with` passes. - With a layout's Files block set to `files-open-with`, the panel lists the focused terminal's folder with Git letters, like the shipped one. - Right-clicking `README.md` opens the popup at the pointer, showing "README.md" and the six file items (when VS Code is installed). - Right-clicking a folder shows four items, without Preview and Quick Look. - Open in VS Code opens the file in VS Code; Reveal in Finder selects it in Finder; Copy path puts its absolute path on the clipboard; Quick Look shows a preview. - Removing VS Code from `ITEMS` and saving reloads the panel and removes the item, with no restart. - Nothing is added to the layout when the mod is installed.