Skip to content

Commit 151d608

Browse files
authored
Merge pull request #1792 from Kilo-Org/fix-inifinite-initial-request
Fix initial API requests spinning forever when switching modes
2 parents c2cddcf + ee300bc commit 151d608

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.changeset/clear-doodles-drum.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"kilo-code": patch
3+
---
4+
5+
Fix infinite spinning initial API request

src/core/tools/newTaskTool.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,27 @@ export async function newTaskTool(
8080
// Preserve the current mode so we can resume with it later.
8181
cline.pausedModeSlug = (await provider.getState()).mode ?? defaultModeSlug
8282

83-
// Create new task instance first (this preserves parent's current mode in its history)
83+
// kilocode_change start: Switch to the desired mode BEFORE creating the task
84+
await provider.handleModeSwitch(mode)
85+
// Small delay to ensure mode switch has propagated
86+
await delay(100)
87+
// kilocode_change end
88+
89+
// Now create the task with the correct mode already set
8490
const newCline = await provider.initClineWithTask(unescapedMessage, undefined, cline)
8591
if (!newCline) {
92+
await provider.handleModeSwitch(cline.pausedModeSlug) // kilocode_change: if task creation failed, switch back to the parent's mode
8693
pushToolResult(t("tools:newTask.errors.policy_restriction"))
8794
return
8895
}
8996

90-
// Now switch the newly created task to the desired mode
91-
await provider.handleModeSwitch(mode)
97+
// kilocode_change start: Switch to the desired mode BEFORE creating the task above
98+
// // Now switch the newly created task to the desired mode
99+
// await provider.handleModeSwitch(mode)
92100

93-
// Delay to allow mode change to take effect
94-
await delay(500)
101+
// // Delay to allow mode change to take effect
102+
// await delay(500)
103+
// kilocode_change end
95104

96105
cline.emit("taskSpawned", newCline.taskId)
97106

0 commit comments

Comments
 (0)