# Next Session: Dashboard Hailo Detections Live Panel

**Status:** deferred from session that implemented Hailo L1 V2
(`docs/NEXT-SESSION-HAILO-ACTIVATION-V2.md`). Quality-of-life addition for
`/nav` page — gives the user live visibility into what the L1 reflex is
seeing, why ESTOP fires, and which sensor (YOLO/sonar/lidar) is the
trigger source. Without this, false positives can persist for days before
the user notices.

---

## What

A live panel on the dashboard `/nav` page that shows:

1. **Last 30 s of `/obstacles` polling** as a sparkline (object count over time)
2. **Current detections table** — class, confidence, distance_cm, bearing,
   distance_source (bbox vs lidar)
3. **Three sensor traffic lights** — Hailo (yolo_safe), sonar (sonar_safe),
   lidar (lidar_safe)
4. **ESTOP banner** when `/health.is_estop_latched == true` — color-coded by
   reason source: red for obstacle, amber for camera-stale, blue for watchdog
5. **Click-through camera frame** with bbox overlay (debounced fetch from
   `/photo`, only when user clicks "show frame" button — preserves bandwidth)
6. **Rolling watchdog metric**: `safety_inference_age_ms` and `safety_inference_p95_ms`
   from `/health` (lit green if both healthy, amber 100-200 ms, red >200 ms)

---

## Why

After the V2 hardening session, `/health` and `/obstacles` expose:

- `safety_inference_age_ms` — watchdog liveness (C5)
- `safety_inference_p95_ms` — Hailo throughput trend (C5)
- `is_estop_latched` — daemon-side latch (C10)
- `camera_stale_estop_latched` — distinguishes camera-feed faults from obstacle
  ESTOPs (C7) so the user knows whether to recheck the USB cable or the room

These fields are invisible to the user today. A single panel surfaces the
information that scientific debugging requires: was that ESTOP fire from
YOLO false-positive on a shadow, lidar self-reflection, sonar I2C glitch, or
a real obstacle?

---

## Plan sketch

### Phase A — Backend additions (none required)

`/health` and `/obstacles` already expose everything. No new endpoints.

### Phase B — Dashboard frontend

- New file: `services/dashboard-frontend/src/components/HailoSafetyPanel.vue`
  (or React equivalent — match existing dashboard stack)
- Polls `/obstacles` at 2 Hz, `/health` at 0.5 Hz.
- Sparkline via `Sparklines` lib or hand-rolled SVG (24 data points = 12 s window).
- Camera frame overlay: fetch `/photo`, draw `<canvas>` bboxes from `/obstacles`
  using `bbox: [x,y,w,h]` (convert to canvas coords).

### Phase C — Tests

- Mock `/obstacles` + `/health` responses, snapshot the rendered panel for
  three states: healthy, ESTOP-latched (obstacle), ESTOP-latched (camera-stale).
- Smoke test: load `/nav`, verify the panel is present and polling.

### Phase D — Doc updates

- `docs/perspectives-vlm-primary-hybrid-nav-v3.html` Lens 04 — note that the
  user now has live observability of the L1 reflex.
- Day-in-life pages — Rajesh debugging the WiFi-hiccup scene now glances at
  the panel instead of `ssh pi 'journalctl ...'`.

---

## Out of scope

- Saving false-positive frames for offline retraining (separate ML-loop session).
- Cumulative ESTOP statistics (per-day fire counts, trends) — Grafana territory,
  not in-app dashboard.
- Mobile-responsive layout — start with desktop; add mobile when needed.

---

## Open questions for user

1. **Should the camera frame overlay be always-on or click-to-show?**
   Always-on at 2 Hz adds ~5–10% bandwidth load (640×480 JPEG ~50 KB);
   click-to-show is cheaper but less spectacular for demos.
2. **Where on `/nav` does the panel live?** Below the existing scan rose,
   side-panel, or full-width across the top? Existing `/nav` layout is
   already crowded.
3. **Is `is_estop_latched` worth a notification toast (slide-in alert) on
   first transition?** vs. just the red banner. Toast risks being annoying
   if YOLO false-positives fire many times per day; banner is calmer.

---

## Files this session would touch

- `services/dashboard-frontend/src/components/HailoSafetyPanel.{vue,jsx}` (NEW)
- `services/dashboard-frontend/src/views/Nav{View,Page}.{vue,jsx}` (slot-in)
- `services/dashboard-frontend/test/HailoSafetyPanel.test.{ts,js}` (NEW)
- `docs/perspectives-vlm-primary-hybrid-nav-v3.html` (Lens 04 update)
- `docs/day-in-life-{annie,rajesh}.html` (Rajesh-debugging-via-dashboard scene)

---

## Done when

- `/nav` page shows the live panel with: detections table, three sensor
  traffic lights, watchdog metric, optional camera-overlay button
- Panel updates within 1 s of a real ESTOP fire on Pi
- ESTOP banner correctly distinguishes obstacle/stale/watchdog reasons via
  the `is_estop_latched` + `camera_stale_estop_latched` flags
- Snapshot tests cover the three banner states
