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.

Refine comment in useChat hook for improved clarity

Salman-Ahamed433a820af6b0
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 c474f92e..40c63f7a 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
@@ -316,7 +316,7 @@ export const useChat = (config: IUseChatConfig): IUseChatReturn => {
// Remove error messages
const filtered = prev.filter((msg) => msg.type !== 'error');
- // If there were error messages, also remove the loading message
+ // 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);