Skip to content

Commit a7683da

Browse files
committed
fix: .
1 parent 3373e6e commit a7683da

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

lua/codecompanion/interactions/chat/acp/handler.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ end
310310

311311
---Handle completion
312312
function ACPHandler:handle_completion()
313+
-- Ignore completions from a stale handler (e.g. a late cancel ack after a new request started)
314+
if self.chat._acp_handler ~= self then
315+
return
316+
end
317+
313318
if not self.chat.status or self.chat.status == "" then
314319
self.chat.status = "success"
315320
end
@@ -320,6 +325,10 @@ end
320325
---Handle errors
321326
---@param error string
322327
function ACPHandler:handle_error(error)
328+
if self.chat._acp_handler ~= self then
329+
return
330+
end
331+
323332
self.chat.status = "error"
324333
log:error("[ACP::Handler] %s", error)
325334

lua/codecompanion/interactions/chat/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ end
11451145
---@return nil
11461146
function Chat:_submit_acp(payload)
11471147
local acp_handler = require("codecompanion.interactions.chat.acp.handler").new(self)
1148+
self._acp_handler = acp_handler
11481149
self.current_request = acp_handler:submit(payload)
11491150
end
11501151

0 commit comments

Comments
 (0)