Add path tracing functionality to map screen#165
Conversation
wel97459
commented
Feb 12, 2026
- Implemented path tracing feature in the map screen, allowing users to add nodes to a path and visualize it on the map as they select nodes.
- Added buttons for starting path tracing, removing the last node, and running the path trace.
- Introduced a new overlay to display current path information and distance.
- Updated localization files for multiple languages to include new strings related to path tracing.
- Refactored map rendering logic to accommodate path tracing visuals.
- Implemented path tracing feature in the map screen, allowing users to add nodes to a path and visualize it on the map. - Added buttons for starting path tracing, removing the last node, and running the path trace. - Introduced a new overlay to display current path information and distance. - Updated localization files for multiple languages to include new strings related to path tracing. - Refactored map rendering logic to accommodate path tracing visuals.
There was a problem hiding this comment.
Pull request overview
Adds an in-map “path trace” builder workflow so users can select nodes on the main map, visualize the selected path, and then run an actual trace in the dedicated Path Trace screen. Also updates localization resources to support new UI strings.
Changes:
- Add path-building mode to
MapScreen(select nodes to build a path, show overlay, run trace). - Refactor
PathTraceMapScreenmap rendering and distance formatting utilities. - Update ARB + generated localization files with new path-tracing strings (and remove some duplicate entries).
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/screens/path_trace_map.dart | Extracts distance helpers, refactors map widget build, improves unknown-hop labeling, adds additional error handling. |
| lib/screens/map_screen.dart | Adds path-building mode, overlay UI (tap-to-add, remove last, run trace), and polyline rendering during path build. |
| lib/l10n/app_en.arb | Adds new strings for map path building + clear tooltip. |
| lib/l10n/app_de.arb | Adds new strings; also removes duplicate entries/normalizes formatting. |
| lib/l10n/app_es.arb | Adds new strings; also removes duplicate entries/normalizes formatting. |
| lib/l10n/app_fr.arb | Adds new strings for map path building. |
| lib/l10n/app_it.arb | Adds new strings for map path building. |
| lib/l10n/app_nl.arb | Adds new strings for map path building. |
| lib/l10n/app_pl.arb | Adds new strings for map path building. |
| lib/l10n/app_pt.arb | Adds new strings for map path building. |
| lib/l10n/app_ru.arb | Adds new strings for map path building. |
| lib/l10n/app_sk.arb | Adds new strings for map path building. |
| lib/l10n/app_sl.arb | Adds new strings for map path building. |
| lib/l10n/app_sv.arb | Adds new strings for map path building. |
| lib/l10n/app_uk.arb | Adds new strings for map path building. |
| lib/l10n/app_zh.arb | Adds new strings for map path building. |
| lib/l10n/app_bg.arb | Adds new strings for map path building. |
| lib/l10n/app_localizations.dart | Adds new localization getters for map path-building + clear tooltip. |
| lib/l10n/app_localizations_en.dart | Implements new localization getters. |
| lib/l10n/app_localizations_de.dart | Implements new localization getters. |
| lib/l10n/app_localizations_es.dart | Implements new localization getters. |
| lib/l10n/app_localizations_fr.dart | Implements new localization getters. |
| lib/l10n/app_localizations_it.dart | Implements new localization getters. |
| lib/l10n/app_localizations_nl.dart | Implements new localization getters. |
| lib/l10n/app_localizations_pl.dart | Implements new localization getters. |
| lib/l10n/app_localizations_pt.dart | Implements new localization getters. |
| lib/l10n/app_localizations_ru.dart | Implements new localization getters. |
| lib/l10n/app_localizations_sk.dart | Implements new localization getters. |
| lib/l10n/app_localizations_sl.dart | Implements new localization getters. |
| lib/l10n/app_localizations_sv.dart | Implements new localization getters. |
| lib/l10n/app_localizations_uk.dart | Implements new localization getters. |
| lib/l10n/app_localizations_zh.dart | Implements new localization getters. |
| lib/l10n/app_localizations_bg.dart | Implements new localization getters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import 'package:latlong2/latlong.dart'; | ||
| import 'package:meshcore_open/screens/path_trace_map.dart'; | ||
| import 'package:provider/provider.dart'; |
There was a problem hiding this comment.
map_screen.dart imports path_trace_map.dart just to reuse getPathDistanceMeters / formatDistance. This introduces an unnecessary dependency on a UI screen file and makes reuse harder. Consider moving these helpers into a small shared utility (e.g., lib/utils/path_distance.dart) and importing that instead.
There was a problem hiding this comment.
This is not true there is a navigation to PathTraceMapScreen method.
| _polylines.clear(); | ||
| _polylines.addAll( | ||
| _points.length > 1 | ||
| ? [ | ||
| Polyline( |
There was a problem hiding this comment.
build() is mutating state by clearing/rebuilding _polylines on every rebuild. This makes the widget harder to reason about and can lead to subtle issues if build is triggered often. Prefer deriving a local final polylines = ... from _points (without mutating state), or update _polylines only inside setState when _points changes.
| _pathTrace.add( | ||
| contact.publicKey[0], | ||
| ); // Add first 16 bytes of public key to path trace | ||
| _points.add(LatLng(contact.latitude!, contact.longitude!)); |
There was a problem hiding this comment.
The inline comment says “Add first 16 bytes of public key”, but the code only appends contact.publicKey[0] (1 byte). Please correct the comment to match the actual behavior (or adjust the logic if the intent really is 16 bytes).
| /// No description provided for @pathTrace_clearTooltip. | ||
| /// | ||
| /// In en, this message translates to: | ||
| /// **'Clear path.'** | ||
| String get pathTrace_clearTooltip; | ||
|
|
There was a problem hiding this comment.
pathTrace_clearTooltip is added to localizations, but it is not referenced anywhere in the Dart codebase. Either wire this up to the intended UI (e.g., a clear-path action/tooltip) or remove the string to avoid unused translations and translator churn.
| /// No description provided for @pathTrace_clearTooltip. | |
| /// | |
| /// In en, this message translates to: | |
| /// **'Clear path.'** | |
| String get pathTrace_clearTooltip; |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1afd6c9a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| MaterialPageRoute( | ||
| builder: (context) => PathTraceMapScreen( | ||
| title: l10n.contacts_pathTrace, | ||
| path: Uint8List.fromList(_pathTrace), |
There was a problem hiding this comment.
Enforce max trace path length before sending request
The selected path is passed straight through as Uint8List.fromList(_pathTrace) with no size check, so users can keep adding nodes until the trace payload exceeds the protocol frame budget (trace header + payload, with frames capped at 172 bytes). In larger meshes this can produce oversized trace requests that are rejected or truncated by the device transport; add a guard and user feedback before allowing/sending paths beyond the supported length.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
To use Codex here, create an environment for this repo.
There was a problem hiding this comment.
Summary
- Added explicit frame-budget constants in
MapScreenso path trace payload sizing is derived from protocol max frame size (172) minus trace request overhead ([cmd][tag x4][auth x4][flag]). lib/screens/map_screen.dartL48-L51 lib/connector/meshcore_protocol.dartL220 lib/connector/meshcore_protocol.dartL741-L750 - Added a guard in
_addToPathto stop adding nodes when the trace path reaches the supported payload limit, and show user feedback viaSnackBarinstead of allowing an oversized request path to be built. lib/screens/map_screen.dartL1456-L1466 - Added a defensive guard before launching
PathTraceMapScreento prevent sending if path length is oversized, with snackbar feedback for the user. lib/screens/map_screen.dartL1530-L1540 lib/screens/map_screen.dartL1542-L1549 - Corrected the stale inline comment to reflect the actual behavior (1-byte public key hash prefix, not 16 bytes). lib/screens/map_screen.dartL1469-L1472
- Committed changes as
08cc9b0and created a follow-up PR via themake_prtool.
Testing
- ✅
git diff -- lib/screens/map_screen.dart - ✅
git status --short ⚠️ ~/flutter/bin/dart format lib/screens/map_screen.dart(Flutter/Dart SDK path unavailable in this environment:/root/flutter/bin/dartnot found)
| onLongPress: () => | ||
| _isBuildingPathTrace ? _showNodeInfo(context, contact) : null, |
There was a problem hiding this comment.
Avoid swallowing long-presses when path mode is off
This always installs a marker onLongPress callback, but when _isBuildingPathTrace is false the callback just returns null. That still captures long-press gestures on top of markers, so map-level long-press behavior (like the share-marker flow on the map) no longer triggers in those spots. Make the handler itself null when path tracing is inactive instead of returning null from an active handler.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
To use Codex here, create an environment for this repo.
There was a problem hiding this comment.
Summary
- Updated marker long-press wiring in
MapScreensoGestureDetector.onLongPressis only assigned when_isBuildingPathTraceis active; otherwise it isnull. This prevents markers from swallowing long-press gestures when path tracing is off while preserving the path-mode behavior. lib/screens/map_screen.dartL468-L474 - Committed the change with message:
Fix marker long-press handler in path mode(commit4aa2e05), and created a follow-up PR via themake_prtool.
Testing
⚠️ python - <<'PY' ... urllib.request.urlopen('https://api.github.com/search/issues?q=flutter+GestureDetector+onLongPress') ... PY(web-search attempt failed due network tunnel restriction:403 Forbidden).⚠️ ~/flutter/bin/flutter analyze lib/screens/map_screen.dart(Flutter binary not present at that path in this environment).⚠️ flutter --version(command not found in environment).
|
tested and working well other than above changes |