Skip to content

Commit 7a7310d

Browse files
committed
use a new chat-id when re-opening nvim
1 parent 80e3be4 commit 7a7310d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lua/eca/mediator.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,8 @@ function mediator:mcps()
8686
return mcps
8787
end
8888

89+
function mediator:id()
90+
return (self.state and self.state.id)
91+
end
92+
8993
return mediator

lua/eca/sidebar.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ function M:_send_message(message)
12751275

12761276
local contexts = self:get_contexts()
12771277
self.mediator:send("chat/prompt", {
1278-
chatId = self.id,
1278+
chatId = self.mediator:id(),
12791279
requestId = tostring(os.time()),
12801280
message = message,
12811281
contexts = contexts or {},

lua/eca/state.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
---@field status string
1818
---
1919
---@class eca.State
20+
---@field id string?
2021
---@field status eca.StateStatus
2122
---@field config eca.StateConfig
2223
---@field usage eca.StateUsage
@@ -26,6 +27,7 @@ local State = {}
2627
---@return eca.State
2728
function State._new()
2829
local instance = setmetatable({
30+
id = nil,
2931
status = {
3032
state = "idle",
3133
text = "Idle",
@@ -99,6 +101,10 @@ function State:_chat_content_received(message)
99101
return
100102
end
101103

104+
if message.params.chatId and message.params.chatId ~= self.id then
105+
self.id = message.params.chatId
106+
end
107+
102108
local content = message.params.content
103109

104110
if content.type == "progress" then

0 commit comments

Comments
 (0)