-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Enable Copy with Markdown Formatting #102
base: main
Are you sure you want to change the base?
Conversation
Run & review this pull request in StackBlitz Codeflow. |
|
WalkthroughThe pull request introduces a new feature to enable copying messages from the assistant in a browser extension. This is achieved by adding a Changes
Assessment against linked issues
Poem
π Recent review detailsConfiguration used: CodeRabbit UI π Files selected for processing (1)
π§ Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (2)
src/pages/content/sidebar.tsx (1)
59-63
: Consider error handling or fallback for clipboard operations
Althoughnavigator.clipboard.writeText
typically succeeds in modern browsers, it can reject under certain conditions (e.g., user denies permissions or if invoked outside a user gesture). A try/catch block or user notification can help provide better UX.if (action === 'copy-to-clipboard') { const { content } = _payload as { content: string } - navigator.clipboard.writeText(content) + navigator.clipboard.writeText(content).catch((err) => { + console.error('Clipboard write failed', err) + }) }src/components/Sidebar/chat/ChatList.tsx (1)
94-102
: Assistant copy button
Providing a dedicated copy button is a great UX enhancement. Consider adding a tooltip or confirmation toast to inform users that content has been copied successfully.
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (3)
manifest.config.ts
(1 hunks)src/components/Sidebar/chat/ChatList.tsx
(4 hunks)src/pages/content/sidebar.tsx
(1 hunks)
π Additional comments (5)
manifest.config.ts (1)
44-44
: Looks good: introduction of 'clipboardWrite' permission
Great addition for enabling clipboard functionality. Ensure your use cases comply with user expectations and privacy best practices, as some users may be sensitive to clipboard writes.
src/components/Sidebar/chat/ChatList.tsx (4)
2-7
: Import addition for copy icon
Importing RiFileCopyLine
is consistent with the new clipboard feature. No issues found.
41-43
: Regex approach for formatting
The positive lookbehind (?<=\n\n)
is modern and may not be supported in older browsers, but is typically acceptable for extensions on modern Chromium-based browsers. Just be mindful of potential compatibility issues.
45-53
: Validate window parent usage
Using window.parent.postMessage
is an effective cross-context communication approach. Confirm that the iframe
and parent environment always have matching domains or appropriate event listeners configured to ensure secure and consistent message handling.
111-111
: Consistent formatting usage
Using formatContent(msg.content)
in ReactMarkdown
ensures consistent transformations. Keep an eye on rendering performance and verify that additional spaces or <nbsp>
tags do not unexpectedly alter message display.
β¨ feat: Enable Copy with Markdown Formatting πβοΈ
Summary:
msg.content.replace
logic into a reusableformatContent
function to clean up line breaks and improve formatting.ChatRole.ASSISTANT
) that triggers thehandleCopyMessage
function for quick copying.clipboardWrite
for enabling clipboard functionality.Fixes #98
Summary by CodeRabbit
New Features
Bug Fixes