Chat interaction and message composition
Chat interaction turns a selected conversation into a readable transcript and a controlled place to write messages. It links chat navigation, message content, media, delivery state, previews, and desktop alerts while keeping actions tied to the correct account and chat.
Conversation views
The conversation view is the main workspace for reading and acting on one chat. The chat list selects the conversation, and the open view presents its header, message history, composer, and temporary panels such as replies or attachment review (src/…/chats.rs, src/…/conversation.rs).
Chat navigation
The chat list helps the reader find a conversation through search, filters, archived chats, starred messages, and locked chats. Search can return chats, message hits, and contacts; selecting a message result opens the conversation at that message rather than only opening the chat (src/…/chats.rs• L1185-1275).
The open chat header identifies the conversation and exposes actions that belong to it. The header also reflects presence, group activity, calls, pinned messages, and read-only or blocked states. On a narrow window, the list and conversation use a single view with a back action (src/…/conversation.rs• L430-485, src/…/conversation.rs• L1003-1070).
References: src/…/chats.rs• L1185-1275 src/…/conversation.rs• L430-485 src/…/conversation.rs• L1003-1070
Message transcript
The transcript presents messages in time order and keeps the reader's place while older history loads. It groups nearby messages from the same side and sender, groups suitable media into albums, marks day boundaries, and keeps the first visible date available while scrolling (src/…/conversation.rs• L2700-2794, src/…/conversation.rs• L2900-2960).
Each message can carry content, sender identity, time, delivery state, reply context, reactions, edit and forward markers, mentions, and a thumbnail. These fields let the view show the message itself and the small pieces of context needed to understand it (src/model.rs• L574-610).
The transcript supports direct interaction with message bubbles. A reader can open a message menu, reply, react, select messages, follow a quoted message, open media, or inspect delivery details. The interaction target remains the message id even when rows are grouped or the transcript is virtualized (src/…/conversation.rs• L4858-5010, src/…/conversation.rs• L5578-5738).
References: src/…/conversation.rs• L2700-2794 src/…/conversation.rs• L2900-2960 src/model.rs• L574-610 src/…/conversation.rs• L4858-5010 src/…/conversation.rs• L5578-5738
Message composition
The composer is the single entry point for text, captions, replies, attachments, voice messages, and related actions. It keeps draft state local to the active account and chat, then sends a text or staged media action with the selected reply and mention context (src/…/conversation.rs• L1495-1519, src/…/conversation.rs• L2096-2120).
Draft editing
The draft field grows from one line to a small multi-line area. Enter behavior follows the account setting: Enter can send while Shift+Enter adds a line, or Ctrl+Enter sends when that mode is selected. The composer offers attachment tools, emoji and sticker access, view-once media, and a send or record control (src/…/conversation.rs• L1661-1685, src/…/conversation.rs• L1692-1772, src/…/conversation.rs• L2044-2088).
Formatting applies to selected draft text. Replies and edits appear as strips above the field so the next send keeps its intended context. If the source of a cross-chat reply is not available, the composer keeps the reply state visible instead of silently sending an unquoted message (src/…/conversation.rs• L1597-1638, src/…/conversation.rs• L1940-1962).
Attachment composition
Staged attachments are reviewed without leaving the conversation. The review keeps each selected item identifiable, allows supported pictures to be edited, allows items to be removed or added, and sends through the same composer path (src/…/attachment_preview.rs• L89-183, src/…/attachment_preview.rs• L290-376). A caption can accompany staged media, but it does not create a link card while attachments are pending (src/app.rs• L6433-6445).
The composer also shows upload progress and lets the reader cancel an upload. A refused voice message remains available for another send or for discard, so a failed send does not become an unexplained empty composer (src/…/conversation.rs• L2356-2459).
References: src/…/conversation.rs• L1495-1519 src/…/conversation.rs• L1661-1685 src/…/conversation.rs• L1692-1772 src/…/conversation.rs• L2044-2120 src/…/conversation.rs• L1597-1638 src/…/attachment_preview.rs• L89-183 src/…/attachment_preview.rs• L290-376
Message rendering
Message rendering maps the content model to a bubble, card, media surface, system row, or other focused view. The renderer uses the chat type and message metadata to decide alignment, sender details, grouping, footer content, and available actions (src/model.rs• L783-850, src/…/conversation.rs• L4858-5010).
Content presentation
Text uses a bubble that can include quoted content, links, mentions, and formatted spans. Media can appear as a picture, video, audio, document, sticker, location, interactive card, or album. A picture without a caption can carry its time and delivery marks over the image, while content with context keeps a normal bubble (src/…/conversation.rs• L5496-5554, src/…/conversation.rs• L5592-5697, src/…/conversation.rs• L6504-6669).
The footer gives outgoing messages a delivery state and time. It can also show edited, failed, starred, and pinned marks. A failed outgoing message says that it was not sent and does not imply an automatic retry (src/model.rs• L558-572, src/…/conversation.rs• L6715-6779).
Media views
Media interaction moves from a message bubble to a full-window viewer when the reader needs a larger view. The viewer can show a picture or video, browse the chat's media album, download missing media, save or open a local file, and return to the source message (src/…/image_preview.rs• L32-177, src/…/image_preview.rs• L226-508).
The attachment review and media viewer serve different points in the lifecycle. Review handles files that are about to leave the device; the viewer handles media that belongs to an existing message and may still need to be downloaded (src/…/attachment_preview.rs• L290-376, src/…/image_preview.rs• L753-835).
References: src/model.rs• L558-610 src/…/conversation.rs• L5496-5554 src/…/conversation.rs• L5592-5697 src/…/conversation.rs• L6504-6779 src/…/image_preview.rs• L32-177 src/…/image_preview.rs• L753-835
Markup and text direction
Message text has one logical source used for drawing, selection, copying, previews, and accessibility. Markup turns that source into styled spans while preserving the original character order needed for links, mentions, and cursor actions (src/markup.rs• L34-149).
Text markup
The message language supports common WhatsApp-style formatting and structured lines. It recognizes bold, italic, strike-through, inline and fenced monospace text, quotes, lists, web links, phone numbers, email addresses, and known mentions. Plain summaries remove display markup and replace stored mention ids with readable names (src/markup.rs• L232-292, src/markup.rs• L294-372, src/markup.rs• L392-475).
Links are underlined and kept as character ranges so a click can open the right target. Phone numbers become telephone links, email addresses remain mail links, and email links are excluded from browser-link lists. The same parsing rules support message cards, search results, quotes, and copied transcript text (src/markup.rs• L51-57, src/markup.rs• L200-229, src/model.rs• L1326-1361).
Bidirectional text
Bidirectional text means text that mixes left-to-right and right-to-left scripts. The layout follows the Unicode bidirectional algorithm for each paragraph, places glyphs in visual order, and keeps logical character positions for selection, links, and carets (src/bidi.rs• L1-12, src/bidi.rs• L22-66).
The first strong direction controls message alignment. A right-to-left message aligns its rows to the same right edge, while embedded left-to-right text keeps its own reading order. This keeps mixed text, numbers, brackets, links, and wrapped lines readable and clickable (src/bidi.rs• L107-120, src/bidi.rs• L122-159). The composer uses the same rules, so typing and editing match the way the final message will appear (src/…/conversation.rs• L1810-1892).
References: src/markup.rs• L34-149 src/markup.rs• L232-292 src/markup.rs• L294-372 src/markup.rs• L392-475 src/model.rs• L1326-1361 src/bidi.rs• L1-12 src/bidi.rs• L22-66 src/bidi.rs• L107-159 src/…/conversation.rs• L1810-1892
Message metadata
Message metadata explains who sent a message, what happened to it, and how it relates to other messages. The transcript shows a compact form, while message menus and the information dialog expose more detail when the reader asks for it (src/model.rs• L574-610, src/…/message_info.rs• L11-69).
Delivery and read state
Outgoing messages move through pending, sent, delivered, read, played, or failed states. Direct chats show the account-level delivery state; group chats can show per-recipient delivery, read, and play times when the audience was recorded (src/model.rs• L558-572, src/model.rs• L2570-2627).
Message info is available for completed outgoing messages. It shows the message preview first, then direct-chat receipt stages or group recipient lists. Missing historical receipt data is called out as incomplete rather than shown as proof that nobody received the message (src/…/message_info.rs• L72-100, src/…/message_info.rs• L233-301).
Read-receipt privacy changes display without changing the stored delivery state. In a direct chat with receipts disabled, a stored Read state is shown as Delivered (src/…/conversation.rs• L6520-6537).
Reply and message context
Replies retain the source message id and may name a different source chat for a private reply to a group message. The composer and transcript use that context to show the quoted sender and summary and to navigate back to the source (src/model.rs• L62-74, src/…/conversation.rs• L6124-6229).
Mentions, reactions, edits, forwarding, stars, pins, and message thumbnails are part of the message's context. They affect what the bubble, quote, search result, notification, and copied transcript can say without changing the main text contract (src/model.rs• L574-610, src/…/conversation.rs• L5188-5227).
References: src/model.rs• L574-610 src/…/message_info.rs• L11-100 src/model.rs• L2570-2627 src/…/message_info.rs• L233-301 src/…/conversation.rs• L6520-6537 src/model.rs• L62-74 src/…/conversation.rs• L6124-6229
Notifications
Desktop notifications carry unread chat activity outside the active conversation. They show a localized title and summary, play the selected sound, and retain the account, chat, and message target so a click opens the exact message that caused the alert (src/notify.rs• L23-32, src/notify.rs• L245-310).
Notification content
Notification content follows account settings. When content is hidden, the notification says only “New message” and does not reveal the chat, sender, or message. Group notifications include the sender; direct-chat notifications use the chat title and message summary (src/notify.rs• L390-421, src/…/settings.rs• L517-539).
Muted chats stay quiet. Repeat limits can allow one notification and then quiet the chat for ten minutes; opening the chat resets that wait. Mentions and replies to the reader still notify in groups (src/…/settings.rs• L517-572).
Notification lifecycle
Reading a chat closes its waiting notifications for that account and chat. A notification click wakes the app and opens its stored target. The notification manager bounds waiting alerts and releases older ones when the limit is reached, which prevents unread desktop alerts from consuming unbounded resources (src/notify.rs• L41-76, src/notify.rs• L103-155, src/notify.rs• L497-524).
References: src/notify.rs• L23-32 src/notify.rs• L245-310 src/notify.rs• L390-421 src/…/settings.rs• L517-572 src/notify.rs• L41-76 src/notify.rs• L103-155 src/notify.rs• L497-524
Link previews
Link previews turn the first web link in a draft into optional metadata for the outgoing message. The flow waits briefly after typing, fetches page metadata, shows a card above the composer, and attaches that same card only if the draft still contains the requested link (src/app.rs• L410-447, src/app.rs• L6420-6460, src/…/worker.rs• L9572-9603).
Preview composition
The composer preview has three states: loading, ready, and dismissed. A ready card can include a title, description, and thumbnail. The reader can remove it, which sends the message without the card and prevents another request for that link in the current draft (src/app.rs• L413-447, src/…/conversation.rs• L2533-2610).
The preview belongs to an account, chat, and normalized URL. A response for another account or another draft does not appear in the current composer. Adding attachments suppresses the card because captions do not receive previews (src/app.rs• L6463-6527).
Preview fetch safety
Preview fetching reads only bounded page and image data and uses page metadata such as Open Graph, Twitter card, or title tags. It accepts only HTTP and HTTPS content and rejects local, private, link-local, multicast, and other non-public destinations. Failed or empty fetches produce no card and do not expose fetched link data in logs (src/…/link_preview.rs• L26-37, src/…/link_preview.rs• L462-541).
The phone's link-preview privacy setting controls whether fetching and sending are allowed. Until an unknown setting is confirmed, previews stay off; a complete phone snapshot can establish the default, while a later phone change wins (src/…/link_preview_setting.rs• L14-26, src/…/link_preview_setting.rs• L29-96).
References: src/app.rs• L410-447 src/app.rs• L6420-6527 src/…/conversation.rs• L2533-2610 src/…/worker.rs• L9572-9622 src/…/link_preview.rs• L26-37 src/…/link_preview.rs• L462-541 src/…/link_preview_setting.rs• L14-96
Related pages
- Messaging and conversations — overall messaging lifecycle and conversation ownership.
- Groups, contacts, and blocking — participant identity, group permissions, and blocked-chat behavior.
- Interactive messages and polls — cards, buttons, and poll actions inside message bubbles.
- Chat archive and export — stored history, message selection, and export behavior.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the composer preview identity aligned with the account, chat, and normalized first link. A stale response must not attach to a new draft.
- Keep message character offsets aligned across markup, emoji replacement, bidirectional layout, selection, and link hit testing.
- Keep delivery-state display aligned with read-receipt privacy so the stored state and visible ticks do not disagree.
- Keep notification targets account-scoped and message-scoped when chat opening or account switching changes.
- Keep attachment captions separate from link-preview eligibility and outgoing preview attachment.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A link-preview response arrives after the account, chat, or draft link changes | The wrong card could appear or be sent | Match the response to the stored account, chat, and normalized URL before showing or attaching it (src/app.rs• L6518-6527, src/…/worker.rs• L9582-9594) |
| The phone link-preview setting is unknown or its snapshot fails | A preview fetch could violate the user's phone setting | Keep previews disabled until a stored answer or complete snapshot permits them (src/…/link_preview_setting.rs• L17-26, src/…/link_preview_setting.rs• L69-96) |
| A message contains mixed right-to-left and left-to-right text | Visual order can differ from logical order and break links or carets | Reorder visual runs while preserving logical character indices (src/bidi.rs• L122-159) |
| Historical group receipts have no saved audience | The UI could falsely imply that no recipient read the message | Show that receipt details are unavailable or incomplete (src/…/message_info.rs• L233-262) |
| A notification is clicked after its chat was read or replaced | The click could open a stale message | Cancel or release the waiting notification and retain its target only while it is valid (src/notify.rs• L58-76, src/notify.rs• L497-524) |
Key files
| File | Why to read it |
|---|---|
| src/…/chats.rs | Chat search, filters, result navigation, and entry into a conversation |
| src/…/conversation.rs | Conversation header, transcript, composer, bubble actions, markup display, and link-preview card |
| src/model.rs | Stable chat, message, delivery, reply, link-preview, and receipt concepts |
| src/markup.rs | Message formatting, links, mentions, plain summaries, and selectable text |
| src/bidi.rs | Shared bidirectional text rules for messages and the composer |
| src/…/message_info.rs | Delivery and read details for outgoing messages |
| src/notify.rs | Notification content, targets, throttling, cancellation, and click routing |
| src/…/link_preview.rs | Safe page metadata and thumbnail retrieval for link cards |
| src/…/link_preview_setting.rs | Phone privacy setting recovery and preview gating |
| src/…/attachment_preview.rs | Staged-file review before a message is sent |
| src/…/image_preview.rs | Full-window browsing and actions for received media |