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 useChat hook to remove redundant error message handling logic before sending new messages

Salman-Ahamed169400420a20
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 40c63f7a..0b84f0e3 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,23 +308,6 @@ export const useChat = (config: IUseChatConfig): IUseChatReturn => {
setIsProcessing(true);
clearError();
- // Remove any previous error messages and loading messages before sending new message
- setMessages((prev) => {
- // Check if there are any error messages (indicates stopped generation)
- const hasErrorMessages = prev.some((msg) => msg.type === 'error');
-
- // Remove error messages
- const filtered = prev.filter((msg) => msg.type !== 'error');
-
- // If there were error messages and the last message is loading,
- if (hasErrorMessages && filtered.length > 0) {
- const lastMessage = filtered[filtered.length - 1];
- if (lastMessage.type === 'loading') return filtered.slice(0, -1);
- }
-
- return filtered;
- });
-
// Upload files if present
let attachments: IFileAttachment[] = [];
if (files && files.length > 0) {