Skip to content

Commit 87f6ac4

Browse files
author
ShayBC
committed
pass last message of a subtask to parent task
1 parent c3c3874 commit 87f6ac4

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/core/Cline.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -490,26 +490,22 @@ export class Cline {
490490
])
491491
}
492492

493-
async resumePausedTask() {
493+
async resumePausedTask(lastMessage?: string) {
494494
// release this Cline instance from paused state
495495
this.isPaused = false
496496

497-
// Clear any existing ask state and simulate a completed ask response
498-
// this.askResponse = "messageResponse";
499-
// this.askResponseText = "Sub Task finished Successfully!\nthere is no need to perform this task again, please continue to the next task.";
500-
// this.askResponseImages = undefined;
501-
// this.lastMessageTs = Date.now();
502-
503497
// This adds the completion message to conversation history
504-
await this.say(
505-
"text",
506-
"Sub Task finished Successfully!\nthere is no need to perform this task again, please continue to the next task.",
507-
)
508-
509-
// this.userMessageContent.push({
510-
// type: "text",
511-
// text: `${"Result:\\n\\nSub Task finished Successfully!\nthere is no need to perform this task again, please continue to the next task."}`,
512-
// })
498+
await this.say("text", `new_task finished successfully! ${lastMessage ?? "Please continue to the next task."}`)
499+
500+
await this.addToApiConversationHistory({
501+
role: "assistant",
502+
content: [
503+
{
504+
type: "text",
505+
text: `new_task finished successfully! ${lastMessage ?? "Please continue to the next task."}`,
506+
},
507+
],
508+
})
513509

514510
try {
515511
// Resume parent task
@@ -2699,7 +2695,7 @@ export class Cline {
26992695
await this.say("completion_result", result, undefined, false)
27002696
if (this.isSubTask) {
27012697
// tell the provider to remove the current subtask and resume the previous task in the stack
2702-
this.providerRef.deref()?.finishSubTask()
2698+
this.providerRef.deref()?.finishSubTask(lastMessage?.text)
27032699
}
27042700
}
27052701

@@ -2720,7 +2716,7 @@ export class Cline {
27202716
await this.say("completion_result", result, undefined, false)
27212717
if (this.isSubTask) {
27222718
// tell the provider to remove the current subtask and resume the previous task in the stack
2723-
this.providerRef.deref()?.finishSubTask()
2719+
this.providerRef.deref()?.finishSubTask(lastMessage?.text)
27242720
}
27252721
}
27262722

src/core/webview/ClineProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
218218
// remove the current task/cline instance (at the top of the stack), ao this task is finished
219219
// and resume the previous task/cline instance (if it exists)
220220
// this is used when a sub task is finished and the parent task needs to be resumed
221-
async finishSubTask() {
221+
async finishSubTask(lastMessage?: string) {
222222
// remove the last cline instance from the stack (this is the finished sub task)
223223
await this.removeClineFromStack()
224224
// resume the last cline instance in the stack (if it exists - this is the 'parnt' calling task)
225-
this.getCurrentCline()?.resumePausedTask()
225+
this.getCurrentCline()?.resumePausedTask(lastMessage)
226226
}
227227

228228
/*

0 commit comments

Comments
 (0)