Skip to content

fix(livechat): wrap transfer comment in message body to prevent overflow(#26723)#39734

Open
rohitbansal2005 wants to merge 3 commits into
RocketChat:developfrom
rohitbansal2005:fix/livechat-transfer-comment-wrap
Open

fix(livechat): wrap transfer comment in message body to prevent overflow(#26723)#39734
rohitbansal2005 wants to merge 3 commits into
RocketChat:developfrom
rohitbansal2005:fix/livechat-transfer-comment-wrap

Conversation

@rohitbansal2005
Copy link
Copy Markdown

@rohitbansal2005 rohitbansal2005 commented Mar 19, 2026

Summary: Fixes an issue where long omnichannel transfer comments were rendered on a single line and clipped. Adds safe wrapping rules to the message body so transfer comments (and other long/no-space strings) break into multiple lines.

Files changed: apps\meteor\client\components\message\MessageContentBody.tsx

Proposed changes

  • Add CSS style to the message container to allow breaking long words and wrapping text:
    • overflow-wrap: anywhere
    • word-break: break-word
    • white-space: normal

Rationale: some transfer comments contain long strings (no spaces) or long sentences that previously overflowed the message container causing the text to be hidden.

Issue(s)

Fixes: #26723

Steps to test or reproduce

1.Open an omnichannel conversation as Agent A.
2.Transfer the conversation to Agent B and include a long comment (long sentence or very long no-space string).
3.Switch to Agent B (or open the chat on Agent B’s side) and observe the transfer message:

  • Expected: comment wraps to multiple lines and is fully visible.
  • Previous behavior: comment stayed on one line and overflowed/truncated.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed message text overflow by improving text wrapping, word breaking, and whitespace handling for consistent display.
  • Improvements

    • Enhanced two-factor authentication code inputs with one-time-code autocomplete and optimized input sizing for quicker, more reliable entry.

@rohitbansal2005 rohitbansal2005 requested review from a team as code owners March 19, 2026 11:53
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Mar 19, 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
Copy Markdown

changeset-bot Bot commented Mar 19, 2026

⚠️ No Changeset found

Latest commit: 6cd60e3

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd0199ef-6b70-4564-96f9-03c70db70d65

📥 Commits

Reviewing files that changed from the base of the PR and between 37cf4a8 and 6cd60e3.

📒 Files selected for processing (1)
  • apps/meteor/client/components/message/MessageContentBody.tsx
✅ Files skipped from review due to trivial changes (1)
  • apps/meteor/client/components/message/MessageContentBody.tsx
📜 Recent 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

Walkthrough

Adds a new VS Code TypeScript SDK setting, adds autoComplete='one-time-code' and htmlSize={6} to 2FA code inputs, and applies explicit text-wrapping styles to message body rendering.

Changes

Cohort / File(s) Summary
Developer Configuration
.vscode/settings.json
Added js/ts.tsdk.path pointing to ./node_modules/typescript/lib alongside existing typescript.tsdk.
Two-Factor Authentication UI
apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.tsx, apps/meteor/client/components/TwoFactorModal/TwoFactorTotpModal.tsx
Added autoComplete='one-time-code' and htmlSize={6} to the TextInput used for 2FA code entry.
Message Display
apps/meteor/client/components/message/MessageContentBody.tsx
Destructures style prop and applies inline styles to MessageBody: overflowWrap: 'anywhere', wordBreak: 'break-word', whiteSpace: 'normal' to ensure text wraps properly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Changes to TwoFactorEmailModal.tsx and TwoFactorTotpModal.tsx (adding autoComplete and htmlSize attributes) appear unrelated to the linked issue #26723 about omnichannel message wrapping. Remove two-factor modal changes or clarify their connection to the omnichannel transfer comment wrapping fix; they appear to be unrelated improvements bundled into this PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: fixing text wrapping in message bodies to prevent overflow of long omnichannel transfer comments.
Linked Issues check ✅ Passed The PR directly addresses issue #26723 by adding CSS rules (overflow-wrap, word-break, white-space) to MessageContentBody to enable text wrapping for long transfer comments.
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.

📝 Coding Plan
  • Generate coding plan for human review comments

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
Copy Markdown
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.

No issues found across 6 files

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/meteor/client/components/message/MessageContentBody.tsx`:
- Line 18: The MessageBody JSX in MessageContentBody.tsx currently passes style
before {...props}, allowing callers to fully override the wrapping rules; fix by
destructuring style out of props in the MessageContentBody component (e.g.,
const { style, ...rest } = props) and merge the default wrapping styles with the
incoming style (e.g., mergedStyle = { overflowWrap: 'anywhere', wordBreak:
'break-word', whiteSpace: 'normal', ...style }) then pass style={mergedStyle}
and {...rest} to <MessageBody> so the wrapping rules are preserved while still
honoring caller styles.
🪄 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: 18d0dc78-f703-424f-a31e-e9ca68025961

📥 Commits

Reviewing files that changed from the base of the PR and between ff3a6fd and 37cf4a8.

⛔ Files ignored due to path filters (2)
  • .yarn-install-last.log is excluded by !**/*.log
  • .yarn-install.log is excluded by !**/*.log
📒 Files selected for processing (4)
  • .vscode/settings.json
  • apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.tsx
  • apps/meteor/client/components/TwoFactorModal/TwoFactorTotpModal.tsx
  • apps/meteor/client/components/message/MessageContentBody.tsx
📜 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/client/components/TwoFactorModal/TwoFactorEmailModal.tsx
  • apps/meteor/client/components/TwoFactorModal/TwoFactorTotpModal.tsx
  • apps/meteor/client/components/message/MessageContentBody.tsx
🧠 Learnings (5)
📓 Common learnings
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:18.785Z
Learning: In Rocket.Chat PR reviews, maintain strict scope boundaries—when a PR is focused on a specific endpoint (e.g., rooms.favorite), avoid reviewing or suggesting changes to other endpoints that were incidentally refactored (e.g., rooms.invite) unless explicitly requested by maintainers.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
📚 Learning: 2026-03-18T16:08:11.691Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 39590
File: apps/meteor/client/views/omnichannel/contactInfo/EditContactInfo.tsx:97-99
Timestamp: 2026-03-18T16:08:11.691Z
Learning: In `apps/meteor/client/views/omnichannel/contactInfo/EditContactInfo.tsx`, `reValidateMode: 'onBlur'` is intentionally used (not 'onChange') because the `validateEmailFormat` and `validatePhone` functions are async and call the `checkExistenceEndpoint` API to check for duplicates. Using 'onChange' would trigger excessive network requests on every keystroke. The combination of `mode: 'onSubmit'` with `reValidateMode: 'onBlur'` is a deliberate design decision to minimize API calls while still providing revalidation feedback.

Applied to files:

  • apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.tsx
  • apps/meteor/client/components/TwoFactorModal/TwoFactorTotpModal.tsx
📚 Learning: 2026-03-03T11:11:48.541Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 39230
File: apps/meteor/app/api/server/v1/chat.ts:214-222
Timestamp: 2026-03-03T11:11:48.541Z
Learning: In apps/meteor/server/lib/moderation/reportMessage.ts, the reportMessage function validates that description is not empty or whitespace-only with `if (!description.trim())`. When migrating the chat.reportMessage endpoint to OpenAPI, adding minLength validation to the schema preserves this existing behavior.

Applied to files:

  • apps/meteor/client/components/message/MessageContentBody.tsx
📚 Learning: 2026-03-15T14:31:28.969Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.

Applied to files:

  • .vscode/settings.json
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.{ts,tsx,js} : Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests

Applied to files:

  • .vscode/settings.json
🔇 Additional comments (3)
.vscode/settings.json (1)

20-20: ⚠️ Potential issue | 🟡 Minor

Remove the invalid "js/ts.tsdk.path" VS Code setting.

The setting name "js/ts.tsdk.path" is not a valid current VS Code configuration option. The correct TypeScript SDK setting is "typescript.tsdk" (already present at line 2). The added setting at line 20 is either deprecated or archived and should be removed.

⛔ Skipped due to learnings
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.{ts,tsx,js} : Avoid code comments in the implementation
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.{ts,tsx,js} : Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.tsx (1)

68-68: Good UX enhancement for email 2FA input.

The addition of autoComplete='one-time-code' enables browsers and password managers to autofill the OTP from SMS/email, and htmlSize={6} provides an appropriate visual hint for the expected 6-digit code length.

apps/meteor/client/components/TwoFactorModal/TwoFactorTotpModal.tsx (1)

52-52: Good UX enhancement for TOTP input.

The addition of autoComplete='one-time-code' and htmlSize={6} aligns with the email 2FA modal changes and improves the user experience by enabling autofill support and providing a visual hint for the typical 6-digit TOTP code length.


return (
<MessageBody role='document' aria-roledescription={t('message_body')} dir='auto' {...props}>
<MessageBody role='document' aria-roledescription={t('message_body')} dir='auto' style={{ overflowWrap: 'anywhere', wordBreak: 'break-word', whiteSpace: 'normal' }} {...props}>
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify if call sites pass `style` to MessageContentBody (which currently overrides wrapping rules).
rg -nP --type=tsx -C2 '<MessageContentBody\b[^>]*\bstyle='

Repository: RocketChat/Rocket.Chat

Length of output: 93


🏁 Script executed:

#!/bin/bash
# 1. Check the component implementation
echo "=== Component Implementation ==="
cat -n apps/meteor/client/components/message/MessageContentBody.tsx | head -50

echo -e "\n=== Search for MessageContentBody usage with style prop ==="
# Try broader search without file type specification
rg -nC2 '<MessageContentBody\b[^>]*\bstyle=' --type-list

Repository: RocketChat/Rocket.Chat

Length of output: 1870


🏁 Script executed:

#!/bin/bash
# Search for all usages of MessageContentBody component
rg '<MessageContentBody' -A3 -B1 | head -100

Repository: RocketChat/Rocket.Chat

Length of output: 6843


🏁 Script executed:

#!/bin/bash
# Check the full MessageContentBody usage in RoomMessageContent.tsx
rg '<MessageContentBody' -A10 apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx

Repository: RocketChat/Rocket.Chat

Length of output: 324


🏁 Script executed:

#!/bin/bash
# Verify: Does any call site actually pass a 'style' prop to MessageContentBody?
rg 'MessageContentBody' -A5 | grep -E '(MessageContentBody|style=)' | head -50

Repository: RocketChat/Rocket.Chat

Length of output: 4979


Prevent style prop override at call sites by merging instead of replacing (Line 18).

The current prop order (style={...} {...props}) means any caller passing a style prop would completely override the wrapping rules. While no current call sites do this, the API is exposed. Extract style from props and merge it to ensure wrapping rules are always preserved:

-const MessageContentBody = ({ mentions, channels, md, searchText, ...props }: MessageContentBodyProps) => {
+const MessageContentBody = ({ mentions, channels, md, searchText, style, ...props }: MessageContentBodyProps) => {
 	const { t } = useTranslation();
 
 	return (
-		<MessageBody role='document' aria-roledescription={t('message_body')} dir='auto' style={{ overflowWrap: 'anywhere', wordBreak: 'break-word', whiteSpace: 'normal' }} {...props}>
+		<MessageBody
+			role='document'
+			aria-roledescription={t('message_body')}
+			dir='auto'
+			{...props}
+			style={{ ...style, overflowWrap: 'anywhere', wordBreak: 'break-word', whiteSpace: 'normal' }}
+		>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/components/message/MessageContentBody.tsx` at line 18, The
MessageBody JSX in MessageContentBody.tsx currently passes style before
{...props}, allowing callers to fully override the wrapping rules; fix by
destructuring style out of props in the MessageContentBody component (e.g.,
const { style, ...rest } = props) and merge the default wrapping styles with the
incoming style (e.g., mergedStyle = { overflowWrap: 'anywhere', wordBreak:
'break-word', whiteSpace: 'normal', ...style }) then pass style={mergedStyle}
and {...rest} to <MessageBody> so the wrapping rules are preserved while still
honoring caller styles.

@coderabbitai coderabbitai Bot removed the type: bug label Mar 19, 2026
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.

Omnichannel transfer comment is not wrapped to multiple lines

1 participant