import { useCallback } from 'react' import { Button } from '@janhq/joi' import { useAtomValue, useSetAtom } from 'jotai' import { showMigrationModalAtom } from '@/containers/Providers/ModalMigrations' import { toaster } from '@/containers/Toast' import useThreads from '@/hooks/useThreads' import { threadsAtom } from '@/helpers/atoms/Thread.atom' const DataMigration: React.FC = () => { const setShowMigrationModal = useSetAtom(showMigrationModalAtom) const threads = useAtomValue(threadsAtom) const { deleteThread } = useThreads() const onStartMigrationClick = useCallback(() => { setShowMigrationModal(true) }, [setShowMigrationModal]) const onCleanUpDataClick = useCallback(async () => { for (const thread of threads) { try { await deleteThread(thread.id) } catch (err) { console.error('Error deleting thread', err) toaster({ title: 'Delete thread failed', description: `Failed to delete thread ${thread.title}`, type: 'error', }) } } toaster({ title: 'Delete thread successfully!', type: 'success', }) }, [threads, deleteThread]) return ( <>
Data Migration from Older Versions

From version 0.6, Jan uses Cortex as its core engine. Without migration, your previous threads and models may be inaccessible. Migrate your data to maintain access in the latest version.

Delete All Threads

Multiple migrations may create duplicate threads. Use this button to clean up if needed.

) } export default DataMigration