Skip to content

fix(ui): prevent username truncation in system messages#38245

Closed
sharanyamahajan wants to merge 11 commits intoRocketChat:developfrom
sharanyamahajan:fix/ui-username-truncation-clean
Closed

fix(ui): prevent username truncation in system messages#38245
sharanyamahajan wants to merge 11 commits intoRocketChat:developfrom
sharanyamahajan:fix/ui-username-truncation-clean

Conversation

@sharanyamahajan
Copy link

@sharanyamahajan sharanyamahajan commented Jan 18, 2026

Proposed changes (including videos or screenshots)

This pull request fixes a UI issue in system messages where the username gets truncated when the room topic is very long.

The issue occurs due to flex layout behavior, where the username container is allowed to shrink to accommodate long topic text. As a result, usernames such as "admin-user" appear truncated as "admin...".

This change prevents the username container from shrinking and allows the topic text to wrap instead. This ensures usernames remain fully visible and improves the readability of system messages.

The change is limited to the message header UI and does not introduce any logic, data flow, or behavioral changes.

Issue(s)

Fixes #38234

Steps to test or reproduce

  1. Open any channel in Rocket.Chat.
  2. Change the room topic to a very long string.
  3. Observe the system message that appears.
  4. Verify that the username is fully visible and the topic text wraps correctly instead of truncating the username.

Further comments

This is a small, focused UI fix scoped only to layout behavior. No alternative approaches were required, and no side effects are expected.

Summary by CodeRabbit

  • New Features

    • Added a loading skeleton component for contextual list views.
  • Bug Fixes

    • Fixed sidebar item removal to behave reliably.
    • Prevented usernames in message headers from being truncated; private message indicator formatting preserved.
  • Chores

    • Simplified profile form inputs (trimmed input handling, streamlined validation UI).
    • Refactored core data-access behavior and improved configuration parsing and defaults.

✏️ Tip: You can customize this high-level summary in your review settings.

@sharanyamahajan sharanyamahajan requested review from a team as code owners January 18, 2026 17:16
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 18, 2026

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
Copy link

changeset-bot bot commented Jan 18, 2026

⚠️ No Changeset found

Latest commit: 46a871c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 18, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Updates fix username truncation in message headers, adjust sidebar item removal, add a contextual list skeleton component, harden MongoDB config parsing and options, and substantially simplify/condense the BaseRaw data-access class API.

Changes

Cohort / File(s) Summary
UI Message Display
apps/meteor/client/components/message/MessageHeader.tsx
Prevent username truncation by adding flexShrink: 0 and whiteSpace: 'nowrap'; moved MessageRoles rendering into an explicit conditional block gated by shouldShowRolesList; wrapped private message indicator in parentheses.
Sidebar Management
apps/meteor/client/lib/createSidebarItems.ts
unregisterSidebarItem now guards index === -1 and uses splice to remove items instead of delete; minor type/formatting adjustments.
Skeleton Component
apps/meteor/client/views/room/contextualBar/lib/ContextualListSkeleton.tsx
New default-exported ContextualListSkeleton component rendering configurable skeleton rows (prop: items?: number, default 6).
MongoDB Configuration
apps/meteor/packages/rocketchat-mongo-config/server/index.js
Set tls.DEFAULT_ECDH_CURVE = 'auto'; add retryWrites: false default when absent from MONGO_URL; wrap JSON.parse(MONGO_OPTIONS) in try/catch with detailed logging and thrown error on invalid JSON; minor formatting/log wording changes.
Data Model API Reduction
packages/models/src/models/BaseRaw.ts
Removed many public data-access methods and overloads; consolidated findOne/findOneById paths; reworked findOneAndDelete to handle optional trash collection with rollback attempts; simplified count and update timestamp behavior; large public API surface reduction.

Sequence Diagram(s)

(No sequence diagrams generated — changes are across UI, config, and large model refactor without a single new multi-component sequential flow requiring visualization.)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • gabriellsh
  • tassoevan

Poem

🐰
I nibbled code where usernames hid,
Stitched roles in place and trimmed the grid.
Skeleton rows hop into view,
Mongo set safe, BaseRaw made new.
A tiny thump — the repo’s new spring dew.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes multiple unrelated file changes (createSidebarItems.ts, ContextualListSkeleton.tsx, mongo config, BaseRaw.ts, AccountProfileForm.tsx) that are not connected to the username truncation issue #38234. Move unrelated changes to separate PRs. Keep only MessageHeader.tsx changes in this PR to fix the username truncation issue per #38234.
✅ 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 directly addresses the main change: preventing username truncation in system messages by modifying MessageHeader styling and logic.
Linked Issues check ✅ Passed The PR title and primary file changes in MessageHeader.tsx directly address issue #38234's requirement to prevent username truncation by adding flexShrink: 0 and whiteSpace properties.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/meteor/packages/rocketchat-mongo-config/server/index.js`:
- Around line 33-47: The catch block that logs the raw MONGO_OPTIONS value
(variable mongoOptionStr in the try/catch parsing block) may leak secrets;
update the error logging to avoid printing the full mongoOptionStr by either
omitting it or replacing it with a redacted/truncated representation (e.g., a
helper like redactSecret(mongoOptionStr) or show only the first/last N chars
with a marker) and keep the existing user-facing throw using error.message;
apply this change inside the existing try/catch that parses mongoOptionStr so
the other log lines and the thrown Error remain intact.
🧹 Nitpick comments (2)
apps/meteor/client/components/message/MessageHeader.tsx (1)

55-59: Remove inline comments from production code.

The fix correctly prevents username truncation using flexShrink: 0 and whiteSpace: 'nowrap'. However, the emoji comments (// 🔑 prevents username truncation, // 🔑 keeps full username visible) should be removed per the coding guidelines.

Suggested fix
 			style={{
 				cursor: 'pointer',
-				flexShrink: 0,          // 🔑 prevents username truncation
-				whiteSpace: 'nowrap',   // 🔑 keeps full username visible
+				flexShrink: 0,
+				whiteSpace: 'nowrap',
 			}}

Based on coding guidelines: "Avoid code comments in the implementation".

apps/meteor/client/views/room/contextualBar/lib/ContextualListSkeleton.tsx (1)

1-2: Consider grouping type imports separately.

Minor style suggestion: group the type import with value imports for consistency.

Suggested import order
-import type { FC } from 'react';
-import { Box, Skeleton } from '@rocket.chat/fuselage';
+import { Box, Skeleton } from '@rocket.chat/fuselage';
+import type { FC } from 'react';

Comment on lines 33 to 47
if (typeof mongoOptionStr !== 'undefined') {
const mongoOptions = JSON.parse(mongoOptionStr);
Object.assign(mongoConnectionOptions, mongoOptions);
try {
const mongoOptions = JSON.parse(mongoOptionStr);
Object.assign(mongoConnectionOptions, mongoOptions);
} catch (error) {
console.error('Failed to parse MONGO_OPTIONS environment variable');
console.error('Provided value:', mongoOptionStr);
console.error('Error:', error.message);
console.error('Please ensure MONGO_OPTIONS contains valid JSON');

throw new Error(
`Invalid MONGO_OPTIONS configuration: ${error.message}`,
);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Good error handling addition, but consider redacting sensitive data in logs.

The try/catch for JSON.parse is a solid improvement that helps operators debug misconfigured environments. However, logging the raw MONGO_OPTIONS value (line 39) could expose sensitive information like credentials if they were mistakenly included in the JSON.

Consider either:

  • Omitting the raw value from logs, or
  • Truncating/redacting it
Suggested safer logging
 	} catch (error) {
 		console.error('Failed to parse MONGO_OPTIONS environment variable');
-		console.error('Provided value:', mongoOptionStr);
+		console.error('Provided value length:', mongoOptionStr.length, 'chars');
 		console.error('Error:', error.message);
 		console.error('Please ensure MONGO_OPTIONS contains valid JSON');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (typeof mongoOptionStr !== 'undefined') {
const mongoOptions = JSON.parse(mongoOptionStr);
Object.assign(mongoConnectionOptions, mongoOptions);
try {
const mongoOptions = JSON.parse(mongoOptionStr);
Object.assign(mongoConnectionOptions, mongoOptions);
} catch (error) {
console.error('Failed to parse MONGO_OPTIONS environment variable');
console.error('Provided value:', mongoOptionStr);
console.error('Error:', error.message);
console.error('Please ensure MONGO_OPTIONS contains valid JSON');
throw new Error(
`Invalid MONGO_OPTIONS configuration: ${error.message}`,
);
}
}
if (typeof mongoOptionStr !== 'undefined') {
try {
const mongoOptions = JSON.parse(mongoOptionStr);
Object.assign(mongoConnectionOptions, mongoOptions);
} catch (error) {
console.error('Failed to parse MONGO_OPTIONS environment variable');
console.error('Provided value length:', mongoOptionStr.length, 'chars');
console.error('Error:', error.message);
console.error('Please ensure MONGO_OPTIONS contains valid JSON');
throw new Error(
`Invalid MONGO_OPTIONS configuration: ${error.message}`,
);
}
}
🤖 Prompt for AI Agents
In `@apps/meteor/packages/rocketchat-mongo-config/server/index.js` around lines 33
- 47, The catch block that logs the raw MONGO_OPTIONS value (variable
mongoOptionStr in the try/catch parsing block) may leak secrets; update the
error logging to avoid printing the full mongoOptionStr by either omitting it or
replacing it with a redacted/truncated representation (e.g., a helper like
redactSecret(mongoOptionStr) or show only the first/last N chars with a marker)
and keep the existing user-facing throw using error.message; apply this change
inside the existing try/catch that parses mongoOptionStr so the other log lines
and the thrown Error remain intact.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 5 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/meteor/packages/rocketchat-mongo-config/server/index.js">

<violation number="1" location="apps/meteor/packages/rocketchat-mongo-config/server/index.js:39">
P2: Logging the raw `MONGO_OPTIONS` value could expose sensitive information like credentials in error logs. Consider logging only the string length or a truncated/redacted version to aid debugging without leaking secrets.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Object.assign(mongoConnectionOptions, mongoOptions);
} catch (error) {
console.error('Failed to parse MONGO_OPTIONS environment variable');
console.error('Provided value:', mongoOptionStr);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 18, 2026

Choose a reason for hiding this comment

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

P2: Logging the raw MONGO_OPTIONS value could expose sensitive information like credentials in error logs. Consider logging only the string length or a truncated/redacted version to aid debugging without leaking secrets.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/packages/rocketchat-mongo-config/server/index.js, line 39:

<comment>Logging the raw `MONGO_OPTIONS` value could expose sensitive information like credentials in error logs. Consider logging only the string length or a truncated/redacted version to aid debugging without leaking secrets.</comment>

<file context>
@@ -22,28 +23,43 @@ const mongoConnectionOptions = {
+		Object.assign(mongoConnectionOptions, mongoOptions);
+	} catch (error) {
+		console.error('Failed to parse MONGO_OPTIONS environment variable');
+		console.error('Provided value:', mongoOptionStr);
+		console.error('Error:', error.message);
+		console.error('Please ensure MONGO_OPTIONS contains valid JSON');
</file context>
Suggested change
console.error('Provided value:', mongoOptionStr);
console.error('Provided value length:', mongoOptionStr.length, 'chars');
Fix with Cubic

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/meteor/client/views/account/profile/AccountProfileForm.tsx`:
- Line 170: The onChange handlers currently call
field.onChange(e.target.value.trim()), which strips spaces while typing; remove
the .trim() from the onChange calls (use field.onChange(e.target.value)) and add
corresponding onBlur handlers that trim the value and call
field.onChange(e.target.value.trim()) so trimming happens only on blur/submit;
apply this change for the fields referenced by the handlers (the
name/statusText/nickname/bio inputs where field.onChange is used).
🧹 Nitpick comments (2)
apps/meteor/client/views/account/profile/AccountProfileForm.tsx (2)

8-9: Unused imports: FieldError and FieldHint are imported but not used.

These components are imported but appear to have no corresponding usage in the JSX. If error display components were intentionally removed, these imports should be cleaned up. If the removal was unintentional, validation errors won't be properly displayed to users.

♻️ Remove unused imports
 import {
   Field,
   FieldGroup,
   FieldLabel,
   FieldRow,
-  FieldError,
-  FieldHint,
   TextInput,
   TextAreaInput,
   Box,
   Icon,
   Button,
 } from '@rocket.chat/fuselage';

75-86: Dead code: handleSendConfirmationEmail and related mutation are never used.

The mutateConfirmationEmail mutation and handleSendConfirmationEmail callback are defined but never invoked in the component. The Button import (line 14) also appears unused. If the resend confirmation email functionality was intentionally removed from the UI, this code should be cleaned up.

♻️ Remove unused code
-import {
+import {
   Field,
   FieldGroup,
   FieldLabel,
   FieldRow,
   TextInput,
   TextAreaInput,
   Box,
   Icon,
-  Button,
 } from '@rocket.chat/fuselage';

And remove the unused mutation and callback:

-const mutateConfirmationEmail = useMutation({
-  mutationFn: sendConfirmationEmail,
-  onSuccess: () => dispatchToastMessage({ type: 'success', message: t('Verification_email_sent') }),
-  onError: (error) => dispatchToastMessage({ type: 'error', message: error }),
-});
-
-const handleSendConfirmationEmail = useCallback(async () => {
-  if (email !== previousEmail) {
-    return;
-  }
-  mutateConfirmationEmail.mutateAsync({ email });
-}, [email, previousEmail, mutateConfirmationEmail]);

If the sendConfirmationEmail endpoint is no longer needed, also remove line 47.

<TextInput
{...field}
id={nameId}
onChange={(e) => field.onChange(e.target.value.trim())}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: trim() on every keystroke prevents typing spaces.

Calling trim() in the onChange handler removes whitespace as the user types, making it impossible to enter multi-word values like "John Doe" for name, "On vacation" for status, etc. The space gets stripped immediately after typing it.

Trim should only be applied on blur or during form submission, not on every keystroke.

🐛 Proposed fix: trim on blur instead of onChange

For each affected field, either remove the trim entirely and handle it server-side, or use onBlur:

 <TextInput
   {...field}
   id={nameId}
-  onChange={(e) => field.onChange(e.target.value.trim())}
+  onChange={(e) => field.onChange(e.target.value)}
+  onBlur={(e) => field.onChange(e.target.value.trim())}
   error={errors.name?.message}
   disabled={!allowRealNameChange}
 />

Apply the same pattern to statusText (line 211), nickname (line 235), and bio (line 252).

Also applies to: 211-211, 235-235, 252-252

🤖 Prompt for AI Agents
In `@apps/meteor/client/views/account/profile/AccountProfileForm.tsx` at line 170,
The onChange handlers currently call field.onChange(e.target.value.trim()),
which strips spaces while typing; remove the .trim() from the onChange calls
(use field.onChange(e.target.value)) and add corresponding onBlur handlers that
trim the value and call field.onChange(e.target.value.trim()) so trimming
happens only on blur/submit; apply this change for the fields referenced by the
handlers (the name/statusText/nickname/bio inputs where field.onChange is used).

Copy link
Contributor

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

Choose a reason for hiding this comment

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

2 issues found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/meteor/client/views/account/profile/AccountProfileForm.tsx">

<violation number="1" location="apps/meteor/client/views/account/profile/AccountProfileForm.tsx:170">
P1: Trimming on every onChange strips user-entered spaces/newlines, preventing multi-word names and multiline bios from being typed.</violation>

<violation number="2" location="apps/meteor/client/views/account/profile/AccountProfileForm.tsx:262">
P2: Resend verification email action is no longer reachable; the email field lacks the button that triggers handleSendConfirmationEmail, leaving unverified users without a resend option while the handler remains dead code.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

<TextInput
{...field}
id={nameId}
onChange={(e) => field.onChange(e.target.value.trim())}
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 18, 2026

Choose a reason for hiding this comment

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

P1: Trimming on every onChange strips user-entered spaces/newlines, preventing multi-word names and multiline bios from being typed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/views/account/profile/AccountProfileForm.tsx, line 170:

<comment>Trimming on every onChange strips user-entered spaces/newlines, preventing multi-word names and multiline bios from being typed.</comment>

<file context>
@@ -162,136 +154,90 @@ const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactEle
 									<TextInput
 										{...field}
 										id={nameId}
+										onChange={(e) => field.onChange(e.target.value.trim())}
 										error={errors.name?.message}
 										disabled={!allowRealNameChange}
</file context>
Suggested change
onChange={(e) => field.onChange(e.target.value.trim())}
onChange={(e) => field.onChange(e.target.value)}
Fix with Cubic

`}
>
<FieldLabel required htmlFor={emailId}>{t('Email')}</FieldLabel>
<FieldRow>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 18, 2026

Choose a reason for hiding this comment

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

P2: Resend verification email action is no longer reachable; the email field lacks the button that triggers handleSendConfirmationEmail, leaving unverified users without a resend option while the handler remains dead code.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/views/account/profile/AccountProfileForm.tsx, line 262:

<comment>Resend verification email action is no longer reachable; the email field lacks the button that triggers handleSendConfirmationEmail, leaving unverified users without a resend option while the handler remains dead code.</comment>

<file context>
@@ -303,69 +249,34 @@ const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactEle
-						`}
-					>
+					<FieldLabel required htmlFor={emailId}>{t('Email')}</FieldLabel>
+					<FieldRow>
 						<Controller
 							control={control}
</file context>
Fix with Cubic

@MartinSchoeler
Copy link
Member

There seems to be lots of unrelated changes in this PR, also it is an exact duplicate of #38242 and it's trying to fix something that someone else has already raised a PR for #38236

I understand that people want to participate on open source projects, but as the old saying goes "quality over quantity" raising a ton of PRs without care will only make the life of the few maintainers harder. So next time I would suggest at least checking if the issue already has a PR, and reviewing your own PR after submitting, to check if its correct.

I'll be closing this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Username gets truncated in system messages with long Channel topics

3 participants