Skip to content

fix: save recent emojis when selected from composer popup and fix emoji sort #40167

Open
Naetiksoni08 wants to merge 3 commits intoRocketChat:developfrom
Naetiksoni08:fix/emoji-sort-idB-typo
Open

fix: save recent emojis when selected from composer popup and fix emoji sort #40167
Naetiksoni08 wants to merge 3 commits intoRocketChat:developfrom
Naetiksoni08:fix/emoji-sort-idB-typo

Conversation

@Naetiksoni08
Copy link
Copy Markdown
Contributor

@Naetiksoni08 Naetiksoni08 commented Apr 15, 2026

Proposed changes (including videos or screenshots)

Two related bugs were found and fixed in the emoji composer popup:

Bug 1 — Recent emojis never saved from composer popup

When a user selected an emoji using the : or +: trigger in the message composer, addRecentEmoji was never called. This meant emoji.recent in localStorage was never populated, so the "recently used" sorting had no data to work with.

Fix: Added an onSelect callback to ComposerPopupOption type and wired it up in both emoji popup configs to call addRecentEmoji on selection.

Bug 2 — Broken sort in +: emoji reaction popup

In the emojiSort function for the +: trigger, idB was incorrectly assigned a._id instead of b._id, causing every comparison to return 0 (equal) and
making the sort completely ineffective.

// Before (broken)
let idA = a._id;                                                                                                                                                
let idB = a._id; // ← always comparing a against itself
                                                                                                                                                                
// After (fixed)
let idA = a._id;                                                                                                                                                
let idB = b._id;

Before Fix: Recently used emojis never appeared at the top. Order was random.

Screenshot 2026-04-15 at 2 15 15 PM Screenshot 2026-04-15 at 2 11 45 PM

And because of this emoji.recent in localStorage was never populated

After Fix: Recently used emojis correctly appear at the top of the popup.

Screenshot 2026-04-15 at 2 15 15 PM Screenshot 2026-04-15 at 2 16 16 PM

And now this emoji.recent in localStorage is populated correctly

Screenshot 2026-04-15 at 2 17 31 PM

Steps to test or reproduce

  1. Open any room or DM
  2. Type smirk: in the composer and select it from the popup to send
  3. Now type +:smi in the composer
  4. Before fix: smirk: does not appear at the top
  5. After fix: smirk: appears at the top as a recently used emoji

Further comments

The root cause was that the composer popup had no mechanism to notify the emoji system when an emoji was selected. The fix adds an optional onSelect callback to ComposerPopupOption which is generic enough to be used by other popup types in the future if needed.

Summary by CodeRabbit

  • New Features

    • Composer popups can run item-specific onSelect actions when an option is chosen.
    • Emoji picker now saves recently used emojis for faster access.
  • Bug Fixes

    • Fixed emoji ordering so recently used and search results sort correctly.
  • Refactor

    • Improved emoji selection handling and stability for popup behaviors.

@Naetiksoni08 Naetiksoni08 requested a review from a team as a code owner April 15, 2026 09:15
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Apr 15, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 15, 2026

⚠️ No Changeset found

Latest commit: ec5c9fa

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds an optional onSelect callback to composer popup options, invokes it after item selection (before clearing state), wires emoji selections to record recent-emoji history, and fixes an emoji comparator initialization bug.

Changes

Cohort / File(s) Summary
Popup option type
apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
Added optional onSelect?: (item: T) => void to ComposerPopupOption<T>.
Popup hook
apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
Invoke option.onSelect?.(item) after performing selection logic and before clearing popup state (optionIndex/focused).
Emoji picker provider
apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
Consume emoji picker context to get addRecentEmoji, add onSelect handlers for emoji popups that call addRecentEmoji(item._id.slice(1, -1)), fix comparator by using b._id for idB, and add addRecentEmoji to memo deps.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ComposerPopupUI as "ComposerPopup UI"
  participant PopupHook as "useComposerBoxPopup"
  participant Provider as "ComposerPopupProvider"
  participant EmojiStore as "RecentEmojiStore"

  User->>ComposerPopupUI: select item
  ComposerPopupUI->>PopupHook: select(item)
  PopupHook->>PopupHook: perform selection logic (commands/replaceText)
  PopupHook->>Provider: call option.onSelect?(item)
  Provider->>EmojiStore: addRecentEmoji(item._id.slice(1, -1))
  PopupHook->>ComposerPopupUI: clear popup state (setOptionIndex, setFocused)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the two main fixes: saving recent emojis when selected from composer popup and fixing the emoji sort bug.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts (1)

113-115: Ensure popup cleanup always runs even if onSelect fails.

A thrown error in option.onSelect can currently skip reset of optionIndex/focused. Wrapping callback + teardown in try/finally keeps UI state consistent.

♻️ Proposed change
-		option.onSelect?.(item);
-		setOptionIndex(-1);
-		setFocused(undefined);
+		try {
+			option.onSelect?.(item);
+		} finally {
+			setOptionIndex(-1);
+			setFocused(undefined);
+		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts` around
lines 113 - 115, The current call to option.onSelect inside the handler can
throw and prevent the cleanup calls setOptionIndex(-1) and setFocused(undefined)
from running; modify the selection flow in useComposerBoxPopup so that you
invoke option.onSelect(item) inside a try block and perform the cleanup
(setOptionIndex(-1) and setFocused(undefined)) in a finally block to guarantee
popup state reset even if option.onSelect throws. Ensure you still call
option.onSelect?.(item) (guarded for undefined) and keep the final cleanup
semantics intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts`:
- Around line 113-115: The current call to option.onSelect inside the handler
can throw and prevent the cleanup calls setOptionIndex(-1) and
setFocused(undefined) from running; modify the selection flow in
useComposerBoxPopup so that you invoke option.onSelect(item) inside a try block
and perform the cleanup (setOptionIndex(-1) and setFocused(undefined)) in a
finally block to guarantee popup state reset even if option.onSelect throws.
Ensure you still call option.onSelect?.(item) (guarded for undefined) and keep
the final cleanup semantics intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c006a97e-d25f-4ea5-aa72-26b7bb87e7a1

📥 Commits

Reviewing files that changed from the base of the PR and between 41f6662 and b8459a6.

📒 Files selected for processing (3)
  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{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/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
🧠 Learnings (8)
📚 Learning: 2026-04-10T22:42:03.240Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 40075
File: apps/meteor/client/views/room/modals/FileUploadModal/FileUploadModal.tsx:69-71
Timestamp: 2026-04-10T22:42:03.240Z
Learning: In `apps/meteor/client/views/room/modals/FileUploadModal/FileUploadModal.tsx`, the submit handler converts an empty/whitespace-only description to `undefined` (`description?.trim() || undefined`) intentionally. All downstream image-rendering components (`AttachmentImage`, `ImagePreview`, `ImageItem`, `ImageGallery`) default `undefined` alt to `''`, so the `<img alt="">` attribute is always present. Do not flag this `undefined` conversion as a bug preventing alt text from being cleared.

Applied to files:

  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
📚 Learning: 2026-03-04T14:16:49.202Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39304
File: packages/ui-contexts/src/ActionManagerContext.ts:26-26
Timestamp: 2026-03-04T14:16:49.202Z
Learning: In `packages/ui-contexts/src/ActionManagerContext.ts` (TypeScript, RocketChat/Rocket.Chat), the `disposeView` method in `IActionManager` uses an intentionally explicit union `UiKit.ModalView['id'] | UiKit.BannerView['viewId'] | UiKit.ContextualBarView['id']` to document which view types are accepted, even though all constituents resolve to the same primitive. The inline `// eslint-disable-next-line typescript-eslint/no-duplicate-type-constituents` comment is intentional and should not be flagged or removed.

Applied to files:

  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
📚 Learning: 2026-03-11T22:04:20.529Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 39545
File: apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts:59-61
Timestamp: 2026-03-11T22:04:20.529Z
Learning: In `apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts`, the `msg.u._id === uid` early-return in the `streamNewMessage` handler is intentional: the "New messages" indicator is designed to notify about messages from other users only. Self-sent messages — including those sent from a different session/device — are always skipped, by design. Do not flag this as a multi-session regression.

Applied to files:

  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.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/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.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/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
📚 Learning: 2025-12-02T22:23:49.593Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37654
File: apps/meteor/client/hooks/useAppSlashCommands.ts:32-38
Timestamp: 2025-12-02T22:23:49.593Z
Learning: In apps/meteor/client/hooks/useAppSlashCommands.ts, the `data?.forEach((command) => slashCommands.add(command))` call during render is intentional. The query is configured with `structuralSharing: false` to prevent React Query from keeping stable data references, and `slashCommands.add` is idempotent, so executing on every render is acceptable and ensures the command registry stays current.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
🔇 Additional comments (3)
apps/meteor/client/views/room/contexts/ComposerPopupContext.ts (1)

23-23: Optional onSelect hook is a clean, backward-compatible extension.

Adding it as optional keeps existing popup configs unaffected while enabling selection side-effects in typed consumers.

apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx (2)

247-248: Recent-emoji tracking integration is correctly wired in both emoji popups.

Hooking onSelect to addRecentEmoji for both : and +: paths, plus including addRecentEmoji in useMemo deps, keeps behavior consistent and closure-safe.

Also applies to: 305-306, 394-394


261-263: Comparator typo fix is correct.

Initializing idB from b._id restores proper pairwise comparison in the +: emoji sort path.

@Naetiksoni08 Naetiksoni08 force-pushed the fix/emoji-sort-idB-typo branch from b8459a6 to 6b3842b Compare April 16, 2026 07:28
@coderabbitai coderabbitai Bot removed the type: bug label Apr 16, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx (1)

260-277: ⚠️ Potential issue | 🟡 Minor

Fix lexicographic misordering in emoji sort comparator for 2-digit recent indexes.

Lines 265 and 268 concatenate numeric indexOf() results with string _id values. In JavaScript, this triggers string concatenation (e.g., 10 + ":joy:" becomes "10:joy:"), causing incorrect lexicographic ordering where index 10 sorts before index 2.

Suggested fix
-					const emojiSort = (recents: string[]) => (a: { _id: string }, b: { _id: string }) => {
-						let idA = a._id;
-						let idB = b._id;
-
-						if (recents.includes(a._id)) {
-							idA = recents.indexOf(a._id) + idA;
-						}
-						if (recents.includes(b._id)) {
-							idB = recents.indexOf(b._id) + idB;
-						}
-
-						if (idA < idB) {
-							return -1;
-						}
-
-						if (idA > idB) {
-							return 1;
-						}
-
-						return 0;
-					};
+					const emojiSort = (recents: string[]) => (a: { _id: string }, b: { _id: string }) => {
+						const rank = (id: string) => {
+							const index = recents.indexOf(id);
+							return index === -1 ? Number.MAX_SAFE_INTEGER : index;
+						};
+
+						const rankA = rank(a._id);
+						const rankB = rank(b._id);
+
+						if (rankA !== rankB) {
+							return rankA - rankB;
+						}
+
+						return a._id.localeCompare(b._id);
+					};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx` around
lines 260 - 277, The emojiSort comparator in ComposerPopupProvider.tsx currently
concatenates recents.indexOf(...) with the _id (idA/idB), causing lexicographic
misordering for multi-digit indexes; instead compute a numeric recentIndex
(e.g., const recentIndexA = recents.includes(a._id) ? recents.indexOf(a._id) :
Infinity) and compare recentIndexA vs recentIndexB first, returning their
numeric comparison if different, and only fall back to comparing a._id and b._id
lexicographically when the recent indexes are equal; update the emojiSort
closure (variables idA/idB, recents, comparator return path) to use this
numeric-first comparison.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx`:
- Around line 260-277: The emojiSort comparator in ComposerPopupProvider.tsx
currently concatenates recents.indexOf(...) with the _id (idA/idB), causing
lexicographic misordering for multi-digit indexes; instead compute a numeric
recentIndex (e.g., const recentIndexA = recents.includes(a._id) ?
recents.indexOf(a._id) : Infinity) and compare recentIndexA vs recentIndexB
first, returning their numeric comparison if different, and only fall back to
comparing a._id and b._id lexicographically when the recent indexes are equal;
update the emojiSort closure (variables idA/idB, recents, comparator return
path) to use this numeric-first comparison.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f459aeac-0ae8-4592-a5c0-9a89128b5254

📥 Commits

Reviewing files that changed from the base of the PR and between b8459a6 and 6b3842b.

📒 Files selected for processing (3)
  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{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/client/views/room/providers/ComposerPopupProvider.tsx
🧠 Learnings (3)
📚 Learning: 2026-03-11T22:04:20.529Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 39545
File: apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts:59-61
Timestamp: 2026-03-11T22:04:20.529Z
Learning: In `apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts`, the `msg.u._id === uid` early-return in the `streamNewMessage` handler is intentional: the "New messages" indicator is designed to notify about messages from other users only. Self-sent messages — including those sent from a different session/device — are always skipped, by design. Do not flag this as a multi-session regression.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2025-12-02T22:23:49.593Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37654
File: apps/meteor/client/hooks/useAppSlashCommands.ts:32-38
Timestamp: 2025-12-02T22:23:49.593Z
Learning: In apps/meteor/client/hooks/useAppSlashCommands.ts, the `data?.forEach((command) => slashCommands.add(command))` call during render is intentional. The query is configured with `structuralSharing: false` to prevent React Query from keeping stable data references, and `slashCommands.add` is idempotent, so executing on every render is acceptable and ensures the command registry stays current.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
🔇 Additional comments (3)
apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx (3)

187-187: Whitespace-only JSX formatting change.

No functional impact.


31-31: Good integration of emoji-recents callback into memoized config.

Line 88 correctly consumes addRecentEmoji, and Line 394 includes it in the useMemo deps, avoiding stale callback capture.

Also applies to: 88-88, 394-394


247-247: Selection side-effect wiring looks correct for both emoji triggers.

Using item._id.slice(1, -1) passes the unwrapped emoji id expected by addRecentEmoji, so both : and +: flows now persist recents.

Also applies to: 305-305

@Naetiksoni08 Naetiksoni08 force-pushed the fix/emoji-sort-idB-typo branch from 6b3842b to 198e159 Compare April 17, 2026 06:11
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 (1)
apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx (1)

260-280: Consider unifying the two emojiSort implementations.

With idB fixed, this sort now runs, but the string-concatenation approach is fragile and inconsistent with the score-based emojiSort in the : block above (lines 199–222):

  • Multi-digit recent indices sort lexicographically — e.g., index "10" prefixes come before "2" prefixes ('1' < '2'), so a less-recent entry can bubble above a more-recent one once recents grow beyond 10.
  • Non-recent items fall back to plain _id alphabetical order with no exact/prefix weighting against key, unlike the : variant.

Aligning both blocks on the score-based comparator (and extracting the duplicated getItemsFromLocal body) would fix the ordering edge case and remove ~40 lines of duplication.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx` around
lines 260 - 280, The two emojiSort implementations are inconsistent and fragile
(string-concatenation causes lexicographic bugs); refactor by replacing the
second emojiSort with the same score-based comparator used by the first one:
compute a numeric score for each item using recents.indexOf(id) (with
non-recents given a large sentinel like Infinity or -1 handled consistently)
plus a secondary tie-breaker of _id or key, then compare those numeric scores
instead of concatenating strings; also extract the duplicated getItemsFromLocal
logic into a single helper used by both the ':' and emoji branches to remove ~40
lines of duplication and ensure both branches use the same ordering logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx`:
- Line 88: ComposerPopupProvider currently calls useEmojiPickerData() (which
calls useEmojiPickerContext() and throws if missing) unconditionally; change it
so ComposerPopupProvider no longer crashes when EmojiPickerProvider is absent by
either using a non-throwing accessor or guarding the call: implement or use an
optional hook (e.g., useOptionalEmojiPickerContext or modify useEmojiPickerData
to return null/noop when context is missing) and only call addRecentEmoji when
the context exists, or wrap the component with EmojiPickerProvider at the top
level; update references to useEmojiPickerData, useEmojiPickerContext,
ComposerPopupProvider, and addRecentEmoji accordingly so the provider absence is
handled safely.

---

Nitpick comments:
In `@apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx`:
- Around line 260-280: The two emojiSort implementations are inconsistent and
fragile (string-concatenation causes lexicographic bugs); refactor by replacing
the second emojiSort with the same score-based comparator used by the first one:
compute a numeric score for each item using recents.indexOf(id) (with
non-recents given a large sentinel like Infinity or -1 handled consistently)
plus a secondary tie-breaker of _id or key, then compare those numeric scores
instead of concatenating strings; also extract the duplicated getItemsFromLocal
logic into a single helper used by both the ':' and emoji branches to remove ~40
lines of duplication and ensure both branches use the same ordering logic.
🪄 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: 0612f046-701a-4bc5-9e84-61b6723530bd

📥 Commits

Reviewing files that changed from the base of the PR and between 6b3842b and 198e159.

📒 Files selected for processing (3)
  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
✅ Files skipped from review due to trivial changes (1)
  • apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/views/room/contexts/ComposerPopupContext.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{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/client/views/room/providers/ComposerPopupProvider.tsx
🧠 Learnings (3)
📚 Learning: 2026-03-11T22:04:20.529Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 39545
File: apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts:59-61
Timestamp: 2026-03-11T22:04:20.529Z
Learning: In `apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts`, the `msg.u._id === uid` early-return in the `streamNewMessage` handler is intentional: the "New messages" indicator is designed to notify about messages from other users only. Self-sent messages — including those sent from a different session/device — are always skipped, by design. Do not flag this as a multi-session regression.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2025-12-02T22:23:49.593Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37654
File: apps/meteor/client/hooks/useAppSlashCommands.ts:32-38
Timestamp: 2025-12-02T22:23:49.593Z
Learning: In apps/meteor/client/hooks/useAppSlashCommands.ts, the `data?.forEach((command) => slashCommands.add(command))` call during render is intentional. The query is configured with `structuralSharing: false` to prevent React Query from keeping stable data references, and `slashCommands.add` is idempotent, so executing on every render is acceptable and ensures the command registry stays current.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
🔇 Additional comments (1)
apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx (1)

262-262: Good catch on the comparator fix.

Setting idB = b._id (previously a._id) makes the \+: reaction popup comparator actually meaningful — the prior self-comparison always produced 0 and left ordering undefined.

Comment thread apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx Outdated
@coderabbitai coderabbitai Bot removed the type: bug label Apr 17, 2026
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx">

<violation number="1" location="apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx:210">
P2: Recent emojis are scored backwards in the `:` popup, so older recents can sort above newer ones and even outrank exact matches.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx (1)

267-287: ⚠️ Potential issue | 🟡 Minor

+: sort: fix is correct, but the comparator is still fragile and inconsistent with the : popup.

The idB = b._id fix resolves the self-comparison bug. However, two concerns remain in this comparator:

  1. Numeric-as-string ordering breaks at 10+ recents. recents.indexOf(a._id) + idA prepends the index as a string; lexicographic compare gives "10:smile:" < "2:smile:", so once emoji.recent grows to 10+ matching entries, recent-order is wrong. Consider pinning the recent check as a primary comparator returning numeric indices directly.
  2. Match quality is ignored. Unlike the new : popup (lines 200–229) which scores exact/prefix matches first, this comparator sorts by raw _id (with the index-prefix hack). The two popups will now order similar candidate sets differently for the same filter.

Consider reusing the same emojiSort helper for both popups so behavior stays consistent.

♻️ Example: reuse the `:` popup comparator
-				const emojiSort = (recents: string[]) => (a: { _id: string }, b: { _id: string }) => {
-					let idA = a._id;
-					let idB = b._id;
-
-					if (recents.includes(a._id)) {
-						idA = recents.indexOf(a._id) + idA;
-					}
-					if (recents.includes(b._id)) {
-						idB = recents.indexOf(b._id) + idB;
-					}
-
-					if (idA < idB) {
-						return -1;
-					}
-
-					if (idA > idB) {
-						return 1;
-					}
-
-					return 0;
-				};
+				const emojiSort = (recents: string[]) => (a: { _id: string }, b: { _id: string }) => {
+					const aExact = a._id === key ? 2 : 0;
+					const bExact = b._id === key ? 2 : 0;
+					const aPartial = a._id.startsWith(key) ? 1 : 0;
+					const bPartial = b._id.startsWith(key) ? 1 : 0;
+					const aScore = aExact + aPartial;
+					const bScore = bExact + bPartial;
+					if (aScore !== bScore) return bScore - aScore;
+					const aRecent = recents.indexOf(a._id);
+					const bRecent = recents.indexOf(b._id);
+					if (aRecent === bRecent) return 0;
+					if (aRecent === -1) return 1;
+					if (bRecent === -1) return -1;
+					return aRecent - bRecent;
+				};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx` around
lines 267 - 287, The comparator emojiSort currently builds string prefixes and
does lexicographic compares which breaks when recents length >=10 and ignores
match quality; change emojiSort to return a numeric comparison: first compute
recent indices for a and b (use -1 when not found) and return compare(recIndexA,
recIndexB) if indices differ (treat found<not found), then reuse the same
match-quality scoring used by the ":" popup (the scoring routine from the popup
comparator at lines ~200–229) to compare exact/prefix matches, and finally fall
back to comparing the raw _id strings; consider extracting that scoring logic
into a shared helper and have both popups call it so ordering is consistent
across both emoji popups.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx`:
- Around line 267-287: The comparator emojiSort currently builds string prefixes
and does lexicographic compares which breaks when recents length >=10 and
ignores match quality; change emojiSort to return a numeric comparison: first
compute recent indices for a and b (use -1 when not found) and return
compare(recIndexA, recIndexB) if indices differ (treat found<not found), then
reuse the same match-quality scoring used by the ":" popup (the scoring routine
from the popup comparator at lines ~200–229) to compare exact/prefix matches,
and finally fall back to comparing the raw _id strings; consider extracting that
scoring logic into a shared helper and have both popups call it so ordering is
consistent across both emoji popups.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0c57b3de-d0b0-4be4-8271-496101ccd68c

📥 Commits

Reviewing files that changed from the base of the PR and between faa6052 and 5ca8362.

📒 Files selected for processing (1)
  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{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/client/views/room/providers/ComposerPopupProvider.tsx
🧠 Learnings (13)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
📚 Learning: 2026-02-24T19:36:55.089Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/home-content.ts:60-82
Timestamp: 2026-02-24T19:36:55.089Z
Learning: In RocketChat/Rocket.Chat e2e tests (apps/meteor/tests/e2e/page-objects/fragments/home-content.ts), thread message preview listitems do not have aria-roledescription="message", so lastThreadMessagePreview locator cannot be scoped to messageListItems (which filters for aria-roledescription="message"). It should remain scoped to page.getByRole('listitem') or mainMessageList.getByRole('listitem').

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-03-04T14:16:49.202Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39304
File: packages/ui-contexts/src/ActionManagerContext.ts:26-26
Timestamp: 2026-03-04T14:16:49.202Z
Learning: In `packages/ui-contexts/src/ActionManagerContext.ts` (TypeScript, RocketChat/Rocket.Chat), the `disposeView` method in `IActionManager` uses an intentionally explicit union `UiKit.ModalView['id'] | UiKit.BannerView['viewId'] | UiKit.ContextualBarView['id']` to document which view types are accepted, even though all constituents resolve to the same primitive. The inline `// eslint-disable-next-line typescript-eslint/no-duplicate-type-constituents` comment is intentional and should not be flagged or removed.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-03-20T13:51:23.302Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 39553
File: apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts:179-181
Timestamp: 2026-03-20T13:51:23.302Z
Learning: In `apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts`, the truthiness guards `...(integration.avatar && { avatar })`, `...(integration.emoji && { emoji })`, `...(integration.alias && { alias })`, and `...(integration.script && { script })` in the `$set` payload of `updateIncomingIntegration` are intentional. Empty-string values for these fields should NOT overwrite the stored value — only truthy values are persisted. Do not flag these as bugs preventing explicit clears.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-03-06T18:10:23.330Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:23.330Z
Learning: In the RocketChat/Rocket.Chat `packages/gazzodown` package and more broadly, the HTML `<code>` element has an implicit ARIA role of `code` per WAI-ARIA 1.3, and `testing-library/dom` / jsdom supports it. Therefore, `screen.getByRole('code')` / `screen.findByRole('code')` correctly locates `<code>` elements without needing an explicit `role="code"` attribute. Do NOT flag `findByRole('code')` as invalid in future reviews.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-04-10T22:42:05.539Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 40075
File: apps/meteor/client/views/room/modals/FileUploadModal/FileUploadModal.tsx:69-71
Timestamp: 2026-04-10T22:42:05.539Z
Learning: In `apps/meteor/client/views/room/modals/FileUploadModal/FileUploadModal.tsx`, the submit handler converts an empty/whitespace-only description to `undefined` (`description?.trim() || undefined`) intentionally. All downstream image-rendering components (`AttachmentImage`, `ImagePreview`, `ImageItem`, `ImageGallery`) default `undefined` alt to `''`, so the `<img alt="">` attribute is always present. Do not flag this `undefined` conversion as a bug preventing alt text from being cleared.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2025-12-02T22:23:49.593Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37654
File: apps/meteor/client/hooks/useAppSlashCommands.ts:32-38
Timestamp: 2025-12-02T22:23:49.593Z
Learning: In apps/meteor/client/hooks/useAppSlashCommands.ts, the `data?.forEach((command) => slashCommands.add(command))` call during render is intentional. The query is configured with `structuralSharing: false` to prevent React Query from keeping stable data references, and `slashCommands.add` is idempotent, so executing on every render is acceptable and ensures the command registry stays current.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-04-14T21:10:36.233Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36292
File: apps/meteor/client/hooks/useHasValidLocationHash.ts:7-12
Timestamp: 2026-04-14T21:10:36.233Z
Learning: In the RocketChat/Rocket.Chat repository, adding JSDoc-style comments to React hooks (e.g., files under apps/meteor/client/hooks/) is considered a good pattern and should not be flagged as a violation of the "avoid code comments in the implementation" guideline. The guideline against code comments does not apply to JSDoc documentation on exported hooks.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-01-19T18:08:13.423Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38169
File: packages/ui-client/src/hooks/useGoToDirectMessage.ts:20-27
Timestamp: 2026-01-19T18:08:13.423Z
Learning: In React hooks, including custom hooks like useUserSubscriptionByName, must always be called unconditionally and in the same order on every render, per the Rules of Hooks. Passing empty strings or fallback values to hooks is the correct approach when dealing with potentially undefined values, rather than conditionally calling the hook based on whether the value exists.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-04-13T16:40:55.864Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 40100
File: apps/meteor/client/views/root/MainLayout/EmbeddedPreload.tsx:18-35
Timestamp: 2026-04-13T16:40:55.864Z
Learning: In Rocket.Chat's embedded mode (`?layout=embedded`), route changes are driven by the parent frame reloading the iframe URL, which causes a full remount of the React tree (including `EmbeddedPreload` at `apps/meteor/client/views/root/MainLayout/EmbeddedPreload.tsx`). The component never survives a navigation, so `roomParams` (computed via `useMemo`) is always fresh on mount. A `[router]` singleton as the sole `useMemo` dependency is therefore correct and intentional — do not flag it as a stale-dependency bug in this component.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2026-03-09T18:39:21.178Z
Learnt from: Harxhit
Repo: RocketChat/Rocket.Chat PR: 39476
File: apps/meteor/server/methods/addAllUserToRoom.ts:0-0
Timestamp: 2026-03-09T18:39:21.178Z
Learning: In apps/meteor/server/methods/addAllUserToRoom.ts, the implementation uses a single cursor pass (Users.find(userFilter).batchSize(100)) that collects both the full user objects (collectedUsers: IUser[]) and their usernames (usernames: string[]) in one iteration. `beforeAddUserToRoom` is then called once with the full usernames batch (preserving batch-validation semantics), and the subsequent subscription/message processing loop iterates over the same stable `collectedUsers` array — no second DB query is made. This avoids any race condition between validation and processing while preserving the original batch-validation behavior.

Applied to files:

  • apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
🔇 Additional comments (3)
apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx (3)

88-89: Safe fallback for missing EmojiPickerProvider — LGTM.

Using useContext(EmojiPickerContext) directly with ?? (() => undefined) correctly prevents crashes when the provider is absent (tests, Storybook, embedded surfaces). Matches the pattern agreed in the previous review.


200-254: : popup: new match-quality sort + recent wiring looks correct.

Score-first ordering (exact > prefix > other) with a recency tiebreaker is an improvement over the previous index-concatenation approach, and the onSelect: (item) => addRecentEmoji(item._id.slice(1, -1)) correctly strips the surrounding : before persisting to emoji.recent (matches the localStorage screenshot in the PR description).


312-312: Recording recent emoji on +: selection — LGTM.

Mirrors the : popup wiring and produces the unprefixed shortcode expected by addRecentEmoji.

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.

1 participant