-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: restore orchestrator subtask connection after VSCode restart #8622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Check both parentTask and parentTaskId in attemptCompletionTool to handle cases where the direct reference is lost - Enhance finishSubTask to restore parent task from history when not in stack - Add proper error handling and logging for parent task restoration Fixes #8621
Code Review SummaryI've reviewed the changes in this PR and the previously identified issue remains unresolved: Issues Found
RecommendationThe parent task restoration logic needs to be modified to prevent automatic resumption when restoring the task, or to properly await task initialization before calling |
…lResult and auto-approve resume when restoring parent from history
| if (!parentTask && parentTaskId) { | ||
| try { | ||
| // 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( | ||
| `[finishSubTask] Failed to restore parent task ${parentTaskId}: ${error instanceof Error ? error.message : String(error)}`, | ||
| ) | ||
| // Even if parent restoration fails, we should still show completion | ||
| // The user can manually resume the parent from task history | ||
| return | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the parent task is restored from history using createTaskWithHistoryItem, the Task constructor automatically calls resumeTaskFromHistory() in the background (without awaiting). This method will show a "resume task" dialog to the user and wait for their response. Meanwhile, completeSubtask is called on line 515 immediately after the task is created, causing a race condition where the task is simultaneously asking the user to resume while trying to add the subtask result to its conversation. This will likely result in incorrect state or unexpected behavior. The parent task restoration should use createTaskWithHistoryItem with startTask: false option to prevent automatic resumption, or you need to await the task initialization before calling completeSubtask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review complete. Found 1 critical issue that needs to be addressed before this PR can be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review complete. There is still 1 unresolved issue that needs to be addressed before this PR can be merged.
Description
This PR fixes an issue where orchestrator subtasks lose their connection to the parent orchestrator when VSCode is closed and reopened during subtask execution.
Problem
When using Orchestrator mode, if VSCode is closed while a subtask is running and then reopened, the subtask cannot return its completion result to the parent orchestrator. Users had to manually copy the subtask completion result to the parent task from the task history.
Solution
The fix ensures that the parent-child task relationship is preserved and restored even after VSCode restarts:
Enhanced parent task detection in
attemptCompletionTool: Now checks bothparentTask(direct reference) andparentTaskId(persisted ID) to handle cases where the direct reference is lost.Improved
finishSubTaskmethod inClineProvider:Changes
src/core/tools/attemptCompletionTool.ts: Check both parentTask and parentTaskIdsrc/core/webview/ClineProvider.ts: Add parent task restoration logic in finishSubTaskTesting
Fixes #8621
Important
Fixes subtask connection loss to parent orchestrator after VSCode restart by enhancing task detection and restoration logic in
attemptCompletionTool.tsandClineProvider.ts.attemptCompletionTool().parentTaskandparentTaskIdto restore task connection.finishSubTask()inClineProviderto restore parent task from history if not in stack.attemptCompletionTool.ts: Enhanced parent task detection logic.ClineProvider.ts: Added logic for parent task restoration and handling restoration failures.This description was created by
for fe7f93c. You can customize this summary. It will automatically update as commits are pushed.