refactor: replace message.content with message.parts (#868)

This commit is contained in:
Jeremy 2025-03-16 18:42:29 -07:00 committed by GitHub
parent 553a3d825a
commit 47a630fd53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 1311 additions and 311 deletions

View file

@ -32,8 +32,6 @@ export function PureMessageActions({
if (isLoading) return null;
if (message.role === 'user') return null;
if (message.toolInvocations && message.toolInvocations.length > 0)
return null;
return (
<TooltipProvider delayDuration={0}>
@ -44,7 +42,18 @@ export function PureMessageActions({
className="py-1 px-2 h-fit text-muted-foreground"
variant="outline"
onClick={async () => {
await copyToClipboard(message.content as string);
const textFromParts = message.parts
?.filter((part) => part.type === 'text')
.map((part) => part.text)
.join('\n')
.trim();
if (!textFromParts) {
toast.error("There's no text to copy!");
return;
}
await copyToClipboard(textFromParts);
toast.success('Copied to clipboard!');
}}
>