Skip to content
Open
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
8 changes: 8 additions & 0 deletions doc/agentic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ settings ~
window after submitting a prompt.
Default: `true`.

*agentic-config-provider-switcher*
provider_switcher ~
Type: `table`

`hide_unhealthy_providers` Hide providers whose command is not installed
from the provider switcher UI.
Default: `false`.

*agentic-config-hooks*
hooks ~
Type: `table`
Expand Down
11 changes: 11 additions & 0 deletions lua/agentic/config_default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@
--- @field on_session_update? fun(data: agentic.UserConfig.SessionUpdateData): nil
--- @field on_file_edit? fun(data: agentic.UserConfig.FileEditData): nil

--- Provider switcher UI behavior
--- @class agentic.UserConfig.ProviderSwitcher
--- @field hide_unhealthy_providers boolean Hide providers whose command is not installed

--- Control various behaviors and features of the plugin
--- @class agentic.UserConfig.Settings
--- @field move_cursor_to_chat_on_submit boolean Automatically move cursor to chat window after submitting a prompt
Expand All @@ -201,6 +205,7 @@
--- @class (partial) agentic.PartialUserConfig.DiffPreview: agentic.UserConfig.DiffPreview
--- @class (partial) agentic.PartialUserConfig.Folding.ToolCalls: agentic.UserConfig.Folding.ToolCalls
--- @class (partial) agentic.PartialUserConfig.Settings: agentic.UserConfig.Settings
--- @class (partial) agentic.PartialUserConfig.ProviderSwitcher: agentic.UserConfig.ProviderSwitcher

--- Windows partial with nested type overrides
--- @class (partial) agentic.PartialUserConfig.Windows: agentic.UserConfig.Windows
Expand Down Expand Up @@ -232,6 +237,7 @@
--- @field diff_preview? agentic.PartialUserConfig.DiffPreview
--- @field folding? agentic.PartialUserConfig.Folding
--- @field settings? agentic.PartialUserConfig.Settings
--- @field provider_switcher? agentic.PartialUserConfig.ProviderSwitcher

--- @class agentic.UserConfig
--- @field debug boolean Enable printing debug messages which can be read via `:messages`
Expand All @@ -253,6 +259,7 @@
--- @field hooks agentic.UserConfig.Hooks
--- @field headers agentic.UserConfig.Headers
--- @field settings agentic.UserConfig.Settings
--- @field provider_switcher agentic.UserConfig.ProviderSwitcher
local ConfigDefault = {
debug = false,

Expand Down Expand Up @@ -491,6 +498,10 @@ local ConfigDefault = {
settings = {
move_cursor_to_chat_on_submit = true,
},

provider_switcher = {
hide_unhealthy_providers = false,
},
}

return ConfigDefault
9 changes: 8 additions & 1 deletion lua/agentic/session_registry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ function SessionRegistry.select_provider(on_selected)
end
end

vim.list_extend(sorted_providers, not_installed)
if not Config.provider_switcher.hide_unhealthy_providers then
vim.list_extend(sorted_providers, not_installed)
elseif #sorted_providers == 0 then
Logger.notify(
"No healthy providers found. Showing unavailable providers."
)
vim.list_extend(sorted_providers, not_installed)
end
Comment thread
coderabbitai[bot] marked this conversation as resolved.

vim.ui.select(sorted_providers, {
prompt = "Select an ACP provider for the new session:",
Expand Down
47 changes: 47 additions & 0 deletions lua/agentic/session_registry.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ describe("agentic.SessionRegistry", function()
["claude-acp"] = { command = "claude-code-acp" },
["gemini-acp"] = { command = "gemini" },
},
provider_switcher = {
hide_unhealthy_providers = true,
},
}

default_config_mock = {
Expand Down Expand Up @@ -105,6 +108,9 @@ describe("agentic.SessionRegistry", function()
["claude-acp"] = { command = "claude-code-acp" },
["gemini-acp"] = { command = "gemini" },
}
config_mock.provider_switcher = {
hide_unhealthy_providers = true,
}
default_config_mock.provider = "claude-acp"

session_manager_mock.new = function(_, tab_page_id)
Expand Down Expand Up @@ -487,6 +493,47 @@ describe("agentic.SessionRegistry", function()
assert.is_nil(result)
end)

describe("hide_unhealthy_providers", function()
before_each(function()
acp_health_mock.get_default_provider_names = function()
return { "claude-acp", "gemini-acp" }
end
acp_health_mock.is_command_available = function(cmd)
return cmd == "claude-code-acp"
end
end)

it(
"excludes not-installed providers when hide_unhealthy_providers is true",
function()
config_mock.provider_switcher =
{ hide_unhealthy_providers = true }

SessionRegistry.select_provider(function() end)

assert.equal(1, #captured_items)
assert.equal("claude-acp", captured_items[1].name)
assert.is_true(captured_items[1].installed)
end
)

it(
"includes not-installed providers when hide_unhealthy_providers is false",
function()
config_mock.provider_switcher =
{ hide_unhealthy_providers = false }

SessionRegistry.select_provider(function() end)

assert.equal(2, #captured_items)
assert.equal("claude-acp", captured_items[1].name)
assert.is_true(captured_items[1].installed)
assert.equal("gemini-acp", captured_items[2].name)
assert.is_false(captured_items[2].installed)
end
)
end)

describe("format_item labels", function()
before_each(function()
acp_health_mock.get_default_provider_names = function()
Expand Down
Loading