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 10, 2024
2 parents 1a15c3b + fe349e0 commit 3168dec
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export const SyncMessageCard: FC<SyncMessageCardProps> = ({
onClick={() => setShowMessage(!showMessage)}
>
<div css={infoContainerStyle}>
{runRequestType || messageStatus === MESSAGE_STATUS.ANALYZE_STOP ? (
{runRequestType ||
messageStatus !== MESSAGE_STATUS.ANALYZE_PENDING ? (
<>
<div css={textAndIconContainerStyle}>
<div css={iconStyle(messageStatus)}>{InfoIcon}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
import store from "@/redux/store"
import {
cancelPendingMessage,
delayHandleTask,
formatSendMessagePayload,
getNeedCacheUIMessage,
groupReceivedMessagesForUI,
Expand Down Expand Up @@ -494,12 +495,14 @@ export const AgentWSProvider: FC<IAgentWSProviderProps> = (props) => {
if (!teamID) {
return
}
startSendMessage(
{} as ChatSendRequestPayload,
TextSignal.STOP_RUN,
SEND_MESSAGE_WS_TYPE.STOP_ALL,
)
setIsReceiving(false)
await delayHandleTask(() => {
startSendMessage(
{} as ChatSendRequestPayload,
TextSignal.STOP_RUN,
SEND_MESSAGE_WS_TYPE.STOP_ALL,
)
setIsReceiving(false)
})
cleanMessage()
setChatMessages([])
chatMessagesRef.current = []
Expand Down
15 changes: 9 additions & 6 deletions apps/agent/src/page/WorkSpace/Chat/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { useLazyGetAIAgentAnonymousAddressQuery } from "@/redux/services/agentAP
import store from "@/redux/store"
import {
cancelPendingMessage,
delayHandleTask,
formatSendMessagePayload,
getNeedCacheUIMessage,
groupReceivedMessagesForUI,
Expand Down Expand Up @@ -394,12 +395,14 @@ export const ChatWSProvider: FC<IChatWSProviderProps> = (props) => {
if (!teamID || !chatID) {
return
}
startSendMessage(
{} as ChatSendRequestPayload,
TextSignal.STOP_RUN,
SEND_MESSAGE_WS_TYPE.STOP_ALL,
)
setIsReceiving(false)
await delayHandleTask(() => {
startSendMessage(
{} as ChatSendRequestPayload,
TextSignal.STOP_RUN,
SEND_MESSAGE_WS_TYPE.STOP_ALL,
)
setIsReceiving(false)
})
cleanMessage()
setChatMessages([])
chatMessagesRef.current = []
Expand Down
1 change: 1 addition & 0 deletions apps/agent/src/utils/agent/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DELAY_TASK_TIME = 500
10 changes: 10 additions & 0 deletions apps/agent/src/utils/agent/wsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
MESSAGE_SYNC_TYPE,
} from "@/components/PreviewChat/interface"
import { AgentInitial } from "@/page/WorkSpace/AI/AIAgent/interface"
import { DELAY_TASK_TIME } from "./constants"
import { isGroupMessage, isNormalMessage } from "./typeHelper"

export const formatSendMessagePayload = (payload: ChatSendRequestPayload) => {
Expand Down Expand Up @@ -211,3 +212,12 @@ export const getNeedCacheUIMessage = (
| ChatMessage
)[]
}

export const delayHandleTask = (task: () => void) => {
return new Promise((resolve) => {
task()
setTimeout(() => {
resolve(true)
}, DELAY_TASK_TIME)
})
}

0 comments on commit 3168dec

Please sign in to comment.