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 AIChat component to always start with a new chat session and clear chat history on mount

Salman-Ahamed193f35487438
diff --git a/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx b/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx
index 5b859db8..8740b9da 100644
--- a/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx
+++ b/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx
@@ -155,12 +155,18 @@ const AIChat: FC<AIChatProps> = ({
currentAgent.aiAgentSettings = agentSettingsData.settings;
currentAgent.id = agentId;
- if (!currentAgent?.aiAgentSettings?.lastConversationId) {
- createNewChatSession();
- }
+ // Always start with a clear session when opening the chat
+ createNewChatSession();
}
}, [agentSettingsData, currentAgent, agentId, createNewChatSession]);
+ // Ensure clean state on mount - clear chat history every time page loads
+ useEffect(() => {
+ clearMessages();
+ setShowScrollButton(false);
+ isFirstMessageSentRef.current = false;
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
+
useEffect(() => {
if (!isAgentLoading && !isQueryInputDisabled) {
queryInputRef.current?.focus();