Skip to content

refactor(core-typings): Record types missing a required _updatedAt field#38528

Draft
tassoevan wants to merge 11 commits intodevelopfrom
refactor/optional-updated-at-field
Draft

refactor(core-typings): Record types missing a required _updatedAt field#38528
tassoevan wants to merge 11 commits intodevelopfrom
refactor/optional-updated-at-field

Conversation

@tassoevan
Copy link
Contributor

@tassoevan tassoevan commented Feb 6, 2026

Proposed changes (including videos or screenshots)

Some record types (i.e. types that represent database documents) are not properly declaring the presence of the _updatedAt field. This PR normalizes it and refines API methods to reflect it.

Issue(s)

ARCH-1931

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes

    • Custom sound uploads and renames now broadcast the actual updated sound only when the update is confirmed, improving sync accuracy.
  • User Interface

    • Removed the "Updated at" timestamp from the instance details modal for a cleaner view.
  • Refactor

    • Standardized record shapes, event payloads, and method signatures across custom sounds, business hours, user statuses, credential tokens and related models for consistency.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 6, 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 targeting the wrong base branch. It should target 8.2.0, but it targets 8.1.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

⚠️ No Changeset found

Latest commit: e8a28d7

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
Contributor

coderabbitai bot commented Feb 6, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Walkthrough

Consolidates record identity/timestamps under IRocketChatRecord, narrows input types to exclude _updatedAt, updates models to return full updated documents for custom sounds, adjusts server broadcasts to send fetched/updated sound objects, removes IInquiry, and updates related signatures and UI that displayed _updatedAt.

Changes

Cohort / File(s) Summary
Core typings — introduce / centralize record shape
packages/core-typings/src/IRocketChatRecord.ts, packages/core-typings/src/ICustomSound.ts, packages/core-typings/src/ICustomUserStatus.ts, packages/core-typings/src/ILivechatBusinessHour.ts, packages/core-typings/src/ILivechatDepartment.ts, packages/core-typings/src/ICronHistoryItem.ts, packages/core-typings/src/ICredentialToken.ts, packages/core-typings/src/IEmailMessageHistory.ts, packages/core-typings/src/ISmarshHistory.ts, packages/core-typings/src/ICronHistoryItem.ts
Many interfaces now extend IRocketChatRecord; explicit _id and _updatedAt fields removed from those interfaces, centralizing record metadata.
Core typings — removals / adjustments
packages/core-typings/src/IInquiry.ts, packages/core-typings/src/IInstanceStatus.ts
IInquiry removed; IInstanceStatus no longer extends IRocketChatRecord and now declares _id explicitly.
Model typings & models — CustomSounds & BusinessHours
packages/model-typings/src/models/ICustomSoundsModel.ts, packages/models/src/models/CustomSounds.ts, packages/model-typings/src/models/ILivechatBusinessHoursModel.ts, packages/models/src/models/LivechatBusinessHours.ts
CustomSounds.setName now returns `Promise<ICustomSound
Server methods — custom sounds broadcasting
apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts, apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts
When renaming or after upload completes, handlers now use the model-returned document (fetched updated sound) and broadcast only if that document exists, sending the full sound object as payload.
Livechat — business hours typings & usage
apps/meteor/app/livechat/server/business-hour/LivechatBusinessHours.ts, apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.ts
Function signatures narrowed to accept/return types that omit _updatedAt where appropriate.
Client types & contexts
apps/meteor/client/lib/userStatuses.ts, apps/meteor/client/providers/CustomSoundProvider/CustomSoundProvider.tsx, apps/meteor/client/providers/CustomSoundProvider/lib/helpers.ts, packages/ui-contexts/src/CustomSoundContext.ts
Public/client types changed to use Omit<..., '_updatedAt'> for custom sounds and custom user statuses; runtime logic unchanged.
UI — Instances modal
apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.tsx, .../InstancesModal.stories.tsx
Removed rendering and story data for instance ._updatedAt (created remains).
Core services events
packages/core-services/src/events/Events.ts
Removed IInquiry import and updated livechat-inquiry-queue-observer event payload to use ILivechatInquiryRecord for inquiry.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as Client
  participant Server as CustomSounds Service
  participant DB as Database
  participant Notify as Notify/Broadcast

  Note over Client,Server: Upload or rename request initiated
  Client->>Server: upload sound / rename request
  Server->>DB: write (insert / findOneAndUpdate)
  DB-->>Server: returns inserted/updated document (or null)
  alt document returned
    Server->>Notify: broadcast `updateCustomSound` with full sound object
    Notify->>Client: notify clients
  else no document
    Server-->>Client: no broadcast
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐇
I hopped through types and fields anew,
Gathered records tidy as dew,
Found the sound, then gave a ring,
Only when the doc exists I sing,
A cheerful hop — the changes true.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Changes include removal of IInquiry interface and updates to IInstanceStatus (removing IRocketChatRecord inheritance), which extend beyond the core _updatedAt field normalization. Clarify rationale for IInquiry removal and IInstanceStatus refactoring, or move these changes to a separate PR focused on those specific concerns.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main refactoring effort to fix record types missing proper _updatedAt field declarations.
Linked Issues check ✅ Passed All code changes align with ARCH-1931 objectives: record type definitions now correctly declare _updatedAt, interfaces extend IRocketChatRecord, and related API signatures are updated accordingly.
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.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/optional-updated-at-field

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.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.38%. Comparing base (eb366e7) to head (e8a28d7).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38528      +/-   ##
===========================================
- Coverage    70.39%   70.38%   -0.01%     
===========================================
  Files         3161     3161              
  Lines       110654   110653       -1     
  Branches     19892    19849      -43     
===========================================
- Hits         77895    77884      -11     
- Misses       30731    30742      +11     
+ Partials      2028     2027       -1     
Flag Coverage Δ
unit 71.37% <50.00%> (-0.03%) ⬇️

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.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

📦 Docker Image Size Report

➡️ Changes

Service Current Baseline Change Percent
sum of all images 0B 0B 0B
account-service 0B 0B 0B
authorization-service 0B 0B 0B
ddp-streamer-service 0B 0B 0B
omnichannel-transcript-service 0B 0B 0B
presence-service 0B 0B 0B
queue-worker-service 0B 0B 0B
rocketchat 0B 0B 0B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "02/06 19:47 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.00]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "queue-worker-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "rocketchat" [0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.00]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.4GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 0B
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-38528
  • Baseline: develop
  • Timestamp: 2026-02-06 19:47:13 UTC
  • Historical data points: 30

Updated: Fri, 06 Feb 2026 19:47:14 GMT

@tassoevan tassoevan added this to the 8.2.0 milestone Feb 6, 2026
@tassoevan tassoevan marked this pull request as ready for review February 6, 2026 17:32
@tassoevan tassoevan requested review from a team as code owners February 6, 2026 17:32
Copy link
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

🤖 Fix all issues with AI agents
In `@apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts`:
- Around line 32-40: The ws.on('end') handler uses an async setTimeout with a
fixed 500ms delay which is a race condition and creates unhandled promise
rejections; change this to avoid the magic timeout and to handle errors: either
(preferred) perform an atomic read-after-write (e.g., use the same insert/update
operation or a findOneAndUpdate on CustomSounds to get the final document and
broadcast immediately from that promise), or (minimal) replace the async
setTimeout with a proper promise chain that awaits CustomSounds.findOneById and
calls api.broadcast inside a try/catch so rejections are handled before calling
resolve; remove the fire-and-forget async callback to eliminate unhandled
promise rejections and reference ws.on('end'), setTimeout,
CustomSounds.findOneById and api.broadcast when making the change.
🧹 Nitpick comments (1)
apps/meteor/tests/data/livechat/department.ts (1)

200-205: delete department._updatedAt is now contradictory with the parameter type.

The parameter is typed as Omit<ILivechatDepartment, '_updatedAt'>, signaling _updatedAt shouldn't be present, yet line 202 still deletes it. This only compiles because ILivechatDepartment has an index signature ([k: string]: any). Consider removing the delete statement since the type contract already guarantees the field isn't there, or keep the original ILivechatDepartment type if the intent is to defensively strip it at runtime.

Option A: Remove the dead delete (trust the type)
 export const disableDepartment = async (department: Omit<ILivechatDepartment, '_updatedAt'>): Promise<void> => {
 	department.enabled = false;
-	delete department._updatedAt;
 	const updatedDepartment = await updateDepartment(department._id, department);
 	expect(updatedDepartment.enabled).to.be.false;
 };
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac9065f and 50d8933.

📒 Files selected for processing (22)
  • apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts
  • apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts
  • apps/meteor/app/livechat/server/business-hour/LivechatBusinessHours.ts
  • apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.ts
  • apps/meteor/client/lib/userStatuses.ts
  • apps/meteor/client/providers/CustomSoundProvider/CustomSoundProvider.tsx
  • apps/meteor/client/providers/CustomSoundProvider/lib/helpers.ts
  • apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.stories.tsx
  • apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.tsx
  • apps/meteor/tests/data/livechat/department.ts
  • packages/core-services/src/events/Events.ts
  • packages/core-typings/src/ICustomSound.ts
  • packages/core-typings/src/ICustomUserStatus.ts
  • packages/core-typings/src/IInquiry.ts
  • packages/core-typings/src/IInstanceStatus.ts
  • packages/core-typings/src/ILivechatBusinessHour.ts
  • packages/core-typings/src/ILivechatDepartment.ts
  • packages/model-typings/src/models/ICustomSoundsModel.ts
  • packages/model-typings/src/models/ILivechatBusinessHoursModel.ts
  • packages/models/src/models/CustomSounds.ts
  • packages/models/src/models/LivechatBusinessHours.ts
  • packages/ui-contexts/src/CustomSoundContext.ts
💤 Files with no reviewable changes (3)
  • apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.stories.tsx
  • packages/core-typings/src/IInquiry.ts
  • apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.tsx
🧰 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:

  • packages/core-services/src/events/Events.ts
  • apps/meteor/app/livechat/server/business-hour/LivechatBusinessHours.ts
  • apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.ts
  • packages/core-typings/src/ILivechatBusinessHour.ts
  • packages/core-typings/src/IInstanceStatus.ts
  • apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts
  • packages/core-typings/src/ICustomUserStatus.ts
  • apps/meteor/tests/data/livechat/department.ts
  • packages/model-typings/src/models/ILivechatBusinessHoursModel.ts
  • packages/model-typings/src/models/ICustomSoundsModel.ts
  • packages/models/src/models/LivechatBusinessHours.ts
  • packages/core-typings/src/ILivechatDepartment.ts
  • apps/meteor/client/providers/CustomSoundProvider/CustomSoundProvider.tsx
  • apps/meteor/client/providers/CustomSoundProvider/lib/helpers.ts
  • packages/core-typings/src/ICustomSound.ts
  • packages/models/src/models/CustomSounds.ts
  • packages/ui-contexts/src/CustomSoundContext.ts
  • apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts
  • apps/meteor/client/lib/userStatuses.ts
🧠 Learnings (4)
📓 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/livechat/server/business-hour/LivechatBusinessHours.ts
  • apps/meteor/tests/data/livechat/department.ts
  • packages/models/src/models/LivechatBusinessHours.ts
  • apps/meteor/client/lib/userStatuses.ts
📚 Learning: 2025-09-15T21:34:39.812Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 36717
File: packages/ui-voip/src/providers/useCallSounds.ts:6-21
Timestamp: 2025-09-15T21:34:39.812Z
Learning: The voipSounds methods (playDialer, playRinger, playCallEnded) from useCustomSound return proper offCallbackHandler cleanup functions, not void as some type definitions might suggest.

Applied to files:

  • apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts
📚 Learning: 2025-11-19T18:20:37.116Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: apps/meteor/server/services/media-call/service.ts:141-141
Timestamp: 2025-11-19T18:20:37.116Z
Learning: In apps/meteor/server/services/media-call/service.ts, the sendHistoryMessage method should use call.caller.id or call.createdBy?.id as the message author, not call.transferredBy?.id. Even for transferred calls, the message should appear in the DM between the two users who are calling each other, not sent by the person who transferred the call.

Applied to files:

  • apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts
🧬 Code graph analysis (14)
packages/core-services/src/events/Events.ts (1)
packages/core-typings/src/IInquiry.ts (1)
  • ILivechatInquiryRecord (29-55)
apps/meteor/app/livechat/server/business-hour/LivechatBusinessHours.ts (1)
packages/core-typings/src/ILivechatBusinessHour.ts (1)
  • ILivechatBusinessHour (33-41)
apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.ts (1)
packages/core-typings/src/ILivechatBusinessHour.ts (1)
  • ILivechatBusinessHour (33-41)
apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts (2)
packages/models/src/index.ts (1)
  • CustomSounds (144-144)
packages/core-services/src/index.ts (1)
  • api (55-55)
apps/meteor/tests/data/livechat/department.ts (1)
packages/core-typings/src/ILivechatDepartment.ts (1)
  • ILivechatDepartment (3-24)
packages/model-typings/src/models/ILivechatBusinessHoursModel.ts (1)
packages/core-typings/src/ILivechatBusinessHour.ts (1)
  • ILivechatBusinessHour (33-41)
packages/model-typings/src/models/ICustomSoundsModel.ts (2)
packages/core-typings/src/ICustomSound.ts (1)
  • ICustomSound (3-8)
packages/ui-contexts/src/index.ts (1)
  • FindOptions (110-110)
packages/models/src/models/LivechatBusinessHours.ts (1)
packages/core-typings/src/ILivechatBusinessHour.ts (1)
  • ILivechatBusinessHour (33-41)
apps/meteor/client/providers/CustomSoundProvider/CustomSoundProvider.tsx (1)
packages/core-typings/src/ICustomSound.ts (1)
  • ICustomSound (3-8)
apps/meteor/client/providers/CustomSoundProvider/lib/helpers.ts (1)
packages/core-typings/src/ICustomSound.ts (1)
  • ICustomSound (3-8)
packages/models/src/models/CustomSounds.ts (1)
packages/core-typings/src/ICustomSound.ts (1)
  • ICustomSound (3-8)
packages/ui-contexts/src/CustomSoundContext.ts (1)
packages/core-typings/src/ICustomSound.ts (1)
  • ICustomSound (3-8)
apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts (2)
packages/models/src/index.ts (1)
  • CustomSounds (144-144)
packages/core-services/src/index.ts (1)
  • api (55-55)
apps/meteor/client/lib/userStatuses.ts (1)
packages/core-typings/src/ICustomUserStatus.ts (1)
  • ICustomUserStatus (4-4)
⏰ 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). (10)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (18)
packages/core-services/src/events/Events.ts (1)

26-26: LGTM — consistent replacement of IInquiry with ILivechatInquiryRecord.

The import and event signature change on line 74 now aligns with the existing usage on line 242 (watch.inquiries), and ILivechatInquiryRecord properly extends IRocketChatRecord (which carries _updatedAt), matching the PR objective.

Also applies to: 74-74

packages/core-typings/src/ICustomSound.ts (1)

1-8: LGTM!

Clean refactor: extending IRocketChatRecord correctly provides _id and _updatedAt for this DB document type, and the remaining fields are unchanged. Consumers that don't need _updatedAt properly use Omit<ICustomSound, '_updatedAt'> elsewhere in the PR.

packages/ui-contexts/src/CustomSoundContext.ts (1)

39-39: LGTM!

Using Omit<ICustomSound, '_updatedAt'> for the client-side list is the right approach since the UI context doesn't carry the DB timestamp.

packages/core-typings/src/IInstanceStatus.ts (1)

1-23: Correct: intentionally detaching from IRocketChatRecord since the instance-status model doesn't support _updatedAt.

This is the mirror case of the other changes in this PR — the type now accurately reflects that instance-status documents don't have an _updatedAt field.

packages/core-typings/src/ILivechatDepartment.ts (1)

1-3: LGTM!

Consistent with the PR pattern — ILivechatDepartment now correctly inherits _id and _updatedAt from IRocketChatRecord as a proper DB document type. The separate LivechatDepartmentDTO remains unchanged, which is correct.

packages/core-typings/src/ILivechatBusinessHour.ts (1)

2-2: LGTM!

Same consistent pattern — ILivechatBusinessHour now properly inherits _id and _updatedAt via IRocketChatRecord.

Also applies to: 33-33

packages/model-typings/src/models/ILivechatBusinessHoursModel.ts (1)

26-26: LGTM!

Correctly excludes _updatedAt from the insertOne input, matching the pattern used in ICustomSoundsModel.create — the DB layer auto-sets this field.

packages/model-typings/src/models/ICustomSoundsModel.ts (1)

9-10: Signatures match the implementation perfectly.

setName correctly uses findOneAndUpdate with returnDocument: 'after' to return the updated document or null. create correctly uses insertOne and returns InsertOneResult<WithId<ICustomSound>>. The type omissions for _id and _updatedAt in create's input accurately reflect DB auto-population behavior.

apps/meteor/app/livechat/server/business-hour/LivechatBusinessHours.ts (1)

6-6: LGTM — return type correctly reflects the constructed object shape.

The object literal provides _id but not _updatedAt, so Omit<ILivechatBusinessHour, '_updatedAt'> is an accurate representation.

packages/models/src/models/LivechatBusinessHours.ts (1)

75-80: LGTM — parameter type correctly excludes _updatedAt.

The base layer (BaseRaw.insertOne) handles _id generation and _updatedAt stamping, so excluding both from the input type is correct.

apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.ts (1)

4-6: LGTM — parameter type widening is correct and consistent with callers.

All fields accessed in the body (active, workHours, _id, type) remain available in Omit<ILivechatBusinessHour, '_updatedAt'>, and this aligns with createDefaultBusinessHourRow's updated return type.

packages/models/src/models/CustomSounds.ts (2)

35-43: Good refactor — setName now returns the updated document.

Switching from updateOne to findOneAndUpdate with returnDocument: 'after' is a clean approach that eliminates the need for a separate fetch when the caller needs the updated document (as in insertOrUpdateSound.ts).


46-48: LGTM — create parameter type correctly excludes _updatedAt.

apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts (1)

90-96: LGTM — properly handles nullable return and broadcasts full document.

The null guard on updatedSound correctly handles the case where the document wasn't found, and broadcasting the full updated document ensures payload consistency with the actual DB state.

apps/meteor/client/providers/CustomSoundProvider/lib/helpers.ts (1)

7-9: No changes needed. The code does not pass defaultSounds elements to getCustomSoundURL. Instead, it passes items from customSoundsList (which are full ICustomSound objects from the server method listCustomSounds(): ICustomSound[]) to the function, matching its parameter type exactly. The defaultSounds array is concatenated separately after the mapping operation, so no type mismatch occurs.

Likely an incorrect or invalid review comment.

apps/meteor/client/providers/CustomSoundProvider/CustomSoundProvider.tsx (1)

26-26: LGTM — explicit return type aligns queryFn with the updated ICustomSound shape.

The annotation correctly reflects that neither sdk.call('listCustomSounds') nor defaultSounds include _updatedAt, keeping the type consistent with the broader refactor.

apps/meteor/client/lib/userStatuses.ts (1)

36-47: LGTM — parameter type correctly narrowed to exclude _updatedAt.

The method only uses name, _id, and statusType, so Omit<ICustomUserStatus, '_updatedAt'> accurately describes the required shape. Structural subtyping ensures existing callers (lines 68, 74) remain compatible.

packages/core-typings/src/ICustomUserStatus.ts (1)

1-4: Clean consolidation — _updatedAt properly handled by InsertionModel.

By extending IRocketChatRecord, ICustomUserStatus gains a consolidated _updatedAt field. Although _updatedAt is required in the IRocketChatRecord interface, the InsertionModel<ICustomUserStatus> type utility already makes _updatedAt optional during object construction (_updatedAt?: Date), so no call site changes are needed. Existing code that inserts custom user statuses without explicitly providing _updatedAt (e.g., apps/meteor/app/user-status/server/methods/insertOrUpdateUserStatus.ts) continues to work correctly.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
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 22 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts">

<violation number="1" location="apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts:32">
P1: The async callback passed to `setTimeout` lacks error handling. If `CustomSounds.findOneById` rejects (e.g., due to a database error), it will result in an UnhandledPromiseRejection, which can crash the Node.js process or leave the application in an unstable state. Wrap the asynchronous operation in a `try/catch` block.</violation>
</file>

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

@tassoevan tassoevan force-pushed the refactor/optional-updated-at-field branch from 50d8933 to 3912614 Compare February 6, 2026 17:59
Copy link
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: 0

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/lib/userStatuses.ts (1)

61-70: ⚠️ Potential issue | 🔴 Critical

Type mismatch in sync() method: sdk.call('listCustomUserStatus') returns ICustomUserStatus[] but createFromCustom() expects Omit<ICustomUserStatus, '_updatedAt'>.

The listCustomUserStatus() method returns full ICustomUserStatus objects (which include _updatedAt from IRocketChatRecord), but createFromCustom() at line 36 requires Omit<ICustomUserStatus, '_updatedAt'>. Passing the full type to a function expecting the omitted type is incompatible.

The stream event at line 74 correctly provides Omit<ICustomUserStatus, '_updatedAt'> and is compatible. The sync() method should either strip _updatedAt before passing to createFromCustom(), or the method signature should accept the full ICustomUserStatus type.

🧹 Nitpick comments (1)
apps/meteor/tests/data/livechat/department.ts (1)

200-205: The Omit is effectively a no-op due to the index signature on ILivechatDepartment.

Since ILivechatDepartment declares [k: string]: any, Omit<ILivechatDepartment, '_updatedAt'> still allows _updatedAt to be accessed (as any) through the index signature. The type narrowing has no practical enforcement here—callers can still pass objects with _updatedAt, and line 202 still compiles without issue via the index signature.

This isn't a problem introduced by this PR (the index signature is pre-existing), but it's worth noting that the Omit doesn't provide the type-safety it suggests. If the index signature on ILivechatDepartment is ever tightened, this will need revisiting.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50d8933 and 3912614.

📒 Files selected for processing (23)
  • apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts
  • apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts
  • apps/meteor/app/livechat/server/business-hour/LivechatBusinessHours.ts
  • apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.ts
  • apps/meteor/client/lib/userStatuses.ts
  • apps/meteor/client/providers/CustomSoundProvider/CustomSoundProvider.tsx
  • apps/meteor/client/providers/CustomSoundProvider/lib/helpers.ts
  • apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.stories.tsx
  • apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.tsx
  • apps/meteor/tests/data/livechat/department.ts
  • packages/core-services/src/events/Events.ts
  • packages/core-typings/src/ICronHistoryItem.ts
  • packages/core-typings/src/ICustomSound.ts
  • packages/core-typings/src/ICustomUserStatus.ts
  • packages/core-typings/src/IInquiry.ts
  • packages/core-typings/src/IInstanceStatus.ts
  • packages/core-typings/src/ILivechatBusinessHour.ts
  • packages/core-typings/src/ILivechatDepartment.ts
  • packages/model-typings/src/models/ICustomSoundsModel.ts
  • packages/model-typings/src/models/ILivechatBusinessHoursModel.ts
  • packages/models/src/models/CustomSounds.ts
  • packages/models/src/models/LivechatBusinessHours.ts
  • packages/ui-contexts/src/CustomSoundContext.ts
💤 Files with no reviewable changes (3)
  • apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.stories.tsx
  • packages/core-typings/src/IInquiry.ts
  • apps/meteor/client/views/admin/workspace/DeploymentCard/components/InstancesModal/InstancesModal.tsx
🚧 Files skipped from review as they are similar to previous changes (8)
  • apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts
  • packages/models/src/models/LivechatBusinessHours.ts
  • apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.ts
  • packages/model-typings/src/models/ICustomSoundsModel.ts
  • packages/core-typings/src/ILivechatBusinessHour.ts
  • packages/models/src/models/CustomSounds.ts
  • apps/meteor/client/providers/CustomSoundProvider/CustomSoundProvider.tsx
  • packages/core-services/src/events/Events.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/livechat/server/business-hour/LivechatBusinessHours.ts
  • packages/core-typings/src/ILivechatDepartment.ts
  • packages/ui-contexts/src/CustomSoundContext.ts
  • packages/core-typings/src/ICustomSound.ts
  • packages/core-typings/src/IInstanceStatus.ts
  • packages/core-typings/src/ICronHistoryItem.ts
  • apps/meteor/client/lib/userStatuses.ts
  • apps/meteor/tests/data/livechat/department.ts
  • packages/model-typings/src/models/ILivechatBusinessHoursModel.ts
  • packages/core-typings/src/ICustomUserStatus.ts
  • apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts
  • apps/meteor/client/providers/CustomSoundProvider/lib/helpers.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/livechat/server/business-hour/LivechatBusinessHours.ts
  • packages/core-typings/src/ICronHistoryItem.ts
  • apps/meteor/client/lib/userStatuses.ts
  • apps/meteor/tests/data/livechat/department.ts
🧬 Code graph analysis (6)
apps/meteor/app/livechat/server/business-hour/LivechatBusinessHours.ts (1)
packages/core-typings/src/ILivechatBusinessHour.ts (1)
  • ILivechatBusinessHour (33-41)
packages/ui-contexts/src/CustomSoundContext.ts (1)
packages/core-typings/src/ICustomSound.ts (1)
  • ICustomSound (3-8)
apps/meteor/client/lib/userStatuses.ts (1)
packages/core-typings/src/ICustomUserStatus.ts (1)
  • ICustomUserStatus (4-4)
apps/meteor/tests/data/livechat/department.ts (1)
packages/core-typings/src/ILivechatDepartment.ts (1)
  • ILivechatDepartment (3-24)
packages/model-typings/src/models/ILivechatBusinessHoursModel.ts (1)
packages/core-typings/src/ILivechatBusinessHour.ts (1)
  • ILivechatBusinessHour (33-41)
apps/meteor/client/providers/CustomSoundProvider/lib/helpers.ts (1)
packages/core-typings/src/ICustomSound.ts (1)
  • ICustomSound (3-8)
⏰ 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: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (11)
apps/meteor/app/livechat/server/business-hour/LivechatBusinessHours.ts (1)

6-6: LGTM — return type correctly narrowed.

The function never sets _updatedAt (it's a seed row for DB insertion), so Omit<ILivechatBusinessHour, '_updatedAt'> accurately reflects the runtime shape. Clean alignment with the broader IRocketChatRecord type tightening.

packages/core-typings/src/ICustomUserStatus.ts (1)

1-4: LGTM — clean centralization of _updatedAt via IRocketChatRecord.

This correctly removes the locally declared optional _updatedAt in favor of inheriting the required one from IRocketChatRecord, aligning with the PR's goal of normalizing record types.

apps/meteor/client/lib/userStatuses.ts (1)

36-47: Sound type narrowing — method doesn't use _updatedAt.

The Omit<ICustomUserStatus, '_updatedAt'> correctly reflects that this method never reads _updatedAt, and it keeps callers compatible now that ICustomUserStatus inherits a required _updatedAt from IRocketChatRecord. Objects that do carry _updatedAt remain assignable, so existing call sites at lines 68 and 74 are unaffected.

packages/core-typings/src/IInstanceStatus.ts (1)

1-2: Consistent removal of IRocketChatRecord for a type without _updatedAt.

Since _updatedAt is now required on IRocketChatRecord, disconnecting IInstanceStatus and declaring _id explicitly is the correct approach for documents that don't carry an _updatedAt field.

packages/core-typings/src/ICronHistoryItem.ts (1)

1-3: LGTM!

Clean migration to IRocketChatRecord_id and _updatedAt are now inherited from the base record type, consistent with the PR's normalization goal.

packages/model-typings/src/models/ILivechatBusinessHoursModel.ts (1)

26-26: LGTM!

Omitting _updatedAt from the insertOne parameter is correct — it's auto-managed by the persistence layer, just like _id.

packages/core-typings/src/ICustomSound.ts (1)

1-7: LGTM!

Promoting _updatedAt from optional to required (via IRocketChatRecord) correctly reflects the database document shape. Downstream code that constructs objects without _updatedAt (e.g., default sounds) appropriately uses Omit<ICustomSound, '_updatedAt'>.

apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts (1)

90-95: Good improvement: broadcast now sends the actual updated document.

Broadcasting the full updatedSound returned by setName instead of a hand-assembled partial object ensures field consistency with the ICustomSound type. The guard on line 91 is also an improvement — previously the broadcast would fire even if the update was a no-op.

One minor note: if setName returns falsy (e.g., document not found), the method still returns soundData._id on line 98 as if it succeeded. Consider whether this silent no-op should surface an error to the caller.

apps/meteor/client/providers/CustomSoundProvider/lib/helpers.ts (1)

28-28: LGTM!

Omit<ICustomSound, '_updatedAt'> correctly models static default sounds that aren't database documents and don't carry _updatedAt.

packages/ui-contexts/src/CustomSoundContext.ts (1)

39-39: LGTM!

The list type is correctly widened to Omit<ICustomSound, '_updatedAt'>[] since it merges default sounds (no _updatedAt) with DB-fetched sounds — the lowest common denominator type is appropriate here.

packages/core-typings/src/ILivechatDepartment.ts (1)

1-3: Clean adoption of IRocketChatRecord as the base type.

This correctly centralizes _id and _updatedAt into the shared base record, aligning with the PR's goal of making _updatedAt a required field on document types. The DTO type below appropriately remains separate since it represents input data, not a stored document.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@tassoevan tassoevan force-pushed the refactor/optional-updated-at-field branch from 3912614 to 052278b Compare February 6, 2026 19:04
…ken` to extend `IRocketChatRecord` and update `create` method to return void
@tassoevan tassoevan marked this pull request as draft February 6, 2026 19:27
@tassoevan tassoevan force-pushed the refactor/optional-updated-at-field branch from 052278b to e8a28d7 Compare February 6, 2026 19:31
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