Skip to content

fix: move copy button in the message container - #388

Merged
bdjulbic merged 1 commit into
mainfrom
fix/move-message-container-copy-button
Feb 25, 2026
Merged

bdjulbic merged 1 commit into
mainfrom
fix/move-message-container-copy-button

Conversation

@bdjulbic

@bdjulbic bdjulbic commented Feb 25, 2026 •

Copy link
Copy Markdown
Collaborator

Move the copy button in the message container of the AI assistant
So it appears on mouse hover

Screenshot 2026-02-25 at 17 21 18

Summary by CodeRabbit

  • UI Improvements
    • Repositioned the copy button in answer displays to the header area, providing enhanced accessibility and improved visibility of essential user actions.
    • Refined styling and positioning of message container elements, including adjustments to badge placement, for a more cohesive and polished visual experience.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes relocate the CopyButton from footerActions to headerActions in AnalysisAnswer. MessageContainer is extended with new headerActions and headerActionsClassName props to support header-level action rendering, with Badge positioning adjusted accordingly.

Changes

Cohort / File(s) Summary
MessageContainer Enhancement
packages/ai-core/src/components/MessageContainer.tsx
Added headerActions and headerActionsClassName props to MessageContainerProps, implemented conditional rendering of header actions container, and adjusted Badge positioning from left-2 top-[-12px] to top-[-12px] left-2.
AnalysisAnswer Integration
packages/ai-core/src/components/AnalysisAnswer.tsx
Migrated CopyButton from footerActions to headerActions with className styling, updating MessageContainer prop usage to leverage new header actions API.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • feat: AI output copy to clipboard #368: Directly related as the original PR that introduced footerActions and copy-button support in MessageContainer; this change reorganizes that API by moving the copy button from footer to header position.

Poem

🐰 From footer to header, our copy button flies,
A headerActions debut beneath the blue skies!
With new props in place and positioning so right,
The MessageContainer's ready to dazzle in light! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: move copy button in the message container' directly and clearly summarizes the main change: relocating the copy button's position within the MessageContainer component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/move-message-container-copy-button

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ai-core/src/components/MessageContainer.tsx`:
- Around line 57-66: The header action container in MessageContainer.tsx (the
div rendering headerActions and using headerActionsClassName) is hidden by
default which makes copy/controls undiscoverable on touch; update the tailwind
classes so the control is visible by default on small/touch screens but remains
hover/focus-revealed on larger pointer devices—replace the current 'opacity-0
... group-focus-within:opacity-100 group-hover:opacity-100' fragment with a
responsive variant like 'opacity-100 sm:opacity-0 ...
sm:group-focus-within:opacity-100 sm:group-hover:opacity-100' while preserving
headerActionsClassName and the rest of the wrapper.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45ef14f and 87c092e.

📒 Files selected for processing (2)
  • packages/ai-core/src/components/AnalysisAnswer.tsx
  • packages/ai-core/src/components/MessageContainer.tsx

Comment on lines +57 to +66
{headerActions && (
<div
className={cn(
'absolute right-2 bottom-2 flex items-center justify-end gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100',
headerActionsClassName,
)}
>
{headerActions}
</div>
)}

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.

⚠️ Potential issue | 🟠 Major

Copy action becomes effectively undiscoverable on touch devices.

This container is hidden by default (opacity-0) and only shown on hover/focus-within. On touch screens (no hover), users may not discover or access the copy affordance reliably.

💡 Suggested fix (show by default on small/touch-centric layouts)
-            'absolute right-2 bottom-2 flex items-center justify-end gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100',
+            'absolute right-2 bottom-2 flex items-center justify-end gap-1 opacity-100 transition-opacity sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{headerActions && (
<div
className={cn(
'absolute right-2 bottom-2 flex items-center justify-end gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100',
headerActionsClassName,
)}
>
{headerActions}
</div>
)}
{headerActions && (
<div
className={cn(
'absolute right-2 bottom-2 flex items-center justify-end gap-1 opacity-100 transition-opacity sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100',
headerActionsClassName,
)}
>
{headerActions}
</div>
)}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ai-core/src/components/MessageContainer.tsx` around lines 57 - 66,
The header action container in MessageContainer.tsx (the div rendering
headerActions and using headerActionsClassName) is hidden by default which makes
copy/controls undiscoverable on touch; update the tailwind classes so the
control is visible by default on small/touch screens but remains
hover/focus-revealed on larger pointer devices—replace the current 'opacity-0
... group-focus-within:opacity-100 group-hover:opacity-100' fragment with a
responsive variant like 'opacity-100 sm:opacity-0 ...
sm:group-focus-within:opacity-100 sm:group-hover:opacity-100' while preserving
headerActionsClassName and the rest of the wrapper.

Copilot AI 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.

Pull request overview

This PR moves the copy button in AI assistant messages from a footer position (below content, with relative positioning) to an overlay position (absolutely positioned at bottom-right, appearing on hover). The change improves the UI by making the copy button appear within the message container on mouse hover rather than below the message content.

Changes:

  • Added headerActions and headerActionsClassName props to MessageContainer component for absolutely-positioned actions
  • Changed AnalysisAnswer to use headerActions instead of footerActions for the copy button
  • Applied border styling to the copy button for better visibility

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/ai-core/src/components/MessageContainer.tsx Added new headerActions props that render absolutely-positioned actions at bottom-right with hover opacity; reordered CSS classes for error badge positioning
packages/ai-core/src/components/AnalysisAnswer.tsx Changed copy button from footerActions to headerActions and added border styling
Comments suppressed due to low confidence (1)

packages/ai-core/src/components/MessageContainer.tsx:42

  • The ordering of positioning classes is inconsistent with the pattern used elsewhere in the same file. Line 60 uses "right-2 bottom-2" (horizontal then vertical), but this line now uses "top-[-12px] left-2" (vertical then horizontal). For consistency, consider using "left-2 top-[-12px]" to match the horizontal-then-vertical pattern used on line 60.
            'absolute top-[-12px] left-2 flex items-center gap-1 border text-xs',

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +14
headerActions?: React.ReactNode;
headerActionsClassName?: string;

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming "headerActions" is misleading since these actions are positioned at the bottom-right of the container (using "absolute right-2 bottom-2" on line 60), not in the header area. Consider renaming to something more descriptive like "overlayActions" or "inlineActions" to better reflect that these are absolutely positioned actions that overlay the content.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a non-issue in my opinion.
We can keep it like headerActions

Comment on lines +25 to +26
headerActions,
headerActionsClassName,

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming "headerActions" is misleading since these actions are positioned at the bottom-right of the container (line 60 uses "absolute right-2 bottom-2"), not in the header area. Consider renaming to something more descriptive like "overlayActions" or "inlineActions" to better reflect that these are absolutely positioned actions that overlay the content.

Copilot uses AI. Check for mistakes.
[content],
);
const footerActions = hasTextContent ? (
const headerActions = hasTextContent ? (

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name "headerActions" is misleading since these actions are positioned at the bottom-right of the container (see MessageContainer line 60 which uses "absolute right-2 bottom-2"), not in the header area. Consider renaming to something more descriptive like "overlayActions" or "inlineActions" to better reflect the actual positioning and purpose.

Copilot uses AI. Check for mistakes.
@bdjulbic
bdjulbic merged commit 7c57d70 into main Feb 25, 2026
8 checks passed
@bdjulbic
bdjulbic deleted the fix/move-message-container-copy-button branch February 25, 2026 16:49
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