mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix(orchestrator): return child attempt_completion result via pushToolResult and auto-approve resume when restoring parent from history
This commit is contained in:
parent
fef9bb1d70
commit
fe7f93cffe
2 changed files with 25 additions and 0 deletions
|
|
@ -104,6 +104,9 @@ export async function attemptCompletionTool(
|
|||
return
|
||||
}
|
||||
|
||||
// Return the completion content as a tool result for the child task before finishing
|
||||
pushToolResult(formatResponse.toolResult(result))
|
||||
|
||||
// tell the provider to remove the current subtask and resume the previous task in the stack
|
||||
await cline.providerRef.deref()?.finishSubTask(result)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -485,6 +485,7 @@ export class ClineProvider
|
|||
// Get the current task before removing it from the stack
|
||||
const currentTask = this.getCurrentTask()
|
||||
const parentTaskId = currentTask?.parentTaskId
|
||||
let didRestoreParentFromHistory = false
|
||||
|
||||
// Remove the last cline instance from the stack (this is the finished
|
||||
// subtask).
|
||||
|
|
@ -500,6 +501,7 @@ export class ClineProvider
|
|||
// Restore the parent task from history
|
||||
const { historyItem } = await this.getTaskWithId(parentTaskId)
|
||||
parentTask = await this.createTaskWithHistoryItem(historyItem)
|
||||
didRestoreParentFromHistory = true
|
||||
this.log(`[finishSubTask] Restored parent task ${parentTaskId} from history to receive subtask result`)
|
||||
} catch (error) {
|
||||
this.log(
|
||||
|
|
@ -513,6 +515,26 @@ export class ClineProvider
|
|||
|
||||
// Resume the parent task with the subtask result
|
||||
await parentTask?.completeSubtask(lastMessage)
|
||||
|
||||
// If the parent was restored from history, auto-approve the resume prompt so execution continues
|
||||
if (didRestoreParentFromHistory && parentTask) {
|
||||
try {
|
||||
await pWaitFor(
|
||||
() => {
|
||||
const ask = parentTask!.taskAsk
|
||||
return !!ask && (ask.ask === "resume_task" || ask.ask === "resume_completed_task")
|
||||
},
|
||||
{ timeout: 3000 },
|
||||
).catch(() => undefined)
|
||||
parentTask.approveAsk()
|
||||
} catch (error) {
|
||||
this.log(
|
||||
`[finishSubTask] Auto-approve resume failed for parent ${parentTask.taskId}: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Pending Edit Operations Management
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue