From ebb7fd090fe31731a5e20a8920e318f8473aaf49 Mon Sep 17 00:00:00 2001 From: Doug Borg Date: Tue, 10 Mar 2026 14:38:58 -0600 Subject: [PATCH] Address review: stable tie-breaker and accurate log message - Add node id tie-breaker to sort comparator so equal-distance nodes have deterministic ordering across renders (prevents flicker) - Log validNodesCount instead of allNodes.length so the message reflects the actual post-filter count Co-Authored-By: Claude Opus 4.6 --- lib/widgets/map/map_data_manager.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/widgets/map/map_data_manager.dart b/lib/widgets/map/map_data_manager.dart index 4ddf057..fdb0249 100644 --- a/lib/widgets/map/map_data_manager.dart +++ b/lib/widgets/map/map_data_manager.dart @@ -88,7 +88,8 @@ class MapDataManager { (a.coord.longitude - centerLng) * (a.coord.longitude - centerLng); final distB = (b.coord.latitude - centerLat) * (b.coord.latitude - centerLat) + (b.coord.longitude - centerLng) * (b.coord.longitude - centerLng); - return distA.compareTo(distB); + final cmp = distA.compareTo(distB); + return cmp != 0 ? cmp : a.id.compareTo(b.id); }); nodesToRender = validNodes.take(maxNodes).toList(); isLimitActive = true; @@ -107,7 +108,7 @@ class MapDataManager { if (isLimitActive != _lastNodeLimitState) { _lastNodeLimitState = isLimitActive; if (isLimitActive) { - debugPrint('[MapDataManager] Node limit active: rendering ${nodesToRender.length} of ${allNodes.length} devices'); + debugPrint('[MapDataManager] Node limit active: rendering ${nodesToRender.length} of $validNodesCount valid devices'); } // Schedule callback after build completes to avoid setState during build WidgetsBinding.instance.addPostFrameCallback((_) {