fix: skip unread alert on room rename when system message is disabled#40872
fix: skip unread alert on room rename when system message is disabled#40872rish106-hub wants to merge 6 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 6e6ad8d The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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:
WalkthroughThe PR modifies ChangesRoom Rename Alert Suppression
🎯 1 (Trivial) | ⏱️ ~3 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
1 issue found across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
rish106-hub
left a comment
There was a problem hiding this comment.
apps/meteor/app/channel-settings/server/functions/saveRoomName.ts:89 - room.sysMes?.includes('r') will false-positive match
'rp', 'ru', or any other sysMes type starting with 'r'. Should use exact element check: room.sysMes?.includes('r') only works correctly if sysMes is string[] with exact values - verify 'r' is never a substring of another valid sysMes token; if tokens can be substrings, use .some(m => m === 'r') instead.
PR_DOCUMENTATION.md — committed to repo root; should not be in source tree, only in PR description body.
Commented in CodeRabbit Change Stack
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/startup/ensureMessagesTextIndex.ts`:
- Line 99: ensureMessagesTextIndex currently calls Messages.col.createIndex(...)
without specifying an explicit name, which can cause MongoDB to auto-generate
overly long names and fail on some FCVs; update the createIndex call in
ensureMessagesTextIndex to pass an options object with a short explicit name for
each variant (e.g., name: 'messages_text' and name: 'messages_room_text' or
similarly concise identifiers) so both the room-scoped and global
TEXT_INDEX_FIELDS indexes are created with stable short names; locate the
createIndex invocation (the line assigning const name = await
Messages.col.createIndex(...)) and add the appropriate name property to the
options argument for each branch.
🪄 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: 9a6eb72c-1fa5-4e02-98bc-0b63d565f425
📒 Files selected for processing (2)
.changeset/fix-search-attachment-fields.mdapps/meteor/server/startup/ensureMessagesTextIndex.ts
✅ Files skipped from review due to trivial changes (1)
- .changeset/fix-search-attachment-fields.md
📜 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). (1)
- GitHub Check: cubic · AI code reviewer
🧰 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/server/startup/ensureMessagesTextIndex.ts
🧠 Learnings (3)
📚 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/startup/ensureMessagesTextIndex.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/startup/ensureMessagesTextIndex.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/startup/ensureMessagesTextIndex.ts
When sysMes suppresses the 'r' (room name changed) system message, room rename no longer marks subscriptions as unread. Uses exact element match (.some(m => m === 'r')) to avoid false positives on tokens like 'rp' or 'ru'. Closes RocketChat#40778
1304981 to
f584c60
Compare
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
…behavior Covers four cases: sysMes without 'r' fires alert, sysMes with 'r' skips alert, undefined sysMes defaults to alert, and partial tokens like 'rp'/'ru' do not suppress the alert. Also refactors updateRoomName: rename param alert → triggerUnreadAlert and extract ternary to subscriptionUpdate variable for readability. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… test cases Addresses cubic P2: each test now verifies room persistence (setNameById) in addition to the subscription alert path, so the spec cannot pass if the room name update is accidentally removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74b462e to
1c3d93f
Compare
…aming limits MongoDB versions prior to 4.2 (or with FCV < 4.2) enforce a 127-byte limit on fully-qualified index names. Auto-generated names from long concatenated field paths exceed this, causing index creation to fail. Specify explicit short names for both index variants: - room-scoped: 'messages_room_text' - default: 'messages_text' This ensures startup succeeds on all MongoDB versions and FCVs.
Proposed changes:
When a room is renamed, saveRoomName was always calling Subscriptions.updateNameAndAlertByRoomId, which marks the room as unread for all members even when the r (room name changed) system message was disabled via sysMes setting.
Fix: check if sysMes includes 'r'. If system message suppressed → call updateNameAndFnameByRoomId (no alert).
Otherwise → call updateNameAndAlertByRoomId as before.
Issue(s): Closes #40778
Steps to test or reproduce:
Further comments:
updateRoomName gets new optional alert param (default true) - no breaking change. Logic isolated to saveRoomName;
federation/discussion path (updateFName) unaffected.
Summary by CodeRabbit