Commit 5a00c065 by Archer Committed by GitHub

fix: chatitem animation (#6965)

* fix: chatitem animation

* fix: chatitem animation
parent fb38d14f
...@@ -126,8 +126,8 @@ const AIContentCard = React.memo(function AIContentCard({ ...@@ -126,8 +126,8 @@ const AIContentCard = React.memo(function AIContentCard({
onOpenCiteModal: (e?: OnOpenCiteModalProps) => void; onOpenCiteModal: (e?: OnOpenCiteModalProps) => void;
}) { }) {
const lastValue = chatValue[chatValue.length - 1]; const lastValue = chatValue[chatValue.length - 1];
const lastIsText = lastValue?.text; const lastHasText = !!lastValue?.text?.content?.trim();
const lastIsReasoning = lastValue?.reasoning; const lastHasReasoning = !!lastValue?.reasoning?.content?.trim();
return ( return (
<Flex flexDirection={'column'}> <Flex flexDirection={'column'}>
{chatValue.map((value, i) => { {chatValue.map((value, i) => {
...@@ -154,7 +154,7 @@ const AIContentCard = React.memo(function AIContentCard({ ...@@ -154,7 +154,7 @@ const AIContentCard = React.memo(function AIContentCard({
})} })}
{/* 生成中占位动画(含断线续传拉流期间最后一条非文本时的 shimmer) */} {/* 生成中占位动画(含断线续传拉流期间最后一条非文本时的 shimmer) */}
{isLastChild && !lastIsText && !lastIsReasoning && isChatting && ( {isLastChild && !lastHasText && !lastHasReasoning && isChatting && (
<Box className={markdownStyles.animation}></Box> <Box className={markdownStyles.animation}></Box>
)} )}
......
...@@ -38,30 +38,32 @@ const AIResponseBox = ({ ...@@ -38,30 +38,32 @@ const AIResponseBox = ({
const tools = value.tools || (value.tool ? [value.tool] : undefined); const tools = value.tools || (value.tool ? [value.tool] : undefined);
const disableStreamingInteraction = isChatting && isLastChild; const disableStreamingInteraction = isChatting && isLastChild;
const skills = value.skills; const skills = value.skills;
const reasoningContent = value.reasoning?.content || '';
const textContent = value.text?.content || '';
if (value.hideInUI) return null; if (value.hideInUI) return null;
const responseBlocks: React.ReactNode[] = []; const responseBlocks: React.ReactNode[] = [];
if ('reasoning' in value && value.reasoning && !value.hideReason) { if (reasoningContent && !value.hideReason) {
responseBlocks.push( responseBlocks.push(
<RenderReasoningContent <RenderReasoningContent
key="reasoning" key="reasoning"
isChatting={isChatting} isChatting={isChatting}
isLastResponseValue={isLastResponseValue} isLastResponseValue={isLastResponseValue && !textContent && !tools}
content={value.reasoning.content} content={reasoningContent}
isDisabled={disableStreamingInteraction} isDisabled={disableStreamingInteraction}
/> />
); );
} }
if ('text' in value && value.text) { if (value.text && textContent) {
responseBlocks.push( responseBlocks.push(
<RenderText <RenderText
key="text" key="text"
chatItemDataId={chatItemDataId} chatItemDataId={chatItemDataId}
showAnimation={isChatting && isLastResponseValue} showAnimation={isChatting && isLastResponseValue}
text={value.text.content} text={textContent}
onOpenCiteModal={onOpenCiteModal} onOpenCiteModal={onOpenCiteModal}
isDisabled={disableStreamingInteraction} isDisabled={disableStreamingInteraction}
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment