Skip to content

fix: move copy button - #390

Merged
bdjulbic merged 6 commits into
mainfrom
fix/move-copy-button
Feb 25, 2026
Merged

bdjulbic merged 6 commits into
mainfrom
fix/move-copy-button

Conversation

@bdjulbic

@bdjulbic bdjulbic commented Feb 25, 2026 •

Copy link
Copy Markdown
Collaborator

Moved the copy button in the ai assistant
Screenshot 2026-02-25 at 19 13 29

Summary by CodeRabbit

  • UI Changes
    • Removed per-answer copy control to reduce clutter.
    • Added a single "Copy entire response" button at the bottom of analysis results when text is present for easier copying.
    • Improved spacing/visual layout of analysis result blocks for clearer readability.

@coderabbitai

coderabbitai Bot commented Feb 25, 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 6 minutes and 20 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.

📥 Commits

Reviewing files that changed from the base of the PR and between cbd3a15 and aa91c47.

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

Walkthrough

The PR adjusts copy-to-clipboard UI: it removes the header-level CopyButton from AnalysisAnswer and adds a footer-level CopyButton in AnalysisResult that copies the concatenated textual parts of a response.

Changes

Cohort / File(s) Summary
Copy Button Removal
packages/ai-core/src/components/AnalysisAnswer.tsx
Removed headerActions declaration and stopped passing headerActions to MessageContainer, eliminating the header CopyButton.
Copy Button Addition
packages/ai-core/src/components/AnalysisResult.tsx
Imported isTextPart/isReasoningPart, aggregated all text parts into allTextContent, added hasTextContent check and a footer CopyButton ("Copy entire response"), and adjusted container spacing (mb-4).
Manifest
package.json
No functional changes to manifest; referenced in diff metadata (lines changed count).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • igorDykhta

Poem

🐇 I hopped through code both near and far,
Took the header button off its star,
Gathered every text bit in a row,
Puffed a footer button — ready to go! ✨

🚥 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' directly describes the main change—relocating the copy button from AnalysisAnswer to AnalysisResult component—which aligns with the changeset and PR objectives.
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/move-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.

@bdjulbic
bdjulbic requested a review from Copilot February 25, 2026 18:11
@bdjulbic bdjulbic changed the title Fix/move copy button fix: move copy button Feb 25, 2026

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

🧹 Nitpick comments (1)
packages/ai-core/src/components/AnalysisResult.tsx (1)

60-70: Avoid any and memoize text aggregation to improve type safety and performance.

Line 65's as any drops type guarantees. Lines 60–70 recompute text aggregation on every render despite being expensive (multiple iterations over arrays). Both 'text' and 'reasoning' message parts have a guaranteed .text: string property per the schema, so a type-safe useMemo wrapper is straightforward.

♻️ Proposed refactor
-import {useEffect, useRef, useState} from 'react';
+import {useEffect, useMemo, useRef, useState} from 'react';

-  const allTextContent = uiMessageParts
-    .filter((part) => part.type === 'text' || part.type === 'reasoning')
-    .map((part) => {
-      if (part.type === 'text' || part.type === 'reasoning') {
-        return (part as any).text;
-      }
-      return '';
-    })
-    .join('\n\n');
+  const allTextContent = useMemo(
+    () =>
+      uiMessageParts
+        .flatMap((part) => {
+          if (
+            (part.type === 'text' || part.type === 'reasoning') &&
+            'text' in part &&
+            typeof part.text === 'string'
+          ) {
+            return [part.text];
+          }
+          return [];
+        })
+        .join('\n\n'),
+    [uiMessageParts],
+  );
🤖 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 60 - 70,
Replace the untyped cast and repeated computation by memoizing the text
aggregation with React's useMemo and using the proper part type narrowing:
compute allTextContent via useMemo(() => uiMessageParts.filter(p => p.type ===
'text' || p.type === 'reasoning').map(p => p.text).join('\n\n'),
[uiMessageParts]) (no "as any"), then derive hasTextContent from that memoized
value; update references to allTextContent and hasTextContent in
AnalysisResult.tsx accordingly so the code preserves type safety and avoids
recomputing on every render.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/ai-core/src/components/AnalysisResult.tsx`:
- Around line 60-70: Replace the untyped cast and repeated computation by
memoizing the text aggregation with React's useMemo and using the proper part
type narrowing: compute allTextContent via useMemo(() => uiMessageParts.filter(p
=> p.type === 'text' || p.type === 'reasoning').map(p => p.text).join('\n\n'),
[uiMessageParts]) (no "as any"), then derive hasTextContent from that memoized
value; update references to allTextContent and hasTextContent in
AnalysisResult.tsx accordingly so the code preserves type safety and avoids
recomputing on every render.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c57d70 and e6144cc.

📒 Files selected for processing (2)
  • packages/ai-core/src/components/AnalysisAnswer.tsx
  • packages/ai-core/src/components/AnalysisResult.tsx
💤 Files with no reviewable changes (1)
  • packages/ai-core/src/components/AnalysisAnswer.tsx

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 refactors the copy button functionality for AI analysis results by moving it from individual answer components to a single copy button at the analysis result level. The change consolidates the copy functionality to provide a single "Copy entire response" button that collects all text and reasoning content from message parts, rather than having individual copy buttons for each answer segment.

Changes:

  • Moved copy button from AnalysisAnswer component to AnalysisResult component
  • Added logic to collect all text and reasoning content from message parts for a unified copy operation
  • Removed headerActions prop usage from MessageContainer in AnalysisAnswer
  • Added bottom margin (mb-4) to AnalysisResult container for improved spacing

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/ai-core/src/components/AnalysisResult.tsx Added text content collection logic and placed copy button at the end of the analysis result, added mb-4 margin to container
packages/ai-core/src/components/AnalysisAnswer.tsx Removed headerActions variable and prop that previously contained the copy button

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

Comment thread packages/ai-core/src/components/AnalysisResult.tsx Outdated
@bdjulbic
bdjulbic merged commit a7ba4f2 into main Feb 25, 2026
3 checks passed
@bdjulbic
bdjulbic deleted the fix/move-copy-button branch February 25, 2026 18:40
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