Skip to content
  1. Docs
  2. Apps
  3. Developers

Messages internals

The crate layout behind Messages, the protocol adapter interface, native bridge hosts and how to add a protocol.

Messages separates protocol-neutral messaging state from the code that talks to each service. This page describes that split for contributors. For using the app, see Messages.

Crates

Crate or moduleOwns
crates/messages-coreprotocol-neutral identities, capabilities, timelines, drafts and durable outbox state transitions
crates/messages-protocolsthe adapter registry, bounded HTTP transport, protocol translations and the local bridge contract
crates/messages-bridgelocal native protocol hosts for WhatsApp and Matrix
crates/messages-mediadevice enumeration and capture helpers
crates/messages-test-serveraccount-free wire fixtures and integration tests
src/appapplication state, event routing and asynchronous effects
src/viewnavigation, conversation surfaces and settings
src/persistenceversioned state snapshots with atomic replacement
src/platformsystem keyring access and supervision of managed helpers

Adapters

Every service is an implementation of the Adapter trait in messages-protocols. Its operations cover syncing, history and paged history, attachments, sending, message actions, starting conversations and threads, login state and authentication, call control, and capabilities.

ServiceTransport
Signalsignal-cli JSON-RPC over HTTP, with a resumable server-sent event stream
Matrixclient-server API v3 over REST, or a native encrypted SDK host
WhatsAppa native host built on whatsapp-rust, behind the local bridge API

To add a protocol, implement Adapter and register its descriptor and factory in the registry.

Capabilities and identity

  • Capabilities are evaluated per account and per room, and checked again at dispatch time, so the UI never offers an action a room cannot perform.
  • Every room ID is namespaced by its account, so two accounts of the same service never share rooms.
  • Optimistic messages keep a stable transaction ID across retries and server echoes, so a message is never duplicated when the server confirms it.
  • Message updates (edits, deletions, reactions) are stored with replay protection, so an old event cannot undo an edit or resurrect a deleted message.

Native bridge hosts

Services whose cryptographic sessions must stay inside an official SDK run as separate local hosts from crates/messages-bridge. Each host serves a versioned local JSON API protected by a token, and keeps its session state in a private directory. The hosts are built as separate binaries, one feature per service:

sh
cargo build --locked --manifest-path crates/messages-bridge/Cargo.toml --target-dir target \
  --features whatsapp --bin messages-whatsapp -j 1

The same applies to matrix (messages-matrix). Build both helpers into the same target directory as the main app. Signal uses a pinned, checksum-verified signal-cli, installed with ./tools/install-signal-cli.sh.

In managed mode, Messages starts and stops these helpers itself and restores their sessions. Packaged installations can point Messages at the helpers with MESSAGES_HELPER_DIR and at signal-cli with SIGNAL_CLI_PATH. Each managed account has a private session directory under the app's state location; helper access tokens are loaded by the app and never written into the conversation snapshot.

Testing the adapters

messages-test-server serves account-free fixtures for the supported protocol adapters on a local port, so the adapters' real HTTP requests can be exercised without live accounts:

sh
cargo run --locked -j1 -p messages-test-server

The fixtures test request and response handling, not network cryptography. Live-provider interoperability has to be verified separately with real accounts.

Attachments

Visible and nearby transcript images load on demand in two workers and share a bounded decoded-image cache. Local copies made for Open are kept in a bounded cache. Saving a file always publishes a complete new file and never replaces an existing destination.