Skip to content

Commit 3de71f8

Browse files
olimorriscleong14
authored andcommitted
fix(tools): can now chain jobs effectively (olimorris#945)
Co-authored-by: Oli Morris <olimorris@users.noreply.github.com>
1 parent 8a6836e commit 3de71f8

File tree

1 file changed

+13
-3
lines changed
  • lua/codecompanion/strategies/chat/tools

1 file changed

+13
-3
lines changed

lua/codecompanion/strategies/chat/tools/init.lua

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ function Tools:run()
352352
end
353353
end
354354

355-
-- Delay executing the job to allow for output to be collated and processed
356-
self.chat.current_tool = Job:new({
355+
local new_job = Job:new({
357356
command = vim.fn.has("win32") == 1 and "cmd.exe" or "sh",
358357
args = { vim.fn.has("win32") == 1 and "/c" or "-c", table.concat(cmd.cmd or cmd, " ") },
359358
enable_recording = true,
@@ -418,7 +417,18 @@ function Tools:run()
418417
run(index + 1, data)
419418
end)
420419
end,
421-
}):start()
420+
})
421+
422+
if self.chat.current_tool then
423+
-- Chain to the previous job if it exists
424+
self.chat.current_tool:and_then_wrap(new_job)
425+
else
426+
-- Start first job directly
427+
new_job:start()
428+
end
429+
430+
-- Update current_tool reference
431+
self.chat.current_tool = new_job
422432
end
423433
end
424434

0 commit comments

Comments
 (0)