Skip to content

feat: played receipts for voice messages and audio files - #4023

Merged
isekovanic merged 21 commits into
developfrom
feat/message-marks
Nov 25, 2026
Merged

isekovanic merged 21 commits into
developfrom
feat/message-marks

Conversation

@isekovanic

@isekovanic isekovanic commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Ticket: https://linear.app/stream/issue/RN-542 (backend: https://linear.app/stream/issue/CHA-6554)

Replaces #3962. Depends on GetStream/stream-chat-js#2039. Typecheck fails until a stream-chat release ships markMessagePlayed, channel.config.markTypes, the marks types and the offline DB's getMessageMarks and insertMessageMark. The synced design tokens come from GetStream/design-system-tokens#83.

🎯 Goal

Show the author of a voice note, audio file or video that other users played it, following the "Message Marks" design.

πŸ›  Implementation details

  • Marking follows the player, not the component. Audio and video players take an optional onPlaybackStarted callback, called on each progress once playback advances, after any download and buffering, until it returns true. The message is marked once it actually plays, even if its bubble scrolled away while the audio buffered. A pool keeps a player's callback when a later caller passes none.
  • AudioAttachment passes a callback for its message. Composer previews pass none and are never marked.
  • AnimatedGalleryVideo passes a callback for the video's message. openImageGallery takes an optional channel, which Gallery and the channel details MediaList pass. A gallery opened without one marks nothing.
  • Apps decide what playing media does through ChatConfigProvider, which takes an optional handlePlaybackStarted({ attachment, markPlayed, message, player }). It is called as playback advances until it returns true, so returning false can wait for a minimum played time, and it can skip marking or branch on attachment.type or message.cid. Without it the message is marked as soon as playback starts. Render the provider above OverlayProvider so it also reaches gallery videos. The types are HandlePlaybackStarted and PlaybackStartedParams.
  • useMarkMessagePlayed is public, for a custom player that does not use the SDK's players.

Gallery autoplay fix

  • With autoPlayVideo on, every gallery player was created playing, so the slides next to the shown one played off screen, sound included, and moving to another slide paused nothing, because autoplay never went through play() and the pool had no active player. The same code is in v9.
  • Players now start paused, and a slide plays its video once it is shown, through a store subscription that renders nothing. Moving to another slide pauses the old video before the new index is published, so the new slide's autoplay is not paused right after it starts.
  • Only the shown video plays now, so marking no longer needs to skip slides that are not shown.
  • The client decides whether to send: it skips channel types without the played mark, the user's own messages and messages the user already marked, and queues the mark while offline. A failed mark is ignored.
  • A new MessageMark slot shows the mark in the footer's status row, before the delivery status and separated from it by a dot. A direct message reads "Played", any other channel "Played by" and the count, capped at 99+. It uses the read colour and the theme tokens, with theme keys messageItemView.mark.{container,text,separator}.
  • The mark shows only once someone played the message and only when channel.config.markTypes includes played. There is no opt-in prop. Turning marks on for the channel type is the switch.
  • Played messages stay in their group. An earlier message in a group shows only the mark, without the delivery status or timestamp, so the time is not read as the time it was played. The last message keeps the full row.
  • The Message and MessageFooter memo comparators and stringifyMessage include the played count, so a mark that arrives while the channel is open re-renders the row.

Offline mark lists

  • The offline database stores marks the way it stores reactions, so a "Played by" list (MessageMarkPaginator in stream-chat) opens offline from the stored marks while its first page loads.
  • A new messageMarks table holds one row per marker (messageId, userId, type, createdAt), deleted with its message. Rows come from each stored message's mark_groups, which carries the newest markers per type (up to 100), and from message.mark_added.
  • mark_groups and own_marks move out of extraData into their own markGroups and ownMarks columns, as reaction_groups has reactionGroups, so a new mark updates them without rewriting the message.
  • OfflineDB implements getMessageMarks, the stored marks on a message newest first and joined to the stored users (a mark whose user is not stored lists with the user's ID), and insertMessageMark, which stores the mark, the user who made it and the two columns.
  • SqliteClient.dbVersion goes from 19 to 20, so existing installs rebuild their offline database once on update.

Design tokens

  • The generated tokens are synced to the latest design-system-tokens build (last synced in June). The token repo has since renamed or removed 55 semantic tokens (chat* β†’ messageBubble*, presence* β†’ avatarPresence*, the avatarPalette* set, ...). Its React Native build now keeps every old name mapped to the current token (GetStream/design-system-tokens#83), so theme.semantics only gains keys and the SDK compiles unchanged. The old names are removed in the next major.
  • Some token values changed in the design. Dark-mode mention text is now blue200 instead of blue400. accentWarning and the avatar default colours changed too, but no SDK component reads them directly.
  • AGENTS.md now says where the tokens come from, that the old names are adapters kept in the token repo, and that new code uses the current names.

Avatars

  • Avatars without an image use avatarBgDefault and avatarTextDefault instead of a colour picked per user or channel from the 5-colour palette, following the current design. Light mode matches what palette 1 looked like. In dark mode the default is the mode-aware brand colour. The avatarPalette* keys stay in theme.semantics through the token adapter, so integrators can still use them.

🎨 UI Changes

iOS
Before After
Android
Before After

πŸ§ͺ Testing

  • Unit tests cover the footer mark, with no mark before a play or without the played mark type, "Played" in a direct message, the count and 99+ in a channel, a mark that arrives live, and the mark-only row on an earlier message in a group.
  • Player tests cover calling onPlaybackStarted once on the first progress, asking again until it returns true, nothing while paused, an autoplaying video only once it advances, Expo's progress, and the callback on a reused player. Gallery video tests render the gallery with a real pool and cover autoplay playing only the shown video, moving to another slide pausing it and playing the new one, no autoplay without autoPlayVideo, marking the shown video, a handler from ChatConfigProvider deciding, and nothing without a channel. AudioAttachment tests render it in a Channel: a press alone does not mark, the first progress does, a preview never does, and a configured handler decides. useMarkMessagePlayed has its own tests.
  • Tested in the SampleApp on the iOS simulator against the stream-chat branch. As the author, in a direct message, no mark before a play, then "Played" alone under the earlier voice note and "Played Β· βœ“ time" on the last message, both live and after a reload. As the recipient, playing a voice note and playing a video in the gallery each wrote the mark only once playback started, and the author saw "Played Β· βœ“βœ“ time" under the video. Rechecked after moving the override to ChatConfigProvider. With autoplay on and a message with two videos, logging each slide's progress showed the off-screen slide playing alongside the shown one before the fix, and only the shown slide playing after it, opening either slide. Moving between slides, a custom handlePlaybackStarted and "Played by" with a count are covered by the unit tests only.
  • Store tests run against real SQLite: a message's markers are stored and read back newest first with their users, filtered by type and limited, an updated message adds its new markers, the marks are deleted with their message, a thread reply stores none, mark_groups lives in its column and not in extraData and reads back, and insertMessageMark stores the mark, its user and the columns without touching the rest of the message, stores the user's own mark on another user's message, and skips a message the database never held without aborting the rest of the batch.
  • Offline mark lists ran on the Android emulator with a "Played by" sheet over 30 throwaway members: a list opened in airplane mode came from the stored marks with names and stopped at its page size without retrying, a mark added on the server while offline appeared at the top after the reconnect, and the list then paged to all 31. A live mark with the channel open landed as its row, its user and the updated markGroups, with mark_groups gone from extraData. The channel list still showed its cached channels on an offline cold start.
  • With the synced tokens and the avatar change, typecheck and lint are clean and the full unit suite passes. The MessageSystem, TypingIndicator, MessageAuthor and Thread snapshots are updated for the token references and the avatar colour.

β˜‘οΈ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

The design keeps a group of voice messages together, so a played message no
longer ends its group.
Adds a MessageMark slot before the delivery status. A direct message reads
"Played", any other channel "Played by" and the count, shown only once someone
played the message and the channel type has the played mark. Earlier messages
in a group show only the mark.
Brings the generated tokens up to the latest design-system-tokens build. The
old semantic names stay available through the token repo's React Native
adapter, so theme.semantics only gains keys.
Avatars without an image use avatarBgDefault and avatarTextDefault instead of
a palette colour picked per user or channel, following the current design.
A shared useMarkMessagePlayed hook marks the message whenever its player starts,
however playback started, instead of on the play button press.
openImageGallery takes the channel the messages belong to, and the gallery video
marks its message played when playback starts, autoplay included.
Audio and video players take an optional messageId and tell their pool when
playback first advances, after any download and buffering, through an optional
onPlaybackStarted pool callback.
ChannelShell marks a message once its audio player starts, and the gallery once
the shown video starts, whatever UI controls the player. Components only pass
the messageId. useMarkMessagePlayed is public for players outside the SDK's.
Players take an optional onPlaybackStarted callback, called as playback advances
until it returns true, instead of a messageId. AudioAttachment and the gallery
video pass one that marks their message, so the pools, AudioPlayerProvider and
ChannelShell no longer take part in marking.
ChatConfigProvider takes an optional handlePlaybackStarted, called as audio, voice recording and
video playback advances until it returns true. It gets the attachment, message, player and a
markPlayed helper, and defaults to marking the message played. The gallery keeps skipping slides
that are not shown, so autoplayed neighbours do not count.
Gallery players were created playing when autoPlayVideo was on, so the slides next to the shown
one played off screen, and moving to another slide paused nothing, since autoplay never went
through play(). Players now start paused, and a slide plays its video once it is shown, through a
store subscription that renders nothing. Moving to another slide pauses the old video before the
new index is published. Marking no longer needs to skip slides that are not shown.
Implements the offline database's `getMessageMarks` and `insertMessageMark`, stored like
reactions.

- A `messageMarks` table holds one row per marker (`messageId`, `userId`, `type`, `createdAt`),
  deleted with its message. Rows come from each stored message's `mark_groups`, and from
  `message.mark_added` through `insertMessageMark`.
- `mark_groups` and `own_marks` move out of `extraData` into their own `markGroups` and `ownMarks`
  columns, so a new mark updates them without rewriting the message.
- `getMessageMarks` reads a message's marks newest first, joined to the stored users. A mark whose
  user is not stored lists with the user's ID only.
- `SqliteClient.dbVersion` is bumped to 20 for the new table and columns.
isekovanic added a commit to GetStream/stream-chat-js that referenced this pull request Nov 25, 2026
Ticket: https://linear.app/stream/issue/RN-542 (backend:
https://linear.app/stream/issue/CHA-6554)

Replaces #2015. The React Native SDK side is
GetStream/stream-chat-react-native#4023.

## CLA

- [x] I have signed the [Stream
CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform)
(required).
- [x] Code changes are tested

## Description of the changes, What, Why and How?

Adds message marks. A user who plays another user's voice note or audio
file marks the message `played`, and the author sees who played it, as a
count on the message and as a list of every member who played it.

- `channel.sendMessageMark({ id }, { type })` sends a mark through the
offline queue. A mark that fails for lack of a connection is stored as a
`send-message-mark` pending task and replayed on reconnect. A mark of
the same type that is already queued for the message is not queued
again.
- `channel.markMessagePlayed(messageId)` sends the `played` mark. It
sends nothing when the channel type has no `played` mark or without the
`send-message-mark` capability. When the client's message store holds
the message, it also sends nothing for the user's own message or a
message the user already marked (`own_marks`). For a message the store
does not hold, such as a search result, the server ignores those. There
is no optimistic update. The message changes when `message.mark_added`
arrives, as with read state.
- `ChannelConfig` gains `markTypes`, the channel type's `mark_types`.
Like `availableCommands` it is server-owned, so the integrator cannot
set it, and it is `[]` when marks are off for the channel type. UI SDKs
read it to decide whether to show marks.
- `message.mark_added` updates the message in the message store,
`mark_groups` on the author's copy and `own_marks` on the marker's copy.
The offline DB stores the mark through `insertMessageMark`, with the
user who made it and the message's mark summaries as the store holds
them.
- `MessageMarkPaginator` lists the marks on one message, with the user
who made each one, newest first, through `queryMessageMarks`. It pages
forward with the API's `next` cursor. `messageId` and `filter` say which
marks it lists, `paginatorOptions` (such as `pageSize`) work as for the
channel, thread and message paginators, and `id` names it, generated
when left out as the channel and message paginators do.
- `client.messageMarks` keeps the paginators registered with it current:
`registerPaginator({ paginator })` registers one and replaces one with
the same `id`, `getPaginatorById(id)` finds it again with the pages it
loaded, so opening a list again sends no request, and
`removePaginator(paginatorOrId)` unregisters it. The app picks the ids,
so the client derives no key from the message and the filter.
- `message.mark_added` adds the mark to the lists of its message, with
the marker from the event's `user`. A mark without one is skipped and
shows on the list's next load.
- A reconnect flags every list stale, since events may have been missed.
A list between `paginator.activate()` and the release it returns reloads
at once, and any other reloads when it is next activated.
- A hard delete, a channel delete, losing membership, or a truncation
that removed the message empties and unregisters the lists it affects.
`disconnectUser()` empties and unregisters them all, since the app may
still hold them.
- With offline support, a mark list opens with the marks the offline
database holds while its first page loads, and keeps them when the
request fails. Then it pages no further and counts as stale, so a
reconnect or the next `activate()` reloads it. `OfflineDBApi` gains
`getMessageMarks` and `insertMessageMark`, both required like their
reaction counterparts.
- Reaction and thread events don't carry marks, so the local marks are
kept when those events replace the message.
- A thread now registers its channel's server config. A thread opened
from the thread list can belong to a channel that was never queried,
which left its config empty (no `markTypes`, no `availableCommands`).
- The API client is regenerated from the backend commit that added
marks. It also picks up the backend changes since the last regeneration
(moderation `model` and `provider`, `bypass`, unban query params,
`queryUsers` `connection_id`).

The server ignores a repeat mark (`created: false`, no event), so a
quick play, stop and play before the event arrives sends one extra
request and changes nothing.

### Offline page in `BasePaginator`

Mark lists showed a bug in how every paginator shows the offline
database's first page. The page `preloadFirstPageFromOfflineDb` returned
went to `state.items` only, with no interval behind it, so a live item
ingested while the first query ran rebuilt the list from empty storage
and collapsed it to that one item until the query landed. The channel
list had the same collapse once the offline sync was done.

- The offline page is stored as the head interval, and the paginator
tracks which of its items no live event has touched since
(`showsOfflinePage`). The first page from the server, or the next one
after a failed query, takes the place of those items as a first page.
Items a live event touched stay and merge with it.
- `setItemsFromOfflineDb` shows the offline page without a query, for a
paginator that defers its first query. `ChannelPaginator` uses it and
`showsOfflinePage` for its cold start before the offline sync, in place
of its own flags, so both of its offline paths now work the same way.
- After a failed cold-start query, pull-to-refresh and scrolling to the
end merged the next page into the cached channels and kept channels the
server no longer returns. They now replace them. A recovery after a
failed cold start updates the list once instead of adding the new
channels and removing the dropped ones in two steps.
- Every other channel list flow is unchanged. The offline flows are
recorded publish by publish in the `ChannelPaginator` tests: cold start
before and after the sync, a failed first query followed by recovery,
pull-to-refresh or another query, a live channel arriving during the
first query, and a list loaded from the server that reconnects or
refreshes. Each was compared against the code before this change, and
only the cases listed above differ.

## Changelog

- Add `channel.sendMessageMark` and `channel.markMessagePlayed`, and
handle the `message.mark_added` event.
- Add `channel.config.markTypes`.
- Add `MessageMarkPaginator` and `client.messageMarks`
(`registerPaginator`, `getPaginatorById`, `removePaginator`) to list who
marked a message, kept current by `message.mark_added`.
- Queue message marks while offline.
- Open message mark lists from the offline database. `OfflineDBApi`
gains the required `getMessageMarks` and `insertMessageMark`, so a
custom offline DB implementation has to add them.
- Fix a list showing the offline database's page collapsing to one item
when a live item arrived while its first query ran, which affected the
channel list once the offline sync was done.
- Fix the channel list keeping channels the server no longer returns
after a failed cold-start query, on pull-to-refresh or when scrolling to
the end.
- Fix a thread opened from the thread list missing its channel's server
config.

## Testing

Besides the unit tests, the paginator and `client.messageMarks` ran
against a real app with throwaway users: pages of 2 followed the
server's cursors to the last page in order, a live mark from a user the
client had never seen joined the list with no request, a list found
again by its id after closing came back with no request, a reconnect
reloaded the shown list, and a hard delete dropped it.

The offline mark lists ran on an Android emulator with the React Native
SDK: a list opened in airplane mode came from the stored marks and
stopped at its page size without retrying, a mark added on the server
while the app was offline appeared at the top after the reconnect
reloaded the list, and the list then paged to its end. A live mark
landed in the offline database as its row, its user and the message's
mark summaries. The channel list still showed its cached channels on an
offline cold start, with the same timing as before the `BasePaginator`
change.
10.3.0 adds four scheduled-message notification types, which the notification
translations have to map, and editedScheduledMessage to the composer state.
10.3.1 lets a bounced message be sent again after it is edited.
@github-actions

Copy link
Copy Markdown

SDK Size

title develop branch diff status
js_bundle_size 2036 KB 2076 KB +41447 B πŸ”΄
ai_components_size 353 KB 353 KB 0 B 🟒
a2ui_size 103 KB 103 KB 0 B 🟒

@isekovanic
isekovanic merged commit 2049a42 into develop Nov 25, 2026
22 checks passed
@isekovanic
isekovanic deleted the feat/message-marks branch November 25, 2026 13:16
@github-actions github-actions Bot mentioned this pull request Nov 25, 2026
6 tasks
@github-actions

Copy link
Copy Markdown

πŸŽ‰ This PR is included in version 10.3.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants