Gunnar

nordisk/dwarves

.nornir/dwarves-embed-run-picker-guide.md

<!-- nornir:class: guide -->
# Guide — pick which run the Forge(live) tab shows

The **Forge (live)** tab (`dwarves-embed`) now has a **run-picker**: a dropdown of the
recent runs on the forge. Pick one and the pane renders *that* run; pick **● newest** to
go back to following the latest.

## 1. Make a few runs

```
dwarves-server                                  # 127.0.0.1:7900
dwarves trigger demo demo-ci  --server http://127.0.0.1:7900   # → run r-1 · passed
dwarves trigger demo demo-ci  --server http://127.0.0.1:7900   # → run r-2 · failed
```

## 2. Open the tab and pick

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

In the control strip, next to `⟳ Refresh` and `● live`, a dropdown shows `newest` by
default. Open it:

```
● newest
r-2 · demo-ci · failed
r-1 · demo-ci · passed
```

Click a run → the pane fetches and renders that run's build DAG (per-step status,
durations, `needs` edges). Click **● newest** → back to auto-following the latest run.

If a run you pinned is later purged (or its report fails to load), the pane does **not**
go blank: it shows an amber *"run r-2 unavailable — pick another run"* and **keeps the
dropdown populated** so you just pick a working run. Only an actually-offline server (or a
forge with zero runs) shows the plain "forge unavailable". Over the seam that recoverable
state is `state_json.status == "report_error"` with the `runs` list still intact.

## 3. Same thing over the seam (headless / robot)

The dropdown click is just the `{"run_id": …}` seam:

```jsonc
{"run_id": "r-1"}     // pin run r-1
{"run_id": ""}        // clear → newest
{"history_limit": 50} // list up to 50 recent runs
```

`state_json` reports the picker surface:

```jsonc
{ "kind": "forge", "status": "loaded",
  "selected_run_id": "r-1",          // the pin (null ⇒ newest)
  "run_count": 2,
  "runs": [ {"run_id":"r-2","pipeline":"demo-ci","status":"failed"},
            {"run_id":"r-1","pipeline":"demo-ci","status":"passed"} ],
  "history_limit": 20 }
```

## Embed it yourself

Nothing new to call — `dwarves_embed::panel(endpoint)` (or `panel_with`) gives you the
pane with the picker built in. A pinned start still works:

```rust
let live = dwarves_embed::panel_with(
    "http://127.0.0.1:7900", "token", Some("r-1".to_string()));
```

Offline (or a forge with no runs) ⇒ the clean **"forge unavailable"** pane, dropdown
empty — never a panic. A transient blip keeps the last-known list so the dropdown doesn't
flicker empty.