diff --git a/apps/agent/src/page/WorkSpace/AI/components/SyncMessageCard/index.tsx b/apps/agent/src/page/WorkSpace/AI/components/SyncMessageCard/index.tsx index dadccd70..3842a36b 100644 --- a/apps/agent/src/page/WorkSpace/AI/components/SyncMessageCard/index.tsx +++ b/apps/agent/src/page/WorkSpace/AI/components/SyncMessageCard/index.tsx @@ -86,7 +86,8 @@ export const SyncMessageCard: FC = ({ onClick={() => setShowMessage(!showMessage)} >
- {runRequestType || messageStatus === MESSAGE_STATUS.ANALYZE_STOP ? ( + {runRequestType || + messageStatus !== MESSAGE_STATUS.ANALYZE_PENDING ? ( <>
{InfoIcon}
diff --git a/apps/agent/src/page/WorkSpace/AI/context/AgentWSContext/index.tsx b/apps/agent/src/page/WorkSpace/AI/context/AgentWSContext/index.tsx index eac28deb..566c1ee7 100644 --- a/apps/agent/src/page/WorkSpace/AI/context/AgentWSContext/index.tsx +++ b/apps/agent/src/page/WorkSpace/AI/context/AgentWSContext/index.tsx @@ -53,6 +53,7 @@ import { import store from "@/redux/store" import { cancelPendingMessage, + delayHandleTask, formatSendMessagePayload, getNeedCacheUIMessage, groupReceivedMessagesForUI, @@ -494,12 +495,14 @@ export const AgentWSProvider: FC = (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 = [] diff --git a/apps/agent/src/page/WorkSpace/Chat/context/index.tsx b/apps/agent/src/page/WorkSpace/Chat/context/index.tsx index 09556f3d..57ed7d0d 100644 --- a/apps/agent/src/page/WorkSpace/Chat/context/index.tsx +++ b/apps/agent/src/page/WorkSpace/Chat/context/index.tsx @@ -48,6 +48,7 @@ import { useLazyGetAIAgentAnonymousAddressQuery } from "@/redux/services/agentAP import store from "@/redux/store" import { cancelPendingMessage, + delayHandleTask, formatSendMessagePayload, getNeedCacheUIMessage, groupReceivedMessagesForUI, @@ -394,12 +395,14 @@ export const ChatWSProvider: FC = (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 = [] diff --git a/apps/agent/src/utils/agent/constants.ts b/apps/agent/src/utils/agent/constants.ts new file mode 100644 index 00000000..044fd422 --- /dev/null +++ b/apps/agent/src/utils/agent/constants.ts @@ -0,0 +1 @@ +export const DELAY_TASK_TIME = 500 diff --git a/apps/agent/src/utils/agent/wsUtils.ts b/apps/agent/src/utils/agent/wsUtils.ts index 4ebd50ef..c47bf702 100644 --- a/apps/agent/src/utils/agent/wsUtils.ts +++ b/apps/agent/src/utils/agent/wsUtils.ts @@ -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) => { @@ -211,3 +212,12 @@ export const getNeedCacheUIMessage = ( | ChatMessage )[] } + +export const delayHandleTask = (task: () => void) => { + return new Promise((resolve) => { + task() + setTimeout(() => { + resolve(true) + }, DELAY_TASK_TIME) + }) +}