diff --git a/src/components/chat/hooks/useChatComposerState.ts b/src/components/chat/hooks/useChatComposerState.ts index ca430a1..a779bcd 100644 --- a/src/components/chat/hooks/useChatComposerState.ts +++ b/src/components/chat/hooks/useChatComposerState.ts @@ -47,6 +47,7 @@ interface UseChatComposerStateArgs { sendMessage: (message: unknown) => void; sendByCtrlEnter?: boolean; onSessionActive?: (sessionId?: string | null) => void; + onSessionProcessing?: (sessionId?: string | null) => void; onInputFocusChange?: (focused: boolean) => void; onFileOpen?: (filePath: string, diffInfo?: unknown) => void; onShowSettings?: () => void; @@ -98,6 +99,7 @@ export function useChatComposerState({ sendMessage, sendByCtrlEnter, onSessionActive, + onSessionProcessing, onInputFocusChange, onFileOpen, onShowSettings, @@ -569,6 +571,9 @@ export function useChatComposerState({ pendingViewSessionRef.current = { sessionId: null, startedAt: Date.now() }; } onSessionActive?.(sessionToActivate); + if (effectiveSessionId && !isTemporarySessionId(effectiveSessionId)) { + onSessionProcessing?.(effectiveSessionId); + } const getToolsSettings = () => { try { @@ -666,6 +671,7 @@ export function useChatComposerState({ executeCommand, isLoading, onSessionActive, + onSessionProcessing, pendingViewSessionRef, permissionMode, provider, diff --git a/src/components/chat/hooks/useChatRealtimeHandlers.ts b/src/components/chat/hooks/useChatRealtimeHandlers.ts index e84f726..6ba11cc 100644 --- a/src/components/chat/hooks/useChatRealtimeHandlers.ts +++ b/src/components/chat/hooks/useChatRealtimeHandlers.ts @@ -956,12 +956,26 @@ export function useChatRealtimeHandlers({ case 'session-status': { const statusSessionId = latestMessage.sessionId; + if (!statusSessionId) { + break; + } + const isCurrentSession = statusSessionId === currentSessionId || (selectedSession && statusSessionId === selectedSession.id); - if (isCurrentSession && latestMessage.isProcessing) { - setIsLoading(true); - setCanAbortSession(true); + + if (latestMessage.isProcessing) { onSessionProcessing?.(statusSessionId); + if (isCurrentSession) { + setIsLoading(true); + setCanAbortSession(true); + } + break; + } + + onSessionInactive?.(statusSessionId); + onSessionNotProcessing?.(statusSessionId); + if (isCurrentSession) { + clearLoadingIndicators(); } break; } diff --git a/src/components/chat/view/ChatInterface.tsx b/src/components/chat/view/ChatInterface.tsx index 946a080..11091e5 100644 --- a/src/components/chat/view/ChatInterface.tsx +++ b/src/components/chat/view/ChatInterface.tsx @@ -180,6 +180,7 @@ function ChatInterface({ sendMessage, sendByCtrlEnter, onSessionActive, + onSessionProcessing, onInputFocusChange, onFileOpen, onShowSettings, @@ -238,13 +239,6 @@ function ChatInterface({ }; }, [canAbortSession, handleAbortSession, isLoading]); - useEffect(() => { - const processingSessionId = selectedSession?.id || currentSessionId; - if (processingSessionId && isLoading && onSessionProcessing) { - onSessionProcessing(processingSessionId); - } - }, [currentSessionId, isLoading, onSessionProcessing, selectedSession?.id]); - useEffect(() => { return () => { resetStreamingState();