From 701f6f1197cb66e0952a95277fead4070c78611c Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sat, 28 Mar 2026 17:52:41 +0100 Subject: [PATCH] fix(dm): refresh mc.contacts from device on PATH_UPDATE event The Contact Info dialog showed stale path data (e.g. "Flood" instead of the discovered route) because auto_update_contacts is OFF and PATH_UPDATE only sets _contacts_dirty=True without refreshing mc.contacts. The API then served stale in-memory data even after cache invalidation. Now ensure_contacts(follow=True) is called on PATH_UPDATE to read fresh contact data from the device before invalidating cache and emitting the socket event. PATH_UPDATE events are rare (only on path discovery), so the serial I/O cost is acceptable unlike advertisements. Co-Authored-By: Claude Opus 4.6 --- app/device_manager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/device_manager.py b/app/device_manager.py index 811953e..06b8737 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -761,6 +761,14 @@ class DeviceManager: ) logger.debug(f"Path update for {pubkey[:8]}...") + # Refresh mc.contacts from device so API returns fresh path data. + # PATH_UPDATE events are rare (only on path discovery), so the + # serial I/O cost is acceptable (unlike advertisements). + try: + await self.mc.ensure_contacts(follow=True) + except Exception as e: + logger.warning(f"Failed to refresh contacts after path update: {e}") + # Invalidate contacts cache so UI gets fresh path data try: from app.routes.api import invalidate_contacts_cache