Skip to content

Commit 639cb78

Browse files
committed
fix: await updateClineMessage calls to prevent duplicate reasoning blocks
- Add await to all updateClineMessage calls in Task.ts - Fixes race condition where reasoning blocks were rendered multiple times - Ensures message updates complete before proceeding with next update
1 parent a879f24 commit 639cb78

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core/task/Task.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export class Task extends EventEmitter<ClineEvents> {
450450
// data or one whole message at a time so ignore partial for
451451
// saves, and only post parts of partial message instead of
452452
// whole array in new listener.
453-
this.updateClineMessage(lastMessage)
453+
await this.updateClineMessage(lastMessage)
454454
throw new Error("Current ask promise was ignored (#1)")
455455
} else {
456456
// This is a new partial message, so add it with partial
@@ -486,7 +486,7 @@ export class Task extends EventEmitter<ClineEvents> {
486486
lastMessage.progressStatus = progressStatus
487487
lastMessage.isProtected = isProtected
488488
await this.saveClineMessages()
489-
this.updateClineMessage(lastMessage)
489+
await this.updateClineMessage(lastMessage)
490490
} else {
491491
// This is a new and complete message, so add it like normal.
492492
this.askResponse = undefined
@@ -636,7 +636,7 @@ export class Task extends EventEmitter<ClineEvents> {
636636
lastMessage.images = images
637637
lastMessage.partial = partial
638638
lastMessage.progressStatus = progressStatus
639-
this.updateClineMessage(lastMessage)
639+
await this.updateClineMessage(lastMessage)
640640
} else {
641641
// This is a new partial message, so add it with partial state.
642642
const sayTs = Date.now()
@@ -674,7 +674,7 @@ export class Task extends EventEmitter<ClineEvents> {
674674
await this.saveClineMessages()
675675

676676
// More performant than an entire `postStateToWebview`.
677-
this.updateClineMessage(lastMessage)
677+
await this.updateClineMessage(lastMessage)
678678
} else {
679679
// This is a new and complete message, so add it like normal.
680680
const sayTs = Date.now()

0 commit comments

Comments
 (0)