Skip to content

Chat: direct messages and channel messages - #7

Merged
mategogiberidze merged 2 commits into
mainfrom
feature/chat
Oct 21, 2026
Merged

mategogiberidze merged 2 commits into
mainfrom
feature/chat

Conversation

@mategogiberidze

@mategogiberidze mategogiberidze commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Adds chat to MeshAnd: read and send text messages, both to channels (the primary plus any secondary channels on the radio) and directly to one node.

Stacked on #6 (phone GPS). This branch starts from feature/phone-gps-override, so until #6 is merged this PR also shows that commit. Merge #6 first; the chat change itself is the last commit (5ce7e4c).

What's new

  • Chat tab (bottom bar, unread badge): one entry per channel on the radio, then one per direct-message partner, latest first, with unread counts.
  • Conversation view: bubbles (mine on the right), the sender's name and map colour on channels, time, and delivery state for my messages (sending / sent / delivered ✓ for direct, relayed ✓ for channels / not delivered). The compose box enforces the 233-byte payload and shows a byte counter from 160 bytes (Georgian letters count 3). The bottom bar hides inside a conversation so the keyboard has room. A delete button removes a conversation from the phone.
  • Message button on expanded node cards (Nodes page) and a chat icon on team member cards (Team list from OsmAnd) open a direct conversation.
  • Notifications: one per conversation (MessagingStyle, last 6 unread), opening the conversation. The conversation on screen is marked read and isn't notified.

How it works

  • ChatRepository collects client.session → packets, like PinRepository. It keeps TEXT_MESSAGE_APP packets that aren't meshand: pins (PinText.parseMessage). Broadcast → channel packet.channel; to or from our node → direct conversation with the other side. Repeats are dropped by sender + packet id.
  • Sending uses RadioClient.sendText(text, to, channel). Channels go to NodeId.BROADCAST. A direct message goes on the channel the partner last wrote to us on (else 0); radios with each other's keys encrypt DMs end-to-end anyway. Delivery comes from MessageHandle.state, with a 2-minute wait like pins.
  • Channel names come from RadioClient.channels (only the slot and name). An empty primary name shows the modem preset (for example "LongFast"), read from the LoRa config. Message texts, PSKs, channels and configBundle are never logged.
  • Saved to chat.tsv via StoreCodec.encodeChat/decodeChat: at most 500 messages per conversation, plus the channel names so the list still makes sense offline. Writes are debounced to 500 ms. "Clear saved data" deletes messages too.
  • Pure logic is in domain/ChatRules (thread routing, byte limit, conversation list, trimming, reply channel).

Tests

  • ./gradlew :app:testDebugUnitTest :app:assembleDebug :app:lintDebug passes, with no new lint warnings.
  • New ChatRulesTest (9 tests) and chat round-trip / damaged-line tests in StoreCodecTest.
  • Not tested on a radio yet. Worth checking on the phone: DM delivery ✓, a secondary channel's name and messages, the keyboard on Android 7, and tapping a notification.

Docs: AGENTS.md takes messaging out of "Out of scope" and lists chat as the third allowed write. CHANGELOG.md has an Unreleased entry.

Type of change

  • New feature
  • UI / design

How was it tested?

  • Unit tests pass: ./gradlew :app:testDebugUnitTest
  • Lint has no errors: ./gradlew :app:lintDebug
  • Tried on a real phone with a real radio (still to do)

Checklist

  • Doesn't log channel keys, radio configuration or other secrets (message texts aren't logged either)
  • Transmits something new (text messages, only when the user taps Send): asked for by the owner on 2026-10-21
  • User-visible changes are in CHANGELOG.md under Unreleased
  • AGENTS.md updated
  • AI tools were used for this change: yes (Claude Code)

🤖 Generated with Claude Code

mategogiberidze and others added 2 commits October 21, 2026 23:45
When the radio's GPS is stuck, MeshAnd can send the phone's location to
its own radio (POSITION_APP to our own node number, LOC_EXTERNAL). The
radio uses it as its own position and broadcasts it on its usual
schedule, so it adds no airtime.

- PhoneGpsFeeder: LocationManager GPS fixes every 30 s; skips fixes
  worse than 100 m, older than 60 s, or within 15 s of the last send
- Opt-in switch in Settings and a "Use phone GPS" button on the GPS card
  when the radio's fix isn't good; location permission asked on enable
- Foreground service adds the location type while it's on; falls back
  to "open MeshAnd to resume" when Android 14+ refuses it in background
- AGENTS.md and CHANGELOG updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Chat tab lists every channel on the radio plus one conversation per
direct-message partner, with unread badges. A conversation shows the
messages (sender, time, delivery state) and a compose box limited to the
233-byte payload. "Message" on node cards and team member cards opens a
direct conversation.

ChatRepository collects TEXT_MESSAGE_APP packets (pins stay in Pins),
saves them to chat.tsv, notifies per conversation, and sends with
RadioClient.sendText, tracking MessageHandle.state. Channel names come
from RadioClient.channels; keys and settings are never read or logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Oct 21, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@mategogiberidze mategogiberidze mentioned this pull request Oct 21, 2026
9 of 10 tasks
@mategogiberidze
mategogiberidze merged commit e4fe986 into main Oct 21, 2026
2 checks passed
@mategogiberidze
mategogiberidze deleted the feature/chat branch October 21, 2026 20:22
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