@@ -142,7 +142,6 @@ export class Cline extends EventEmitter<ClineEvents> {
142142 private askResponse ?: ClineAskResponse
143143 private askResponseText ?: string
144144 private askResponseImages ?: string [ ]
145- private lastMessageTs ?: number
146145 // Not private since it needs to be accessible by tools
147146 consecutiveMistakeCount : number = 0
148147 consecutiveMistakeCountForApplyDiff : Map < string , number > = new Map ( )
@@ -441,7 +440,6 @@ export class Cline extends EventEmitter<ClineEvents> {
441440 // This is a new partial message, so add it with partial
442441 // state.
443442 askTs = Date . now ( )
444- this . lastMessageTs = askTs
445443 await this . addToClineMessages ( { ts : askTs , type : "ask" , ask : type , text, partial } )
446444 throw new Error ( "Current ask promise was ignored (#2)" )
447445 }
@@ -460,8 +458,6 @@ export class Cline extends EventEmitter<ClineEvents> {
460458 So in this case we must make sure that the message ts is never altered after first setting it.
461459 */
462460 askTs = lastMessage . ts
463- this . lastMessageTs = askTs
464- // lastMessage.ts = askTs
465461 lastMessage . text = text
466462 lastMessage . partial = false
467463 lastMessage . progressStatus = progressStatus
@@ -473,7 +469,6 @@ export class Cline extends EventEmitter<ClineEvents> {
473469 this . askResponseText = undefined
474470 this . askResponseImages = undefined
475471 askTs = Date . now ( )
476- this . lastMessageTs = askTs
477472 await this . addToClineMessages ( { ts : askTs , type : "ask" , ask : type , text } )
478473 }
479474 }
@@ -483,18 +478,10 @@ export class Cline extends EventEmitter<ClineEvents> {
483478 this . askResponseText = undefined
484479 this . askResponseImages = undefined
485480 askTs = Date . now ( )
486- this . lastMessageTs = askTs
487481 await this . addToClineMessages ( { ts : askTs , type : "ask" , ask : type , text } )
488482 }
489483
490- await pWaitFor ( ( ) => this . askResponse !== undefined || this . lastMessageTs !== askTs , { interval : 100 } )
491-
492- if ( this . lastMessageTs !== askTs ) {
493- // Could happen if we send multiple asks in a row i.e. with
494- // command_output. It's important that when we know an ask could
495- // fail, it is handled gracefully.
496- throw new Error ( "Current ask promise was ignored" )
497- }
484+ await pWaitFor ( ( ) => this . askResponse !== undefined , { interval : 100 } )
498485
499486 const result = { response : this . askResponse ! , text : this . askResponseText , images : this . askResponseImages }
500487 this . askResponse = undefined
@@ -537,16 +524,13 @@ export class Cline extends EventEmitter<ClineEvents> {
537524 } else {
538525 // this is a new partial message, so add it with partial state
539526 const sayTs = Date . now ( )
540- this . lastMessageTs = sayTs
541527 await this . addToClineMessages ( { ts : sayTs , type : "say" , say : type , text, images, partial } )
542528 }
543529 } else {
544530 // New now have a complete version of a previously partial message.
545531 if ( isUpdatingPreviousPartial ) {
546532 // This is the complete version of a previously partial
547533 // message, so replace the partial with the complete version.
548- this . lastMessageTs = lastMessage . ts
549- // lastMessage.ts = sayTs
550534 lastMessage . text = text
551535 lastMessage . images = images
552536 lastMessage . partial = false
@@ -559,14 +543,12 @@ export class Cline extends EventEmitter<ClineEvents> {
559543 } else {
560544 // This is a new and complete message, so add it like normal.
561545 const sayTs = Date . now ( )
562- this . lastMessageTs = sayTs
563546 await this . addToClineMessages ( { ts : sayTs , type : "say" , say : type , text, images } )
564547 }
565548 }
566549 } else {
567550 // this is a new non-partial message, so add it like normal
568551 const sayTs = Date . now ( )
569- this . lastMessageTs = sayTs
570552 await this . addToClineMessages ( { ts : sayTs , type : "say" , say : type , text, images, checkpoint } )
571553 }
572554 }
0 commit comments