Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'beta' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangtaofeng committed Apr 25, 2024
2 parents b476127 + c169a4e commit 4bedff4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/agent/src/components/PreviewChat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import InputArea from "./InputArea"
import MessageList from "./MessageList"
import { SEND_MESSAGE_WS_TYPE } from "./TipisWebscoketContext/interface"
import { SCROLL_DIRECTION } from "./constants"
import { ChatSendRequestPayload, PreviewChatProps } from "./interface"
import {
ChatMessage,
ChatSendRequestPayload,
PreviewChatProps,
} from "./interface"
import {
inputTextContainerStyle,
maxWidthStyle,
Expand Down Expand Up @@ -44,6 +48,14 @@ export const PreviewChat: FC<PreviewChatProps> = (props) => {
cacheLastScroll.current = e.currentTarget.scrollTop
}, [])

const handleSendMessage = (cheatMessage: ChatMessage) => {
scrollDirectRef.current = SCROLL_DIRECTION.DOWN
chatRef.current?.scrollTo({
top: chatRef.current.scrollHeight,
})
onSendMessage(cheatMessage)
}

useEffect(() => {
if (chatMessages.length === 0) {
scrollDirectRef.current = SCROLL_DIRECTION.DOWN
Expand Down Expand Up @@ -80,7 +92,7 @@ export const PreviewChat: FC<PreviewChatProps> = (props) => {
/>
<InputArea
isReceiving={isReceiving}
onSendMessage={onSendMessage}
onSendMessage={handleSendMessage}
hasMessage={chatMessages.length > 0}
/>
</>
Expand Down

0 comments on commit 4bedff4

Please sign in to comment.