fix: prevent parent tasks from auto-starting during recursive restoration

When restoring subtasks after VS Code restart, parent tasks were being
recursively restored but inadvertently started execution due to missing
startTask parameter. This caused parent tasks to interfere with child
task execution.

Solution:
- Added optional startTask parameter to createTaskWithHistoryItem (defaults to true)
- Pass startTask: false when recursively restoring parent tasks
- Parent tasks now exist in memory for reference only without starting execution

This ensures subtasks can properly complete and report back to parent
tasks after VS Code restarts.
This commit is contained in:
Roo Code 2025-11-04 23:38:39 +00:00
parent 5e3854ffd6
commit b3f421bc67

View file

@ -859,6 +859,7 @@ export class ClineProvider
public async createTaskWithHistoryItem(
historyItem: HistoryItem & { rootTask?: Task; parentTask?: Task },
startTask: boolean = true,
): Promise<Task> {
await this.removeClineFromStack()
@ -919,7 +920,8 @@ export class ClineProvider
try {
const { historyItem: parentHistoryItem } = await this.getTaskWithId(historyItem.parentTaskId)
// Recursively restore parent task (which may have its own parent)
restoredParentTask = await this.createTaskWithHistoryItem(parentHistoryItem)
// Pass startTask: false to prevent the parent from automatically starting execution
restoredParentTask = await this.createTaskWithHistoryItem(parentHistoryItem, false)
} catch (error) {
this.log(
`Failed to restore parent task ${historyItem.parentTaskId}: ${error instanceof Error ? error.message : String(error)}`,
@ -966,6 +968,7 @@ export class ClineProvider
workspacePath: historyItem.workspace,
onCreated: this.taskCreationCallback,
enableBridge: BridgeOrchestrator.isEnabled(cloudUserInfo, taskSyncEnabled),
startTask,
})
await this.addClineToStack(task)