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.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
Refactor useChat hook: Update thinking message handling to modify message type and retain conversationTurnId
Salman-Ahamed19c062fc8dc6
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.tsindex 1c4c356e..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@@ -359,26 +359,30 @@ export const useChat = (config: IUseChatConfig): IUseChatReturn => {onThinking: (thinkingMsg: string, type: TThinkingType, conversationTurnId?: string) => {if (conversationTurnId && !currentTurnIdRef.current) {currentTurnIdRef.current = conversationTurnId; // Capture turn ID from thinking messages-- // Optimized: Consistent with other state updates- setMessages((prev) => {- const lastIndex = prev.length - 1;- if (lastIndex >= 0) {- // Only update last element without copying entire array- const newMessages = prev.slice(0, -1);- newMessages.push({ ...prev[lastIndex], conversationTurnId });- return newMessages;- }- return prev;- });}// Mark that we're in thinking stateisThinkingRef.current = true;hasThinkingOccurredRef.current = true;- // Update thinking message- updateThinkingMessage(thinkingMsg);+ // Update thinking message and change type from 'loading' to 'system' to close loading indicator+ setMessages((prev) => {+ const lastIndex = prev.length - 1;+ if (lastIndex >= 0) {+ const lastMsg = prev[lastIndex];+ // Only update last element without copying entire array+ const newMessages = prev.slice(0, -1);+ newMessages.push({+ ...lastMsg,+ thinkingMessage: thinkingMsg,+ conversationTurnId: conversationTurnId || lastMsg.conversationTurnId,+ // Change type from 'loading' to 'system' to close loading indicator+ type: lastMsg.type === 'loading' ? 'system' : lastMsg.type,+ });+ return newMessages;+ }+ return prev;+ });},onToolCall: (toolName: string,