"use client"; import React, { createContext, useContext } from "react"; import { useSessions, Session, Message } from "@/lib/SessionManager"; interface SessionContextType { sessions: Session[]; currentSessionId: string | null; createNewSession: () => void; switchSession: (sessionId: string) => void; updateSessionMessages: (sessionId: string, messages: Message[]) => void; deleteSession: (sessionId: string) => void; renameSession: (sessionId: string, newName: string) => void; } const SessionContext = createContext(undefined); export const SessionProvider: React.FC<{ children: React.ReactNode }> = ({ children, }) => { const sessionManager = useSessions(); return ( {children} ); }; export const useSessionContext = () => { const context = useContext(SessionContext); if (context === undefined) { throw new Error("useSessionContext must be used within a SessionProvider"); } return context; };