Skip to content

Conversation

@danditomaso
Copy link
Collaborator

Description

This pull request introduces a new MeshService class to centralize mesh device connection, configuration, and node management logic, replacing scattered event handling and improving the flow for configuration and node updates. It also updates the node database retention strategy to prune stale nodes by age rather than a fixed count, and refactors event handling and status mapping throughout the codebase for consistency and maintainability.

MeshService introduction and connection flow improvements:

  • Added the new MeshService class (packages/web/src/core/services/MeshService.ts) to manage device connection lifecycle, configuration state, heartbeat, and node batching, providing a unified event-driven API for mesh device interactions.
  • Updated event handling so that node information packets are now batched during initial configuration and dispatched in bulk after config completion, with real-time updates post-config. Node handling responsibilities have shifted from subscriptions to MeshService and its events. [1] [2]

Node database retention and pruning:

  • Changed node retention policy in nodeDBStore to prune nodes not heard from in the last 14 days, replacing the previous fixed-count eviction strategy. Added a new pruneStaleNodes method and integrated pruning into nodeDB initialization and access. [1] [2] [3]
  • Updated mock store and interface to support the new pruneStaleNodes method. [1] [2]

Event and status handling enhancements:

  • Added an onConfigComplete event to the core event system (eventSystem.ts) and updated packet decoding to dispatch this event, enabling the two-stage configuration flow managed by MeshService. [1] [2]
  • Refactored connection status mapping in UI components to support new states like "configured", "configuring", and "online" for improved user feedback.

Checklist

  • Code follows project style guidelines
  • Documentation has been updated or added
  • Tests have been added or updated
  • All i18n translation labels have been added (read
    CONTRIBUTING_I18N_DEVELOPER_GUIDE.md for more details)

Copilot AI review requested due to automatic review settings November 10, 2025 01:41
@vercel
Copy link

vercel bot commented Nov 10, 2025

@danditomaso is attempting to deploy a commit to the Meshtastic Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Nov 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
web-test Ready Ready Preview Comment Nov 10, 2025 10:41pm

Copy link
Contributor

Copilot AI left a comment

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 introduces a new MeshService class to centralize connection management and configuration flow for mesh devices. The service manages the lifecycle of device connections, batches node information during initial configuration for performance, and implements a two-stage configuration flow with heartbeat management.

Key changes:

  • New MeshService class for managing mesh device connections and configuration
  • Refactored node handling to batch-process nodes during initial configuration and process individually afterward
  • Added pruneStaleNodes functionality to nodeDB store with 14-day retention policy
  • Updated connection status handling and event subscriptions

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/web/src/core/services/MeshService.ts New service class for connection lifecycle management, configuration flow, and heartbeat handling
packages/web/src/pages/Connections/useConnections.ts Integrated MeshService for connection management, updated setupMeshDevice to handle batched nodes
packages/web/src/core/subscriptions.ts Removed individual node handling logic, now delegated to MeshService
packages/web/src/core/stores/nodeDBStore/index.ts Added pruneStaleNodes method with 14-day retention, removed old eviction logic
packages/web/src/core/stores/nodeDBStore/nodeDBStore.mock.ts Updated mock to include new pruneStaleNodes method
packages/core/src/utils/transform/decodePacket.ts Updated config complete handling to emit event for MeshService
packages/core/src/utils/eventSystem.ts Added onConfigComplete event dispatcher
packages/web/src/components/DeviceInfoPanel.tsx Extended status color mapping for new connection states
packages/web/src/components/Dialog/AddConnectionDialog/AddConnectionDialog.tsx Type improvement: using ConnectionType instead of string literal union
packages/web/src/components/PageComponents/Map/Markers/NodeMarker.tsx Removed unused label parameter
packages/web/src/pages/Connections/index.tsx Removed extra blank line
.gitignore Added .DS_Store exclusion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant