@@ -9,6 +9,7 @@ import { PlanApproval } from '../PlanApproval';
99import { ToolApproval } from '../ToolApproval' ;
1010import {
1111 ACTION_NOT_PERFORMED ,
12+ INTERRUPT_REASON ,
1213 PLAN_CHECKLIST_REMINDER ,
1314 PLAN_EXECUTION_REMINDER ,
1415} from './constants' ;
@@ -33,14 +34,18 @@ export function Chat({
3334 const [ messages , setMessages ] = useState < ollama . Message [ ] > ( [ ] ) ;
3435 const [ streamingMessage , setStreamingMessage ] =
3536 useState < ollama . Message | null > ( null ) ;
37+
3638 const [ isLoading , setIsLoading ] = useState ( false ) ;
39+
3740 const [ pendingToolCall , setPendingToolCall ] =
3841 useState < ollama . ToolCall | null > ( null ) ;
3942 const [ pendingPlan , setPendingPlan ] = useState < {
4043 planContent : string ;
4144 messages : ollama . Message [ ] ;
4245 } | null > ( null ) ;
43- const [ wasInterrupted , setWasInterrupted ] = useState ( false ) ;
46+
47+ const [ interruptReason , setInterruptReason ] =
48+ useState < INTERRUPT_REASON | null > ( null ) ;
4449 const abortControllerRef = useRef < AbortController | null > ( null ) ;
4550
4651 useEffect ( ( ) => {
@@ -49,7 +54,7 @@ export function Chat({
4954 setIsLoading ( false ) ;
5055 setPendingToolCall ( null ) ;
5156 setPendingPlan ( null ) ;
52- setWasInterrupted ( false ) ;
57+ setInterruptReason ( null ) ;
5358 } , [ sessionId ] ) ;
5459
5560 const buildToolResultMessage = useCallback (
@@ -93,7 +98,7 @@ export function Chat({
9398 abortControllerRef . current = null ;
9499 setIsLoading ( false ) ;
95100 setStreamingMessage ( null ) ;
96- setWasInterrupted ( true ) ;
101+ setInterruptReason ( INTERRUPT_REASON . INTERRUPTED ) ;
97102 setMessages ( ( prev ) => [
98103 ...prev ,
99104 { role : ROLE . USER , content : TURN_ABORTED_MESSAGE } ,
@@ -477,18 +482,12 @@ export function Chat({
477482 }
478483
479484 case DECISION . REJECT : {
480- const rejectionMessage : ollama . Message = {
481- role : ROLE . USER ,
482- content : TURN_ABORTED_MESSAGE ,
483- } ;
484-
485- const newMessages = [ ...messages , rejectionMessage ] ;
486485 setMessages ( ( previousMessages ) => [
487486 ...previousMessages ,
488- rejectionMessage ,
487+ { role : ROLE . USER , content : TURN_ABORTED_MESSAGE } ,
489488 ] ) ;
490-
491- await processStream ( newMessages ) ;
489+ setIsLoading ( false ) ;
490+ setInterruptReason ( INTERRUPT_REASON . REJECTED ) ;
492491 break ;
493492 }
494493 }
@@ -498,7 +497,7 @@ export function Chat({
498497
499498 const handleSubmit = useCallback (
500499 async ( value : string ) => {
501- setWasInterrupted ( false ) ;
500+ setInterruptReason ( null ) ;
502501 const userContent = value . trim ( ) ;
503502
504503 if ( ! userContent ) {
@@ -553,9 +552,13 @@ export function Chat({
553552 />
554553 ) }
555554
556- { wasInterrupted && ! isLoading && (
555+ { interruptReason && ! isLoading && (
557556 < Box marginBottom = { 1 } >
558- < Text color = "red" > β Execution interrupted.</ Text >
557+ < Text color = "red" >
558+ { interruptReason === INTERRUPT_REASON . REJECTED
559+ ? 'β Tool call rejected.'
560+ : 'β Execution interrupted.' }
561+ </ Text >
559562 </ Box >
560563 ) }
561564
0 commit comments