import { createFileRoute, useParams } from '@tanstack/react-router' import { useMemo } from 'react' import { useThreadManagement } from '@/hooks/useThreadManagement' import { useThreads } from '@/hooks/useThreads' import { useTranslation } from '@/i18n/react-i18next-compat' import ChatInput from '@/containers/ChatInput' import HeaderPage from '@/containers/HeaderPage' import ThreadList from '@/containers/ThreadList' import DropdownAssistant from '@/containers/DropdownAssistant' import { PlatformFeatures } from '@/lib/platform/const' import { PlatformGuard } from '@/lib/platform/PlatformGuard' import { PlatformFeature } from '@/lib/platform/types' import { IconMessage } from '@tabler/icons-react' import { cn } from '@/lib/utils' import { useAppearance } from '@/hooks/useAppearance' import { useSmallScreen } from '@/hooks/useMediaQuery' export const Route = createFileRoute('/project/$projectId')({ component: ProjectPage, }) function ProjectPage() { return ( ) } function ProjectPageContent() { const { t } = useTranslation() const { projectId } = useParams({ from: '/project/$projectId' }) const { getFolderById } = useThreadManagement() const threads = useThreads((state) => state.threads) const chatWidth = useAppearance((state) => state.chatWidth) const isSmallScreen = useSmallScreen() // Find the project const project = getFolderById(projectId) // Get threads for this project const projectThreads = useMemo(() => { return Object.values(threads) .filter((thread) => thread.metadata?.project?.id === projectId) .sort((a, b) => (b.updated || 0) - (a.updated || 0)) }, [threads, projectId]) if (!project) { return (

{t('projects.projectNotFound')}

{t('projects.projectNotFoundDesc')}

) } return (
{PlatformFeatures[PlatformFeature.ASSISTANTS] && ( )}
{projectThreads.length > 0 && ( <>

{t('projects.conversationsIn', { projectName: project.name, })}

{t('projects.conversationsDescription')}

)}
{/* Thread List or Empty State */}
{projectThreads.length > 0 ? ( ) : (

{t('projects.noConversationsIn', { projectName: project.name, })}

{t('projects.startNewConversation', { projectName: project.name, })}

)}
{/* New Chat Input */}
) }