Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/eca/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
22 changes: 22 additions & 0 deletions tests/test_select_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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([[
Expand Down
Loading