From 877b79ada8011f4464c225356d2c59bd54c0687b Mon Sep 17 00:00:00 2001 From: Huarch Date: Wed, 10 Jun 2026 21:33:33 +0800 Subject: [PATCH] refactor(chat): remove typing indicator --- src/components/chat/AgentWorkspace.test.tsx | 4 -- src/components/chat/AgentWorkspace.tsx | 49 ++++----------------- src/components/chat/GlobalChatbox.parts.tsx | 30 ------------- 3 files changed, 9 insertions(+), 74 deletions(-) diff --git a/src/components/chat/AgentWorkspace.test.tsx b/src/components/chat/AgentWorkspace.test.tsx index 134d6ac..a135fdf 100644 --- a/src/components/chat/AgentWorkspace.test.tsx +++ b/src/components/chat/AgentWorkspace.test.tsx @@ -34,10 +34,6 @@ jest.mock("framer-motion", () => ({ }, })); -jest.mock("./GlobalChatbox.parts", () => ({ - TypingIndicator: () =>
typing
, -})); - jest.mock("./AgentTurn", () => ({ AgentTurn: ({ message, isStreaming }: { message: Message; isStreaming: boolean }) => { React.useEffect(() => { diff --git a/src/components/chat/AgentWorkspace.tsx b/src/components/chat/AgentWorkspace.tsx index 00a63a0..2833b7e 100644 --- a/src/components/chat/AgentWorkspace.tsx +++ b/src/components/chat/AgentWorkspace.tsx @@ -10,7 +10,6 @@ import TroubleshootRounded from "@mui/icons-material/TroubleshootRounded"; import MapRounded from "@mui/icons-material/MapRounded"; import { AgentTurn } from "./AgentTurn"; -import { TypingIndicator } from "./GlobalChatbox.parts"; import type { PermissionReply } from "@/lib/chatStream"; import type { Message, @@ -39,7 +38,7 @@ type AgentWorkspaceProps = { type TurnListProps = { messages: Message[]; - isStreaming: boolean; + isAssistantStreaming: boolean; streamingMessageId: string | null; speakingMessageId: string | null; speechState: SpeechState; @@ -65,7 +64,7 @@ const TurnItem = React.memo(AgentTurn); const TurnListInner = ({ messages, - isStreaming, + isAssistantStreaming, streamingMessageId, speakingMessageId, speechState, @@ -85,7 +84,7 @@ const TurnListInner = ({ sameMessages(prevProps.messages, nextProps.messages) && - prevProps.isStreaming === nextProps.isStreaming && + prevProps.isAssistantStreaming === nextProps.isAssistantStreaming && prevProps.streamingMessageId === nextProps.streamingMessageId && prevProps.speakingMessageId === nextProps.speakingMessageId && prevProps.speechState === nextProps.speechState && @@ -318,19 +317,10 @@ export const AgentWorkspace = ({ onReplyQuestion, onRejectQuestion, }: AgentWorkspaceProps) => { - const theme = useTheme(); - const latestAssistant = [...messages] - .reverse() - .find((message) => message.role === "assistant"); - const showTypingIndicator = - isStreaming && - (!latestAssistant || - (latestAssistant.content.trim().length === 0 && - !(latestAssistant.artifacts?.length))); - const streamingMessage = + const streamingMessageId = isStreaming && messages.at(-1)?.role === "assistant" - ? messages.at(-1) - : undefined; + ? messages.at(-1)?.id ?? null + : null; const handleScroll = React.useCallback( (event: React.UIEvent) => { if (!onScrollStateChange) return; @@ -372,8 +362,8 @@ export const AgentWorkspace = ({ )} - {!isLoadingSession && showTypingIndicator ? ( - - - - - - ) : null} -
{ - return ( - - {[0, 1, 2].map((i) => ( - - - - ))} - - ); -}; export const Blob = ({ color,