-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: restore parent task switching and strengthen subtask completion flow (issue #8081) #9086
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
fix: restore parent task switching and strengthen subtask completion flow (issue #8081) #9086
Conversation
- Add SubtaskMetadata schema to history.ts for validating parent-child relationships - Implement subtask metadata persistence in Task to track parentTaskId, depth, and return requirements - Add verifyParentExists() method to check parent task accessibility before completion - Enhance attemptCompletionTool with parent verification and orphaned subtask handling - Make subtask_result injection non-interactive to avoid interfering with resume asks - Add subtask metadata tracking test suite Ensures subtasks maintain proper parent relationships across VSCode restarts and handle edge cases like missing/deleted parents gracefully.
Re-review complete. All previously identified issues have been resolved. No new issues found. Issues Resolved:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Fixes identified by @roomote bot code review: 1. ClineProvider.finishSubTask() - Unhandled Promise Rejection - Added .catch handler to createTaskWithHistoryItem() restore call - Prevents silent failures when parent task initialization fails - Logs error without breaking subtask completion flow - Location: src/core/webview/ClineProvider.ts:503-506 2. ClineProvider.createTaskWithHistoryItem() - Missing Parameter - Added optional 'options' parameter with viewOnly flag - Fixed undefined reference to options.viewOnly (was options?.viewOnly) - Ensures backward compatibility with existing callers - Location: src/core/webview/ClineProvider.ts:982-984,1117 3. attemptCompletionTool() - Time-of-Check-Time-of-Use Race - Removed pre-verification of parent existence (lines 98-121) - Delegates parent validation to ClineProvider.finishSubTask() - finishSubTask() already handles missing parents gracefully - Eliminates race where parent deleted between check and restore - Location: src/core/tools/attemptCompletionTool.ts:98-139 Impact: Improves reliability of resumed subtask → parent return flow Tests: 46 tests passing (finishSubTask + metadata tracking) Risk: Low - defensive programming, no breaking changes References: roomote feedback on PR fix/8081-subtask-parent-return-v2
|
@Mnehmos Thank you for the work in PR 9086. After comparing both branches, PR 9090 delivers the same delegation resume improvement with a smaller and more focused scope. It keeps the changes limited to the backend, avoids UI and localization updates, and provides a clearer resume path. |
Most of y'all know me. I dont code, so I'd appreciate a review by an expert as well please. My tests work both manual and automated.
Related GitHub Issue
Closes: #8081
Roo Code Task Context (Optional)
N/A - Developed using Roo Code's Orchestrator mode with multi-agent collaboration.
Description
This PR fixes a recurring regression where subtasks completing after interruption fail to properly return control to parent agents, leaving the webview stuck displaying the subtask instead of switching to the resumed parent task.
Key Implementation Details:
UI Navigation Fix: Added explicit
chatButtonClickedaction inClineProvider.finishSubTask()after state posting. The previous implementation only calledpostStateToWebview()which broadcasts state changes but doesn't trigger UI navigation. This mirrors the pattern used inshowTaskWithId()for consistency.Subtask Metadata Persistence: Implemented a new
SubtaskMetadataschema (Zod-validated) that stores parent-child relationships in message metadata. This ensures task hierarchy survives VSCode restarts and enables proper parent restoration after interruptions.Enhanced Error Handling: Added
verifyParentExists()method to check parent accessibility before completion, gracefully handling orphaned subtasks. Also added race tolerance for resume asks by treating ignored promises as implicit approval.Non-Interactive Injection: Made
subtask_resultmessage injection non-interactive to avoid interfering with pending resume asks, preventing timing conflicts.Reviewers should pay attention to:
ClineProvider.ts: The UI navigation action that fixes the core regressionTask.ts: Metadata persistence implementationTask.ts: Resume ask race tolerance handlingClineProvider.spec.ts(lines 210-224): Proper tuple return fromTask.create()Test Procedure
Automated Testing:
cd src npx vitest run core/webview/__tests__/ClineProvider.finishSubTask.spec.ts npx vitest run core/webview/__tests__/ClineProvider.spec.ts npx vitest run __tests__/subtask-metadata-tracking.test.tsTest Results:
ClineProvider.finishSubTask.spec.ts: 98 tests passingClineProvider.spec.ts: 92 passed, 6 skippedsubtask-metadata-tracking.test.ts: All tests passingManual Testing Procedure:
new_tasktoolattempt_completionEdge Case Testing:
Pre-Submission Checklist
Screenshots / Videos
Before (Bug):
After (Fixed):
(https://vimeo.com/1134407282?share=copy&fl=sv&fe=ci)
Documentation Updates
Rationale: This is a bug fix that restores expected behavior. The feature (subtask completion returning to parent) already exists and is documented; this PR simply fixes the regression where the UI wasn't properly switching views.
Additional Notes
Backward Compatibility:
Performance Impact:
Code Quality:
showTaskWithId()navigation pattern)Related Changes:
Task.create()mock in test suite to return proper tuple structureGet in Touch
Discord: @Mnehmos
Important
Fixes subtask completion flow to ensure UI returns to parent task, adds metadata persistence, and enhances error handling in
ClineProviderandTaskclasses.ClineProvider.finishSubTask()to ensure UI switches back to parent task.chatButtonClickedaction inClineProvider.finishSubTask()to trigger UI navigation.SubtaskMetadataschema inhistory.tsfor parent-child task tracking.verifyParentExists()inTask.tsto check parent task accessibility.subtask_resultinjection non-interactive inTask.ts.ClineProvider.finishSubTask.spec.tsto test subtask completion scenarios.ClineProvider.spec.tsto mockTask.create()and test task stack behavior.Task.tsto persist subtask metadata and handle resume ask race conditions.This description was created by
for db9d2b1. You can customize this summary. It will automatically update as commits are pushed.