mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-21 04:45:12 +00:00
* feat: create conversations storage hook * feat: save conversation hook * feat: created chat layout * feat: created chat history button * feat: setup chat history view links * chore: updated placeholder * fix: width of the chat history screen * feat: provide navigation from history page back to conversation page * fix: issue with restoring conversation id * chore: do not update history when content doesn't change * feat: mark active conversation id * fix: syncing the conversation id ref
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import type { FC } from 'react'
|
|
import { Outlet } from 'react-router'
|
|
import { ChatHeader } from '../index/ChatHeader'
|
|
import {
|
|
ChatSessionProvider,
|
|
useChatSessionContext,
|
|
} from './ChatSessionContext'
|
|
|
|
const ChatLayoutContent: FC = () => {
|
|
const {
|
|
providers,
|
|
selectedProvider,
|
|
handleSelectProvider,
|
|
resetConversation,
|
|
messages,
|
|
isLoading,
|
|
} = useChatSessionContext()
|
|
|
|
if (isLoading || !selectedProvider) {
|
|
return (
|
|
<div className="flex h-screen w-screen items-center justify-center bg-background">
|
|
<div className="h-5 w-5 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div className="mx-auto flex h-screen w-screen flex-col overflow-hidden bg-background text-foreground">
|
|
<ChatHeader
|
|
selectedProvider={selectedProvider}
|
|
onSelectProvider={handleSelectProvider}
|
|
providers={providers}
|
|
onNewConversation={resetConversation}
|
|
hasMessages={messages.length > 0}
|
|
/>
|
|
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
|
<Outlet />
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const ChatLayout: FC = () => {
|
|
return (
|
|
<ChatSessionProvider>
|
|
<ChatLayoutContent />
|
|
</ChatSessionProvider>
|
|
)
|
|
}
|