-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Problem (one or two sentences)
Parent tasks in delegation chains (Orchestrator mode and subtasks) are being permanently deleted from task history when their api_conversation_history.json file is temporarily unavailable, causing child tasks to become orphaned and unable to navigate back to their parent.
Context (who is affected and when)
This affects users who:
- Use Orchestrator mode to delegate tasks to child modes
- Create long chains of subtasks (A → B → C)
- Try to navigate back to a parent task using the "Back to Parent Task" button
- Have slow disk I/O or filesystem latency
The issue is particularly severe during delegation transitions when parent tasks are disposed and child tasks are created, creating a race condition window.
Reproduction steps
-
Environment/setup:
- Any OS with Roo Code extension
- Any API provider
- Use Orchestrator mode or any mode that delegates tasks via
new_tasktool
-
Exact actions:
- Start a parent task in Orchestrator mode
- Let it create a subtask (delegation)
- While subtask is running, if any file I/O latency occurs:
- Or manually: delete/rename the parent's
api_conversation_history.jsonfile in global storage
- Or manually: delete/rename the parent's
- Click "Back to Parent Task" button in the subtask
- Or wait for subtask to complete and auto-resume parent
-
What you observed:
- Parent task entry disappears from task history completely
- Child task shows "Back to Parent Task" button but clicking it fails
- Error "Task not found" is thrown
- In longer chains (A→B→C), completing C may orphan B, then A becomes unreachable
Expected result
Parent tasks should remain in task history even if their files are temporarily unavailable. Navigation should either retry, show an error without deleting data, or gracefully handle the missing file scenario.
Actual result
Parent tasks are permanently deleted from taskHistory global state when getTaskWithId() is called and the api_conversation_history.json file doesn't exist. This happens via deleteTaskFromState() being called unconditionally when files are missing.
Variations tried (optional)
This is a code analysis finding. The vulnerable code path is:
src/core/webview/ClineProvider.tslines 1658-1693 (getTaskWithId())- The code includes a
// FIXMEcomment acknowledging the issue: "this seems to happen sometimes when the json file doesnt save to disk for some reason"
Related vulnerable paths include:
showTaskWithId()- Navigation triggers the deletionreopenParentFromDelegation()- Delegation resume can trigger deletiondeleteTaskWithId()- Cascading deletions can occur
App Version
Any version with the current getTaskWithId() implementation (verified in current main)
API Provider
Not Applicable / Other (affects all providers)
Additional Technical Context
Root cause location: getTaskWithId() in src/core/webview/ClineProvider.ts (lines 1658-1693)
// If task exists in history but file is missing, it gets DELETED:
await this.deleteTaskFromState(id) // Line 1691
throw new Error("Task not found") // Line 1692Impact severity: High - Data loss, broken navigation, orphaned tasks
Related metadata fields in HistoryItem:
parentTaskId- becomes a dangling reference when parent is deletedchildIds- parent loses track of children if deletedawaitingChildId,delegatedToId,completedByChildId- all become invalid
Key code paths affected:
getTaskWithId()- Primary bug locationshowTaskWithId()- UI navigation triggers deletionreopenParentFromDelegation()- Auto-resume can fail and delete parentdelegateParentAndOpenChild()- Race window during delegationdeleteTaskWithId()- Cascading effects when orphan detection fails