From c96bfe3b2cdffb38739493848c4de8b009b398e3 Mon Sep 17 00:00:00 2001 From: you Date: Sun, 22 Mar 2026 23:52:44 +0000 Subject: [PATCH] Fix: packet detail uses server-side resolve-hops with GPS anchor Client-side HopResolver wasn't properly disambiguating despite correct data. Switched detail view to use the server API directly: /api/resolve-hops?hops=...&observer=...&originLat=...&originLon=... Server-side resolution is battle-tested and handles regional filtering + GPS-anchored disambiguation correctly. --- public/index.html | 2 +- public/packets.js | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index e5220f02..1e1892b0 100644 --- a/public/index.html +++ b/public/index.html @@ -86,7 +86,7 @@ - + diff --git a/public/packets.js b/public/packets.js index 6587a0c9..f9e90965 100644 --- a/public/packets.js +++ b/public/packets.js @@ -1100,18 +1100,22 @@ let pathHops; try { pathHops = JSON.parse(pkt.path_json || '[]'); } catch { pathHops = []; } - // Re-resolve hops with sender location + observer — bypass stale cache + // Re-resolve hops using SERVER-SIDE API with sender GPS + observer for proper disambiguation if (pathHops.length) { - await ensureHopResolver(); const senderLat = decoded.lat != null ? decoded.lat : (decoded.latitude || null); const senderLon = decoded.lon != null ? decoded.lon : (decoded.longitude || null); - console.log('[renderDetail] GPS anchor:', senderLat, senderLon, 'observer:', pkt.observer_id?.slice(0,12)); - // Always re-resolve for detail view — list view may have cached without anchor - const fresh = HopResolver.resolve(pathHops, senderLat, senderLon, null, null, pkt.observer_id); - for (const [k, v] of Object.entries(fresh || {})) { - console.log('[renderDetail] hop', k, '→', v.name, 'ambig:', v.ambiguous, 'conflicts:', v.conflicts?.length); - hopNameCache[k] = v; - } + try { + const params = new URLSearchParams({ hops: pathHops.join(',') }); + if (pkt.observer_id) params.set('observer', pkt.observer_id); + if (senderLat != null) params.set('originLat', senderLat); + if (senderLon != null) params.set('originLon', senderLon); + const serverResolved = await api(`/resolve-hops?${params}`); + if (serverResolved?.resolved) { + for (const [k, v] of Object.entries(serverResolved.resolved)) { + hopNameCache[k] = v; + } + } + } catch {} } // Parse hash size from path byte