You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a delegated subtask was cancelled mid-execution, cancelTask() immediately severed the parent–child link — parent transitioned from "delegated" → "active" with awaitingChildId cleared. When the user resumed the child and it called attempt_completion, the parent no longer awaited it, so it fell through to the standalone "Start New Task" flow instead of reporting back.
How it works
Before: cancel child → parent: delegated→active, awaitingChildId→undefined
→ child resumes → falls through to standalone "Start New Task"
After: cancel child → child: active→interrupted, parent stays delegated
→ child resumes → delegates back to parent → parent completes
Changes
Core fix:
packages/types/src/history.ts — Add "interrupted" to HistoryItem status enum
packages/types/src/task.ts, src/core/task/Task.ts, src/core/task-persistence/taskMetadata.ts — Propagate "interrupted" through initialStatus types
src/core/webview/ClineProvider.ts#cancelTask — Mark cancelled delegated child as "interrupted" instead of severing parent link; await abortTask() promise before writing "interrupted" to prevent a late saveClineMessages write from downgrading the status back to "active"
src/core/webview/ClineProvider.ts#removeClineFromStack — Skip parent auto-repair when child history shows "interrupted" (parent must stay "delegated" for resume)
src/core/tools/AttemptCompletionTool.ts — Accept "interrupted" alongside "active" so resumed children can delegate back to parent
CLI/session type sync:
packages/core/src/task-history/index.ts — Add "interrupted" to session reader allow-list so persisted interrupted sessions are not silently dropped
apps/cli/src/ui/types.ts, apps/cli/src/ui/components/autocomplete/triggers/HistoryTrigger.tsx — Add "interrupted" to status unions; display interrupted tasks with ⏸ icon and cyan color
Test Procedure
Unit tests (3 files updated, 3 new tests added):
src/core/webview/__tests__/ClineProvider.flicker-free-cancel.spec.ts — Updated existing cancel tests; added tests asserting child is marked "interrupted" and parent stays "delegated"
src/__tests__/removeClineFromStack-delegation.spec.ts — Added test asserting parent is not auto-repaired when child is "interrupted"
src/core/tools/__tests__/attemptCompletionTool.spec.ts — Added test for interrupted child delegating back to parent
apps/cli/src/ui/components/autocomplete/triggers/__tests__/HistoryTrigger.test.tsx — Added test asserting ⏸ icon renders for interrupted status
E2E test:
apps/vscode-e2e/src/suite/subtasks.test.ts — New test: interrupt child mid-execution → resume → asserts child reports back to parent and parent completes with expected result
All unit tests pass: pnpm vitest run (408/408 files).
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8d74f235-6d60-4039-ac89-a74807f980c8
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
🔍 Trigger review
✨ Finishing Touches🧪 Generate unit tests (beta)
Create PR with unit tests
Commit unit tests in branch issue/560
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: #560
Description
When a delegated subtask was cancelled mid-execution,
cancelTask()immediately severed the parent–child link — parent transitioned from"delegated"→"active"withawaitingChildIdcleared. When the user resumed the child and it calledattempt_completion, the parent no longer awaited it, so it fell through to the standalone "Start New Task" flow instead of reporting back.How it works
Changes
Core fix:
packages/types/src/history.ts— Add"interrupted"toHistoryItemstatus enumpackages/types/src/task.ts,src/core/task/Task.ts,src/core/task-persistence/taskMetadata.ts— Propagate"interrupted"throughinitialStatustypessrc/core/webview/ClineProvider.ts#cancelTask— Mark cancelled delegated child as"interrupted"instead of severing parent link; awaitabortTask()promise before writing"interrupted"to prevent a latesaveClineMessageswrite from downgrading the status back to"active"src/core/webview/ClineProvider.ts#removeClineFromStack— Skip parent auto-repair when child history shows"interrupted"(parent must stay"delegated"for resume)src/core/tools/AttemptCompletionTool.ts— Accept"interrupted"alongside"active"so resumed children can delegate back to parentCLI/session type sync:
packages/core/src/task-history/index.ts— Add"interrupted"to session reader allow-list so persisted interrupted sessions are not silently droppedapps/cli/src/ui/types.ts,apps/cli/src/ui/components/autocomplete/triggers/HistoryTrigger.tsx— Add"interrupted"to status unions; display interrupted tasks with ⏸ icon and cyan colorTest Procedure
Unit tests (3 files updated, 3 new tests added):
src/core/webview/__tests__/ClineProvider.flicker-free-cancel.spec.ts— Updated existing cancel tests; added tests asserting child is marked"interrupted"and parent stays"delegated"src/__tests__/removeClineFromStack-delegation.spec.ts— Added test asserting parent is not auto-repaired when child is"interrupted"src/core/tools/__tests__/attemptCompletionTool.spec.ts— Added test for interrupted child delegating back to parentapps/cli/src/ui/components/autocomplete/triggers/__tests__/HistoryTrigger.test.tsx— Added test asserting ⏸ icon renders for interrupted statusE2E test:
apps/vscode-e2e/src/suite/subtasks.test.ts— New test: interrupt child mid-execution → resume → asserts child reports back to parent and parent completes with expected resultAll unit tests pass:
pnpm vitest run(408/408 files).Pre-Submission Checklist