Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 30, 2026

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_task tool in orchestrator mode, the parent task may not have its API history file saved yet while waiting for the child to complete. Previously, getTaskWithId would 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 calls deleteTaskFromState(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" or awaitingChildId exists) before deleting. Delegated tasks now get empty history returned instead of being deleted, allowing the delegation flow to recover properly.

Test Procedure

  1. Unit tests added in ClineProvider.spec.ts:

    • returns empty history for delegated task when API history file is missing
    • returns empty history for task with awaitingChildId when API history file is missing
    • deletes non-delegated task from state when API history file is missing (preserves existing behavior)
  2. Run tests: cd src && npx vitest run core/webview/__tests__/ClineProvider.spec.ts --testNamePattern="getTaskWithId - delegated task handling"

  3. All 3 critical tests pass.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

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 getTaskWithId to prevent deletion of parent tasks in orchestrator mode when API history file is missing, ensuring delegated tasks return empty history instead.

  • Behavior:
    • Fix getTaskWithId in ClineProvider.ts to prevent deletion of parent tasks when API history file is missing.
    • Delegated tasks or tasks with awaitingChildId return empty history instead of being deleted.
    • Non-delegated tasks with missing files are deleted from state.
  • Tests:
    • Add tests in ClineProvider.spec.ts for delegated tasks returning empty history when file is missing.
    • Add tests for non-delegated tasks being deleted when file is missing.
  • Logging:
    • Add logging in getTaskWithId to indicate when a task is returned with empty history or deleted.

This description was created by Ellipsis for c0c1e26. You can customize this summary. It will automatically update as commits are pushed.

…ks (EXT-696)

When a parent task delegates to a child via new_task tool, the parent task may
not have its API history file saved yet while waiting for the child to complete.
Previously, getTaskWithId would delete such tasks from state and throw
"Task not found", breaking the orchestrator delegation flow.

This fix checks if a task is delegated (status === "delegated" or has awaitingChildId)
before deleting it when the history file is missing. Delegated tasks get empty
history returned instead, allowing the delegation flow to recover properly.

Changes:
- Added delegation check in getTaskWithId before deleting tasks with missing files
- Added 3 tests for the fix scenarios:
  - Delegated task with status "delegated"
  - Task with awaitingChildId
  - Non-delegated task still gets deleted (existing behavior)
@roomote
Copy link
Contributor Author

roomote bot commented Jan 30, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

Changes reviewed:

  • ClineProvider.ts: Added delegation check before deleting tasks with missing API history files
  • ClineProvider.spec.ts: Added 3 tests covering delegated and non-delegated task scenarios

All checks passed:

  • Logic correctly handles both status === "delegated" and awaitingChildId presence
  • Preserves existing behavior for non-delegated tasks
  • Tests adequately cover the fix scenarios
  • Appropriate logging added for debugging

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@daniel-lxs
Copy link
Member

Closing this PR as it doesn't address the root cause identified in the investigation.

Issue with this approach

The PR fixes getTaskWithId() to avoid deleting delegated tasks when their history files are missing. However, the investigation in EXT-696 concluded that the parent task is likely being filtered out by UI logic, not actually deleted from state.

Why this misses the mark

The investigation pointed to:

  • UI filtering logic hiding tasks with status === "delegated"
  • Race conditions in UI updates during status transitions
  • Missing UI state handling for delegated tasks

This PR addresses a backend state management issue instead of the UI filtering issue that was identified.

Questions this raises

  1. Why would parent tasks have missing history files? If a task delegates immediately, it may not have saved API history yet. But this suggests a timing/lifecycle issue rather than a fundamental deletion problem.

  2. Recent UI changes: PR ux: Improve subtask visibility and navigation in history and chat views #10864 introduced useGroupedTasks and new subtask components. The parent task disappearance likely relates to how these new UI components handle delegated tasks during rendering.

Next steps

The investigation should focus on:

  • How useGroupedTasks filters and groups tasks with status === "delegated"
  • Whether the new subtask UI components properly handle parent tasks in delegated state
  • Timing of when parent tasks transition to delegated status vs. when UI tries to render them

The fix likely needs to be in the webview UI layer, not in ClineProvider.getTaskWithId().

@daniel-lxs daniel-lxs closed this Jan 30, 2026
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 30, 2026
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jan 30, 2026
@daniel-lxs daniel-lxs deleted the feature/EXT-696-parent-task-disappears branch January 30, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants