The model list under an agent (Pick on its row) had a third view, Order, for Codex alone (#855): the API said only Codex's list was orderable and refused an order for any other. The order itself was never Codex's only: provider.CatalogFor puts every agent's catalog in its order (InOrder), and the gateway's /models, the files magpie writes for each agent and Claude Code's modelPicker are all built from it. So the view is now on every agent's list, the API takes any agent's order, and one agent's order leaves the others' alone. Codex's note still says it is the order Codex lists them in; another agent's says it is the order magpie hands them to it, since an agent that sorts its own menu may sort them again. zh, ja, de. Verified: TestAgentModelOrderAPI fails on the old code (opencode: 400, the order refused); codex-model-order.test.cjs's new Claude Code case (en, zh, 440px wide: three views uncut and inside the box, Order lists the shown, Alt+Down posts the order, Default order posts none, nothing scrolls) fails on the old app.js (no Order). TestModelOrderReachesEveryAgent checks Claude Code's picker and opencode's written models follow their own order. Chromium and WebKit: codex-model-order, agent-models, agent-models-all- hidden, agent-models-loading, agent-model-groups, agent-models-picker, gui-ja, gui-de, i18n-keys pass. click-scroll's "Live and a day" and "room kept for a click" (Requests page) fail the same on origin/main, untouched here. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass.
52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
package agent
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// An order dragged on the Agents page reaches every agent, not only Codex
|
|
// (#1052): Claude Code's /model picker (viaMagpie, which writePicker turns
|
|
// into settings.json's modelPicker) and the model files magpie writes for
|
|
// the others (magpieModels) list the models in it, and one agent's order
|
|
// leaves another's alone.
|
|
func TestModelOrderReachesEveryAgent(t *testing.T) {
|
|
syncHome(t)
|
|
if err := provider.Save(provider.Provider{ID: "other", Name: "Other", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"m1", "m2"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
refs := func(agent string) (out []string) {
|
|
for _, o := range viaMagpie(agent, "") {
|
|
out = append(out, o.Ref)
|
|
}
|
|
return out
|
|
}
|
|
ids := func(agent string) (out []string) {
|
|
for _, m := range magpieModels(agent) {
|
|
out = append(out, m.ID)
|
|
}
|
|
return out
|
|
}
|
|
was := ids("opencode")
|
|
if want := []string{"relay/glm-4.6", "other/m1", "other/m2"}; !slices.Equal(was, want) {
|
|
t.Fatalf("default %v, want %v", was, want)
|
|
}
|
|
if err := provider.SetModelOrder("claude", []string{"other/m2", "relay/glm-4.6"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got, want := refs("claude"), []string{"other/m2", "relay/glm-4.6", "other/m1"}; !slices.Equal(got, want) {
|
|
t.Errorf("Claude Code's picker %v, want %v", got, want)
|
|
}
|
|
if got := ids("opencode"); !slices.Equal(got, was) {
|
|
t.Errorf("claude's order moved opencode's: %v", got)
|
|
}
|
|
if err := provider.SetModelOrder("opencode", []string{"other/m1"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got, want := ids("opencode"), []string{"other/m1", "relay/glm-4.6", "other/m2"}; !slices.Equal(got, want) {
|
|
t.Errorf("opencode's models %v, want %v", got, want)
|
|
}
|
|
}
|