Skip to content

Commit 1e60f22

Browse files
committed
update welcome message to use the server and also be configurable
1 parent da7a28b commit 1e60f22

File tree

4 files changed

+59
-22
lines changed

4 files changed

+59
-22
lines changed

docs/configuration.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,16 @@ require("eca").setup({
4848
-- === CHAT ===
4949
chat = {
5050
headers = {
51-
user = "## 👤 You\n\n",
52-
assistant = "## 🤖 ECA\n\n",
51+
user = "> ",
52+
assistant = "",
53+
},
54+
welcome = {
55+
-- If non-empty, overrides server-provided welcome message
56+
message = "",
57+
-- Tips appended under the welcome (set {} to disable)
58+
tips = {
59+
"Type your message and use CTRL+s to send",
60+
},
5361
},
5462
},
5563

lua/eca/config.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ M._defaults = {
4848
user = "> ",
4949
assistant = "",
5050
},
51+
welcome = {
52+
message = "", -- If non-empty, overrides server-provided welcome message
53+
tips = {
54+
"Type your message and use CTRL+s to send", -- Tips appended under the welcome (set empty list {} to disable)
55+
},
56+
},
5157
},
5258
windows = {
5359
wrap = true,

lua/eca/mediator.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ function mediator:status_text()
5454
return self.state.status.text
5555
end
5656

57+
function mediator:welcome_message()
58+
return (self.state and self.state.config and self.state.config.welcome_message) or nil
59+
end
60+
5761
function mediator:mcps()
5862
local mcps = {}
5963

lua/eca/sidebar.lua

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function M.new(id, mediator)
6565
user = (Config.chat and Config.chat.headers and Config.chat.headers.user) or "> ",
6666
assistant = (Config.chat and Config.chat.headers and Config.chat.headers.assistant) or "",
6767
}
68+
instance._welcome_message_applied = false
6869

6970
require("eca.observer").subscribe("sidebar-" .. id, function(message)
7071
instance:handle_chat_content(message)
@@ -192,6 +193,7 @@ function M:reset()
192193
self._selected_code = nil
193194
self._todos = {}
194195
self._current_status = ""
196+
self._welcome_message_applied = false
195197
end
196198

197199
function M:new_chat()
@@ -747,6 +749,7 @@ function M:_handle_state_updated(state)
747749

748750
if state.config or state.tools then
749751
self:_update_config_display()
752+
self:_update_welcome_content()
750753
end
751754
end
752755

@@ -869,26 +872,7 @@ function M:_set_welcome_content()
869872
self._force_welcome = false
870873
end
871874

872-
local lines = {
873-
"# 🤖 ECA - Editor Code Assistant",
874-
"",
875-
"> **Welcome to ECA!** Your AI-powered code assistant is ready to help.",
876-
"",
877-
"## 🚀 Getting Started",
878-
"",
879-
"- **Chat**: Type your message in the input field at the bottom and press `Ctrl+S` to send",
880-
"- **Multiline**: Use `Enter` for new lines, `Ctrl+S` to send",
881-
"- **Context**: Use `@` to mention files or directories",
882-
"- **Context**: Use `:EcaAddFile` to add files, `:EcaListContexts` to view, `:EcaClearContexts` to clear",
883-
"- **Selection**: Use `:EcaAddSelection` to add code selection",
884-
"- **RepoMap**: Use `:EcaAddRepoMap` to add repository structure context",
885-
"",
886-
"---",
887-
"",
888-
}
889-
890-
Logger.debug("Setting welcome content for new chat")
891-
vim.api.nvim_buf_set_lines(chat.bufnr, 0, -1, false, lines)
875+
self:_update_welcome_content()
892876

893877
-- Auto-add repoMap context if enabled and not already present
894878
if Config.options.context.auto_repo_map then
@@ -1224,6 +1208,41 @@ function M:_update_usage_info()
12241208
)
12251209
end
12261210

1211+
function M:_update_welcome_content()
1212+
if self._welcome_applied then
1213+
return
1214+
end
1215+
1216+
local chat = self.containers.chat
1217+
if not chat or not vim.api.nvim_buf_is_valid(chat.bufnr) then
1218+
return
1219+
end
1220+
1221+
local cfg = (Config.chat and Config.chat.welcome) or {}
1222+
local cfg_msg = (cfg.message and cfg.message ~= "" and cfg.message) or nil
1223+
local welcome_message = cfg_msg or (self.mediator and self.mediator:welcome_message() or nil)
1224+
1225+
local lines = { "Waiting for welcome message from ECA server..." }
1226+
1227+
if welcome_message and welcome_message ~= "" then
1228+
lines = Utils.split_lines(welcome_message)
1229+
1230+
local tips = cfg.tips or {}
1231+
1232+
if #tips > 0 then
1233+
for _, tip in ipairs(tips) do
1234+
table.insert(lines, tip)
1235+
end
1236+
end
1237+
1238+
self._welcome_applied = true
1239+
end
1240+
1241+
table.insert(lines, "")
1242+
Logger.debug("Setting welcome content for chat (welcome applied: " .. tostring(self._welcome_applied) .. ")")
1243+
vim.api.nvim_buf_set_lines(chat.bufnr, 0, -1, false, lines)
1244+
end
1245+
12271246
function M:_render_header(container_name, header_text)
12281247
if not Config.windows.sidebar_header.enabled then
12291248
return {}

0 commit comments

Comments
 (0)