Spaces:
Sleeping
Sleeping
File size: 825 Bytes
23d418f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import { type ReactNode, useState } from 'react'
import type { SystemId } from '@/lib/types'
import { ChatContext } from './chatContext'
import { useChat } from './useChat'
/** The conversation and the box's settings (system, policy date), held ABOVE the pages:
* a page unmounts when you navigate away, and its state with it (owner: the chat
* disappeared on a visit to Evals). Here it lives as long as the browser tab, and an
* answer still streaming keeps arriving while another page is open. */
export function ChatProvider({ children }: { children: ReactNode }) {
const chat = useChat()
const [system, setSystem] = useState<SystemId>('c')
const [day, setDay] = useState<string | null>(null)
return <ChatContext.Provider value={{ ...chat, system, setSystem, day, setDay }}>{children}</ChatContext.Provider>
}
|