Skip to content

fix(models): list models in pi's /model order, not by name (#783) - #1111

Open
agegr wants to merge 1 commit into
mainfrom
fix/model-picker-pi-order
Open

agegr wants to merge 1 commit into
mainfrom
fix/model-picker-pi-order

Conversation

@agegr

@agegr agegr commented Oct 8, 2026

Copy link
Copy Markdown
Owner

The route and ModelSelector both sorted models by display name, so a models.json provider lost the order its file gives (#783).

pi's own /model selector never sorts by name:

  • with enabledModels set it lists the scope in the order the patterns are written (a glob expands in config order);
  • the full list is sorted by provider id only, keeping registry (= file) order within each provider.

The name sort came in as a side bullet of #80 ("Sort model options alphabetically"); no issue asked for it.

  • lib/model-scope.ts: new orderSelectorModels() gives pi's order; app/api/models/route.ts uses it.
  • components/ModelSelector.tsx no longer re-sorts; it still groups by provider (first-appearance order).
  • Differences from the TUI, kept on purpose: the current and default models are marked in place rather than lifted to the top, and a scoped list that alternates providers is grouped under provider headers.
  • docs/agents/models.md notes the rule.

Tests: lib/model-scope.test.mjs, components/ModelSelector.test.mjs (+ a regex in components/AgentsConfig.test.mjs). Checked against the real SDK with a scratch models.json that file order is kept. tsc, eslint, npm test pass.

Closes #783

🤖 Generated with Claude Code

The route and ModelSelector both sorted models by display name, so a
models.json provider lost the order its file gives. pi's TUI selector
never sorts by name: a scope keeps its enabledModels order, and the full
list is sorted by provider id only, keeping the registry (file) order
within each provider. The name sort came in as a side change of #80.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

模型选择器忽略 models.json 中的顺序 —— 始终按显示名称字母序排序

1 participant