-
Notifications
You must be signed in to change notification settings - Fork 2.2k
FIX: parent-child task relationships across extension reloads #7906
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
base: main
Are you sure you want to change the base?
FIX: parent-child task relationships across extension reloads #7906
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've reviewed the changes and the implementation correctly addresses the core issue of parent-child task relationships being lost on extension reloads. The comprehensive test coverage and error handling are excellent. I've left some suggestions inline to help improve the implementation.
} | ||
} | ||
// Start the continuation in the background to avoid blocking | ||
continueExecution() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential race condition: The task continuation is started in the background without awaiting it. This could lead to race conditions if multiple operations happen quickly.
continueExecution() | |
// Start the continuation and await it to ensure proper synchronization | |
await continueExecution() |
Alternatively, consider implementing a queue or synchronization mechanism to handle concurrent operations safely.
await addToHierarchy(parentHistoryItem) | ||
} catch (error) { | ||
this.log( | ||
`[buildTaskHierarchy] Failed to load parent task ${historyItem.parentTaskId}: ${error instanceof Error ? error.message : String(error)}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error recovery: When a parent task fails to load, the error is logged but the hierarchy continues building. This could result in an incomplete or broken task stack.
Consider either:
- Throwing an error to stop the reconstruction
- Implementing a fallback strategy (e.g., treating the current task as root)
- Returning a partial hierarchy with a warning to the user
@@ -572,7 +572,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike { | |||
|
|||
// API Messages | |||
|
|||
private async getSavedApiConversationHistory(): Promise<ApiMessage[]> { | |||
public async getSavedApiConversationHistory(): Promise<ApiMessage[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encapsulation concern: Making these methods public breaks encapsulation. If these are only needed for task reconstruction, consider:
- Creating a TaskReconstruction interface with these specific methods
- Using a friend/internal pattern (e.g., @internal JSDoc tag)
- Moving the reconstruction logic into the Task class itself
This would maintain better separation of concerns and prevent misuse of these methods.
const hierarchy: HistoryItem[] = [] | ||
const visited = new Set<string>() | ||
|
||
// Recursive function to build hierarchy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding timeout protection to prevent indefinite waiting. For example:
public async waitForSubtask(timeoutMs: number = 60000) {
const timeout = setTimeout(() => {
clearInterval(this.pauseInterval)
this.pauseInterval = undefined
throw new Error('Subtask timeout exceeded')
}, timeoutMs)
await new Promise<void>((resolve) => {
this.pauseInterval = setInterval(() => {
if (!this.isPaused) {
clearTimeout(timeout)
clearInterval(this.pauseInterval)
this.pauseInterval = undefined
resolve()
}
}, 1000)
})
}
const addToHierarchy = async (historyItem: HistoryItem): Promise<void> => { | ||
// Prevent infinite loops | ||
if (visited.has(historyItem.id)) { | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The circular reference protection works but could be more explicit. Consider adding a warning log when a circular reference is detected:
if (visited.has(historyItem.id)) {
this.log('[buildTaskHierarchy] Warning: Circular reference detected for task ' + historyItem.id)
return
}
This would help with debugging task hierarchy issues in production.
@hannesrudolph hannesrudolph I made some changes to fix this inconsistency. Now should work as expected. |
@catrielmuller Thank you! Just tested again, the child task does not restore with the original mode. Nested subtasks seem to also cause breaking behaviour.
|
@hannesrudolph , I added the mode switch and logs to track down the actions of this component.
parent-mode-switch.mp4 |
Hi RooTeam, Catriel from KiloCode
Related GitHub Issue
Closes: #2534
Closes: #6624
Related: #6625
Related: https://discordapp.com/channels/1349288496988160052/1414333923118284922
Related: Kilo-Org/kilocode#2379
Description
This PR fixes an issue with the orchestrator mode where loading a child task from task history wouldn't properly reconstruct the task stack, preventing the parent task from resuming execution after the child task finishes.
Test Procedure
Orchestrator
ModePre-Submission Checklist
Documentation Updates
Does this PR necessitate updates to user-facing documentation?
Additional Notes
Get in Touch
Discord: catrielmuller
Important
Fixes task stack reconstruction in orchestrator mode, ensuring parent-child relationships are maintained across reloads, with new methods and tests added.
ClineProvider.ts
.reconstructTaskStack()
andcontinueParentTask()
inClineProvider.ts
.showTaskWithId()
to handle task stack reconstruction.ClineProvider.stack-reconstruction.spec.ts
to test task stack reconstruction and parent-child relationships.This description was created by
for 4b237d2. You can customize this summary. It will automatically update as commits are pushed.