diff --git a/src/components/ChatInterface.tsx b/src/components/ChatInterface.tsx index 2117db1..cfdc43a 100644 --- a/src/components/ChatInterface.tsx +++ b/src/components/ChatInterface.tsx @@ -22,7 +22,7 @@ export function ChatInterface() { selectModel, isAuthenticated } = useInference(); - const [isLoading, setIsLoading] = useState(false); + const [loadingConversations, setLoadingConversations] = useState>(new Set()); const messagesEndRef = useRef(null); const activeConversation = activeConversationId ? getConversation(activeConversationId) : undefined; @@ -38,13 +38,17 @@ export function ChatInterface() { return; } - setIsLoading(true); + setLoadingConversations(prev => new Set(prev).add(activeConversationId)); try { await sendMessage(activeConversationId, content); } catch (error) { console.error('Failed to send message:', error); } finally { - setIsLoading(false); + setLoadingConversations(prev => { + const newSet = new Set(prev); + newSet.delete(activeConversationId); + return newSet; + }); } }; @@ -78,7 +82,8 @@ export function ChatInterface() { ); } - const isGenerating = agentLoopState?.isRunning || isLoading; + const isCurrentConversationLoading = activeConversationId ? loadingConversations.has(activeConversationId) : false; + const isGenerating = agentLoopState?.isRunning || isCurrentConversationLoading; return (