Skip to content

Commit 925e391

Browse files
committed
refactor(ClineProvider): extract scheduleTask helper to deduplicate fire-and-forget scheduling
1 parent 46f4a28 commit 925e391

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/core/webview/ClineProvider.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ function runDelegationTransition<T>(
154154
return current
155155
}
156156

157+
function scheduleTask(scheduler: TaskScheduler, task: Task, source: string): void {
158+
void scheduler
159+
.schedule(task, () => task.run())
160+
.catch((error) => console.error(`[${source}] taskScheduler.schedule failed:`, error))
161+
}
162+
157163
export class ClineProvider
158164
extends EventEmitter<TaskProviderEvents>
159165
implements vscode.WebviewViewProvider, TelemetryPropertiesProvider, TaskProviderLike
@@ -1230,7 +1236,7 @@ export class ClineProvider
12301236
)
12311237

12321238
if (options?.startTask !== false) {
1233-
this.scheduleTask(task, "createTaskWithHistoryItem")
1239+
scheduleTask(this.taskScheduler, task, "createTaskWithHistoryItem")
12341240
}
12351241
} else {
12361242
await this.addClineToStack(task)
@@ -1240,7 +1246,7 @@ export class ClineProvider
12401246
)
12411247

12421248
if (options?.startTask !== false) {
1243-
this.scheduleTask(task, "createTaskWithHistoryItem")
1249+
scheduleTask(this.taskScheduler, task, "createTaskWithHistoryItem")
12441250
}
12451251
}
12461252

@@ -3200,7 +3206,7 @@ export class ClineProvider
32003206

32013207
await this.addClineToStack(task)
32023208
if (options.startTask !== false) {
3203-
this.scheduleTask(task, "createTask")
3209+
scheduleTask(this.taskScheduler, task, "createTask")
32043210
}
32053211

32063212
this.log(
@@ -3221,12 +3227,6 @@ export class ClineProvider
32213227
await this.cancelTaskInternal(task)
32223228
}
32233229

3224-
private scheduleTask(task: Task, source: string): void {
3225-
void this.taskScheduler
3226-
.schedule(task, () => task.run())
3227-
.catch((error) => console.error(`[${source}] taskScheduler.schedule failed:`, error))
3228-
}
3229-
32303230
private async cancelTaskInternal(task: Task): Promise<void> {
32313231
let historyItem: HistoryItem | undefined
32323232
try {
@@ -3718,7 +3718,7 @@ export class ClineProvider
37183718
}
37193719

37203720
// 6) Start the child task now that parent metadata is safely persisted.
3721-
this.scheduleTask(child, "delegateParentAndOpenChild")
3721+
scheduleTask(this.taskScheduler, child, "delegateParentAndOpenChild")
37223722

37233723
// 7) Emit TaskDelegated (provider-level)
37243724
try {

0 commit comments

Comments
 (0)