Skip to content

Conversation

@amitkumarashutosh
Copy link

@amitkumarashutosh amitkumarashutosh commented Feb 26, 2025

Feature summary

Fix the toggle option for formatting buttons and shortcuts in message composer

Video

Screen.Recording.2025-02-26.at.11.31.47.AM.mov

Issue(s)

#35086

Steps to test or reproduce

  1. Open the message composer in Rocket.Chat.
  2. Type some text and select it.
  3. Click the Bold (B) button or use the shortcut (Ctrl+B / Cmd+B).
  4. Click the Bold button again or use the shortcut again.

Summary by CodeRabbit

  • Refactor
    • Optimized text pattern matching logic in message composition for improved efficiency.

✏️ Tip: You can customize this high-level summary in your review settings.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 26, 2025

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

changeset-bot bot commented Feb 26, 2025

⚠️ No Changeset found

Latest commit: 5f1a007

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

@CLAassistant
Copy link

CLAassistant commented Feb 26, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

Walkthrough

The wrapSelection function in the composer API was refactored to use direct substring comparisons via slice() instead of character-by-character iteration to detect start and end patterns, simplifying the matching logic without altering functionality.

Changes

Cohort / File(s) Summary
Pattern Matching Refactor
apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
Replaced iterative character checks with direct slice() substring comparisons for start and end pattern detection in wrapSelection. Logic simplified without control flow changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through code with care,
No loops through chars floating in air—
With slices clean, the patterns align,
Simpler logic, more refined! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title claims to add a toggle option for formatting buttons and shortcuts, but the actual changes only simplify substring comparison logic in the wrapSelection function without implementing any toggle functionality. Update the PR title to reflect the actual changes, such as 'refactor: Simplify substring comparisons in wrapSelection function' or provide changes that actually implement the toggle feature described in the title.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d3511ea and 5f1a007.

📒 Files selected for processing (1)
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
🧰 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/createComposerAPI.ts
🔇 Additional comments (1)
apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts (1)

227-231: LGTM! Clean refactoring for pattern detection.

The refactoring from character-by-character iteration to direct substring comparison using slice() is well-implemented. The logic correctly handles edge cases:

  • When the selection is near the start/end of the input, slice() naturally returns partial or empty strings that won't match the full patterns, correctly indicating patterns are not present
  • This enables proper toggle behavior for formatting buttons

The code is more concise, readable, and performant.


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.

@amitkumarashutosh amitkumarashutosh marked this pull request as draft January 4, 2026 04:53
@amitkumarashutosh amitkumarashutosh marked this pull request as ready for review January 4, 2026 05:43
@amitkumarashutosh amitkumarashutosh marked this pull request as draft January 4, 2026 05:44
Copy link
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 1 file

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.

2 participants