Skip to content

refactor: sync missed messages via REST chat.syncMessages on reconnect - #41189

Open
VanshajPoonia wants to merge 4 commits into
RocketChat:developfrom
VanshajPoonia:refactor/reconnect-sync-rest-messages
Open

refactor: sync missed messages via REST chat.syncMessages on reconnect#41189
VanshajPoonia wants to merge 4 commits into
RocketChat:developfrom
VanshajPoonia:refactor/reconnect-sync-rest-messages

Conversation

@VanshajPoonia

@VanshajPoonia VanshajPoonia commented Jul 6, 2026

Copy link
Copy Markdown

Proposed changes (including videos or screenshots)

Migrates reconnect message synchronization from the loadMissedMessages DDP method to the GET /v1/chat.syncMessages REST endpoint, so edits and deletions made while a client was offline are applied when the connection is restored.

  • useLoadMissedMessages now sends the latest locally known _updatedAt as lastUpdate, maps the payload with mapMessageFromApi, upserts updated messages through upsertMessageBulk (keeps the e2e pending flag handling) and removes deleted messages via Messages.state.remove, mirroring the live deleteMessageBulk stream handler
  • Records still awaiting server confirmation (optimistic messages without an _updatedAt) are skipped when choosing the sync baseline
  • Adds a { rid: 1, _updatedAt: 1 } index to the messages collection. findForUpdates filters by rid plus an _updatedAt range, which the existing { rid: 1, ts: 1, _updatedAt: 1 } index cannot bound because ts sits between the two fields
  • No new trash index: { rid: 1, __collection__: 1, _deletedAt: 1 } already exists and serves the deleted side of the query
  • Deprecates the loadMissedMessages method (removal planned for 9.0.0) instead of removing it, since external clients can still call it through method.call
  • Adds unit tests for the hook

Issue(s)

Closes #41079
Closes #41000

Steps to test or reproduce

  1. Open a room, then go offline (devtools network tab)
  2. From another user, edit one message, delete another and send a new one in that room
  3. Go back online: the edit, the deletion and the new message all appear without reloading

Further comments

Kept a single lastUpdate request per opened room instead of cursor pagination: only currently opened rooms are synced (capped by maxRoomsOpen) and the endpoint already supports type/next cursors if bounded batches become necessary.

Known follow-up, tracked in #41190: the open thread panel and infinite message lists (threads, discussions, omnichannel history) keep their own query caches fed only by live stream events, so they are not reconciled on a DDP-only reconnect. This is a pre-existing gap (the old DDP method also only wrote the message store) and is best solved across all those caches at once.

Lint, typecheck and the jest suite pass locally.

Review in cubic

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Reconnection now syncs missed message changes via the REST-based message sync flow when you come back online, improving recovery of edits and deletions after being offline.
  • Bug Fixes

    • Missed-message reconciliation is more reliable in large rooms, with improved ordering during offline sync to match the sync cursor.
  • Chores

    • The older missed-message sync path is now deprecated in favor of the REST-based endpoint.

Reconnect sync previously used the loadMissedMessages DDP method, which
queries by creation timestamp and cannot see edits or deletions that
happened while the client was offline. The client now calls
GET /v1/chat.syncMessages with the latest locally known _updatedAt as
baseline, upserts the returned updated messages and removes the deleted
ones from the message store.

Adds a { rid: 1, _updatedAt: 1 } index to the messages collection so the
sync query is bounded per room, since the existing { rid, ts, _updatedAt }
index cannot serve the _updatedAt range. The trash collection already has
{ rid, __collection__, _deletedAt } covering the deleted side.

The loadMissedMessages method is now deprecated, planned for removal in
9.0.0.

Closes RocketChat#41079
Closes RocketChat#41000
- Skip store records without _updatedAt when picking the sync baseline, so
  an optimistic message whose temp flag was already cleared (but which never
  gained an _updatedAt) can no longer crash the comparator
- Wrap the whole sync body in the try/catch so a stray throw can't escape as
  an unhandled rejection from the unawaited call
- Batch deletions through Messages.state.remove instead of a per-id delete
  loop, matching the deleteMessageBulk stream handler and notifying once
- Use the exported EndpointFunction type and Object.values
@VanshajPoonia
VanshajPoonia requested review from a team as code owners July 6, 2026 09:30
@dionisio-bot

dionisio-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 68a0b9e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@rocket.chat/models Minor
@rocket.chat/meteor Minor
@rocket.chat/core-typings Minor
@rocket.chat/rest-typings Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5870a178-9612-491e-8e6a-ab456d8c5bdd

📥 Commits

Reviewing files that changed from the base of the PR and between 329387c and b5961c2.

📒 Files selected for processing (3)
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.ts
  • apps/meteor/server/publications/messages.ts
  • apps/meteor/tests/unit/server/publications/messages.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • 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/server/publications/messages.ts
  • apps/meteor/tests/unit/server/publications/messages.spec.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/tests/unit/server/publications/messages.spec.ts
🧠 Learnings (5)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/server/publications/messages.ts
  • apps/meteor/tests/unit/server/publications/messages.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 this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/server/publications/messages.ts
  • apps/meteor/tests/unit/server/publications/messages.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/server/publications/messages.ts
  • apps/meteor/tests/unit/server/publications/messages.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/tests/unit/server/publications/messages.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/tests/unit/server/publications/messages.spec.ts
🔇 Additional comments (2)
apps/meteor/server/publications/messages.ts (1)

143-159: LGTM!

apps/meteor/tests/unit/server/publications/messages.spec.ts (1)

216-221: LGTM!


Walkthrough

This PR moves reconnect message reconciliation to GET /v1/chat.syncMessages, aligns the message query and index usage around _updatedAt, updates the client reconnect hook, adds tests, and deprecates loadMissedMessages.

Changes

Reconnect sync migration

Layer / File(s) Summary
Query alignment and index notes
packages/models/src/models/Messages.ts, apps/meteor/server/publications/messages.ts, apps/meteor/tests/unit/server/publications/messages.spec.ts, .changeset/reconnect-sync-rest-messages.md
The messages query now sorts by _updatedAt, the { rid: 1, _updatedAt: 1 } index is documented, the publication test expectations are updated, and the changeset records the sync migration and deprecation timeline.
Client REST sync implementation
apps/meteor/app/ui-utils/client/index.ts, apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts
The reconnect hook now uses GET /v1/chat.syncMessages, computes the sync baseline from the latest eligible _updatedAt, applies bulk updates and deletions, and re-exports upsertMessageBulk.
Hook reconnect tests
apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.ts
The hook test suite covers reconnect gating, baseline selection, update/delete application, skipped rooms, and per-room error handling.
Deprecate loadMissedMessages
apps/meteor/server/methods/loadMissedMessages.ts
The DDP method is marked deprecated in type declarations and logs a deprecation warning when called.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

Suggested labels: type: chore

Suggested reviewers: sampaiodiego, cardoso

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the REST-based reconnect sync refactor and matches the main change set.
Linked Issues check ✅ Passed The PR migrates reconnect sync to /v1/chat.syncMessages, reconciles edits/deletions, adds the index, and keeps loadMissedMessages deprecated.
Out of Scope Changes check ✅ Passed No unrelated code changes stand out; the tests, exports, endpoint updates, and index/query tweaks all support the reconnect sync migration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@coderabbitai coderabbitai Bot added the type: feature Pull requests that introduces new feature label Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/models/src/models/Messages.ts (1)

46-51: 🚀 Performance & Scalability | 🔵 Trivial

Solid, well-documented index addition.

The { rid: 1, _updatedAt: 1 } index correctly targets findForUpdates's range query, and the comment clearly explains why the adjacent { rid, ts, _updatedAt } index can't serve this pattern.

One thing worth keeping in mind operationally: the downstream consumer (handleWithoutPagination in apps/meteor/server/publications/messages.ts, not in this diff) sorts the matched set by ts without a limit. For clients that stay offline a long time in very active rooms, the matched-and-sorted set could grow large enough to add memory/sort overhead even with this index in place, since ts isn't part of the new index. Not a regression from this PR, just a scaling consideration for the overall sync design.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/models/src/models/Messages.ts` around lines 46 - 51, The new { rid:
1, _updatedAt: 1 } index fixes the filter path, but `handleWithoutPagination`
still materializes and sorts all matched messages by `ts`, which can become
expensive for large offline syncs. Update the sync flow in
`handleWithoutPagination`/`chat.syncMessages` to avoid a full in-memory sort of
the entire result set, either by batching/paginating the fetch or by aligning
the query and index strategy with the `ts` ordering. Keep the existing
`modelIndexes()` change, but make the downstream consumer scale without relying
on an unbounded sort.
🤖 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.

Nitpick comments:
In `@packages/models/src/models/Messages.ts`:
- Around line 46-51: The new { rid: 1, _updatedAt: 1 } index fixes the filter
path, but `handleWithoutPagination` still materializes and sorts all matched
messages by `ts`, which can become expensive for large offline syncs. Update the
sync flow in `handleWithoutPagination`/`chat.syncMessages` to avoid a full
in-memory sort of the entire result set, either by batching/paginating the fetch
or by aligning the query and index strategy with the `ts` ordering. Keep the
existing `modelIndexes()` change, but make the downstream consumer scale without
relying on an unbounded sort.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 74bb7365-2754-412b-b9a6-0c1212f07883

📥 Commits

Reviewing files that changed from the base of the PR and between 3296b4d and 329387c.

📒 Files selected for processing (6)
  • .changeset/reconnect-sync-rest-messages.md
  • apps/meteor/app/ui-utils/client/index.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts
  • apps/meteor/server/methods/loadMissedMessages.ts
  • packages/models/src/models/Messages.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • 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/app/ui-utils/client/index.ts
  • apps/meteor/server/methods/loadMissedMessages.ts
  • packages/models/src/models/Messages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.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/views/root/hooks/useLoadMissedMessages.spec.ts
🧠 Learnings (9)
📚 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/app/ui-utils/client/index.ts
  • apps/meteor/server/methods/loadMissedMessages.ts
  • packages/models/src/models/Messages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.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 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/app/ui-utils/client/index.ts
  • apps/meteor/server/methods/loadMissedMessages.ts
  • packages/models/src/models/Messages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.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/app/ui-utils/client/index.ts
  • apps/meteor/server/methods/loadMissedMessages.ts
  • packages/models/src/models/Messages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.ts
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/reconnect-sync-rest-messages.md
📚 Learning: 2026-03-09T18:39:14.020Z
Learnt from: Harxhit
Repo: RocketChat/Rocket.Chat PR: 39476
File: apps/meteor/server/methods/addAllUserToRoom.ts:0-0
Timestamp: 2026-03-09T18:39:14.020Z
Learning: When implementing batch processing in server methods, favor a single data pass to collect both the items and any derived fields needed for validation. Use the same dataset for both validation and processing to avoid races between validation and execution, and document the approach in code comments. Apply this pattern to similar Meteor Rocket.Chat server methods under apps/meteor/server/methods to prevent race conditions and ensure consistent batch behavior.

Applied to files:

  • apps/meteor/server/methods/loadMissedMessages.ts
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.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/views/root/hooks/useLoadMissedMessages.ts
  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.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/views/root/hooks/useLoadMissedMessages.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.ts
🔇 Additional comments (6)
apps/meteor/server/methods/loadMissedMessages.ts (1)

8-21: LGTM!

.changeset/reconnect-sync-rest-messages.md (1)

1-7: LGTM!

apps/meteor/app/ui-utils/client/index.ts (1)

1-3: LGTM!

apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts (2)

10-46: LGTM!


56-63: 📐 Maintainability & Code Quality

No change needed here. syncMissedMessages already handles its own errors, and @typescript-eslint/no-floating-promises is disabled for apps/meteor/client/**/*.ts.

			> Likely an incorrect or invalid review comment.
apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.ts (1)

1-225: LGTM!

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/client/views/root/hooks/useLoadMissedMessages.spec.ts
- Sort chat.syncMessages without-pagination results by _updatedAt instead
  of ts so the new { rid, _updatedAt } index serves both the range filter
  and the ordering, avoiding an in-memory sort on large offline syncs. This
  matches the cursor-paginated path, which already orders by _updatedAt, and
  keeps the ts-descending order for normal sequential sends. Unit test
  assertions updated to match.
- Restore spies via afterEach in the useLoadMissedMessages spec so a failed
  assertion can no longer leak the console.error mock into other tests.
@coderabbitai coderabbitai Bot added type: chore and removed type: feature Pull requests that introduces new feature labels Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant