regression: missing emojis in picker search - #41342
Conversation
|
Looks like this PR is ready to merge! 🎉 |
WalkthroughEmoji 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. ChangesEmoji search behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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. Comment |
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
apps/meteor/tests/unit/app/emoji/helpers.spec.ts (1)
37-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNo teardown for
registerNativeEmojis— mutates shared singleton for the rest of the suite.
before(registerNativeEmojis)populatesemoji.packages.nativeand adds many entries toemoji.liston the sharedemojisingleton (imported fromapps/meteor/app/emoji/client/lib.ts), but there's noafterhook to remove them. Any other test blocks in this file or process sharing this module instance (e.g. tests forupdateRecent/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 winCategory-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 aSet<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
📒 Files selected for processing (2)
apps/meteor/app/emoji/client/helpers.tsapps/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.tsapps/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.tsextension 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.tsapps/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.tsapps/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.tsapps/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 thebreak→continuefix.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 CorrectnessNo typing issue here
EmojiPackages['native']is assignable toEmojiPackage, andcategoryIndexis optional.getEmojiConfig()already returnsemojiListentries withemojiPackage, so the direct mutation andemoji.packages.nativeassignment match the existing types.> Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
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('👍🏼');
});
|
hey @jessicaschelly and @KevLehman, we need your check here again. |
jessicaschelly
left a comment
There was a problem hiding this comment.
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
Co-authored-by: Matheus Cardoso <matheus@cardo.so>
Proposed changes (including videos or screenshots)
Issue(s)
CORE-2415
Steps to test or reproduce
Further comments
Summary by CodeRabbit
Bug Fixes
Tests