Skip to content

Conversation

@KevLehman
Copy link
Member

@KevLehman KevLehman commented Dec 22, 2025

https://rocketchat.atlassian.net/browse/CORE-1717

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes

    • Stricter server startup validation to prevent incompatible Node/Mongo versions.
    • More reliable asset and avatar loading with guarded handling to avoid upload errors.
  • Refactor

    • Improved typing for binary asset handling to ensure consistent binary results.
    • Streamlined administrative user initialization for clearer defaults and safer setup.
    • Broadened room metadata typing to accept wider value types.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2025

⚠️ No Changeset found

Latest commit: 8df4a9c

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 Dec 22, 2025

Walkthrough

Type updates and startup logic adjustments: Assets.getBinaryAsync() now returns Uint8Array | undefined; admin/bootstrap initialization and avatar handling were typed and guarded; server startup performs semver-based Node/Mongo validation with optional chaining; room creation extraData widened from Record<string,string> to Record<string,unknown>.

Changes

Cohort / File(s) Change Summary
Meteor Type Definitions
apps/meteor/definition/externals/meteor/meteor.d.ts
Assets.getBinaryAsync(assetPath: string) return type changed from Promise<EJSON | undefined> to Promise<Uint8Array | undefined>.
Server Startup & Admin Initialization
apps/meteor/server/startup/initialData.ts
Admin user creation refactored to use typed Partial<IUser> / Omit<IUser,...> shapes; UserStatus enum used for status fields; avatar asset loading now guards absent assets and creates Buffer without utf8 encoding; non-null assertions added where accessed.
Server Running Validation
apps/meteor/server/startup/serverRunning.ts
Added types, semver.parse for Node version with failure handling, optional chaining for Info.commit fields, and stronger MongoDB version coercion/validation.
Room Model Types & Implementation
packages/model-typings/src/models/IRoomsModel.ts, packages/models/src/models/Rooms.ts
createWithIdTypeAndName(..., extraData?) parameter type broadened from Record<string,string> to Record<string,unknown> in both interface and implementation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

stat: ready to merge

Suggested reviewers

  • ggazzo
  • tassoevan

Poem

🐇 I hopped through types and startup light,
Buffers found where strings took flight,
Admins typed and statuses true,
Semver watches every queue,
Hooray — a tidy code-night! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: InitialData & serverRunning to TS' accurately describes the main changes, which involve converting InitialData and serverRunning files to TypeScript with improved type annotations.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/ts

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f68cc09 and 8df4a9c.

📒 Files selected for processing (1)
  • packages/models/src/models/Rooms.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/models/src/models/Rooms.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: CodeQL-Build
  • GitHub Check: CodeQL-Build

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 Dec 22, 2025

Codecov Report

❌ Patch coverage is 79.31034% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.65%. Comparing base (5be5362) to head (8df4a9c).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37929      +/-   ##
===========================================
+ Coverage    70.62%   70.65%   +0.02%     
===========================================
  Files         3143     3143              
  Lines       108688   108694       +6     
  Branches     19529    19548      +19     
===========================================
+ Hits         76763    76796      +33     
+ Misses       29923    29904      -19     
+ Partials      2002     1994       -8     
Flag Coverage Δ
e2e 60.19% <ø> (+0.05%) ⬆️
e2e-api 48.55% <64.28%> (+1.06%) ⬆️
unit 71.73% <16.66%> (-0.04%) ⬇️

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 Dec 22, 2025

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.1GiB 1.1GiB +11MiB
rocketchat 355MiB 345MiB +11MiB
omnichannel-transcript-service 132MiB 132MiB +2.1KiB
queue-worker-service 132MiB 132MiB -962B
ddp-streamer-service 126MiB 126MiB +559B
account-service 113MiB 113MiB +788B
authorization-service 111MiB 111MiB +317B
presence-service 111MiB 111MiB +680B

📊 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/15 22:28", "11/16 01:28", "11/17 23:50", "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 03:50", "12/23 15:00 (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]
  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]
  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]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 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]
  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]
  line "queue-worker-service" [0.14, 0.14, 0.14, 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]
  line "rocketchat" [0.36, 0.36, 0.35, 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.35]
Loading

Statistics (last 28 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.1GiB
ℹ️ About this report

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

  • Tag: pr-37929
  • Baseline: develop
  • Timestamp: 2025-12-23 15:00:08 UTC
  • Historical data points: 28

Updated: Tue, 23 Dec 2025 15:00:09 GMT

@KevLehman KevLehman marked this pull request as ready for review December 22, 2025 20:21
@KevLehman KevLehman requested review from a team as code owners December 22, 2025 20:21
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

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d7924d3 and f68cc09.

📒 Files selected for processing (5)
  • apps/meteor/definition/externals/meteor/meteor.d.ts
  • apps/meteor/server/startup/initialData.ts
  • apps/meteor/server/startup/serverRunning.ts
  • packages/model-typings/src/models/IRoomsModel.ts
  • packages/models/src/models/Rooms.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/definition/externals/meteor/meteor.d.ts
  • packages/models/src/models/Rooms.ts
  • packages/model-typings/src/models/IRoomsModel.ts
  • apps/meteor/server/startup/initialData.ts
  • apps/meteor/server/startup/serverRunning.ts
🧠 Learnings (5)
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.

Applied to files:

  • packages/models/src/models/Rooms.ts
  • packages/model-typings/src/models/IRoomsModel.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings by mapping subscription documents to room IDs, never undefined, even when user has no room subscriptions.

Applied to files:

  • packages/model-typings/src/models/IRoomsModel.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings (mapping subscription documents to room IDs), never undefined, even when user has no room subscriptions.

Applied to files:

  • packages/model-typings/src/models/IRoomsModel.ts
📚 Learning: 2025-09-19T15:15:04.642Z
Learnt from: rodrigok
Repo: RocketChat/Rocket.Chat PR: 36991
File: apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts:219-221
Timestamp: 2025-09-19T15:15:04.642Z
Learning: The Federation_Matrix_homeserver_domain setting in apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts is part of the old federation system and is being deprecated/removed, so configuration issues with this setting should not be flagged for improvement.

Applied to files:

  • apps/meteor/server/startup/initialData.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • apps/meteor/server/startup/serverRunning.ts
🧬 Code graph analysis (2)
packages/model-typings/src/models/IRoomsModel.ts (3)
packages/core-typings/src/IRoom.ts (1)
  • IRoom (20-94)
packages/apps-engine/src/definition/rooms/IRoom.ts (1)
  • IRoom (4-28)
packages/apps/src/AppsEngine.ts (1)
  • IRoom (16-16)
apps/meteor/server/startup/initialData.ts (1)
apps/meteor/app/lib/server/functions/addUserToDefaultChannels.ts (1)
  • addUserToDefaultChannels (12-47)
⏰ 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: 🔨 Test UI (EE) / MongoDB 8.2 (3/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (1/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (2/4)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (4/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (1/4)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (4/4)
  • GitHub Check: 🔨 Test API (EE) / MongoDB 8.2 coverage (1/1)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (5/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (2/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (3/4)
🔇 Additional comments (14)
apps/meteor/definition/externals/meteor/meteor.d.ts (1)

11-11: LGTM! Type definition now correctly represents binary data.

The return type change from Promise<EJSON | undefined> to Promise<Uint8Array | undefined> accurately reflects that getBinaryAsync returns binary asset data. This aligns with the usage in initialData.ts where the asset is consumed as a buffer without text encoding.

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

2038-2038: Appropriate type broadening to support diverse extraData values.

Changing extraData from Record<string, string> to Record<string, unknown> allows passing boolean, number, and other property types. This aligns with actual usage in the codebase (e.g., { default: true } in initialData.ts:122) and matches the interface definition update.

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

302-302: Interface correctly updated to match implementation.

The type change to Record<string, unknown> maintains consistency with the corresponding implementation in packages/models/src/models/Rooms.ts.

apps/meteor/server/startup/serverRunning.ts (5)

16-16: Good addition of explicit type annotation.

The type annotation ignore: string | undefined improves code clarity and type safety.


31-37: Robust version parsing with proper error handling.

The added null check and early exit on parse failure prevents downstream errors. Using parsedSemVer.major is more reliable than string manipulation for extracting the major version.


40-40: Type annotation accurately reflects runtime behavior.

The string | string[] type correctly models that msg starts as an array before being joined into a string at line 58.


50-56: Optional chaining prevents potential runtime errors.

Using Info.commit?.hash and Info.commit?.branch safely handles cases where commit information may be absent, avoiding Cannot read property of undefined errors.


72-79: Verify MongoDB version validation logic change.

The semver.coerce function correctly normalizes MongoDB version strings (e.g., "7.0.0", "6.0.8") by extracting and coercing the first digit sequence. The dual condition !mongoSemver || semver.satisfies(mongoSemver, '<7.0.0') properly handles both edge cases:

  • !mongoSemver catches any coercion failures (malformed version strings)
  • semver.satisfies(mongoSemver, '<7.0.0') validates the version requirement

The logic is equivalent to a direct check but more defensive, protecting against unexpected MongoDB version formats while correctly rejecting anything below 7.0.0.

apps/meteor/server/startup/initialData.ts (6)

1-1: Appropriate imports for typed user creation.

Adding UserStatus and type IUser enables proper typing throughout the file.


20-28: Well-typed admin user initialization.

Using Partial<IUser> with UserStatus enum values provides proper type safety. Setting status: UserStatus.OFFLINE and statusDefault: UserStatus.ONLINE is semantically clearer than string literals.


136-137: Consistent use of UserStatus enum.

Applying UserStatus.ONLINE for the rocket.cat bot user maintains consistency with the admin user creation pattern.


145-161: Improved type safety in avatar loading with proper guards.

The updated logic correctly handles the new Uint8Array | undefined return type from Assets.getBinaryAsync(). The if (asset) guard ensures all file operations only execute when data is present, and creating the buffer directly from asset (without utf8 encoding) aligns with binary data handling.


213-228: Precise typing for test admin user.

Using Omit<IUser, 'createdAt' | 'roles' | '_updatedAt'> accurately reflects that these fields are added by the system during Users.create().


254-254: Review cast necessity for type compatibility.

The cast adminUser as IUser is required because addUserToDefaultChannels expects a full IUser, but adminUser is typed as Omit<IUser, 'createdAt' | 'roles' | '_updatedAt'>. Since Users.create() at line 243 adds these fields to the database but doesn't update the local variable, the cast is necessary.

This is acceptable but consider whether addUserToDefaultChannels could accept a more flexible type.

@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Dec 23, 2025
@KevLehman KevLehman added this to the 8.1.0 milestone Dec 23, 2025
@KevLehman KevLehman added the stat: ready to merge PR tested and approved waiting for merge label Dec 23, 2025
@kodiakhq kodiakhq bot merged commit a8a84ab into develop Dec 23, 2025
45 checks passed
@kodiakhq kodiakhq bot deleted the chore/ts branch December 23, 2025 15:53
gaolin1 pushed a commit to gaolin1/medsense.webchat that referenced this pull request Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants