# Supabase + Vercel Insights Your projects' Supabase databases and Vercel deployments, as a Herdr panel that follows the space you are in and as a tab that shows a whole group of projects with Grafana-style charts. ![Supabase + Vercel Insights](preview.png) ## What you see **The panel** (a block in a layout, or a popup): one column on `background`, radius 10, 1 px `border`, 12.5 px type. A 42 px header: "Servers" semibold, a red "N need you" pill when something is down, and a Refresh button. Then machine cards (one per Herdr machine, foldable from their name: CPU/MEM/DISK meters 84×4 px, uptime, Docker containers that need you with Logs and Restart) and a **Cloud** section: a head line ("Cloud · 2 of 7 projects · checked 3m ago", a "This project / All projects" button, and "N hidden need you" when a hidden project is down), then one card per project on `surface`, radius 9: the project name with a health dot and a Details link, and per environment a 22 px head (name, branch, Open ↗ to its url), a Supabase row (ref · region, "up · 203 ms" or the problem, Add key when it has no metrics, Dashboard), the meters and headline numbers when it has metrics, and a Vercel row (project · branch, "ready · 14h", Dashboard). Details adds the Postgres facts (load, memory, disk, tuples, txns, pooler, realtime, queries) and the Vercel facts (team/project, id, root, Node, framework, url, latest). **The tab** (`props.tab`): 24 px padding, a 20 px title "Servers · ", a dim line "3 of 7 projects · checked 6s ago", pills "All (3) · nova-x ● · …" (26 px, radius 13, `selected` when on), and a grid of the project cards in columns of about 440 px. With a project focused (its pill) the grid is one column and the card gets everything: per Supabase env six bar charts in rows of three (CPU %, MEM %, Connections, I/O B/s, Network B/s, Queries/min; 44 px tall, up to 60 bars, the last bar in the full color, the rest at 60 %, percentages colored accent/`blocked`/`ansi1` at 75/90 %), the Postgres facts, and under Vercel a "Deployments" list: "20 total · 8 recent · avg build 3m 12s", then rows with a state dot, short sha, age, ⏱ build time (or the state when not ready), author, branch and the commit message; a click opens the deployment. ## How it behaves - The panel scopes the Cloud section to the space the person is in: a project is "mine" when its `folder` equals or contains the focused terminal's folder, any folder of the space's terminals, or the space's folder. Outside every project nothing shows and the head says so. The button switches to all; the choice persists per copy. `props.group` scopes to a space-groups group (the folders of its spaces); `props.project` opens the tab focused. - Every 5 minutes, and on Refresh, one copy (a lease in shared state) looks at everything: Supabase liveness through a keyless GET on `https://.supabase.co/rest/v1/` (401 = up, 540 = paused), metrics through `/customer/v1/privileged/metrics` with Basic auth `service_role:` when a key is known, Vercel through `vercel ls --scope -F json --environment production|preview [-m githubCommitRef=]` (the first CLI run alone, the rest together, because parallel runs race the token refresh). Results are published in shared state for the other copies. A second metrics-only scrape 20 s after the first gives the rates; tabs scrape metrics every 60 s while open. - Metric samples go to shared `svi.cloud.history` per project/env (1440 at most) and feed the charts. - Alerts compare each look with the last one that could tell: ": production: Supabase down" (error) and " is back" (success, 6 s). The first look says nothing. - Add key opens a 480×236 dialog: a sentence, an input, Cancel and Save. Save validates (printable, eyJ… or sb_secret_…), merges into `data//supabase-keys.json` atomically and makes the panel look again at once. - Machine cards: every 30 s a probe (`sh -c` on Linux/macOS machines, PowerShell on a local Windows computer) prints load, cpus, mem, disk, uptime and `docker ps -a`; Restart confirms inline, then `docker restart -- `; Logs opens a 760×520 dialog with `docker logs --tail 300`, newest first. ## Built from - One mod, `mods/supabase-vercel-insights/`: `main.js` (routes `props.view`: panel, "logs", "key"), `panel.js` (the panel and the tab), `cloud.js` (config validation, probes, metric parsing, health), `keys.js` (the key dialog), `probe.js` and `logs.js` (machines), `demo.js` (made-up data for screenshots), `cloud.example.json`. `mod.json`: `{ "place": "none", "overlay": { "kind": "dialog", "width": 0.9, "height": 0.9 } }`. - `herdr`: `exec`, `readTextFile`, `writeTextFile`, `appHome`, `spaces`, `focused`, `panes`, `machines`, `shared`/`setShared`, `openOverlay`/`closeOverlay`, `notify`, `theme`, `window`; `fetch` for Supabase. gpui-base: `Input`/`InputState`, `Editor` for logs. Icons: Herdr's `mods/workspace-chrome/server.svg` for a button. - Shared keys: `svi.cloud.lease`, `svi.cloud.results`, `svi.cloud.history`, `svi.keys.changed`. - With space-groups: its group header can call `run("tab.new", { name: \`Servers · ${group.name}\`, space, mod: "supabase-vercel-insights", props: { group: group.id, tab: true } })` and hide the side panel when it shows this mod. ## Watch out - Herdr's JS ignores `toLocaleString` options: format numbers by hand. - In a row, nothing drawn after a `flex_1().truncate()` child shows: put the truncating text last. - Several copies run at once (docked, popup, tabs): only the lease holder looks and announces; copies never share `localStorage`, so anything they must agree on goes through shared state. - Windows: no `sh` on PATH; the local probe is PowerShell and the Vercel CLI runs through `cmd /c`. PowerShell 5.1 mangles double quotes inside native arguments (docker's format uses `{{json .}}`). - Keys never go in `cloud.json`; the keys file is secret. The metrics endpoint needs the `service_role` key. ## Done when - `herdr-app check` passes; the panel shows only the projects of the space you are in and "All projects" shows every one. - A tab opened with `props.tab` draws the pills and the grid; a pill focuses one project with charts and the deployments list. - Add key saves a key and the env's meters appear on the next look; the charts fill one bar a minute. - Pausing a Supabase project turns its row `paused` and toasts; unpausing toasts "is back".