fix(tui): sort connect providers alphabetically (#30891)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
parent
31c099be43
commit
f20655bef4
2 changed files with 17 additions and 1 deletions
|
|
@ -48,7 +48,11 @@ export function providerOptions(list: { id: string; name: string }[]): ProviderO
|
||||||
return [
|
return [
|
||||||
...pipe(
|
...pipe(
|
||||||
list,
|
list,
|
||||||
sortBy((x) => PROVIDER_PRIORITY[x.id] ?? 99),
|
sortBy(
|
||||||
|
(x) => PROVIDER_PRIORITY[x.id] ?? 99,
|
||||||
|
(x) => x.name.toLowerCase(),
|
||||||
|
(x) => x.id,
|
||||||
|
),
|
||||||
map((provider) => ({
|
map((provider) => ({
|
||||||
type: "provider" as const,
|
type: "provider" as const,
|
||||||
title: provider.name,
|
title: provider.name,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,18 @@ describe("providerOptions", () => {
|
||||||
expect(providerOptions([{ id: "mistral", name: "Mistral" }])[0]?.category).toBe("Providers")
|
expect(providerOptions([{ id: "mistral", name: "Mistral" }])[0]?.category).toBe("Providers")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("keeps popular providers first and sorts the rest alphabetically", () => {
|
||||||
|
expect(
|
||||||
|
providerOptions([
|
||||||
|
{ id: "openai", name: "OpenAI" },
|
||||||
|
{ id: "custom-z", name: "Zebra Provider" },
|
||||||
|
{ id: "anthropic", name: "Anthropic" },
|
||||||
|
{ id: "mistral", name: "Mistral" },
|
||||||
|
{ id: "aws", name: "AWS Bedrock" },
|
||||||
|
]).map((option) => option.value),
|
||||||
|
).toEqual(["openai", "anthropic", "aws", "mistral", "custom-z", "__opencode_custom_provider__"])
|
||||||
|
})
|
||||||
|
|
||||||
test("does not collide with a configured provider named other", () => {
|
test("does not collide with a configured provider named other", () => {
|
||||||
const values = providerOptions([{ id: "other", name: "Other Provider" }]).map((option) => option.value)
|
const values = providerOptions([{ id: "other", name: "Other Provider" }]).map((option) => option.value)
|
||||||
expect(new Set(values).size).toBe(values.length)
|
expect(new Set(values).size).toBe(values.length)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue