fix(recent): re-find merged row by sameNode so name survives key promotion

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erwin FitenandClaude Opus 4.8 committed 2026-06-15 11:05:35 +02:00
1 parent 556dc72f46
commit 6132eb91ef
1 file changed
+6 -5
+6 -5
View File
@@ -8,7 +8,7 @@ import { parseFrame, PUSH_CODE_LOG_RX_DATA } from './frames.js';
import { parsePacket, deriveHeardKey, bytesToHex, isFloodRoute } from './meshpacket.js';
import { requestSelfInfo, requestDeviceInfo, setPathHashMode } from './selfinfo.js';
import { resolveName } from './names.js';
import { upsertHeard } from './recent.js';
import { upsertHeard, sameNode } from './recent.js';
import { createLocalMap } from './localmap.js';
import { Gps } from './gps.js';
import { Queue } from './queue.js';
@@ -40,14 +40,15 @@ function snrColor(snr) {
function noteHeard(key, keylen, snr, rssi, src) {
state.recent = upsertHeard(state.recent, { key, keylen, snr, rssi, src, now: Date.now() }, RECENT_MAX);
const e = state.recent[0]; // merged entry is at the front
// Resolve the name once per node, keyed on the canonical (longest) key. Look the
// entry up again in the callback so a later merge can't leave us writing a stale row.
// Resolve the name once per node, keyed on the canonical (longest) key. Re-find the
// entry in the callback by sameNode (not exact key) so a key promotion mid-flight
// (short hash → full pubkey) still writes the name to the merged row.
if (e.name === undefined && !e._req) {
e._req = true;
const canon = e.key;
resolveName(canon)
.then((nm) => { const cur = state.recent.find((x) => x.key === canon); if (cur) { cur.name = nm || ''; renderRecent(); } })
.catch(() => { const cur = state.recent.find((x) => x.key === canon); if (cur) cur._req = false; });
.then((nm) => { const cur = state.recent.find((x) => sameNode(x.key, canon)); if (cur) { cur.name = nm || ''; renderRecent(); } })
.catch(() => { const cur = state.recent.find((x) => sameNode(x.key, canon)); if (cur) cur._req = false; });
}
renderRecent();
}