From 11dac3e8751e799e8669f9147ce17ceb2f4f2d15 Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 18:00:42 +0100 Subject: [PATCH] hOTfIX --- CHANGELOG.md | 24 +++---------- meshcore_gui/ble/events.py | 69 ++++++++++++++++++++++++-------------- meshcore_gui/ble/worker.py | 16 +++++---- 3 files changed, 58 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6c585..a2c9131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1,13 @@ -## [1.13.4] - 2026-03-12 — Room Server message classification fix - -### Fixed -- 🛠 **Room messages without `signature` were not shown in the Room Server panel** — `CONTACT_MSG_RECV` with `txt_type == 2` is now always treated as room traffic, even when the room server omits the `signature` field. -- 🛠 **Room messages could be stored under the wrong pubkey** — room message classification now prefers `room_pubkey` / receiver-style keys before falling back to `pubkey_prefix`, so incoming room traffic is attached to the room and becomes visible in the room panel/history cache. -- 🛠 **UI state could lag behind the actual room login event** — `LOGIN_SUCCESS` now also updates `room_login_states` and refreshes room history through `SharedData`, so the panel reflects the server-confirmed login immediately. - -### Changed -- 🔄 `meshcore_gui/ble/events.py`: relaxed room-message detection from `txt_type == 2 and signature` to `txt_type == 2`; added safer fallbacks for room pubkey and author resolution. -- 🔄 `meshcore_gui/ble/worker.py`: `LOGIN_SUCCESS` handler now updates room login state and reloads room history. -- 🔄 `meshcore_gui/config.py`: Version kept at `1.13.4`. - -### Impact -- Keeps the original login behaviour without the rejected extra post-login fetch loop from Iteratie A. -- Targets USB/serial and BLE equally because the changes are in the shared event/worker layer above the transport. -- No intended breaking changes outside the Room Server flow. - ---- - # CHANGELOG + + All notable changes to MeshCore GUI are documented in this file. Format follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/). --- +<<<<<<< HEAD ## [1.13.3] - 2026-03-12 — Active Panel Timer Gating ### Changed @@ -82,6 +67,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Ver - No breaking changes outside the three files listed above --- +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b ## [1.13.0] - 2026-03-09 — Leaflet Map Runtime Stabilization ### Added diff --git a/meshcore_gui/ble/events.py b/meshcore_gui/ble/events.py index 7105179..cb11722 100644 --- a/meshcore_gui/ble/events.py +++ b/meshcore_gui/ble/events.py @@ -293,22 +293,15 @@ class EventHandler: """Handle direct message and room message events. Room Server messages arrive as ``CONTACT_MSG_RECV`` with - ``txt_type == 2``. The ``pubkey_prefix`` is the Room Server's - key and the ``signature`` field contains the original author's - pubkey prefix. We resolve the author name from ``signature`` - so the UI shows who actually wrote the message. + ``txt_type == 2``. Some room servers omit the ``signature`` + field, so room detection may not depend on that key being + present. For room traffic the storage key must match the room + pubkey that the Room Server panel later filters on. """ payload = event.payload pubkey = payload.get('pubkey_prefix', '') txt_type = payload.get('txt_type', 0) signature = payload.get('signature', '') - room_pubkey = ( - payload.get('room_pubkey') - or payload.get('receiver') - or payload.get('receiver_pubkey') - or payload.get('receiver_pubkey_prefix') - or pubkey - ) debug_print(f"DM payload keys: {list(payload.keys())}") @@ -327,21 +320,8 @@ class EventHandler: # --- Room Server message (txt_type 2) --- if txt_type == 2: - # Resolve actual author from signature when present. - # Some room servers omit the signature field; in that case - # fall back to the payload sender/display name if available. - author = '' - if signature: - author = self._shared.get_contact_name_by_prefix(signature) - if not author: - author = signature[:8] - if not author: - author = ( - payload.get('sender') - or payload.get('name') - or payload.get('author') - or '?' - ) + room_pubkey = self._resolve_room_pubkey(payload) or pubkey + author = self._resolve_room_author(payload) self._shared.add_message(Message.incoming( author, @@ -381,6 +361,43 @@ class EventHandler: )) debug_print(f"DM received from {sender}: {payload.get('text', '')[:30]}") + def _resolve_room_pubkey(self, payload: Dict) -> str: + """Resolve the room key used for room-message storage. + + Prefer explicit room/receiver-style keys because some room-server + events carry the room identity there instead of in + ``pubkey_prefix``. Falling back to ``pubkey_prefix`` preserves + compatibility with earlier working cases. + """ + for key in ( + 'room_pubkey', + 'receiver', + 'receiver_pubkey', + 'receiver_pubkey_prefix', + 'pubkey_prefix', + ): + value = payload.get(key, '') + if isinstance(value, str) and value: + return value + return '' + + def _resolve_room_author(self, payload: Dict) -> str: + """Resolve the display author for a room message.""" + signature = payload.get('signature', '') + if signature: + author = self._shared.get_contact_name_by_prefix(signature) + if author: + return author + return signature[:8] + + for key in ('sender', 'name', 'author'): + value = payload.get(key, '') + if isinstance(value, str) and value: + return value + + pubkey = payload.get('pubkey_prefix', '') + return pubkey[:8] if pubkey else '?' + # ------------------------------------------------------------------ # Helpers # ------------------------------------------------------------------ diff --git a/meshcore_gui/ble/worker.py b/meshcore_gui/ble/worker.py index 449db10..4f5482a 100644 --- a/meshcore_gui/ble/worker.py +++ b/meshcore_gui/ble/worker.py @@ -260,17 +260,21 @@ class _BaseWorker(abc.ABC): def _on_login_success(self, event) -> None: payload = event.payload or {} pubkey = ( - payload.get("room_pubkey") - or payload.get("pubkey_prefix") - or payload.get("receiver") - or "" + payload.get('room_pubkey') + or payload.get('pubkey_prefix') + or payload.get('receiver') + or payload.get('receiver_pubkey') + or payload.get('receiver_pubkey_prefix') + or '' ) is_admin = payload.get("is_admin", False) debug_print(f"LOGIN_SUCCESS received: pubkey={pubkey}, admin={is_admin}") - self.shared.set_status("✅ Room login OK — messages arriving over RF…") if pubkey: - self.shared.set_room_login_state(pubkey, 'ok', f'admin={is_admin}') + self.shared.set_room_login_state( + pubkey, 'ok', f'admin={is_admin}', + ) self.shared.load_room_history(pubkey) + self.shared.set_status("✅ Room login OK — messages arriving over RF…") # ── apply cache ───────────────────────────────────────────────