@@ -183,6 +183,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
183183 const [ primaryButtonText , setPrimaryButtonText ] = useState < string | undefined > ( undefined )
184184 const [ secondaryButtonText , setSecondaryButtonText ] = useState < string | undefined > ( undefined )
185185 const [ didClickCancel , setDidClickCancel ] = useState ( false )
186+ const [ terminationClickCount , setTerminationClickCount ] = useState ( 0 )
186187 const virtuosoRef = useRef < VirtuosoHandle > ( null )
187188 const [ expandedRows , setExpandedRows ] = useState < Record < number , boolean > > ( { } )
188189 const prevExpandedRowsRef = useRef < Record < number , boolean > > ( )
@@ -412,6 +413,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
412413 setPrimaryButtonText ( t ( "chat:resumeTask.title" ) )
413414 setSecondaryButtonText ( t ( "chat:terminate.title" ) )
414415 setDidClickCancel ( false ) // special case where we reset the cancel button state
416+ setTerminationClickCount ( 0 ) // Reset termination click count when resuming
415417 break
416418 case "resume_completed_task" :
417419 setSendingDisabled ( false )
@@ -470,6 +472,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
470472 everVisibleMessagesTsRef . current . clear ( ) // Clear for new task
471473 setCurrentFollowUpTs ( null ) // Clear follow-up answered state for new task
472474 setIsCondensing ( false ) // Reset condensing state when switching tasks
475+ setTerminationClickCount ( 0 ) // Reset termination click count for new task
473476 // Note: sendingDisabled is not reset here as it's managed by message effects
474477
475478 // Clear any pending auto-approval timeout from previous task
@@ -730,7 +733,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
730733 const trimmedInput = text ?. trim ( )
731734
732735 if ( isStreaming ) {
733- vscode . postMessage ( { type : "cancelTask" } )
736+ const newClickCount = terminationClickCount + 1
737+ setTerminationClickCount ( newClickCount )
738+ vscode . postMessage ( { type : "cancelTask" , clickCount : newClickCount } )
734739 setDidClickCancel ( true )
735740 return
736741 }
@@ -769,7 +774,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
769774 setClineAsk ( undefined )
770775 setEnableButtons ( false )
771776 } ,
772- [ clineAsk , startNewTask , isStreaming ] ,
777+ [ clineAsk , startNewTask , isStreaming , terminationClickCount ] ,
773778 )
774779
775780 const { info : model } = useSelectedModel ( apiConfiguration )
0 commit comments