"use client"; import Image from "next/image"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useState, type ReactNode } from "react"; import { BookOpen, Bot, Brain, Library, MessageSquare, PanelLeftClose, PanelLeftOpen, PenLine, Plus, Settings, type LucideIcon, } from "lucide-react"; import { useTranslation } from "react-i18next"; import SessionList from "@/components/SessionList"; import { TutorBotRecent } from "@/components/sidebar/TutorBotRecent"; import { BookRecent } from "@/components/sidebar/BookRecent"; import type { SessionSummary } from "@/lib/session-api"; interface NavEntry { href: string; label: string; icon: LucideIcon; } const PRIMARY_NAV: NavEntry[] = [ { href: "/chat", label: "Chat", icon: MessageSquare }, { href: "/agents", label: "TutorBot", icon: Bot }, { href: "/co-writer", label: "Co-Writer", icon: PenLine }, { href: "/book", label: "Book", icon: Library }, { href: "/knowledge", label: "Knowledge", icon: BookOpen }, { href: "/memory", label: "Memory", icon: Brain }, ]; const SECONDARY_NAV: NavEntry[] = [{ href: "/settings", label: "Settings", icon: Settings }]; const DEFAULT_SESSION_VIEWPORT_CLASS_NAME = "max-h-[112px]"; interface SidebarShellProps { sessions?: SessionSummary[]; activeSessionId?: string | null; loadingSessions?: boolean; showSessions?: boolean; sessionViewportClassName?: string; onNewChat?: () => void; onSelectSession?: (sessionId: string) => void | Promise; onRenameSession?: (sessionId: string, title: string) => void | Promise; onDeleteSession?: (sessionId: string) => void | Promise; footerSlot?: ReactNode; } export function SidebarShell({ sessions = [], activeSessionId = null, loadingSessions = false, showSessions = false, sessionViewportClassName = DEFAULT_SESSION_VIEWPORT_CLASS_NAME, onNewChat, onSelectSession, onRenameSession, onDeleteSession, footerSlot, }: SidebarShellProps) { const pathname = usePathname(); const router = useRouter(); const { t } = useTranslation(); const [collapsed, setCollapsed] = useState(false); const handleNewChat = () => { if (onNewChat) { onNewChat(); return; } router.push("/chat"); }; /* ---- Collapsed state ---- */ if (collapsed) { return ( ); } /* ---- Expanded state ---- */ return ( ); }