Skip to content

chore: message parser limit on the client#40600

Draft
gabriellsh wants to merge 8 commits into
developfrom
chore/markdownParserLimitClient
Draft

chore: message parser limit on the client#40600
gabriellsh wants to merge 8 commits into
developfrom
chore/markdownParserLimitClient

Conversation

@gabriellsh
Copy link
Copy Markdown
Member

@gabriellsh gabriellsh commented May 18, 2026

Proposed changes (including videos or screenshots)

This PR is a complementary of #40306. On this PR we are making consistent the behavior between the BE and FE regarding message parsing, with the use of the new MESSAGE_MAX_PARSE_LENGTH environment variable.

Issue(s)

CORE-2211

Steps to test or reproduce

  1. Setup: Run Rocket.Chat with the MESSAGE_MAX_PARSE_LENGTH environment variable set to 100.

  2. Under Limit: Send a message with < 100 characters containing markdown (e.g., Hello **bold**). Verify the markdown renders correctly. In the database, the message must contain the md property.

  3. Over Limit: Send a message with > 100 characters containing markdown. Verify it renders as plain text (raw asterisks).

  4. Contexts: Verify the same behavior (under vs. over limit) inside a Thread and when Quoting/Replying.

  5. Editing: Edit a short message (currently rendered) and add text to exceed 100 characters. Verify it loses markdown formatting upon saving.

  6. Translations: Enable Auto Translate in a room (Administration > Settings > Message > Auto Translate — requires a translation service configured as per the Auto Translate documentation). Set the target language and send a message in a different language with > 100 characters containing markdown. Verify that the message renders as plain text using the translated text, not the original source language. Also verify the "Translated" indicator is still shown. Repeat inside a Thread parent preview and when Quoting/Replying.

  7. Disabled State: Re-run Rocket.Chat with the MESSAGE_MAX_PARSE_LENGTH env var set to 0. Verify that every message now render markdown correctly again (0 means disabled).

Further comments

Co-authored-by: Copilot <copilot@github.com>
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 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 targeting the wrong base branch. It should target 8.6.0, but it targets 8.5.0

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 May 18, 2026

⚠️ No Changeset found

Latest commit: cc9a123

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 May 18, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3cdf0194-9aff-439c-bd76-0b3690b0e033

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 94.75524% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.58%. Comparing base (cedda23) to head (cc9a123).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40600      +/-   ##
===========================================
- Coverage    69.80%   69.58%   -0.23%     
===========================================
  Files         3325     3330       +5     
  Lines       122974   125254    +2280     
  Branches     21943    21922      -21     
===========================================
+ Hits         85839    87153    +1314     
- Misses       33784    34795    +1011     
+ Partials      3351     3306      -45     
Flag Coverage Δ
unit 69.76% <95.07%> (-0.75%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nazabucciarelli nazabucciarelli changed the title chore: Implement mrkdown parser limit on the client chore: message parser limit on the client May 18, 2026
@nazabucciarelli nazabucciarelli added this to the 8.6.0 milestone May 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the client-side rendering/parsing behavior with the server’s new MESSAGE_MAX_PARSE_LENGTH setting by skipping markdown parsing when message text exceeds the configured limit, falling back to plain-text rendering.

Changes:

  • Add client-side limit resolution (rc-message-parser-max-length meta) and caching utilities (getPageMeta, getMarkdownParserLimit).
  • Enforce the limit in key parsing/rendering paths (parseMessageTextToAstMarkdown, normalizeThreadMessage, MarkdownText, omnichannel contact history).
  • Add unit tests covering limit behavior across parsing and UI components.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
apps/meteor/client/views/omnichannel/contactHistory/MessageList/ContactHistoryMessage.tsx Render plain message.msg when md is absent (e.g., parsing skipped).
apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts Skip parsing and return a plain-text AST when text exceeds the configured limit.
apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts Add tests for “over limit” plain-text AST behavior (message + attachments).
apps/meteor/client/lib/normalizeThreadMessage.tsx Apply the parser limit to thread preview normalization, falling back to plain-text tokens.
apps/meteor/client/lib/normalizeThreadMessage.spec.tsx Add tests validating “within limit” vs “over limit” behavior and error handling.
apps/meteor/client/lib/getPageMeta.ts Add meta tag reader with in-memory caching.
apps/meteor/client/lib/getPageMeta.spec.ts Add tests for meta reading and caching behavior.
apps/meteor/client/lib/getMarkdownParserLimit.ts Resolve the markdown parser limit from meta/default constant with “0 disables” semantics.
apps/meteor/client/lib/getMarkdownParserLimit.spec.ts Add tests for limit resolution from meta/default constant.
apps/meteor/client/components/message/content/attachments/QuoteAttachment.tsx Adjust quote rendering fallback when md is missing (but introduces a regression risk).
apps/meteor/client/components/MarkdownTextInner.tsx Extract previous MarkdownText parsing/sanitization implementation into an inner component.
apps/meteor/client/components/MarkdownText.tsx Add limit-based early return to render plain text without parsing.
apps/meteor/client/components/MarkdownText.spec.tsx Add tests for limit-based plain-text vs parsed rendering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/meteor/client/components/MarkdownText.tsx Outdated
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.

3 participants