Repository navigation
fix: Improve copy message placement in AI assistant - #392
Conversation
📝 WalkthroughWalkthroughAggregates text and reasoning parts from a message and conditionally renders a CopyButton that copies the combined text; adjusts main container gap from 4 to 2. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR restores the copy button functionality to the AI assistant's analysis results and reduces the spacing between message elements for a more compact UI. The copy button allows users to easily copy all text and reasoning content from an analysis response.
Changes:
- Added copy button to AnalysisResult component that collects all text and reasoning parts
- Reduced gap spacing from
gap-4togap-2for tighter message layout
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
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`:
- Line 2: Remove the reintroduced copy-button behavior: delete the new import of
CopyButton and remove any JSX and handlers that render or wire the copy button
inside the AnalysisResult component (search for CopyButton usage and any
functions/props like onCopy, handleCopy, or copy-related state within
AnalysisResult) so the component returns to the original UI without copy
functionality; ensure related props or state introduced only for copying are
also removed to avoid unused variables.
| @@ -1,11 +1,13 @@ | |||
| import {AnalysisResultSchema} from '@sqlrooms/ai-config'; | |||
| import {CopyButton} from '@sqlrooms/ui'; | |||
There was a problem hiding this comment.
Rollback objective is not met: copy button was reintroduced.
This change adds copy-button behavior instead of rolling it back (Line 132 onward), which conflicts with the PR goal.
Suggested rollback diff
import {AnalysisResultSchema} from '@sqlrooms/ai-config';
-import {CopyButton} from '@sqlrooms/ui';
import type {UIMessage} from 'ai';
@@
-import {isTextPart, isReasoningPart} from '../utils';
@@
- // Collect all text content from message parts for copy button
- const allTextContent = uiMessageParts
- .filter((part) => isTextPart(part) || isReasoningPart(part))
- .map((part) => part.text)
- .join('\n\n');
- const hasTextContent = allTextContent.trim().length > 0;
@@
- {hasTextContent && (
- <div className="flex justify-start">
- <CopyButton
- text={allTextContent}
- tooltipLabel="Copy entire response"
- className="border-muted border"
- />
- </div>
- )}Also applies to: 10-10, 61-67, 132-140
🤖 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` at line 2, Remove the
reintroduced copy-button behavior: delete the new import of CopyButton and
remove any JSX and handlers that render or wire the copy button inside the
AnalysisResult component (search for CopyButton usage and any functions/props
like onCopy, handleCopy, or copy-related state within AnalysisResult) so the
component returns to the original UI without copy functionality; ensure related
props or state introduced only for copying are also removed to avoid unused
variables.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Ilya Boyandin <[email protected]>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/ai-core/src/components/AnalysisResult.tsx (1)
2-2:⚠️ Potential issue | 🟠 MajorRollback objective is still not met: copy-button flow is reintroduced.
Line 2, Line 10, Line 61-67, and Line 133-141 collectively add back copy behavior (
CopyButtonimport, content aggregation, and render path), which conflicts with the PR goal to roll back the copy button.Suggested rollback diff
import {AnalysisResultSchema} from '@sqlrooms/ai-config'; -import {CopyButton} from '@sqlrooms/ui'; import type {UIMessage} from 'ai'; @@ -import {isTextPart, isReasoningPart} from '../utils'; @@ - // Collect all text content from message parts for copy button - const allTextContent = uiMessageParts - .flatMap((part) => - isTextPart(part) || isReasoningPart(part) ? [part.text] : [], - ) - .join('\n\n'); - const hasTextContent = allTextContent.trim().length > 0; @@ - {hasTextContent && ( - <div className="flex justify-start"> - <CopyButton - text={allTextContent} - tooltipLabel="Copy message" - className="border-muted border" - /> - </div> - )}Also applies to: 10-10, 61-67, 133-141
🤖 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` at line 2, The rollback reintroduces copy behavior by importing and using CopyButton; remove the CopyButton import and all code paths that aggregate content for copying and the JSX that renders CopyButton in AnalysisResult.tsx (remove the import line for CopyButton and delete the variables/logic that build the copy content and the render block that returns <CopyButton .../>), ensuring the component no longer references CopyButton or any copy-related functions/variables.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@packages/ai-core/src/components/AnalysisResult.tsx`:
- Line 2: The rollback reintroduces copy behavior by importing and using
CopyButton; remove the CopyButton import and all code paths that aggregate
content for copying and the JSX that renders CopyButton in AnalysisResult.tsx
(remove the import line for CopyButton and delete the variables/logic that build
the copy content and the render block that returns <CopyButton .../>), ensuring
the component no longer references CopyButton or any copy-related
functions/variables.
Rollback copy button in the ai assistant
and I would suggest we decrease the gap of the messages to 2 instead of 4
Here are the screenshots showing gap-2


Summary by CodeRabbit