@@ -3090,7 +3090,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
30903090 } catch ( error ) {
30913091 console . error ( "[Task#startTask] ignored-disabled-tools notice failed:" , error )
30923092 }
3093- this . isInitialized = true
3093+ this . markInitialized ( )
30943094
30953095 const imageBlocks : Anthropic . ImageBlockParam [ ] = formatResponse . imageBlocks ( images )
30963096
@@ -3216,7 +3216,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
32163216 }
32173217
32183218 if ( this . pendingAction ) {
3219- this . isInitialized = true
3219+ this . markInitialized ( )
32203220 await this . resumePendingTaskAction ( this . pendingAction )
32213221 return
32223222 }
@@ -3237,7 +3237,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
32373237 askType = "resume_task"
32383238 }
32393239
3240- this . isInitialized = true
3240+ this . markInitialized ( )
32413241
32423242 const { response, text, images } = await this . ask ( askType ) // Calls `postStateToWebview`.
32433243
@@ -3564,11 +3564,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
35643564 }
35653565
35663566 public abortTask ( isAbandoned = false ) : Promise < void > {
3567- if ( isAbandoned ) {
3568- this . abandoned = true
3569- }
3570-
3571- this . abort = true
3567+ this . requestAbort ( isAbandoned )
35723568 this . cancelAssistantMessagePersistence ( )
35733569 this . abortPromise ??= this . abortTaskOnce ( )
35743570 return this . abortPromise
@@ -3656,13 +3652,13 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
36563652 }
36573653
36583654 // A task being disposed is no longer serving requests: set the same
3659- // cancellation state `abortTask()` sets, synchronously before the aborts
3655+ // abort latch `abortTask()` sets (disposal never sets abandoned) , synchronously before the aborts
36603656 // below, so the request-construction guard (`abort || abandoned` in
36613657 // attemptApiRequest) and the outer loop's `abort` checks observe disposal
36623658 // even when it lands before any explicit cancel. Without this, only the
36633659 // signals below are cancelled and a request already past those checks
36643660 // could still build tools and call `createMessage()`.
3665- this . abort = true
3661+ this . requestDispose ( )
36663662
36673663 // Cancel any in-progress HTTP request
36683664 try {
@@ -3762,7 +3758,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
37623758 *
37633759 * This method:
37643760 * - Clears any pending ask states
3765- * - Resets abort and streaming flags
3761+ * - Resets streaming flags
37663762 * - Ensures next API call includes full context
37673763 * - Immediately continues task loop without user interaction
37683764 */
@@ -3772,10 +3768,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
37723768 this . resumableAsk = undefined
37733769 this . interactiveAsk = undefined
37743770
3775- // Reset abort and streaming state to ensure clean continuation
3776- this . abort = false
3777- this . abandoned = false
3778- this . abortReason = undefined
3771+ // Reset streaming state to ensure clean continuation
37793772 this . didFinishAbortingStream = false
37803773 this . isStreaming = false
37813774 this . isWaitingForFirstChunk = false
@@ -3784,7 +3777,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
37843777 this . skipPrevResponseIdOnce = true
37853778
37863779 // Mark as initialized and active
3787- this . isInitialized = true
3780+ this . markInitialized ( )
37883781 this . emit ( RooCodeEventName . TaskActive , this . taskId )
37893782
37903783 // Load conversation history if not already loaded
@@ -4665,8 +4658,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
46654658 await abortStream ( cancelReason , streamingFailedMessage )
46664659
46674660 if ( this . abort ) {
4668- // ??= keeps the first reason; a cancel can land during abortStream after cancelReason was already computed.
4669- this . abortReason ??= "user_cancelled"
4661+ // A cancel can land during abortStream after cancelReason was computed; setAbortReason keeps the first reason .
4662+ this . setAbortReason ( "user_cancelled" )
46704663 await this . abortTask ( )
46714664 } else if ( error instanceof OutputTokenLimitError ) {
46724665 // Truncation repeats on an identical request, so never auto-retry it
@@ -4701,7 +4694,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
47014694 console . log (
47024695 `[Task#${ this . taskId } .${ this . instanceId } ] Task aborted during mid-stream retry backoff` ,
47034696 )
4704- this . abortReason ??= "user_cancelled"
4697+ this . setAbortReason ( "user_cancelled" )
47054698 await this . abortTask ( )
47064699 break
47074700 }
0 commit comments