From 6dd26f8cf922cadb8b7466780e2f52d2e563a307 Mon Sep 17 00:00:00 2001 From: R0ck Date: Sat, 10 Oct 2026 00:02:36 +0100 Subject: [PATCH 1/3] feat(scope-audit): transport view on the Scope Audit page (#2142) Adds a Declared / Transport toggle to #/scope-audit. The transport view calls ?mode=transport and lists every repeater seen forwarding in the window: - Seen carrying: one chip per region scope with its packet count; - Declared: the repeater's declared regions coloured by whether they were seen carried (the declared view's chips), or "not asked" when no declared-regions answer exists; - Other traffic: unscoped, unmatched and ambiguous-hop counts. A Region box (suggestions from the scopes seen) adds a Carries column, puts the repeaters not yet carrying the region first, and summarises carriers vs active non-carriers: the rollout report. The window, view and region are in the hash (#/scope-audit?window=7d&mode=transport®ion=be). The page says that "transported" means seen carrying, not configured, and that a quiet region looks like a missing one over a short window. Tests: 9 cases in test-frontend-helpers.js on rendered markup and hash state (net-new UI surface: tests land in the same PR, per TDD.md). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H --- public/scope-audit.css | 15 ++ public/scope-audit.js | 236 ++++++++++++++++++++++++++-- tests/unit/test-frontend-helpers.js | 89 +++++++++++ 3 files changed, 327 insertions(+), 13 deletions(-) diff --git a/public/scope-audit.css b/public/scope-audit.css index 3dd6e36da..414868ab6 100644 --- a/public/scope-audit.css +++ b/public/scope-audit.css @@ -103,3 +103,18 @@ region IS observed. The dotted underline says how that was established without introducing a third colour into a column that already carries two. */ .sa-chip-verified { text-decoration: underline dotted; text-underline-offset: 2px; } + +/* #2142 transport view: view toggle, region filter, carried-scope chips. */ +.sa-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } +.sa-region-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 12px; } +.sa-region-bar[hidden] { display: none; } /* display:flex above would otherwise override the hidden attribute */ +.sa-region-bar label { font-weight: 600; } +/* .nodes-search sets width:100%; the region box only needs room for one code. */ +.sa-region-bar .sa-region { width: 160px; max-width: 100%; flex: none; } +.sa-chip-transported { background: var(--section-bg, var(--card-bg)); color: var(--text); border: 1px solid var(--border); } +.sa-chip-transported .sa-chip-count { color: var(--text-muted); } +/* The region being filtered on: same chip, heavier outline in the link colour, + so it stands out without adding a third status colour. */ +.sa-chip-match { border-color: var(--link-color); box-shadow: inset 0 0 0 1px var(--link-color); } +.sa-not-asked { color: var(--text-muted); font-style: italic; font-size: 12px; } +.sa-counts { font-size: 11px; white-space: nowrap; } diff --git a/public/scope-audit.js b/public/scope-audit.js index de85f3589..7d46d1178 100644 --- a/public/scope-audit.js +++ b/public/scope-audit.js @@ -17,10 +17,54 @@ { key: '7d', label: '7d' } ]; var win = DEFAULT_WINDOW; + // #2142: 'declared' is the declared-vs-observed audit; 'transport' lists every + // repeater seen forwarding, optionally split by one region (rollout tracking). + var MODES = [ + { key: 'declared', label: 'Declared' }, + { key: 'transport', label: 'Transport' } + ]; + var mode = 'declared'; + var region = ''; // transport view only; normalised (no '#', lower case) var searchQuery = ''; // free-text filter over name/pubkey/region, applied client-side var searchIndex = {}; // publicKey -> lowercased searchable haystack, rebuilt every renderBody var sortCtl = null; // tracked TableSort controller for destroy-before-reinit (mirrors observers.js) + // introHtml describes the view being shown: the declared view covers only + // repeaters that answered a declared-regions request, the transport view + // every repeater seen forwarding. + function introHtml(m) { + if (m === 'transport') { + return 'Every repeater seen forwarding in the window, with the region scopes it was seen carrying and, where it has answered, the regions it declares. ' + + 'Type a region to see which repeaters carry it and which were active but did not. Per-node detail lives on each node\'s page.'; + } + return 'Network-wide comparison of declared vs. observed region-scope forwarding, across every repeater that has declared a region list over RF. ' + + 'Per-node detail lives on each node\'s page.'; + } + + function modeBtn(key, cur, label) { + var on = key === cur; + return ''; + } + + // normRegion mirrors the server's normalisation for ?region=: no leading '#', + // lower case, trimmed. + function normRegion(r) { + r = String(r || '').trim().toLowerCase(); + return r.charAt(0) === '#' ? r.slice(1) : r; + } + + // buildHash / apiPath carry the view state, so a transport view filtered to + // one region is shareable as a link (AGENTS.md deep-linking rule). + function buildHash(w, m, rgn) { + return '#/scope-audit?window=' + encodeURIComponent(w) + + (m === 'transport' ? '&mode=transport' + (rgn ? '®ion=' + encodeURIComponent(rgn) : '') : ''); + } + function apiPath(w, m, rgn) { + return '/scope-audit?window=' + encodeURIComponent(w) + + (m === 'transport' ? '&mode=transport' + (rgn ? '®ion=' + encodeURIComponent(rgn) : '') : ''); + } + function windowBtn(key, cur, label) { var on = key === cur; return '