refactor: move chat-sidebar related components to router's components dir

feat-display-remote-workers
Meng Zhang 2023-11-19 16:18:38 -08:00
parent 352db4ecf2
commit d2281c7a1b
5 changed files with 3 additions and 41 deletions

View File

@ -14,7 +14,7 @@ import {
TooltipContent,
TooltipTrigger
} from '@/components/ui/tooltip'
import { EditChatTitleDialog } from '@/components/edit-chat-title-dialog'
import { EditChatTitleDialog } from './edit-chat-title-dialog'
import { useStore } from '@/lib/hooks/use-store'
import { Button } from '@/components/ui/button'
import { ListSkeleton } from '@/components/skeleton'

View File

@ -4,7 +4,7 @@ import React from 'react'
import { Chat } from '@/components/chat'
import { useChatStore } from '@/lib/stores/chat-store'
import { getChatById } from '@/lib/stores/utils'
import { ChatSessions } from '@/components/chat-sessions'
import { ChatSessions } from './chat-sessions'
import { useStore } from '@/lib/hooks/use-store'
import type { Message } from 'ai'

View File

@ -17,7 +17,7 @@ import { IconArrowElbow, IconEdit, IconTrash } from '@/components/ui/icons'
import { Input } from '@/components/ui/input'
import { updateChat } from '@/lib/stores/chat-actions'
import { Button } from './ui/button'
import { Button } from '@/components/ui/button'
interface EditChatTitleDialogProps {
initialValue: string | undefined

View File

@ -1,38 +0,0 @@
'use client'
import React from 'react'
import { Message, UseChatHelpers, useChat } from 'ai/react'
import { toast } from 'react-hot-toast'
export interface ChatContextValue extends UseChatHelpers {
id: string | undefined
}
export const ChatContext = React.createContext({} as ChatContextValue)
export interface ChatContextProviderProps {
id: string | undefined
initialMessages?: Message[]
}
export const ChatContextProvider: React.FC<
React.PropsWithChildren<ChatContextProviderProps>
> = ({ children, id, initialMessages }) => {
const chatHelpers = useChat({
initialMessages,
id,
body: {
id
},
onResponse(response) {
if (response.status === 401) {
toast.error(response.statusText)
}
}
})
return (
<ChatContext.Provider value={{ ...chatHelpers, id }}>
{children}
</ChatContext.Provider>
)
}