Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rude-pans-throw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"roo-cline": patch
---

Fix parent-child task relationships across extension reloads
25 changes: 22 additions & 3 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {

// API Messages

private async getSavedApiConversationHistory(): Promise<ApiMessage[]> {
public async getSavedApiConversationHistory(): Promise<ApiMessage[]> {
Copy link
Contributor

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:

  1. Creating a TaskReconstruction interface with these specific methods
  2. Using a friend/internal pattern (e.g., @internal JSDoc tag)
  3. Moving the reconstruction logic into the Task class itself

This would maintain better separation of concerns and prevent misuse of these methods.

return readApiMessages({ taskId: this.taskId, globalStoragePath: this.globalStoragePath })
}

Expand Down Expand Up @@ -602,7 +602,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {

// Cline Messages

private async getSavedClineMessages(): Promise<ClineMessage[]> {
public async getSavedClineMessages(): Promise<ClineMessage[]> {
return readTaskMessages({ taskId: this.taskId, globalStoragePath: this.globalStoragePath })
}

Expand Down Expand Up @@ -1289,7 +1289,14 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
.find((m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task")) // Could be multiple resume tasks.

let askType: ClineAsk
if (lastClineMessage?.ask === "completion_result") {

// Check for completion indicators in multiple ways
const isCompleted =
lastClineMessage?.ask === "completion_result" ||
lastClineMessage?.say === "completion_result" ||
this.clineMessages.some((m) => m.ask === "completion_result" || m.say === "completion_result")

if (isCompleted) {
askType = "resume_completed_task"
} else {
askType = "resume_task"
Expand Down Expand Up @@ -1600,6 +1607,13 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
const newTask = await provider.createTask(message, undefined, this, { initialTodos })

if (newTask) {
// Store the current task's mode before pausing
const currentTaskMode = await this.getTaskMode()
this.pausedModeSlug = currentTaskMode
provider.log(
`[startSubtask] Storing parent task mode '${currentTaskMode}' in pausedModeSlug before pausing`,
)

this.isPaused = true // Pause parent.
this.childTaskId = newTask.taskId

Expand Down Expand Up @@ -1749,6 +1763,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {

if (currentMode !== this.pausedModeSlug) {
// The mode has changed, we need to switch back to the paused mode.
provider.log(
`[subtasks] task ${this.taskId}.${this.instanceId} switching back to paused mode '${this.pausedModeSlug}' from current mode '${currentMode}'`,
)
await provider.handleModeSwitch(this.pausedModeSlug)

// Delay to allow mode change to take effect before next tool is executed.
Expand All @@ -1757,6 +1774,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
provider.log(
`[subtasks] task ${this.taskId}.${this.instanceId} has switched back to '${this.pausedModeSlug}' from '${currentMode}'`,
)
} else {
provider.log(`[subtasks] task ${this.taskId}.${this.instanceId} mode unchanged: '${currentMode}'`)
}
}

Expand Down
Loading
Loading