Skip to content

Commit 0a7a771

Browse files
committed
feat: allow selecting the default variant
Fixes #426
1 parent e1fec23 commit 0a7a771

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

lua/opencode/services/agent_model.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function M.configure_variant()
3939
return
4040
end
4141

42-
state.model.set_variant(selection.name)
42+
state.model.set_variant(selection.value)
4343

4444
if state.ui.is_visible() then
4545
ui.focus_input()

lua/opencode/variant_picker.lua

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,24 @@ local function get_current_model_variants()
2323
return {}
2424
end
2525

26-
local variants = {}
26+
local variants = {
27+
{
28+
name = 'default',
29+
value = nil,
30+
config = nil,
31+
},
32+
}
2733
for variant_name, variant_config in pairs(model_info.variants) do
2834
table.insert(variants, {
2935
name = variant_name,
36+
value = variant_name,
3037
config = variant_config,
3138
})
3239
end
3340

3441
util.sort_by_priority(variants, function(item)
3542
return item.name
36-
end, { low = 1, medium = 2, high = 3 })
43+
end, { default = 0, low = 1, medium = 2, high = 3 })
3744

3845
return variants
3946
end
@@ -68,7 +75,7 @@ function M.select(callback)
6875
layout_opts = config.ui.picker,
6976
format_fn = function(item, width)
7077
local item_width = width or vim.api.nvim_win_get_width(0)
71-
local is_current = state.current_variant == item.name
78+
local is_current = state.current_variant == item.value
7279
local current_indicator = is_current and '*' or ' '
7380

7481
local name_width = item_width - vim.api.nvim_strwidth(current_indicator)
@@ -89,12 +96,12 @@ function M.select(callback)
8996
actions = {},
9097
callback = function(selection)
9198
if selection and state.current_model then
92-
state.model.set_variant(selection.name)
99+
state.model.set_variant(selection.value)
93100

94101
-- Save variant to model state
95102
local provider, model = state.current_model:match('^(.-)/(.+)$')
96103
if provider and model then
97-
model_state.set_variant(provider, model, selection.name)
104+
model_state.set_variant(provider, model, selection.value)
98105
end
99106
end
100107
if callback then

0 commit comments

Comments
 (0)