Skip to content

Commit ed2edcf

Browse files
committed
More progress
1 parent a89faa5 commit ed2edcf

File tree

4 files changed

+133
-1004
lines changed

4 files changed

+133
-1004
lines changed

src/core/task/Task.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ export type TaskEvents = {
108108
taskCompleted: [taskId: string, tokenUsage: TokenUsage, toolUsage: ToolUsage]
109109
taskTokenUsageUpdated: [taskId: string, tokenUsage: TokenUsage]
110110
taskToolFailed: [taskId: string, tool: ToolName, error: string]
111-
taskBusy: [taskId: string]
112-
taskFree: [taskId: string]
113111
}
114112

115113
export type TaskEventHandlers = {
@@ -712,7 +710,9 @@ export class Task extends EventEmitter<TaskEvents> {
712710
await this.addToClineMessages({ ts: askTs, type: "ask", ask: type, text, isProtected })
713711
}
714712

713+
console.log(`[Task#${this.taskId}] pWaitFor askResponse...`, type)
715714
await pWaitFor(() => this.askResponse !== undefined || this.lastMessageTs !== askTs, { interval: 100 })
715+
console.log(`[Task#${this.taskId}] pWaitFor askResponse done!`, this.askResponse)
716716

717717
if (this.lastMessageTs !== askTs) {
718718
// Could happen if we send multiple asks in a row i.e. with
@@ -1019,7 +1019,7 @@ export class Task extends EventEmitter<TaskEvents> {
10191019
const lastClineMessage = this.clineMessages
10201020
.slice()
10211021
.reverse()
1022-
.find((m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task")) // could be multiple resume tasks
1022+
.find((m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task")) // Could be multiple resume tasks.
10231023

10241024
let askType: ClineAsk
10251025
if (lastClineMessage?.ask === "completion_result") {
@@ -1030,9 +1030,11 @@ export class Task extends EventEmitter<TaskEvents> {
10301030

10311031
this.isInitialized = true
10321032

1033-
const { response, text, images } = await this.ask(askType) // calls poststatetowebview
1033+
const { response, text, images } = await this.ask(askType) // Calls `postStateToWebview`.
1034+
10341035
let responseText: string | undefined
10351036
let responseImages: string[] | undefined
1037+
10361038
if (response === "messageResponse") {
10371039
await this.say("user_feedback", text, images)
10381040
responseText = text
@@ -1572,7 +1574,6 @@ export class Task extends EventEmitter<TaskEvents> {
15721574
let assistantMessage = ""
15731575
let reasoningMessage = ""
15741576
this.isStreaming = true
1575-
this.emit("taskBusy", this.taskId)
15761577

15771578
try {
15781579
for await (const chunk of stream) {
@@ -1679,7 +1680,6 @@ export class Task extends EventEmitter<TaskEvents> {
16791680
}
16801681
} finally {
16811682
this.isStreaming = false
1682-
this.emit("taskFree", this.taskId)
16831683
}
16841684

16851685
if (inputTokens > 0 || outputTokens > 0 || cacheWriteTokens > 0 || cacheReadTokens > 0) {

src/core/tools/attemptCompletionTool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ export async function attemptCompletionTool(
4141
if (preventCompletionWithOpenTodos && hasIncompleteTodos) {
4242
cline.consecutiveMistakeCount++
4343
cline.recordToolError("attempt_completion")
44+
4445
pushToolResult(
4546
formatResponse.toolError(
4647
"Cannot complete task while there are incomplete todos. Please finish all todos before attempting completion.",
4748
),
4849
)
50+
4951
return
5052
}
5153

@@ -72,7 +74,7 @@ export async function attemptCompletionTool(
7274
await cline.ask("command", removeClosingTag("command", command), block.partial).catch(() => {})
7375
}
7476
} else {
75-
// no command, still outputting partial result
77+
// No command, still outputting partial result
7678
await cline.say("completion_result", removeClosingTag("result", result), undefined, block.partial)
7779
}
7880
return

0 commit comments

Comments
 (0)