|
|
@@ -142,7 +142,6 @@ export class Cline extends EventEmitter<ClineEvents> {
|
|
|
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<string, number> = new Map()
|
|
|
@@ -441,7 +440,6 @@ export class Cline extends EventEmitter<ClineEvents> {
|
|
|
// 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<ClineEvents> {
|
|
|
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<ClineEvents> {
|
|
|
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<ClineEvents> {
|
|
|
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<ClineEvents> {
|
|
|
} 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<ClineEvents> {
|
|
|
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<ClineEvents> {
|
|
|
} 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 })
|
|
|
}
|
|
|
}
|