fix: discussion parent message count and last message time out of sync with the discussion - #41702
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 5c79bd8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughMessage-save flows now include pending room updates and returned room counts when propagating discussion metadata. End-to-end tests verify parent message counts and timestamps for regular and rename system messages. ChangesDiscussion metadata synchronization
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant MessageSave
participant Rooms
participant ParentRoomUpdater
participant MessageNotifier
MessageSave->>Rooms: Increment msgs and return updated room
MessageSave->>ParentRoomUpdater: Refresh parent discussion metadata
ParentRoomUpdater->>MessageNotifier: Notify refreshed parent message
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #41702 +/- ##
===========================================
+ Coverage 68.64% 68.67% +0.02%
===========================================
Files 4162 4165 +3
Lines 158824 159274 +450
Branches 28107 28274 +167
===========================================
+ Hits 109023 109375 +352
- Misses 44628 44743 +115
+ Partials 5173 5156 -17
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts (1)
9-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the implementation comment block.
Lines 9-14 add an implementation comment. Remove it. The helper name already describes the operation.
As per coding guidelines,
**/*.{ts,tsx,js}must avoid code comments in implementation.🤖 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 `@apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts` around lines 9 - 14, Remove the implementation comment block immediately preceding the helper in propagateDiscussionMetadata.ts, leaving the helper implementation unchanged.Source: Coding guidelines
🤖 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 @.changeset/tangy-cobras-beg.md:
- Line 5: Update the changeset entry describing the discussion parent metadata
fix to explicitly mention both corrected fields: the parent message count and
the parent dlm (last-message timestamp) value.
In `@apps/meteor/tests/end-to-end/api/rooms.ts`:
- Line 2094: Update the assertion for discussionMessage.dlm to validate its
timestamp value rather than only its existence. Capture the sent message
timestamp, normalize both dates consistently, and assert that
discussionMessage.dlm matches it.
---
Nitpick comments:
In `@apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts`:
- Around line 9-14: Remove the implementation comment block immediately
preceding the helper in propagateDiscussionMetadata.ts, leaving the helper
implementation unchanged.
🪄 Autofix
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 Plus
Run ID: 7cd3b57d-9457-421f-bf70-9cb7e8ef9fbf
📒 Files selected for processing (3)
.changeset/tangy-cobras-beg.mdapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tsapps/meteor/tests/end-to-end/api/rooms.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (9)
- GitHub Check: 🔎 Code Check / Code Lint
- GitHub Check: 🔎 Code Check / TypeScript
- GitHub Check: 🔨 Test Unit / Unit Tests
- GitHub Check: 🔨 Test Storybook / Test Storybook
- GitHub Check: 📦 Meteor Build (coverage)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
🧰 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/tests/end-to-end/api/rooms.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts
🧠 Learnings (4)
📚 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/tangy-cobras-beg.md
📚 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/tests/end-to-end/api/rooms.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.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/tests/end-to-end/api/rooms.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.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/tests/end-to-end/api/rooms.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts
🔇 Additional comments (2)
apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts (1)
3-8: LGTM!Also applies to: 15-25, 44-44, 60-60
apps/meteor/tests/end-to-end/api/rooms.ts (1)
2063-2093: LGTM!Also applies to: 2095-2096
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/server/services/messages/service.ts`:
- Around line 217-220: Update saveSystemMessage so failures from
updateAndNotifyParentRoomWithParentMessage do not propagate after the system
message and room count are persisted. Run this parent-room refresh as a
non-failing, repairable post-commit metadata sync while preserving the existing
conditional room?.prid behavior and successful save result.
In `@packages/models/src/models/Rooms.ts`:
- Around line 798-808: The findOneAndIncMsgCountById contract must always return
the post-increment IRoom without permitting caller-controlled upsert or
result-shape options. In Rooms.ts, restrict the method options type, filter out
returnDocument, includeResultMetadata, and upsert, and apply protected
returnDocument: 'after', includeResultMetadata: false, and upsert: false
settings after caller options are merged. Update
IRoomsModel.findOneAndIncMsgCountById in
packages/model-typings/src/models/IRoomsModel.ts:171 to use the same restricted
options type.
🪄 Autofix
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 Plus
Run ID: cba19e13-8dba-45a0-a28d-a2ed55a79613
📒 Files selected for processing (6)
.changeset/tangy-cobras-beg.mdapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tsapps/meteor/server/services/messages/service.tsapps/meteor/tests/end-to-end/api/rooms.tspackages/model-typings/src/models/IRoomsModel.tspackages/models/src/models/Rooms.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts
- .changeset/tangy-cobras-beg.md
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
⚠️ CI failures not shown inline (3)
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 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/model-typings/src/models/IRoomsModel.tsapps/meteor/server/services/messages/service.tsapps/meteor/tests/end-to-end/api/rooms.tspackages/models/src/models/Rooms.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:
packages/model-typings/src/models/IRoomsModel.tsapps/meteor/server/services/messages/service.tsapps/meteor/tests/end-to-end/api/rooms.tspackages/models/src/models/Rooms.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:
packages/model-typings/src/models/IRoomsModel.tsapps/meteor/server/services/messages/service.tsapps/meteor/tests/end-to-end/api/rooms.tspackages/models/src/models/Rooms.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:
packages/model-typings/src/models/IRoomsModel.tsapps/meteor/server/services/messages/service.tsapps/meteor/tests/end-to-end/api/rooms.tspackages/models/src/models/Rooms.ts
📚 Learning: 2026-07-15T01:31:50.632Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41382
File: packages/model-typings/src/models/IPushTokenModel.ts:10-10
Timestamp: 2026-07-15T01:31:50.632Z
Learning: In Rocket.Chat’s push-token model, APNs/GCM standard tokens and PushKit VoIP tokens use distinct, globally-unique token string values. As a result, when deduplicating/looking up tokens, key identity solely on `{ tokenValue, appName }` (e.g., for `findOneByTokenAndAppName`, `removeDuplicateTokens`) and do **not** include `tokenType` in the uniqueness criteria to avoid collisions between standard and VoIP tokens.
Applied to files:
packages/model-typings/src/models/IRoomsModel.tspackages/models/src/models/Rooms.ts
📚 Learning: 2026-08-05T22:02:59.828Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41707
File: apps/meteor/server/hooks/messages/processThreads.ts:66-68
Timestamp: 2026-08-05T22:02:59.828Z
Learning: In Rocket.Chat Meteor server code, `callbacks.runAsync` returns its input item rather than the asynchronous callback promise. Callers of `afterReadMessages` must invoke `callbacks.runAsync` without awaiting it, keeping read-receipt I/O off the message-send path; this includes `apps/meteor/server/hooks/messages/processThreads.ts`.
Applied to files:
apps/meteor/server/services/messages/service.ts
🔇 Additional comments (3)
packages/models/src/models/Rooms.ts (1)
833-835: LGTM!Also applies to: 1811-1817
apps/meteor/server/services/messages/service.ts (1)
21-21: LGTM!Also applies to: 189-199
apps/meteor/tests/end-to-end/api/rooms.ts (1)
2073-2087: LGTM!Also applies to: 2088-2094, 2096-2110
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/models/src/models/Rooms.ts (2)
801-811: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winEnforce the protected MongoDB options at runtime.
Line 801 narrows the TypeScript type, but it does not remove properties from runtime objects. A value typed as the broader
FindOneAndUpdateOptionscan still containupsert: trueorincludeResultMetadata: true. Line 811 forwards both options.
upsert: truecan create an incomplete room when_iddoes not exist.includeResultMetadata: truechanges the result shape and violatesPromise<IRoom | null>. Set both values after spreadingoptions.Proposed fix
return this.findOneAndUpdate(query, update, { ...options, returnDocument: 'after', + includeResultMetadata: false, + upsert: false, });This is the same unresolved contract risk identified in the previous review.
🤖 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/Rooms.ts` around lines 801 - 811, Update the findOneAndUpdate call in the room update method to override protected runtime options after spreading options: set upsert and includeResultMetadata to false while retaining returnDocument: 'after'. Preserve the existing query, update, and Promise<IRoom | null> behavior.
1823-1824: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winDo not cast the projected document to
IRoom.This query returns only
abacAttributesand_id, butinsertAbacAttributeIfNotExistsByIdis typed asPromise<IRoom | null>. Callers can read requiredIRoomfields such asmsgs,t, orufrom data that is absent at runtime. If callers need a full room, remove the projection. Otherwise, return an accurate projected type such asPick<IRoom, '_id' | 'abacAttributes'> | null.🤖 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/Rooms.ts` around lines 1823 - 1824, Update insertAbacAttributeIfNotExistsById to remove the unsafe cast to Promise<IRoom | null> and accurately type the projected result as Pick<IRoom, '_id' | 'abacAttributes'> | null; keep the projection limited to the fields actually returned.
🤖 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.
Outside diff comments:
In `@packages/models/src/models/Rooms.ts`:
- Around line 801-811: Update the findOneAndUpdate call in the room update
method to override protected runtime options after spreading options: set upsert
and includeResultMetadata to false while retaining returnDocument: 'after'.
Preserve the existing query, update, and Promise<IRoom | null> behavior.
- Around line 1823-1824: Update insertAbacAttributeIfNotExistsById to remove the
unsafe cast to Promise<IRoom | null> and accurately type the projected result as
Pick<IRoom, '_id' | 'abacAttributes'> | null; keep the projection limited to the
fields actually returned.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ba220ec5-da73-4189-9fa1-523bbc89a7b8
📒 Files selected for processing (3)
apps/meteor/server/services/messages/service.tspackages/model-typings/src/models/IRoomsModel.tspackages/models/src/models/Rooms.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/model-typings/src/models/IRoomsModel.ts
- apps/meteor/server/services/messages/service.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
⚠️ CI failures not shown inline (5)
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 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/models/src/models/Rooms.ts
🧠 Learnings (4)
📚 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:
packages/models/src/models/Rooms.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:
packages/models/src/models/Rooms.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:
packages/models/src/models/Rooms.ts
📚 Learning: 2026-07-15T01:31:50.632Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41382
File: packages/model-typings/src/models/IPushTokenModel.ts:10-10
Timestamp: 2026-07-15T01:31:50.632Z
Learning: In Rocket.Chat’s push-token model, APNs/GCM standard tokens and PushKit VoIP tokens use distinct, globally-unique token string values. As a result, when deduplicating/looking up tokens, key identity solely on `{ tokenValue, appName }` (e.g., for `findOneByTokenAndAppName`, `removeDuplicateTokens`) and do **not** include `tokenType` in the uniqueness criteria to avoid collisions between standard and VoIP tokens.
Applied to files:
packages/models/src/models/Rooms.ts
🔇 Additional comments (1)
packages/models/src/models/Rooms.ts (1)
837-843: LGTM!
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Proposed changes (including videos or screenshots)
Root cause 1: the refresh reads outdated values (lag of one message). In #33034 we moved the flush of the
roomUpdaterout of thenotifyUsersOnMessagecallback and intoafterSaveMessage, where it now runs after the whole callback chain. Previously the room record was already updated by the MEDIUM prioritynotifyUsersOnMessagecallback and then freshly consumed byPropagateDiscussionMetadata(LOW priority); nowadays that callback reads the room before the flush, so it propagates the pre-incrementmsgsand the previouslm.Root cause 2: the refresh never runs for system messages.
Message.saveSystemMessagedoes not run theafterSaveMessagecallbacks at all: it inserts the message, increments the room counter and notifies the message and room changes. SincePropagateDiscussionMetadatais one of those callbacks, system messages added to a discussion leave the parent message outdated until the next user message triggers the refresh. This one is not a regression from #33034, it has been like that since discussions were introduced.Solution 1: use the
roomUpdaterreceived by the callback to read the update filter operations staged in memory (getRawUpdateFilter()) and apply them on top of the room fetched from the database, so the discussion metadata is computed against the state the room is about to have.Solution 2: refresh the discussion metadata from
saveSystemMessageitself. TheRooms.incMsgCountByIdcall it already performs is replaced with a newfindOneAndIncMsgCountById, which returns the updated room from the increment already in flight, so the refresh costs no extra round trip.Issue(s)
CORE-2517 Discussion parent message count (dcount) and last message time (dlm) are out of sync with the discussion
Steps to test or reproduce
Lag of one message
dcountis 0,dlmis not set).Expected after the fix: the parent message reads "1 message" right after step 2, with the timestamp
of that message.
System messages
Expected after the fix: the parent message reflects the new message as soon as the system message is
added.
Further comments
Summary by CodeRabbit
Bug Fixes
Tests