chore: message parser limit on the client#40600
Conversation
Co-authored-by: Copilot <copilot@github.com>
|
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 |
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…e/markdownParserLimitClient
There was a problem hiding this comment.
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-lengthmeta) 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.
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_LENGTHenvironment variable.Issue(s)
CORE-2211
Steps to test or reproduce
Setup: Run Rocket.Chat with the
MESSAGE_MAX_PARSE_LENGTHenvironment variable set to100.Under Limit: Send a message with
< 100characters containing markdown (e.g.,Hello **bold**). Verify the markdown renders correctly. In the database, the message must contain themdproperty.Over Limit: Send a message with
> 100characters containing markdown. Verify it renders as plain text (raw asterisks).Contexts: Verify the same behavior (under vs. over limit) inside a Thread and when Quoting/Replying.
Editing: Edit a short message (currently rendered) and add text to exceed 100 characters. Verify it loses markdown formatting upon saving.
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.
Disabled State: Re-run Rocket.Chat with the
MESSAGE_MAX_PARSE_LENGTHenv var set to0. Verify that every message now render markdown correctly again (0 means disabled).Further comments