Skip to content

Traceroute map position snapshots#4035

Merged
jamesarich merged 3 commits into
meshtastic:mainfrom
Jord-JD:enhancement/traceroute-map-snapshots
Dec 18, 2025
Merged

Traceroute map position snapshots#4035
jamesarich merged 3 commits into
meshtastic:mainfrom
Jord-JD:enhancement/traceroute-map-snapshots

Conversation

@Jord-JD

@Jord-JD Jord-JD commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

This PR addresses #4033 by storing the current (last known) position data for all related nodes in a new DB table (traceroute_node_position) when a traceroute response is processed by the MeshService.

This data is then used by the traceroute map screens to display the traceroute with the nodes positioned where they were at the time the traceroute took place. If the position information can not be found in the traceroute_node_position table for whatever reason (e.g. traceroute logs stored prior to this feature being implemented), the map will fallback to using the more recent (current) locations.

Store per-traceroute node position snapshots in Room and prefer them when rendering traceroute maps, so historical traceroutes show positions from completion time.
@Jord-JD Jord-JD force-pushed the enhancement/traceroute-map-snapshots branch from 4477570 to 7eeca2b Compare December 18, 2025 11:05
@Jord-JD Jord-JD marked this pull request as ready for review December 18, 2025 11:08
@codecov

codecov Bot commented Dec 18, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 138 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.56%. Comparing base (59a0ad6) to head (8a3755a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...in/java/com/geeksville/mesh/service/MeshService.kt 0.00% 32 Missing ⚠️
...lin/org/meshtastic/feature/map/BaseMapViewModel.kt 0.00% 27 Missing ⚠️
...tastic/feature/node/metrics/TracerouteMapScreen.kt 0.00% 25 Missing ⚠️
...re/data/repository/TracerouteSnapshotRepository.kt 0.00% 21 Missing ⚠️
...g/meshtastic/feature/node/metrics/TracerouteLog.kt 0.00% 19 Missing ⚠️
.../com/geeksville/mesh/navigation/NodesNavigation.kt 0.00% 7 Missing ⚠️
app/src/main/java/com/geeksville/mesh/ui/Main.kt 0.00% 4 Missing ⚠️
...eshtastic/feature/node/metrics/MetricsViewModel.kt 0.00% 2 Missing ⚠️
...in/kotlin/org/meshtastic/core/navigation/Routes.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #4035      +/-   ##
========================================
- Coverage   0.56%   0.56%   -0.01%     
========================================
  Files        405     406       +1     
  Lines      24163   24275     +112     
  Branches    3100    3117      +17     
========================================
  Hits         136     136              
- Misses     24006   24118     +112     
  Partials      21      21              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements traceroute map position snapshots by storing node positions at the time a traceroute response is received. This allows traceroute maps to display historical node positions rather than current locations, providing a more accurate representation of where nodes were during the actual traceroute.

Key Changes:

  • New database table (traceroute_node_position) with foreign key to mesh logs for automatic cleanup
  • Position snapshot capture in MeshService when full traceroute responses are processed
  • Map views updated to accept and display snapshot positions with fallback to current positions
  • Navigation and UI components updated to pass logUuid through the flow

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
TracerouteNodePositionEntity.kt New database entity for storing position snapshots with composite primary key
TracerouteNodePositionDao.kt DAO interface for accessing snapshot position data
MeshtasticDatabase.kt Database version bump to 25 with auto-migration for new table
TracerouteSnapshotRepository.kt Repository managing snapshot position CRUD operations
MeshService.kt Captures position snapshots when traceroute responses arrive, tracks logUuid lifecycle
MetricsViewModel.kt Exposes snapshot positions flow to UI layer
TracerouteMapScreen.kt Accepts optional logUuid and snapshot positions, refactored into scaffold pattern
TracerouteLog.kt Updated dialog to include logUuid and use snapshot positions for map availability check
BaseMapViewModel.kt Extension function for node selection logic handling snapshot vs current positions
MapView.kt (both variants) Updated to accept and use snapshot positions for traceroute display
Routes.kt Navigation route updated with optional logUuid parameter
Main.kt Passes logUuid when navigating to traceroute map from service response
NodesNavigation.kt Navigation handler updated to pass logUuid to traceroute map
ServiceRepository.kt TracerouteResponse data class updated with optional logUuid field
DatabaseModule.kt DI binding for new TracerouteNodePositionDao
25.json Database schema export for version 25

Comment thread app/src/main/java/com/geeksville/mesh/service/MeshService.kt Outdated
…/TracerouteNodePositionDao.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jord <650645+DivineOmega@users.noreply.github.com>
@Jord-JD

Jord-JD commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

Unrelated to co-pilot's earlier comment, there might be a race condition related to both insertMeshLog(packetToSave) and the traceroute node positions both being stored asynchronously. In the unlikely chance it did happen, it would not be catastrophic - we'd just miss the position snapshots that particular traceroute.

However, I'll see if I can put something in to guard against it.

Should be fixed in 8a3755a. Difficult to test though, as it's extremely unlikely this would occur in reality.

@jamesarich

Copy link
Copy Markdown
Collaborator

However, I'll see if I can put something in to guard against it.

Appreciate it - this one turned into a bigger beast than expected 😅

…/TracerouteNodePositionDao.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jord <650645+DivineOmega@users.noreply.github.com>
@Jord-JD Jord-JD marked this pull request as draft December 18, 2025 13:34
@Jord-JD

Jord-JD commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

Moved PR to draft to do some more local testing.

@Jord-JD Jord-JD marked this pull request as ready for review December 18, 2025 14:04
@Jord-JD

Jord-JD commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

Okay, this all seems to be working. Ready for re-review.

@jamesarich jamesarich left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give it a spin 😵‍💫

@jamesarich jamesarich added this pull request to the merge queue Dec 18, 2025
@Jord-JD

Jord-JD commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

I'd appreciate some other people testing it after merge as well. I've done several tests myself, but there's barely any movement in my local nodes (at least those that I can reliably traceroute).

Also, worth noting for anyone testing this: Old traceroutes, prior to this feature being implemented, will just show the current (latest) positions. Only new traceroutes will have their position info snapshotted.

@jamesarich

Copy link
Copy Markdown
Collaborator

I'd appreciate some other people testing it after merge as well. I've done several tests myself, but there's barely any movement in my local nodes (at least those that I can reliably traceroute).

Also, worth noting for anyone testing this: Old traceroutes, prior to this feature being implemented, will just show the current (latest) positions. Only new traceroutes will have their position info snapshotted.

I'll cut it into an internal build shortly, which our devs and testers usually snag right away - we should find out soon 👍

@Jord-JD

Jord-JD commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

I'd appreciate some other people testing it after merge as well. I've done several tests myself, but there's barely any movement in my local nodes (at least those that I can reliably traceroute).
Also, worth noting for anyone testing this: Old traceroutes, prior to this feature being implemented, will just show the current (latest) positions. Only new traceroutes will have their position info snapshotted.

I'll cut it into an internal build shortly, which our devs and testers usually snag right away - we should find out soon 👍

Great, thank you!

Merged via the queue into meshtastic:main with commit 9833795 Dec 18, 2025
8 checks passed
@jamesarich jamesarich added the bugfix PR tag label Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants