Skip to content

Commit dd37879

Browse files
committed
fix(ClineProvider): route createTaskWithHistoryItem through taskScheduler
1 parent 7fc3e4b commit dd37879

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/__tests__/single-open-invariant.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ describe("Single-open-task invariant", () => {
186186
// Methods used by createTaskWithHistoryItem for pending edit cleanup
187187
getPendingEditOperation: vi.fn().mockReturnValue(undefined),
188188
clearPendingEditOperation: vi.fn(),
189+
taskScheduler: { schedule: vi.fn().mockResolvedValue(undefined) },
189190
context: { extension: { packageJSON: {} }, globalStorageUri: { fsPath: "/tmp" } },
190191
contextProxy: {
191192
extensionUri: {},

src/core/webview/ClineProvider.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ export class ClineProvider
11871187
taskNumber: historyItem.number,
11881188
workspacePath: historyItem.workspace,
11891189
onCreated: this.taskCreationCallback,
1190-
startTask: options?.startTask ?? true,
1190+
startTask: false,
11911191
// Preserve the status from the history item to avoid overwriting it when the task saves messages
11921192
initialStatus: historyItem.status,
11931193
rateLimitClock: this.rateLimitClock,
@@ -1233,6 +1233,14 @@ export class ClineProvider
12331233
this.log(
12341234
`[createTaskWithHistoryItem] ${task.parentTask ? "child" : "parent"} task ${task.taskId}.${task.instanceId} instantiated`,
12351235
)
1236+
1237+
if (options?.startTask !== false) {
1238+
void this.taskScheduler
1239+
.schedule(task, () => task.run())
1240+
.catch((error) => {
1241+
console.error("[createTaskWithHistoryItem] taskScheduler.schedule failed:", error)
1242+
})
1243+
}
12361244
}
12371245

12381246
// Check if there's a pending edit after checkpoint restoration

0 commit comments

Comments
 (0)