[FEATURE]: Configurable sort criterion for models within each group in the /models picker

未关闭
#66,988 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
70/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
json, typescript

调研方向

Start with packages/tui/src/component/dialog-model.tsx and its sortModelOptions() function, then trace how configuration is loaded before reading packages/cli/src/commands/handlers/models.ts for the existing alphabetical comparison. Add the configurable models.sort option with release-desc, release-asc, name-asc, and name-desc, preserving group order, Favorites, Recent, and fuzzy-search behavior. Done means the /models picker respects the configured within-group order while the default remains release date descending.

由索引模型根据 Issue 内容生成。

描述

area/tui platform/macos type/feature version/v2
Feature hasn't been suggested before.
  • I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request

Make the sort criterion of the models within each group configurable of the /models picker (provider groups and the "Free" group).

Current behavior

The server returns chat models sorted by release date, newest first (packages/core/src/model.ts: .sort((left, right) => right.time.released - left.time.released)). The TUI picker (packages/tui/src/component/dialog-model.tsx → sortModelOptions()) only orders the provider groups and keeps the release-date order inside each group.

With large catalogs (opencode, opencode-go, google-vertex, …) this makes it hard to find a model by name when scrolling a group: models of the same family end up scattered by release date.

The CLI already does the opposite: opencode models sorts its output alphabetically (packages/cli/src/commands/handlers/models.ts: .toSorted((a, b) => a.localeCompare(b))), so the two views of the same catalog disagree.

Proposal

Make the sort criterion of the /models picker configurable, e.g. in cli.json:

{ "models": { "sort": "release-desc" } }
Value Order inside each group
release-desc (default, current behavior) newest first
release-asc oldest first
name-asc alphabetical by display name
name-desc reverse alphabetical

Both criteria are useful: newest-first to spot what was just released, alphabetical to find a known model by name. Implementation-wise this is a final tie-breaker in sortModelOptions() (time.released or title.localeCompare, with the chosen direction). Group order, Favorites, Recent and fuzzy search results would stay as they are.

A picker keybind to cycle the criterion on the fly (like other *.cycle keybinds) would be a nice extra, but the config option alone would solve it.

Why not a plugin

A V2 plugin can filter the catalog (ctx.model.transform), but it cannot control picker order. The only lever is rewriting model.time.released, which also feeds default-model selection and the model metadata exposed to agents, so it is not a safe workaround. (#45412 asked for a plugin ordering API for the same reason and was auto-closed for template compliance.)

Related
  • #57195: configurable provider group order (open). This request is complementary: order of models inside a group.
  • #22593 (Filter and sort models), #38228 (custom order UI), #51941 (user-defined order in config): closed as not planned / stale; they proposed broader custom ordering. This one only asks for a few built-in sort criteria (release date or name, each in both directions).
Environment
  • opencode version: 2.4.2
  • OS: macOS 12.7.6 (Darwin 21.6.0)
  • Terminal: tmux 3.5a
主要语言
TypeScript
星标
230k
派生
31.3k
平均合并
5 小时 32 分钟
30 天内合并 PR
453

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。