import { ErrorCode, MessageStatus, ThreadMessage } from '@janhq/core' import { Button } from '@janhq/uikit' import { useAtomValue, useSetAtom } from 'jotai' import { RefreshCcw } from 'lucide-react' import ModalTroubleShooting, { modalTroubleShootingAtom, } from '@/containers/ModalTroubleShoot' import { MainViewState } from '@/constants/screens' import { loadModelErrorAtom } from '@/hooks/useActiveModel' import useSendChatMessage from '@/hooks/useSendChatMessage' import { mainViewStateAtom } from '@/helpers/atoms/App.atom' import { getCurrentChatMessagesAtom } from '@/helpers/atoms/ChatMessage.atom' const ErrorMessage = ({ message }: { message: ThreadMessage }) => { const messages = useAtomValue(getCurrentChatMessagesAtom) const { resendChatMessage } = useSendChatMessage() const setModalTroubleShooting = useSetAtom(modalTroubleShootingAtom) const loadModelError = useAtomValue(loadModelErrorAtom) const setMainState = useSetAtom(mainViewStateAtom) const PORT_NOT_AVAILABLE = 'PORT_NOT_AVAILABLE' const regenerateMessage = async () => { const lastMessageIndex = messages.length - 1 const message = messages[lastMessageIndex] resendChatMessage(message) } const getErrorTitle = () => { switch (message.error_code) { case ErrorCode.Unknown: return 'Apologies, something’s amiss!' case ErrorCode.InvalidApiKey: return ( Invalid API key. Please check your API key from{' '} {' '} and try again. ) default: return message.content[0]?.text?.value } } return (
Port 3928 is currently unavailable. Check for conflicting apps, or access setModalTroubleShooting(true)} > troubleshooting assistance for further support.
Model is currently unavailable. Please switch to a different model or install the{' '} {' '} to continue using it.
Jan’s in beta. Access setModalTroubleShooting(true)} > troubleshooting assistance now.