fix: prevent parent task deletion when file missing for delegated tasks (EXT-696) #11105
+217
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: EXT-696 (Linear issue - Parent task disappears in orchestrator mode without error)
Description
When a parent task delegates to a child via the
new_tasktool in orchestrator mode, the parent task may not have its API history file saved yet while waiting for the child to complete. Previously,getTaskWithIdwould delete such tasks from state and throw "Task not found", breaking the orchestrator delegation flow silently.Root cause: In
ClineProvider.getTaskWithId(), when the API conversation history file does not exist, the method unconditionally callsdeleteTaskFromState(id)and throws "Task not found". This is problematic for delegated parent tasks because they may not have their history file saved yet when they are waiting for a child task to complete.Fix: Added a check for delegation status (
status === "delegated"orawaitingChildIdexists) before deleting. Delegated tasks now get empty history returned instead of being deleted, allowing the delegation flow to recover properly.Test Procedure
Unit tests added in
ClineProvider.spec.ts:returns empty history for delegated task when API history file is missingreturns empty history for task with awaitingChildId when API history file is missingdeletes non-delegated task from state when API history file is missing(preserves existing behavior)Run tests:
cd src && npx vitest run core/webview/__tests__/ClineProvider.spec.ts --testNamePattern="getTaskWithId - delegated task handling"All 3 critical tests pass.
Pre-Submission Checklist
Documentation Updates
Additional Notes
The fix adds a simple delegation check that preserves existing behavior for non-delegated tasks while preventing silent deletion of parent tasks that are waiting for child subtasks to complete.
Important
Fix
getTaskWithIdto prevent deletion of parent tasks in orchestrator mode when API history file is missing, ensuring delegated tasks return empty history instead.getTaskWithIdinClineProvider.tsto prevent deletion of parent tasks when API history file is missing.awaitingChildIdreturn empty history instead of being deleted.ClineProvider.spec.tsfor delegated tasks returning empty history when file is missing.getTaskWithIdto indicate when a task is returned with empty history or deleted.This description was created by
for c0c1e26. You can customize this summary. It will automatically update as commits are pushed.