Skip to content

refactor(client): centralize DDP wire codec behind sdk/ddpProtocol#40486

Merged
ggazzo merged 2 commits into
developfrom
refactor/sdk-ddp-protocol-helper
May 15, 2026
Merged

refactor(client): centralize DDP wire codec behind sdk/ddpProtocol#40486
ggazzo merged 2 commits into
developfrom
refactor/sdk-ddp-protocol-helper

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented May 11, 2026

Summary

Five client modules each imported DDPCommon.parseDDP / stringifyDDP from meteor/ddp-common to encode and decode DDP frames. The codec itself is a small concern, but every direct import is a Meteor dependency we'll need to migrate again when we swap to a standalone EJSON helper.

Introduce apps/meteor/client/lib/sdk/ddpProtocol.ts as the single entry point. It re-exports parseDDP / stringifyDDP from DDPCommon (with a DDPMessage type alias for the stringifyDDP parameter shape) and is the only file on the client that imports from meteor/ddp-common. The future EJSON swap is one file change.

Migrate the five consumers to import from the new module:

  • app/utils/client/lib/SDKClient.ts
  • client/lib/sdk/meteorBackedSdk.ts
  • client/meteor/overrides/ddpOverREST.ts
  • client/meteor/overrides/ddpSdkCollectionBridge.ts
  • client/meteor/overrides/stubMeteorStream.ts

Drop the verbose Parameters<typeof DDPCommon.stringifyDDP>[0] casts in favour of the exported DDPMessage type.

No behaviour change: same DDPCommon implementation under the hood.

Test plan

  • yarn eslint on the 6 changed files: 0 errors.
  • tsc --noEmit on apps/meteor is clean.
  • grep confirms only ddpProtocol.ts imports from meteor/ddp-common on the client side.
  • Manual (flag-OFF): log in, send a message, observe sub/unsub/notify-user frames go through the SDKClient stream proxy and reach consumers.
  • Manual (flag-ON, Use_RC_SDK enabled): login and method calls routed through ddpOverREST and the stub stream both work — frames serialize/deserialize identically.
  • Manual: trigger a force-logout (admin → reset user E2E key) so the error-result re-encoding in ddpOverREST catch branch runs; the 2FA / totp-required flow still opens the modal.

Summary by CodeRabbit

  • Refactor
    • Centralized DDP protocol handling into a single, swappable codec module.
    • Replaced internal uses of the legacy codec with the centralized parser/serializer across the client.
    • Improved consistency for message parsing, serialization, and stream handling.
    • Tests and mocks updated to align with the new protocol helpers.

Review Change Stack

Task: ARCH-2139

@ggazzo ggazzo requested a review from a team as a code owner May 11, 2026 22:40
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 11, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

⚠️ No Changeset found

Latest commit: d107030

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 May 11, 2026

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a local DDP codec module and migrates client-side parsing/serialization calls from Meteor's DDPCommon to that module across SDK client bridging, collection handlers, REST transport overrides, stub streams, and tests.

Changes

DDP Protocol Codec Abstraction

Layer / File(s) Summary
Centralized DDP Codec Module
apps/meteor/client/lib/sdk/ddpProtocol.ts
New module re-exports parseDDP and stringifyDDP from Meteor and exposes DDPMessage type derived from stringifyDDP's argument type.
Legacy Stream Message Parsing
apps/meteor/app/utils/client/lib/SDKClient.ts
SDKClient parses legacy raw Meteor.connection._stream messages with the local parseDDP helper before validating and forwarding to streamProxy.
SDK Collection Handler Parsing
apps/meteor/client/lib/sdk/meteorBackedSdk.ts
meteorBackedSdk's onCollection handler switched to the local parseDDP for decoding raw DDP messages.
REST Transport DDP Codec
apps/meteor/client/meteor/overrides/ddpOverREST.ts
ddpOverREST replaces DDPCommon calls with local parseDDP/stringifyDDP for request serialization, login-token extraction, error-frame detection, and synthetic error re-encoding.
Collection Bridge Frame Serialization
apps/meteor/client/meteor/overrides/ddpSdkCollectionBridge.ts
ddpSdkCollectionBridge now stringifies bridged frames with local stringifyDDP before forwarding to Meteor's stream handler.
Stub Stream DDP Codec Usage
apps/meteor/client/meteor/overrides/stubMeteorStream.ts
stubMeteorStream parses inbound frames and serializes synthesized frames (pong heartbeat, connected bootstrap) using local parseDDP/stringifyDDP.
Test mocks and presence spec updates
apps/meteor/client/lib/presence.spec.ts, apps/meteor/tests/mocks/client/meteor.ts
Jest mock and test fixtures add a DDPCommon mock implementing parseDDP/stringifyDDP to match the codec surface expected by tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • gabriellsh
  • tassoevan
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(client): centralize DDP wire codec behind sdk/ddpProtocol' clearly and specifically describes the primary change: creating a centralized entry point for DDP codec functionality and migrating client modules to use it.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ARCH-2139: Request failed with status code 401

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.

@ggazzo ggazzo added this to the 8.5.0 milestone May 11, 2026
@ggazzo
Copy link
Copy Markdown
Member Author

ggazzo commented May 11, 2026

/jira ARCH-2116

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.62%. Comparing base (fe65e8f) to head (d107030).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #40486   +/-   ##
========================================
  Coverage    69.61%   69.62%           
========================================
  Files         3325     3326    +1     
  Lines       122797   122807   +10     
  Branches     21831    21863   +32     
========================================
+ Hits         85490    85504   +14     
+ Misses       33957    33945   -12     
- Partials      3350     3358    +8     
Flag Coverage Δ
e2e 59.14% <55.55%> (+0.05%) ⬆️
e2e-api 46.23% <ø> (-0.05%) ⬇️
unit 70.35% <92.30%> (-0.02%) ⬇️

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.

@ggazzo ggazzo force-pushed the refactor/sdk-ddp-protocol-helper branch from 16cf6a4 to f60b056 Compare May 11, 2026 22:58
@ggazzo ggazzo changed the base branch from develop to refactor/sdk-status-loggingin-providers May 11, 2026 22:58
Base automatically changed from refactor/sdk-status-loggingin-providers to refactor/auth-provider-login-token-helper May 13, 2026 19:11
@ggazzo ggazzo force-pushed the refactor/auth-provider-login-token-helper branch from addc58e to fbf06fc Compare May 14, 2026 12:30
@ggazzo ggazzo force-pushed the refactor/sdk-ddp-protocol-helper branch from f60b056 to eba2310 Compare May 14, 2026 12:32
@ggazzo ggazzo changed the base branch from refactor/auth-provider-login-token-helper to develop May 14, 2026 12:32
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/client/lib/sdk/ddpSdk.ts`:
- Around line 145-149: Stored-token rejection currently clears storage and calls
Meteor.connection.setUserId(null) but does not notify account.onLogout
subscribers (so CachedStoresManager.clearAllCachesOnLogout etc. aren't run);
after clearing storage and setting userId to null, explicitly invoke the SDK's
logout notification pipeline to run registered onLogout callbacks (e.g. call a
method on getDdpSdk().account such as _runLogoutHandlers / _runOnLogoutCallbacks
or whatever internal runner exists) so that subscribers registered via
getDdpSdk().account.onLogout() are executed; modify the cleanup path around
Meteor.connection.setUserId(null) to call that runner immediately (or, if no
runner exists, iterate over the stored onLogout callbacks on getDdpSdk().account
and invoke them) to ensure logout side effects run without calling
Meteor.logout().

In
`@apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx`:
- Around line 155-164: The wipeLocalAuth implementation clears storage and calls
Meteor.connection.setUserId(null) which bypasses the Accounts/DDL logout hooks
and leaves subscribers like CachedStoresManager stale; replace the direct
setUserId(null) path by invoking the SDK logout flow (call getDdpSdk().logout()
from inside wipeLocalAuth) so Accounts.onLogout / getDdpSdk().account.onLogout()
handlers run, or if the ddpSdk race concern applies in this force-logout code
path, explicitly trigger the registered logout callbacks used by
CachedStoresManager after clearing storage; update the wipeLocalAuth function to
use getDdpSdk().logout() (or call the same logout callbacks that
CachedStoresManager subscribes to) instead of Meteor.connection.setUserId(null).
- Around line 38-48: The installed flag is set too early in
installLoggingInBridge causing a permanent no-op if Accounts._setLoggingIn is
missing on first call; change installLoggingInBridge so it only sets
loggingInBridgeInstalled = true after verifying typeof wrap._setLoggingIn ===
'function' and after assigning wrap._setLoggingIn to the wrapper that calls
original.call(...) and loggingInListeners.forEach(...), i.e., perform the
runtime check and replacement first (using the wrap and original variables) and
then mark loggingInBridgeInstalled true to ensure future calls short-circuit
only after a successful attachment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6df056ff-1a7c-425a-b4b6-3ebd82d91187

📥 Commits

Reviewing files that changed from the base of the PR and between f60b056 and eba2310.

📒 Files selected for processing (14)
  • apps/meteor/app/utils/client/lib/SDKClient.ts
  • apps/meteor/client/hooks/useReactiveValue.ts
  • apps/meteor/client/lib/cachedStores/CachedStoresManager.ts
  • apps/meteor/client/lib/sdk/ddpProtocol.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/meteorBackedSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/meteor/overrides/ddpOverREST.ts
  • apps/meteor/client/meteor/overrides/ddpSdkCollectionBridge.ts
  • apps/meteor/client/meteor/overrides/index.ts
  • apps/meteor/client/meteor/overrides/stubMeteorStream.ts
  • apps/meteor/client/meteor/overrides/unstoreLoginToken.ts
  • apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx
  • apps/meteor/client/providers/ServerProvider.tsx
💤 Files with no reviewable changes (3)
  • apps/meteor/client/hooks/useReactiveValue.ts
  • apps/meteor/client/meteor/overrides/unstoreLoginToken.ts
  • apps/meteor/client/meteor/overrides/index.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/meteor/client/lib/sdk/meteorBackedSdk.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/meteor/client/meteor/overrides/stubMeteorStream.ts
  • apps/meteor/client/meteor/overrides/ddpOverREST.ts
  • apps/meteor/client/meteor/overrides/ddpSdkCollectionBridge.ts
  • apps/meteor/client/lib/sdk/ddpProtocol.ts
  • apps/meteor/app/utils/client/lib/SDKClient.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/lib/cachedStores/CachedStoresManager.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx
  • apps/meteor/client/providers/ServerProvider.tsx
🧠 Learnings (6)
📚 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/lib/cachedStores/CachedStoresManager.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/sdk/ddpSdk.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/lib/cachedStores/CachedStoresManager.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/lib/cachedStores/CachedStoresManager.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

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

Applied to files:

  • apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx
  • apps/meteor/client/providers/ServerProvider.tsx
🔇 Additional comments (3)
apps/meteor/client/lib/sdk/storage.ts (1)

9-9: LGTM!

apps/meteor/client/lib/cachedStores/CachedStoresManager.ts (1)

2-2: LGTM!

Also applies to: 20-21

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

15-15: LGTM!

Also applies to: 129-159, 164-164

Comment thread apps/meteor/client/lib/sdk/ddpSdk.ts
Five client modules each imported DDPCommon.parseDDP / stringifyDDP from
meteor/ddp-common to encode and decode DDP frames. The codec itself is a
small concern, but every direct import is a Meteor dependency we'll need
to migrate again when we swap to a standalone EJSON helper.

Introduce apps/meteor/client/lib/sdk/ddpProtocol.ts as the single entry
point. It re-exports parseDDP / stringifyDDP from DDPCommon (with a
DDPMessage type alias for the stringifyDDP parameter shape) and is the
only file on the client that imports from meteor/ddp-common. The future
EJSON swap is one file change.

Migrate the five consumers (SDKClient, meteorBackedSdk, ddpOverREST,
ddpSdkCollectionBridge, stubMeteorStream) to import from the new module.
Drop the verbose Parameters<typeof DDPCommon.stringifyDDP>[0] casts in
favour of the exported DDPMessage type.

No behaviour change: same DDPCommon implementation under the hood.
@tassoevan tassoevan force-pushed the refactor/sdk-ddp-protocol-helper branch from eba2310 to 9d906da Compare May 15, 2026 16:12
tassoevan
tassoevan previously approved these changes May 15, 2026
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 8 files

Re-trigger cubic

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/client/lib/presence.spec.ts`:
- Around line 9-12: The DDP mock uses JSON.parse/JSON.stringify which doesn't
preserve EJSON types; update the mock to use EJSON by importing the ejson
package and replacing DDPCommon.parseDDP and DDPCommon.stringifyDDP
implementations to call EJSON.parse and EJSON.stringify respectively; ensure the
import (e.g., import EJSON from 'ejson' or the correct default/named import) is
added at the top of presence.spec.ts so the mock behavior matches the production
DDP codec used in ddpSdk.ts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 763b9122-b400-43e3-803f-153030aa26bf

📥 Commits

Reviewing files that changed from the base of the PR and between 9d906da and d107030.

📒 Files selected for processing (2)
  • apps/meteor/client/lib/presence.spec.ts
  • apps/meteor/tests/mocks/client/meteor.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 📦 Meteor Build (coverage)
  • GitHub Check: cubic · AI code reviewer
🧰 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/client/lib/presence.spec.ts
  • apps/meteor/tests/mocks/client/meteor.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.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/client/lib/presence.spec.ts
🧠 Learnings (7)
📚 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/lib/presence.spec.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/lib/presence.spec.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/client/lib/presence.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/lib/presence.spec.ts
  • apps/meteor/tests/mocks/client/meteor.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/lib/presence.spec.ts
  • apps/meteor/tests/mocks/client/meteor.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/client/lib/presence.spec.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/client/lib/presence.spec.ts
  • apps/meteor/tests/mocks/client/meteor.ts
🔇 Additional comments (1)
apps/meteor/tests/mocks/client/meteor.ts (1)

54-57: ⚡ Quick win

Mock DDPCommon codec should preserve type fidelity, but the suggested fix is unfeasible.

The concern about DDP using JSON instead of EJSON is valid—DDP in production uses EJSON to preserve types like Date. However, the suggested patch references EJSON.parse() and EJSON.stringify(), which do not exist on the mocked EJSON object (the mock only provides isBinary, clone, and equals).

To fix this properly, extend the mock's EJSON object with parse and stringify methods, or alternatively use a different approach to ensure type-aware codec behavior in this mock.

			> Likely an incorrect or invalid review comment.

Comment thread apps/meteor/client/lib/presence.spec.ts
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label May 15, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 15, 2026
@tassoevan tassoevan enabled auto-merge May 15, 2026 19:51
@tassoevan tassoevan added this pull request to the merge queue May 15, 2026
@ggazzo ggazzo removed this pull request from the merge queue due to a manual request May 15, 2026
@ggazzo ggazzo merged commit 405584e into develop May 15, 2026
47 checks passed
@ggazzo ggazzo deleted the refactor/sdk-ddp-protocol-helper branch May 15, 2026 19:53
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 type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants