Skip to content

Enhance contact handling logic in MeshCoreConnector.#268

Merged
wel97459 merged 1 commit into
mainfrom
dev-discoveryFix
Mar 7, 2026
Merged

Enhance contact handling logic in MeshCoreConnector.#268
wel97459 merged 1 commit into
mainfrom
dev-discoveryFix

Conversation

@wel97459

@wel97459 wel97459 commented Mar 7, 2026

Copy link
Copy Markdown
Collaborator

Enhance contact handling logic in MeshCoreConnector to support conditional addition based on auto-add settings.
Fixes a problem where all contacts got added to the contacts list in the app, but not on the companion.
This also added it to the known contacts, and made the discovery list not show the contact.

Copilot AI review requested due to automatic review settings March 7, 2026 09:45
@wel97459 wel97459 merged commit b748b96 into main Mar 7, 2026
8 checks passed
@wel97459 wel97459 deleted the dev-discoveryFix branch March 7, 2026 09:46

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 adjusts MeshCoreConnector’s contact ingestion so that “new advert” frames don’t automatically become full contacts unless auto-add settings allow it, aiming to keep contacts/discovery state consistent between the app and the companion device.

Changes:

  • Route pushCodeNewAdvert through _handleContact(..., isContact: false) to distinguish adverts from actual device contacts.
  • Extend _handleContact with an isContact flag and gate adding new entries to _contacts based on auto-add settings (or isContact).

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

"Discovered contact ${contact.name} (type ${contact.typeLabel}) not added due to auto-add settings",
tag: 'Connector',
);
return;

Copilot AI Mar 7, 2026

Copy link

Choose a reason for hiding this comment

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

If isContact is false and auto-add for this type is disabled, the handler logs and returns here, but does not add the advert to _discoveredContacts (or persist/notify it). As a result, pushCodeNewAdvert frames are effectively dropped and the discovery list still won’t show the contact. Consider routing this case into the discovery flow (e.g., _handleDiscovery(contact, <rawPacket>)) instead of returning silently.

Suggested change
return;
_handleDiscovery(contact, rawPacket);

Copilot uses AI. Check for mistakes.
Comment on lines +2259 to +2263
if ((_autoAddUsers && contact.type == advTypeChat) ||
(_autoAddRepeaters && contact.type == advTypeRepeater) ||
(_autoAddRoomServers && contact.type == advTypeRoom) ||
(_autoAddSensors && contact.type == advTypeSensor) ||
isContact) {

Copilot AI Mar 7, 2026

Copy link

Choose a reason for hiding this comment

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

The auto-add predicate is now duplicated (here and in _handlePayloadAdvertReceived). Consider extracting it into a single helper (e.g., _shouldAutoAdd(type) / _shouldAutoAddContact(Contact)) to avoid the two sites drifting over time when new advert types/flags are added.

Copilot uses AI. Check for mistakes.
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.

2 participants