fix: resolve phantom subtask display on cancel during API retry (#4602)#4893
Merged
hannesrudolph merged 3 commits intomainfrom Jun 19, 2025
Merged
fix: resolve phantom subtask display on cancel during API retry (#4602)#4893hannesrudolph merged 3 commits intomainfrom
hannesrudolph merged 3 commits intomainfrom
Conversation
- Fixed clearTask handler to check for actual parent task existence - Changed condition from getClineStackSize() > 1 to checking currentTask.parentTask - Prevents finishSubTask() from being called on tasks without parents - Added comprehensive test coverage for clearTask message handler - Resolves infinite checkpoint initialization loop issue
- Modified clearTask handler to check for parentTask property instead of stack size - This prevents single tasks from being incorrectly treated as subtasks - Added comprehensive test coverage for the fix - Fixes issue where canceling during API retry would show phantom 'Subtask Results' and create checkpoint initialization loop
Contributor
There was a problem hiding this comment.
Pull Request Overview
Fixes an issue where canceling during an API retry incorrectly treated single tasks as subtasks.
- Replace
getClineStackSize()check with explicitparentTaskexistence in theclearTaskhandler - Introduce a new
clearTask()method onClineProviderfor non-subtask cancellations - Add comprehensive tests for both subtask and single-task cancellation flows
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/core/webview/webviewMessageHandler.ts | Updated clearTask case to branch on currentTask.parentTask and call finishSubTask or clearTask |
| src/core/webview/ClineProvider.ts | Added clearTask() helper to remove the current task without subtask logic |
| src/core/webview/tests/ClineProvider.spec.ts | Added tests covering the new clearTask logic, including the fix for issue #4602 |
Comments suppressed due to low confidence (2)
src/core/webview/tests/ClineProvider.spec.ts:675
- This test does not mock or assert
postStateToWebview; consider spying onprovider.postStateToWebviewto both avoid unintended side effects and verify that state is posted in this scenario.
await messageHandler({ type: "clearTask" })
src/core/webview/webviewMessageHandler.ts:207
- The translation function
tis used here but not imported in this module. Add the appropriate import (e.g.import { t } from 'i18n';) to prevent a runtime error.
await provider.finishSubTask(t("common:tasks.canceled"))
mrubens
approved these changes
Jun 19, 2025
cte
pushed a commit
that referenced
this pull request
Jun 24, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #4602
This PR resolves an issue where canceling a task during API retry would incorrectly display "Subtask Results" and create a checkpoint initialization loop, even though no subtask was actually created.
Changes Made
clearTaskhandler inwebviewMessageHandler.tsto check for the existence of aparentTaskproperty instead of relying on stack sizefinishSubTask()methodclearTask()insteadTesting
ClineProvider.spec.ts:clearTaskfinishSubTaskVerification of Acceptance Criteria
Checklist
Technical Details
The root cause was that the previous implementation checked
provider.getClineStackSize() > 1to determine if a task was a subtask. However, during API retry scenarios, the stack could have multiple entries even for a single task, leading to incorrect behavior.The fix now properly checks for the existence of a
parentTaskproperty on the current task, which is the definitive way to determine if a task is actually a subtask.Important
Fixes phantom subtask display issue by checking
parentTaskproperty inwebviewMessageHandler.tsduring task cancellation.clearTaskinwebviewMessageHandler.tsnow checks forparentTaskproperty instead of stack size to determine subtask status.parentTasktriggerfinishSubTask(); others useclearTask().ClineProvider.spec.tsfor single tasks, child tasks, and no current task scenarios.This description was created by
for 0cc9eca. You can customize this summary. It will automatically update as commits are pushed.