Skip to content

Persistent message store#814

Merged
danditomaso merged 9 commits into
meshtastic:mainfrom
philon-:persistent-message-store
Sep 4, 2025
Merged

Persistent message store#814
danditomaso merged 9 commits into
meshtastic:mainfrom
philon-:persistent-message-store

Conversation

@philon-

@philon- philon- commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

Description

This PR introduces persistent storage for the message store and some enhancements to node PKI validation and nodeDB merging logic

Related Issues

Changes Made

  • Persistent Message Store: Adds persistence to the message store, ensuring messages and node information survive page reloads and browser restarts.

  • Node PKI Validation & Merging:

    • Implements validateIncomingNode to check new nodes for public key conflicts and correct update handling. This flow is taken from Meshtastic-Android NodeInfo upsert
    • Refactors nodeDBFactory to use new validation during node addition.
    • Updates getNodes to optionally include the current node.
  • There is also a minor fix to fall back to client's Date.now() when a packet is received with a time field less or equal to 0. This is consistent with how the Meshtastic-Apple client handles new packets.

Testing Done

Added/updated tests to cover new validation logic and merging behavior that ensures proper behavior on node addition, PKI mismatch.
Added/updated messageStore tests to also check persistence flow
Added/updated users of messageStore to reflect new structure

Screenshots (if applicable)

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 August 30, 2025 19:08
@vercel

vercel Bot commented Aug 30, 2025

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

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 introduces persistent storage for the message store and enhances node PKI validation. It implements client-side persistence for messages and adds improved validation logic for node database operations to prevent PKI conflicts and ensure proper data integrity.

Key Changes:

  • Message store refactored to support persistence with device-scoped storage
  • Node PKI validation system implemented to detect key conflicts and prevent impersonation
  • Fallback mechanism added for packet timestamps when zero or negative

Reviewed Changes

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

Show a summary per file
File Description
packages/web/src/pages/Messages.tsx Updates to use new message store API with device-scoped access
packages/web/src/core/subscriptions.ts Simplifies node handling by delegating PKI validation to nodeDB
packages/web/src/core/stores/utils/useNewNodeNum.ts New utility for coordinating node number updates across stores
packages/web/src/core/stores/nodeDBStore/types.ts Adds new error type for duplicate PKI detection
packages/web/src/core/stores/nodeDBStore/nodeValidation.ts New validation logic for incoming nodes with PKI conflict detection
packages/web/src/core/stores/nodeDBStore/nodeDBStore.test.ts Comprehensive tests for validation and merge behavior
packages/web/src/core/stores/nodeDBStore/index.ts Integrates validation, adds timestamp fallback, and improves merge logic
packages/web/src/core/stores/messageStore/messageStore.test.ts Updates tests for new persistent store structure
packages/web/src/core/stores/messageStore/index.ts Complete refactor to support persistence and device-scoped instances
packages/web/src/core/stores/index.ts Exports new hooks and utilities for the refactored stores
packages/web/src/core/services/dev-overrides.ts Enables message persistence feature flag in development
Various component files Updates to use new message store API patterns

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/web/src/core/stores/nodeDBStore/index.ts Outdated
Comment thread packages/web/src/core/stores/nodeDBStore/nodeValidation.ts Outdated
Comment thread packages/web/src/core/stores/messageStore/index.ts Outdated
Comment thread packages/web/src/core/stores/messageStore/index.ts Outdated
Implement node validation and improve merging logic

- Added `validateIncomingNode` function to validate new nodes against existing nodes, checking for public key conflicts and ensuring proper handling of node updates.
- Updated `nodeDBFactory` to utilize the new validation function when adding nodes.
- Enhanced `getNodes` method to optionally include the current node in the results.
- Removed the `mergeNodeInfo` utility as its functionality is now integrated into the validation and merging process.
- Updated tests to cover new validation logic and ensure correct behavior during node addition and merging.
- Cleaned up unused utility functions related to key comparison.
@philon- philon- force-pushed the persistent-message-store branch from 1eb6177 to 2910c96 Compare August 31, 2025 22:09
Comment thread packages/web/src/core/stores/utils/useNewNodeNum.ts
@philon- philon- force-pushed the persistent-message-store branch from ce4b37b to 988c045 Compare September 1, 2025 10:01
@vercel

vercel Bot commented Sep 3, 2025

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
web-test Ready Ready Preview Comment Sep 4, 2025 0:37am

@danditomaso

Copy link
Copy Markdown
Collaborator

@philon- Any chance you could rebase main onto this branch to bring it up to date? And run pnpm run lint:fix against it?

@danditomaso danditomaso 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.

LGTM

@danditomaso danditomaso merged commit dcb44d2 into meshtastic:main Sep 4, 2025
4 checks passed
@philon- philon- deleted the persistent-message-store branch September 8, 2025 17:36
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.

3 participants