# Dashboard widgets

The **Dashboard** is a grid of cards. Arrange it on the grid itself: drag a card by its title to move it, pull its
right edge to make it one, two or three columns wide (with a mouse; saved at once). **Edit layout** adds to each card
its buttons (move, width, hide: the way of a phone and of the keyboard) and lists the hidden widgets under the grid,
to show them again; **Done** leaves it. Refresh a card with its refresh button. In the
[Windows layout](settings-and-keys.md) a widget can also sit on the desktop. **Settings -> Widgets** lists the widgets your extensions bring (switch one
off, **Rescan** after a change) and its **Customize the dashboard** button opens the dashboard in edit mode. Widgets
shared by other users are on the website: [harness-maxxing.com/community](https://harness-maxxing.com/community).

Cards build themselves as they appear: numbers count up to their value, lists and tables rise in row by row,
chart bars grow and lines draw, progress bars fill, and **Today's schedule** opens each job's line and drops its
runs on it from left to right. A card further down the page waits until you scroll to it, so you see it too.
When the notifications panel opens or closes, the cards slide to their new place. Everything stays still when
your system asks for reduced motion.

A new install shows Activity, Server and usage, Today's schedule, Tasks and **Make it yours**. The others are hidden
until you need them (**Edit layout** shows them).

**Make it yours** is the card at the end: click an example ("Today's Shopify sales", "Visitors on my
website"...) and a new session opens in `system/harness` with the request already typed - send it, and
Harness writes the widget in your extensions. Any request works the same way from any session: "add a widget
that shows ...". Hide the card with **Edit layout** once you have yours.

## Built-in widgets

| Widget | Shows |
|---|---|
| Activity | sessions running, unread and active today, today's tokens with a 14-day curve, the latest sessions with their project's chip (emoji and colour) and a "Running" pill (before the first session: where to start) |
| Tasks | a ring of the tasks done over 7 days with a bar per day, in progress, due today, overdue, the urgent tasks with their due date (red when late) and priority |
| Today's schedule | the day of your scheduled jobs on a 00:00 - 24:00 line: one row per job, runs done (green, red if failed), runs still to come (hollow), the one running now (pulsing) and a "now" line; a job that runs too often for round dots gets thin bars, one per run at its exact time, and a job that runs every minute or so a band (done up to now, planned after); hover a dot or a bar for its time and duration |
| Scheduled jobs | next runs and recent failures |
| Server and usage | the usage of the active engine as round gauges - a Claude plan (5-hour window, week; the same figures as the bottom of the sidebar), a ChatGPT plan with Codex (its windows, once a turn has run), the credits of an OpenRouter key - then CPU, memory and disk as bars, uptime, health issues; an engine on an API key has no quota to show: only the server |
| Memory backup | last run, age, repository |
| Telegram | bot and link status |
| Make it yours | how to get your own widgets, with examples that open a session ready to send |

Your shop's sales (Shopify, WooCommerce, Stripe, PrestaShop…), your site's visitors, an ads account: ask Claude
for a widget, it builds an extension that reads them (see below).

## Writing your own widget

A widget is a folder in `<workspace>/extensions/<id>/` with two files. You write **data**, not
HTML: the card is drawn by the app's design system, so it always looks right in dark and light
mode, on desktop and phone. (Need free-form drawing or interaction - a game, a canvas? See
[HTML widgets](#html-widgets-games-custom-drawings) below.)

The fastest way: ask Claude in a session, "create a dashboard widget that shows ...". The
`maxxing-extension` skill knows everything below.

### 1. Create the folder

```
/root/maxxing/extensions/disk-usage/
  manifest.json
  api.py
```

The id (folder name) is a lowercase slug: letters, digits, dashes. Reserved ids: `activity`,
`tasks`, `day`, `crons`, `server`, `backup`, `telegram`, `customize`. A folder whose name is
not valid UTF-8 is ignored.

### 2. manifest.json

```json
{"id": "disk-usage", "name": "Disk usage", "type": "widget", "icon": "hard-drive",
 "version": "1.0.0", "api": 1, "span": 1, "ttl": 60}
```

| Key | Meaning |
|---|---|
| `type` | `widget` |
| `api` | version of the extension contract it is written for (default 1); a release that stops supporting it is announced by the update preflight before you update |
| `icon` | an icon name in kebab-case (`gauge`, `chart-line`, `shopping-cart`, `users`, `receipt`...) from the app's set of [lucide](https://lucide.dev/icons) icons; a name the app does not ship shows a puzzle piece |
| `span` | width in grid columns: 1, 2 or 3 |
| `ttl` | seconds the result is cached (default 300). The refresh button bypasses it. Past it, a slow card keeps showing its last result while the new one is computed. |

### 3. api.py

```python
import shutil


def card(ctx):
    du = shutil.disk_usage("/")
    pct = round(100 * (du.total - du.free) / du.total)
    return {
        "title": "Disk usage",
        "status": "error" if pct > 95 else "warn" if pct > 85 else "ok",
        "blocks": [
            {"type": "stat", "label": "Used", "value": f"{pct}%", "hint": f"{du.free / 1e9:.1f} GB free"},
            {"type": "progress", "label": "/", "value": pct, "max": 100},
        ],
    }
```

`card(ctx)` runs inside the server: use only the Python standard library, keep network calls short
(timeout ≤ 10 s). Extension code runs on 4 threads of its own: code that never returns (a network call without a
timeout) only blocks other extensions ("extensions are busy" until it returns), never the rest of Harness. An
`api.py` must load in under 10 s (no network call at import time), or the extension shows an error. `ctx` contains:

| Key | Value |
|---|---|
| `id` | the extension id |
| `workspace` | workspace path |
| `state_dir` | a folder reserved for this extension (cache, data) |
| `secret(name)` | value of a key from Settings -> Keys, or `None` |
| `config` | `{"timezone", "language", "public_url"}` |

Never hard-code a token: store it in Settings -> Keys and read it with `ctx["secret"]("MY_TOKEN")`.

### 4. The Card schema

```
Card  = {title?, status?: "ok"|"warn"|"error", link?, blocks: [Block], updated?}
Block =
  {type: "stat", label, value, hint?, delta?, tone?: "ok"|"warn"|"error", icon?, live?, spark?, spark_kind?}
                                                            icon: a stats row with icons is drawn as tiles
                                                            live: a pulsing dot; spark: [numbers] = a small
                                                            curve ("line") or bars ("bar"), oldest first
| {type: "stats", items: [stat, ...]}                      several stats in a row
| {type: "list", items: [{title, subtitle?, crumbs?, value?, href?, status?, icon?, emoji?, avatar?, badge?, level?}],
   empty?, grid?}
                                                            grid: true = tiles side by side (shortcuts)
                                                            icon: an icon name (below), drawn like the app's
                                                            crumbs: ["acme", "blog"] = "acme › blog"
                                                            avatar: {emoji?, text?, color?} = a round chip
                                                            badge: {text, tone?, live?} = a pill on the right
                                                            level: 1-3 small bars (a priority)
| {type: "rings", items: [{label, value, max, hint?, format?: "percent"|"fraction", tone?, spark?}], title?, icon?}
                                                            round gauges side by side (title: in one box)
| {type: "chart", kind: "bar"|"line", series: [{name, points: [[x, y], ...]}], unit?}
                                                            y: a number (or a number as text, "40");
                                                            null = a point without a value (a gap)
| {type: "table", columns: [str], rows: [[cell, ...]]}
| {type: "progress", label, value, max, hint?}
| {type: "markdown", text}
```

`link` makes the card title clickable (an app route like `/tasks` or an `https://` URL). Unknown
block types are ignored. A card larger than 1 MB (as JSON) is shown as an error.

Example list + chart:

```python
def card(ctx):
    orders = [("#1042", "Alice", 89.0), ("#1041", "Bob", 34.5)]
    return {
        "title": "Shop",
        "link": "https://shop.example.com/admin",
        "blocks": [
            {"type": "stats", "items": [{"type": "stat", "label": "Today", "value": "123.50 €"},
                                        {"type": "stat", "label": "Orders", "value": "2"}]},
            {"type": "chart", "kind": "bar", "unit": "€",
             "series": [{"name": "Sales", "points": [["Mon", 80], ["Tue", 120], ["Wed", 123.5]]}]},
            {"type": "list", "empty": "No orders yet",
             "items": [{"title": o, "subtitle": c, "value": f"{v:.2f} €"} for o, c, v in orders]},
        ],
    }
```

### 5. Test, then load

Test the function directly on the server:

```bash
cd /root/maxxing/extensions/disk-usage && python3 -c "
import json, api, tempfile
ctx = {'id': 'disk-usage', 'workspace': '/root/maxxing', 'state_dir': tempfile.mkdtemp(),
       'secret': lambda n: None, 'config': {'timezone': 'UTC', 'language': 'en', 'public_url': ''}}
print(json.dumps(api.card(ctx), indent=2))"
```

Then **Settings -> Widgets -> Rescan**. The widget appears on the dashboard. If something is
wrong (invalid manifest, import error, exception in `card`), the error is shown on the extension's
row and on the card; the rest of the dashboard keeps working.

Extensions live in your workspace: updates never touch them and the backup includes them.

## HTML widgets (games, custom drawings)

When a Card is not enough - a small game, a canvas drawing, a custom chart library - write the
widget in HTML instead. Same folder, with `widget.html` instead of (or next to) `api.py`:

```
/root/maxxing/extensions/snake-widget/
  manifest.json     {"type": "widget", "name": "Snake", "icon": "gamepad-2", "height": 300}
  widget.html       one self-contained file: inline <style> and <script>
  api.py            optional: handle(ctx, method, path, query, body) for data it saves or fetches
```

The dashboard draws `widget.html` in a **sandboxed frame**: scripts run, but the frame cannot read
the app, its cookies or its API - a widget can never act as you. It talks to its own `api.py`
through a small bridge that is injected for you:

| In widget.html | What it does |
|---|---|
| `await maxxing.api("best")` · `maxxing.api("best", {method: "PUT", body: {...}})` | calls `handle()` in this extension's `api.py` (`/api/ext/<id>/best`), returns its JSON |
| `maxxing.resize(400)` | sets the frame height in px (the manifest `height`, 120-800, is the default) |
| `maxxing.theme` · `maxxing.onTheme(fn)` | `"dark"` or `"light"`, and a callback when it changes |
| `class="ui-card"`, `ui-btn`, `ui-input`, `ui-badge`, `ui-stat`... | the app's **UI kit** (see [Page extensions](page-extensions.md#styling)), already loaded in the frame |
| `var(--card)` `--foreground` `--muted-foreground` `--border` `--primary`... (and the older `--mx-fg` `--mx-muted` `--mx-border` `--mx-accent` `--mx-card` `--mx-bg`) | the app's colors, updated with the theme and the accent color (also `--fill-1`, `--sunken`; `<html data-material="glass">` when the Glass material is on) |

Rules: one file only (no other file of the folder is served to the frame - inline everything, or
load libraries from a CDN `<script src="https://...">`); no `localStorage`/cookies (the sandbox has
none: save through `api.py` and `ctx["state_dir"]`). The refresh button of the card reloads the
frame. Full example: `examples/extensions/snake-widget/` in the code directory.

## Share a widget

Widgets you made can go to the [community library](https://harness-maxxing.com/community): push the folder to a public
GitHub repository and list it, or let Claude do it with an API key. The rules and the steps are in
[Page extensions -> Publish yours](page-extensions.md#publish-yours).
