Skip to content

Commit

Permalink
fixme comment for tmp solution
Browse files Browse the repository at this point in the history
  • Loading branch information
wwayne committed May 24, 2024
1 parent de39118 commit 976d8d1
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions ee/tabby-ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ export default function ChatPage() {
null
)
const [activeChatId, setActiveChatId] = useState('')
const [initialMessages, setInitialMessages] = useState<QuestionAnswerPair[]>(
[]
)
let pendingMessages: ChatMessage[] = [] // FIXME(wwayne): use init message props after Chat component update

const chatRef = useRef<ChatRef>(null)
const searchParams = useSearchParams()
const maxWidth = searchParams.get('max-width') || undefined
Expand Down Expand Up @@ -71,14 +70,7 @@ export default function ChatPage() {
if (chatRef.current) {
chatRef.current.sendUserChat(message)
} else {
const newInitialMessages = [...initialMessages]
newInitialMessages.push({
user: {
...message,
id: nanoid()
}
})
setInitialMessages(newInitialMessages)
pendingMessages.push(message)
}
}

Expand All @@ -88,6 +80,11 @@ export default function ChatPage() {
setActiveChatId(nanoid())
setIsInit(true)
setFetcherOptions(request.fetcherOptions)

// FIXME(wwayne): This is no needed after Chat support initMessage
setTimeout(() => {
pendingMessages.forEach(sendMessage)
}, 1000)
},
sendMessage: (message: ChatMessage) => {
return sendMessage(message)
Expand All @@ -108,7 +105,6 @@ export default function ChatPage() {
key={activeChatId}
ref={chatRef}
headers={headers}
initialMessages={initialMessages}
onThreadUpdates={() => {}}
onNavigateToContext={onNavigateToContext}
maxWidth={maxWidth}
Expand Down

0 comments on commit 976d8d1

Please sign in to comment.