Skip to content

regression: missing emojis in picker search - #41342

Merged
dionisio-bot[bot] merged 3 commits into
release-8.7.0from
reg/missing-search-alias-emoji
Jul 24, 2026
Merged

regression: missing emojis in picker search#41342
dionisio-bot[bot] merged 3 commits into
release-8.7.0from
reg/missing-search-alias-emoji

Conversation

@MartinSchoeler

@MartinSchoeler MartinSchoeler commented Jul 13, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Issue(s)

CORE-2415

Steps to test or reproduce

Further comments

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Improved emoji search result selection by deduplicating candidates and tightening qualification logic.
    • Enhanced alias handling, including primary/secondary aliases and partial alias matching.
    • Prevented default results from showing skin-tone variant names while still honoring the selected tone.
    • Continued gracefully when an emoji can’t be rendered by moving to the next candidate.
  • Tests

    • Added unit coverage for the updated emoji search behavior, including deduplication, alias resolution (including partial matches), and tone filtering.

@dionisio-bot

dionisio-bot Bot commented Jul 13, 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 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Emoji data now carries entry names, and emoji search deduplicates matches, resolves aliases and partial matches, skips unavailable rendered results, and handles skin tones. Unit tests register native emoji data and cover these search behaviors.

Changes

Emoji search behavior

Layer / File(s) Summary
Emoji data name contract
apps/meteor/app/emoji-native/lib/generateEmojiData.ts, apps/meteor/app/emoji/lib/rocketchat.ts
Native emoji entries now include generated names, and package list types distinguish entries with and without names.
Search matching and deduplication
apps/meteor/app/emoji/client/helpers.ts
getEmojisBySearchTerm deduplicates results, matches using category and shortcode data, and continues past unavailable rendered emojis.
Native emoji search tests
apps/meteor/tests/unit/app/emoji/helpers.spec.ts
Registers native emoji metadata and tests shortcode, alias, partial-match, duplicate, and skin-tone behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: type: bug

Suggested reviewers: cardoso

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the regression fix in emoji picker search and matches the main change.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • CORE-2415: 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 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 07039c7

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

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.78947% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.26%. Comparing base (ed594fd) to head (07039c7).
⚠️ Report is 100 commits behind head on release-8.7.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           release-8.7.0   #41342      +/-   ##
=================================================
- Coverage          69.11%   68.26%   -0.85%     
=================================================
  Files               3759     4006     +247     
  Lines             147859   156293    +8434     
  Branches           26420    27425    +1005     
=================================================
+ Hits              102196   106700    +4504     
- Misses             41179    44643    +3464     
- Partials            4484     4950     +466     
Flag Coverage Δ
unit 70.69% <57.89%> (+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.

@MartinSchoeler
MartinSchoeler marked this pull request as ready for review July 13, 2026 19:57
@MartinSchoeler
MartinSchoeler requested a review from a team as a code owner July 13, 2026 19:57
KevLehman
KevLehman previously approved these changes Jul 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/meteor/tests/unit/app/emoji/helpers.spec.ts (1)

37-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No teardown for registerNativeEmojis — mutates shared singleton for the rest of the suite.

before(registerNativeEmojis) populates emoji.packages.native and adds many entries to emoji.list on the shared emoji singleton (imported from apps/meteor/app/emoji/client/lib.ts), but there's no after hook to remove them. Any other test blocks in this file or process sharing this module instance (e.g. tests for updateRecent/removeFromRecent/replaceEmojiInRecent) that run after this describe block could observe polluted state.

🧹 Suggested cleanup
 	describe('getEmojisBySearchTerm', () => {
 		before(registerNativeEmojis);
+		after(() => {
+			delete emoji.packages.native;
+			// also remove entries added to emoji.list by registerNativeEmojis
+		});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/tests/unit/app/emoji/helpers.spec.ts` around lines 37 - 39, Add
teardown to the getEmojisBySearchTerm suite that reverses the shared emoji
singleton mutations performed by registerNativeEmojis, including clearing
emoji.packages.native and removing its entries from emoji.list. Use the existing
emoji state and cleanup utilities if available, and ensure subsequent tests
start with the same state as before setup.
apps/meteor/app/emoji/client/helpers.ts (1)

189-194: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Category-membership scan runs per matching candidate.

Object.values(...emojisByCategory).some(contents => contents.indexOf(categoryName) !== -1) linearly scans every category array for every key that passes the initial regex test. For short search terms that match many keys (e.g. a single character while typing), this becomes an O(candidates × categories × itemsPerCategory) scan on a UI hot path. Consider building a Set<string> of category members once per package (memoized outside the loop or cached alongside the package) and doing an O(1) .has() lookup instead.

♻️ Possible optimization
+	const categoryMembership = new Map<string, Set<string>>();
+
 	for (let current in emoji.list) {
 		...
-		const isCategoryEmoji = Object.values(emoji.packages[emojiPackage].emojisByCategory).some(
-			(contents) => contents.indexOf(categoryName) !== -1,
-		);
+		if (!categoryMembership.has(emojiPackage)) {
+			categoryMembership.set(
+				emojiPackage,
+				new Set(Object.values(emoji.packages[emojiPackage].emojisByCategory).flat()),
+			);
+		}
+		const isCategoryEmoji = categoryMembership.get(emojiPackage)!.has(categoryName);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/app/emoji/client/helpers.ts` around lines 189 - 194, In the
candidate-filtering loop around isCategoryEmoji, avoid rescanning every
emojisByCategory array for each matching key. Build or reuse a per-package Set
containing the category members before the loop, then replace the per-candidate
Object.values(...).some(...) scan with an O(1) membership lookup while
preserving the existing !isCategoryEmoji && shortnames.length === 0 filtering
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/meteor/app/emoji/client/helpers.ts`:
- Around line 171-173: Update the deduplication logic in the emoji-processing
flow to check and record the resolved actualEmoji value rather than emojiObject.
Move the seenEmojis check/add so entries resolving to the same actualEmoji are
emitted only once, while preserving the existing row-generation behavior.

---

Nitpick comments:
In `@apps/meteor/app/emoji/client/helpers.ts`:
- Around line 189-194: In the candidate-filtering loop around isCategoryEmoji,
avoid rescanning every emojisByCategory array for each matching key. Build or
reuse a per-package Set containing the category members before the loop, then
replace the per-candidate Object.values(...).some(...) scan with an O(1)
membership lookup while preserving the existing !isCategoryEmoji &&
shortnames.length === 0 filtering behavior.

In `@apps/meteor/tests/unit/app/emoji/helpers.spec.ts`:
- Around line 37-39: Add teardown to the getEmojisBySearchTerm suite that
reverses the shared emoji singleton mutations performed by registerNativeEmojis,
including clearing emoji.packages.native and removing its entries from
emoji.list. Use the existing emoji state and cleanup utilities if available, and
ensure subsequent tests start with the same state as before setup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a92cf746-ec38-460c-9577-df15aef68893

📥 Commits

Reviewing files that changed from the base of the PR and between ed594fd and d64ad1c.

📒 Files selected for processing (2)
  • apps/meteor/app/emoji/client/helpers.ts
  • apps/meteor/tests/unit/app/emoji/helpers.spec.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
🧰 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:

  • apps/meteor/tests/unit/app/emoji/helpers.spec.ts
  • apps/meteor/app/emoji/client/helpers.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:

  • apps/meteor/tests/unit/app/emoji/helpers.spec.ts
🧠 Learnings (5)
📚 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:

  • apps/meteor/tests/unit/app/emoji/helpers.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:

  • apps/meteor/tests/unit/app/emoji/helpers.spec.ts
  • apps/meteor/app/emoji/client/helpers.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:

  • apps/meteor/tests/unit/app/emoji/helpers.spec.ts
  • apps/meteor/app/emoji/client/helpers.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:

  • apps/meteor/tests/unit/app/emoji/helpers.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:

  • apps/meteor/tests/unit/app/emoji/helpers.spec.ts
  • apps/meteor/app/emoji/client/helpers.ts
🪛 ast-grep (0.44.1)
apps/meteor/app/emoji/client/helpers.ts

[warning] 160-160: Do not use variable for regular expressions
Context: new RegExp(escapeRegExp(searchTerm.replace(/:/g, '')), 'i')
Note: [CWE-1333] Inefficient Regular Expression Complexity. Security best practice.

(regexp-non-literal-typescript)

🔇 Additional comments (3)
apps/meteor/app/emoji/client/helpers.ts (1)

195-208: LGTM on the breakcontinue fix.

Skipping (instead of aborting the whole search) when the rendered emoji for a candidate can't be resolved directly addresses the "missing emojis in picker search" regression — a single unrenderable candidate no longer terminates the entire scan.

apps/meteor/tests/unit/app/emoji/helpers.spec.ts (2)

40-68: LGTM!


11-22: 🎯 Functional Correctness

No typing issue here EmojiPackages['native'] is assignable to EmojiPackage, and categoryIndex is optional. getEmojiConfig() already returns emojiList entries with emojiPackage, so the direct mutation and emoji.packages.native assignment match the existing types.

			> Likely an incorrect or invalid review comment.

Comment thread apps/meteor/app/emoji/client/helpers.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/app/emoji/client/helpers.ts Outdated

@jessicaschelly jessicaschelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test to the scenario mentioned by Cubic?

something like:

  it('applies the selected skin tone when searching by an alias', () => {
        const result = getEmojisBySearchTerm('thumbsup', 2, [], () => undefined).find(({ image }) =>
        image?.includes('👍'));

        expect(result).to.exist;
        expect(result?.image).to.include('👍🏼');
  });

@ricardogarim

Copy link
Copy Markdown
Member

hey @jessicaschelly and @KevLehman, we need your check here again.

KevLehman
KevLehman previously approved these changes Jul 16, 2026

@jessicaschelly jessicaschelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i noticed one scenario that is still not working:

if i select a skin tone and search for an emoji using an alias like thumbsup or yes, the search result shows the correct toned emoji, but after clicking it, the emoji is inserted without the selected tone.
can you check that? and also add a test to prevent it

here's the recording: https://jam.dev/c/db079430-d869-47fc-af7c-76d03db74d36

@cardoso
cardoso requested a review from jessicaschelly July 24, 2026 13:10
@cardoso cardoso added this to the 8.7.0 milestone Jul 24, 2026
@cardoso
cardoso changed the base branch from develop to release-8.7.0 July 24, 2026 13:11
@cardoso cardoso 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
@cardoso cardoso removed the stat: QA assured Means it has been tested and approved by a company insider label Jul 24, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jul 24, 2026
@cardoso cardoso 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 ae0b8fb into release-8.7.0 Jul 24, 2026
52 of 54 checks passed
@dionisio-bot
dionisio-bot Bot deleted the reg/missing-search-alias-emoji branch July 24, 2026 13:22
ricardogarim pushed a commit that referenced this pull request Jul 27, 2026
Co-authored-by: Matheus Cardoso <matheus@cardo.so>
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.

5 participants