Skip to content

chore: Improving notifyOnEmailInboxChanged type safety #38860

Open
Pratheek555 wants to merge 3 commits into
RocketChat:developfrom
Pratheek555:ImprovedType
Open

chore: Improving notifyOnEmailInboxChanged type safety #38860
Pratheek555 wants to merge 3 commits into
RocketChat:developfrom
Pratheek555:ImprovedType

Conversation

@Pratheek555
Copy link
Copy Markdown
Contributor

@Pratheek555 Pratheek555 commented Feb 20, 2026

Proposed changes (including videos or screenshots)

This PR focuses on helping with the //TODO : improve typing remark in apps/meteor/app/lib/server/lib/notifyListener.ts. Upon understanding the places where notifyOnEmailInboxChanged is called and noticed that _id is compulsory to be passed while everything else is optional in the IEmailInbox interface.

Related Issue #38856

Changes Made

  • notifyListener.ts:
    • Replaced the generic union with Pick<IEmailInbox, '_id'> & Partial.
    • Removed the TODO comment.
    • Keeps _id required while accepting partial updates.

Summary by CodeRabbit

  • Refactor
    • Improved type safety in email inbox notification handling for enhanced code reliability.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Feb 20, 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 Feb 20, 2026

⚠️ No Changeset found

Latest commit: 25d24b9

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 Feb 20, 2026

Walkthrough

The notifyOnEmailInboxChanged function signature in the notifyListener module was updated to use a concrete type definition instead of a generic parameter. The data parameter type was changed from Pick<T, '_id'> | T to Pick<IEmailInbox, '_id'> & Partial<IEmailInbox>, enforcing stricter typing while maintaining the same observable behavior and broadcast behavior.

Changes

Cohort / File(s) Summary
Type Signature Refinement
apps/meteor/app/lib/server/lib/notifyListener.ts
Updated notifyOnEmailInboxChanged function parameter typing from generic <T extends IEmailInbox> to concrete type Pick<IEmailInbox, '_id'> & Partial<IEmailInbox>, eliminating generic constraints while ensuring _id presence and allowing additional partial fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A typing twist, so clear and bright,
Generic bounds replaced with might,
IEmailInbox now stands tall,
Concrete types conquering all! ✨

🚥 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 accurately summarizes the main change: improving type safety for the notifyOnEmailInboxChanged function by removing the generic parameter and using a more explicit type definition.
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 1 file

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/app/lib/server/lib/notifyListener.ts (1)

211-212: Consider using the already-imported AtLeast utility for consistency.

Pick<IEmailInbox, '_id'> & Partial<IEmailInbox> is semantically identical to AtLeast<IEmailInbox, '_id'>, which is already imported (line 16) and used elsewhere in this file for the same pattern (e.g., notifyOnIntegrationHistoryChanged). Using the utility type directly improves consistency and readability.

♻️ Proposed refactor
-export const notifyOnEmailInboxChanged = async (
-	data: Pick<IEmailInbox, '_id'> & Partial<IEmailInbox>,
+export const notifyOnEmailInboxChanged = async (
+	data: AtLeast<IEmailInbox, '_id'>,
	clientAction: ClientAction = 'updated',
): Promise<void> => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/lib/server/lib/notifyListener.ts` around lines 211 - 212,
Replace the ad-hoc type annotation in the notifyOnEmailInboxChanged signature
(currently "Pick<IEmailInbox, '_id'> & Partial<IEmailInbox>") with the
already-imported utility type AtLeast<IEmailInbox, '_id'> for consistency;
update the function declaration for notifyOnEmailInboxChanged to use
AtLeast<IEmailInbox, '_id'> and ensure no other code changes are needed since
AtLeast is already imported and used elsewhere (e.g.,
notifyOnIntegrationHistoryChanged).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0285d1 and 5dd7ca6.

📒 Files selected for processing (1)
  • apps/meteor/app/lib/server/lib/notifyListener.ts
🧰 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/app/lib/server/lib/notifyListener.ts
🧠 Learnings (2)
📓 Common learnings
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.
📚 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/app/lib/server/lib/notifyListener.ts
⏰ 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). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
🤖 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/app/lib/server/lib/notifyListener.ts`:
- Around line 211-212: Replace the ad-hoc type annotation in the
notifyOnEmailInboxChanged signature (currently "Pick<IEmailInbox, '_id'> &
Partial<IEmailInbox>") with the already-imported utility type
AtLeast<IEmailInbox, '_id'> for consistency; update the function declaration for
notifyOnEmailInboxChanged to use AtLeast<IEmailInbox, '_id'> and ensure no other
code changes are needed since AtLeast is already imported and used elsewhere
(e.g., notifyOnIntegrationHistoryChanged).

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.64%. Comparing base (8d73ce5) to head (25d24b9).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38860      +/-   ##
===========================================
- Coverage    70.65%   70.64%   -0.01%     
===========================================
  Files         3190     3190              
  Lines       112732   112732              
  Branches     20431    20382      -49     
===========================================
- Hits         79649    79642       -7     
- Misses       31035    31047      +12     
+ Partials      2048     2043       -5     
Flag Coverage Δ
e2e 60.34% <ø> (-0.01%) ⬇️
e2e-api 47.86% <ø> (ø)
unit 71.27% <100.00%> (-0.01%) ⬇️

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant