From e2cba0127c245b363723e542c554cad9a4f4580d Mon Sep 17 00:00:00 2001 From: meijieru Date: Tue, 28 Apr 2026 11:22:39 -0700 Subject: [PATCH] feat(acp): allow hiding model choices when switching adapters --- doc/configuration/adapters-acp.md | 18 +++++++++++++++ lua/codecompanion/config.lua | 1 + .../chat/keymaps/change_adapter.lua | 11 +++++++++ tests/config.lua | 3 +++ tests/interactions/chat/test_keymaps.lua | 23 +++++++++++++++++++ 5 files changed, 56 insertions(+) diff --git a/doc/configuration/adapters-acp.md b/doc/configuration/adapters-acp.md index f8ed315dd..67e2e6ac1 100644 --- a/doc/configuration/adapters-acp.md +++ b/doc/configuration/adapters-acp.md @@ -208,6 +208,24 @@ require("codecompanion").setup({ }) ``` +## Controlling Model Choices + +When switching between ACP adapters, the plugin typically displays all available model choices for the selected adapter. If you want to keep the current/default ACP model automatically chosen and skip the model selection UI, you can set `show_model_choices` to `false`: + +```lua +require("codecompanion").setup({ + adapters = { + acp = { + opts = { + show_model_choices = false, + }, + }, + }, +}) +``` + +With `show_model_choices = false`, CodeCompanion will keep using the ACP session's current/default model when changing adapters instead of prompting for a model. + ## Setup: Auggie CLI from Augment Code To use [Auggie CLI](https://docs.augmentcode.com/cli/overview) within CodeCompanion, you simply need to follow their [Getting Started](https://docs.augmentcode.com/cli/overview#getting-started) guide. diff --git a/lua/codecompanion/config.lua b/lua/codecompanion/config.lua index 3c2424a35..998b79d59 100644 --- a/lua/codecompanion/config.lua +++ b/lua/codecompanion/config.lua @@ -51,6 +51,7 @@ local defaults = { opencode = "opencode", opts = { show_presets = true, + show_model_choices = true, -- Show model choices when changing adapter }, }, opts = { diff --git a/lua/codecompanion/interactions/chat/keymaps/change_adapter.lua b/lua/codecompanion/interactions/chat/keymaps/change_adapter.lua index 4c55c341a..bc5d3c7fc 100644 --- a/lua/codecompanion/interactions/chat/keymaps/change_adapter.lua +++ b/lua/codecompanion/interactions/chat/keymaps/change_adapter.lua @@ -126,6 +126,17 @@ end ---@return table|nil function M.list_acp_models(connection) local models = connection:get_models() + local show_choices = not ( + config.adapters + and config.adapters.acp + and config.adapters.acp.opts + and config.adapters.acp.opts.show_model_choices == false + ) + + if not show_choices then + return nil + end + if not models or vim.tbl_count(models.availableModels) < 2 then return nil end diff --git a/tests/config.lua b/tests/config.lua index 4e1a033b1..e69e84dd3 100644 --- a/tests/config.lua +++ b/tests/config.lua @@ -68,6 +68,9 @@ return { command = { "node", "test-agent.js" }, roles = { user = "user", assistant = "assistant" }, }, + opts = { + show_model_choices = true, + }, }, opts = { cmd_timeout = 10e3, diff --git a/tests/interactions/chat/test_keymaps.lua b/tests/interactions/chat/test_keymaps.lua index 7f6c21cbd..131e258a6 100644 --- a/tests/interactions/chat/test_keymaps.lua +++ b/tests/interactions/chat/test_keymaps.lua @@ -194,4 +194,27 @@ T["Keymaps"]["change_adapter"]["list_acp_models returns nil when < 2 models"] = h.expect_truthy(result) end +T["Keymaps"]["change_adapter"]["list_acp_models returns nil when model choices are hidden"] = function() + local result = child.lua([[ + h.setup_plugin() + config.adapters.acp.opts.show_model_choices = false + + local acp_connection = { + get_models = function(self) + return { + availableModels = { + { modelId = "default", name = "Default" }, + { modelId = "opus", name = "Opus" }, + }, + currentModelId = "default", + } + end + } + + return change_adapter.list_acp_models(acp_connection) == nil + ]]) + + h.expect_truthy(result) +end + return T