Skip to content

Commit ee812fb

Browse files
committed
Fixes #4881: Preserve subtask completion state during task resumption
- Modified task resumption logic in Task.ts to detect completed subtasks - Added check for finishTask tool completion when determining resume type - Ensures completed subtasks show 'Start New Task' button instead of 'Resume Task' - Prevents unnecessary re-execution of completed subtasks and token costs
1 parent 2e2f83b commit ee812fb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/core/task/Task.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,27 @@ export class Task extends EventEmitter<ClineEvents> {
812812
if (lastClineMessage?.ask === "completion_result") {
813813
askType = "resume_completed_task"
814814
} else {
815-
askType = "resume_task"
815+
// Check if this is a completed subtask by looking for finishTask tool completion
816+
const isCompletedSubtask = this.clineMessages
817+
.slice()
818+
.reverse()
819+
.some((m) => {
820+
if (m.type === "ask" && m.ask === "tool" && m.text) {
821+
try {
822+
const tool = JSON.parse(m.text)
823+
return tool.tool === "finishTask"
824+
} catch {
825+
return false
826+
}
827+
}
828+
return false
829+
})
830+
831+
if (isCompletedSubtask && this.parentTask) {
832+
askType = "resume_completed_task"
833+
} else {
834+
askType = "resume_task"
835+
}
816836
}
817837

818838
this.isInitialized = true

0 commit comments

Comments
 (0)