Skip to content

Commit f20655b

Browse files
robertDouglassopencode-agent[bot]rekram1-node
authored
fix(tui): sort connect providers alphabetically (anomalyco#30891)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
1 parent 31c099b commit f20655b

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎packages/tui/src/component/dialog-provider.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ export function providerOptions(list: { id: string; name: string }[]): ProviderO
4848
return [
4949
...pipe(
5050
list,
51-
sortBy((x) => PROVIDER_PRIORITY[x.id] ?? 99),
51+
sortBy(
52+
(x) => PROVIDER_PRIORITY[x.id] ?? 99,
53+
(x) => x.name.toLowerCase(),
54+
(x) => x.id,
55+
),
5256
map((provider) => ({
5357
type: "provider" as const,
5458
title: provider.name,

‎packages/tui/test/cli/cmd/tui/provider-options.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ describe("providerOptions", () => {
1414
expect(providerOptions([{ id: "mistral", name: "Mistral" }])[0]?.category).toBe("Providers")
1515
})
1616

17+
test("keeps popular providers first and sorts the rest alphabetically", () => {
18+
expect(
19+
providerOptions([
20+
{ id: "openai", name: "OpenAI" },
21+
{ id: "custom-z", name: "Zebra Provider" },
22+
{ id: "anthropic", name: "Anthropic" },
23+
{ id: "mistral", name: "Mistral" },
24+
{ id: "aws", name: "AWS Bedrock" },
25+
]).map((option) => option.value),
26+
).toEqual(["openai", "anthropic", "aws", "mistral", "custom-z", "__opencode_custom_provider__"])
27+
})
28+
1729
test("does not collide with a configured provider named other", () => {
1830
const values = providerOptions([{ id: "other", name: "Other Provider" }]).map((option) => option.value)
1931
expect(new Set(values).size).toBe(values.length)

0 commit comments

Comments
 (0)