fix(Realime Composer): Various issues fixes - #41630
Conversation
|
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 |
|
WalkthroughThe rich-text composer now preserves source text during markup rendering, restores drafts immediately, normalizes newline behavior, handles lossy parser output safely, selects thread drafts correctly, and exposes explicit disabled and hidden input states. ChangesRich-text composer rendering
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant RichTextMessageBox
participant renderComposerContent
participant renderComposerMarkup
participant ComposerMarkup
RichTextMessageBox->>renderComposerContent: composer source and selection
renderComposerContent->>renderComposerMarkup: parsed source
renderComposerMarkup->>ComposerMarkup: source context and tokens
ComposerMarkup-->>renderComposerMarkup: rendered composer markup
renderComposerMarkup-->>renderComposerContent: HTML output
renderComposerContent-->>RichTextMessageBox: updated content and selection
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (2)
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 @@
## poc/real-time-composer #41630 +/- ##
==========================================================
- Coverage 68.70% 68.67% -0.04%
==========================================================
Files 4163 4152 -11
Lines 160745 160551 -194
Branches 28246 28238 -8
==========================================================
- Hits 110442 110252 -190
- Misses 45127 45128 +1
+ Partials 5176 5171 -5
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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/client/views/room/composer/messageBox/RichTextMessageBox.tsx`:
- Around line 141-144: Remove the implementation rationale comments at
apps/meteor/client/views/room/composer/messageBox/RichTextMessageBox.tsx:141-144
and :286-287, and at
packages/ui-composer/src/MessageComposer/RichTextComposerInput.tsx:20-21. Leave
the surrounding parser-option, disabled-event, and prop-handling logic
unchanged.
In `@packages/gazzodown-alt/src/ComposerCodeElement.tsx`:
- Around line 7-11: Remove the unthemed mention highlight classes from the
mention rendering flow. Update ComposerCodeElement in
packages/gazzodown-alt/src/ComposerCodeElement.tsx, ComposerMentionChannel in
packages/gazzodown-alt/src/ComposerMentionChannel.tsx, and ComposerMentionUser
in packages/gazzodown-alt/src/ComposerMentionUser.tsx to use only existing
themed classes such as code-colors, preserving the current mention content and
rendering behavior.
In `@packages/gazzodown-alt/src/ComposerMarkup.tsx`:
- Around line 133-134: Update the BIG_EMOJI case in ComposerMarkup to append a
trailing newline to sourceOf(block, source), matching the other block renderers
and preserving line-by-line source reconstruction. Keep the existing
ComposerPlainSpan rendering behavior otherwise unchanged.
- Around line 41-145: Update ComposerMarkup’s block rendering so paragraph and
other block outputs do not add unconditional trailing newlines that duplicate
separate LINE_BREAK blocks. Preserve the exact number of inter-block blank lines
represented by LINE_BREAK tokens, while retaining required separators for
consecutive content blocks and round-tripping input such as “a\n\nb” unchanged.
🪄 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 Plus
Run ID: f33c5e39-13ce-4670-992e-d261fd4aabf1
📒 Files selected for processing (22)
apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.tsapps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.tsapps/meteor/app/ui-message/client/messageBox/messageStateHandler.tsapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.spec.tsxapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.tsxapps/meteor/client/views/room/composer/messageBox/RichTextMessageBox.tsxpackages/gazzodown-alt/src/ComposerBoldSpan.tsxpackages/gazzodown-alt/src/ComposerCodeBlock.tsxpackages/gazzodown-alt/src/ComposerCodeElement.tsxpackages/gazzodown-alt/src/ComposerEmojiElement.tsxpackages/gazzodown-alt/src/ComposerInlineElements.tsxpackages/gazzodown-alt/src/ComposerItalicSpan.tsxpackages/gazzodown-alt/src/ComposerLinkSpan.tsxpackages/gazzodown-alt/src/ComposerMarkup.tsxpackages/gazzodown-alt/src/ComposerMarkupContext.tspackages/gazzodown-alt/src/ComposerMentionChannel.tsxpackages/gazzodown-alt/src/ComposerMentionUser.tsxpackages/gazzodown-alt/src/ComposerStrikeSpan.tsxpackages/gazzodown-alt/src/sourceOf.tspackages/ui-composer/src/MessageComposer/RichTextComposerInput.spec.tsxpackages/ui-composer/src/MessageComposer/RichTextComposerInput.tsx
💤 Files with no reviewable changes (2)
- packages/gazzodown-alt/src/ComposerEmojiElement.tsx
- packages/gazzodown-alt/src/ComposerLinkSpan.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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:
packages/gazzodown-alt/src/ComposerItalicSpan.tsxpackages/gazzodown-alt/src/ComposerMentionUser.tsxpackages/ui-composer/src/MessageComposer/RichTextComposerInput.spec.tsxapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.tsxpackages/gazzodown-alt/src/sourceOf.tspackages/gazzodown-alt/src/ComposerBoldSpan.tsxpackages/gazzodown-alt/src/ComposerCodeBlock.tsxpackages/gazzodown-alt/src/ComposerInlineElements.tsxpackages/gazzodown-alt/src/ComposerMarkupContext.tspackages/ui-composer/src/MessageComposer/RichTextComposerInput.tsxpackages/gazzodown-alt/src/ComposerCodeElement.tsxapps/meteor/app/ui-message/client/messageBox/messageStateHandler.tspackages/gazzodown-alt/src/ComposerStrikeSpan.tsxapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.tsapps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.tsapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.spec.tsxpackages/gazzodown-alt/src/ComposerMarkup.tsxapps/meteor/client/views/room/composer/messageBox/RichTextMessageBox.tsxpackages/gazzodown-alt/src/ComposerMentionChannel.tsx
**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use.spec.tsextension for test files (e.g.,login.spec.ts)
Files:
apps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.ts
🧠 Learnings (6)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.
Applied to files:
packages/gazzodown-alt/src/ComposerItalicSpan.tsxpackages/gazzodown-alt/src/ComposerMentionUser.tsxpackages/ui-composer/src/MessageComposer/RichTextComposerInput.spec.tsxapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.tsxpackages/gazzodown-alt/src/ComposerBoldSpan.tsxpackages/gazzodown-alt/src/ComposerCodeBlock.tsxpackages/gazzodown-alt/src/ComposerInlineElements.tsxpackages/ui-composer/src/MessageComposer/RichTextComposerInput.tsxpackages/gazzodown-alt/src/ComposerCodeElement.tsxpackages/gazzodown-alt/src/ComposerStrikeSpan.tsxapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.spec.tsxpackages/gazzodown-alt/src/ComposerMarkup.tsxapps/meteor/client/views/room/composer/messageBox/RichTextMessageBox.tsxpackages/gazzodown-alt/src/ComposerMentionChannel.tsx
📚 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:
packages/gazzodown-alt/src/ComposerItalicSpan.tsxpackages/gazzodown-alt/src/ComposerMentionUser.tsxpackages/ui-composer/src/MessageComposer/RichTextComposerInput.spec.tsxapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.tsxpackages/gazzodown-alt/src/sourceOf.tspackages/gazzodown-alt/src/ComposerBoldSpan.tsxpackages/gazzodown-alt/src/ComposerCodeBlock.tsxpackages/gazzodown-alt/src/ComposerInlineElements.tsxpackages/gazzodown-alt/src/ComposerMarkupContext.tspackages/ui-composer/src/MessageComposer/RichTextComposerInput.tsxpackages/gazzodown-alt/src/ComposerCodeElement.tsxapps/meteor/app/ui-message/client/messageBox/messageStateHandler.tspackages/gazzodown-alt/src/ComposerStrikeSpan.tsxapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.tsapps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.tsapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.spec.tsxpackages/gazzodown-alt/src/ComposerMarkup.tsxapps/meteor/client/views/room/composer/messageBox/RichTextMessageBox.tsxpackages/gazzodown-alt/src/ComposerMentionChannel.tsx
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.
Applied to files:
packages/ui-composer/src/MessageComposer/RichTextComposerInput.spec.tsxapps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.tsapps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.spec.tsx
📚 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:
packages/gazzodown-alt/src/sourceOf.tspackages/gazzodown-alt/src/ComposerMarkupContext.tsapps/meteor/app/ui-message/client/messageBox/messageStateHandler.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.tsapps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.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:
packages/gazzodown-alt/src/sourceOf.tspackages/gazzodown-alt/src/ComposerMarkupContext.tsapps/meteor/app/ui-message/client/messageBox/messageStateHandler.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.tsapps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.
Applied to files:
apps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.tsapps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.ts
🪛 ast-grep (0.45.0)
apps/meteor/app/ui-message/client/messageBox/messageStateHandler.ts
[warning] 20-20: Direct HTML content assignment detected. Modifying innerHTML, outerHTML, or using document.write with unsanitized content can lead to XSS vulnerabilities. Use secure alternatives like textContent or sanitize HTML with libraries like DOMPurify.
Context: target.innerHTML = renderComposerMarkup(parse(source, parseOptions), source)
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation
(unsafe-html-content-assignment)
[warning] 25-25: Direct HTML content assignment detected. Modifying innerHTML, outerHTML, or using document.write with unsanitized content can lead to XSS vulnerabilities. Use secure alternatives like textContent or sanitize HTML with libraries like DOMPurify.
Context: target.innerHTML = escapeHTML(text)
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation
(unsafe-html-content-assignment)
[warning] 20-20: Direct modification of innerHTML or outerHTML properties detected. Modifying these properties with unsanitized user input can lead to XSS vulnerabilities. Use safe alternatives or sanitize content first.
Context: target.innerHTML = renderComposerMarkup(parse(source, parseOptions), source)
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation
(dom-content-modification)
[warning] 25-25: Direct modification of innerHTML or outerHTML properties detected. Modifying these properties with unsanitized user input can lead to XSS vulnerabilities. Use safe alternatives or sanitize content first.
Context: target.innerHTML = escapeHTML(text)
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation
(dom-content-modification)
apps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.ts
[warning] 25-25: Direct modification of innerHTML or outerHTML properties detected. Modifying these properties with unsanitized user input can lead to XSS vulnerabilities. Use safe alternatives or sanitize content first.
Context: document.body.innerHTML = ''
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation
(dom-content-modification)
apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.ts
[warning] 163-163: Direct modification of innerHTML or outerHTML properties detected. Modifying these properties with unsanitized user input can lead to XSS vulnerabilities. Use safe alternatives or sanitize content first.
Context: document.body.innerHTML = ''
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation
(dom-content-modification)
🔇 Additional comments (18)
packages/gazzodown-alt/src/ComposerMarkupContext.ts (1)
3-10: LGTM!apps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.tsx (1)
6-10: LGTM!packages/gazzodown-alt/src/ComposerMarkup.tsx (1)
90-127: LGTM on the newUNORDERED_LIST/ORDERED_LIST/TASKSrenderers — the intentional prefix-normalization loss (e.g.*bullets →-) is already documented and covered by the "lossy" test suite inrenderComposerMarkup.spec.tsx.packages/gazzodown-alt/src/ComposerCodeBlock.tsx (1)
10-14: LGTM!Also applies to: 23-27
apps/meteor/app/ui-message/client/messageBox/messageStateHandler.ts (1)
2-8: LGTM! The parse → render →sameTextfallback design correctly protects the caret/text (and is safe against injection sincerenderComposerMarkupoutput is React-escaped and the fallback path runs throughescapeHTML). See related comment onpackages/gazzodown-alt/src/ComposerMarkup.tsx(Lines 41-145) regarding a gap this comparison surfaces for blank-line-separated multi-paragraph input.Also applies to: 12-31
apps/meteor/app/ui-message/client/messageBox/messageStateHandler.spec.ts (1)
1-94: LGTM! Good coverage of the renderer-invocation contract, keep/fallback branches, and the HTML-injection-safety assertion (Lines 83-93).apps/meteor/app/ui-message/client/messageBox/renderComposerMarkup.spec.tsx (1)
30-89: LGTM! Thorough parametrized coverage of text-exactness, caret round-trip, and the explicitly-documented lossy cases.apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts (1)
56-63: LGTM! Correctly avoids re-rendering an empty composer into a non-empty trailing-newline state.packages/gazzodown-alt/src/sourceOf.ts (5)
1-16: LGTM!
30-63: LGTM!
76-91: LGTM!
64-74: 🎯 Functional CorrectnessNo change needed.
The relevant autolink parser paths either preserve the typed label (
src === label) or use the//prefix, so the current detection covers the parser-generated plain autolink shapes.
17-25: 🎯 Functional CorrectnessNo change needed.
Non-unicode emoji nodes are reconstructed from
EmojiShortCodeas:"+$[0-9a-zA-Z-_+.]++":, soemoji.value.valueequals the typed shortcode and won't substitute a resolver/preview form.packages/gazzodown-alt/src/ComposerInlineElements.tsx (1)
3-62: LGTM!packages/gazzodown-alt/src/ComposerBoldSpan.tsx (1)
4-19: LGTM!packages/gazzodown-alt/src/ComposerItalicSpan.tsx (1)
4-18: LGTM!packages/gazzodown-alt/src/ComposerStrikeSpan.tsx (1)
4-18: LGTM!apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.spec.ts (1)
7-8: LGTM!Also applies to: 110-143, 161-188
418d2fe
into
poc/real-time-composer
Proposed changes (including videos or screenshots)
Fixes
- item,1. item,- [x] task,---, GFM tables,<t:...>andare rendered as their literal markup instead of being dropped. (I-02):smile:or one unicode emoji on an otherwise empty line used to blank the whole box. (I-02)# hi :smile:,# hi *bold*and# hi @userused to lose everything after the plain text. (I-03)>hino longer gains a space it never had, and# hino longer loses one — no phantom characters, no off-by-one caret. (I-05)*a.com/x*keeps its bold, and typing[[[LINK_0]]]next to a URL no longer duplicates the URL. (I-07, I-01)disabledis inert on a contenteditable, so it now togglescontentEditableand is enforced in the keydown and paste handlers. Typing, pasting and pressing Enter are blocked while recording, while uploads are processing, and in channels the user has not joined — matching the classic composer. (I-11)Issue(s)
RTC-13
RTC-14
RTC-57
RTC-54
RTC-52
RTC-58
RTC-59
RTC-60
RTC-61
RTC-62
RTC-63
RTC-64
RTC-65
RTC-66
RTC-67
RTC-68
RTC-69
RTC-70
RTC-71
Steps to test or reproduce
Further comments
Summary by CodeRabbit
New Features
Bug Fixes