* fix: empty model page not shown when delete all threads and models * fix: blank state when delete jan data folder content (#3345) * test template name --------- Co-authored-by: Van Pham <64197333+Van-QA@users.noreply.github.com>
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import { Fragment, useMemo } from 'react'
|
|
|
|
import {
|
|
EngineStatus,
|
|
LlmEngine,
|
|
RemoteEngine,
|
|
RemoteEngines,
|
|
} from '@janhq/core'
|
|
import { useAtomValue } from 'jotai'
|
|
|
|
import useEngineQuery from '@/hooks/useEngineQuery'
|
|
|
|
import ThreadLeftPanel from '@/screens/Thread/ThreadLeftPanel'
|
|
|
|
import ThreadCenterPanel from './ThreadCenterPanel'
|
|
import EmptyModel from './ThreadCenterPanel/ChatBody/EmptyModel'
|
|
import ThreadRightPanel from './ThreadRightPanel'
|
|
|
|
import { waitingForCortexAtom } from '@/helpers/atoms/App.atom'
|
|
import { downloadedModelsAtom } from '@/helpers/atoms/Model.atom'
|
|
|
|
const ThreadScreen = () => {
|
|
const downloadedModels = useAtomValue(downloadedModelsAtom)
|
|
const waitingForCortex = useAtomValue(waitingForCortexAtom)
|
|
const { data: engineData } = useEngineQuery()
|
|
|
|
const isAnyRemoteModelConfigured = useMemo(() => {
|
|
if (!engineData) return false
|
|
|
|
let result = false
|
|
for (const engine of engineData) {
|
|
if (RemoteEngines.includes(engine.name as RemoteEngine)) {
|
|
if (engine.status === EngineStatus.Ready) {
|
|
result = true
|
|
}
|
|
}
|
|
}
|
|
return result
|
|
}, [engineData])
|
|
|
|
const shouldShowEmptyModel = useMemo(
|
|
() => !downloadedModels.length && !isAnyRemoteModelConfigured,
|
|
[downloadedModels, isAnyRemoteModelConfigured]
|
|
)
|
|
|
|
if (waitingForCortex) return null
|
|
|
|
return (
|
|
<div className="relative flex h-full w-full flex-1 overflow-x-hidden">
|
|
{shouldShowEmptyModel ? (
|
|
<EmptyModel />
|
|
) : (
|
|
<Fragment>
|
|
<ThreadLeftPanel />
|
|
<ThreadCenterPanel />
|
|
<ThreadRightPanel />
|
|
</Fragment>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ThreadScreen
|