From 87d75aafc0e97b40bed901c64355036f345d3ea6 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 16 Jul 2026 20:30:20 +0200 Subject: [PATCH] gui: fix connection history retaining stale counter-based ID _push_lru ran right after connect, before MON-VER resolves the device name, so history entries kept the placeholder ID forever. Dedupe LRU entries by connection endpoint (host/port, serial port, or file path) instead of by receiver_id, and re-push once the device name is known so the corrected entry replaces the placeholder instead of duplicating it. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01XM4FNUjhu9x8df5Dp1hHvd --- gui/connection_tab.py | 2 ++ gui/data_model.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gui/connection_tab.py b/gui/connection_tab.py index 33cf0e4..7fc5cc6 100644 --- a/gui/connection_tab.py +++ b/gui/connection_tab.py @@ -356,3 +356,5 @@ class ConnectionTab(QWidget): if row.get_receiver_id() == rid: row.set_version_info(device_id, sw_version) break + if device_id: + self._refresh_history_combo() diff --git a/gui/data_model.py b/gui/data_model.py index 6d84e6c..f4ad247 100644 --- a/gui/data_model.py +++ b/gui/data_model.py @@ -77,6 +77,13 @@ class ConnectionConfig: return f"{self.receiver_id} [{self.serial_port} @ {self.baud_rate}]" return f"{self.receiver_id} [file: {os.path.basename(self.file_path)}]" + def endpoint_key(self): + if self.conn_type == 'tcp': + return ('tcp', self.host, self.port) + if self.conn_type == 'serial': + return ('serial', self.serial_port, self.baud_rate) + return ('file', self.file_path) + def to_dict(self): return dataclasses.asdict(self) @@ -135,8 +142,8 @@ class ReceiverManager(QObject): pass def _push_lru(self, config: ConnectionConfig): - key = config.display_str() - self._lru = [c for c in self._lru if c.display_str() != key] + key = config.endpoint_key() + self._lru = [c for c in self._lru if c.endpoint_key() != key] self._lru.insert(0, config) self._lru = self._lru[:LRU_MAX] self._save_lru() @@ -333,3 +340,7 @@ class ReceiverManager(QObject): if state: state.device_id = device_id state.sw_version = sw_version + config = self._configs.get(rid) + if config and device_id: + config.receiver_id = device_id + self._push_lru(config)