| 1 | import { BarsArrowDownIcon, TrashIcon } from "@heroicons/react/24/outline"; |
| 2 | import { ChatHistoryItem } from "core"; |
| 3 | import { renderChatMessage } from "core/util/messageContent"; |
| 4 | import FeedbackButtons from "../FeedbackButtons"; |
| 5 | import { CopyIconButton } from "../gui/CopyIconButton"; |
| 6 | import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; |
| 7 | |
| 8 | export interface ResponseActionsProps { |
| 9 | isTruncated: boolean; |
| 10 | onContinueGeneration: () => void; |
| 11 | index: number; |
| 12 | onDelete: () => void; |
| 13 | item: ChatHistoryItem; |
| 14 | } |
| 15 | |
| 16 | export default function ResponseActions({ |
| 17 | onContinueGeneration, |
| 18 | index, |
| 19 | item, |
| 20 | isTruncated, |
| 21 | onDelete, |
| 22 | }: ResponseActionsProps) { |
| 23 | return ( |
| 24 | <div className="mx-2 flex cursor-default items-center justify-end space-x-1 bg-transparent pb-0 text-xs text-gray-400"> |
| 25 | {isTruncated && ( |
| 26 | <HeaderButtonWithToolTip |
| 27 | tabIndex={-1} |
| 28 | text="Continue generation" |
| 29 | onClick={onContinueGeneration} |
| 30 | > |
| 31 | <BarsArrowDownIcon className="h-3.5 w-3.5 text-gray-500" /> |
| 32 | </HeaderButtonWithToolTip> |
| 33 | )} |
| 34 | |
| 35 | <HeaderButtonWithToolTip |
| 36 | testId={`delete-button-${index}`} |
| 37 | text="Delete" |
| 38 | tabIndex={-1} |
| 39 | onClick={onDelete} |
| 40 | > |
| 41 | <TrashIcon className="h-3.5 w-3.5 text-gray-500" /> |
| 42 | </HeaderButtonWithToolTip> |
| 43 | |
| 44 | <CopyIconButton |
| 45 | tabIndex={-1} |
| 46 | text={renderChatMessage(item.message)} |
| 47 | clipboardIconClassName="h-3.5 w-3.5 text-gray-500" |
| 48 | checkIconClassName="h-3.5 w-3.5 text-green-400" |
| 49 | /> |
| 50 | |
| 51 | <FeedbackButtons item={item} /> |
| 52 | </div> |
| 53 | ); |
| 54 | } |