From fa7417d33e7a4b5ffd7a391d179aa8da0ed3237b Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 06:02:31 +0100 Subject: [PATCH 01/21] HotFix --- CHANGELOG.md | 3 ++- meshcore_gui/static/leaflet_map_panel.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8d339..1b253b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,8 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Ver ### Changed - πŸ”„ `meshcore_gui/static/leaflet_map_panel.js` β€” Added size guard in `ensureMap`: returns `null` when host has `clientWidth === 0 && clientHeight === 0` and no map - state exists yet. `processPending` retries on the next tick once the panel is visible. + state exists yet. `processPending` now explicitly reschedules itself until the panel + becomes visible, instead of silently returning and leaving the map pending forever. - πŸ”„ `meshcore_gui/gui/dashboard.py` β€” Consolidated two conditional map-update blocks into a single unconditional update while the MAP panel is active. Added `h-96` to the DOMCA CSS height overrides for consistency with the route page map container. diff --git a/meshcore_gui/static/leaflet_map_panel.js b/meshcore_gui/static/leaflet_map_panel.js index 63c5979..ebecd27 100644 --- a/meshcore_gui/static/leaflet_map_panel.js +++ b/meshcore_gui/static/leaflet_map_panel.js @@ -470,6 +470,13 @@ try { const state = PANEL.ensureMap(containerId); if (!state) { + if (retries >= MAX_RETRIES) { + console.error('MeshCoreLeafletBoot timeout waiting for visible map host', { containerId }); + return; + } + window.setTimeout(() => { + scheduleProcess(containerId, retries + 1); + }, RETRY_DELAY_MS); return; } const current = pending.get(containerId); From d2a63c784a1772877060807fd1c474ac3e89d46f Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 06:12:16 +0100 Subject: [PATCH 02/21] HotFix2 --- CHANGELOG.md | 8 ++++++-- meshcore_gui/gui/panels/map_panel.py | 6 +++--- meshcore_gui/static/leaflet_map_panel.js | 26 ++++++------------------ 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b253b4..bc1c472 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,8 +31,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Ver ### Changed - πŸ”„ `meshcore_gui/static/leaflet_map_panel.js` β€” Added size guard in `ensureMap`: returns `null` when host has `clientWidth === 0 && clientHeight === 0` and no map - state exists yet. `processPending` now explicitly reschedules itself until the panel - becomes visible, instead of silently returning and leaving the map pending forever. + state exists yet. `processPending` retries on the next tick once the panel is visible. - πŸ”„ `meshcore_gui/gui/dashboard.py` β€” Consolidated two conditional map-update blocks into a single unconditional update while the MAP panel is active. Added `h-96` to the DOMCA CSS height overrides for consistency with the route page map container. @@ -838,3 +837,8 @@ overwriting all historical data with only the new buffered messages. ### Changed - Map lifecycle is browser-owned: NiceGUI hosts the container, Leaflet owns map state. - Contact markers are updated incrementally in the existing cluster layer. + +## 2026-03-12 map host bootstrap fix +- Fixed dashboard MAP bootstrap for hidden/inactive panels by rendering the Leaflet host as a real NiceGUI `div` element instead of injecting raw HTML inside a hidden container. +- Fixed browser bootstrap retries so a zero-size hidden host is retried instead of being dropped permanently. +- Simplified host waiting logic to polling-based retries, which avoids missing late NiceGUI DOM inserts while the MAP panel is still being mounted. diff --git a/meshcore_gui/gui/panels/map_panel.py b/meshcore_gui/gui/panels/map_panel.py index 33a89f5..2934350 100644 --- a/meshcore_gui/gui/panels/map_panel.py +++ b/meshcore_gui/gui/panels/map_panel.py @@ -45,9 +45,9 @@ class MapPanel: on_change=lambda e: self._set_map_theme_mode(e.value), ).props('dense') ui.button('Center on Device', on_click=self._center_on_device) - ui.html( - f'
' - ).classes('w-full h-72') + ui.element('div').props(f'id={self._container_id}').classes( + 'meshcore-leaflet-host w-full h-72' + ) self._dispatch_to_browser(snapshot={'__command__': 'ensure_map'}) self._apply_theme_only() diff --git a/meshcore_gui/static/leaflet_map_panel.js b/meshcore_gui/static/leaflet_map_panel.js index ebecd27..3a21db1 100644 --- a/meshcore_gui/static/leaflet_map_panel.js +++ b/meshcore_gui/static/leaflet_map_panel.js @@ -504,35 +504,21 @@ return; } - const observer = new MutationObserver(() => { + const timer = window.setTimeout(() => { + watchers.delete(containerId); const host = document.getElementById(containerId); - if (!host) { + if (host) { + scheduleProcess(containerId, retries + 1); return; } - observer.disconnect(); - watchers.delete(containerId); - scheduleProcess(containerId, retries + 1); - }); - - observer.observe(document.body, { - childList: true, - subtree: true, - }); - - watchers.set(containerId, observer); - - window.setTimeout(() => { - if (watchers.get(containerId) !== observer) { - return; - } - observer.disconnect(); - watchers.delete(containerId); if (retries >= MAX_RETRIES) { console.error('MeshCoreLeafletBoot timeout waiting for host element', { containerId }); return; } scheduleProcess(containerId, retries + 1); }, RETRY_DELAY_MS); + + watchers.set(containerId, timer); } function isDomReady() { From 794f08c780fc114c66305ef64a8c34270076750a Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 06:20:40 +0100 Subject: [PATCH 03/21] HotFix3 --- CHANGELOG.md | 4 ++++ meshcore_gui/gui/route_page.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc1c472..2637bad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -842,3 +842,7 @@ overwriting all historical data with only the new buffered messages. - Fixed dashboard MAP bootstrap for hidden/inactive panels by rendering the Leaflet host as a real NiceGUI `div` element instead of injecting raw HTML inside a hidden container. - Fixed browser bootstrap retries so a zero-size hidden host is retried instead of being dropped permanently. - Simplified host waiting logic to polling-based retries, which avoids missing late NiceGUI DOM inserts while the MAP panel is still being mounted. + +## 2026-03-12 route map host mount fix +- Fixed Message and Archive route pages so the Leaflet route map host is rendered as a real NiceGUI DOM element instead of injected raw HTML. +- This aligns the route page bootstrap with the dashboard MAP fix and prevents route maps from staying blank after clicking a message. diff --git a/meshcore_gui/gui/route_page.py b/meshcore_gui/gui/route_page.py index 492346a..6b84c52 100644 --- a/meshcore_gui/gui/route_page.py +++ b/meshcore_gui/gui/route_page.py @@ -250,9 +250,9 @@ class RoutePage: ).classes('text-xs text-gray-400 italic px-2 pt-2') container_id = f'route-map-{uuid4().hex}' - ui.html( - f'
' - ).classes('w-full').style('height: 24rem') + ui.element('div').props(f'id={container_id}').classes( + 'w-full' + ).style('height:24rem;border-radius:0.5rem;overflow:hidden;') boot_script = ( '(function bootRouteMap(retries){' From c30eb5a467aee83bd8b79761c8e51af5ea5abb0c Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 13:15:58 +0100 Subject: [PATCH 04/21] HotFixPerformance --- CHANGELOG.md | 80 ++++----- meshcore_gui/config.py | 4 +- meshcore_gui/gui/dashboard.py | 208 ++++++++++++++++------- meshcore_gui/gui/panels/map_panel.py | 1 - meshcore_gui/static/leaflet_map_panel.js | 12 ++ 5 files changed, 193 insertions(+), 112 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2637bad..a2c9131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,28 @@ 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 +- πŸ”„ `meshcore_gui/gui/dashboard.py` β€” The 500 ms dashboard timer now keeps only lightweight global state updates running continuously (status label, channel filters/options, drawer submenu consistency). Expensive panel refreshes are now gated to the currently active panel only +- πŸ”„ `meshcore_gui/gui/dashboard.py` β€” Added immediate active-panel refresh on panel switch so newly opened panels populate at once instead of waiting for the next timer tick +- πŸ”„ `meshcore_gui/gui/panels/map_panel.py` β€” Removed eager hidden `ensure_map` bootstrap from `render()`; the browser map now starts only when real snapshot work exists or when a live map already exists +- πŸ”„ `meshcore_gui/static/leaflet_map_panel.js` β€” Theme-only calls without snapshot work no longer start hidden host retry processing before a real map exists +- πŸ”„ `meshcore_gui/config.py` β€” Version bumped to `1.13.3` + +### Fixed +- πŸ›  **Hidden panels still refreshed every 500 ms** β€” Device, actions, contacts, messages, rooms and RX log are no longer needlessly updated while another panel is active +- πŸ›  **Map bootstrap activity while panel is not visible** β€” Removed one source of `MeshCoreLeafletBoot timeout waiting for visible map host` caused by eager hidden startup traffic +- πŸ›  **Slow navigation over VPN** β€” Reduced unnecessary dashboard-side UI churn by limiting timer-driven work to the active panel + +### Impact +- Faster panel switching because the selected panel gets one direct refresh immediately +- Lower background UI/update load on dashboard level, especially when the map panel is not active +- Smaller chance of Leaflet hidden-host retries and related console noise outside active map usage +- No intended functional regression for route maps or visible panel behaviour + --- ## [1.13.2] - 2026-03-11 β€” Map Display Bugfix @@ -45,47 +67,36 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Ver - No breaking changes outside the three files listed above --- -## [1.13.1] - 2026-03-09 β€” Message Icon Consistency - -### Fixed -- Route map markers now use the same JS-rendered node icons as the main MAP instead of NiceGUI default blue markers. -- Route detail pages now bootstrap their Leaflet assets explicitly so the shared map icon runtime is available there too -- Route maps are now rendered browser-side through the shared Leaflet JS runtime for icon consistency with MAP, Messages, and Archive. - -### Changed -- πŸ”„ `meshcore_gui/gui/constants.py` β€” Added shared helper functions to resolve node-type icons and labels from the same contact type mapping used by the map and contacts panel -- πŸ”„ `meshcore_gui/core/models.py` β€” `Message.format_line()` now supports an optional sender prefix so message-related views can prepend the same node icon set without changing existing formatting logic -- πŸ”„ `meshcore_gui/gui/panels/messages_panel.py` β€” Message rows now prepend the sender with the same node icon mapping as the map/contact views -- πŸ”„ `meshcore_gui/gui/archive_page.py` β€” Archive rows now use the same sender icon mapping as the live messages panel and map/contact views -- πŸ”„ `meshcore_gui/gui/route_page.py` β€” Route header and route detail table now show node-type icons derived from the shared contact type mapping instead of generic hardcoded role icons - -### Impact -- Message-driven views now use one consistent icon language across map, contacts, messages, archive and route detail -- Existing map runtime and panel behavior remain unchanged -- No breaking changes outside icon rendering - +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b ## [1.13.0] - 2026-03-09 β€” Leaflet Map Runtime Stabilization ### Added -- βœ… `meshcore_gui/static/leaflet_map_panel.js` β€” Dedicated browser-side Leaflet runtime responsible for map lifecycle, marker registry and theme handling independent from NiceGUI redraw cycles -- βœ… `meshcore_gui/static/leaflet_map_panel.css` β€” Styling for browser-side node markers and map container +- βœ… `meshcore_gui/static/leaflet_map_panel.js` β€” Dedicated browser-side Leaflet runtime responsible for map lifecycle, marker registry, clustering and theme handling independent from NiceGUI redraw cycles +- βœ… `meshcore_gui/static/leaflet_map_panel.css` β€” Styling for browser-side node markers, cluster icons and map container - βœ… `meshcore_gui/services/map_snapshot_service.py` β€” Snapshot service that normalizes device/contact map data into a compact payload for the browser runtime - βœ… Browser-side map state management for center, zoom and theme - βœ… Theme persistence across reconnect events via browser storage fallback +- βœ… Browser-side contact clustering via `Leaflet.markercluster` +- βœ… Separate non-clustered device marker layer so the own device remains individually visible ### Changed - πŸ”„ `meshcore_gui/gui/panels/map_panel.py` β€” Replaced NiceGUI Leaflet wrapper usage with a pure browser-managed Leaflet container while preserving the existing card layout, theme toggle and center-on-device control - πŸ”„ Leaflet bootstrap moved out of inline Python into a dedicated browser runtime loaded from `/static` +- πŸ”„ Asset loading order is now explicit: Leaflet first, then `Leaflet.markercluster`, then the MeshCore panel runtime - πŸ”„ Map initialization now occurs only once per container; NiceGUI refresh cycles no longer recreate the map - πŸ”„ Dashboard update loop now sends compact map snapshots instead of triggering redraws - πŸ”„ Snapshot processing in the browser is coalesced so only the newest payload is applied - πŸ”„ Map markers are managed in separate device/contact layers and updated incrementally by stable node id +- πŸ”„ Contact markers are rendered inside a persistent cluster layer while the device marker remains outside clustering - πŸ”„ Theme switching moved to a dedicated theme channel instead of being embedded in snapshot data ### Fixed - πŸ›  **Map disappearing during dashboard refresh cycles** β€” prevented repeated map reinitialization caused by the 500 ms NiceGUI update loop - πŸ›  **Markers disappearing between refreshes** β€” marker updates are now incremental and keyed by node id - πŸ›  **Blank map container on load** β€” browser bootstrap now waits for DOM host, Leaflet runtime and panel runtime before initialization +- πŸ›  **Leaflet clustering bootstrap failure (`L is not defined`)** β€” resolved by enforcing correct script dependency order before the panel runtime starts +- πŸ›  **MarkerClusterGroup failure (`Map has no maxZoom specified`)** β€” the map now defines `maxZoom` during initial creation before the cluster layer is attached +- πŸ›  **Half-initialized map retry cascade (`Map container is already initialized`)** β€” map state is now registered safely during initialization so a failed attempt cannot trigger a second `L.map(...)` on the same container - πŸ›  **Race condition between queued snapshot and theme selection** β€” explicit theme changes can no longer be overwritten by stale snapshot payloads - πŸ›  **Viewport jumping back to default center/zoom** β€” stored viewport is no longer reapplied on each snapshot update - πŸ›  **Theme reverting to default during reconnect** β€” effective map theme is restored before snapshot processing resumes @@ -93,6 +104,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Ver ### Impact - Leaflet map is now managed entirely in the browser and is no longer recreated on each dashboard refresh - Node markers remain stable and no longer flicker or disappear during the 500 ms update cycle +- Dense contact sets can now be rendered with clustering without violating the browser-owned map lifecycle - Theme switching and viewport state persist reliably across reconnect events - No breaking changes outside the map subsystem --- @@ -820,29 +832,3 @@ overwriting all historical data with only the new buffered messages. - explicit theme changes are now handled only via the dedicated theme channel - initial map render now sends an ensure_map command plus an immediate theme sync - added no-op ensure_map handling in the Leaflet runtime to avoid accidental fallback behaviour - -## [1.13.0] - 2026-03-09 - -### Added -- Leaflet marker clustering using Leaflet.markercluster for contact nodes. -- Browser-side cluster rendering with the device marker kept outside the cluster layer. -- Cluster performance tuning with `chunkedLoading: true`. -- Spiderfy support at max zoom for overlapping markers. - -### Fixed -- Wrong asset load order causing `L is not defined` in MarkerClusterGroup. -- Cluster initialization failure caused by missing `maxZoom` on map startup. -- Retry cascade causing `Map container is already initialized`. - -### Changed -- Map lifecycle is browser-owned: NiceGUI hosts the container, Leaflet owns map state. -- Contact markers are updated incrementally in the existing cluster layer. - -## 2026-03-12 map host bootstrap fix -- Fixed dashboard MAP bootstrap for hidden/inactive panels by rendering the Leaflet host as a real NiceGUI `div` element instead of injecting raw HTML inside a hidden container. -- Fixed browser bootstrap retries so a zero-size hidden host is retried instead of being dropped permanently. -- Simplified host waiting logic to polling-based retries, which avoids missing late NiceGUI DOM inserts while the MAP panel is still being mounted. - -## 2026-03-12 route map host mount fix -- Fixed Message and Archive route pages so the Leaflet route map host is rendered as a real NiceGUI DOM element instead of injected raw HTML. -- This aligns the route page bootstrap with the dashboard MAP fix and prevents route maps from staying blank after clicking a message. diff --git a/meshcore_gui/config.py b/meshcore_gui/config.py index 7c1b8fa..941b0ec 100644 --- a/meshcore_gui/config.py +++ b/meshcore_gui/config.py @@ -25,7 +25,7 @@ from typing import Any, Dict, List # ============================================================================== -VERSION: str = "1.13.2" +VERSION: str = "1.13.3" # ============================================================================== @@ -293,7 +293,7 @@ CHANNEL_CACHE_ENABLED: bool = False # Fixed device name applied when the BOT checkbox is enabled. # The original device name is saved and restored when BOT is disabled. -BOT_DEVICE_NAME: str = "NL-OV-ZWL-STDSHGN-WKC Bot" +BOT_DEVICE_NAME: str = "ZwolsBotje" # Default device name used as fallback when restoring from BOT mode # and no original name was saved (e.g. after a restart). diff --git a/meshcore_gui/gui/dashboard.py b/meshcore_gui/gui/dashboard.py index 6f86e63..0c5607d 100644 --- a/meshcore_gui/gui/dashboard.py +++ b/meshcore_gui/gui/dashboard.py @@ -677,34 +677,17 @@ class DashboardPage: container.set_visibility(pid == panel_id) self._active_panel = panel_id - # Apply channel filter to messages panel if panel_id == 'messages' and self._messages: self._messages.set_active_channel(channel) - # Force immediate rebuild so the panel is populated the - # moment it becomes visible, instead of waiting for the - # next 500 ms timer tick (which caused the "empty on first - # click, populated on second click" symptom). - data = self._shared.get_snapshot() - self._messages.update( - data, - self._messages.channel_filters, - self._messages.last_channels, - room_pubkeys=( - self._room_server.get_room_pubkeys() - if self._room_server else None - ), - ) - # Apply channel filter to archive panel if panel_id == 'archive' and self._archive_page: self._archive_page.set_channel_filter(channel) - # Force map recenter when opening map panel (Leaflet may be hidden on load) - if panel_id == 'map' and self._map: - data = self._shared.get_snapshot() - data['force_center'] = True - self._map.update(data) +<<<<<<< HEAD +======= + self._refresh_active_panel_now(force_map_center=(panel_id == 'map')) +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b # Update active menu highlight (standalone buttons only) for pid, btn in self._menu_buttons.items(): if pid == panel_id: @@ -712,10 +695,89 @@ class DashboardPage: else: btn.classes(remove='domca-menu-active') + # Refresh only the selected panel immediately so the user does not + # need to wait for the next 500 ms dashboard tick. + self._refresh_active_panel_now() + # Close drawer after selection if self._drawer: self._drawer.hide() +<<<<<<< HEAD + def _refresh_active_panel_now(self) -> None: + """Refresh exactly the active panel once, outside the timer tick.""" + data = self._shared.get_snapshot() + + if self._active_panel == 'device' and self._device: + self._device.update(data) + elif self._active_panel == 'map' and self._map: + data = dict(data) + data['force_center'] = True + self._map.update(data) + elif self._active_panel == 'actions' and self._actions: + self._actions.update(data) + elif self._active_panel == 'contacts' and self._contacts: + self._contacts.update(data) + elif self._active_panel == 'messages' and self._messages: + if data.get('channels'): + self._messages.update_filters(data) + self._messages.update_channel_options(data['channels']) + self._update_submenus(data) +======= + def _refresh_active_panel_now(self, force_map_center: bool = False) -> None: + """Refresh only the currently visible panel. + + This is used directly after a panel switch so the user does not + need to wait for the next 500 ms dashboard tick. + """ + data = self._shared.get_snapshot() + + if data.get('channels'): + self._messages.update_filters(data) + self._messages.update_channel_options(data['channels']) + self._update_submenus(data) + + if self._active_panel == 'device': + self._device.update(data) + elif self._active_panel == 'map': + if force_map_center: + data['force_center'] = True + self._map.update(data) + elif self._active_panel == 'actions': + self._actions.update(data) + elif self._active_panel == 'contacts': + self._contacts.update(data) + elif self._active_panel == 'messages': +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b + self._messages.update( + data, + self._messages.channel_filters, + self._messages.last_channels, +<<<<<<< HEAD + room_pubkeys=self._room_server.get_room_pubkeys() if self._room_server else None, + ) + elif self._active_panel == 'rooms' and self._room_server: + if data.get('channels'): + self._messages.update_filters(data) + self._messages.update_channel_options(data['channels']) + self._update_submenus(data) + self._room_server.update(data) + elif self._active_panel == 'rxlog' and self._rxlog: + self._rxlog.update(data) + elif self._active_panel == 'archive' and self._archive_page: + self._archive_page.refresh() +======= + room_pubkeys=( + self._room_server.get_room_pubkeys() + if self._room_server else None + ), + ) + elif self._active_panel == 'rooms': + self._room_server.update(data) + elif self._active_panel == 'rxlog': + self._rxlog.update(data) +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b + # ------------------------------------------------------------------ # Room Server callback (from ContactsPanel) # ------------------------------------------------------------------ @@ -753,56 +815,78 @@ class DashboardPage: # Always update status self._status_label.text = data['status'] - # Device info - if data['device_updated'] or is_first: - self._device.update(data) - - # Map: always send a snapshot while the panel is active. - # The JS runtime coalesces pending payloads β€” only the newest - # is ever applied β€” so calling update() on every tick is cheap. - # This ensures the Leaflet runtime always gets at least one - # valid snapshot after it finishes loading, regardless of - # whether device_updated or is_first happened to be True - # on the tick that fired before MeshCoreLeafletBoot was defined. - if self._active_panel == 'map': - self._map.update(data) - - # Channel-dependent UI: always ensure consistency when - # channels exist. Because a single DashboardPage instance - # is shared across browser sessions (render() is called on - # each new connection), the old session's timer can steal - # the is_first flag before the new timer fires. Running - # these unconditionally is safe because each method has an - # internal fingerprint/equality check that prevents - # unnecessary DOM updates. +<<<<<<< HEAD + # Channel-dependent navigation/filter state remains global, but + # expensive panel refreshes must only run for the active panel. +======= + # Channel-dependent drawer/submenu state may stay global. + # The helpers below already contain equality checks, so this + # remains cheap while keeping navigation consistent. +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b if data['channels']: self._messages.update_filters(data) self._messages.update_channel_options(data['channels']) self._update_submenus(data) - # BOT checkbox state (only on actual change or first render - # to avoid overwriting user interaction mid-toggle) - if data['channels_updated'] or is_first: - self._actions.update(data) + if self._active_panel == 'device': + if data['device_updated'] or is_first: + self._device.update(data) +<<<<<<< HEAD + elif self._active_panel == 'map': + self._map.update(data) + elif self._active_panel == 'actions': + if data['channels_updated'] or is_first: + self._actions.update(data) + elif self._active_panel == 'contacts': + if data['contacts_updated'] or is_first: + self._contacts.update(data) +======= - # Contacts - if data['contacts_updated'] or is_first: - self._contacts.update(data) + elif self._active_panel == 'map': + # Keep sending snapshots while the map panel is active. + # The browser runtime coalesces pending payloads, so only + # the newest snapshot is applied. + self._map.update(data) - # Messages (always β€” for live filter changes) - self._messages.update( - data, - self._messages.channel_filters, - self._messages.last_channels, - room_pubkeys=self._room_server.get_room_pubkeys() if self._room_server else None, - ) + elif self._active_panel == 'actions': + if data['channels_updated'] or is_first: + self._actions.update(data) - # Room Server panels (always β€” for live messages + contact changes) - self._room_server.update(data) + elif self._active_panel == 'contacts': + if data['contacts_updated'] or is_first: + self._contacts.update(data) - # RX Log - if data['rxlog_updated']: - self._rxlog.update(data) +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b + elif self._active_panel == 'messages': + self._messages.update( + data, + self._messages.channel_filters, + self._messages.last_channels, +<<<<<<< HEAD + room_pubkeys=self._room_server.get_room_pubkeys() if self._room_server else None, + ) + elif self._active_panel == 'rooms': + self._room_server.update(data) + elif self._active_panel == 'rxlog': + if data['rxlog_updated'] or is_first: + self._rxlog.update(data) + elif self._active_panel == 'archive' and self._archive_page: + if data.get('messages_updated') or data.get('channels_updated') or is_first: + self._archive_page.refresh() +======= + room_pubkeys=( + self._room_server.get_room_pubkeys() + if self._room_server else None + ), + ) + + elif self._active_panel == 'rooms': + self._room_server.update(data) + + elif self._active_panel == 'rxlog': + if data['rxlog_updated'] or is_first: + self._rxlog.update(data) +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b # Signal worker that GUI is ready for data if is_first and data['channels'] and data['contacts']: diff --git a/meshcore_gui/gui/panels/map_panel.py b/meshcore_gui/gui/panels/map_panel.py index 2934350..f5a8e7b 100644 --- a/meshcore_gui/gui/panels/map_panel.py +++ b/meshcore_gui/gui/panels/map_panel.py @@ -48,7 +48,6 @@ class MapPanel: ui.element('div').props(f'id={self._container_id}').classes( 'meshcore-leaflet-host w-full h-72' ) - self._dispatch_to_browser(snapshot={'__command__': 'ensure_map'}) self._apply_theme_only() def set_ui_dark_mode(self, value: bool | None) -> None: diff --git a/meshcore_gui/static/leaflet_map_panel.js b/meshcore_gui/static/leaflet_map_panel.js index 3a21db1..03e79c7 100644 --- a/meshcore_gui/static/leaflet_map_panel.js +++ b/meshcore_gui/static/leaflet_map_panel.js @@ -634,6 +634,18 @@ } } +<<<<<<< HEAD + const hasSnapshotWork = Boolean(current.snapshot); + const hasLiveMap = maps.has(containerId); + + if (!hasSnapshotWork && !hasLiveMap) { +======= + if (!current.snapshot && current.theme && !maps.has(containerId)) { + pending.set(containerId, current); +>>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b + return; + } + pending.set(containerId, current); scheduleProcess(containerId, 0); }; From ec1c36373e092de9a31eedd26ab44ef36cfc491f Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 13:37:24 +0100 Subject: [PATCH 05/21] Update dashboard.py --- meshcore_gui/gui/dashboard.py | 200 +++++++++++++++------------------- 1 file changed, 89 insertions(+), 111 deletions(-) diff --git a/meshcore_gui/gui/dashboard.py b/meshcore_gui/gui/dashboard.py index 0c5607d..03cf2c7 100644 --- a/meshcore_gui/gui/dashboard.py +++ b/meshcore_gui/gui/dashboard.py @@ -34,6 +34,7 @@ class _DeletedClientFilter(logging.Filter): def filter(self, record: logging.LogRecord) -> bool: return 'Client has been deleted' not in record.getMessage() + logging.getLogger('nicegui').addFilter(_DeletedClientFilter()) @@ -229,9 +230,10 @@ body, .q-layout, .q-page { ''' + # ── Landing SVG loader ──────────────────────────────────────────────── # Reads the SVG from config.LANDING_SVG_PATH and replaces {callsign} -# with config.OPERATOR_CALLSIGN. Falls back to a minimal placeholder +# with config.OPERATOR_CALLSIGN. Falls back to a minimal placeholder # when the file is missing. @@ -259,15 +261,16 @@ def _load_landing_svg() -> str: # ── Standalone menu items (no submenus) ────────────────────────────── _STANDALONE_ITEMS = [ - ('\U0001f465', 'CONTACTS', 'contacts'), - ('\U0001f5fa\ufe0f', 'MAP', 'map'), - ('\U0001f4e1', 'DEVICE', 'device'), - ('\u26a1', 'ACTIONS', 'actions'), - ('\U0001f4ca', 'RX LOG', 'rxlog'), + ('πŸ‘₯', 'CONTACTS', 'contacts'), + ('πŸ—ΊοΈ', 'MAP', 'map'), + ('πŸ“‘', 'DEVICE', 'device'), + ('⚑', 'ACTIONS', 'actions'), + ('πŸ“Š', 'RX LOG', 'rxlog'), ] _EXT_LINKS = config.EXT_LINKS + # ── Shared button styles ───────────────────────────────────────────── _SUB_BTN_STYLE = ( @@ -290,7 +293,12 @@ class DashboardPage: shared: SharedDataReader for data access and command dispatch. """ - def __init__(self, shared: SharedDataReader, pin_store: PinStore, room_password_store: RoomPasswordStore) -> None: + def __init__( + self, + shared: SharedDataReader, + pin_store: PinStore, + room_password_store: RoomPasswordStore, + ) -> None: self._shared = shared self._pin_store = pin_store self._room_password_store = room_password_store @@ -343,7 +351,12 @@ class DashboardPage: # Create panel instances (UNCHANGED functional wiring) put_cmd = self._shared.put_command self._device = DevicePanel() - self._contacts = ContactsPanel(put_cmd, self._pin_store, self._shared.set_auto_add_enabled, self._on_add_room_server) + self._contacts = ContactsPanel( + put_cmd, + self._pin_store, + self._shared.set_auto_add_enabled, + self._on_add_room_server, + ) self._map = MapPanel() self._messages = MessagesPanel(put_cmd) self._actions = ActionsPanel(put_cmd, self._shared.set_bot_enabled) @@ -379,46 +392,57 @@ class DashboardPage: # ── πŸ’¬ MESSAGES (expandable with channel submenu) ────── with ui.expansion( - '\U0001f4ac MESSAGES', icon=None, value=False, + 'πŸ’¬ MESSAGES', + icon=None, + value=False, ).props('dense header-class="q-pa-none"').classes('w-full'): self._msg_sub_container = ui.column().classes('w-full gap-0') with self._msg_sub_container: self._make_sub_btn( - 'ALL', lambda: self._navigate_panel('messages', channel=None) + 'ALL', + lambda: self._navigate_panel('messages', channel=None), ) self._make_sub_btn( - 'DM', lambda: self._navigate_panel('messages', channel='DM') + 'DM', + lambda: self._navigate_panel('messages', channel='DM'), ) # Dynamic channel items populated by _update_submenus # ── 🏠 ROOMS (expandable with room submenu) ─────────── with ui.expansion( - '\U0001f3e0 ROOMS', icon=None, value=False, + '🏠 ROOMS', + icon=None, + value=False, ).props('dense header-class="q-pa-none"').classes('w-full'): self._rooms_sub_container = ui.column().classes('w-full gap-0') with self._rooms_sub_container: self._make_sub_btn( - 'ALL', lambda: self._navigate_panel('rooms') + 'ALL', + lambda: self._navigate_panel('rooms'), ) # Pre-populate from persisted rooms for entry in self._room_password_store.get_rooms(): short = entry.name or entry.pubkey[:12] self._make_sub_btn( - f'\U0001f3e0 {short}', + f'🏠 {short}', lambda: self._navigate_panel('rooms'), ) # ── πŸ“š ARCHIVE (expandable with channel submenu) ────── with ui.expansion( - '\U0001f4da ARCHIVE', icon=None, value=False, + 'πŸ“š ARCHIVE', + icon=None, + value=False, ).props('dense header-class="q-pa-none"').classes('w-full'): self._archive_sub_container = ui.column().classes('w-full gap-0') with self._archive_sub_container: self._make_sub_btn( - 'ALL', lambda: self._navigate_panel('archive', channel=None) + 'ALL', + lambda: self._navigate_panel('archive', channel=None), ) self._make_sub_btn( - 'DM', lambda: self._navigate_panel('archive', channel='DM') + 'DM', + lambda: self._navigate_panel('archive', channel='DM'), ) # Dynamic channel items populated by _update_submenus @@ -450,7 +474,9 @@ class DashboardPage: # Footer in drawer ui.space() - ui.label(f'\u00a9 2026 {config.OPERATOR_CALLSIGN}').classes('domca-footer').style('padding: 0 1.2rem 1rem') + ui.label(f'Β© 2026 {config.OPERATOR_CALLSIGN}').classes( + 'domca-footer' + ).style('padding: 0 1.2rem 1rem') # ── Header ──────────────────────────────────────────────── with ui.header().classes('items-center px-4 py-2 shadow-md'): @@ -464,7 +490,7 @@ class DashboardPage: lambda e: menu_btn.props(f'icon={"close" if e.value else "menu"}') ) - ui.label(f'\U0001f517 MeshCore v{config.VERSION}').classes( + ui.label(f'πŸ”— MeshCore v{config.VERSION}').classes( 'text-lg font-bold ml-2 domca-header-text' ).style("font-family: 'JetBrains Mono', monospace") @@ -504,11 +530,11 @@ class DashboardPage: panel_defs = [ ('messages', self._messages), ('contacts', self._contacts), - ('map', self._map), - ('device', self._device), - ('actions', self._actions), - ('rxlog', self._rxlog), - ('rooms', self._room_server), + ('map', self._map), + ('device', self._device), + ('actions', self._actions), + ('rxlog', self._rxlog), + ('rooms', self._room_server), ] for panel_id, panel_obj in panel_defs: @@ -568,10 +594,12 @@ class DashboardPage: self._msg_sub_container.clear() with self._msg_sub_container: self._make_sub_btn( - 'ALL', lambda: self._navigate_panel('messages', channel=None) + 'ALL', + lambda: self._navigate_panel('messages', channel=None), ) self._make_sub_btn( - 'DM', lambda: self._navigate_panel('messages', channel='DM') + 'DM', + lambda: self._navigate_panel('messages', channel='DM'), ) for ch in channels: idx = ch['idx'] @@ -586,10 +614,12 @@ class DashboardPage: self._archive_sub_container.clear() with self._archive_sub_container: self._make_sub_btn( - 'ALL', lambda: self._navigate_panel('archive', channel=None) + 'ALL', + lambda: self._navigate_panel('archive', channel=None), ) self._make_sub_btn( - 'DM', lambda: self._navigate_panel('archive', channel='DM') + 'DM', + lambda: self._navigate_panel('archive', channel='DM'), ) for ch in channels: idx = ch['idx'] @@ -610,12 +640,13 @@ class DashboardPage: self._rooms_sub_container.clear() with self._rooms_sub_container: self._make_sub_btn( - 'ALL', lambda: self._navigate_panel('rooms') + 'ALL', + lambda: self._navigate_panel('rooms'), ) for entry in rooms: short = entry.name or entry.pubkey[:12] self._make_sub_btn( - f'\U0001f3e0 {short}', + f'🏠 {short}', lambda: self._navigate_panel('rooms'), ) @@ -683,11 +714,6 @@ class DashboardPage: if panel_id == 'archive' and self._archive_page: self._archive_page.set_channel_filter(channel) -<<<<<<< HEAD -======= - self._refresh_active_panel_now(force_map_center=(panel_id == 'map')) - ->>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b # Update active menu highlight (standalone buttons only) for pid, btn in self._menu_buttons.items(): if pid == panel_id: @@ -697,33 +723,12 @@ class DashboardPage: # Refresh only the selected panel immediately so the user does not # need to wait for the next 500 ms dashboard tick. - self._refresh_active_panel_now() + self._refresh_active_panel_now(force_map_center=(panel_id == 'map')) # Close drawer after selection if self._drawer: self._drawer.hide() -<<<<<<< HEAD - def _refresh_active_panel_now(self) -> None: - """Refresh exactly the active panel once, outside the timer tick.""" - data = self._shared.get_snapshot() - - if self._active_panel == 'device' and self._device: - self._device.update(data) - elif self._active_panel == 'map' and self._map: - data = dict(data) - data['force_center'] = True - self._map.update(data) - elif self._active_panel == 'actions' and self._actions: - self._actions.update(data) - elif self._active_panel == 'contacts' and self._contacts: - self._contacts.update(data) - elif self._active_panel == 'messages' and self._messages: - if data.get('channels'): - self._messages.update_filters(data) - self._messages.update_channel_options(data['channels']) - self._update_submenus(data) -======= def _refresh_active_panel_now(self, force_map_center: bool = False) -> None: """Refresh only the currently visible panel. @@ -732,51 +737,45 @@ class DashboardPage: """ data = self._shared.get_snapshot() - if data.get('channels'): + if data.get('channels') and self._messages: self._messages.update_filters(data) self._messages.update_channel_options(data['channels']) self._update_submenus(data) - if self._active_panel == 'device': + if self._active_panel == 'device' and self._device: self._device.update(data) - elif self._active_panel == 'map': + + elif self._active_panel == 'map' and self._map: + data = dict(data) if force_map_center: data['force_center'] = True self._map.update(data) - elif self._active_panel == 'actions': + + elif self._active_panel == 'actions' and self._actions: self._actions.update(data) - elif self._active_panel == 'contacts': + + elif self._active_panel == 'contacts' and self._contacts: self._contacts.update(data) - elif self._active_panel == 'messages': ->>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b + + elif self._active_panel == 'messages' and self._messages: self._messages.update( data, self._messages.channel_filters, self._messages.last_channels, -<<<<<<< HEAD - room_pubkeys=self._room_server.get_room_pubkeys() if self._room_server else None, - ) - elif self._active_panel == 'rooms' and self._room_server: - if data.get('channels'): - self._messages.update_filters(data) - self._messages.update_channel_options(data['channels']) - self._update_submenus(data) - self._room_server.update(data) - elif self._active_panel == 'rxlog' and self._rxlog: - self._rxlog.update(data) - elif self._active_panel == 'archive' and self._archive_page: - self._archive_page.refresh() -======= room_pubkeys=( self._room_server.get_room_pubkeys() if self._room_server else None ), ) - elif self._active_panel == 'rooms': + + elif self._active_panel == 'rooms' and self._room_server: self._room_server.update(data) - elif self._active_panel == 'rxlog': + + elif self._active_panel == 'rxlog' and self._rxlog: self._rxlog.update(data) ->>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b + + elif self._active_panel == 'archive' and self._archive_page: + self._archive_page.refresh() # ------------------------------------------------------------------ # Room Server callback (from ContactsPanel) @@ -815,15 +814,10 @@ class DashboardPage: # Always update status self._status_label.text = data['status'] -<<<<<<< HEAD - # Channel-dependent navigation/filter state remains global, but - # expensive panel refreshes must only run for the active panel. -======= # Channel-dependent drawer/submenu state may stay global. # The helpers below already contain equality checks, so this # remains cheap while keeping navigation consistent. ->>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b - if data['channels']: + if data['channels'] and self._messages: self._messages.update_filters(data) self._messages.update_channel_options(data['channels']) self._update_submenus(data) @@ -831,16 +825,6 @@ class DashboardPage: if self._active_panel == 'device': if data['device_updated'] or is_first: self._device.update(data) -<<<<<<< HEAD - elif self._active_panel == 'map': - self._map.update(data) - elif self._active_panel == 'actions': - if data['channels_updated'] or is_first: - self._actions.update(data) - elif self._active_panel == 'contacts': - if data['contacts_updated'] or is_first: - self._contacts.update(data) -======= elif self._active_panel == 'map': # Keep sending snapshots while the map panel is active. @@ -856,24 +840,11 @@ class DashboardPage: if data['contacts_updated'] or is_first: self._contacts.update(data) ->>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b elif self._active_panel == 'messages': self._messages.update( data, self._messages.channel_filters, self._messages.last_channels, -<<<<<<< HEAD - room_pubkeys=self._room_server.get_room_pubkeys() if self._room_server else None, - ) - elif self._active_panel == 'rooms': - self._room_server.update(data) - elif self._active_panel == 'rxlog': - if data['rxlog_updated'] or is_first: - self._rxlog.update(data) - elif self._active_panel == 'archive' and self._archive_page: - if data.get('messages_updated') or data.get('channels_updated') or is_first: - self._archive_page.refresh() -======= room_pubkeys=( self._room_server.get_room_pubkeys() if self._room_server else None @@ -886,7 +857,14 @@ class DashboardPage: elif self._active_panel == 'rxlog': if data['rxlog_updated'] or is_first: self._rxlog.update(data) ->>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b + + elif self._active_panel == 'archive' and self._archive_page: + if ( + data.get('messages_updated') + or data.get('channels_updated') + or is_first + ): + self._archive_page.refresh() # Signal worker that GUI is ready for data if is_first and data['channels'] and data['contacts']: From 637551cdadb5e608d1151e8fe4de4b57a2facdf7 Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 13:49:47 +0100 Subject: [PATCH 06/21] HotFix1 --- meshcore_gui/gui/dashboard.py | 135 ++++++++--------------- meshcore_gui/static/leaflet_map_panel.js | 7 -- 2 files changed, 43 insertions(+), 99 deletions(-) diff --git a/meshcore_gui/gui/dashboard.py b/meshcore_gui/gui/dashboard.py index 03cf2c7..d7cef43 100644 --- a/meshcore_gui/gui/dashboard.py +++ b/meshcore_gui/gui/dashboard.py @@ -34,7 +34,6 @@ class _DeletedClientFilter(logging.Filter): def filter(self, record: logging.LogRecord) -> bool: return 'Client has been deleted' not in record.getMessage() - logging.getLogger('nicegui').addFilter(_DeletedClientFilter()) @@ -230,10 +229,9 @@ body, .q-layout, .q-page { ''' - # ── Landing SVG loader ──────────────────────────────────────────────── # Reads the SVG from config.LANDING_SVG_PATH and replaces {callsign} -# with config.OPERATOR_CALLSIGN. Falls back to a minimal placeholder +# with config.OPERATOR_CALLSIGN. Falls back to a minimal placeholder # when the file is missing. @@ -261,16 +259,15 @@ def _load_landing_svg() -> str: # ── Standalone menu items (no submenus) ────────────────────────────── _STANDALONE_ITEMS = [ - ('πŸ‘₯', 'CONTACTS', 'contacts'), - ('πŸ—ΊοΈ', 'MAP', 'map'), - ('πŸ“‘', 'DEVICE', 'device'), - ('⚑', 'ACTIONS', 'actions'), - ('πŸ“Š', 'RX LOG', 'rxlog'), + ('\U0001f465', 'CONTACTS', 'contacts'), + ('\U0001f5fa\ufe0f', 'MAP', 'map'), + ('\U0001f4e1', 'DEVICE', 'device'), + ('\u26a1', 'ACTIONS', 'actions'), + ('\U0001f4ca', 'RX LOG', 'rxlog'), ] _EXT_LINKS = config.EXT_LINKS - # ── Shared button styles ───────────────────────────────────────────── _SUB_BTN_STYLE = ( @@ -293,12 +290,7 @@ class DashboardPage: shared: SharedDataReader for data access and command dispatch. """ - def __init__( - self, - shared: SharedDataReader, - pin_store: PinStore, - room_password_store: RoomPasswordStore, - ) -> None: + def __init__(self, shared: SharedDataReader, pin_store: PinStore, room_password_store: RoomPasswordStore) -> None: self._shared = shared self._pin_store = pin_store self._room_password_store = room_password_store @@ -351,12 +343,7 @@ class DashboardPage: # Create panel instances (UNCHANGED functional wiring) put_cmd = self._shared.put_command self._device = DevicePanel() - self._contacts = ContactsPanel( - put_cmd, - self._pin_store, - self._shared.set_auto_add_enabled, - self._on_add_room_server, - ) + self._contacts = ContactsPanel(put_cmd, self._pin_store, self._shared.set_auto_add_enabled, self._on_add_room_server) self._map = MapPanel() self._messages = MessagesPanel(put_cmd) self._actions = ActionsPanel(put_cmd, self._shared.set_bot_enabled) @@ -392,57 +379,46 @@ class DashboardPage: # ── πŸ’¬ MESSAGES (expandable with channel submenu) ────── with ui.expansion( - 'πŸ’¬ MESSAGES', - icon=None, - value=False, + '\U0001f4ac MESSAGES', icon=None, value=False, ).props('dense header-class="q-pa-none"').classes('w-full'): self._msg_sub_container = ui.column().classes('w-full gap-0') with self._msg_sub_container: self._make_sub_btn( - 'ALL', - lambda: self._navigate_panel('messages', channel=None), + 'ALL', lambda: self._navigate_panel('messages', channel=None) ) self._make_sub_btn( - 'DM', - lambda: self._navigate_panel('messages', channel='DM'), + 'DM', lambda: self._navigate_panel('messages', channel='DM') ) # Dynamic channel items populated by _update_submenus # ── 🏠 ROOMS (expandable with room submenu) ─────────── with ui.expansion( - '🏠 ROOMS', - icon=None, - value=False, + '\U0001f3e0 ROOMS', icon=None, value=False, ).props('dense header-class="q-pa-none"').classes('w-full'): self._rooms_sub_container = ui.column().classes('w-full gap-0') with self._rooms_sub_container: self._make_sub_btn( - 'ALL', - lambda: self._navigate_panel('rooms'), + 'ALL', lambda: self._navigate_panel('rooms') ) # Pre-populate from persisted rooms for entry in self._room_password_store.get_rooms(): short = entry.name or entry.pubkey[:12] self._make_sub_btn( - f'🏠 {short}', + f'\U0001f3e0 {short}', lambda: self._navigate_panel('rooms'), ) # ── πŸ“š ARCHIVE (expandable with channel submenu) ────── with ui.expansion( - 'πŸ“š ARCHIVE', - icon=None, - value=False, + '\U0001f4da ARCHIVE', icon=None, value=False, ).props('dense header-class="q-pa-none"').classes('w-full'): self._archive_sub_container = ui.column().classes('w-full gap-0') with self._archive_sub_container: self._make_sub_btn( - 'ALL', - lambda: self._navigate_panel('archive', channel=None), + 'ALL', lambda: self._navigate_panel('archive', channel=None) ) self._make_sub_btn( - 'DM', - lambda: self._navigate_panel('archive', channel='DM'), + 'DM', lambda: self._navigate_panel('archive', channel='DM') ) # Dynamic channel items populated by _update_submenus @@ -474,9 +450,7 @@ class DashboardPage: # Footer in drawer ui.space() - ui.label(f'Β© 2026 {config.OPERATOR_CALLSIGN}').classes( - 'domca-footer' - ).style('padding: 0 1.2rem 1rem') + ui.label(f'\u00a9 2026 {config.OPERATOR_CALLSIGN}').classes('domca-footer').style('padding: 0 1.2rem 1rem') # ── Header ──────────────────────────────────────────────── with ui.header().classes('items-center px-4 py-2 shadow-md'): @@ -490,7 +464,7 @@ class DashboardPage: lambda e: menu_btn.props(f'icon={"close" if e.value else "menu"}') ) - ui.label(f'πŸ”— MeshCore v{config.VERSION}').classes( + ui.label(f'\U0001f517 MeshCore v{config.VERSION}').classes( 'text-lg font-bold ml-2 domca-header-text' ).style("font-family: 'JetBrains Mono', monospace") @@ -530,11 +504,11 @@ class DashboardPage: panel_defs = [ ('messages', self._messages), ('contacts', self._contacts), - ('map', self._map), - ('device', self._device), - ('actions', self._actions), - ('rxlog', self._rxlog), - ('rooms', self._room_server), + ('map', self._map), + ('device', self._device), + ('actions', self._actions), + ('rxlog', self._rxlog), + ('rooms', self._room_server), ] for panel_id, panel_obj in panel_defs: @@ -594,12 +568,10 @@ class DashboardPage: self._msg_sub_container.clear() with self._msg_sub_container: self._make_sub_btn( - 'ALL', - lambda: self._navigate_panel('messages', channel=None), + 'ALL', lambda: self._navigate_panel('messages', channel=None) ) self._make_sub_btn( - 'DM', - lambda: self._navigate_panel('messages', channel='DM'), + 'DM', lambda: self._navigate_panel('messages', channel='DM') ) for ch in channels: idx = ch['idx'] @@ -614,12 +586,10 @@ class DashboardPage: self._archive_sub_container.clear() with self._archive_sub_container: self._make_sub_btn( - 'ALL', - lambda: self._navigate_panel('archive', channel=None), + 'ALL', lambda: self._navigate_panel('archive', channel=None) ) self._make_sub_btn( - 'DM', - lambda: self._navigate_panel('archive', channel='DM'), + 'DM', lambda: self._navigate_panel('archive', channel='DM') ) for ch in channels: idx = ch['idx'] @@ -640,13 +610,12 @@ class DashboardPage: self._rooms_sub_container.clear() with self._rooms_sub_container: self._make_sub_btn( - 'ALL', - lambda: self._navigate_panel('rooms'), + 'ALL', lambda: self._navigate_panel('rooms') ) for entry in rooms: short = entry.name or entry.pubkey[:12] self._make_sub_btn( - f'🏠 {short}', + f'\U0001f3e0 {short}', lambda: self._navigate_panel('rooms'), ) @@ -708,12 +677,16 @@ class DashboardPage: container.set_visibility(pid == panel_id) self._active_panel = panel_id + # Apply channel filter to messages panel if panel_id == 'messages' and self._messages: self._messages.set_active_channel(channel) + # Apply channel filter to archive panel if panel_id == 'archive' and self._archive_page: self._archive_page.set_channel_filter(channel) + self._refresh_active_panel_now(force_map_center=(panel_id == 'map')) + # Update active menu highlight (standalone buttons only) for pid, btn in self._menu_buttons.items(): if pid == panel_id: @@ -721,10 +694,6 @@ class DashboardPage: else: btn.classes(remove='domca-menu-active') - # Refresh only the selected panel immediately so the user does not - # need to wait for the next 500 ms dashboard tick. - self._refresh_active_panel_now(force_map_center=(panel_id == 'map')) - # Close drawer after selection if self._drawer: self._drawer.hide() @@ -737,27 +706,22 @@ class DashboardPage: """ data = self._shared.get_snapshot() - if data.get('channels') and self._messages: + if data.get('channels'): self._messages.update_filters(data) self._messages.update_channel_options(data['channels']) self._update_submenus(data) - if self._active_panel == 'device' and self._device: + if self._active_panel == 'device': self._device.update(data) - - elif self._active_panel == 'map' and self._map: - data = dict(data) + elif self._active_panel == 'map': if force_map_center: data['force_center'] = True self._map.update(data) - - elif self._active_panel == 'actions' and self._actions: + elif self._active_panel == 'actions': self._actions.update(data) - - elif self._active_panel == 'contacts' and self._contacts: + elif self._active_panel == 'contacts': self._contacts.update(data) - - elif self._active_panel == 'messages' and self._messages: + elif self._active_panel == 'messages': self._messages.update( data, self._messages.channel_filters, @@ -767,16 +731,11 @@ class DashboardPage: if self._room_server else None ), ) - - elif self._active_panel == 'rooms' and self._room_server: + elif self._active_panel == 'rooms': self._room_server.update(data) - - elif self._active_panel == 'rxlog' and self._rxlog: + elif self._active_panel == 'rxlog': self._rxlog.update(data) - elif self._active_panel == 'archive' and self._archive_page: - self._archive_page.refresh() - # ------------------------------------------------------------------ # Room Server callback (from ContactsPanel) # ------------------------------------------------------------------ @@ -817,7 +776,7 @@ class DashboardPage: # Channel-dependent drawer/submenu state may stay global. # The helpers below already contain equality checks, so this # remains cheap while keeping navigation consistent. - if data['channels'] and self._messages: + if data['channels']: self._messages.update_filters(data) self._messages.update_channel_options(data['channels']) self._update_submenus(data) @@ -858,14 +817,6 @@ class DashboardPage: if data['rxlog_updated'] or is_first: self._rxlog.update(data) - elif self._active_panel == 'archive' and self._archive_page: - if ( - data.get('messages_updated') - or data.get('channels_updated') - or is_first - ): - self._archive_page.refresh() - # Signal worker that GUI is ready for data if is_first and data['channels'] and data['contacts']: self._shared.mark_gui_initialized() diff --git a/meshcore_gui/static/leaflet_map_panel.js b/meshcore_gui/static/leaflet_map_panel.js index 03e79c7..dad1cee 100644 --- a/meshcore_gui/static/leaflet_map_panel.js +++ b/meshcore_gui/static/leaflet_map_panel.js @@ -634,15 +634,8 @@ } } -<<<<<<< HEAD - const hasSnapshotWork = Boolean(current.snapshot); - const hasLiveMap = maps.has(containerId); - - if (!hasSnapshotWork && !hasLiveMap) { -======= if (!current.snapshot && current.theme && !maps.has(containerId)) { pending.set(containerId, current); ->>>>>>> b76eacf1119026c49c25d2811a6d713da8f8e01b return; } From 72167ba130a5077ddcec9fc38e7e288b71ea1645 Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 14:26:38 +0100 Subject: [PATCH 07/21] HotFix3 --- docs/CHANGELOG.md | 773 ----------------------- meshcore_gui/gui/panels/map_panel.py | 4 +- meshcore_gui/gui/route_page.py | 5 +- meshcore_gui/static/leaflet_map_panel.js | 63 +- 4 files changed, 47 insertions(+), 798 deletions(-) delete mode 100644 docs/CHANGELOG.md diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md deleted file mode 100644 index 8b154a3..0000000 --- a/docs/CHANGELOG.md +++ /dev/null @@ -1,773 +0,0 @@ -# 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/). - ---- -## [1.13.0] - 2026-03-09 β€” Leaflet Map Runtime Stabilization - -### Added -- βœ… `meshcore_gui/static/leaflet_map_panel.js` β€” Dedicated browser-side Leaflet runtime responsible for map lifecycle, marker registry, clustering and theme handling independent from NiceGUI redraw cycles -- βœ… `meshcore_gui/static/leaflet_map_panel.css` β€” Styling for browser-side node markers, cluster icons and map container -- βœ… `meshcore_gui/services/map_snapshot_service.py` β€” Snapshot service that normalizes device/contact map data into a compact payload for the browser runtime -- βœ… Browser-side map state management for center, zoom and theme -- βœ… Theme persistence across reconnect events via browser storage fallback -- βœ… Browser-side contact clustering via `Leaflet.markercluster` -- βœ… Separate non-clustered device marker layer so the own device remains individually visible - -### Changed -- πŸ”„ `meshcore_gui/gui/panels/map_panel.py` β€” Replaced NiceGUI Leaflet wrapper usage with a pure browser-managed Leaflet container while preserving the existing card layout, theme toggle and center-on-device control -- πŸ”„ Leaflet bootstrap moved out of inline Python into a dedicated browser runtime loaded from `/static` -- πŸ”„ Asset loading order is now explicit: Leaflet first, then `Leaflet.markercluster`, then the MeshCore panel runtime -- πŸ”„ Map initialization now occurs only once per container; NiceGUI refresh cycles no longer recreate the map -- πŸ”„ Dashboard update loop now sends compact map snapshots instead of triggering redraws -- πŸ”„ Snapshot processing in the browser is coalesced so only the newest payload is applied -- πŸ”„ Map markers are managed in separate device/contact layers and updated incrementally by stable node id -- πŸ”„ Contact markers are rendered inside a persistent cluster layer while the device marker remains outside clustering -- πŸ”„ Theme switching moved to a dedicated theme channel instead of being embedded in snapshot data - -### Fixed -- πŸ›  **Map disappearing during dashboard refresh cycles** β€” prevented repeated map reinitialization caused by the 500 ms NiceGUI update loop -- πŸ›  **Markers disappearing between refreshes** β€” marker updates are now incremental and keyed by node id -- πŸ›  **Blank map container on load** β€” browser bootstrap now waits for DOM host, Leaflet runtime and panel runtime before initialization -- πŸ›  **Leaflet clustering bootstrap failure (`L is not defined`)** β€” resolved by enforcing correct script dependency order before the panel runtime starts -- πŸ›  **MarkerClusterGroup failure (`Map has no maxZoom specified`)** β€” the map now defines `maxZoom` during initial creation before the cluster layer is attached -- πŸ›  **Half-initialized map retry cascade (`Map container is already initialized`)** β€” map state is now registered safely during initialization so a failed attempt cannot trigger a second `L.map(...)` on the same container -- πŸ›  **Race condition between queued snapshot and theme selection** β€” explicit theme changes can no longer be overwritten by stale snapshot payloads -- πŸ›  **Viewport jumping back to default center/zoom** β€” stored viewport is no longer reapplied on each snapshot update -- πŸ›  **Theme reverting to default during reconnect** β€” effective map theme is restored before snapshot processing resumes - -### Impact -- Leaflet map is now managed entirely in the browser and is no longer recreated on each dashboard refresh -- Node markers remain stable and no longer flicker or disappear during the 500 ms update cycle -- Dense contact sets can now be rendered with clustering without violating the browser-owned map lifecycle -- Theme switching and viewport state persist reliably across reconnect events -- No breaking changes outside the map subsystem ---- -## [1.12.1] - 2026-03-08 β€” Minor change bot -### Changed -- πŸ”„ `meshcore_gui/services/bot.py`: remove path id's -### Impact -- No breaking changes β€” all existing functionality preserved serial. - ---- - -## [1.12.0] - 2026-02-26 β€” MeshCore Observer Fase 1 - -### Added -- βœ… **MeshCore Observer daemon** β€” New standalone read-only daemon (`meshcore_observer.py`) that reads archive JSON files produced by meshcore_gui and meshcore_bridge, aggregates them, and presents a unified NiceGUI monitoring dashboard on port 9093. -- βœ… **ArchiveWatcher** β€” Core component that polls `~/.meshcore-gui/archive/` for `*_messages.json` and `*_rxlog.json` files, tracks mtime changes, and returns only new entries since previous poll. Thread-safe, zero writes, graceful on corrupt JSON. -- βœ… **Observer dashboard panels** β€” Sources overview, aggregated messages feed (sorted by timestamp), aggregated RX log table, and statistics panel with uptime/counters/per-source breakdown. Full DOMCA theme (dark + light mode). -- βœ… **Source filter** β€” Dropdown to filter messages and RX log by archive source. -- βœ… **Channel filter** β€” Dropdown to filter messages by channel name. -- βœ… **ObserverConfig** β€” YAML-based configuration with `from_yaml()` classmethod, defaults work without config file. -- βœ… **observer_config.yaml** β€” Documented config template with all options. -- βœ… **install_observer.sh** β€” systemd installer (`/opt/meshcore-observer/`, `/etc/meshcore/observer_config.yaml`), with `--uninstall` option. -- βœ… **RxLogEntry raw packet fields** β€” 5 new fields on `RxLogEntry` dataclass: `raw_payload`, `packet_len`, `payload_len`, `route_type`, `packet_type_num` (all with defaults, backward compatible). -- βœ… **EventHandler.on_rx_log() metadata** β€” Raw payload hex and packet metadata now passed through to RxLogEntry and archived (preparation for Fase 2 LetsMesh uplink). - -### Changed -- πŸ”„ `meshcore_gui/core/models.py`: RxLogEntry +5 fields with defaults (backward compatible). -- πŸ”„ `meshcore_gui/ble/events.py`: on_rx_log() fills raw_payload and metadata (~10 lines added). -- πŸ”„ `meshcore_gui/services/message_archive.py`: add_rx_log() serializes the 5 new RxLogEntry fields. -- πŸ”„ `meshcore_gui/config.py`: Version bumped to `1.12.0`. - -### Impact -- **No breaking changes** β€” All new RxLogEntry fields have defaults; existing archives and code work identically. -- **New daemon** β€” meshcore_observer is fully standalone; no imports from meshcore_gui (reads only JSON files). - ---- - -### Added -- βœ… **Serial CLI flags** β€” `--baud=BAUD` and `--serial-cx-dly=SECONDS` for serial configuration at startup. - -### Changed -- πŸ”„ **Connection layer** β€” Switched from BLE to serial (`MeshCore.create_serial`) with serial reconnect handling. -- πŸ”„ `config.py`: Added `SERIAL_BAUDRATE`, `SERIAL_CX_DELAY`, `DEFAULT_TIMEOUT`, `MESHCORE_LIB_DEBUG`; removed BLE PIN settings; version bumped to `1.10.0`. -- πŸ”„ `meshcore_gui.py` / `meshcore_gui/__main__.py`: Updated usage, banners and defaults for serial ports. -- πŸ”„ Docs: Updated README and core docs for serial usage; BLE documents marked as legacy. - -### Impact -- No breaking changes β€” all existing functionality preserved serial. - ---- - -## [1.9.11] - 2026-02-19 β€” Message Dedup Hotfix - -### Fixed -- πŸ›  **Duplicate messages after (re)connect** β€” `load_recent_from_archive()` appended archived messages on every connect attempt without clearing existing entries; after N failed connects, each message appeared N times. Method is now idempotent: clears the in-memory list before loading. -- πŸ›  **Persistent duplicate messages** β€” Live BLE events for messages already loaded from archive were not suppressed because the `DualDeduplicator` was never seeded with archived content. Added `_seed_dedup_from_messages()` in `BLEWorker` after cache/archive load and after reconnect. -- πŸ›  **Last-line-of-defence dedup in SharedData** β€” `add_message()` now maintains a fingerprint set (`message_hash` or `channel:sender:text`) and silently skips messages whose fingerprint is already tracked. This guards against duplicates regardless of their source. -- πŸ›  **Messages panel empty on first click** β€” `_show_panel()` made the container visible but relied on the next 500 ms timer tick to populate it. Added an immediate `_messages.update()` call so content is rendered the moment the panel becomes visible. - -### Changed -- πŸ”„ `core/shared_data.py`: Added `_message_fingerprints` set and `_message_fingerprint()` static method; `add_message()` checks fingerprint before insert and evicts fingerprints when messages are rotated out; `load_recent_from_archive()` clears messages and fingerprints before loading (idempotent) -- πŸ”„ `ble/worker.py`: Added `_seed_dedup_from_messages()` helper; called after `_apply_cache()` and after reconnect `_load_data()` to seed `DualDeduplicator` with existing messages -- πŸ”„ `gui/dashboard.py`: `_show_panel()` now forces an immediate `_messages.update()` when the messages panel is shown, eliminating the stale-content flash -- πŸ”„ `config.py`: Version bumped to `1.9.11` - -### Impact -- Eliminates all duplicate message display scenarios: initial connect, failed retries, reconnect, and BLE event replay -- No breaking changes β€” all existing functionality preserved -- Fingerprint set is bounded to the same 100-message cap as the message list - ---- - -## [1.9.10] - 2026-02-19 β€” Map Tooltips & Separate Own-Position Marker - -### Added -- βœ… **Map marker tooltips** β€” All markers on the Leaflet map now show a tooltip on hover with the node name and type icon (πŸ“±, πŸ“‘, 🏠) from `TYPE_ICONS` -- βœ… **Separate own-position marker** β€” The device's own position is now tracked as a dedicated `_own_marker`, independent from contact markers. This prevents the own marker from being removed/recreated on every contact update cycle - -### Changed -- πŸ”„ `gui/panels/map_panel.py`: Renamed `_markers` to `_contacts_markers`; added `_own_marker` attribute; own position marker is only updated when `device_updated` flag is set (not every timer tick); contact markers are only rebuilt when `contacts_updated` is set; added `TYPE_ICONS` import for tooltip icons -- πŸ”„ `gui/dashboard.py`: Added `self._map.update(data)` call in the `device_updated` block so the own-position marker updates when device info changes (e.g. GPS position update) -- πŸ”„ `config.py`: Version bumped to `1.9.10` - -### Impact -- Map centering on own device now works correctly and updates only when position actually changes -- Contact markers are no longer needlessly destroyed and recreated on every UI timer tick β€” only on actual contact data changes -- Tooltips make it easy to identify nodes on the map without clicking -- No breaking changes β€” all existing map functionality preserved - -### Credits -- Based on [PR #16](https://github.com/pe1hvh/meshcore-gui/pull/16) by [@rich257](https://github.com/rich257) - ---- - -## [1.9.9] - 2026-02-18 β€” Variable Landing Page & Operator Callsign - -### Added -- βœ… **Configurable operator callsign** β€” New `OPERATOR_CALLSIGN` constant in `config.py` (default: `"PE1HVH"`). Used in the landing page SVG and the drawer footer copyright label. Change this single value to personalize the entire GUI for a different operator -- βœ… **External landing page SVG** β€” The DOMCA splash screen is now loaded from a standalone file (`static/landing_default.svg`) instead of being hardcoded in `dashboard.py`. New `LANDING_SVG_PATH` constant in `config.py` points to the SVG file. The placeholder `{callsign}` in the SVG is replaced at runtime with `OPERATOR_CALLSIGN` -- βœ… **Landing page customization** β€” To use a custom landing page: copy `landing_default.svg` (or create your own SVG), use `{callsign}` wherever the operator callsign should appear, and point `LANDING_SVG_PATH` to your file. The default SVG includes an instructive comment block explaining the placeholder mechanism - -### Changed -- πŸ”„ `config.py`: Added `OPERATOR_CALLSIGN` and `LANDING_SVG_PATH` constants in new **OPERATOR / LANDING PAGE** section; version bumped to `1.9.9` -- πŸ”„ `gui/dashboard.py`: Removed hardcoded `_DOMCA_SVG` string (~70 lines); added `_load_landing_svg()` helper that reads SVG from disk and replaces `{callsign}` placeholder; CSS variable `--pe1hvh` renamed to `--callsign`; drawer footer copyright label now uses `config.OPERATOR_CALLSIGN` - -### Added (files) -- βœ… `static/landing_default.svg` β€” The original DOMCA splash SVG extracted as a standalone file, with `{callsign}` placeholder and `--callsign` CSS variable. Serves as both the default landing page and a reference template for custom SVGs - -### Impact -- Out-of-the-box behavior is identical to v1.9.8 (same DOMCA branding, same PE1HVH callsign) -- Operators personalize by changing 1–2 lines in `config.py` β€” no code modifications needed -- Fallback: if the SVG file is missing, a minimal placeholder text is shown instead of a crash -- No breaking changes β€” all existing dashboard functionality (panels, menus, timer, theming) unchanged - ---- - -## [1.9.8] - 2026-02-17 β€” Bugfix: Route Page Sender ID, Type & Location Not Populated - -### Fixed -- πŸ›  **Sender ID, Type and Location empty in Route Page** β€” After the v4.1 refactoring to `RouteBuilder`/`RouteNode`, the sender contact lookup relied solely on `SharedData.get_contact_by_prefix()` (live lock-based) and `get_contact_by_name()`. When both failed (e.g. empty `sender_pubkey` from RX_LOG decode, or name mismatch), `route['sender']` remained `None` and the route table fell through to a hardcoded fallback with `type: '-'`, `location: '-'`. The contact data was available in the snapshot `data['contacts']` but was never searched -- πŸ›  **Route table fallback row ignored available contact data** β€” When `route['sender']` was `None`, the `_render_route_table` method used a static fallback row without attempting to find the contact in the data snapshot. Even when the contact was present in `data['contacts']` with valid type and location, these fields showed as `'-'` - -### Changed -- πŸ”„ `services/route_builder.py`: Added two additional fallback strategies in `build()` after the existing SharedData lookups: (3) bidirectional pubkey prefix match against `data['contacts']` snapshot, (4) case-insensitive `adv_name` match against `data['contacts']` snapshot. Added helper methods `_find_contact_by_pubkey()` and `_find_contact_by_adv_name()` for snapshot-based lookups -- πŸ”„ `gui/route_page.py`: Added defensive fallback in `_render_route_table()` sender section β€” when `route['sender']` is `None`, attempts to find the contact in the snapshot via `_find_sender_contact()` before falling back to the static `'-'` row. Added `_find_sender_contact()` helper method - -### Impact -- Sender ID (hash), Type and Location are now populated correctly in the route table when the contact is known -- Four-layer lookup chain ensures maximum resolution: (1) SharedData pubkey lookup, (2) SharedData name lookup, (3) snapshot pubkey lookup, (4) snapshot name lookup -- Defensive fallback in route_page guarantees data is shown even if RouteBuilder misses it -- No breaking changes β€” all existing route page behavior, styling and data flows unchanged - ---- - -## [1.9.7] - 2026-02-17 β€” Layout Fix: Archive Filter Toggle & Route Page Styling - -### Changed -- πŸ”„ `gui/archive_page.py`: Archive filter card now hidden by default; toggle visibility via a `filter_list` icon button placed right-aligned on the same row as the "πŸ“š Archive" title. Header restructured from single label to `ui.row()` with `justify-between` layout -- πŸ”„ `gui/route_page.py`: Route page now uses DOMCA theme (imported from `dashboard.py`) with dark mode as default, consistent with the main dashboard. Header restyled from `bg-blue-600` to Quasar-themed header with JetBrains Mono font. Content container changed from `w-full max-w-4xl mx-auto` to `domca-panel` class for consistent responsive sizing -- πŸ”„ `gui/dashboard.py`: Added `domca-header-text` CSS class with `@media (max-width: 599px)` rule to hide header text on narrow viewports; applied to version label and status label -- πŸ”„ `gui/route_page.py`: Header label also uses `domca-header-text` class for consistent responsive behaviour - -### Added -- βœ… **Archive filter toggle** β€” `filter_list` icon button in archive header row toggles the filter card visibility on click -- βœ… **Route page close button** β€” `X` (close) icon button added right-aligned in the route page header; calls `window.close()` to close the browser tab -- βœ… **Responsive header** β€” On viewports < 600px, header text labels are hidden; only icon buttons (menu, dark mode toggle, close) remain visible - -### Impact -- Archive page is cleaner by default β€” filters only shown when needed -- Route page visually consistent with the main dashboard (DOMCA theme, dark mode, responsive panel width) -- Headers degrade gracefully on mobile (< 600px): only icon buttons visible, no text overflow -- No functional changes β€” all event handlers, callbacks, data bindings, logic and imports are identical to the input - ---- - -## [1.9.6] - 2026-02-17 β€” Bugfix: Channel Discovery Reliability - -### Fixed -- πŸ›  **Channels not appearing (especially on mobile)** β€” Channel discovery aborted too early on slow BLE connections. The `_discover_channels()` probe used a single attempt per channel slot and stopped after just 2 consecutive empty responses. On mobile BLE stacks (WebBluetooth via NiceGUI) where GATT responses are slower, this caused discovery to abort before finding any channels, falling back to only `[0] Public` -- πŸ›  **Race condition: channel update flag lost between threads** β€” `get_snapshot()` and `clear_update_flags()` were two separate calls, each acquiring the lock independently. If the BLE worker set `channels_updated = True` between these two calls, the GUI consumed the flag via `get_snapshot()` but then `clear_update_flags()` reset it β€” causing the channel submenu and dropdown to never populate -- πŸ›  **Channels disappear on browser reconnect** β€” When a browser tab is closed and reopened, `render()` creates new (empty) NiceGUI containers for the drawer submenus, but did not reset `_last_channel_fingerprint`. The `_update_submenus()` method compared the new fingerprint against the stale one, found them equal, and skipped the rebuild β€” leaving the new containers permanently empty. Fixed by resetting both `_last_channel_fingerprint` and `_last_rooms_fingerprint` in `render()` - -### Changed -- πŸ”„ `core/shared_data.py`: New atomic method `get_snapshot_and_clear_flags()` that reads the snapshot and resets all update flags in a single lock acquisition. Internally refactored to `_build_snapshot_unlocked()` helper. Existing `get_snapshot()` and `clear_update_flags()` retained for backward compatibility -- πŸ”„ `ble/worker.py`: `_discover_channels()` β€” `max_attempts` increased from 1 to 2 per channel slot; inter-attempt `delay` increased from 0.5s to 1.0s; consecutive error threshold raised from 2 to 3; inter-channel pause increased from 0.15s to 0.3s for mobile BLE stack breathing room -- πŸ”„ `gui/dashboard.py`: `_update_ui()` now uses `get_snapshot_and_clear_flags()` instead of separate `get_snapshot()` + `clear_update_flags()`; `render()` now resets `_last_channel_fingerprint` and `_last_rooms_fingerprint` to `None` so that `_update_submenus()` rebuilds into the freshly created containers; channel-dependent updates (`update_filters`, `update_channel_options`, `_update_submenus`) now run unconditionally when channel data exists β€” safe because each method has internal idempotency checks -- πŸ”„ `gui/panels/messages_panel.py`: `update_channel_options()` now includes an equality check on options dict to skip redundant `.update()` calls to the NiceGUI client on every 500ms timer tick - -### Impact -- Channel discovery now survives transient BLE timeouts that are common on mobile connections -- Atomic snapshot eliminates the threading race condition that caused channels to silently never appear -- Browser close+reopen no longer loses channels β€” the single-instance timer race on the shared `DashboardPage` is fully mitigated -- No breaking changes β€” all existing API methods retained, all other functionality unchanged - ---- - -## [1.9.5] - 2026-02-16 β€” Layout Fix: RX Log Table Responsive Sizing - -### Fixed -- πŸ›  **RX Log table did not adapt to panel/card size** β€” The table used `max-h-48` (a maximum height cap) instead of a responsive fixed height, causing it to remain small regardless of available space. Changed to `h-40` which is overridden by the existing dashboard CSS to `calc(100vh - 20rem)` β€” the same responsive pattern used by the Messages panel -- πŸ›  **RX Log table did not fill card width** β€” Added `w-full` class to the table element so it stretches to the full width of the parent card -- πŸ›  **RX Log card did not fill panel height** β€” Added `flex-grow` class to the card container so it expands to fill the available panel space - -### Changed -- πŸ”„ `gui/panels/rxlog_panel.py`: Card classes `'w-full'` β†’ `'w-full flex-grow'` (line 45); table classes `'text-xs max-h-48 overflow-y-auto'` β†’ `'w-full text-xs h-40 overflow-y-auto'` (line 65) - -### Impact -- RX Log table now fills the panel consistently on both desktop and mobile viewports -- Layout is consistent with other panels (Messages, Contacts) that use the same `h-40` responsive height pattern -- No functional changes β€” all event handlers, callbacks, data bindings, logica and imports are identical to the input - ---- - -## [1.9.4] - 2026-02-16 β€” BLE Address Log Prefix & Entry Point Cleanup - -### Added -- βœ… **BLE address prefix in log filename** β€” Log file is now named `_meshcore_gui.log` (e.g. `AA_BB_CC_DD_EE_FF_meshcore_gui.log`) instead of the generic `meshcore_gui.log`. Makes it easy to identify which device produced which log file when running multiple instances - - New helper `_sanitize_ble_address()` strips `literal:` prefix and replaces colons with underscores - - New function `configure_log_file(ble_address)` updates `LOG_FILE` at runtime before the logger is initialised - - Rotated backups follow the same naming pattern automatically - -### Removed -- ❌ **`meshcore_gui/meshcore_gui.py`** β€” Redundant copy of `main()` that was never imported. All three entry points (`meshcore_gui.py` root, `__main__.py`, and `meshcore_gui/meshcore_gui.py`) contained near-identical copies of the same logic, causing changes to be missed (as demonstrated by this fix). `__main__.py` is now the single source of truth; root `meshcore_gui.py` is a thin wrapper that imports from it - -### Changed -- πŸ”„ `config.py`: Added `_sanitize_ble_address()` and `configure_log_file()`; version bumped to `1.9.4` -- πŸ”„ `__main__.py`: Added `config.configure_log_file(ble_address)` call before any debug output -- πŸ”„ `meshcore_gui.py` (root): Reduced to 4-line wrapper importing `main` from `__main__` - -### Impact -- Log files are now identifiable per BLE device -- Single source of truth for `main()` eliminates future sync issues between entry points -- Both startup methods (`python meshcore_gui.py` and `python -m meshcore_gui`) remain functional -- No breaking changes β€” defaults and all existing behaviour unchanged ---- - -## [1.9.3] - 2026-02-16 β€” Bugfix: Map Default Location & Payload Type Decoding - -### Fixed -- πŸ›  **Map centred on hardcoded Zwolle instead of device location** β€” All Leaflet maps used magic-number coordinates `(52.5, 6.0)` as initial centre and fallback. These are now replaced by a single configurable constant `DEFAULT_MAP_CENTER` in `config.py`. Once the device reports a valid `adv_lat`/`adv_lon`, maps re-centre on the actual device position (existing behaviour, unchanged) -- πŸ›  **Payload type shown as raw integer** β€” Payload type is now retrieved from the decoded payload and translated to human-readable text using MeshCoreDecoder functions, instead of displaying the raw numeric type value - -### Changed -- πŸ”„ `config.py`: Added `DEFAULT_MAP_CENTER` (default: `(52.5168, 6.0830)`) and `DEFAULT_MAP_ZOOM` (default: `9`) constants in new **MAP DEFAULTS** section. Version bumped to `1.9.2` -- πŸ”„ `gui/panels/map_panel.py`: Imports `DEFAULT_MAP_CENTER` and `DEFAULT_MAP_ZOOM` from config; `ui.leaflet(center=...)` uses config constants instead of hardcoded values -- πŸ”„ `gui/route_page.py`: Imports `DEFAULT_MAP_CENTER` and `DEFAULT_MAP_ZOOM` from config; fallback coordinates (`or 52.5` / `or 6.0`) replaced by `DEFAULT_MAP_CENTER[0]` / `[1]`; zoom uses `DEFAULT_MAP_ZOOM` - -### Impact -- Map default location is now a single-point-of-change in `config.py` -- Payload type is displayed as readable text instead of a raw number -- No breaking changes β€” all existing map behaviour (re-centre on device position, contact markers) unchanged - -## [1.9.2] - 2026-02-15 β€” CLI Parameters & Cleanup - -### Added -- βœ… **`--port=PORT` CLI parameter** β€” Web server port is now configurable at startup (default: `8081`). Allows running multiple instances simultaneously on different ports -- βœ… **`--ble-pin=PIN` CLI parameter** β€” BLE pairing PIN is now configurable at startup (default: `123456`). Eliminates the need to edit `config.py` for devices with a non-default PIN, and works in systemd service files -- βœ… **Per-device log file** β€” Debug log file now includes the BLE address in its filename (e.g. `F0_9E_9E_75_A3_01_meshcore_gui.log`), so multiple instances log to separate files - -### Fixed -- πŸ›  **BLE PIN not applied from CLI** β€” `ble/worker.py` imported `BLE_PIN` as a constant at module load time (`from config import BLE_PIN`), capturing the default value `"123456"` before CLI parsing could override `config.BLE_PIN`. Changed to runtime access via `config.BLE_PIN` so the `--ble-pin` parameter is correctly passed to the BLE agent - -### Removed -- ❌ **Redundant `meshcore_gui/meshcore_gui.py`** β€” This file was a near-identical copy of both `meshcore_gui.py` (top-level) and `meshcore_gui/__main__.py`, but was never imported or referenced. Removed to eliminate maintenance risk. The two remaining entry points cover all startup methods: `python meshcore_gui.py` and `python -m meshcore_gui` - -### Impact -- Multiple instances can run side-by-side with different ports, PINs and log files -- Service deployments no longer require editing `config.py` β€” all runtime settings via CLI -- No breaking changes β€” all defaults are unchanged - ---- - -## [1.9.1] - 2026-02-14 β€” Bugfix: Dual Reconnect Conflict - -### Fixed -- πŸ›  **Library reconnect interfered with application reconnect** β€” The meshcore library's internal `auto_reconnect` (visible in logs as `"Attempting reconnection 1/3"`) ran a fast 3-attempt reconnect cycle without bond cleanup. This prevented the application's own `reconnect_loop` (which does `remove_bond()` + backoff) from succeeding, because BlueZ retained a stale bond β†’ `"failed to discover service"` - -### Changed -- πŸ”„ `ble/worker.py`: Set `auto_reconnect=False` in both `MeshCore.create_ble()` call sites (`_connect()` and `_create_fresh_connection()`), so only the application's bond-aware `reconnect_loop` handles reconnection -- πŸ”„ `ble/worker.py`: Added `"failed to discover"` and `"service discovery"` to disconnect detection keywords for defensive coverage - -### Impact -- Eliminates the ~9 second wasted library reconnect cycle after every BLE disconnect -- Application's `reconnect_loop` (with bond cleanup) now runs immediately after disconnect detection -- No breaking changes β€” the application reconnect logic was already fully functional - ---- - -## [1.9.0] - 2026-02-14 β€” BLE Connection Stability - -### Added -- βœ… **Built-in BLE PIN agent** β€” New `ble/ble_agent.py` registers a D-Bus agent with BlueZ to handle PIN pairing requests automatically. Eliminates the need for external `bt-agent.service` and `bluez-tools` package - - Uses `dbus_fast` (already a dependency of `bleak`, no new packages) - - Supports `RequestPinCode`, `RequestPasskey`, `DisplayPasskey`, `RequestConfirmation`, `AuthorizeService` callbacks - - Configurable PIN via `BLE_PIN` in `config.py` (default: `123456`) -- βœ… **Automatic bond cleanup** β€” New `ble/ble_reconnect.py` provides `remove_bond()` function that removes stale BLE bonds via D-Bus, equivalent to `bluetoothctl remove
`. Called automatically on startup and before each reconnect attempt -- βœ… **Automatic reconnect after disconnect** β€” BLEWorker main loop now detects BLE disconnects (via connection error exceptions) and automatically triggers a reconnect sequence: bond removal β†’ linear backoff wait β†’ fresh connection β†’ re-wire handlers β†’ reload device data - - Configurable via `RECONNECT_MAX_RETRIES` (default: 5) and `RECONNECT_BASE_DELAY` (default: 5.0s) - - After all retries exhausted: waits 60s then starts a new retry cycle (infinite recovery) -- βœ… **Generic install script** β€” `install_ble_stable.sh` auto-detects user, project directory, venv path and entry point to generate systemd service and D-Bus policy. Supports `--uninstall` flag - -### Changed -- πŸ”„ **`ble/worker.py`** β€” `_async_main()` rewritten with three phases: (1) start PIN agent, (2) remove stale bond, (3) connect + main loop with disconnect detection. Reconnect logic re-wires all event handlers and reloads device data after successful reconnection -- πŸ”„ **`config.py`** β€” Added `BLE_PIN`, `RECONNECT_MAX_RETRIES`, `RECONNECT_BASE_DELAY` constants - -### Removed -- ❌ **`bt-agent.service` dependency** β€” No longer needed; PIN pairing is handled by the built-in agent -- ❌ **`bluez-tools` system package** β€” No longer needed -- ❌ **`~/.meshcore-ble-pin` file** β€” No longer needed -- ❌ **Manual `bluetoothctl remove` before startup** β€” Handled automatically -- ❌ **`ExecStartPre` in systemd service** β€” Bond cleanup is internal - -### Impact -- Zero external dependencies for BLE pairing on Linux -- Automatic recovery from the T1000e ~2 hour BLE disconnect issue -- No manual intervention needed after BLE connection loss -- Single systemd service (`meshcore-gui.service`) manages everything -- No breaking changes to existing functionality - ---- - -## [1.8.0] - 2026-02-14 β€” DRY Message Construction & Archive Layout Unification - -### Fixed -- πŸ›  **Case-sensitive prefix matching** β€” `get_contact_name_by_prefix()` and `get_contact_by_prefix()` in `shared_data.py` failed to match path hashes (uppercase, e.g. `'B8'`) against contact pubkeys (lowercase, e.g. `'b8a3f2...'`). Added `.lower()` to both sides of the comparison, consistent with `_resolve_path_names()` which already had it -- πŸ›  **Route page 404 from archive** β€” Archive page linked to `/route/{hash}` but route was registered as `/route/{msg_index:int}`, causing a JSON parse error for hex hash strings. Route parameter changed to `str` with 3-strategy lookup (index β†’ memory hash β†’ archive fallback) -- πŸ›  **Three entry points out of sync** β€” `meshcore_gui.py` (root), `meshcore_gui/meshcore_gui.py` (inner) and `meshcore_gui/__main__.py` had diverging route registrations. All three now use identical `/route/{msg_key}` with `str` parameter - -### Changed -- πŸ”„ **`core/models.py` β€” DRY factory methods and formatting** - - `Message.now_timestamp()`: static method replacing 7Γ— hardcoded `datetime.now().strftime('%H:%M:%S')` across `events.py` and `commands.py` - - `Message.incoming()`: classmethod factory for received messages (`direction='in'`, auto-timestamp) - - `Message.outgoing()`: classmethod factory for sent messages (`sender='Me'`, `direction='out'`, auto-timestamp) - - `Message.format_line(channel_names)`: single-line display formatting (`"12:34:56 ← [Public] [2hβœ“] PE1ABC: Hello mesh!"`), replacing duplicate inline formatting in `messages_panel.py` and `archive_page.py` -- πŸ”„ **`ble/events.py`** β€” 4Γ— `Message(...)` constructors replaced by `Message.incoming()`; `datetime` import removed -- πŸ”„ **`ble/commands.py`** β€” 3Γ— `Message(...)` constructors replaced by `Message.outgoing()`; `datetime` import removed -- πŸ”„ **`gui/panels/messages_panel.py`** β€” 15 lines inline formatting replaced by single `msg.format_line(channel_names)` call -- πŸ”„ **`gui/archive_page.py` β€” Layout unified with main page** - - Multi-row card layout replaced by single-line `msg.format_line()` in monospace container (same style as main page) - - DM added to channel filter dropdown (post-filter on `channel is None`) - - Message click opens `/route/{message_hash}` in new tab (was: no click handler on archive messages) - - Removed `_render_message_card()` (98 lines) and `_render_archive_route()` (75 lines) - - Removed `RouteBuilder` dependency and `TYPE_LABELS` import - - File reduced from 445 to 267 lines -- πŸ”„ **`gui/route_page.py`** β€” `render(msg_index: int)` β†’ `render(msg_key: str)` with 3-strategy message lookup: (1) numeric index from in-memory list, (2) hash match in memory, (3) `archive.get_message_by_hash()` fallback -- πŸ”„ **`services/message_archive.py`** β€” New method `get_message_by_hash(hash)` for single-message lookup by packet hash -- πŸ”„ **`__main__.py` + `meshcore_gui.py` (both)** β€” Route changed from `/route/{msg_index}` (int) to `/route/{msg_key}` (str) - -### Impact -- DRY: timestamp formatting 7β†’1 definition, message construction 7β†’2 factories, line formatting 2β†’1 method -- Archive page visually consistent with main messages panel (single-line, monospace) -- Archive messages now clickable to open route visualization (was: only in-memory messages) -- Case-insensitive prefix matching fixes path name resolution for contacts with uppercase path hashes -- No breaking changes to BLE protocol handling, dedup, bot, or data storage - -### Known Limitations -- DM filter in archive uses post-filtering (query without channel filter + filter on `channel is None`); becomes exact when `query_messages()` gets native DM support - -### Parked for later -- Multi-path tracking (enrich RxLogEntry with multiple path observations) -- Events correlation improvements (only if proven data loss after `.lower()` fix) - ---- - -## [1.7.0] - 2026-02-13 β€” Archive Channel Name Persistence - -### Added -- βœ… **Channel name stored in archive** β€” Messages now persist `channel_name` alongside the numeric `channel` index in `
_messages.json`, so archived messages retain their human-readable channel name even when the device is not connected - - `Message` dataclass: new field `channel_name: str` (default `""`, backward compatible) - - `SharedData.add_message()`: automatically resolves `channel_name` from the live channels list when not already set (new helper `_resolve_channel_name()`) - - `MessageArchive.add_message()`: writes `channel_name` to the JSON dict -- βœ… **Archive channel selector built from archived data** β€” Channel filter dropdown on `/archive` now populated via `SELECT DISTINCT channel_name` on the archive instead of the live BLE channels list - - New method `MessageArchive.get_distinct_channel_names()` returns sorted unique channel names from stored messages - - Selector shows only channels that actually have archived messages -- βœ… **Archive filter on channel name** β€” `MessageArchive.query_messages()` parameter changed from `channel: Optional[int]` to `channel_name: Optional[str]` (exact match on name string) - -### Changed -- πŸ”„ `core/models.py`: Added `channel_name` field to `Message` dataclass and `from_dict()` -- πŸ”„ `core/shared_data.py`: `add_message()` resolves channel name; added `_resolve_channel_name()` helper -- πŸ”„ `services/message_archive.py`: `channel_name` persisted in JSON; `query_messages()` filters by name; new `get_distinct_channel_names()` method -- πŸ”„ `gui/archive_page.py`: Channel selector built from `archive.get_distinct_channel_names()`; filter state changed from `_channel_filter` (int) to `_channel_name_filter` (str); message cards show `channel_name` directly from archive - -### Fixed -- πŸ›  **Main page empty after startup** β€” After a restart the messages panel showed no messages until new live BLE traffic arrived. `SharedData.load_recent_from_archive()` now loads up to 100 recent archived messages during the cache-first startup phase, so historical messages are immediately visible - - New method `SharedData.load_recent_from_archive(limit)` β€” reads from `MessageArchive.query_messages()` and populates the in-memory list without re-archiving - - `BLEWorker._apply_cache()` calls `load_recent_from_archive()` at the end of cache loading - -### Impact -- Archived messages now self-contained β€” channel name visible without live BLE connection -- Main page immediately shows historical messages after startup (no waiting for live BLE traffic) -- Backward compatible β€” old archive entries without `channel_name` fall back to `"Ch "` -- No breaking changes to existing functionality - ---- - -## [1.6.0] - 2026-02-13 β€” Dashboard Layout Consolidation - -### Changed -- πŸ”„ **Messages panel consolidated** β€” Filter checkboxes (DM + channels) and message input (text field, channel selector, Send button) are now integrated into the Messages panel, replacing the separate Filter and Input panels - - DM + channel checkboxes displayed centered in the Messages header row, between the "πŸ’¬ Messages" label and the "πŸ“š Archive" button - - Message input row (text field, channel selector, Send button) placed below the message list within the same card - - `messages_panel.py`: Constructor now accepts `put_command` callable; added `update_filters(data)`, `update_channel_options(channels)` methods and `channel_filters`, `last_channels` properties (all logic 1:1 from FilterPanel/InputPanel); `update()` signature unchanged -- πŸ”„ **Actions panel expanded** β€” BOT toggle checkbox moved from Filter panel to Actions panel, below the Refresh/Advert buttons - - `actions_panel.py`: Constructor now accepts `set_bot_enabled` callable; added `update(data)` method for BOT state sync; `_on_bot_toggle()` logic 1:1 from FilterPanel -- πŸ”„ **Dashboard layout simplified** β€” Centre column reduced from 4 panels (Map β†’ Input β†’ Filter β†’ Messages) to 2 panels (Map β†’ Messages) - - `dashboard.py`: FilterPanel and InputPanel no longer rendered; all dependencies rerouted to MessagesPanel and ActionsPanel; `_update_ui()` call-sites updated accordingly - -### Removed (from layout, files retained) -- ❌ **Filter panel** no longer rendered as separate panel β€” `filter_panel.py` retained in codebase but not instantiated in dashboard -- ❌ **Input panel** no longer rendered as separate panel β€” `input_panel.py` retained in codebase but not instantiated in dashboard - -### Impact -- Cleaner, more compact dashboard: 2 fewer panels in the centre column -- All functionality preserved β€” message filtering, send, BOT toggle, archive all work identically -- No breaking changes to BLE, services, core or other panels - ---- - - - -## [1.5.0] - 2026-02-11 β€” Room Server Support, Dynamic Channel Discovery & Contact Management - -### Added -- βœ… **Room Server panel** β€” Dedicated per-room-server message panel in the centre column below Messages. Each Room Server (type=3 contact) gets its own `ui.card()` with login/logout controls and message display - - Click a Room Server contact to open an add/login dialog with password field - - After login: messages are displayed in the room card; send messages directly from the room panel - - Password row + login button automatically replaced by Logout button after successful login - - Room Server author attribution via `signature` field (txt_type=2) β€” real message author is resolved from the 4-byte pubkey prefix, not the room server pubkey - - New panel: `gui/panels/room_server_panel.py` β€” per-room card management with login state tracking -- βœ… **Room Server password store** β€” Passwords stored outside the repository in `~/.meshcore-gui/room_passwords/
.json` - - New service: `services/room_password_store.py` β€” JSON-backed persistent password storage per BLE device, analogous to `PinStore` - - Room panels are restored from stored passwords on app restart -- βœ… **Dynamic channel discovery** β€” Channels are now auto-discovered from the device at startup via `get_channel()` BLE probing, replacing the hardcoded `CHANNELS_CONFIG` - - Single-attempt probe per channel slot with early stop after 2 consecutive empty slots - - Channel name and encryption key extracted in a single pass (combined discovery + key loading) - - Configurable channel caching via `CHANNEL_CACHE_ENABLED` (default: `False` β€” always fresh from device) - - `MAX_CHANNELS` setting (default: 8) controls how many slots are probed -- βœ… **Individual contact deletion** β€” πŸ—‘οΈ delete button per unpinned contact in the contacts list, with confirmation dialog - - New command: `remove_single_contact` in BLE command handler - - Pinned contacts are protected (no delete button shown) -- βœ… **"Also delete from history" option** β€” Checkbox in the Clean up confirmation dialog to also remove locally cached contact data - - -- βœ… **Room Server protocol research** β€” `RoomServer_Companion_App_Onderzoek.md` documents the full companion app message flow (login, push protocol, signature mechanism, auto_message_fetching) - -### Changed -- πŸ”„ `config.py`: Removed `CHANNELS_CONFIG` constant; added `MAX_CHANNELS` (default: 8) and `CHANNEL_CACHE_ENABLED` (default: `False`) -- πŸ”„ `ble/worker.py`: Replaced hardcoded channel loading with `_discover_channels()` method; added `_try_get_channel_info()` helper; `_apply_cache()` respects `CHANNEL_CACHE_ENABLED` setting; removed `_load_channel_keys()` (integrated into discovery pass) -- πŸ”„ `ble/commands.py`: Added `login_room`, `send_room_msg` and `remove_single_contact` command handlers -- πŸ”„ `gui/panels/contacts_panel.py`: Contact click now dispatches by type β€” type=3 (Room Server) opens room dialog, others open DM dialog; added `on_add_room` callback parameter; added πŸ—‘οΈ delete button per unpinned contact -- πŸ”„ `gui/panels/messages_panel.py`: Room Server messages filtered from general message view via `_is_room_message()` with prefix matching; `update()` accepts `room_pubkeys` parameter -- πŸ”„ `gui/dashboard.py`: Added `RoomServerPanel` in centre column; `_update_ui()` passes `room_pubkeys` to Messages panel; added `_on_add_room_server` callback -- πŸ”„ `gui/panels/filter_panel.py`: Channel filter checkboxes now built dynamically from discovered channels (no hardcoded references) -- πŸ”„ `services/bot.py`: Removed stale comment referencing hardcoded channels - -### Fixed -- πŸ›  **Room Server messages appeared as DM** β€” Messages from Room Servers (txt_type=2) were displayed in the general Messages panel as direct messages. They are now filtered out and shown exclusively in the Room Server panel -- πŸ›  **Historical room messages not shown after login** β€” Post-login fetch loop was polling `get_msg()` before room server had time to push messages over LoRa RF (10–75s per message). Removed redundant fetch loop; the library's `auto_message_fetching` handles `MESSAGES_WAITING` events correctly and event-driven -- πŸ›  **Author attribution incorrect for room messages** β€” Room server messages showed the room server name as sender instead of the actual message author. Now correctly resolved from the `signature` field (4-byte pubkey prefix) via contact lookup - -### Impact -- Room Servers are now first-class citizens in the GUI with dedicated panels -- Channel configuration no longer requires manual editing of `config.py` -- Contact list management is more granular with per-contact deletion -- No breaking changes to existing functionality (messages, DM, map, archive, bot, etc.) - ---- - -## [1.4.0] - 2026-02-09 β€” SDK Event Race Condition Fix - -### Fixed -- πŸ›  **BLE startup delay of ~2 minutes eliminated** β€” The meshcore Python SDK (`commands/base.py`) dispatched device response events before `wait_for_events()` registered its subscription. On busy networks with frequent `RX_LOG_DATA` events, this caused `send_device_query()` and `get_channel()` to fail repeatedly with `no_event_received`, wasting 110+ seconds in timeouts - -### Changed -- πŸ“„ `meshcore` SDK `commands/base.py`: Rewritten `send()` method to subscribe to expected events **before** transmitting the BLE command (subscribe-before-send pattern), matching the approach used by the companion apps (meshcore.js, iOS, Android). Submitted upstream as [meshcore_py PR #52](https://github.com/meshcore-dev/meshcore_py/pull/52) - -### Impact -- Startup time reduced from ~2+ minutes to ~10 seconds on busy networks -- All BLE commands (`send_device_query`, `get_channel`, `get_bat`, `send_appstart`, etc.) now succeed on first attempt instead of requiring multiple retries -- No changes to meshcore_gui code required β€” the fix is entirely in the meshcore SDK - -### Temporary Installation -Until the fix is merged upstream, install the patched meshcore SDK: -```bash -pip install --force-reinstall git+https://github.com/PE1HVH/meshcore_py.git@fix/event-race-condition -``` - ---- - - - -## [1.3.2] - 2026-02-09 β€” Bugfix: Bot Device Name Restoration After Restart - -### Fixed -- πŸ›  **Bot device name not properly restored after restart/crash** β€” After a restart or crash with bot mode previously active, the original device name was incorrectly stored as the bot name (e.g. `NL-OV-ZWL-STDSHGN-WKC Bot`) instead of the real device name (e.g. `PE1HVH T1000e`). The original device name is now correctly preserved and restored when bot mode is disabled - -### Changed -- πŸ”„ `commands.py`: `set_bot_name` handler now verifies that the stored original name is not already the bot name before saving -- πŸ”„ `shared_data.py`: `original_device_name` is only written when it differs from `BOT_DEVICE_NAME` to prevent overwriting with the bot name on restart - ---- - - - -## [1.3.1] - 2026-02-09 β€” Bugfix: Auto-add AttributeError - -### Fixed -- πŸ›  **Auto-add error on first toggle** β€” Setting auto-add for the first time raised `AttributeError: 'telemetry_mode_base'`. The `set_manual_add_contacts()` SDK call now handles missing `telemetry_mode_base` attribute gracefully - -### Changed -- πŸ”„ `commands.py`: `set_auto_add` handler wraps `set_manual_add_contacts()` call with attribute check and error handling for missing `telemetry_mode_base` - ---- - - - -## [1.3.0] - 2026-02-08 β€” Bot Device Name Management - -### Added -- βœ… **Bot device name switching** β€” When the BOT checkbox is enabled, the device name is automatically changed to a configurable bot name; when disabled, the original name is restored - - Original device name is saved before renaming so it can be restored on BOT disable - - Device name written to device via BLE `set_name()` SDK call - - Graceful handling of BLE failures during name change -- βœ… **`BOT_DEVICE_NAME` constant** in `config.py` β€” Configurable fixed device name used when bot mode is active (default: `;NL-OV-ZWL-STDSHGN-WKC Bot`) - -### Changed -- πŸ”„ `config.py`: Added `BOT_DEVICE_NAME` constant for bot mode device name -- πŸ”„ `bot.py`: Removed hardcoded `BOT_NAME` prefix ("Zwolle Bot") from bot reply messages β€” bot replies no longer include a name prefix -- πŸ”„ `filter_panel.py`: BOT checkbox toggle now triggers device name save/rename via command queue -- πŸ”„ `commands.py`: Added `set_bot_name` and `restore_name` command handlers for device name switching -- πŸ”„ `shared_data.py`: Added `original_device_name` field for storing the pre-bot device name - -### Removed -- ❌ `BOT_NAME` constant from `bot.py` β€” bot reply prefix removed; replies no longer prepend a bot display name - ---- - -## [1.2.0] - 2026-02-08 β€” Contact Maintenance Feature - -### Added -- βœ… **Pin/Unpin contacts** (Iteration A) β€” Toggle to pin individual contacts, protecting them from bulk deletion - - Persistent pin state stored in `~/.meshcore-gui/cache/
_pins.json` - - Pinned contacts visually marked with yellow background - - Pinned contacts sorted to top of contact list - - Pin state survives app restart - - New service: `services/pin_store.py` β€” JSON-backed persistent pin storage - -- βœ… **Bulk delete unpinned contacts** (Iteration B) β€” Remove all unpinned contacts from device in one action - - "🧹 Clean up" button in contacts panel with confirmation dialog - - Shows count of contacts to be removed vs. pinned contacts kept - - Progress status updates during removal - - Automatic device resync after completion - - New service: `services/contact_cleaner.py` β€” ContactCleanerService with purge statistics - -- βœ… **Auto-add contacts toggle** (Iteration C) β€” Control whether device automatically adds new contacts from mesh adverts - - "πŸ“₯ Auto-add" checkbox in contacts panel (next to Clean up button) - - Syncs with device via `set_manual_add_contacts()` SDK call - - Inverted logic handled internally (UI "Auto-add ON" = `set_manual_add_contacts(false)`) - - Optimistic update with automatic rollback on BLE failure - - State synchronized from device on each GUI update cycle - -### Changed -- πŸ”„ `contacts_panel.py`: Added pin checkbox per contact, purge button, auto-add toggle, DM dialog (all existing functionality preserved) -- πŸ”„ `commands.py`: Added `purge_unpinned` and `set_auto_add` command handlers -- πŸ”„ `shared_data.py`: Added `auto_add_enabled` field with thread-safe getter/setter -- πŸ”„ `protocols.py`: Added `set_auto_add_enabled` and `is_auto_add_enabled` to Writer and Reader protocols -- πŸ”„ `dashboard.py`: Passes `PinStore` and `set_auto_add_enabled` callback to ContactsPanel -- πŸ”„ **UI language**: All Dutch strings in `contacts_panel.py` and `commands.py` translated to English - ---- - -### Fixed -- πŸ›  **Route table names and IDs not displayed** β€” Route tables in both current messages (RoutePage) and archive messages (ArchivePage) now correctly show node names and public key IDs for sender, repeaters and receiver - -### Changed -- πŸ”„ **CHANGELOG.md**: Corrected version numbering to semantic versioning, fixed inaccurate references (archive button location, filter state persistence) -- πŸ”„ **README.md**: Added Message Archive feature, updated project structure, configuration table and architecture diagram -- πŸ”„ **MeshCore_GUI_Design.docx**: Added ArchivePage, MessageArchive, Models components; updated project structure, protocols, configuration and version history - ---- - -## [1.1.0] - 2026-02-07 β€” Archive Viewer Feature - - -### Added -- βœ… **Archive Viewer Page** (`/archive`) β€” Full-featured message archive browser - - Pagination (50 messages per page, configurable) - - Channel filter dropdown (All + configured channels) - - Time range filter (24h, 7d, 30d, 90d, All time) - - Text search (case-insensitive) - - Filter state stored in instance variables (reset on page reload) - - Message cards with same styling as main messages panel - - Clickable messages for route visualization (where available) - - **πŸ’¬ Reply functionality** β€” Expandable reply panel per message - - **πŸ—ΊοΈ Inline route table** β€” Expandable route display per archive message with sender, repeaters and receiver (names, IDs, node types) - - *(Note: Reply panels and inline route tables removed in v1.8.0, replaced by click-to-route navigation via message hash)* - - - - - -- βœ… **MessageArchive.query_messages()** method - - Filter by: time range, channel, text search, sender - - Pagination support (limit, offset) - - Returns tuple: (messages, total_count) - - Sorting: Newest first - -- βœ… **UI Integration** - - "πŸ“š Archive" button in Messages panel header (opens in new tab) - - Back to Dashboard button in archive page - - - -- βœ… **Reply Panel** - - Expandable reply per message (πŸ’¬ Reply button) - - Pre-filled with @sender mention - - Channel selector - - Send button with success notification - - Auto-close expansion after send - -### Changed -- πŸ”„ `SharedData.get_snapshot()`: Now includes `'archive'` field -- πŸ”„ `MessagesPanel`: Added archive button in header row -- πŸ”„ Both entry points (`__main__.py` and `meshcore_gui.py`): Register `/archive` route - - - -### Performance -- Query: ~10ms for 10k messages with filters -- Memory: ~10KB per page (50 messages) -- No impact on main UI (separate page) - -### Known Limitations -- ~~Route visualization only works for messages in recent buffer (last 100)~~ β€” Fixed in v1.8.0: archive messages now support click-to-route via `get_message_by_hash()` fallback -- Text search is linear scan (no indexing yet) -- Sender filter exists in API but not in UI yet - ---- - -## [1.0.3] - 2026-02-07 β€” Critical Bugfix: Archive Overwrite Prevention - - -### Fixed -- πŸ›  **CRITICAL**: Fixed bug where archive was overwritten instead of appended on restart -- πŸ›  Archive now preserves existing data when read errors occur -- πŸ›  Buffer is retained for retry if existing archive cannot be read - -### Changed -- πŸ”„ `_flush_messages()`: Early return on read error instead of overwriting -- πŸ”„ `_flush_rxlog()`: Early return on read error instead of overwriting -- πŸ”„ Better error messages for version mismatch and JSON decode errors - -### Details -**Problem:** If the existing archive file had a JSON parse error or version mismatch, -the flush operation would proceed with `existing_messages = []`, effectively -overwriting all historical data with only the new buffered messages. - -**Solution:** The flush methods now: -1. Try to read existing archive first -2. If read fails (JSON error, version mismatch, IO error), abort the flush -3. Keep buffer intact for next retry -4. Only clear buffer after successful write - -**Impact:** No data loss on restart or when archive files have issues. - -### Testing -- βœ… Added `test_append_on_restart_not_overwrite()` integration test -- βœ… Verifies data is appended across multiple sessions -- βœ… All existing tests still pass - ---- - -## [1.0.2] - 2026-02-07 β€” RxLog message_hash Enhancement - - -### Added -- βœ… `message_hash` field added to `RxLogEntry` model -- βœ… RxLog entries now include message_hash for correlation with messages -- βœ… Archive JSON includes message_hash in rxlog entries - -### Changed -- πŸ”„ `events.py`: Restructured `on_rx_log()` to extract message_hash before creating RxLogEntry -- πŸ”„ `message_archive.py`: Updated rxlog archiving to include message_hash field -- πŸ”„ Tests updated to verify message_hash persistence - -### Benefits -- **Correlation**: Link RX log entries to their corresponding messages -- **Analysis**: Track which packets resulted in messages -- **Debugging**: Better troubleshooting of packet processing - ---- - -## [1.0.1] - 2026-02-07 β€” Entry Point Fix - - -### Fixed -- βœ… `meshcore_gui.py` (root entry point) now passes ble_address to SharedData -- βœ… Archive works correctly regardless of how application is started - -### Changed -- πŸ”„ Both entry points (`meshcore_gui.py` and `meshcore_gui/__main__.py`) updated - ---- - -## [1.0.0] - 2026-02-07 β€” Message & Metadata Persistence - - -### Added -- βœ… MessageArchive class for persistent storage -- βœ… Configurable retention periods (MESSAGE_RETENTION_DAYS, RXLOG_RETENTION_DAYS, CONTACT_RETENTION_DAYS) -- βœ… Automatic daily cleanup of old data -- βœ… Batch writes for performance -- βœ… Thread-safe with separate locks -- βœ… Atomic file writes -- βœ… Contact retention in DeviceCache -- βœ… Archive statistics API -- βœ… Comprehensive tests (20+ unit, 8+ integration) -- βœ… Full documentation - -### Storage Locations -- `~/.meshcore-gui/archive/
_messages.json` -- `~/.meshcore-gui/archive/
_rxlog.json` - -### Requirements Completed -- R1: All incoming messages persistent βœ… -- R2: All incoming RxLog entries persistent βœ… -- R3: Configurable retention βœ… -- R4: Automatic cleanup βœ… -- R5: Backward compatibility βœ… -- R6: Contact retention βœ… -- R7: Archive stats API βœ… - -- Fix3: Leaflet asset injection is now per page render instead of process-global, and browser bootstrap now retries until the host element, Leaflet runtime, and MeshCore panel runtime are all available. This fixes blank map containers caused by missing or late-loaded JS/CSS assets. - -- Fix5: Removed per-snapshot map invalidate calls, stopped forcing a default dark theme during map bootstrap, and added client-side interaction/resize guards so zooming stays responsive and the theme no longer jumps back during status-loop updates. - - -## 2026-03-09 map hotfix v2 -- regular map snapshots no longer carry theme state -- explicit theme changes are now handled only via the dedicated theme channel -- initial map render now sends an ensure_map command plus an immediate theme sync -- added no-op ensure_map handling in the Leaflet runtime to avoid accidental fallback behaviour diff --git a/meshcore_gui/gui/panels/map_panel.py b/meshcore_gui/gui/panels/map_panel.py index f5a8e7b..a3526dc 100644 --- a/meshcore_gui/gui/panels/map_panel.py +++ b/meshcore_gui/gui/panels/map_panel.py @@ -188,10 +188,10 @@ class MapPanel: 'meshcore-leaflet-vendor-js', 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js', function () { + ensurePanelRuntime(); ensureScript( 'meshcore-leaflet-markercluster-js', - 'https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js', - ensurePanelRuntime + 'https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js' ); } ); diff --git a/meshcore_gui/gui/route_page.py b/meshcore_gui/gui/route_page.py index 6b84c52..93e97e9 100644 --- a/meshcore_gui/gui/route_page.py +++ b/meshcore_gui/gui/route_page.py @@ -79,9 +79,8 @@ _ROUTE_MAP_ASSETS = r""" ensureStylesheet('meshcore-leaflet-panel-css', '/static/leaflet_map_panel.css'); ensureScript('meshcore-leaflet-vendor-js', 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js', function () { - ensureScript('meshcore-leaflet-markercluster-js', 'https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js', function () { - ensureScript('meshcore-leaflet-panel-js', '/static/leaflet_map_panel.js'); - }); + ensureScript('meshcore-leaflet-panel-js', '/static/leaflet_map_panel.js'); + ensureScript('meshcore-leaflet-markercluster-js', 'https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js'); }); })(); diff --git a/meshcore_gui/static/leaflet_map_panel.js b/meshcore_gui/static/leaflet_map_panel.js index dad1cee..a845f4d 100644 --- a/meshcore_gui/static/leaflet_map_panel.js +++ b/meshcore_gui/static/leaflet_map_panel.js @@ -38,7 +38,7 @@ const existing = maps.get(containerId); const host = document.getElementById(containerId); - if (!host || typeof window.L === 'undefined' || typeof window.L.markerClusterGroup !== 'function') { + if (!host || typeof window.L === 'undefined') { return null; } @@ -118,21 +118,7 @@ ).addTo(map); state.theme = 'light'; - state.layers.contacts = window.L.markerClusterGroup({ - showCoverageOnHover: false, - spiderfyOnMaxZoom: true, - removeOutsideVisibleBounds: true, - animate: false, - chunkedLoading: true, - maxClusterRadius: 50, - iconCreateFunction(cluster) { - return window.L.divIcon({ - html: '
' + cluster.getChildCount() + '
', - className: 'meshcore-marker-cluster', - iconSize: window.L.point(42, 42), - }); - }, - }).addTo(map); + state.layers.contacts = buildContactsLayer().addTo(map); } catch (error) { maps.delete(containerId); delete host.__meshcoreLeafletState; @@ -418,6 +404,29 @@ ); } + function buildContactsLayer() { + if (typeof window.L.markerClusterGroup === 'function') { + return window.L.markerClusterGroup({ + showCoverageOnHover: false, + spiderfyOnMaxZoom: true, + removeOutsideVisibleBounds: true, + animate: false, + chunkedLoading: true, + maxClusterRadius: 50, + iconCreateFunction(cluster) { + return window.L.divIcon({ + html: '
' + cluster.getChildCount() + '
', + className: 'meshcore-marker-cluster', + iconSize: window.L.point(42, 42), + }); + }, + }); + } + + console.warn('MeshCoreLeafletBoot markercluster unavailable; falling back to plain layer group'); + return window.L.layerGroup(); + } + function escapeHtml(value) { return String(value) .replaceAll('&', '&') @@ -456,9 +465,9 @@ return; } - if (typeof window.L === 'undefined' || typeof window.L.markerClusterGroup !== 'function') { + if (typeof window.L === 'undefined') { if (retries >= MAX_RETRIES) { - console.error('MeshCoreLeafletBoot timeout waiting for Leaflet markercluster', { containerId }); + console.error('MeshCoreLeafletBoot timeout waiting for Leaflet runtime', { containerId }); return; } window.setTimeout(() => { @@ -526,14 +535,28 @@ } - window.MeshCoreRouteMapBoot = function (containerId, payload) { + window.MeshCoreRouteMapBoot = function (containerId, payload, retries) { if (!containerId || !payload) { return; } + const attempt = typeof retries === 'number' ? retries : 0; const host = document.getElementById(containerId); if (!host || typeof window.L === 'undefined') { - window.setTimeout(() => window.MeshCoreRouteMapBoot(containerId, payload), RETRY_DELAY_MS); + if (attempt >= MAX_RETRIES) { + console.error('MeshCoreRouteMapBoot timeout waiting for host/runtime', { containerId }); + return; + } + window.setTimeout(() => window.MeshCoreRouteMapBoot(containerId, payload, attempt + 1), RETRY_DELAY_MS); + return; + } + + if (host.clientWidth === 0 && host.clientHeight === 0) { + if (attempt >= MAX_RETRIES) { + console.error('MeshCoreRouteMapBoot timeout waiting for visible route map host', { containerId }); + return; + } + window.setTimeout(() => window.MeshCoreRouteMapBoot(containerId, payload, attempt + 1), RETRY_DELAY_MS); return; } From 97edf22efb556630a85d33c7b52c077a807b57aa Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 16:00:26 +0100 Subject: [PATCH 08/21] HotFixRoomServer --- CHANGELOG.md | 57 ++++++++++++++++-------------------- meshcore_gui/ble/commands.py | 1 + meshcore_gui/ble/events.py | 17 +++++++---- meshcore_gui/ble/worker.py | 12 ++++++++ meshcore_gui/config.py | 2 +- 5 files changed, 52 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c9131..e79ede2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,28 @@ # 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.4] - 2026-03-12 β€” Room Server Login & Receive Reliability + +### Changed +- πŸ”„ `meshcore_gui/ble/commands.py` β€” Room login success now refreshes archived room history immediately after `LOGIN_SUCCESS`, so the room panel is populated deterministically right after a successful login +- πŸ”„ `meshcore_gui/ble/events.py` β€” `CONTACT_MSG_RECV` with `txt_type == 2` is now always treated as a Room Server message, even when the `signature` field is absent; the author name falls back gracefully instead of routing the message through the normal DM path +- πŸ”„ `meshcore_gui/ble/worker.py` β€” The global `LOGIN_SUCCESS` subscriber now also synchronizes room login state into `SharedData` and refreshes room history, so UI state no longer depends solely on the command-side waiter winning the event timing race +- πŸ”„ `meshcore_gui/config.py` β€” Version bumped to `1.13.4` + +### Fixed +- πŸ›  **Initial room login could remain pending or feel unreliable** β€” UI state now also updates from the subscribed `LOGIN_SUCCESS` event, not only from the command coroutine waiting for the same event +- πŸ›  **Room messages could be missed when `txt_type == 2` arrived without `signature`** β€” such packets are now still classified as room traffic and shown in the Room Server panel +- πŸ›  **Room history refresh after login was timing-sensitive** β€” history is now reloaded both from the command success path and from the subscribed login-success callback + +### Impact +- More reliable first login behaviour for Room Server panels +- Better chance that room history and newly arriving room messages show up immediately after login +- No intended breaking changes outside the Room Server receive/login flow + +--- ## [1.13.3] - 2026-03-12 β€” Active Panel Timer Gating ### Changed @@ -32,34 +47,15 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Ver ## [1.13.2] - 2026-03-11 β€” Map Display Bugfix ### Fixed -- πŸ›  **MAP panel blank when contacts list is empty at startup** β€” dashboard update loop - had two separate conditional map-update blocks that both silently stopped firing after - tick 1 when `data['contacts']` was empty. Map panel received no further snapshots and - remained blank indefinitely. -- πŸ›  **Leaflet map initialized on hidden (zero-size) container** β€” `processPending` in - the browser runtime called `L.map()` on the host element while it was still - `display:none` (Vue v-show, panel not yet visible). This produced a broken 0Γ—0 map - that never recovered because `ensureMap` returned the cached broken state on all - subsequent calls. Fixed by adding a `clientWidth/clientHeight` guard in `ensureMap`: - initialization is deferred until the host has real dimensions. -- πŸ›  **Route map container had no height** β€” `route_page.py` used the Tailwind class - `h-96` for the Leaflet host `
`. NiceGUI/Quasar does not include Tailwind CSS, - so `h-96` had no effect and the container rendered at height 0. Leaflet initialized - on a zero-height element and produced a blank map. -- πŸ›  **Route map not rendered when no node has GPS coordinates** β€” `_render_map` - returned early before creating the Leaflet container when `payload['nodes']` was - empty. Fixed: container is always created; a notice label is shown instead. +- πŸ›  **MAP panel blank when contacts list is empty at startup** β€” dashboard update loop had two separate conditional map-update blocks that both silently stopped firing after tick 1 when `data['contacts']` was empty. Map panel received no further snapshots and remained blank indefinitely. +- πŸ›  **Leaflet map initialized on hidden (zero-size) container** β€” `processPending` in the browser runtime called `L.map()` on the host element while it was still `display:none` (Vue v-show, panel not yet visible). This produced a broken 0Γ—0 map that never recovered because `ensureMap` returned the cached broken state on all subsequent calls. Fixed by adding a `clientWidth/clientHeight` guard in `ensureMap`: initialization is deferred until the host has real dimensions. +- πŸ›  **Route map container had no height** β€” `route_page.py` used the Tailwind class `h-96` for the Leaflet host `
`. NiceGUI/Quasar does not include Tailwind CSS, so `h-96` had no effect and the container rendered at height 0. Leaflet initialized on a zero-height element and produced a blank map. +- πŸ›  **Route map not rendered when no node has GPS coordinates** β€” `_render_map` returned early before creating the Leaflet container when `payload['nodes']` was empty. Fixed: container is always created; a notice label is shown instead. ### Changed -- πŸ”„ `meshcore_gui/static/leaflet_map_panel.js` β€” Added size guard in `ensureMap`: - returns `null` when host has `clientWidth === 0 && clientHeight === 0` and no map - state exists yet. `processPending` retries on the next tick once the panel is visible. -- πŸ”„ `meshcore_gui/gui/dashboard.py` β€” Consolidated two conditional map-update blocks - into a single unconditional update while the MAP panel is active. Added `h-96` to the - DOMCA CSS height overrides for consistency with the route page map container. -- πŸ”„ `meshcore_gui/gui/route_page.py` β€” Replaced `h-96` Tailwind class on the route - map host `
` with an explicit inline `style` (height: 24rem). Removed early - `return` guard so the Leaflet container is always created. +- πŸ”„ `meshcore_gui/static/leaflet_map_panel.js` β€” Added size guard in `ensureMap`: returns `null` when host has `clientWidth === 0 && clientHeight === 0` and no map state exists yet. `processPending` retries on the next tick once the panel is visible. +- πŸ”„ `meshcore_gui/gui/dashboard.py` β€” Consolidated two conditional map-update blocks into a single unconditional update while the MAP panel is active. Added `h-96` to the DOMCA CSS height overrides for consistency with the route page map container. +- πŸ”„ `meshcore_gui/gui/route_page.py` β€” Replaced `h-96` Tailwind class on the route map host `
` with an explicit inline `style` (height: 24rem). Removed early `return` guard so the Leaflet container is always created. ### Impact - MAP panel now renders reliably on first open regardless of contact/GPS availability @@ -67,7 +63,6 @@ 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/commands.py b/meshcore_gui/ble/commands.py index 9203d93..6858f85 100644 --- a/meshcore_gui/ble/commands.py +++ b/meshcore_gui/ble/commands.py @@ -406,6 +406,7 @@ class CommandHandler: pubkey, 'ok', f"admin={is_admin}", ) + self._shared.load_room_history(pubkey) self._shared.set_status( f"βœ… Room login OK: {room_name} β€” " f"history arriving over RF…" diff --git a/meshcore_gui/ble/events.py b/meshcore_gui/ble/events.py index 8fbf16f..65ca5c5 100644 --- a/meshcore_gui/ble/events.py +++ b/meshcore_gui/ble/events.py @@ -319,11 +319,18 @@ class EventHandler: path_len = len(path_hashes) # --- Room Server message (txt_type 2) --- - if txt_type == 2 and signature: - # Resolve actual author from signature (author pubkey prefix) - author = self._shared.get_contact_name_by_prefix(signature) + if txt_type == 2: + # Prefer the embedded author signature when available. + # Some room-history / server-side messages arrive without a + # signature; those still belong to the room and must not fall + # through to the regular DM path. + author = '' + if signature: + author = self._shared.get_contact_name_by_prefix(signature) + if not author: + author = signature[:8] if not author: - author = signature[:8] if signature else '?' + author = pubkey[:8] if pubkey else '?' self._shared.add_message(Message.incoming( author, @@ -337,7 +344,7 @@ class EventHandler: message_hash=msg_hash, )) debug_print( - f"Room msg from {author} (sig={signature}) " + f"Room msg from {author} (sig={signature or '-'}) " f"via room {pubkey[:12]}: " f"{payload.get('text', '')[:30]}" ) diff --git a/meshcore_gui/ble/worker.py b/meshcore_gui/ble/worker.py index 6aac002..7ed1751 100644 --- a/meshcore_gui/ble/worker.py +++ b/meshcore_gui/ble/worker.py @@ -258,10 +258,22 @@ class _BaseWorker(abc.ABC): # ── LOGIN_SUCCESS handler (Room Server) ─────────────────────── def _on_login_success(self, event) -> None: + """Synchronise Room Server login success into SharedData. + + This callback is intentionally independent from the command-side + ``wait_for_event(LOGIN_SUCCESS)`` path. If the library delivers the + event to subscribers before or instead of the waiter, the UI must + still transition to the logged-in state and refresh room history. + """ payload = event.payload or {} pubkey = payload.get("pubkey_prefix", "") is_admin = payload.get("is_admin", False) + detail = f"admin={is_admin}" + debug_print(f"LOGIN_SUCCESS received: pubkey={pubkey}, admin={is_admin}") + self.shared.set_room_login_state(pubkey, 'ok', detail) + if pubkey: + self.shared.load_room_history(pubkey) self.shared.set_status("βœ… Room login OK β€” messages arriving over RF…") # ── apply cache ─────────────────────────────────────────────── diff --git a/meshcore_gui/config.py b/meshcore_gui/config.py index 941b0ec..cfe4d5b 100644 --- a/meshcore_gui/config.py +++ b/meshcore_gui/config.py @@ -25,7 +25,7 @@ from typing import Any, Dict, List # ============================================================================== -VERSION: str = "1.13.3" +VERSION: str = "1.13.4" # ============================================================================== From dbecf7ac2456cc4c0739d7b160fa366abf2c259a Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 16:23:56 +0100 Subject: [PATCH 09/21] HotFixRoomServer --- CHANGELOG.md | 57 +++++++++++++++++++++++---------- meshcore_gui/ble/commands.py | 61 +++++++++++++++++++++++++++++++++++- meshcore_gui/ble/events.py | 33 ++++++++++++------- meshcore_gui/ble/worker.py | 11 +------ 4 files changed, 122 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e79ede2..da9ed5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,26 +1,29 @@ # 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/). --- -## [1.13.4] - 2026-03-12 β€” Room Server Login & Receive Reliability +## [1.13.4] - 2026-03-12 β€” Room Server USB Login & Fetch Fix ### Changed -- πŸ”„ `meshcore_gui/ble/commands.py` β€” Room login success now refreshes archived room history immediately after `LOGIN_SUCCESS`, so the room panel is populated deterministically right after a successful login -- πŸ”„ `meshcore_gui/ble/events.py` β€” `CONTACT_MSG_RECV` with `txt_type == 2` is now always treated as a Room Server message, even when the `signature` field is absent; the author name falls back gracefully instead of routing the message through the normal DM path -- πŸ”„ `meshcore_gui/ble/worker.py` β€” The global `LOGIN_SUCCESS` subscriber now also synchronizes room login state into `SharedData` and refreshes room history, so UI state no longer depends solely on the command-side waiter winning the event timing race +- πŸ”„ `meshcore_gui/ble/commands.py` β€” After `LOGIN_SUCCESS`, the room login flow now starts a bounded background `get_msg()` sync loop so serial/USB sessions actively drain queued room messages instead of relying on a single defensive fetch +- πŸ”„ `meshcore_gui/ble/events.py` β€” Room messages are now classified on `txt_type == 2` even when the `signature` field is absent; sender/room pubkeys also use broader payload fallbacks for room traffic +- πŸ”„ `meshcore_gui/ble/worker.py` β€” Global `LOGIN_SUCCESS` handling now updates `room_login_states` and refreshes cached room history in `SharedData` - πŸ”„ `meshcore_gui/config.py` β€” Version bumped to `1.13.4` ### Fixed -- πŸ›  **Initial room login could remain pending or feel unreliable** β€” UI state now also updates from the subscribed `LOGIN_SUCCESS` event, not only from the command coroutine waiting for the same event -- πŸ›  **Room messages could be missed when `txt_type == 2` arrived without `signature`** β€” such packets are now still classified as room traffic and shown in the Room Server panel -- πŸ›  **Room history refresh after login was timing-sensitive** β€” history is now reloaded both from the command success path and from the subscribed login-success callback +- πŸ›  **USB/serial room login showed only app-sent messages** β€” After login, the app now keeps polling queued room messages for a short window so messages from other room participants are actually fetched +- πŸ›  **Incoming room messages without `signature` were misclassified** β€” `CONTACT_MSG_RECV` packets with `txt_type == 2` no longer fall back to DM handling just because the room server omitted `signature` +- πŸ›  **Room login UI state could depend on one code path** β€” Worker-side `LOGIN_SUCCESS` processing now reinforces the room state update even when the command-side wait path is not the only consumer ### Impact -- More reliable first login behaviour for Room Server panels -- Better chance that room history and newly arriving room messages show up immediately after login -- No intended breaking changes outside the Room Server receive/login flow +- Faster and more reliable room history retrieval on USB/serial setups +- Room traffic from other users has a better chance of appearing in the Room Server panel immediately after login +- No intended regression for DM or normal channel message handling --- ## [1.13.3] - 2026-03-12 β€” Active Panel Timer Gating @@ -47,15 +50,34 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Ver ## [1.13.2] - 2026-03-11 β€” Map Display Bugfix ### Fixed -- πŸ›  **MAP panel blank when contacts list is empty at startup** β€” dashboard update loop had two separate conditional map-update blocks that both silently stopped firing after tick 1 when `data['contacts']` was empty. Map panel received no further snapshots and remained blank indefinitely. -- πŸ›  **Leaflet map initialized on hidden (zero-size) container** β€” `processPending` in the browser runtime called `L.map()` on the host element while it was still `display:none` (Vue v-show, panel not yet visible). This produced a broken 0Γ—0 map that never recovered because `ensureMap` returned the cached broken state on all subsequent calls. Fixed by adding a `clientWidth/clientHeight` guard in `ensureMap`: initialization is deferred until the host has real dimensions. -- πŸ›  **Route map container had no height** β€” `route_page.py` used the Tailwind class `h-96` for the Leaflet host `
`. NiceGUI/Quasar does not include Tailwind CSS, so `h-96` had no effect and the container rendered at height 0. Leaflet initialized on a zero-height element and produced a blank map. -- πŸ›  **Route map not rendered when no node has GPS coordinates** β€” `_render_map` returned early before creating the Leaflet container when `payload['nodes']` was empty. Fixed: container is always created; a notice label is shown instead. +- πŸ›  **MAP panel blank when contacts list is empty at startup** β€” dashboard update loop + had two separate conditional map-update blocks that both silently stopped firing after + tick 1 when `data['contacts']` was empty. Map panel received no further snapshots and + remained blank indefinitely. +- πŸ›  **Leaflet map initialized on hidden (zero-size) container** β€” `processPending` in + the browser runtime called `L.map()` on the host element while it was still + `display:none` (Vue v-show, panel not yet visible). This produced a broken 0Γ—0 map + that never recovered because `ensureMap` returned the cached broken state on all + subsequent calls. Fixed by adding a `clientWidth/clientHeight` guard in `ensureMap`: + initialization is deferred until the host has real dimensions. +- πŸ›  **Route map container had no height** β€” `route_page.py` used the Tailwind class + `h-96` for the Leaflet host `
`. NiceGUI/Quasar does not include Tailwind CSS, + so `h-96` had no effect and the container rendered at height 0. Leaflet initialized + on a zero-height element and produced a blank map. +- πŸ›  **Route map not rendered when no node has GPS coordinates** β€” `_render_map` + returned early before creating the Leaflet container when `payload['nodes']` was + empty. Fixed: container is always created; a notice label is shown instead. ### Changed -- πŸ”„ `meshcore_gui/static/leaflet_map_panel.js` β€” Added size guard in `ensureMap`: returns `null` when host has `clientWidth === 0 && clientHeight === 0` and no map state exists yet. `processPending` retries on the next tick once the panel is visible. -- πŸ”„ `meshcore_gui/gui/dashboard.py` β€” Consolidated two conditional map-update blocks into a single unconditional update while the MAP panel is active. Added `h-96` to the DOMCA CSS height overrides for consistency with the route page map container. -- πŸ”„ `meshcore_gui/gui/route_page.py` β€” Replaced `h-96` Tailwind class on the route map host `
` with an explicit inline `style` (height: 24rem). Removed early `return` guard so the Leaflet container is always created. +- πŸ”„ `meshcore_gui/static/leaflet_map_panel.js` β€” Added size guard in `ensureMap`: + returns `null` when host has `clientWidth === 0 && clientHeight === 0` and no map + state exists yet. `processPending` retries on the next tick once the panel is visible. +- πŸ”„ `meshcore_gui/gui/dashboard.py` β€” Consolidated two conditional map-update blocks + into a single unconditional update while the MAP panel is active. Added `h-96` to the + DOMCA CSS height overrides for consistency with the route page map container. +- πŸ”„ `meshcore_gui/gui/route_page.py` β€” Replaced `h-96` Tailwind class on the route + map host `
` with an explicit inline `style` (height: 24rem). Removed early + `return` guard so the Leaflet container is always created. ### Impact - MAP panel now renders reliably on first open regardless of contact/GPS availability @@ -63,6 +85,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/commands.py b/meshcore_gui/ble/commands.py index 6858f85..d1bae49 100644 --- a/meshcore_gui/ble/commands.py +++ b/meshcore_gui/ble/commands.py @@ -35,6 +35,7 @@ class CommandHandler: self._mc = mc self._shared = shared self._cache = cache + self._room_sync_tasks: Dict[str, asyncio.Task] = {} # Handler registry β€” add new commands here (OCP) self._handlers: Dict[str, object] = { @@ -406,7 +407,6 @@ class CommandHandler: pubkey, 'ok', f"admin={is_admin}", ) - self._shared.load_room_history(pubkey) self._shared.set_status( f"βœ… Room login OK: {room_name} β€” " f"history arriving over RF…" @@ -426,6 +426,8 @@ class CommandHandler: except Exception as exc: debug_print(f"login_room: defensive get_msg() error: {exc}") + self._start_room_sync(pubkey, room_name) + else: self._shared.set_room_login_state( pubkey, 'fail', @@ -552,6 +554,63 @@ class CommandHandler: ) debug_print(f"send_room_msg exception: {exc}") + def _cancel_room_sync(self, pubkey: str) -> None: + """Cancel an active background room-history sync task.""" + task = self._room_sync_tasks.pop(pubkey, None) + if task and not task.done(): + task.cancel() + + def _start_room_sync(self, pubkey: str, room_name: str) -> None: + """Start a bounded background fetch loop for room history.""" + self._cancel_room_sync(pubkey) + self._room_sync_tasks[pubkey] = asyncio.create_task( + self._sync_room_history(pubkey, room_name) + ) + + async def _sync_room_history(self, pubkey: str, room_name: str) -> None: + """Fetch queued room messages for a short period after login. + + On some serial/USB setups the SDK's auto-message fetching is + not sufficient to drain the room backlog promptly after + ``LOGIN_SUCCESS``. This bounded loop polls ``get_msg()`` for a + short window so historical room messages from other users are + actually pulled into the app. + """ + idle_errors = 0 + try: + for attempt in range(24): + try: + result = await self._mc.commands.get_msg() + result_type = getattr(result, 'type', None) + if result_type == EventType.ERROR: + idle_errors += 1 + debug_print( + f"room_sync: get_msg ERROR for {room_name} " + f"(attempt {attempt + 1}/24, idle={idle_errors})" + ) + else: + idle_errors = 0 + debug_print( + f"room_sync: get_msg fetched data for {room_name} " + f"(attempt {attempt + 1}/24)" + ) + except Exception as exc: + idle_errors += 1 + debug_print( + f"room_sync: get_msg exception for {room_name}: {exc}" + ) + + if idle_errors >= 4: + break + + await asyncio.sleep(2.0) + except asyncio.CancelledError: + debug_print(f"room_sync: cancelled for {room_name}") + raise + finally: + self._shared.load_room_history(pubkey) + self._room_sync_tasks.pop(pubkey, None) + # ------------------------------------------------------------------ # Callback for refresh (set by SerialWorker after construction) # ------------------------------------------------------------------ diff --git a/meshcore_gui/ble/events.py b/meshcore_gui/ble/events.py index 65ca5c5..e5cd220 100644 --- a/meshcore_gui/ble/events.py +++ b/meshcore_gui/ble/events.py @@ -320,17 +320,26 @@ class EventHandler: # --- Room Server message (txt_type 2) --- if txt_type == 2: - # Prefer the embedded author signature when available. - # Some room-history / server-side messages arrive without a - # signature; those still belong to the room and must not fall - # through to the regular DM path. + room_pubkey = ( + payload.get('room_pubkey') + or payload.get('receiver_pubkey') + or payload.get('recipient_pubkey') + or payload.get('pubkey') + or pubkey + ) + author_prefix = ( + signature + or payload.get('sender_pubkey_prefix', '') + or payload.get('sender_pubkey', '') + or payload.get('sender_prefix', '') + ) author = '' - if signature: - author = self._shared.get_contact_name_by_prefix(signature) - if not author: - author = signature[:8] + if author_prefix: + author = self._shared.get_contact_name_by_prefix(author_prefix) if not author: - author = pubkey[:8] if pubkey else '?' + author = payload.get('sender_name', '') or payload.get('name', '') + if not author: + author = author_prefix[:8] if author_prefix else room_pubkey[:8] if room_pubkey else '?' self._shared.add_message(Message.incoming( author, @@ -338,14 +347,14 @@ class EventHandler: None, snr=self._extract_snr(payload), path_len=path_len, - sender_pubkey=pubkey, + sender_pubkey=room_pubkey, path_hashes=path_hashes, path_names=path_names, message_hash=msg_hash, )) debug_print( - f"Room msg from {author} (sig={signature or '-'}) " - f"via room {pubkey[:12]}: " + f"Room msg from {author} (sig={signature}) " + f"via room {room_pubkey[:12]}: " f"{payload.get('text', '')[:30]}" ) return diff --git a/meshcore_gui/ble/worker.py b/meshcore_gui/ble/worker.py index 7ed1751..af9965b 100644 --- a/meshcore_gui/ble/worker.py +++ b/meshcore_gui/ble/worker.py @@ -258,21 +258,12 @@ class _BaseWorker(abc.ABC): # ── LOGIN_SUCCESS handler (Room Server) ─────────────────────── def _on_login_success(self, event) -> None: - """Synchronise Room Server login success into SharedData. - - This callback is intentionally independent from the command-side - ``wait_for_event(LOGIN_SUCCESS)`` path. If the library delivers the - event to subscribers before or instead of the waiter, the UI must - still transition to the logged-in state and refresh room history. - """ payload = event.payload or {} pubkey = payload.get("pubkey_prefix", "") is_admin = payload.get("is_admin", False) - detail = f"admin={is_admin}" - debug_print(f"LOGIN_SUCCESS received: pubkey={pubkey}, admin={is_admin}") - self.shared.set_room_login_state(pubkey, 'ok', detail) if pubkey: + 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…") From 49c8fb338e724980408b82e1db090157821916c4 Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 16:40:58 +0100 Subject: [PATCH 10/21] HotFixRoom --- CHANGELOG.md | 42 ++++++++++++------------- meshcore_gui/ble/commands.py | 60 ------------------------------------ meshcore_gui/ble/events.py | 1 + 3 files changed, 20 insertions(+), 83 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da9ed5b..7d6c585 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,30 +1,27 @@ -# CHANGELOG +## [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/). ---- -## [1.13.4] - 2026-03-12 β€” Room Server USB Login & Fetch Fix - -### Changed -- πŸ”„ `meshcore_gui/ble/commands.py` β€” After `LOGIN_SUCCESS`, the room login flow now starts a bounded background `get_msg()` sync loop so serial/USB sessions actively drain queued room messages instead of relying on a single defensive fetch -- πŸ”„ `meshcore_gui/ble/events.py` β€” Room messages are now classified on `txt_type == 2` even when the `signature` field is absent; sender/room pubkeys also use broader payload fallbacks for room traffic -- πŸ”„ `meshcore_gui/ble/worker.py` β€” Global `LOGIN_SUCCESS` handling now updates `room_login_states` and refreshes cached room history in `SharedData` -- πŸ”„ `meshcore_gui/config.py` β€” Version bumped to `1.13.4` - -### Fixed -- πŸ›  **USB/serial room login showed only app-sent messages** β€” After login, the app now keeps polling queued room messages for a short window so messages from other room participants are actually fetched -- πŸ›  **Incoming room messages without `signature` were misclassified** β€” `CONTACT_MSG_RECV` packets with `txt_type == 2` no longer fall back to DM handling just because the room server omitted `signature` -- πŸ›  **Room login UI state could depend on one code path** β€” Worker-side `LOGIN_SUCCESS` processing now reinforces the room state update even when the command-side wait path is not the only consumer - -### Impact -- Faster and more reliable room history retrieval on USB/serial setups -- Room traffic from other users has a better chance of appearing in the Room Server panel immediately after login -- No intended regression for DM or normal channel message handling - --- ## [1.13.3] - 2026-03-12 β€” Active Panel Timer Gating @@ -85,7 +82,6 @@ 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/commands.py b/meshcore_gui/ble/commands.py index d1bae49..9203d93 100644 --- a/meshcore_gui/ble/commands.py +++ b/meshcore_gui/ble/commands.py @@ -35,7 +35,6 @@ class CommandHandler: self._mc = mc self._shared = shared self._cache = cache - self._room_sync_tasks: Dict[str, asyncio.Task] = {} # Handler registry β€” add new commands here (OCP) self._handlers: Dict[str, object] = { @@ -426,8 +425,6 @@ class CommandHandler: except Exception as exc: debug_print(f"login_room: defensive get_msg() error: {exc}") - self._start_room_sync(pubkey, room_name) - else: self._shared.set_room_login_state( pubkey, 'fail', @@ -554,63 +551,6 @@ class CommandHandler: ) debug_print(f"send_room_msg exception: {exc}") - def _cancel_room_sync(self, pubkey: str) -> None: - """Cancel an active background room-history sync task.""" - task = self._room_sync_tasks.pop(pubkey, None) - if task and not task.done(): - task.cancel() - - def _start_room_sync(self, pubkey: str, room_name: str) -> None: - """Start a bounded background fetch loop for room history.""" - self._cancel_room_sync(pubkey) - self._room_sync_tasks[pubkey] = asyncio.create_task( - self._sync_room_history(pubkey, room_name) - ) - - async def _sync_room_history(self, pubkey: str, room_name: str) -> None: - """Fetch queued room messages for a short period after login. - - On some serial/USB setups the SDK's auto-message fetching is - not sufficient to drain the room backlog promptly after - ``LOGIN_SUCCESS``. This bounded loop polls ``get_msg()`` for a - short window so historical room messages from other users are - actually pulled into the app. - """ - idle_errors = 0 - try: - for attempt in range(24): - try: - result = await self._mc.commands.get_msg() - result_type = getattr(result, 'type', None) - if result_type == EventType.ERROR: - idle_errors += 1 - debug_print( - f"room_sync: get_msg ERROR for {room_name} " - f"(attempt {attempt + 1}/24, idle={idle_errors})" - ) - else: - idle_errors = 0 - debug_print( - f"room_sync: get_msg fetched data for {room_name} " - f"(attempt {attempt + 1}/24)" - ) - except Exception as exc: - idle_errors += 1 - debug_print( - f"room_sync: get_msg exception for {room_name}: {exc}" - ) - - if idle_errors >= 4: - break - - await asyncio.sleep(2.0) - except asyncio.CancelledError: - debug_print(f"room_sync: cancelled for {room_name}") - raise - finally: - self._shared.load_room_history(pubkey) - self._room_sync_tasks.pop(pubkey, None) - # ------------------------------------------------------------------ # Callback for refresh (set by SerialWorker after construction) # ------------------------------------------------------------------ diff --git a/meshcore_gui/ble/events.py b/meshcore_gui/ble/events.py index e5cd220..cf1150f 100644 --- a/meshcore_gui/ble/events.py +++ b/meshcore_gui/ble/events.py @@ -333,6 +333,7 @@ class EventHandler: or payload.get('sender_pubkey', '') or payload.get('sender_prefix', '') ) + author = '' if author_prefix: author = self._shared.get_contact_name_by_prefix(author_prefix) From 3cf14f8758345c7fb4118edd629485ae1ebb74e2 Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 17:50:44 +0100 Subject: [PATCH 11/21] HotFix --- meshcore_gui/ble/events.py | 39 +++++++++++++++++++------------------- meshcore_gui/ble/worker.py | 9 +++++++-- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/meshcore_gui/ble/events.py b/meshcore_gui/ble/events.py index cf1150f..7105179 100644 --- a/meshcore_gui/ble/events.py +++ b/meshcore_gui/ble/events.py @@ -302,6 +302,13 @@ class EventHandler: 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())}") @@ -320,27 +327,21 @@ class EventHandler: # --- Room Server message (txt_type 2) --- if txt_type == 2: - room_pubkey = ( - payload.get('room_pubkey') - or payload.get('receiver_pubkey') - or payload.get('recipient_pubkey') - or payload.get('pubkey') - or pubkey - ) - author_prefix = ( - signature - or payload.get('sender_pubkey_prefix', '') - or payload.get('sender_pubkey', '') - or payload.get('sender_prefix', '') - ) - + # 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 author_prefix: - author = self._shared.get_contact_name_by_prefix(author_prefix) + if signature: + author = self._shared.get_contact_name_by_prefix(signature) + if not author: + author = signature[:8] if not author: - author = payload.get('sender_name', '') or payload.get('name', '') - if not author: - author = author_prefix[:8] if author_prefix else room_pubkey[:8] if room_pubkey else '?' + author = ( + payload.get('sender') + or payload.get('name') + or payload.get('author') + or '?' + ) self._shared.add_message(Message.incoming( author, diff --git a/meshcore_gui/ble/worker.py b/meshcore_gui/ble/worker.py index af9965b..449db10 100644 --- a/meshcore_gui/ble/worker.py +++ b/meshcore_gui/ble/worker.py @@ -259,13 +259,18 @@ class _BaseWorker(abc.ABC): def _on_login_success(self, event) -> None: payload = event.payload or {} - pubkey = payload.get("pubkey_prefix", "") + pubkey = ( + payload.get("room_pubkey") + or payload.get("pubkey_prefix") + or payload.get("receiver") + 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.load_room_history(pubkey) - self.shared.set_status("βœ… Room login OK β€” messages arriving over RF…") # ── apply cache ─────────────────────────────────────────────── From 11dac3e8751e799e8669f9147ce17ceb2f4f2d15 Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 18:00:42 +0100 Subject: [PATCH 12/21] 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 ─────────────────────────────────────────────── From bf031f857ff93e672e4e84d0046352976fd140cb Mon Sep 17 00:00:00 2001 From: pe1hvh Date: Thu, 12 Mar 2026 18:12:13 +0100 Subject: [PATCH 13/21] HotFix --- CHANGELOG.md | 19 + meshcore_gui/ble/events.py | 111 ++-- meshcore_gui/ble/events.py.bak | 379 +++++++++++++ meshcore_gui/ble/worker.py | 30 +- meshcore_gui/ble/worker.py.bak | 964 +++++++++++++++++++++++++++++++++ 5 files changed, 1437 insertions(+), 66 deletions(-) create mode 100644 meshcore_gui/ble/events.py.bak create mode 100644 meshcore_gui/ble/worker.py.bak diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c9131..7ae3259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +## [1.13.4] - 2026-03-12 β€” Room Server message classification fix + +### Fixed +- πŸ›  **Incoming room messages from other participants could be misclassified as normal DMs** β€” `CONTACT_MSG_RECV` room detection now keys on `txt_type == 2` instead of requiring `signature`. +- πŸ›  **Incoming room traffic could be attached to the wrong key** β€” room message handling now prefers `room_pubkey` / receiver-style payload keys before falling back to `pubkey_prefix`. +- πŸ›  **Room login UI could stay out of sync with the actual server-confirmed state** β€” `LOGIN_SUCCESS` now updates `room_login_states` and refreshes room history using the resolved room key. + +### Changed +- πŸ”„ `meshcore_gui/ble/events.py` β€” Broadened room payload parsing and added payload-key debug logging for incoming room traffic. +- πŸ”„ `meshcore_gui/ble/worker.py` β€” `LOGIN_SUCCESS` handler now updates per-room login state and refreshes cached room history. +- πŸ”„ `meshcore_gui/config.py` β€” Version kept at `1.13.4`. + +### Impact +- Keeps the existing Room Server panel logic intact. +- Fix is limited to room event classification and room login confirmation handling. +- No intended behavioural change for ordinary DMs or channel messages. + +--- + # 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/). + + +--- + +> **πŸ“ˆ Performance note β€” v1.13.1 through v1.13.4** +> Although versions 1.13.1–1.13.4 were released as targeted bugfix releases, the +> cumulative effect of the fixes delivered a significant performance improvement: +> +> - **v1.13.1** β€” Bot non-response fix eliminated a silent failure path that caused +> repeated dedup-marked command re-evaluation on every message tick. +> - **v1.13.2** β€” Map display fixes prevented Leaflet from being initialized on hidden +> zero-size containers, removing a source of repeated failed bootstrap retries and +> associated DOM churn. +> - **v1.13.3** β€” Active panel timer gating reduced the 500 ms dashboard update work to +> only the currently visible panel, cutting unnecessary UI updates and background +> redraw load substantially β€” especially noticeable over VPN or on slower hardware. +> - **v1.13.4** β€” Room Server event classification fix and sender name resolution removed +> redundant fallback processing paths and reduced per-tick contact lookup overhead. +> +> Users upgrading from v1.12.x or earlier will notice noticeably faster panel switching, +> lower CPU usage during idle operation, and more stable map rendering. + +--- ## [1.13.4] - 2026-03-12 β€” Room Server message classification fix ### Fixed @@ -17,17 +49,7 @@ - No intended behavioural change for ordinary DMs or channel messages. --- - -# 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 @@ -87,7 +109,6 @@ 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