@@ -622,7 +622,6 @@ class ChatStore {
622622 await conversationsStore . updateCurrentNode ( assistantMessage . id ) ;
623623
624624 if ( onComplete ) await onComplete ( streamedContent ) ;
625- this . setChatLoading ( assistantMessage . convId , false ) ;
626625 this . clearChatStreaming ( assistantMessage . convId ) ;
627626 this . clearProcessingState ( assistantMessage . convId ) ;
628627
@@ -632,12 +631,20 @@ class ChatStore {
632631
633632 // If the model emitted tool calls, execute any enabled tools and continue the exchange.
634633 if ( finalToolCalls ) {
635- await this . processToolCallsAndContinue (
634+ const continued = await this . processToolCallsAndContinue (
636635 finalToolCalls ,
637636 assistantMessage ,
638637 modelOverride || null
639638 ) ;
639+ // Keep the chat "loading" state continuous across tool execution + follow-up generation.
640+ // If we didn't actually continue, make sure we clear the loading state now.
641+ if ( ! continued ) {
642+ this . setChatLoading ( assistantMessage . convId , false ) ;
643+ }
644+ return ;
640645 }
646+
647+ this . setChatLoading ( assistantMessage . convId , false ) ;
641648 } ,
642649 onError : ( error : Error ) => {
643650 this . stopStreaming ( ) ;
@@ -1408,7 +1415,7 @@ class ChatStore {
14081415 toolCallContent : string ,
14091416 sourceAssistant : DatabaseMessage ,
14101417 modelOverride ?: string | null
1411- ) : Promise < void > {
1418+ ) : Promise < boolean > {
14121419 const currentConfig = config ( ) ;
14131420
14141421 let toolCalls : ApiChatCompletionToolCall [ ] = [ ] ;
@@ -1419,17 +1426,17 @@ class ChatStore {
14191426 }
14201427 } catch ( error ) {
14211428 console . warn ( 'Failed to parse tool calls' , error ) ;
1422- return ;
1429+ return false ;
14231430 }
14241431
14251432 const relevantCalls = toolCalls . filter ( ( call ) => {
14261433 const fnName = call . function ?. name ;
14271434 return Boolean ( fnName && call . id && isToolEnabled ( fnName , currentConfig ) ) ;
14281435 } ) ;
1429- if ( relevantCalls . length === 0 ) return ;
1436+ if ( relevantCalls . length === 0 ) return false ;
14301437
14311438 const activeConv = conversationsStore . activeConversation ;
1432- if ( ! activeConv ) return ;
1439+ if ( ! activeConv ) return false ;
14331440
14341441 const toolMessages : DatabaseMessage [ ] = [ ] ;
14351442
@@ -1462,13 +1469,13 @@ class ChatStore {
14621469 }
14631470 }
14641471
1465- if ( toolMessages . length === 0 ) return ;
1472+ if ( toolMessages . length === 0 ) return false ;
14661473
14671474 // Create a new assistant message to continue the conversation
14681475 const newAssistant = await this . createAssistantMessage (
14691476 toolMessages [ toolMessages . length - 1 ] ?. id || sourceAssistant . id
14701477 ) ;
1471- if ( ! newAssistant ) return ;
1478+ if ( ! newAssistant ) return false ;
14721479
14731480 conversationsStore . addMessageToActive ( newAssistant ) ;
14741481 this . setChatLoading ( activeConv . id , true ) ;
@@ -1481,6 +1488,8 @@ class ChatStore {
14811488 undefined ,
14821489 modelOverride || null
14831490 ) ;
1491+
1492+ return true ;
14841493 }
14851494
14861495 // ─────────────────────────────────────────────────────────────────────────────
0 commit comments