Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/customize-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3090,7 +3090,7 @@
return '<option value="' + value + '"' + (mode === value ? ' selected' : '') + '>' + label + '</option>';
};
return '<p class="cust-section-title" style="font-size:14px;margin:16px 0 8px">Path Display</p>' +
'<p class="cust-hint" style="font-size:12px;color:var(--text-muted);margin-bottom:8px">1-byte path-hash prefixes (firmware default) collide often: several nodes share each one, so a 1-byte hop on a route is a best guess. Mark flags the uncertain hops on the map route; Hide leaves 1-byte hops out everywhere without changing what\'s stored.</p>' +
'<p class="cust-hint" style="font-size:12px;color:var(--text-muted);margin-bottom:8px">1-byte path-hash prefixes (firmware default) collide often: several nodes share each one, so a 1-byte hop on a route is a best guess. Mark flags the uncertain hops on the map route; Hide leaves 1-byte hops out everywhere without changing what\'s stored. Until you pick a mode here, the Live map shows every hop unmarked.</p>' +
'<div class="cust-field">' +
'<label for="cv2-hide-1byte-hops" style="display:block;margin-bottom:4px">Short (1-byte) path-hash hops</label>' +
'<select id="cv2-hide-1byte-hops" data-cv2-hide-1byte-hops style="width:100%;padding:6px 8px;border:1px solid var(--border);border-radius:6px;background:var(--input-bg);color:var(--text)">' +
Expand Down
20 changes: 16 additions & 4 deletions public/hop-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
// show — as before #674, no markings;
// mark — (default) visible, uncertain hops marked in the map route view;
// hide — the #1633 behaviour: 1-byte hops left out everywhere.
// The default is stored as "no key". The #1633 boolean key migrates once:
// "true" becomes mode "hide"; anything else is dropped.
// "No key" means the visitor never chose; an explicit choice, Mark
// included, is always stored (#912 M1: Live tells the two apart). The #1633
// boolean key migrates once: "true" becomes mode "hide"; anything else is
// dropped.
var MODE_KEY = 'meshcore-1byte-hops-mode';
var LEGACY_KEY = 'meshcore-hide-1byte-hops';
var MODES = ['show', 'mark', 'hide'];
Expand Down Expand Up @@ -52,8 +54,7 @@
function set1ByteHopsMode(mode) {
if (!isMode(mode)) return;
try {
if (mode === DEFAULT_MODE) localStorage.removeItem(MODE_KEY);
else localStorage.setItem(MODE_KEY, mode);
localStorage.setItem(MODE_KEY, mode);
localStorage.removeItem(LEGACY_KEY);
} catch (_e) { /* private mode */ }
if (typeof window !== 'undefined' && typeof window.CustomEvent === 'function') {
Expand All @@ -63,6 +64,15 @@
}
}

// #912 M1 — the visitor's own choice, or null when they never made one.
// Runs get1ByteHopsMode() first so junk is dropped and the #1633 key
// migrates exactly as for every other reader.
function getStored1ByteHopsMode() {
var mode = get1ByteHopsMode();
try { return localStorage.getItem(MODE_KEY) != null ? mode : null; }
catch (_e) { return null; }
}

// #1633 API, kept for its callers: "hide" is mode hide; turning it off
// restores the pre-#674 unmarked view (show).
function getHide1ByteHops() { return get1ByteHopsMode() === 'hide'; }
Expand Down Expand Up @@ -139,6 +149,7 @@
window.MC_setHide1ByteHops = setHide1ByteHops;
window.MC_get1ByteHopsMode = get1ByteHopsMode;
window.MC_set1ByteHopsMode = set1ByteHopsMode;
window.MC_getStored1ByteHopsMode = getStored1ByteHopsMode;
window.MC_isVisibleHop = isVisibleHop;
window.MC_filterPathHops = filterPathHops;
window.MC_hopByteLen = hopByteLen;
Expand All @@ -151,6 +162,7 @@
setHide1ByteHops: setHide1ByteHops,
get1ByteHopsMode: get1ByteHopsMode,
set1ByteHopsMode: set1ByteHopsMode,
getStored1ByteHopsMode: getStored1ByteHopsMode,
isVisibleHop: isVisibleHop,
filterPathHops: filterPathHops,
hopByteLen: hopByteLen,
Expand Down
100 changes: 89 additions & 11 deletions public/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
let packetCount = 0;
let activeAnims = 0;
const MAX_CONCURRENT_ANIMS = 20;
// #912 M1: an uncertain segment is lighter than a certain one (0.8), as the
// route view's redacted edges are (route-render.js: 0.6 against 0.92).
const UNCERTAIN_SEGMENT_OPACITY = 0.5;
// Perf caps for the animation overlay (see updateAnimCanvas / renderAnimations).
const ANIM_MAX_DPR = 1.5; // cap backing-store pixels on hi-DPI displays
const ANIM_MIN_FRAME_MS = 15; // don't redraw faster than ~60fps (high-refresh guard)
Expand Down Expand Up @@ -4196,6 +4199,9 @@
window._liveFormatLiveTimestampHtml = formatLiveTimestampHtml;
window._liveResolveHopPositions = resolveHopPositions;
window._liveResolveHopEntries = resolveHopEntries;
window._liveOneByteHopsMode = oneByteHopsMode;
window._liveIsUncertainSegment = isUncertainSegment;
window._liveApplyOneByteHopsMode = applyOneByteHopsMode;
window._liveStartFollow = function(hash, opts) { return startFollow(hash, opts); };
window._liveStopFollow = function() { stopFollow(); };
window._liveFollowState = function() { return followState; };
Expand Down Expand Up @@ -4665,6 +4671,7 @@
// Prefer path_json (per-observer unique path) over decoded.path.hops (same for all)
var allPaths = [];
var seenPathKeys = new Set();
var hopMode = oneByteHopsMode(); // #912 M1: once per packet group
for (var qi = 0; qi < packets.length; qi++) {
var qpkt = packets[qi];
var qd = qpkt.decoded || {};
Expand All @@ -4678,7 +4685,7 @@
var pathKey = hops.join(',');
if (seenPathKeys.has(pathKey)) continue;
seenPathKeys.add(pathKey);
var hopPositions = resolveHopPositions(hops, qp, window.getResolvedPath ? getResolvedPath(qpkt) : null);
var hopPositions = resolveHopPositions(hops, qp, window.getResolvedPath ? getResolvedPath(qpkt) : null, hopMode);
if (hopPositions.length >= 2) {
allPaths.push({ hopPositions: hopPositions, raw: qpkt.raw || first.raw });
} else if (hopPositions.length === 1) {
Expand All @@ -4689,7 +4696,7 @@
// If no multi-hop paths found, try the decoded path as fallback
if (allPaths.length === 0) {
var fallbackHops = decoded.path?.hops || [];
var fallbackPositions = resolveHopPositions(fallbackHops, payload);
var fallbackPositions = resolveHopPositions(fallbackHops, payload, null, hopMode);
if (fallbackPositions.length >= 2) {
allPaths.push({ hopPositions: fallbackPositions, raw: first.raw });
} else if (fallbackPositions.length === 1) {
Expand Down Expand Up @@ -4831,13 +4838,73 @@
});
}

function resolveHopPositions(hops, payload, resolvedPath) {
// #912 M1 — the 1-byte hop setting of hop-filter.js (#674), read per
// packet so a change (MC_set1ByteHopsMode fires mc-hide-1byte-hops-changed)
// reaches the next packet at once; animations in flight just finish.
// A visitor who never chose (or no hop-filter.js) gets Show on Live: owner
// decision on #912 (2026-11-27) until M2's operator default replaces this
// fallback. Other pages keep hop-filter.js's own default.
const LIVE_1BYTE_HOPS_FALLBACK = 'show';
function oneByteHopsMode() {
const stored = typeof window.MC_getStored1ByteHopsMode === 'function'
? window.MC_getStored1ByteHopsMode() : null;
return stored || LIVE_1BYTE_HOPS_FALLBACK;
}

// #912 M1 — applies the mode to a path before it is resolved. Hide leaves
// the 1-byte hops out, with resolved_path filtered in step so each server
// answer stays with its own hop; Mark keeps them and flags their positions.
// Returns the input arrays untouched for Show, or when nothing changes.
// O(hops), no lookups: same order as the resolve that follows.
function applyOneByteHopsMode(hops, resolvedPath, mode) {
const out = { hops: hops, resolvedPath: resolvedPath, oneByte: null, hidden: 0 };
const isVisibleHop = window.MC_isVisibleHop;
if ((mode !== 'hide' && mode !== 'mark') || !hops || !hops.length ||
typeof isVisibleHop !== 'function') return out;
const opts = { hide1ByteHops: true };
const paired = !!resolvedPath && resolvedPath.length === hops.length;
let kept = null, keptRp = null;
for (let i = 0; i < hops.length; i++) {
if (isVisibleHop(hops[i], opts)) {
if (kept) { kept.push(hops[i]); if (keptRp) keptRp.push(resolvedPath[i]); }
continue;
}
if (mode === 'mark') {
if (!out.oneByte) out.oneByte = new Array(hops.length).fill(false);
out.oneByte[i] = true;
continue;
}
if (!kept) { kept = hops.slice(0, i); keptRp = paired ? resolvedPath.slice(0, i) : null; }
out.hidden++;
}
if (kept) {
out.hops = kept;
// A resolved_path that did not match the hops is ignored downstream; it
// must not start to match the shorter path by accident.
out.resolvedPath = keptRp;
}
return out;
}

// #912 M1 — a segment is drawn dashed and lighter when either end is an
// uncertain position (Mark: a 1-byte hop; Hide: any, once hops were dropped).
function isUncertainSegment(a, b) {
return !!((a && a.uncertain) || (b && b.uncertain));
}

// mode: the 1-byte hop setting (#912 M1); anything but 'hide' / 'mark'
// draws every hop unmarked.
function resolveHopPositions(hops, payload, resolvedPath, mode) {
// Hoist sender GPS guard once — reject (0,0) as "no GPS"
const hasValidGps = payload.lat != null && payload.lon != null
&& !(payload.lat === 0 && payload.lon === 0);
const senderLat = hasValidGps ? payload.lat : null;
const senderLon = hasValidGps ? payload.lon : null;
const raw = resolveHopEntries(hops, payload, resolvedPath);
const filtered = applyOneByteHopsMode(hops, resolvedPath, mode);
const raw = resolveHopEntries(filtered.hops, payload, filtered.resolvedPath);
if (filtered.oneByte) {
for (let i = 0; i < raw.length; i++) if (filtered.oneByte[i]) raw[i].uncertain = true;
}

// Add sender position as anchor if available
if (payload.pubKey && senderLat != null) {
Expand All @@ -4846,6 +4913,11 @@
raw.unshift({ key: payload.pubKey, pos: [payload.lat, payload.lon], name: payload.name || payload.pubKey.slice(0, 8), known: true });
}
}
// Hide dropped hops: no segment of what is left reads as a direct link
// (route-render.js does the same, #1689 r1).
if (filtered.hidden > 0) {
for (let i = 0; i < raw.length; i++) raw[i].uncertain = true;
}

if (!showGhostHops) return raw.filter(h => h.known);

Expand Down Expand Up @@ -4931,7 +5003,8 @@
const lineColor = (isGhost || nextGhost) ? '#94a3b8' : color;
const lineOpacity = (isGhost || nextGhost) ? 0.3 : undefined;
const segHash = forceColor ? null : pktMeta?.hash;
drawAnimatedLine(hp.pos, nextPos, lineColor, () => { hopIndex++; nextHop(); }, lineOpacity, rawHex, segHash);
const uncertain = isUncertainSegment(hp, hopPositions[hopIndex + 1]);
drawAnimatedLine(hp.pos, nextPos, lineColor, () => { hopIndex++; nextHop(); }, lineOpacity, rawHex, segHash, uncertain);
} else {
if (!isGhost) pulseNode(hp.key, hp.pos, typeName);
hopIndex++; nextHop();
Expand Down Expand Up @@ -5506,7 +5579,8 @@
const line = L.polyline([anim.from, anim.to], {
pane: 'animationsPane', // #1514 M2 — fades stack with the moving phase (z=625).
color: anim.lineColor, weight: anim.isDashed ? 1.5 : 2, opacity: anim.opacity,
lineCap: 'round', dashArray: anim.isDashed ? '4 6' : null
lineCap: 'round', dashArray: anim.isDashed ? '4 6' : null,
className: anim.uncertain ? 'live-path-uncertain' : ''
}).addTo(pathsLayer);

recentPaths.push({ line, glowLine: contrail, time: Date.now() });
Expand All @@ -5529,7 +5603,9 @@
}
}

function drawAnimatedLine(from, to, color, onComplete, overrideOpacity, rawHex, hash) {
// uncertain (#912 M1): a segment at a 1-byte hop (Mark) or of a path whose
// 1-byte hops were left out (Hide): dashed and lighter, in its own colour.
function drawAnimatedLine(from, to, color, onComplete, overrideOpacity, rawHex, hash, uncertain) {
// GUARD: Prevent stale callbacks from pushing to a destroyed map
if (!map || !animCtx) {
if (onComplete) onComplete();
Expand All @@ -5538,14 +5614,15 @@

if (matrixMode) return drawMatrixLine(from, to, color, onComplete, rawHex);

const mainOpacity = overrideOpacity ?? 0.8;
const isDashed = overrideOpacity != null;
const isGhostLine = overrideOpacity != null;
const mainOpacity = overrideOpacity ?? (uncertain ? UNCERTAIN_SEGMENT_OPACITY : 0.8);
const isDashed = isGhostLine || !!uncertain;

var hashFill = '#fff';
var hashOutline = color;
var contrailColor = color;

if (colorByHash && hash && !isDashed && window.HashColor) {
if (colorByHash && hash && !isGhostLine && window.HashColor) {
var hsl = HashColor.hashToHsl(hash, _liveTheme());
hashFill = hsl;
hashOutline = HashColor.hashToOutline(hash, _liveTheme());
Expand All @@ -5560,7 +5637,8 @@
lastTick: null,
opacity: mainOpacity,
isDashed: isDashed,
lineColor: (colorByHash && hash && !isDashed && window.HashColor) ? hashFill : color,
uncertain: !!uncertain,
lineColor: (colorByHash && hash && !isGhostLine && window.HashColor) ? hashFill : color,
contrailColor: contrailColor,
hashFill: hashFill,
hashOutline: hashOutline,
Expand Down
1 change: 1 addition & 0 deletions scripts/e2e-shards.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@
{"file":"test-issue-978-view-path-recovery-e2e.js","shard":3,"env":{"BASE_URL":"$BASE_URL"},"output":"e2e","meanSeconds":3.5,"measurementNote":"New suite; #978 items 2 and 3 on a 375x560 touch phone from a cold start in the light and dark theme: a View Path whose /api/packets/<hash>/path request is aborted once shows a 44x44+ Try again that refetches and draws the map; a shared #/packets/<hash>?viewPath=1 link with packet-path-map.js blocked shows a notice, keeps ?viewPath=1, reports a second blocked retry, then loads the script and opens the modal; Close on the notice drops ?viewPath=1; Escape closes it, a second open replaces it, and leaving the page removes it. 3.5s locally (mean of 5 runs, 3.4 to 3.6s); no CI duration measured yet. Assigned to shard 3, the lightest by meanSeconds.","secondsByExecution":[]},
{"file":"test-984-live-affinity-poller-e2e.js","shard":3,"env":{"BASE_URL":"$BASE_URL"},"output":"e2e","meanSeconds":22,"measurementNote":"New suite; #984 the Live neighbor-graph (hop affinity) poller on Playwright's clock, with the app socket replaced by page.routeWebSocket and every /api/analytics/neighbor-graph request intercepted (held, or answered with the real server body), counted and tracked while open: a 375x560 touch phone from a cold start whose connection stalls for 5 ticks makes one request per tick, each aborted by the timeout before the next, never two open; while one is held extra ticks and a re-armed poller add none, and the next tick's answer reaches HopResolver.setAffinity; a hidden tab (document.hidden overridden, the real visibilitychange listener) polls nothing for 5 min and refreshes exactly once on return with stale data, not with fresh; #/live?kiosk=1 at 1920x1080 still refreshes every 60 s; leaving Live aborts the open request and nothing polls afterwards, and an in-place remount polls on one interval. About 22s locally; no CI duration measured yet. Assigned to shard 3, the lightest by the sum of meanSeconds.","secondsByExecution":[]},
{"file":"test-issue-990-packets-live-area-e2e.js","shard":2,"env":{"CHROMIUM_REQUIRE":"1"},"output":"e2e","meanSeconds":7,"measurementNote":"New suite; #990 live WebSocket packets on the Packets page follow the Area filter. Fully stubbed (page.route and routeWebSocket), no server needed. Local runs about 7 s; assigned to the lightest shard."},
{"file":"test-issue-912-live-1byte-hops-e2e.js","shard":1,"env":{"BASE_URL":"$BASE_URL"},"output":"e2e","meanSeconds":10.5,"measurementNote":"#912 M1 the Live map follows the 1-byte hop setting: with no stored mode Live uses Show (owner decision, until M2); ADVERT routes between fixture nodes through the real WS handler with every L.polyline recorded; at 1440x900 with the mode switched through the customizer select and no reload, Show draws the 1-byte hop unmarked (control), Hide leaves no polyline vertex on it and draws A to C dashed and lighter (live-path-uncertain), a pure 1-byte path with decoded.path.hops set draws no hop through the renderPacketTree fallback, a multi-byte route stays unmarked, Mark keeps the hop and marks only the segments that touch it; a 375x560 touch phone from a cold start picks Hide by real taps (More, Customize, Display) and Live draws no vertex on the hop. About 10s in CI shard 1 (run 46044676327) and 10.5s locally with the #912 fix-round steps. Assigned to shard 1, the lightest by the sum of meanSeconds.","secondsByExecution":[]},
{"file":"test-issue-740-m3a-dagi-filter-e2e.js","shard":3,"env":{"BASE_URL":"$BASE_URL"},"output":"e2e","meanSeconds":10,"measurementNote":"New suite; #740 M3a the Danish areas (DAGI) filter on the Nodes page against the real GET /api/config/dagi: at 375x560 touch in light and dark from a cold #/nodes with real taps only, the trigger opens a bottom sheet inside the viewport (no sideways scroll, 44 px rows, no autofocus in the search), aar finds Aarhus and the postcodes, a tap puts kommune=0751 in the URL and the request (that one /api/nodes answer is fulfilled from a real fixture node, as the fixture has no Danish node), labels the trigger and shows the hidden-count notice, and the clear button takes it all away again; unmocked: kommune=0860 shows the server count and an empty list, an unknown code is never sent and leaves the URL, the most specific of several params wins; at 1440x900 keyboard pick, Escape and a search or tab change keeping the param; first open and a search timed at 4x CPU throttling; the saved pick across a reload and a street postcode link. About 9s locally; no CI duration measured yet. Assigned to shard 3, the lightest by the sum of meanSeconds."},
{"file":"test-issue-740-m3b-packets-live-dagi-e2e.js","shard":1,"env":{"CHROMIUM_REQUIRE":"1"},"output":"e2e","meanSeconds":8,"measurementNote":"New suite; #740 M3b live WebSocket packets on the Packets page follow the DAGI filter by the server's rule (the ADVERT sender is in the member set; a known area nobody is in matches nothing; an unknown or unchecked code is never sent), with one member-set request per selection change, picked with the real dagi-filter.js control. Fully stubbed (page.route and routeWebSocket), no server needed. About 8 s locally; no CI duration measured yet. Assigned to shard 1, the lightest by the sum of meanSeconds."},
{"file":"test-issue-740-m3b-dagi-packets-map-e2e.js","shard":2,"env":{"BASE_URL":"$BASE_URL"},"output":"e2e","meanSeconds":85,"measurementNote":"New suite; #740 M3b against the real server: Packets and Map at 375x560 touch in light and dark from a cold start with real taps (a bottom sheet nothing covers, kommune=0751 on /api/packets with one member-set request and the ADVERT note; the Map outline from one polygon request, fitted on the pick, a zoom asks for nothing, the clear removes it and its credit; the #740 M3b follow-up adds the Map case at 360x640 and checks that the pick closes the controls panel so nothing covers the fitted outline), 1440x900 light and dark (a cold link with its own view draws without a fit, a keyboard pick in the unclipped popover replaces the outline and fits, pan and zoom ask for nothing), a leave/re-enter leak check, and the Packets REST and URL-writer cases. About 60 s locally; no CI duration measured yet. Assigned to shard 2, the lightest by the sum of meanSeconds after the stubbed suite."},
Expand Down
1 change: 1 addition & 0 deletions test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ run test-issue-1509-detect-preset.js
run test-issue-353-path-hash-warn.js
run test-issue-480-no-scope.js
run test-live.js
run test-issue-912-live-1byte-hops.js
run test-issue-220-live-filter-readiness.js
run test-coverage-gate.js
run test-node-reach-coverage.js
Expand Down
Loading
Loading