diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 294c423c87..dadce608a7 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -142,7 +142,6 @@ export class Cline extends EventEmitter { private askResponse?: ClineAskResponse private askResponseText?: string private askResponseImages?: string[] - private lastMessageTs?: number // Not private since it needs to be accessible by tools consecutiveMistakeCount: number = 0 consecutiveMistakeCountForApplyDiff: Map = new Map() @@ -441,7 +440,6 @@ export class Cline extends EventEmitter { // This is a new partial message, so add it with partial // state. askTs = Date.now() - this.lastMessageTs = askTs await this.addToClineMessages({ ts: askTs, type: "ask", ask: type, text, partial }) throw new Error("Current ask promise was ignored (#2)") } @@ -460,8 +458,6 @@ export class Cline extends EventEmitter { So in this case we must make sure that the message ts is never altered after first setting it. */ askTs = lastMessage.ts - this.lastMessageTs = askTs - // lastMessage.ts = askTs lastMessage.text = text lastMessage.partial = false lastMessage.progressStatus = progressStatus @@ -473,7 +469,6 @@ export class Cline extends EventEmitter { this.askResponseText = undefined this.askResponseImages = undefined askTs = Date.now() - this.lastMessageTs = askTs await this.addToClineMessages({ ts: askTs, type: "ask", ask: type, text }) } } @@ -483,18 +478,10 @@ export class Cline extends EventEmitter { this.askResponseText = undefined this.askResponseImages = undefined askTs = Date.now() - this.lastMessageTs = askTs await this.addToClineMessages({ ts: askTs, type: "ask", ask: type, text }) } - await pWaitFor(() => this.askResponse !== undefined || this.lastMessageTs !== askTs, { interval: 100 }) - - if (this.lastMessageTs !== askTs) { - // Could happen if we send multiple asks in a row i.e. with - // command_output. It's important that when we know an ask could - // fail, it is handled gracefully. - throw new Error("Current ask promise was ignored") - } + await pWaitFor(() => this.askResponse !== undefined, { interval: 100 }) const result = { response: this.askResponse!, text: this.askResponseText, images: this.askResponseImages } this.askResponse = undefined @@ -537,7 +524,6 @@ export class Cline extends EventEmitter { } else { // this is a new partial message, so add it with partial state const sayTs = Date.now() - this.lastMessageTs = sayTs await this.addToClineMessages({ ts: sayTs, type: "say", say: type, text, images, partial }) } } else { @@ -545,8 +531,6 @@ export class Cline extends EventEmitter { if (isUpdatingPreviousPartial) { // This is the complete version of a previously partial // message, so replace the partial with the complete version. - this.lastMessageTs = lastMessage.ts - // lastMessage.ts = sayTs lastMessage.text = text lastMessage.images = images lastMessage.partial = false @@ -559,14 +543,12 @@ export class Cline extends EventEmitter { } else { // This is a new and complete message, so add it like normal. const sayTs = Date.now() - this.lastMessageTs = sayTs await this.addToClineMessages({ ts: sayTs, type: "say", say: type, text, images }) } } } else { // this is a new non-partial message, so add it like normal const sayTs = Date.now() - this.lastMessageTs = sayTs await this.addToClineMessages({ ts: sayTs, type: "say", say: type, text, images, checkpoint }) } }