mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-21 04:45:12 +00:00
* feat: added ai-sdk dev tools * feat: new system prompt section * feat: tests to maintain prompt integrity * feat: update mcp sync to use react query * fix: refetch logic for sync * chore: remove limits on fetching integrations * fix: refetch integrations on delete * fix: review comment * chore: update tests * fix: improved memory classification * fix: lint issues * fix: core memory prompts * fix: handle scenario where soul file is empty
36 lines
1010 B
TypeScript
36 lines
1010 B
TypeScript
import { createContext, type FC, type ReactNode, useContext } from 'react'
|
|
import { useSyncRemoteIntegrations } from '@/lib/mcp/useSyncRemoteIntegrations'
|
|
import {
|
|
type ChatSessionOptions,
|
|
useChatSession,
|
|
} from '../index/useChatSession'
|
|
|
|
type ChatSessionContextValue = ReturnType<typeof useChatSession>
|
|
|
|
const ChatSessionContext = createContext<ChatSessionContextValue | null>(null)
|
|
|
|
export const ChatSessionProvider: FC<
|
|
{ children: ReactNode } & ChatSessionOptions
|
|
> = ({ children, ...options }) => {
|
|
const { hasSynced } = useSyncRemoteIntegrations()
|
|
const session = useChatSession({
|
|
...options,
|
|
isIntegrationsSynced: hasSynced,
|
|
})
|
|
return (
|
|
<ChatSessionContext.Provider value={session}>
|
|
{children}
|
|
</ChatSessionContext.Provider>
|
|
)
|
|
}
|
|
|
|
export const useChatSessionContext = () => {
|
|
const context = useContext(ChatSessionContext)
|
|
if (!context) {
|
|
throw new Error(
|
|
'useChatSessionContext must be used within a ChatSessionProvider',
|
|
)
|
|
}
|
|
return context
|
|
}
|