feat: Reaction notifications - #41701
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 7192cea The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
🚧 Files skipped from review as they are similar to previous changes (11)
📜 Recent review details⏰ Context from checks skipped due to timeout. (4)
WalkthroughThis PR adds reaction notifications for message authors. It adds global and per-user controls, client and REST preference support, server-side delivery, localized text, unit tests, and release metadata. ChangesReaction notifications
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Sequence Diagram(s)sequenceDiagram
participant Reactor
participant afterSetReaction
participant notifyAuthorOnReaction
participant DesktopNotification
Reactor->>afterSetReaction: Add reaction to message
afterSetReaction->>notifyAuthorOnReaction: Invoke reaction hook
notifyAuthorOnReaction->>notifyAuthorOnReaction: Check author, preference, subscription, and eligibility
notifyAuthorOnReaction->>DesktopNotification: Send localized notification
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/meteor/server/hooks/messages/notifyAuthorOnReaction.ts (1)
14-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the implementation comment.
The self-reaction condition is clear without the comment. As per coding guidelines, avoid code comments in implementation.
🤖 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/server/hooks/messages/notifyAuthorOnReaction.ts` at line 14, Remove the “skip self-reactions” implementation comment near the self-reaction handling, leaving the surrounding logic unchanged.Source: Coding guidelines
🤖 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/server/hooks/messages/notifyAuthorOnReaction.ts`:
- Line 59: Update the messageExcerpt assignment in notifyAuthorOnReaction to
truncate message.msg using the existing notification excerpt convention before
interpolation, while preserving the Attachment fallback for empty messages.
---
Nitpick comments:
In `@apps/meteor/server/hooks/messages/notifyAuthorOnReaction.ts`:
- Line 14: Remove the “skip self-reactions” implementation comment near the
self-reaction handling, leaving the surrounding logic unchanged.
🪄 Autofix
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 Plus
Run ID: 34b4cc54-3d4a-42ea-a060-0442d27e5fc1
📒 Files selected for processing (11)
.changeset/reaction-notifications.mdapps/meteor/client/views/account/preferences/PreferencesNotificationsSection.tsxapps/meteor/client/views/account/preferences/useAccountPreferencesValues.tsapps/meteor/server/hooks/messages/notifyAuthorOnReaction.tsapps/meteor/server/importPackages.tsapps/meteor/server/meteor-methods/users/saveUserPreferences.tsapps/meteor/server/settings/accounts.tsapps/meteor/server/settings/general.tsapps/meteor/tests/unit/server/hooks/messages/notifyAuthorOnReaction.spec.tspackages/i18n/src/locales/en.i18n.jsonpackages/rest-typings/src/v1/users/UsersSetPreferenceParamsPOST.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
- GitHub Check: 📦 Build Packages
- GitHub Check: cubic · AI code reviewer
- GitHub Check: CodeQL-Build
- GitHub Check: Hacktron Security Check
- GitHub Check: CodeQL-Build
🧰 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/server/importPackages.tsapps/meteor/client/views/account/preferences/PreferencesNotificationsSection.tsxapps/meteor/server/settings/general.tsapps/meteor/server/settings/accounts.tspackages/rest-typings/src/v1/users/UsersSetPreferenceParamsPOST.tsapps/meteor/server/meteor-methods/users/saveUserPreferences.tsapps/meteor/tests/unit/server/hooks/messages/notifyAuthorOnReaction.spec.tsapps/meteor/client/views/account/preferences/useAccountPreferencesValues.tsapps/meteor/server/hooks/messages/notifyAuthorOnReaction.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/server/hooks/messages/notifyAuthorOnReaction.spec.ts
🧠 Learnings (10)
📚 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/server/importPackages.tsapps/meteor/server/settings/general.tsapps/meteor/server/settings/accounts.tspackages/rest-typings/src/v1/users/UsersSetPreferenceParamsPOST.tsapps/meteor/server/meteor-methods/users/saveUserPreferences.tsapps/meteor/tests/unit/server/hooks/messages/notifyAuthorOnReaction.spec.tsapps/meteor/client/views/account/preferences/useAccountPreferencesValues.tsapps/meteor/server/hooks/messages/notifyAuthorOnReaction.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/server/importPackages.tsapps/meteor/server/settings/general.tsapps/meteor/server/settings/accounts.tspackages/rest-typings/src/v1/users/UsersSetPreferenceParamsPOST.tsapps/meteor/server/meteor-methods/users/saveUserPreferences.tsapps/meteor/tests/unit/server/hooks/messages/notifyAuthorOnReaction.spec.tsapps/meteor/client/views/account/preferences/useAccountPreferencesValues.tsapps/meteor/server/hooks/messages/notifyAuthorOnReaction.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/server/importPackages.tsapps/meteor/client/views/account/preferences/PreferencesNotificationsSection.tsxapps/meteor/server/settings/general.tsapps/meteor/server/settings/accounts.tspackages/rest-typings/src/v1/users/UsersSetPreferenceParamsPOST.tsapps/meteor/server/meteor-methods/users/saveUserPreferences.tsapps/meteor/tests/unit/server/hooks/messages/notifyAuthorOnReaction.spec.tsapps/meteor/client/views/account/preferences/useAccountPreferencesValues.tsapps/meteor/server/hooks/messages/notifyAuthorOnReaction.ts
📚 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/account/preferences/PreferencesNotificationsSection.tsx
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.
Applied to files:
.changeset/reaction-notifications.md
📚 Learning: 2026-05-11T23:14:59.316Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 40469
File: packages/rest-typings/src/v1/users.ts:337-337
Timestamp: 2026-05-11T23:14:59.316Z
Learning: In Rocket.Chat REST endpoint typings (e.g., packages/rest-typings/src/v1/users.ts and other rest-typings files), keep the established convention of deriving field types from the domain model (e.g., use IUser indexed access like IUser['statusExpiresAt']) rather than swapping individual fields to serialized primitives (like string) in an ad-hoc way. If a truly different “serialized” representation is needed, perform the refactor consistently across the codebase (not just a single endpoint/field) and ensure all related REST typings stay aligned with the shared serialization types.
Applied to files:
packages/rest-typings/src/v1/users/UsersSetPreferenceParamsPOST.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:
apps/meteor/tests/unit/server/hooks/messages/notifyAuthorOnReaction.spec.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/server/hooks/messages/notifyAuthorOnReaction.spec.ts
📚 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/account/preferences/useAccountPreferencesValues.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.
Applied to files:
apps/meteor/client/views/account/preferences/useAccountPreferencesValues.ts
🔇 Additional comments (12)
apps/meteor/server/settings/general.ts (1)
298-302: LGTM!apps/meteor/server/settings/accounts.ts (1)
467-471: LGTM!apps/meteor/server/meteor-methods/users/saveUserPreferences.ts (1)
56-56: LGTM!Also applies to: 133-133
packages/rest-typings/src/v1/users/UsersSetPreferenceParamsPOST.ts (2)
273-276: 🗄️ Data Integrity & IntegrationVerify REST null handling.
The schema accepts
receiveReactionNotifications: null.apps/meteor/server/meteor-methods/users/saveUserPreferences.tsaccepts only an omitted value or a boolean. If the REST handler forwardsdataunchanged, validation succeeds at the REST boundary and fails in the Meteor method. Removenullableor normalizenullbefore storage validation.
56-56: LGTM!apps/meteor/client/views/account/preferences/useAccountPreferencesValues.ts (1)
42-42: LGTM!Also applies to: 83-83, 116-116
apps/meteor/client/views/account/preferences/PreferencesNotificationsSection.tsx (1)
146-155: LGTM!packages/i18n/src/locales/en.i18n.json (1)
4505-4507: LGTM!Also applies to: 4529-4529
apps/meteor/server/hooks/messages/notifyAuthorOnReaction.ts (1)
1-13: LGTM!Also applies to: 15-58, 60-84
apps/meteor/server/importPackages.ts (1)
56-56: LGTM!apps/meteor/tests/unit/server/hooks/messages/notifyAuthorOnReaction.spec.ts (1)
1-86: LGTM!.changeset/reaction-notifications.md (1)
1-6: LGTM!
ae6699c to
8a3bda5
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #41701 +/- ##
===========================================
- Coverage 68.64% 68.61% -0.03%
===========================================
Files 4164 4165 +1
Lines 158957 158989 +32
Branches 28160 28213 +53
===========================================
- Hits 109113 109092 -21
- Misses 44678 44716 +38
- Partials 5166 5181 +15
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.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
8a3bda5 to
b09c285
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Sends a desktop/in-app notification to a message's author when another user reacts to it, reusing the existing notification pipeline. Delivery goes through notifyDesktopUser and is gated by shouldNotifyDesktop plus the recipient's room subscription, so it honors the desktop notification preference, mute, and busy/offline presence. Self-reactions are skipped. The emoji shortcode is rendered as unicode and the body includes an excerpt of the reacted message. Toggle is layered: - Global admin switch 'Reaction_Notifications_Enabled' (default on) as a master kill switch that adds/removes the callback at runtime. - Per-user 'receiveReactionNotifications' preference (default on) exposed in Account > Preferences > Notifications for individual opt-out. Co-authored-by: Divyanshu <divyanshuchandra9027@gmail.com>
b09c285 to
7192cea
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Notifies a message author when someone reacts to their message. Ported to current
developand merge-ready.Incorporates the work by @DivyanshuVortex in #40303 (co-authored). That branch was ~466 commits behind and on an old file layout, so this is a clean reimplementation of the same feature on current develop, keeping the design decisions from the discussion there.
Closes #40303
Behavior
afterSetReactionhook notifies the message author when another user reacts (self-reactions skipped).notifyDesktopUser), gated byshouldNotifyDesktop+ the recipient's room subscription → honors desktop pref, mute, busy/offline presence.{name} reacted with {emoji} to your message: {excerpt}; shortcode rendered as unicode viashortnameToUnicode.Toggle (layered)
Reaction_Notifications_Enabled(General → Notifications, default on) — master kill switch; adds/removes the callback at runtime viasettings.watch.receiveReactionNotifications(default on) — Account → Preferences → Notifications.Files
Server hook + settings (global + per-user default), per-user preference plumbing (account prefs UI,
useAccountPreferencesValues,saveUserPreferenceswhitelist,users.setPreferencesajv schema), i18n, and a unit spec (5 cases: self-react, opt-out, no subscription, desktop gated, happy path).Verification
rest-typingstypechecks clean.Summary by CodeRabbit
New Features
Bug Fixes