import { zodResolver } from '@hookform/resolvers/zod' import { Check, Copy, Pencil, Split, ThumbsDown, ThumbsUp, Trash2 } from 'lucide-react' import { useEffect, useState, type PropsWithChildren } from 'react' import { useForm } from 'react-hook-form' import { Button, cn, Form, FormControl, FormField, Popover, PopoverContent, PopoverTrigger, TextArea, } from 'ui' import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import * as z from 'zod' import { ButtonTooltip } from '../ButtonTooltip' export function MessageActions({ children, alwaysShow = false, }: PropsWithChildren<{ alwaysShow?: boolean }>) { return (
{children}
) } function MessageActionsEdit({ onClick, tooltip }: { onClick: () => void; tooltip: string }) { return ( } onClick={onClick} className="text-foreground-light hover:text-foreground p-1 rounded-sm" aria-label={tooltip} tooltip={{ content: { side: 'bottom', text: tooltip, }, }} /> ) } MessageActions.Edit = MessageActionsEdit function MessageActionsDelete({ onClick }: { onClick: () => void }) { return ( } tooltip={{ content: { side: 'bottom', text: 'Delete message' } }} onClick={onClick} className="text-foreground-light hover:text-foreground p-1 rounded-sm" title="Delete message" aria-label="Delete message" /> ) } MessageActions.Delete = MessageActionsDelete function MessageActionsBranch({ onClick }: { onClick: () => void }) { return ( } onClick={onClick} className="text-foreground-light hover:text-foreground p-1 rounded-sm" title="Branch in new chat" aria-label="Branch in new chat" tooltip={{ content: { side: 'bottom', text: 'Branch in new chat' } }} /> ) } MessageActions.Branch = MessageActionsBranch function MessageActionsCopy({ onClick }: { onClick: (onSuccess: () => void) => void }) { const [copied, setCopied] = useState(false) useEffect(() => { if (copied) setTimeout(() => setCopied(false), 1000) }, [copied]) return ( : } onClick={() => onClick(() => setCopied(true))} className="text-foreground-light hover:text-foreground p-1 rounded-sm" title="Copy response" aria-label="Copy response" tooltip={{ content: { side: 'bottom', text: 'Copy response' } }} /> ) } MessageActions.Copy = MessageActionsCopy function MessageActionsThumbsUp({ onClick, isActive, disabled, }: { onClick: () => void isActive?: boolean disabled?: boolean }) { return ( {form.formState.isSubmitSuccessful ? (

We appreciate your feedback!

) : (
(