All files / src/components/Chatbot ResetChatBotButton.tsx

100% Statements 21/21
100% Branches 4/4
100% Functions 2/2
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 351x           1x     1x   1x 3x 3x 3x     3x 3x 3x   3x 3x 3x 3x 3x 1x 1x 1x   3x 3x   3x  
import {
  useCopilotChat,
  useCopilotMessagesContext,
} from '@copilotkit/react-core';
 
// Icons
import { RetryIcon } from '../icons/reacts';
 
// Components
import { Button } from './Button';
 
export const ResetChatBotButton = ({
  btnLabel = 'Reset ChatBot',
  className = '',
}: {
  btnLabel?: string;
  className?: string;
}) => {
  const { reset } = useCopilotChat();
  const { setMessages } = useCopilotMessagesContext();
 
  return (
    <Button
      className={`w-full border border-gray-400 text-gray-400 text-3xs hover:bg-gray-200/80 bg-transparent mt-3 ${className ? className : ''}`}
      type="button"
      onClick={() => {
        reset();
        setMessages([]);
      }}
    >
      {btnLabel} <RetryIcon className="size-3" />
    </Button>
  );
};