-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: make removeClineFromStack() delegation-aware to prevent orphaned parent tasks #11302
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
Conversation
Re-reviewed the incremental changes (45d756e). The previously flagged nested delegation issue is resolved via the
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
… parent tasks When a delegated child task is removed via removeClineFromStack() (e.g., Clear Task, navigate to history, start new task), the parent task was left orphaned in "delegated" status with a stale awaitingChildId. This made the parent unresumable without manual history repair. This fix captures parentTaskId and childTaskId before abort/dispose, then repairs the parent metadata (status -> active, clear awaitingChildId) when the popped task is a delegated child and awaitingChildId matches. Parent lookup + updateTaskHistory are wrapped in try/catch so failures are non-fatal (logged but do not block the pop). Closes #11301
241c0a2 to
45d756e
Compare
Reviewed all changes across both commits. The fix is well-scoped:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Related GitHub Issue
Closes: #11301
Description
This PR attempts to address Issue #11301 where parent tasks become orphaned in a
delegatedstate when a child task is removed viaremoveClineFromStack().Root cause:
removeClineFromStack()is a pure pop-and-dispose operation with no delegation awareness. When a delegated child task is removed (via Clear Task, navigate to history, or start new task), the parent'sHistoryItemremains stuck withstatus: "delegated"and a staleawaitingChildId.Fix: Makes
removeClineFromStack()the delegation-aware chokepoint. After popping and disposing the child task, it now:parentTaskIdandchildTaskIdbefore abort/dispose (sinceabortTask(true)is async and the task reference is cleared later)HistoryItemviagetTaskWithId(parentTaskId)status === "delegated"andawaitingChildId === childTaskId, updates parent metadata:status->"active",awaitingChildId->undefinedupdateTaskHistory()This is a lightweight metadata repair (~20 lines), not a full delegation return. The parent simply becomes resumable from the task history list. All three affected paths (and any future callers) go through
removeClineFromStack(), so this single fix covers everything.Test Procedure
src/__tests__/removeClineFromStack-delegation.spec.ts:provider-delegation.spec.ts,history-resume-delegation.spec.ts,nested-delegation-resume.spec.ts,single-open-invariant.spec.ts)ClineProvider.spec.ts(88 tests) continues to passPre-Submission Checklist
Documentation Updates
Additional Notes
Feedback and guidance are welcome.
Important
Enhance
removeClineFromStack()inClineProvider.tsto be delegation-aware, preventing orphaned parent tasks by updating metadata when a delegated child is removed.removeClineFromStack()inClineProvider.tsis now delegation-aware, updating parent task metadata when a delegated child is removed.delegatedstatus andawaitingChildIdmatches the removed child, it updates toactiveand clearsawaitingChildId.removeClineFromStack-delegation.spec.tswith 6 new tests covering scenarios like delegated child removal, non-delegated tasks, mismatchedawaitingChildId, and error handling.awaitingChildId.removeClineFromStack()now accepts anoptionsparameter to skip delegation repair when necessary.This description was created by
for 45d756e. You can customize this summary. It will automatically update as commits are pushed.