From aa95332a934aba1cad0a9ebf360b2be03cd6cdef Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 22 Aug 2025 18:53:54 +0800 Subject: [PATCH] fix(ai-chat): handle empty text in AIReasoningPart and improve message button visibility - Added a check to return null if the text is empty in AIReasoningPart, preventing unnecessary rendering. - Replaced motion div with a standard div for action buttons in AIChatMessage, improving visibility on hover with a more straightforward opacity transition. - Updated loading element styling in AIMessageParts for better layout and visual consistency. These changes enhance the user experience by ensuring components render correctly and improving the visibility of interactive elements. Signed-off-by: Innei --- .../components/displays/AIReasoningPart.tsx | 1 + .../components/message/AIChatMessage.tsx | 19 +++---------------- .../components/message/AIMessageParts.tsx | 2 +- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/AIReasoningPart.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/AIReasoningPart.tsx index fe905e47d..f6f3972ac 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/AIReasoningPart.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/AIReasoningPart.tsx @@ -24,6 +24,7 @@ export const AIReasoningPart: React.FC = React.memo( setIsOpen(true) } }, [isStreaming]) + if (!text) return null return (
diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIChatMessage.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIChatMessage.tsx index 9b7d0cf94..2912dfeee 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIChatMessage.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIChatMessage.tsx @@ -63,7 +63,6 @@ export const AIChatMessage: React.FC = React.memo(({ message throw thenable } - const [isHovered, setIsHovered] = React.useState(false) const getMessageMarkdownFormat = useMessageMarkdownFormat(message) const handleCopy = React.useCallback(async () => { @@ -77,12 +76,7 @@ export const AIChatMessage: React.FC = React.memo(({ message }, [getMessageMarkdownFormat]) return ( -
setIsHovered(true)} - onMouseLeave={() => setIsHovered(false)} - > +
{/* Normal message display */}
@@ -92,14 +86,7 @@ export const AIChatMessage: React.FC = React.memo(({ message
{/* Action buttons */} - +
- +
diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx index 3f90f0b48..a6d5ec595 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx @@ -73,7 +73,7 @@ export const AIMessageParts: React.FC = React.memo(({ messa case "tool-displayFlowChart": { const loadingElement = ( -
+