Skip to content

chore: split composer API and reintroduce RichTextComposerAPI - #41286

Merged
MartinSchoeler merged 2 commits into
poc/real-time-composerfrom
feat-b/real-time-refactor
Jul 16, 2026
Merged

chore: split composer API and reintroduce RichTextComposerAPI#41286
MartinSchoeler merged 2 commits into
poc/real-time-composerfrom
feat-b/real-time-refactor

Conversation

@MartinSchoeler

@MartinSchoeler MartinSchoeler commented Jul 9, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Issue(s)

RTC-4

Steps to test or reproduce

Further comments

Review in cubic

Summary by CodeRabbit

  • Improvements
    • Improved message composer reliability when editing, inserting, replacing, and formatting text.
    • Enhanced draft persistence while composing messages.
    • Preserved quoting, replying, selection, and rich-text editing workflows across composer modes.
    • Improved handling of text updates so changes are consistently reflected in the composer.

@dionisio-bot

dionisio-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 56249bf

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

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The composer APIs now share a new core factory for state, persistence, formatting, event dispatch, and common editor helpers. Plain-text and rich-text implementations retain their specialized text and selection operations while composing their public APIs from the shared core.

Changes

Composer API consolidation

Layer / File(s) Summary
Shared composer core factory
apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts
Adds shared state management, debounced persistence, formatting observation, text helpers, event dispatch, quoted-message handling, initialization, and lifecycle cleanup.
Plain-text composer integration
apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
Delegates common behavior to the core while retaining text insertion, selection, quoting, reply, substring, and cursor helpers.
Rich-text composer integration
apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts
Delegates shared behavior to the core while retaining rich-text editing, selection, reply, substring, and text/selection accessors.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: type: chore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: splitting the composer API and reintroducing RichTextComposerAPI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • RTC-4: Request failed with status code 401

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.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.44068% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.14%. Comparing base (7021e91) to head (56249bf).

Additional details and impacted files

Impacted file tree graph

@@                    Coverage Diff                     @@
##           poc/real-time-composer   #41286      +/-   ##
==========================================================
+ Coverage                   68.08%   68.14%   +0.05%     
==========================================================
  Files                        3976     3977       +1     
  Lines                      155555   155547       -8     
  Branches                    27991    27997       +6     
==========================================================
+ Hits                       105906   105991      +85     
+ Misses                      44913    44819      -94     
- Partials                     4736     4737       +1     
Flag Coverage Δ
e2e 58.53% <76.69%> (+0.13%) ⬆️
e2e-api 44.02% <ø> (-0.02%) ⬇️
unit 70.23% <83.87%> (+0.03%) ⬆️

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.

@MartinSchoeler
MartinSchoeler force-pushed the poc/real-time-composer branch from b59db10 to f79f20b Compare July 13, 2026 20:00
@CLAassistant

CLAassistant commented Jul 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@MartinSchoeler
MartinSchoeler force-pushed the poc/real-time-composer branch 3 times, most recently from 6eda512 to 7021e91 Compare July 15, 2026 14:25
@MartinSchoeler
MartinSchoeler force-pushed the feat-b/real-time-refactor branch from f694f6a to 56249bf Compare July 15, 2026 17:05
@MartinSchoeler
MartinSchoeler marked this pull request as ready for review July 15, 2026 17:06

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts (1)

24-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove newly introduced implementation comments.

  • apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts#L24-L24: express or track the React tracker cleanup outside implementation comments.
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts#L205-L207: move the observer performance rationale to tests or PR documentation.
  • apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts#L62-L62: remove the redundant HTML-storage explanation.

As per coding guidelines, “Avoid code comments in the implementation.” <coding_guidelines>

🤖 Prompt for 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.

In `@apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts` at
line 24, Remove the implementation comments from createComposerAPICore.ts at
lines 24 and 205-207, and from createRichTextComposerAPI.ts at line 62; preserve
the surrounding behavior and move any necessary rationale to tests or PR
documentation instead.

Source: Coding guidelines

🤖 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/app/ui-message/client/messageBox/createComposerAPICore.ts`:
- Line 89: Update the persistence lifecycle around persist, save, and release so
teardown handles any pending debounce before removing listeners or
clearing/reusing the input element. During release, synchronously flush the
pending save when the latest draft must be preserved, then cancel remaining
debounce state to prevent later execution.

In `@apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts`:
- Around line 56-70: Make draft persistence and restoration symmetric in
createComposerAPICore: align the save callback’s innerHTML serialization with
the initialization path that uses setText, either by persisting plain text or by
restoring sanitized HTML through a rich-text initializer. Update the relevant
save and initialValue handling without changing unrelated composer behavior.
- Around line 52-54: Update the composer API setup and release flow around the
input listener and core.release() so the registered handler is stored and
explicitly removed during release. Ensure recreating the API on the same editor
leaves only one active listener and does not retain stale parseOptions.

---

Nitpick comments:
In `@apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts`:
- Line 24: Remove the implementation comments from createComposerAPICore.ts at
lines 24 and 205-207, and from createRichTextComposerAPI.ts at line 62; preserve
the surrounding behavior and move any necessary rationale to tests or PR
documentation instead.
🪄 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: 4a270c76-50ed-4df9-a10e-4f9603eaf514

📥 Commits

Reviewing files that changed from the base of the PR and between 7021e91 and 56249bf.

📒 Files selected for processing (3)
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts
  • apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🧰 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/app/ui-message/client/messageBox/createComposerAPICore.ts
  • apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
🧠 Learnings (3)
📚 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:

  • apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts
  • apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.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:

  • apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts
  • apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
📚 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:

  • apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts
  • apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
🔇 Additional comments (3)
apps/meteor/app/ui-message/client/messageBox/createComposerAPICore.ts (1)

1-23: LGTM!

Also applies to: 25-88, 90-204, 208-218, 223-253

apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts (1)

3-3: LGTM!

Also applies to: 15-58, 136-174

apps/meteor/app/ui-message/client/messageBox/createRichTextComposerAPI.ts (1)

6-50: LGTM!

Also applies to: 74-188, 195-222

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

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.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
@MartinSchoeler
MartinSchoeler merged commit fd61b66 into poc/real-time-composer Jul 16, 2026
84 of 86 checks passed
@MartinSchoeler
MartinSchoeler deleted the feat-b/real-time-refactor branch July 16, 2026 19:01
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.

3 participants