@@ -838,6 +838,7 @@ interface StreamingContext {
838838 doneEventCount : number
839839 streamComplete ?: boolean
840840 wasAborted ?: boolean
841+ suppressContinueOption ?: boolean
841842 /** Track active subagent sessions by parent tool call ID */
842843 subAgentParentToolCallId ?: string
843844 /** Track subagent content per parent tool call */
@@ -2104,6 +2105,7 @@ const initialState = {
21042105 suppressAutoSelect : false ,
21052106 autoAllowedTools : [ ] as string [ ] ,
21062107 messageQueue : [ ] as import ( './types' ) . QueuedMessage [ ] ,
2108+ suppressAbortContinueOption : false ,
21072109}
21082110
21092111export const useCopilotStore = create < CopilotStore > ( ) (
@@ -2612,10 +2614,11 @@ export const useCopilotStore = create<CopilotStore>()(
26122614 } ,
26132615
26142616 // Abort streaming
2615- abortMessage : ( ) => {
2617+ abortMessage : ( options ?: { suppressContinueOption ?: boolean } ) => {
26162618 const { abortController, isSendingMessage, messages } = get ( )
26172619 if ( ! isSendingMessage || ! abortController ) return
2618- set ( { isAborting : true } )
2620+ const suppressContinueOption = options ?. suppressContinueOption === true
2621+ set ( { isAborting : true , suppressAbortContinueOption : suppressContinueOption } )
26192622 try {
26202623 abortController . abort ( )
26212624 stopStreamingUpdates ( )
@@ -2626,15 +2629,17 @@ export const useCopilotStore = create<CopilotStore>()(
26262629 ?. filter ( ( b ) => b . type === 'text' )
26272630 . map ( ( b : any ) => b . content )
26282631 . join ( '' ) || ''
2629- const nextContentBlocks = appendContinueOptionBlock (
2630- lastMessage . contentBlocks ? [ ... lastMessage . contentBlocks ] : [ ]
2631- )
2632+ const nextContentBlocks = suppressContinueOption
2633+ ? lastMessage . contentBlocks ?? [ ]
2634+ : appendContinueOptionBlock ( lastMessage . contentBlocks ? [ ... lastMessage . contentBlocks ] : [ ] )
26322635 set ( ( state ) => ( {
26332636 messages : state . messages . map ( ( msg ) =>
26342637 msg . id === lastMessage . id
26352638 ? {
26362639 ...msg ,
2637- content : appendContinueOption ( textContent . trim ( ) || 'Message was aborted' ) ,
2640+ content : suppressContinueOption
2641+ ? textContent . trim ( ) || 'Message was aborted'
2642+ : appendContinueOption ( textContent . trim ( ) || 'Message was aborted' ) ,
26382643 contentBlocks : nextContentBlocks ,
26392644 }
26402645 : msg
@@ -3042,6 +3047,11 @@ export const useCopilotStore = create<CopilotStore>()(
30423047 const { abortController } = get ( )
30433048 if ( abortController ?. signal . aborted ) {
30443049 context . wasAborted = true
3050+ const { suppressAbortContinueOption } = get ( )
3051+ context . suppressContinueOption = suppressAbortContinueOption === true
3052+ if ( suppressAbortContinueOption ) {
3053+ set ( { suppressAbortContinueOption : false } )
3054+ }
30453055 context . pendingContent = ''
30463056 finalizeThinkingBlock ( context )
30473057 stopStreamingUpdates ( )
@@ -3166,7 +3176,7 @@ export const useCopilotStore = create<CopilotStore>()(
31663176 : block
31673177 )
31683178 }
3169- if ( context . wasAborted ) {
3179+ if ( context . wasAborted && ! context . suppressContinueOption ) {
31703180 sanitizedContentBlocks = appendContinueOptionBlock ( sanitizedContentBlocks )
31713181 }
31723182
@@ -3179,7 +3189,7 @@ export const useCopilotStore = create<CopilotStore>()(
31793189 }
31803190
31813191 const finalContent = stripTodoTags ( context . accumulatedContent . toString ( ) )
3182- const finalContentWithOptions = context . wasAborted
3192+ const finalContentWithOptions = context . wasAborted && ! context . suppressContinueOption
31833193 ? appendContinueOption ( finalContent )
31843194 : finalContent
31853195 set ( ( state ) => ( {
@@ -3704,7 +3714,7 @@ export const useCopilotStore = create<CopilotStore>()(
37043714 // If currently sending, abort and send this one
37053715 const { isSendingMessage } = get ( )
37063716 if ( isSendingMessage ) {
3707- get ( ) . abortMessage ( )
3717+ get ( ) . abortMessage ( { suppressContinueOption : true } )
37083718 // Wait a tick for abort to complete
37093719 await new Promise ( ( resolve ) => setTimeout ( resolve , 50 ) )
37103720 }
0 commit comments