Skip to content

Commit 83d4bd2

Browse files
committed
handle server not running
1 parent 08215a2 commit 83d4bd2

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

lua/eca/sidebar.lua

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,30 +1161,24 @@ function M:_send_message(message)
11611161
-- Store the last user message to avoid duplication
11621162
self._last_user_message = message
11631163

1164-
-- Send message to ECA server
1165-
local eca = require("eca")
1166-
if eca.server and eca.server:is_running() then
1167-
-- Include active contexts in the message
1168-
local contexts = self:get_contexts()
1169-
self.mediator:send("chat/prompt", {
1170-
chatId = self.id,
1171-
requestId = tostring(os.time()),
1172-
message = message,
1173-
contexts = contexts or {},
1174-
}, function(err, result)
1175-
if err then
1176-
Logger.error("Failed to send message to ECA server: " .. tostring(err))
1177-
self:_add_message("assistant", "❌ **Error**: Failed to send message to ECA server")
1178-
end
1179-
-- Response will come through server notification handler
1180-
self:_add_input_line()
1181-
1182-
self:handle_chat_content_received(result.params)
1183-
end)
1184-
else
1185-
self:_add_message("assistant", "❌ **Error**: ECA server is not running. Please check server status.")
1164+
local contexts = self:get_contexts()
1165+
self.mediator:send("chat/prompt", {
1166+
chatId = self.id,
1167+
requestId = tostring(os.time()),
1168+
message = message,
1169+
contexts = contexts or {},
1170+
}, function(err, result)
1171+
if err then
1172+
print("err is " .. err)
1173+
Logger.error("Failed to send message to ECA server: " .. err)
1174+
self:_add_message("assistant", "❌ **Error**: Failed to send message to ECA server: " .. err)
1175+
return
1176+
end
1177+
-- Response will come through server notification handler
11861178
self:_add_input_line()
1187-
end
1179+
1180+
self:handle_chat_content_received(result.params)
1181+
end)
11881182
end
11891183

11901184
function M:handle_chat_content(message)

0 commit comments

Comments
 (0)