Skip to content

feat(Reactions): send emoji_code with reactions for push notification rendering#3209

Merged
oliverlaz merged 1 commit into
masterfrom
feat/react-880-reaction-emoji-code
Jun 5, 2026
Merged

feat(Reactions): send emoji_code with reactions for push notification rendering#3209
oliverlaz merged 1 commit into
masterfrom
feat/react-880-reaction-emoji-code

Conversation

@oliverlaz
Copy link
Copy Markdown
Member

@oliverlaz oliverlaz commented Jun 5, 2026

🎯 Goal

Reactions sent via channel.sendReaction did not include emoji_code, so mobile push notification templates (e.g. for reaction.new) had no emoji to render. This wires the React SDK to include emoji_code in the reaction request payload so mobile SDKs can render the correct emoji in push notifications.

Linear: REACT-880

πŸ›  Implementation details

  • New exported helper getEmojiCodeByReactionType(reactionOptions, type) in reactionOptions.tsx resolves the native emoji character (e.g. πŸ‘) for a reaction type from the option's existing unicode field via unicodeToEmoji(). Returns undefined for legacy array options or options that omit unicode, so we never send a garbage code.
  • useReactionHandler now reads reactionOptions from ComponentContext (falling back to defaultReactionOptions, like other consumers) and includes emoji_code in the sendReaction payload when one resolves:
    channel.sendReaction(id, { type, ...(emojiCode && { emoji_code: emojiCode }) });
    The optimistic reaction preview is stamped with the same value for consistency. The public handleReaction(type, event) signature is unchanged.
  • mapEmojiMartData now stores unicode on each mapped entry, so emoji picked from the extended (emoji-mart) list also resolve an emoji_code.
  • The stream-chat Reaction type already supports the optional emoji_code field β€” only stream-chat-react needed to populate it.

Behavior: default reactions (like, love, haha, sad, wow, fire) and any custom reactions defining unicode now ship emoji_code automatically. Legacy array-form reaction options carry no unicode data and continue to send no emoji_code (graceful, unchanged otherwise).

Tests: new reactionOptions.test.ts covering the helper (quick/extended/legacy-array/unknown/missing-unicode) and mapEmojiMartData; useReactionHandler tests for default/custom/no-unicode payloads and the optimistic preview; updated the existing Message.test.tsx send assertion to the new contract.

🎨 UI Changes

None β€” this only affects the network payload sent with reactions (and the local optimistic reaction object). No visual changes.

Summary by CodeRabbit

Release Notes

  • New Features

    • Reactions now support and transmit emoji code data for improved emoji handling.
  • Tests

    • Expanded test coverage for reaction emoji code derivation with custom reaction options.

… rendering

Resolve the native emoji for a reaction type from the configured reaction
options and include it as `emoji_code` in the `sendReaction` payload so mobile
push notification templates can render the emoji. Defaults and any custom
reaction options defining `unicode` are supported automatically; legacy array
options and options without `unicode` send no `emoji_code`. No public API
change.

REACT-880
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Size Change: +659 B (+0.1%)

Total Size: 656 kB

πŸ“¦ View Changed
Filename Size Change
dist/cjs/index.js 255 kB +312 B (+0.12%)
dist/es/index.mjs 252 kB +347 B (+0.14%)
ℹ️ View Unchanged
Filename Size
dist/cjs/audioProcessing.js 1.74 kB
dist/cjs/emojis.js 2.54 kB
dist/cjs/mp3-encoder.js 814 B
dist/cjs/ReactPlayerWrapper.js 545 B
dist/cjs/useNotificationApi.js 49.8 kB
dist/css/emoji-picker.css 178 B
dist/css/emoji-replacement.css 456 B
dist/css/index.css 39.7 kB
dist/es/audioProcessing.mjs 1.65 kB
dist/es/emojis.mjs 2.47 kB
dist/es/mp3-encoder.mjs 768 B
dist/es/ReactPlayerWrapper.mjs 485 B
dist/es/useNotificationApi.mjs 48.6 kB

compressed-size-action

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cb410d11-e7c4-4b45-8f42-9637f27e6995

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 7ad98fa and dcc1431.

πŸ“’ Files selected for processing (5)
  • src/components/Message/__tests__/Message.test.tsx
  • src/components/Message/hooks/__tests__/useReactionHandler.test.tsx
  • src/components/Message/hooks/useReactionHandler.ts
  • src/components/Reactions/__tests__/reactionOptions.test.ts
  • src/components/Reactions/reactionOptions.tsx

πŸ“ Walkthrough

Walkthrough

This PR adds emoji code support to message reactions by introducing emoji lookup helpers, integrating them into the reaction handler hook, and verifying the payload changes end-to-end. The flow reads reaction options from context, derives emoji codes for each reaction type, and includes them when sending reactions.

Changes

Emoji Code Support in Reactions

Layer / File(s) Summary
Emoji code lookup contract and helpers
src/components/Reactions/reactionOptions.tsx, src/components/Reactions/__tests__/reactionOptions.test.ts
mapEmojiMartData now stores computed unicode values in extended reaction option objects. New exported function getEmojiCodeByReactionType converts reaction option unicode to native emoji strings, returning undefined for legacy array options or missing unicode. Comprehensive tests cover quick and extended type lookups, unknown types, and edge cases.
Hook integration of emoji code resolution
src/components/Message/hooks/useReactionHandler.ts, src/components/Message/hooks/__tests__/useReactionHandler.test.tsx
useReactionHandler reads reaction options from component context and computes emoji codes per reaction type using the new helper. Hook now includes emoji_code in sendReaction payloads and builds optimistic previews with both emoji code and type. Test helper wraps in ComponentProvider to inject custom reaction options; expanded test suite verifies emoji derivation from defaults, context overrides, and unmapped type handling.
Message test emoji code assertion
src/components/Message/__tests__/Message.test.tsx
Updated test expectation to assert sendReaction calls include both type and emoji_code fields, confirming emoji codes propagate end-to-end.

Sequence Diagram

sequenceDiagram
  participant Sender as Reaction Sender
  participant Handler as useReactionHandler
  participant Context as ComponentContext
  participant Emoji as getEmojiCodeByReactionType
  participant API as sendReaction
  Sender->>Handler: toggleReaction(reactionType)
  Handler->>Context: read reactionOptions
  Handler->>Emoji: resolve emoji code by type
  Emoji-->>Handler: emoji_code: string | undefined
  Handler->>API: sendReaction({ type, emoji_code })
  API-->>Sender: reaction sent
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through emoji fields,
Where reaction codes now unlock hearts,
Each ❀️ and πŸ˜‚ joined with their type,
The message flow stitched whole and bright,
Native emojis in every sendReaction call! πŸŽ‰

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check βœ… Passed The pull request title clearly and concisely describes the main change: adding emoji_code to reactions for push notification rendering.
Description check βœ… Passed The pull request description follows the template with complete Goal, Implementation details, and UI Changes sections, providing clear rationale, technical approach, and test coverage.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/react-880-reaction-emoji-code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 83.92%. Comparing base (7ad98fa) to head (dcc1431).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3209      +/-   ##
==========================================
+ Coverage   83.84%   83.92%   +0.08%     
==========================================
  Files         439      439              
  Lines       13212    13222      +10     
  Branches     4286     4293       +7     
==========================================
+ Hits        11077    11097      +20     
+ Misses       2135     2125      -10     

β˜” View full report in Codecov by Harness.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@oliverlaz oliverlaz merged commit 2faa620 into master Jun 5, 2026
14 checks passed
@oliverlaz oliverlaz deleted the feat/react-880-reaction-emoji-code branch June 5, 2026 15:11
github-actions Bot pushed a commit that referenced this pull request Jun 5, 2026
## [14.4.0](v14.3.0...v14.4.0) (2026-06-05)

### Bug Fixes

* **compat:** restore React 17/18 compatibility in certain components ([#3197](#3197)) ([b513b69](b513b69))
* general performance and bug fixes ([#3201](#3201)) ([57c5795](57c5795))
* **interop:** unwrap CJS default exports (react-player, @emoji-mart/react) ([#3199](#3199)) ([4cddb02](4cddb02))
* maintain topmost modal non-inert ([#3206](#3206)) ([7ad98fa](7ad98fa))

### Features

* allow to stack modals on top of each other ([#3203](#3203)) ([4c934ae](4c934ae))
* display notifications above modals ([#3200](#3200)) ([0433090](0433090))
* **Reactions:** send emoji_code with reactions for push notification rendering ([#3209](#3209)) ([2faa620](2faa620))

### Performance Improvements

* **Message:** hoist regex compilation in message text rendering ([#3202](#3202)) ([8c018a4](8c018a4))
* **VideoPlayer:** lazy-load react-player to keep it out of the main bundle ([#3204](#3204)) ([18dc966](18dc966))
@stream-ci-bot
Copy link
Copy Markdown

πŸŽ‰ This PR is included in version 14.4.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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants