mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-07-09 17:28:58 +00:00
fix: sort provider picker by display name
This commit is contained in:
parent
16c7734af8
commit
26ae04fedc
2 changed files with 25 additions and 0 deletions
|
|
@ -124,6 +124,14 @@ func collectCustomProviders(cfg *Config) []customProviderListItem {
|
|||
|
||||
func newProviderTUI(cfg *Config) providerTUIModel {
|
||||
providers := llm.ListProviders()
|
||||
sort.SliceStable(providers, func(i, j int) bool {
|
||||
left := strings.ToLower(providers[i].DisplayName)
|
||||
right := strings.ToLower(providers[j].DisplayName)
|
||||
if left == right {
|
||||
return providers[i].Name < providers[j].Name
|
||||
}
|
||||
return left < right
|
||||
})
|
||||
|
||||
mi := textinput.New()
|
||||
mi.Placeholder = "model name"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
|
|
@ -136,6 +138,21 @@ func TestProviderTUI_TabSwitchOnlyOnStepProvider(t *testing.T) {
|
|||
|
||||
// --- Official tab tests (updated from original) ---
|
||||
|
||||
func TestProviderTUI_OfficialProvidersSortedByDisplayName(t *testing.T) {
|
||||
m := newProviderTUI(&Config{})
|
||||
|
||||
displayNames := make([]string, len(m.providers))
|
||||
normalized := make([]string, len(m.providers))
|
||||
for i, p := range m.providers {
|
||||
displayNames[i] = p.DisplayName
|
||||
normalized[i] = strings.ToLower(p.DisplayName)
|
||||
}
|
||||
|
||||
if !sort.StringsAreSorted(normalized) {
|
||||
t.Errorf("provider display names are not sorted: %v", displayNames)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProviderTUI_EscFromModelGoesBackToProvider(t *testing.T) {
|
||||
m := newProviderTUI(&Config{})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue