fix: hidden system messages being counted on discussions - #41673
dionisio-bot[bot] merged 28 commits into
Conversation
…ussionMetadata old method
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 5fbd0ae The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 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:
WalkthroughDiscussion message counts now exclude hidden system messages. Counts update when hidden-message settings change. The room edit panel explains this behavior, and end-to-end tests cover visible and hidden scenarios. ChangesDiscussion message count visibility
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant RoomSettings
participant DiscussionUpdater
participant MessagesModel
participant ParentRoom
RoomSettings->>DiscussionUpdater: save hidden system-message settings
DiscussionUpdater->>MessagesModel: count visible messages for hidden types
MessagesModel-->>DiscussionUpdater: return visible message count
DiscussionUpdater->>ParentRoom: refresh and notify discussion metadata
Suggested labels: Suggested reviewers: 🚥 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 #41673 +/- ##
===========================================
+ Coverage 68.69% 69.25% +0.56%
===========================================
Files 4166 4234 +68
Lines 159310 167316 +8006
Branches 28285 29869 +1584
===========================================
+ Hits 109440 115877 +6437
- Misses 44703 46264 +1561
- Partials 5167 5175 +8
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…s-msgs-from-discussion-count
…ket.Chat into fix/substract-hidden-sys-msgs-from-discussion-count
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.ts (1)
9-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the new implementation comments.
Lines 9-12 and Line 19 add comments in a TypeScript implementation. Remove them.
As per coding guidelines, “Avoid code comments in the 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/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.ts` around lines 9 - 20, Remove the implementation comments above getHiddenMessageTypes and inside its mute_unmute mapping, while leaving the function logic 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/sour-pugs-bow.md:
- Line 8: Update the release note to accurately describe global
hidden-system-message setting changes: clarify that discussion counts are
refreshed when a later regular message triggers the discussion refresh, rather
than immediately when the global setting changes. Preserve the statements about
excluding hidden message types and the room-level option hint.
In
`@apps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.ts`:
- Around line 38-41: Update updateAndNotifyParentRoomWithParentMessage so the
awaited getDiscussionMessagesCount result cannot overwrite newer discussion
metadata: before applying or refreshing the parent message, verify that the
parent metadata is not newer than room.lm, or obtain and apply the count and
metadata from a single atomic snapshot. Preserve the existing notification flow
for valid, current metadata.
---
Nitpick comments:
In
`@apps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.ts`:
- Around line 9-20: Remove the implementation comments above
getHiddenMessageTypes and inside its mute_unmute mapping, while leaving the
function logic 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: a7dcf0fc-9a30-481f-975a-007368ed3208
📒 Files selected for processing (10)
.changeset/sour-pugs-bow.mdapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsxapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tsapps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.tsapps/meteor/server/meteor-methods/rooms/saveRoomSettings.tsapps/meteor/server/services/messages/service.tsapps/meteor/tests/end-to-end/api/rooms.tspackages/i18n/src/locales/en.i18n.jsonpackages/model-typings/src/models/IMessagesModel.tspackages/models/src/models/Messages.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (10)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (1/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (3/5)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (1/4)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (2/5)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (3/4)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (4/4)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (2/4)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (5/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (4/5)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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/meteor-methods/rooms/saveRoomSettings.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsxpackages/models/src/models/Messages.tsapps/meteor/tests/end-to-end/api/rooms.tsapps/meteor/server/services/messages/service.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tspackages/model-typings/src/models/IMessagesModel.tsapps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.ts
apps/meteor/**
📄 CodeRabbit inference engine (CLAUDE.md)
The main Rocket.Chat Meteor application resides in
apps/meteor/; place its application code there rather than in other monorepo areas.
Files:
apps/meteor/server/meteor-methods/rooms/saveRoomSettings.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsxapps/meteor/tests/end-to-end/api/rooms.tsapps/meteor/server/services/messages/service.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tsapps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.ts
packages/**
📄 CodeRabbit inference engine (CLAUDE.md)
Shared libraries belong in
packages/, while other services belong inapps/andee/.
Files:
packages/models/src/models/Messages.tspackages/i18n/src/locales/en.i18n.jsonpackages/model-typings/src/models/IMessagesModel.ts
🧠 Learnings (7)
📚 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/meteor-methods/rooms/saveRoomSettings.tspackages/models/src/models/Messages.tsapps/meteor/tests/end-to-end/api/rooms.tsapps/meteor/server/services/messages/service.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tspackages/model-typings/src/models/IMessagesModel.tsapps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.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/meteor-methods/rooms/saveRoomSettings.tspackages/models/src/models/Messages.tsapps/meteor/tests/end-to-end/api/rooms.tsapps/meteor/server/services/messages/service.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tspackages/model-typings/src/models/IMessagesModel.tsapps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.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/meteor-methods/rooms/saveRoomSettings.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsxpackages/models/src/models/Messages.tsapps/meteor/tests/end-to-end/api/rooms.tsapps/meteor/server/services/messages/service.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tspackages/model-typings/src/models/IMessagesModel.tsapps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.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/meteor-methods/rooms/saveRoomSettings.tsapps/meteor/server/services/messages/service.tsapps/meteor/server/hooks/messages/propagateDiscussionMetadata.tsapps/meteor/server/lib/messaging/discussions/updateAndNotifyParentRoomWithParentMessage.ts
📚 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/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx
📚 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/Messages.tspackages/model-typings/src/models/IMessagesModel.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/sour-pugs-bow.md
🪛 LanguageTool
.changeset/sour-pugs-bow.md
[style] ~8-~8: ‘taking into account’ might be wordy. Consider a shorter alternative.
Context: ...essages count displayed on a discussion taking into account system messages which are hidden inside...
(EN_WORDINESS_PREMIUM_TAKING_INTO_ACCOUNT)
🔇 Additional comments (8)
packages/model-typings/src/models/IMessagesModel.ts (1)
143-143: LGTM!packages/models/src/models/Messages.ts (1)
765-788: LGTM!apps/meteor/server/services/messages/service.ts (1)
199-199: LGTM!apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts (1)
42-42: LGTM!apps/meteor/server/meteor-methods/rooms/saveRoomSettings.ts (1)
12-12: LGTM!Also applies to: 338-340
packages/i18n/src/locales/en.i18n.json (1)
2653-2653: LGTM!apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx (1)
478-506: LGTM!apps/meteor/tests/end-to-end/api/rooms.ts (1)
2073-2080: LGTM!Also applies to: 2096-2144
There was a problem hiding this comment.
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/server/meteor-methods/rooms/saveRoomSettings.ts`:
- Around line 339-344: Refresh the room’s sysMes value after
saveRoomSystemMessages(rid, value) completes and before calling
updateAndNotifyParentRoomWithParentMessage(room), so the helper receives the
persisted hidden system-message types while retaining the existing error
handling.
🪄 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: 5a9cf05d-4bad-4c83-b59b-4b0231f602fd
📒 Files selected for processing (2)
apps/meteor/server/hooks/messages/propagateDiscussionMetadata.tsapps/meteor/server/meteor-methods/rooms/saveRoomSettings.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
- GitHub Check: 📦 Build Packages
- GitHub Check: cubic · AI code reviewer
- GitHub Check: CodeQL-Build
- GitHub Check: Hacktron Security Check
- GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (4)
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 (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/meteor-methods/rooms/saveRoomSettings.ts
apps/meteor/**
📄 CodeRabbit inference engine (CLAUDE.md)
The main Rocket.Chat Meteor application resides in
apps/meteor/; place its application code there rather than in other monorepo areas.
Files:
apps/meteor/server/meteor-methods/rooms/saveRoomSettings.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:
apps/meteor/server/meteor-methods/rooms/saveRoomSettings.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/meteor-methods/rooms/saveRoomSettings.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/meteor-methods/rooms/saveRoomSettings.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/meteor-methods/rooms/saveRoomSettings.ts
🔇 Additional comments (1)
apps/meteor/server/meteor-methods/rooms/saveRoomSettings.ts (1)
12-12: LGTM!
There was a problem hiding this comment.
All reported issues were addressed across 2 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/models/src/models/Messages.ts (1)
1574-1578: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep implementation comments out of this file.
Move this contract description to the model interface or project documentation. Keep
packages/models/src/models/Messages.tsconcise.As per coding guidelines, avoid code comments in the 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 `@packages/models/src/models/Messages.ts` around lines 1574 - 1578, Remove the implementation comment immediately above Messages.refreshDiscussionMetadata and preserve the method signature and behavior. Relocate the contract description to the corresponding model interface or project documentation, keeping packages/models/src/models/Messages.ts free of explanatory implementation comments.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 `@packages/models/src/models/Messages.ts`:
- Around line 1578-1584: Update refreshDiscussionMetadata so the stale-update
predicate remains enforced when room.lm is absent: either require a defined lm
before performing the update or add an explicit no-timestamp predicate that
prevents overwriting a newer dlm. Preserve the existing guard for rooms with lm
and ensure older metadata cannot be applied.
---
Nitpick comments:
In `@packages/models/src/models/Messages.ts`:
- Around line 1574-1578: Remove the implementation comment immediately above
Messages.refreshDiscussionMetadata and preserve the method signature and
behavior. Relocate the contract description to the corresponding model interface
or project documentation, keeping packages/models/src/models/Messages.ts free of
explanatory implementation comments.
🪄 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: fef9996a-8510-44eb-8d94-01f6fd4f0bb2
📒 Files selected for processing (2)
apps/meteor/server/meteor-methods/rooms/saveRoomSettings.tspackages/models/src/models/Messages.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/meteor/server/meteor-methods/rooms/saveRoomSettings.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
- GitHub Check: 📦 Build Packages
- GitHub Check: cubic · AI code reviewer
- GitHub Check: CodeQL-Build
- GitHub Check: Hacktron Security Check
- GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (2)
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 (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:
packages/models/src/models/Messages.ts
packages/**
📄 CodeRabbit inference engine (CLAUDE.md)
Shared libraries belong in
packages/, while other services belong inapps/andee/.
Files:
packages/models/src/models/Messages.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/Messages.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/Messages.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/Messages.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/Messages.ts
🔇 Additional comments (1)
packages/models/src/models/Messages.ts (1)
765-775: LGTM!
cardoso
left a comment
There was a problem hiding this comment.
Two caveats/questions: were the frontend changes necessary to be in this PR? I see the tests assert 0 and 1, are we really covered with those?
5fbd0ae
Proposed changes (including videos or screenshots)
The issue is that we are not filtering out from the discussion's message count those system messages that are intended to be 'hidden', either from the global
Hide_System_Messagessetting or from the room preferences.So, to address this:
Backend-side
Messages.ts Added
countVisibleByRoomIdContainingTypesmodel method to subtract that number to the overall room messages count. AlsorefreshDiscussionMetadatawas modified to update the discussion metadata only if the parent message has adlm(discussion last message timestamp) earlier than the roomlm, avoiding race conditions with stale data.saveRoomSettings.ts Added broadcast to update discussion metadata when the changed room has
prid, meaning it's a discussion.updateAndNotifyParentRoomWithParentMessage.ts After the extraction to a 'lib' file on the parent branch (see #41702) the
updateAndNotifyParentRoomWithParentMessagemethod logic was changed to filter out hidden system messages.propagateDiscussionMetadata.ts
sysMesproperty was added to the projection object, since it's needed for filtering them out from the overall message count inupdateAndNotifyParentRoomWithParentMessage.service.ts I've only added
sysMesto the projection, since we need that property to update the parent message count correctly in line 220, taking into account those hidden types.Client-side:
EditRoomInfo.tsx Added a hint on the 'Hide System Messages' option, as accorded with design and product team.
en.i18n.json Added the key for the hint.
Issue(s)
SUP-1080 Discussion Message Count Includes Hidden System Messages
Steps to test or reproduce
Known Limitations
Hide system messagesglobal option (not the room-specific one) under Manage -> Settings -> Messages, you will notice the discussion count with those kind of system messages will not immediately update. Instead, you will have to send a regular message to recompute the count value, which is a reasonable trade-off, given that the global setting is usually configured once and adding a watcher for it to update each discussion parent message with the proper count would be a too expensive operation. Important to clarify that this doesn't happen with the room-specific setting.Summary by CodeRabbit
Summary by CodeRabbit