fix(meshcore): preserve node name on empty advert (#3756)#3785
Conversation
Zero-hop repeaters (and some firmware builds) emit `contact_advertised` events with `adv_name: ""`. The `??` null-coalescing operator passes an empty string through unchanged, so the stored node name was silently overwritten with "" on every re-advert, leaving the node unnamed in the list. Switch `??` to `||` in both the in-memory contact merge (handleBridgeEvent) and the DB write (persistContact) so an empty name falls back to the previously known value, the same way null/undefined already did. Adds a regression test that fires a named advert followed by an empty-name re-advert and asserts both the in-memory contact and the upsertNode DB call retain the original name. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBLhGGNh35oMwTL53va1Y5
|
Claude finished @Yeraze's task —— View job PR Review: fix(meshcore): preserve node name on empty advert (#3756)Tasks:
SummaryThis is a clean, minimal, well-targeted fix. The root cause analysis is correct, the fix is idiomatic, and the regression test is solid. Ready to merge with one minor observation noted below. Code Review
|
Summary
Fixes #3756 — MeshCore nodes showing as unnamed in the node list after a re-advertise.
Root cause: Zero-hop repeaters (and some MeshCore firmware builds) send
contact_advertisedevents withadv_name: "". The??null-coalescing operator passes an empty string through unchanged (since""is notnull/undefined), so the stored node name was silently overwritten with an empty value on every re-advert.Fix: Switch
??→||in two places so an empty name falls back to the previously known value, the same waynull/undefinedalready did:handleBridgeEvent(in-memory contact merge) —meshcoreManager.ts:1112persistContact(DB write intomeshcore_nodes) —meshcoreManager.ts:1473Test: New regression case in
meshcoreManager.contactPersistence.test.tsfires a named advert followed by an empty-name re-advert and asserts both the in-memory contact (getContact) and theupsertNodeDB call retain the original name.Provenance
This is the minimal, still-relevant half of the now-closed PRs #3771 / #3772 (which were duplicates of each other). Their other half — the #3769 message-metadata contrast fix — already shipped in #3778, so those PRs were closed and this carries forward only the node-name fix, rebased clean on current
mainwith no CSS changes.Test plan
vitest run src/server/meshcoreManager.contactPersistence.test.ts— 10/10 pass (incl. new regression)tsc -p tsconfig.server.json --noEmit— clean🤖 Generated with Claude Code