From 87f6ac4d06083a895aadc5c15ffb1532eb70ba9e Mon Sep 17 00:00:00 2001 From: ShayBC Date: Sun, 23 Feb 2025 05:15:23 +0200 Subject: [PATCH] pass last message of a subtask to parent task --- src/core/Cline.ts | 30 +++++++++++++----------------- src/core/webview/ClineProvider.ts | 4 ++-- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 134961129c..54de357d46 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -490,26 +490,22 @@ export class Cline { ]) } - async resumePausedTask() { + async resumePausedTask(lastMessage?: string) { // release this Cline instance from paused state this.isPaused = false - // Clear any existing ask state and simulate a completed ask response - // this.askResponse = "messageResponse"; - // this.askResponseText = "Sub Task finished Successfully!\nthere is no need to perform this task again, please continue to the next task."; - // this.askResponseImages = undefined; - // this.lastMessageTs = Date.now(); - // This adds the completion message to conversation history - await this.say( - "text", - "Sub Task finished Successfully!\nthere is no need to perform this task again, please continue to the next task.", - ) + await this.say("text", `new_task finished successfully! ${lastMessage ?? "Please continue to the next task."}`) - // this.userMessageContent.push({ - // type: "text", - // text: `${"Result:\\n\\nSub Task finished Successfully!\nthere is no need to perform this task again, please continue to the next task."}`, - // }) + await this.addToApiConversationHistory({ + role: "assistant", + content: [ + { + type: "text", + text: `new_task finished successfully! ${lastMessage ?? "Please continue to the next task."}`, + }, + ], + }) try { // Resume parent task @@ -2699,7 +2695,7 @@ export class Cline { await this.say("completion_result", result, undefined, false) if (this.isSubTask) { // tell the provider to remove the current subtask and resume the previous task in the stack - this.providerRef.deref()?.finishSubTask() + this.providerRef.deref()?.finishSubTask(lastMessage?.text) } } @@ -2720,7 +2716,7 @@ export class Cline { await this.say("completion_result", result, undefined, false) if (this.isSubTask) { // tell the provider to remove the current subtask and resume the previous task in the stack - this.providerRef.deref()?.finishSubTask() + this.providerRef.deref()?.finishSubTask(lastMessage?.text) } } diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index d690efa9dd..b00c744ff6 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -218,11 +218,11 @@ export class ClineProvider implements vscode.WebviewViewProvider { // remove the current task/cline instance (at the top of the stack), ao this task is finished // and resume the previous task/cline instance (if it exists) // this is used when a sub task is finished and the parent task needs to be resumed - async finishSubTask() { + async finishSubTask(lastMessage?: string) { // remove the last cline instance from the stack (this is the finished sub task) await this.removeClineFromStack() // resume the last cline instance in the stack (if it exists - this is the 'parnt' calling task) - this.getCurrentCline()?.resumePausedTask() + this.getCurrentCline()?.resumePausedTask(lastMessage) } /*