diff --git a/lua/eca/commands.lua b/lua/eca/commands.lua index 522c680..c6f4a31 100644 --- a/lua/eca/commands.lua +++ b/lua/eca/commands.lua @@ -454,6 +454,7 @@ function M.setup() }, function(choice) if choice then chat.mediator:update_selected_model(choice) + chat.mediator:send("chat/selectedModelChanged", { model = choice, variant = vim.NIL }, nil) end end) end, { diff --git a/tests/test_select_commands.lua b/tests/test_select_commands.lua index 8274422..c563fc8 100644 --- a/tests/test_select_commands.lua +++ b/tests/test_select_commands.lua @@ -82,6 +82,28 @@ T["EcaChatSelectModel"]["updates state when model selected"] = function() eq(child.lua_get("_G.State.config.models.selected"), "model2") end +T["EcaChatSelectModel"]["notifies server of model change"] = function() + child.lua([[ + _G.State.config.models.list = { "model1", "model2", "model3" } + _G.State.config.models.selected = "model1" + + -- Capture outgoing notifications + _G.sent_notifications = {} + _G.Mediator.send = function(self, method, params, callback) + table.insert(_G.sent_notifications, { method = method, params = params }) + end + + _G.mock_select("model2") + ]]) + + child.cmd("EcaChatSelectModel") + + local notifications = child.lua_get("_G.sent_notifications") + eq(#notifications, 1) + eq(notifications[1].method, "chat/selectedModelChanged") + eq(notifications[1].params.model, "model2") +end + T["EcaChatSelectModel"]["handles nil selection"] = function() -- Setup initial state child.lua([[