From 35d4d5dfd373b5d7c8178d2622aab8bec9dd3cc0 Mon Sep 17 00:00:00 2001 From: shoemoney Date: Tue, 23 Jun 2026 12:47:14 -0500 Subject: [PATCH] =?UTF-8?q?docs:=20README=20live-dashboard=20section=20+?= =?UTF-8?q?=20ponytail=20cleanup=20=F0=9F=93=8A=F0=9F=A6=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - README: marquee Live Dashboard section (hero screenshot, --dashboard usage, how-it-works table, flow Mermaid), CLI table + TOC entries. - ponytail: dropped a hand-rolled totalsInfo.MarshalJSON β€” struct json tags do the lowercase-key mapping for free. --- README.md | 44 ++++++++++++++++++++++++++++- internal/hub/dashboard/dashboard.go | 16 ++++------- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 20e82ee..0b0b11e 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ |---|---|---| | πŸ€” [Why devbox?](#-why-devbox) | 🧠 [Core Concepts](#-core-concepts) | πŸ—οΈ [Architecture](#%EF%B8%8F-architecture) | | πŸ”„ [How Sync Works](#-how-sync-works) | πŸ’₯ [Conflicts](#-conflicts-never-lose-a-byte) | πŸš€ [Quick Start](#-quick-start) | -| 🧰 [CLI Reference](#-cli-reference) | πŸͺ [Hooks](#-hooks) | πŸ™ˆ [.devignore & Secrets](#-devignore--secret-guard) | +| 🧰 [CLI Reference](#-cli-reference) | πŸ“Š [Live Dashboard](#-live-dashboard--watch-your-fabric-breathe) | πŸͺ [Hooks](#-hooks) | πŸ™ˆ [.devignore & Secrets](#-devignore--secret-guard) | | πŸ•°οΈ [Versioning & Deploy](#%EF%B8%8F-versioning--deploy) | πŸ–₯️ [Cross-Platform](#%EF%B8%8F-cross-platform) | πŸ” [Security & Durability](#-security--durability) | | πŸ—ΊοΈ [Roadmap](#%EF%B8%8F-roadmap) | βš–οΈ [License & Open-Core](#%EF%B8%8F-license--open-core) | πŸ™Œ [Contributing](#-contributing) | @@ -346,12 +346,54 @@ container automatically. πŸͺ„ | `devbox-hub token` | 🎟️ Mint / rotate the join token | | `devbox-hub device list` / `revoke ` | πŸ“‹βŒ List / revoke devices | | `devbox-hub readonly ` | πŸ”’ Mark a device read-only on a share | +| `devbox-hub member set/rm/list` Β· `principal` | πŸ›‘οΈ Per-share roles + principals (M8a) | +| `devbox-hub serve --dashboard` | πŸ“Š Serve the live web dashboard (loopback `:8099` by default) | | `devbox-hub gc` | 🧹 Garbage-collect unreferenced chunks | --- +## πŸ“Š Live Dashboard β€” watch your fabric breathe + +> Our own. No Grafana, no Prometheus required, **no external deps** β€” it ships *inside the hub binary* +> and runs air-gapped. **Off by default**; flip it on and watch every push, join, and chunk flow in real time. ✨ + +

devbox hub live dashboard

+ +```bash +devbox-hub serve --dashboard # loopback http://127.0.0.1:8099 (safe default) +devbox-hub serve --dashboard --dashboard-addr 0.0.0.0:8099 # expose on the LAN (unauthenticated β€” warns you) +``` + +A mission-control flow visualization rendered on `` at 60fps: a **breathing hub core**, your +**devices orbiting** (bright = active), **shares** on the outer ring β€” and when a device pushes, a glowing +**particle streams device β†’ hub β†’ share** and fans out to the subscribers. Plus live **metric tiles** with +sparklines (devices online, shares, snapshots, chunks, total data, pushes/min, bytes/min) and a streaming, +color-coded **activity feed**. + +| How it works | | +|---|---| +| πŸ–₯️ **Served from the hub** | single `go:embed`'d HTML, vanilla JS + canvas, zero CDN/build | +| πŸ”Œ **`GET /api/state`** | snapshot: hub, totals, devices, shares (UI polls every 10s) | +| πŸ“‘ **`GET /api/events`** | SSE live flow stream (`join`, `push`) β€” the dashboard animates each one | +| πŸ”’ **Loopback by default** | unauthenticated read-only metrics; bind non-loopback only deliberately (it warns) | +| 🎬 **`?demo=1`** | synthesizes a live stream β€” instant wow + works offline (`file://`) | + +```mermaid +flowchart LR + DEV["πŸ’» device pushes"] -->|"POST /v1/push"| HUB["πŸ›°οΈ hub"] + HUB -->|"Emit(join/push)"| BRK["πŸ“‘ SSE broker"] + BRK -->|"/api/events"| UI["πŸ“Š dashboard canvas"] + HUB -->|"/api/state"| UI + UI -.->|"particle deviceβ†’hubβ†’share"| UI + style HUB fill:#0b2b3a,stroke:#27e8ff,color:#fff + style UI fill:#2a0b2b,stroke:#ff3df0,color:#fff + style BRK fill:#1e5a2e,stroke:#b6ff3a,color:#fff +``` + +--- + ## πŸͺ Hooks Drop executable scripts in `/.devbox/hooks/`, named after the event. **bash everywhere** diff --git a/internal/hub/dashboard/dashboard.go b/internal/hub/dashboard/dashboard.go index 8ff303a..ba47345 100644 --- a/internal/hub/dashboard/dashboard.go +++ b/internal/hub/dashboard/dashboard.go @@ -103,16 +103,12 @@ type hubInfo struct { UptimeS int64 `json:"uptime_s"` } type totalsInfo struct { - Devices, Online, Shares, Snapshots, Chunks int64 - Bytes int64 -} - -// MarshalJSON keeps the totals keys lowercase to match the frontend contract. -func (t totalsInfo) MarshalJSON() ([]byte, error) { - return json.Marshal(map[string]int64{ - "devices": t.Devices, "online": t.Online, "shares": t.Shares, - "snapshots": t.Snapshots, "chunks": t.Chunks, "bytes": t.Bytes, - }) + Devices int64 `json:"devices"` + Online int64 `json:"online"` + Shares int64 `json:"shares"` + Snapshots int64 `json:"snapshots"` + Chunks int64 `json:"chunks"` + Bytes int64 `json:"bytes"` } type deviceJSON struct {