Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Refactor Chat component to streamline message rendering logic and handle error state

Salman-Ahamed6c7ff2c08fb7
diff --git a/packages/app/src/react/features/ai-chat/components/chat.tsx b/packages/app/src/react/features/ai-chat/components/chat.tsx
index 13479197..d30472c3 100644
--- a/packages/app/src/react/features/ai-chat/components/chat.tsx
+++ b/packages/app/src/react/features/ai-chat/components/chat.tsx
@@ -16,15 +16,15 @@ interface ChatProps extends IChatMessage {
export const Chat: FC<ChatProps> = ({
me,
+ type,
files,
avatar,
message,
- type,
isReplying,
isRetrying,
+ hideMessage,
onRetryClick,
isError = false,
- hideMessage,
thinkingMessage,
scrollToBottom,
}) => {
@@ -32,19 +32,19 @@ export const Chat: FC<ChatProps> = ({
if (me && !hideMessage) return <UserMessage message={message} files={files} />;
if (type === 'thinking') return <ThinkingMessage message={message} avatar={avatar} />;
- return (
- !hideMessage && (
- <SystemMessage
- avatar={avatar}
- message={message}
- isError={isError}
- onRetryClick={onRetryClick}
- isRetrying={isRetrying}
- thinkingMessage={thinkingMessage}
- onTypingProgress={() => scrollToBottom?.()}
- onTypingComplete={() => scrollToBottom?.()}
- typingAnimation={!isReplying && !isRetrying && !isError}
- />
- )
+ return !hideMessage ? (
+ <SystemMessage
+ avatar={avatar}
+ message={message}
+ isError={isError}
+ onRetryClick={onRetryClick}
+ isRetrying={isRetrying}
+ thinkingMessage={thinkingMessage}
+ onTypingProgress={() => scrollToBottom?.()}
+ onTypingComplete={() => scrollToBottom?.()}
+ typingAnimation={!isReplying && !isRetrying && !isError}
+ />
+ ) : (
+ <SystemMessage message="Something went wrong" />
);
};