Skip to content

fix: skip unread alert on room rename when system message is disabled#40872

Open
rish106-hub wants to merge 6 commits into
RocketChat:developfrom
rish106-hub:fix/issue-40778-room-rename-unread-notification
Open

fix: skip unread alert on room rename when system message is disabled#40872
rish106-hub wants to merge 6 commits into
RocketChat:developfrom
rish106-hub:fix/issue-40778-room-rename-unread-notification

Conversation

@rish106-hub

@rish106-hub rish106-hub commented Jun 10, 2026

Copy link
Copy Markdown

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:

  1. Create a channel with members
  2. Disable "Room name changed" system message (Admin > Rooms > edit room → uncheck r in System Messages)
  3. Rename the channel
  4. Verify members do not get unread badge / notification
  5. Re-enable system message, rename again → members should get unread alert

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

  • Bug Fixes
    • Room renames no longer trigger unread alerts for members when the "Room name changed" system message is hidden in room settings.

@dionisio-bot

dionisio-bot Bot commented Jun 10, 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

@CLAassistant

CLAassistant commented Jun 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6e6ad8d

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

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

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 Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The PR modifies saveRoomName to conditionally suppress unread alerts when renaming a room if the "Room name changed" system message is hidden. The updateRoomName helper now accepts an alert flag to route subscription updates through either the alerting or non-alerting method, and a changeset entry documents the fix.

Changes

Room Rename Alert Suppression

Layer / File(s) Summary
Conditional alert routing in updateRoomName and saveRoomName
apps/meteor/app/channel-settings/server/functions/saveRoomName.ts
updateRoomName adds an optional alert boolean parameter (default true) and branches between updateNameAndAlertByRoomId (when alert is true) and updateNameAndFnameByRoomId (when alert is false). saveRoomName computes shouldAlert from room.sysMes to determine routing.
Changeset documentation
.changeset/fix-room-rename-unread-alert.md
Patch-level changeset entry documenting that room renames no longer trigger unread alerts when the "Room name changed" system message is hidden in room settings.

🎯 1 (Trivial) | ⏱️ ~3 minutes


type: bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: skipping unread alerts on room rename when the system message is disabled.
Linked Issues check ✅ Passed The changes correctly implement the core requirement from issue #40778: prevent unread marking when room rename system message is disabled.
Out of Scope Changes check ✅ Passed All changes are scoped to the room rename unread alert fix; no unrelated modifications detected.

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

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ISSUE-40778: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rish106-hub rish106-hub marked this pull request as draft June 10, 2026 07:31

@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 2 files

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

Re-trigger cubic

Comment thread PR_DOCUMENTATION.md Outdated
@rish106-hub rish106-hub marked this pull request as ready for review June 10, 2026 07:38
@coderabbitai coderabbitai Bot removed the type: bug label Jun 10, 2026

@rish106-hub rish106-hub left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

@rish106-hub rish106-hub requested a review from a team as a code owner June 10, 2026 08:33
@coderabbitai coderabbitai Bot removed the type: bug label Jun 10, 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 40b288c and 68ac348.

📒 Files selected for processing (2)
  • .changeset/fix-search-attachment-fields.md
  • apps/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

Comment thread apps/meteor/server/startup/ensureMessagesTextIndex.ts Outdated
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
@rish106-hub rish106-hub force-pushed the fix/issue-40778-room-rename-unread-notification branch from 1304981 to f584c60 Compare June 10, 2026 12:56

@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 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

rish106-hub and others added 2 commits June 10, 2026 18:45
…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>
@rish106-hub rish106-hub force-pushed the fix/issue-40778-room-rename-unread-notification branch from 74b462e to 1c3d93f Compare June 10, 2026 13:15
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing the name of a channel marks it as unread

2 participants