Skip to content

regression: native emoji rendered as corrupted characters in omnichannel PDF transcript - #41552

Merged
dionisio-bot[bot] merged 1 commit into
release-8.7.0from
fix/pdf-transcript-native-emoji
Jul 24, 2026
Merged

regression: native emoji rendered as corrupted characters in omnichannel PDF transcript#41552
dionisio-bot[bot] merged 1 commit into
release-8.7.0from
fix/pdf-transcript-native-emoji

Conversation

@KevLehman

@KevLehman KevLehman commented Jul 24, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

When a visitor sends a native emoji (e.g. 👍 from the livechat emoji picker), the generated PDF transcript renders it as corrupted characters such as =M instead of a readable shortcode like :+1:.

Regression from #39411 (emojione removal): emojibase-data stores emoji with a variation selector (1F44D FE0F), while @rocket.chat/message-parser emits the bare codepoint (1F44D). The exact Map lookup in unicodeToShortname missed, the raw emoji reached react-pdf's Latin font, and its UTF-16 surrogates were truncated to =M. The old emojione.toShort was regex-based and tolerant of this.

This strips variation selectors from both the map keys and the lookup input, so bare and selector-suffixed emoji resolve to the same shortcode.

https://rocketchat.atlassian.net/browse/CORE-2465

Steps to test or reproduce

  1. Enable Omnichannel with an online agent
  2. As a visitor at /livechat, send 👍 alone and inside text
  3. Close the conversation as the agent and generate the PDF transcript
  4. The PDF shows :+1: instead of corrupted characters

Further comments

Added emoji.spec.ts covering bare, variation-selector-suffixed, and skin-tone emoji plus the non-emoji fallback.

Review in cubic

image image

Summary by CodeRabbit

  • Bug Fixes

    • Improved emoji name conversion by consistently handling Unicode variation selectors.
    • Added support for correctly mapping skin-tone emoji variants.
    • Preserved the original emoji when no matching shortname is available.
  • Tests

    • Added coverage for standard emoji, variation-selector variants, skin-tone emoji, and fallback behavior.

@dionisio-bot

dionisio-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2cc6de36-768d-48db-a251-830d4afd55d8

📥 Commits

Reviewing files that changed from the base of the PR and between c8b080b and 6aa6358.

📒 Files selected for processing (2)
  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (2/4)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (2/5)
  • GitHub Check: 🔨 Test API Apps (node-runtime - EE) / MongoDB 8.0 coverage (1/1)
  • GitHub Check: 🔨 Test API Livechat (CE) / MongoDB 8.0 (1/1)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
🧠 Learnings (6)
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
Learning: Adopt the monorepo-wide Jest testMatch pattern: <rootDir>/src/**/*.spec.{ts,js,mjs} (represented here as '**/src/**/*.spec.{ts,js,mjs}') to ensure spec files under any package's src directory are picked up consistently across all packages in the Rocket.Chat monorepo. Apply this pattern in jest.config.ts for all relevant packages to maintain uniform test discovery.

Applied to files:

  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
  • ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.ts
🔇 Additional comments (2)
ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.ts (1)

16-28: LGTM!

Also applies to: 39-39

ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts (1)

1-19: LGTM!


Walkthrough

Emoji shortname mapping now strips Unicode variation selectors during map construction and lookup. Tests cover standard emoji, variation-selector emoji, skin-tone emoji, and unmapped input fallback behavior.

Changes

Emoji shortname normalization

Layer / File(s) Summary
Normalize emoji mappings and lookups
ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.ts
Adds variation-selector stripping for base and skin-variant map keys and for unicodeToShortname lookups.
Validate shortname conversion
ee/packages/pdf-worker/src/templates/ChatTranscript/markup/emoji.spec.ts
Adds tests for standard, variation-selector, skin-tone, and unmapped emoji inputs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: type: bug

Suggested reviewers: cardoso, martinschoeler

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing native emoji rendering in omnichannel PDF transcripts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (3)
  • UTF-16: Request failed with status code 401
  • CORE-2465: Request failed with status code 401
  • E4EB4EAE-3276: Request failed with status code 401

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.

@changeset-bot

changeset-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6aa6358

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@KevLehman KevLehman added this to the 8.7.0 milestone Jul 24, 2026
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.59%. Comparing base (c8b080b) to head (6aa6358).
⚠️ Report is 2 commits behind head on release-8.7.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           release-8.7.0   #41552      +/-   ##
=================================================
- Coverage          68.62%   68.59%   -0.03%     
=================================================
  Files               4138     4138              
  Lines             159417   159417              
  Branches           28197    28134      -63     
=================================================
- Hits              109392   109354      -38     
- Misses             44885    44923      +38     
  Partials            5140     5140              
Flag Coverage Δ
unit 70.56% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 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.

@KevLehman
KevLehman marked this pull request as ready for review July 24, 2026 16:47
@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Jul 24, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 24, 2026
@dionisio-bot
dionisio-bot Bot merged commit fcf244e into release-8.7.0 Jul 24, 2026
84 of 92 checks passed
@dionisio-bot
dionisio-bot Bot deleted the fix/pdf-transcript-native-emoji branch July 24, 2026 16:53
ricardogarim pushed a commit that referenced this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants