Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 30, 2025

Summary:

  • Adds Lucide Copy icon button to "or via CLI" section on homepage
  • Copies installation command to clipboard on click
  • Shows Check icon for 1s to confirm success
  • Adds timeout cleanup on unmount and aria-live="polite" for accessibility

Implementation:

  • apps/web-roo-code/src/components/homepage/install-section.tsx
    • useState for "copied" state
    • handleCopy() with navigator.clipboard and textarea fallback
    • Timeout stored in ref and cleared on unmount
    • Replaces hardcoded command usage with installCmd constant

Testing:

  • Lint, type-check, and full test suite pass locally

Acceptance criteria:

  • Clicking the Copy icon copies "code --install-extension RooVeterinaryInc.roo-cline" to clipboard
  • Icon switches to Check for ~1s then reverts
  • Works without errors in browsers where Clipboard API is unavailable (fallback)

Important

Adds copy-to-clipboard feature to CLI install section with success icon in install-section.tsx.

  • Feature:
    • Adds copy-to-clipboard functionality to CLI install section in install-section.tsx.
    • Displays a Check icon for 1s after copying to confirm success.
    • Uses useState for "copied" state and useEffect for timeout cleanup.
  • Implementation:
    • handleCopy() uses navigator.clipboard and a textarea fallback for copying.
    • Timeout stored in timeoutRef and cleared on unmount.
    • Replaces hardcoded command with installCmd constant.
  • Testing:
    • Lint, type-check, and full test suite pass locally.
  • Acceptance Criteria:
    • Clicking Copy icon copies command to clipboard and shows Check icon.
    • Works without errors in browsers without Clipboard API support.

This description was created by Ellipsis for f8d8120. You can customize this summary. It will automatically update as commits are pushed.

@roomote roomote bot requested review from cte, jr and mrubens as code owners September 30, 2025 10:01
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Sep 30, 2025
<div className="text-sm font-medium text-foreground">or via CLI</div>
<div className="flex items-center justify-between">
<div className="text-sm font-medium text-foreground">or via CLI</div>
<button
Copy link
Contributor

Choose a reason for hiding this comment

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

UI labels (aria-label, title, and sr-only text) are hardcoded in English. Consider using the project’s translation function (e.g. t('...')) to support internationalization.

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

const handleCopy = async () => {
try {
await navigator.clipboard.writeText(installCmd)
setCopied(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

In handleCopy, the logic for setting the copied state and timeout is duplicated in both try and fallback blocks. Also, consider clearing any existing timeout before setting a new one to avoid potential overlaps on rapid clicks.

@github-actions
Copy link
Contributor

🚀 Preview deployed!

Your changes have been deployed to Vercel:

Preview URL: https://roo-code-website-jh2lo7mnn-roo-code.vercel.app

This preview will be updated automatically when you push new commits to this PR.

@brunobergher
Copy link
Collaborator

@roomote-agent apply the PR feedback, and, additionally:

  • Move the copy icon to be inside the box where the command is, but to the right (basically same position, just below)
  • Make the "or via CLI" text centered again.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 30, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Sep 30, 2025

Acknowledged. I will apply the feedback:

  • Move the copy icon inside the command box, aligned to the right
  • Center the "or via CLI" text again

I will push updates to the feat/homepage-cli-copy-cta branch shortly.

Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Self-review protocol engaged: I argued with myself, lost, and the linter took notes.

try {
await navigator.clipboard.writeText(installCmd)
setCopied(true)
const id = setTimeout(() => setCopied(false), 1000)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P2] Clear any existing timeout before scheduling a new one to avoid overlapping timers and stale state on rapid clicks.

} catch (_e) {
// Fallback for environments without Clipboard API support
const textarea = document.createElement("textarea")
textarea.value = installCmd
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P3] In fallback, set textarea to readonly and position it offscreen (fixed, left:-9999px) before appendChild to avoid layout shift and improve reliability.

}
}, [])

const handleCopy = async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P3] Optional: feature-detect isSecureContext and navigator.clipboard?.writeText before calling Clipboard API to avoid relying on exceptions for control flow.


export function InstallSection({ downloads }: InstallSectionProps) {
const [copied, setCopied] = useState(false)
const installCmd = "code --install-extension RooVeterinaryInc.roo-cline"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P3] Optional: extract installCmd to a shared constant (e.g., apps/web-roo-code/src/lib/constants.ts) to keep it DRY across the site.

<Copy className="h-4 w-4" />
)}
<span className="sr-only" aria-live="polite" role="status">
{copied ? "Copied" : "Copy"}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P3] Optional a11y: use a more descriptive SR announcement like 'Copied to clipboard' rather than 'Copied'.

@roomote
Copy link
Contributor Author

roomote bot commented Sep 30, 2025

Update applied per feedback:

  • Moved the copy icon into the command box, aligned to the right (positioned absolutely in the code container with padding to avoid overlap)
  • Centered the "or via CLI" text in the header above the command box

Local checks: lint, type-check, and tests pass. CI checks are green. Please take another look.

@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Oct 1, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants