Skip to content

fix: add copy to ai assistant prompt - #411

Merged
bdjulbic merged 4 commits into
mainfrom
fix/rollback-copy-button
Mar 4, 2026
Merged

bdjulbic merged 4 commits into
mainfrom
fix/rollback-copy-button

Conversation

@bdjulbic

@bdjulbic bdjulbic commented Mar 3, 2026 •

Copy link
Copy Markdown
Collaborator

Add back copy button to the user prompt when user hover mouse over the prompt

Screenshot 2026-03-03 at 12 46 09

Summary by CodeRabbit

  • New Features

    • Added a copy button for analysis questions so users can quickly copy and reuse prompts.
  • Style

    • Button now appears on hover or focus for clearer discoverability and improved accessibility (with a descriptive tooltip).

@coderabbitai

coderabbitai Bot commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@bdjulbic has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 727ca088-2994-4dbe-871d-f474eefdd71a

📥 Commits

Reviewing files that changed from the base of the PR and between d4294a0 and 10934cd.

📒 Files selected for processing (1)
  • packages/ai-core/src/components/AnalysisResult.tsx
📝 Walkthrough

Walkthrough

Added a hover/focus-revealed CopyButton next to the prompt text in AnalysisResult; the button copies analysisResult.prompt, uses tooltipLabel "Copy question", and is sized h-6 w-6. No other behavioral or public API changes.

Changes

Cohort / File(s) Summary
Prompt Copy Button
packages/ai-core/src/components/AnalysisResult.tsx
Added an opacity-controlled CopyButton adjacent to the prompt that copies analysisResult.prompt with tooltipLabel "Copy question". Button is revealed on group hover/focus and sized h-6 w-6; prompt container positioned to accommodate the button.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • igorDykhta
  • ilyabo

Poem

🐰 I found a tiny shiny key,
A CopyButton hung by a tree.
Hover, focus — a gentle light,
Hop! The prompt takes flight tonight. ✨

🚥 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: add copy to ai assistant prompt' accurately describes the main change: adding a copy button to the AI assistant prompt that appears on hover.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/rollback-copy-button

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/AnalysisResult.tsx`:
- Around line 104-114: The floating CopyButton is absolutely positioned over
long prompt text and remains clickable when hidden; update the prompt container
(the div containing analysisResult.prompt — currently class "flex-1") to reserve
horizontal space for the control (e.g., add a right padding like pr-8/pr-10) and
change the CopyButton wrapper (the absolute div) to disable pointer events when
hidden and enable them when visible by adding pointer-events-none plus the
focus/hover variants (e.g., group-focus-within/prompt:pointer-events-auto and
group-hover/prompt:pointer-events-auto) so the hidden hit-area is inert and the
control only receives pointer events when visible.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60a639e and 8b34e73.

📒 Files selected for processing (1)
  • packages/ai-core/src/components/AnalysisResult.tsx

Comment on lines +104 to +114
<div className="group/prompt bg-muted relative flex w-full items-center gap-2 rounded-md border p-2 text-sm">
<SquareTerminalIcon className="h-4 w-4" />
{/** render prompt */}
<div className="flex-1">{analysisResult.prompt}</div>
<div className="absolute right-2 opacity-0 transition-opacity group-focus-within/prompt:opacity-100 group-hover/prompt:opacity-100">
<CopyButton
text={analysisResult.prompt}
tooltipLabel="Copy question"
className="h-6 w-6"
/>
</div>

@coderabbitai coderabbitai Bot Mar 3, 2026 •

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 | 🟡 Minor

Reserve space for the floating copy control and disable hidden hit-area.

At Line 104 and Line 108, the absolute copy button can overlap long prompt text, and opacity-only hiding keeps an invisible clickable zone active.

Suggested patch
-        <div className="group/prompt bg-muted relative flex w-full items-center gap-2 rounded-md border p-2 text-sm">
+        <div className="group/prompt bg-muted relative flex w-full items-center gap-2 rounded-md border p-2 pr-10 text-sm">
...
-          <div className="absolute right-2 opacity-0 transition-opacity group-focus-within/prompt:opacity-100 group-hover/prompt:opacity-100">
+          <div className="pointer-events-none absolute right-2 opacity-0 transition-opacity group-focus-within/prompt:pointer-events-auto group-focus-within/prompt:opacity-100 group-hover/prompt:pointer-events-auto group-hover/prompt: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
<div className="group/prompt bg-muted relative flex w-full items-center gap-2 rounded-md border p-2 text-sm">
<SquareTerminalIcon className="h-4 w-4" />
{/** render prompt */}
<div className="flex-1">{analysisResult.prompt}</div>
<div className="absolute right-2 opacity-0 transition-opacity group-focus-within/prompt:opacity-100 group-hover/prompt:opacity-100">
<CopyButton
text={analysisResult.prompt}
tooltipLabel="Copy question"
className="h-6 w-6"
/>
</div>
<div className="group/prompt bg-muted relative flex w-full items-center gap-2 rounded-md border p-2 pr-10 text-sm">
<SquareTerminalIcon className="h-4 w-4" />
{/** render prompt */}
<div className="flex-1">{analysisResult.prompt}</div>
<div className="pointer-events-none absolute right-2 opacity-0 transition-opacity group-focus-within/prompt:pointer-events-auto group-focus-within/prompt:opacity-100 group-hover/prompt:pointer-events-auto group-hover/prompt:opacity-100">
<CopyButton
text={analysisResult.prompt}
tooltipLabel="Copy question"
className="h-6 w-6"
/>
</div>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ai-core/src/components/AnalysisResult.tsx` around lines 104 - 114,
The floating CopyButton is absolutely positioned over long prompt text and
remains clickable when hidden; update the prompt container (the div containing
analysisResult.prompt — currently class "flex-1") to reserve horizontal space
for the control (e.g., add a right padding like pr-8/pr-10) and change the
CopyButton wrapper (the absolute div) to disable pointer events when hidden and
enable them when visible by adding pointer-events-none plus the focus/hover
variants (e.g., group-focus-within/prompt:pointer-events-auto and
group-hover/prompt:pointer-events-auto) so the hidden hit-area is inert and the
control only receives pointer events when visible.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree, it'd be good to avoid absolute here

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.

@ilyabo Got it! Here's a cleaner approach using flexbox instead of absolute positioning:

<div className="group/prompt bg-muted flex w-full items-center gap-2 rounded-md border p-2 text-sm">
  <SquareTerminalIcon className="h-4 w-4" />
  {/** render prompt */}
  <div className="flex-1">{analysisResult.prompt}</div>
  <div className="opacity-0 transition-opacity group-focus-within/prompt:opacity-100 group-hover/prompt:opacity-100">
    <CopyButton
      text={analysisResult.prompt}
      tooltipLabel="Copy question"
      className="h-6 w-6"
    />
  </div>
</div>

Changes:

  • Remove relative from the parent container (no longer needed)
  • Remove absolute right-2 from the button wrapper
  • The button stays in the flex flow, so space is automatically reserved
  • No text overlap issues
  • The opacity transitions still work as expected

This way the button is always part of the layout and naturally positioned at the end, avoiding any potential overlap with long prompts.

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.

Fixed

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.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

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

Adds a hover-revealed copy affordance to the “prompt” header within the AI analysis result UI, aligning it with existing “copy” interactions elsewhere in the app.

Changes:

  • Added a CopyButton next to analysisResult.prompt that appears on hover/focus.
  • Uses Tailwind group-*/ hover/focus variants to control visibility.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 104 to +114
<div className="group/prompt bg-muted flex w-full items-center gap-2 rounded-md border p-2 text-sm">
<SquareTerminalIcon className="h-4 w-4" />
{/** render prompt */}
<div className="flex-1">{analysisResult.prompt}</div>
<div className="opacity-0 transition-opacity group-focus-within/prompt:opacity-100 group-hover/prompt:opacity-100">
<CopyButton
text={analysisResult.prompt}
tooltipLabel="Copy question"
className="h-6 w-6"
/>
</div>

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

The copy button container is part of the flex layout (not absolutely positioned), so it reserves horizontal space even when hidden (opacity-0). This can cause the prompt text to wrap earlier / truncate sooner and makes the layout inconsistent with other hover-copy UIs (e.g. QueryToolResult uses a relative container with an absolute top-* right-* copy button). Consider making the prompt row relative, positioning the CopyButton wrapper absolute in the top-right, and adding right padding on the prompt text so the button doesn’t overlap it.

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.

we agreed not to use absolute positioning for this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Evidently, the two agents don't talk to each other (yet) :)

Comment thread packages/ai-core/src/components/AnalysisResult.tsx Outdated
Comment thread packages/ai-core/src/components/AnalysisResult.tsx Outdated
@bdjulbic
bdjulbic requested a review from ilyabo March 4, 2026 10:33
@bdjulbic
bdjulbic merged commit 2cc975a into main Mar 4, 2026
3 checks passed
@bdjulbic
bdjulbic deleted the fix/rollback-copy-button branch March 4, 2026 17:43
dmitriy-kostianetskiy pushed a commit that referenced this pull request Mar 5, 2026
bdjulbic added a commit that referenced this pull request Mar 16, 2026
Co-authored-by: Copilot <[email protected]>
Signed-off-by: bdjulbic <[email protected]>
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