Gunnar

nordisk/dwarves

.nornir/dwarves-embed-live-report-guide.md

<!-- nornir:class: guide -->
# Guide — watch a LIVE forge run in the demo (`dwarves-embed`)

The **Forge (live)** tab in `dwarves-gui` renders a real `dwarves-server` run — the
build DAG, per-step status, durations and `needs` edges — on the same viewer the
in-process **Pipeline** tab uses, but fed over the network by `GetRunReport`.

## 1. Start the forge and make a run

```
dwarves-server                                  # listens on 127.0.0.1:7900
dwarves repo add git@codeberg.org:nordisk/demo.git --server http://127.0.0.1:7900
dwarves trigger demo demo-ci --server http://127.0.0.1:7900
# → run <run-id> · passed
```

(Any registered pipeline + trigger produces a historized run with per-step rows.)

## 2. Open the live tab

```
cargo run -p dwarves-gui         # native window; open the "Forge (live)" tab
```

By default the tab connects to `http://127.0.0.1:7900` and renders the **newest** run.
Override either:

```
DWARVES_SERVER=http://host:7900 \
DWARVES_SERVER_TOKEN=<bearer> \
DWARVES_RUN_ID=<run-id> \
cargo run -p dwarves-gui
```

- `DWARVES_SERVER` — the forge endpoint (else `http://127.0.0.1:7900`).
- `DWARVES_SERVER_TOKEN` — the bearer token if the server was started with one.
- `DWARVES_RUN_ID` — pin a specific run; unset ⇒ the newest historized run.

The tab **auto-polls** every 1.5s, so a run in flight fills in its steps live; the
`● live` / `⏸ paused` button toggles it, `⟳ Refresh` re-fetches now. If the server is
down (or the forge has no runs), the tab shows a clean **"forge unavailable"** message
— it never panics.

## Embed it yourself

`dwarves-embed` is the reusable `<guest>-embed` leaf. In any egui host:

```rust
use facett_core::Panel;

// Newest run, creds from the environment:
let live: Box<dyn Panel> = dwarves_embed::panel("http://127.0.0.1:7900");

// Or a specific run with explicit creds:
let live = dwarves_embed::panel_with(
    "http://127.0.0.1:7900",
    "my-bearer-token",
    Some("run-abc123".to_string()),
);
```

Under the hood: a thin tonic client calls `Dwarf.GetRunReport(run_id)`,
`report_from_wire` reconstructs the `(Dag, RunReport)` pair client-side, and
`ForgePipelineAdapter::from_report` renders it on the reused `facett-pipeline` viewer —
no `nornir` dep, no dwarves `server` feature pulled.

## The wire, directly

```
grpcurl -H 'authorization: Bearer <token>' \
  -d '{"run_id":"<run-id>"}' \
  127.0.0.1:7900 dwarf.v1.Dwarf/GetRunReport
# → { "run": {...}, "steps": [ { "step":"compile", "status":"passed",
#       "durationMs":"820", "needs":[] }, { "step":"test", "needs":["compile"], ... } ] }
```

An unknown `run_id` is a clean `NotFound`.