Skip to content

Fix copy button visibility and add copied text #113

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

Closed
wants to merge 1 commit into from

Conversation

Royal-lobster
Copy link
Owner

@Royal-lobster Royal-lobster commented Mar 11, 2025

Related to #109


For more details, open the Copilot Workspace session.

Summary by CodeRabbit

  • New Features
    • Added a visual "Copied!" notification that appears temporarily when a message is copied to provide user feedback.
  • Style
    • Updated the appearance of copy buttons to ensure they remain consistently visible without requiring hover actions.

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Mar 11, 2025

⚠️ No Changeset found

Latest commit: 9f48665

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

Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Walkthrough

This change introduces a new state variable in the ChatList component to control the visibility of a "Copied!" message when a message is copied. It uses a state hook and an effect hook to display the feedback for 3 seconds. The copy button now toggles between two icons based on this state, and certain CSS classes have been removed from buttons to adjust their visibility.

Changes

File Path Summary
src/.../ChatList.tsx - Added showCopiedText state and corresponding useEffect for 3-second timeout.
- Updated handleCopyMessage to show feedback with conditional rendering for check (RiCheckLine) or copy (RiFileCopyLine) icons.
- Removed group-hover:cdx-visible and cdx-invisible CSS classes from buttons.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant C as ChatList Component
    participant T as Timer (useEffect)
    
    U->>C: Clicks copy button
    C->>C: set showCopiedText = true
    C->>U: Renders check icon & "Copied!" message
    T->>C: After 3s, set showCopiedText = false
    C->>U: Renders copy icon & hides "Copied!" message
Loading

Possibly related PRs

Poem

I'm a bunny in the code, hopping with delight,
Copying messages so smoothly, a marvelous sight!
A check icon appears, and "Copied!" shimmers with glee,
In the world of ChatList changes, as spry as can be.
With every hop and every click, the code sings in tune,
Celebrating these changes under a digital moon!

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (1)
src/components/Sidebar/chat/ChatList.tsx (1)

148-152: Suggest positioning improvement for the copied notification.

The fixed positioning with transform works, but it might overlap with other UI elements in some cases.

Consider using a toast notification system or positioning the element relative to the copy button for a more contextual user experience:

-      {showCopiedText && (
-        <div className="cdx-fixed cdx-bottom-4 cdx-left-1/2 cdx-transform cdx--translate-x-1/2 cdx-bg-black cdx-text-white cdx-px-4 cdx-py-2 cdx-rounded">
-          Copied!
-        </div>
-      )}
+      {showCopiedText && (
+        <div className="cdx-fixed cdx-bottom-16 cdx-right-4 cdx-bg-black cdx-text-white cdx-px-4 cdx-py-2 cdx-rounded cdx-shadow-md cdx-z-50 cdx-transition-opacity">
+          Copied!
+        </div>
+      )}

Additionally, consider adding a fade transition to make the appearance and disappearance smoother:

/* Add to the className */
cdx-animate-fade cdx-duration-300
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6dc97c and 9f48665.

📒 Files selected for processing (1)
  • src/components/Sidebar/chat/ChatList.tsx (6 hunks)
🔇 Additional comments (6)
src/components/Sidebar/chat/ChatList.tsx (6)

1-1: Appropriate icon import added for the copy feedback.

Adding the RiCheckLine icon is a good choice for providing visual feedback when content is copied.

Also applies to: 7-7


32-33: Good state management for copied text feedback.

The new state variable effectively tracks when to show the "Copied!" notification to users.


34-41: Well-implemented auto-dismissal of the copied notification.

The useEffect correctly sets up a timeout to hide the copied confirmation after 3 seconds and properly cleans up the timeout when the component unmounts or when the state changes again.


64-64: Good integration of copy feedback with existing functionality.

Setting the copied text state within the existing copy function is the right approach and ensures user feedback is triggered at the appropriate time.


101-101: Button visibility improved.

Removing the conditional visibility classes ensures users can always see and access the delete button functionality without having to hover first.


110-112: Enhanced user feedback for copy operations.

The button now provides clear visual feedback by toggling between copy and check icons based on state. Making the button consistently visible also improves usability.

@Royal-lobster
Copy link
Owner Author

Fixed this in migrate-wxt branch

@github-project-automation github-project-automation bot moved this from Backlog to Done in 💬 Project Syncia Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

1 participant