Skip to content

Conversation

@AyushKumar123456789
Copy link
Contributor

@AyushKumar123456789 AyushKumar123456789 commented May 16, 2025

This PR is based on the GSOC (2025) project, "AI Enhanced Message Composer Component" Project Link currently introducing the tone enhancement, translation, summaizer UI components in initial version, This PR bind together this three components currently into a single component <MessageBoxEnhancementToolbar> which is then integrate with the new RichTextMessageBox.tsx following similar structure as the <MessageBoxFormattingToolbar> component. This PR is rebased on the top of #35975

Key Changes Include :

  • Introduction of MessageEnhancementToolbar folder for single source of three enhancement components (Contributor friendly and well structured)
  • Introduction of MessageBoxEnhancementToolbar.tsx which imports generic menu components from this file EnhancementToolbarDropdown.tsx.
  • Trying to add <Throbber> , still in initial version.
    image
    image
    image

Since the RicketTextComposer is still in initial phase , there are lots to things to update from here.

Future Work :

  • grammar corrections & context sensitive spelling correction (Highlight areas needing improvement (Grammar, clarity). Click to apply changes.).
  • Message Preview: Allow users to toggle between the original and enhanced/translate message.
  • Hinting: Display suggestions as subtle highlights or underlines, ensuring a smooth, non-intrusive experience.

ishanmitra and others added 13 commits May 12, 2025 23:22
- Replaced the `ComposerMessageInput`'s underlying `<textarea>` with a `<div contenteditable>`.
- Currently, this implementation is non-functional beyond accepting plain text input.
- Placeholder support is currently not working due to limitations with `contenteditable`.
- Further work is needed to restore full functionality, including keyboard event handling, Markdown formatting, and cursor management.
- Clipboard paste and file attachments continue to work as expected.
- Updated Storybook stories to include `MessageComposerInputNew` for preview and testing.
- Refactored existing stories and exports for clarity and compatibility with the new input component.
- Cloned `CreateComposerAPI.ts` as `newCreateComposerAPI.ts` and updated references from `HTMLTextAreaElement` to `HTMLDivElement`.
- Implemented `getSelectionRange` and `setSelectionRange` using the Selection API to replace `input.selectionStart` and `input.selectionEnd`.
- Fixed Enter key functionality, allowing messages to be sent as expected.
- Restored Bold, Italics, and Strikethrough button functionality, confirming successful Selection API migration.

Known Issues & Next Steps
- Enabled `/` key to trigger the slash command menu, but pressing Enter currently inserts the command and sends the message immediately.
- Emoji autocomplete works, but pressing Enter finalizes the emoji and sends the message.
- **The Send button remains visually disabled**, requiring an additional fix to update its state.
- Next step: Prevent message sending when popups (slash command, emoji autocomplete) are active.
- Updated reducer function to handle FormEvent<HTMLDivElement> instead of FormEvent<HTMLInputElement>.
- Changed event target from HTMLInputElement to HTMLDivElement for compatibility with contenteditable.
- Used `innerText.trim()` instead of `value.trim()` to correctly determine if the message input is empty.
- Replaced `onChange` with `onInput` in `MessageComposerInputNew` to properly detect user input.

This ensures the Send button is correctly enabled or disabled based on input presence.

Known Issues & Next Steps:
- Pressing `/` opens the slash command menu, but pressing Enter inserts the command and sends the message immediately.
- Emoji autocomplete works, but Enter finalizes the emoji and sends the message.
- Next step: Prevent message sending when popups (slash command or emoji autocomplete) are active.
- Introduced `featurePreviewComposer` flag to toggle between the new <div contenteditable> input and the classic <textarea> input.
- Conditionally render `MessageBoxNew` or `MessageBox` based on the flag.
- Added `MessageComposerHint` in `MessageBoxNew` to label the feature as experimental.
- Changed class name from `rc-message-box__textarea` to `rc-message-box__divcontenteditable`.
- Rectified string values for `minHeight` and `maxHeight` with numeric values.
- Corrected `minHeight` from `52px` to `20px` to match new layout requirements.
This refactor removes ambiguity and improves naming consistency across the message composer components.

Renamed:
- `MessageComposerInputNew.tsx` → `RichTextComposerInput.tsx`
- `MessageBoxNew.tsx` → `RichTextMessageBox.tsx`
- `newCreateComposerAPI.ts` → `createRichTextComposerAPI.ts`

Updated references in:
- `ComposerMessage.tsx`
- `MessageComposer.stories.tsx`
- `MessageComposer/index.ts`
- Moved `getSelectionRange` and `setSelectionRange` from `createRichTextComposerAPI.ts` to a new `selectionRange.ts` file.
- Improves separation of concerns and allows reuse across other modules.
- Replaced `input.value` and `input.selectionEnd` with `innerText` and `getSelectionRange`
- Used `setSelectionRange` to handle caret movement
- Updated event targets and types from HTMLTextAreaElement to HTMLDivElement
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented May 16, 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 May 16, 2025

⚠️ No Changeset found

Latest commit: 9beb8e2

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

@AyushKumar123456789 AyushKumar123456789 changed the title Ai enhanced message composer. feat : Ai enhanced message composer. May 16, 2025
@AyushKumar123456789 AyushKumar123456789 changed the title feat : Ai enhanced message composer. feat : Add AI enhanced message composer components. May 16, 2025
Removed the small warning about credentials, by Github.
@AyushKumar123456789
Copy link
Contributor Author

AyushKumar123456789 commented May 16, 2025

Why are there so many file changes to my PR because my branch is rebased to #35975 branch.

…oper state management that need to be fixed).
@AyushKumar123456789 AyushKumar123456789 changed the title feat : Add AI enhanced message composer components. feat : Add ai enhancement message composer components. May 18, 2025
@AyushKumar123456789 AyushKumar123456789 changed the title feat : Add ai enhancement message composer components. feat: Add ai enhancement message composer components May 23, 2025
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