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.

Enhance error handling in chat system

Salman-Ahamedcbc03133eacc
diff --git a/packages/app/src/react/features/ai-chat/components/system-message.tsx b/packages/app/src/react/features/ai-chat/components/system-message.tsx
index 8b03f6c5..5c6ffbd2 100644
--- a/packages/app/src/react/features/ai-chat/components/system-message.tsx
+++ b/packages/app/src/react/features/ai-chat/components/system-message.tsx
@@ -34,6 +34,8 @@ export const SystemMessage: FC<ISystemMessageProps> = (props) => {
const contentRef = useRef<HTMLDivElement>(null);
+ if (!message) return null; // if message is empty, return null
+
return (
<div className="system-message-bubble relative">
{isError ? (
diff --git a/packages/app/src/react/features/ai-chat/hooks/use-chat.ts b/packages/app/src/react/features/ai-chat/hooks/use-chat.ts
index 0b84f0e3..48bf86e8 100644
--- a/packages/app/src/react/features/ai-chat/hooks/use-chat.ts
+++ b/packages/app/src/react/features/ai-chat/hooks/use-chat.ts
@@ -308,6 +308,9 @@ export const useChat = (config: IUseChatConfig): IUseChatReturn => {
setIsProcessing(true);
clearError();
+ // Remove any previous error messages before sending new message
+ setMessages((prev) => prev.filter((msg) => msg.type !== 'error'));
+
// Upload files if present
let attachments: IFileAttachment[] = [];
if (files && files.length > 0) {