From ba990b155fbdc89f2fec3af85f83be35c82f25cf Mon Sep 17 00:00:00 2001 From: MarekWo Date: Mon, 2 Mar 2026 17:19:09 +0100 Subject: [PATCH] fix(ui): fix leading pipe separator when SNR is missing from message Use array-based metaParts.join(' | ') instead of string concatenation to avoid ugly leading "| Hops: 0" when meshcore lib doesn't provide SNR. Also revert temporary INFO-level debug logging back to DEBUG. Co-Authored-By: Claude Opus 4.6 --- app/device_manager.py | 4 ++-- app/static/js/app.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/device_manager.py b/app/device_manager.py index 1e7992a..9ac1de0 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -228,7 +228,7 @@ class DeviceManager: for event_type, handler in handlers: sub = self.mc.subscribe(event_type, handler) self._subscriptions.append(sub) - logger.info(f"Subscribed to {event_type.value}") + logger.debug(f"Subscribed to {event_type.value}") def _sync_contacts_to_db(self): """Sync device contacts to database.""" @@ -519,7 +519,7 @@ class DeviceManager: import io data = getattr(event, 'payload', {}) payload_hex = data.get('payload', '') - logger.info(f"RX_LOG_DATA received: {len(payload_hex)//2} bytes, snr={data.get('snr')}") + logger.debug(f"RX_LOG_DATA received: {len(payload_hex)//2} bytes, snr={data.get('snr')}") if not payload_hex: return diff --git a/app/static/js/app.js b/app/static/js/app.js index 22f4d4a..e230bab 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -774,12 +774,12 @@ function createMessageElement(msg) { })); } - let metaInfo = ''; + let metaParts = []; if (msg.snr !== undefined && msg.snr !== null) { - metaInfo += `SNR: ${msg.snr.toFixed(1)} dB`; + metaParts.push(`SNR: ${msg.snr.toFixed(1)} dB`); } if (msg.path_len !== undefined && msg.path_len !== null) { - metaInfo += ` | Hops: ${msg.path_len}`; + metaParts.push(`Hops: ${msg.path_len}`); } if (msg.paths && msg.paths.length > 0) { // Show first path inline (shortest/first arrival) @@ -790,8 +790,9 @@ function createMessageElement(msg) { : segments.join('\u2192'); const pathsData = encodeURIComponent(JSON.stringify(msg.paths)); const routeLabel = msg.paths.length > 1 ? `Route (${msg.paths.length})` : 'Route'; - metaInfo += ` | ${routeLabel}: ${shortPath}`; + metaParts.push(`${routeLabel}: ${shortPath}`); } + const metaInfo = metaParts.join(' | '); if (msg.is_own) { // Own messages: right-aligned, no avatar