Skip to content

feat: add copy buttons and improve mobile Enter behavior#647

Open
croll83 wants to merge 3 commits intoThe-Vibe-Company:mainfrom
croll83:feature/copy-and-mobile-enter
Open

feat: add copy buttons and improve mobile Enter behavior#647
croll83 wants to merge 3 commits intoThe-Vibe-Company:mainfrom
croll83:feature/copy-and-mobile-enter

Conversation

@croll83
Copy link
Copy Markdown

@croll83 croll83 commented Apr 7, 2026

Features

1. Copy Buttons

  • ✅ Copy button on hover for entire AI messages (top-right)
  • ✅ Copy button in code block headers for copying code only
  • ✅ CopyButton component with clipboard → check animation
  • ✅ Code blocks now always show header with language label and copy button
  • ✅ Fallback document.execCommand for older browsers

2. Mobile Enter Behavior

  • ✅ Mobile detection via user agent pattern matching
  • ✅ On mobile: Enter creates newline, send only via button
  • ✅ On desktop: unchanged (Enter sends, Shift+Enter newline)
  • ✅ Fixes mobile keyboard limitations where Shift+Enter unavailable

Screenshots

Copy Buttons in Action

Shows copy buttons appearing on code block headers (BASH) and message hover:

Copy buttons demo

Mobile Enter Behavior

Shows newlines being created in the textarea via Enter key on mobile:

Mobile newline demo

Technical Implementation

  • CopyButton component (web/src/components/CopyButton.tsx) — reusable with clipboard/success states
  • MessageBubble integration — copy buttons appear on hover with smooth transitions
  • Composer mobile logic — user agent detection for Enter key behavior differentiation
  • Always-visible headers — code blocks now consistently show language + copy UI

Testing

  • ✅ Copy buttons work on both messages and code blocks
  • ✅ Mobile Enter behavior creates newlines as expected
  • ✅ Desktop behavior unchanged
  • ✅ Accessibility: proper button labels and keyboard navigation
  • ✅ Cross-browser compatibility with clipboard API fallback

Commits

Two clean commits from fresh upstream main:

  1. Copy buttons implementation — new component + MessageBubble integration
  2. Mobile Enter behavior — Composer keyboard handling logic

Code reviewed by: AI (Claude Code) + human testing
Visual testing: Complete on both desktop and mobile simulation

croll83 added 2 commits April 7, 2026 21:57
- Add CopyButton component with clipboard icon and success feedback
- Show copy button on hover for entire AI messages (top-right)
- Show copy button in code block headers for copying code only
- Code blocks now always display header with language and copy button
- Add mobile device detection via user agent
- On mobile: Enter creates newline, send only via button
- On desktop: unchanged behavior (Enter sends, Shift+Enter newline)
- Fixes mobile keyboard limitations where Shift+Enter unavailable
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 7, 2026

@croll83 is attempting to deploy a commit to the The Vibe Company Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@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.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="web/src/components/CopyButton.tsx">

<violation number="1" location="web/src/components/CopyButton.tsx:24">
P2: Fallback copy marks success without checking whether `document.execCommand('copy')` actually succeeded, so the UI can show a success checkmark even when nothing was copied.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread web/src/components/CopyButton.tsx Outdated
document.execCommand('copy') returns false when the copy fails, but the
fallback path was ignoring the return value and always calling setCopied(true),
causing a false success checkmark to be shown even when nothing was copied.

Fix: capture the return value and return early if the copy did not succeed.
@croll83
Copy link
Copy Markdown
Author

croll83 commented Apr 9, 2026

hey @StanGirard tagging here to bring a bit of visibility on this PR...

it's a very simple small change, but improve usability on mobile by 100x.

Please would love to have it live (if i run my fork i can't live update the new versions)

croll83 added a commit to croll83/companion that referenced this pull request Apr 28, 2026
Two fixes for PR The-Vibe-Company#647 that didn't fully land:

1. Code-block copy button was invisible on mobile because it relied on
   hover state (opacity-70 hover:opacity-100) and also used `text-gray-500
   hover:bg-gray-100` which had poor contrast on the code-block background.
   Switch to theme-aware colors (text-cc-muted, hover:bg-cc-fg/[0.06]) and
   force opacity-100 on mobile, fading to 0.7 only on >=sm breakpoints.

2. Add a message-level copy button under each completed assistant turn.
   PR The-Vibe-Company#647's description claimed this was implemented but only the code-
   block button shipped. The new MessageActions row is always visible on
   mobile (60% opacity → 100% on hover at desktop) and copies the
   concatenated text from the message's text blocks.

Also unrelated test fixes from PR The-Vibe-Company#651: existing dropdown tests used /Opus/
which now matches both Opus 4.7 and Opus 4.6, and the default-model
assertion in HomePage was still claude-opus-4-6 instead of the new -4-7.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant