diff --git a/app/static/index.html b/app/static/index.html
index 956f4d5..1ad3bc7 100644
--- a/app/static/index.html
+++ b/app/static/index.html
@@ -4367,6 +4367,53 @@ function gfHitTime(p) {
if (Number.isNaN(d.getTime())) return String(raw).slice(11, 19) || '—';
return d.toISOString().slice(11, 19) + 'Z';
}
+function gfEvidence(p) {
+ if (!p || typeof p !== 'object') return null;
+ let payload = p.payload;
+ if (typeof payload === 'string') {
+ try { payload = JSON.parse(payload); }
+ catch (e) { payload = null; }
+ }
+ if (payload && typeof payload === 'object' && payload.evidence && typeof payload.evidence === 'object') {
+ return payload.evidence;
+ }
+ if (p.evidence && typeof p.evidence === 'object') return p.evidence;
+ return null;
+}
+function gfNewsHref(url) {
+ const u = String(url == null ? '' : url).trim();
+ if (!u) return '';
+ const low = u.slice(0, 16).toLowerCase();
+ if (low.startsWith('rtsp:') || low.startsWith('javascript:') || low.startsWith('data:')) return '';
+ return u;
+}
+function gfHitEvidenceHtml(ev) {
+ if (!ev || typeof ev !== 'object' || Array.isArray(ev)) return '';
+ const cams = Array.isArray(ev.cameras) ? ev.cameras.slice(0, 5) : [];
+ const news = Array.isArray(ev.news) ? ev.news.slice(0, 3) : [];
+ const bits = [];
+ if (cams.length) {
+ const first = cams[0] && typeof cams[0] === 'object' ? cams[0] : {};
+ const name = first.name == null ? '' : String(first.name).trim();
+ let line = cams.length + ' cams';
+ if (name) line += ' · ' + newsEsc(name);
+ bits.push(line);
+ }
+ const item = news[0] && typeof news[0] === 'object' ? news[0] : null;
+ const headline = item && item.headline != null ? String(item.headline).trim() : '';
+ if (headline) {
+ const href = gfNewsHref(item.url);
+ if (href) {
+ bits.push(
+ `${newsEsc(headline)}`
+ );
+ } else {
+ bits.push(newsEsc(headline));
+ }
+ }
+ if (!bits.length) return '';
+ return `${bits.join(' · ')}`;
+}
function pushGfInbox(p) {
if (!p) return;
const box = document.getElementById('gf-inbox');
@@ -4379,9 +4426,16 @@ function pushGfInbox(p) {
el.dataset.gid = gid;
if (p.lat != null) el.dataset.lat = String(p.lat);
if (p.lon != null) el.dataset.lon = String(p.lon);
- el.innerHTML = `${newsEsc(gfHitTime(p))} · ${newsEsc(name)}` +
+ const meta = `${newsEsc(gfHitTime(p))} · ${newsEsc(name)}` +
` · ${newsEsc(p.source_kind || '')} · ${newsEsc(p.entity_id || '')}`;
- el.onclick = () => onGfHitClick(el);
+ let ev = '';
+ try { ev = gfHitEvidenceHtml(gfEvidence(p)); } catch (e) { ev = ''; }
+ el.innerHTML = ev ? meta + '
' + ev : meta;
+ el.onclick = (clickEv) => {
+ const t = clickEv && clickEv.target;
+ if (t && t.closest && t.closest('a')) return;
+ onGfHitClick(el);
+ };
box.prepend(el);
while (box.children.length > 50) box.removeChild(box.lastChild);
}
diff --git a/tests/test_geofence_frontend.py b/tests/test_geofence_frontend.py
index 994c02d..895727b 100644
--- a/tests/test_geofence_frontend.py
+++ b/tests/test_geofence_frontend.py
@@ -2,6 +2,9 @@
from __future__ import annotations
+import json
+import subprocess
+import tempfile
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
@@ -54,3 +57,151 @@ def test_fence_dvr_at_endpoint():
assert "/at?timestamp=" in HTML or "/at?timestamp=${" in HTML
assert "function dvrScrubFence" in HTML
assert "gfSelectedId" in HTML
+
+
+def _inbox_src() -> str:
+ news = HTML.split("function newsEsc", 1)[1].split("function newsTimeAgo", 1)[0]
+ inbox = HTML.split("function gfHitTime", 1)[1].split("function onGfHitClick", 1)[0]
+ return "function newsEsc" + news + "function gfHitTime" + inbox
+
+
+def _render_inbox(hits: list) -> list[dict]:
+ harness = r"""
+const fs = require('fs');
+const src = fs.readFileSync(process.argv[2], 'utf8');
+const hits = JSON.parse(fs.readFileSync(process.argv[3], 'utf8'));
+var gfNameById = {};
+function makeBox() {
+ const kids = [];
+ const box = {
+ children: kids,
+ prepend(el) { kids.unshift(el); },
+ removeChild(el) {
+ const i = kids.indexOf(el);
+ if (i >= 0) kids.splice(i, 1);
+ },
+ };
+ global.document = {
+ getElementById(id) { return id === 'gf-inbox' ? box : null; },
+ createElement() {
+ return { type: '', className: '', dataset: {}, innerHTML: '', onclick: null };
+ },
+ };
+ return box;
+}
+eval(src);
+const out = [];
+for (const hit of hits) {
+ const box = makeBox();
+ pushGfInbox(hit);
+ const el = box.children[0];
+ out.push({
+ html: el ? el.innerHTML : '',
+ hasOnclick: !!(el && typeof el.onclick === 'function'),
+ });
+}
+process.stdout.write(JSON.stringify(out));
+"""
+ with tempfile.TemporaryDirectory() as td:
+ root = Path(td)
+ src_path = root / "inbox.js"
+ hits_path = root / "hits.json"
+ harness_path = root / "harness.js"
+ src_path.write_text(_inbox_src())
+ hits_path.write_text(json.dumps(hits))
+ harness_path.write_text(harness)
+ proc = subprocess.run(
+ ["node", str(harness_path), str(src_path), str(hits_path)],
+ check=False,
+ capture_output=True,
+ text=True,
+ )
+ assert proc.returncode == 0, proc.stderr
+ return json.loads(proc.stdout)
+
+
+def test_push_gf_inbox_evidence_pack():
+ """Second line from payload.evidence; missing evidence stays the one-liner."""
+ linked = {
+ "geofence_name": "Yard",
+ "source_kind": "news",
+ "entity_id": "n-1",
+ "created_at": "2026-11-14T05:00:00Z",
+ "payload": {
+ "evidence": {
+ "cameras": [
+ {"id": "c1", "name": "North Gate", "snapshot_url": "rtsp://camera/1"},
+ {"id": "c2", "name": "South Gate", "snapshot_url": "/api/cameras/c2/snapshot"},
+ ],
+ "news": [{"headline": "Fence brief", "url": "https://ex.com/1", "importance": "high"}],
+ "snapshot": "/api/geofences/g1/at?ts=2026-11-14T05:00:00Z",
+ }
+ },
+ }
+ text_news = {
+ "geofence_name": "Yard",
+ "source_kind": "earthquake",
+ "entity_id": "eq-9",
+ "payload": {
+ "evidence": {
+ "cameras": [],
+ "news": [{"headline": "Silent quake", "url": "", "importance": ""}],
+ }
+ },
+ }
+ bare = {
+ "geofence_name": "Old Fence",
+ "source_kind": "adsb",
+ "entity_id": "abc123",
+ "payload": {"icao": "abc123"},
+ }
+ top_level = {
+ "geofence_name": "Top",
+ "source_kind": "fire_incident",
+ "entity_id": "fi-1",
+ "evidence": {
+ "cameras": [{"id": "c9", "name": "Lot Cam", "snapshot_url": "rtsp://camera/1"}],
+ "news": [{"headline": "Lot fire", "url": "https://ex.com/1", "importance": ""}],
+ },
+ }
+ as_string = {
+ "geofence_name": "String Fence",
+ "source_kind": "news",
+ "entity_id": "s1",
+ "payload": json.dumps({
+ "evidence": {
+ "cameras": [{"id": "c3", "name": "Cam A", "snapshot_url": "rtsp://camera/1"}],
+ "news": [{"headline": "From string", "url": "https://ex.com/1", "importance": ""}],
+ }
+ }),
+ }
+ rendered = _render_inbox([linked, text_news, bare, top_level, as_string])
+ html, quiet, plain, fallback, parsed = [row["html"] for row in rendered]
+
+ assert "2 cams" in html
+ assert "North Gate" in html
+ assert 'href="https://ex.com/1"' in html
+ assert 'target="_blank"' in html
+ assert 'rel="noopener"' in html
+ assert "stopPropagation" in html
+ assert "rtsp://camera/1" not in html
+ assert rendered[0]["hasOnclick"]
+
+ assert "Silent quake" in quiet
+ assert "" not in plain
+ assert rendered[2]["hasOnclick"]
+
+ assert "1 cams" in fallback
+ assert 'href="https://ex.com/1"' in fallback
+ assert "rtsp://camera/1" not in fallback
+
+ assert "1 cams" in parsed
+ assert "From string" in parsed
+ assert "rtsp://camera/1" not in parsed