@@ -977,17 +977,7 @@ export class Task extends EventEmitter<ClineEvents> {
977977 await this . initiateTaskLoop ( newUserContent )
978978 }
979979
980- public async abortTask ( isAbandoned = false ) {
981- console . log ( `[subtasks] aborting task ${ this . taskId } .${ this . instanceId } ` )
982-
983- // Will stop any autonomously running promises.
984- if ( isAbandoned ) {
985- this . abandoned = true
986- }
987-
988- this . abort = true
989- this . emit ( "taskAborted" )
990-
980+ public dispose ( ) : void {
991981 // Stop waiting for child task completion.
992982 if ( this . pauseInterval ) {
993983 clearInterval ( this . pauseInterval )
@@ -1004,10 +994,25 @@ export class Task extends EventEmitter<ClineEvents> {
1004994
1005995 // If we're not streaming then `abortStream` (which reverts the diff
1006996 // view changes) won't be called, so we need to revert the changes here.
997+ // This check should ideally be more robust or part of abortStream's logic.
1007998 if ( this . isStreaming && this . diffViewProvider . isEditing ) {
1008- await this . diffViewProvider . revertChanges ( )
999+ this . diffViewProvider . revertChanges ( ) . catch ( console . error )
1000+ }
1001+ }
1002+
1003+ public async abortTask ( isAbandoned = false ) {
1004+ console . log ( `[subtasks] aborting task ${ this . taskId } .${ this . instanceId } ` )
1005+
1006+ // Will stop any autonomously running promises.
1007+ if ( isAbandoned ) {
1008+ this . abandoned = true
10091009 }
10101010
1011+ this . abort = true
1012+ this . emit ( "taskAborted" )
1013+
1014+ this . dispose ( ) // Call the centralized dispose method
1015+
10111016 // Save the countdown message in the automatic retry or other content.
10121017 await this . saveClineMessages ( )
10131018 }
0 commit comments