Skip to content

Auto-favorite nodes on direct message, except CLIENT_BASE role #1240

Open

Description

@garthvh

Summary

Per cross-platform alignment issue meshtastic/design#39, all Meshtastic clients should automatically mark a node as a "favorite" when a direct message is sent or received with that node — except when the local device's own role is CLIENT_BASE, in which case auto-favoriting must be skipped to avoid creating unintended routing/relay behavior.

This is already implemented on iOS and Android. Based on a code search of this repo (meshtastic/web, main branch), the web client does not implement this yet: it has a favorite/unfavorite concept, but it is purely user-triggered from the UI, with no automatic trigger tied to direct-message send/receive, and there is no CLIENT_BASE role check anywhere in the codebase.

Related prior report: #932 (same behavior gap, auto-closed by the stale bot without a fix landing — re-filing with full implementation context since an agent/contributor needs a concrete starting point).

Reference implementations (other platforms)

iOS — meshtastic/Meshtastic-Apple, Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift (around line 339):

user.userNode?.favorite = user.userNode?.deviceConfig?.role ?? 0 != DeviceRoles.clientBase.rawValue
// Do not auto-favorite when using CLIENT_BASE role to avoid creating routing issues.

Android — meshtastic/Meshtastic-Android, core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/usecase/SendMessageUseCase.kt (around lines 89-143):

val isClientBase = ourNode?.user?.role == Config.DeviceConfig.Role.CLIENT_BASE
...
if (!destNode.isFavorite && !isClientBase) {
    // ...setFavorite(node.num, favorite = true)...
}

Both platforms: on send/receive of a direct message, if the peer node is not already a favorite AND the local device's own configured role is not CLIENT_BASE, mark the peer as a favorite.

Current state in this repo

  • Favoriting exists but is entirely manual, driven from the UI:
    • apps/web/src/core/hooks/useFavoriteNode.ts — toggle callback used by node detail/table UI.
    • packages/sdk-react/src/hooks/useFavoriteNode.ts — thin SDK-react wrapper.
    • packages/sdk/src/features/nodes/NodesClient.ts (favorite() / unfavorite() methods, ~lines 176-186) — sends the admin message and patches local node state (isFavorite).
    • packages/sdk/src/features/nodes/application/FavoriteNodeUseCase.ts — sends setFavoriteNode / removeFavoriteNode admin messages via AdminMessageSender.
    • packages/sdk/src/features/nodes/domain/Node.ts — Node.isFavorite: boolean.
  • There is no reference to CLIENT_BASE anywhere in the TypeScript source (only in the generated proto definition, packages/protobufs/meshtastic/config.proto, where CLIENT_BASE = 12 is a Config.DeviceConfig.Role enum value — the concept exists in the protocol but is unused by any app logic).
  • Direct-message detection already happens in packages/sdk/src/features/chat/ChatClient.ts (~lines 108-131), in the client.events.onMessagePacket.subscribe(...) handler. It already computes whether a packet is a direct message and derives the peer node number:
    const conv: ConversationKey =
      packet.type === "direct" && packet.to !== Constants.broadcastNum
        ? { kind: "direct", peer: packet.from === client.myNodeNum ? packet.to : packet.from }
        : { kind: "channel", channel: packet.channel };
    This looks like the natural hook point for triggering auto-favorite logic on both inbound and outbound (echoed) direct messages, for the derived peer node number.
  • The local device's configured role is available via ConfigClient — client.config.radio.value.device?.role (packages/sdk/src/features/config/ConfigClient.ts, packages/sdk/src/features/config/domain/RadioConfig.ts), which maps to the device variant of the Config.Config protobuf oneof (Config_DeviceConfig.role, generated from packages/protobufs/meshtastic/config.proto).
  • NodesClient already exposes favorite(nodeNum) and each node's current isFavorite state, so the missing piece is purely the "when" — wiring a call to client.nodes.favorite(peer) from the direct-message handler, guarded by the CLIENT_BASE role check.

Suggested implementation approach

  1. In ChatClient.ts's onMessagePacket subscriber (or a small use case it delegates to), when conv.kind === "direct":
    • Look up the peer node via client.nodes and skip if it's already isFavorite.
    • Read the local device role via client.config.radio.value.device?.role.
    • If the role is not Protobuf.Config.Config_DeviceConfig_Role.CLIENT_BASE, call client.nodes.favorite(peer).
    • Skip entirely if the role is CLIENT_BASE.
  2. This should fire for both inbound direct messages and locally-sent outbound direct messages (matching the "receives/sends a direct message" wording in [ALIGNMENT]: Clients should auto-favorite nodes on direct message except for CLIENT_BASE design#39, and mirroring the Android use case which triggers on send).
  3. Add unit test coverage similar to packages/sdk/src/features/nodes/NodesClient.test.ts / ChatClient.send.test.ts, covering: (a) normal role auto-favorites an un-favorited DM peer, (b) already-favorited peer is left alone / no duplicate admin message sent, (c) CLIENT_BASE role never triggers auto-favorite.

References


Update (in progress: #1554)

This now follows Android's SendMessageUseCase and meshtastic/design#39 instead of always favouriting:

  • Firmware 2.7.12 and later: before each direct message (and retry), the web client sends the peer to the local radio as a SharedContact (add_contact). It skips this when it has no public key for the peer, so the radio's stored key is never cleared.
  • Older firmware: it favourites the peer of a legacy (non-PKI) DM, except when the local role is CLIENT_BASE or the peer is already a favourite.

Both are best-effort, so the message is sent either way. Like Android, nothing happens when a DM is received.

Activity

  1. added
    help wanted
    parity
    on Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedparity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions