import React, { createContext, useContext, useMemo } from 'react'; import type { EModelEndpoint } from 'librechat-data-provider'; import { useChatContext } from './ChatContext'; interface SidePanelContextValue { endpoint?: EModelEndpoint | null; } const SidePanelContext = createContext(undefined); export function SidePanelProvider({ children }: { children: React.ReactNode }) { const { conversation } = useChatContext(); /** Context value only created when endpoint changes */ const contextValue = useMemo( () => ({ endpoint: conversation?.endpoint, }), [conversation?.endpoint], ); return {children}; } export function useSidePanelContext() { const context = useContext(SidePanelContext); if (!context) { throw new Error('useSidePanelContext must be used within SidePanelProvider'); } return context; }