The reporter's screenshot was Codex's model menu, where a long name plus " · Relay" or " · routing group" is cut off. Magpie can't widen an agent's menu. What it can do is shorten the label. Models can already be renamed (provider editor › Names & levels), groups have a Name, and Settings › Provider in model names (#335) can drop the suffix. The reporter found none of these. Changes: - The provider editor's Names & levels and a routing group's editor now each have the three choices: Off, Not on names I set, On. - Each says what the agents' lists will show, e.g. "My Sol · Relay" or "Fast · routing group". - The line follows the name as it is typed and the choice as it is picked. - A pick posts settings/plain-names once and doesn't scroll. - "Not on names I set" now covers routing groups the user made or changed (Entry.Named = !g.Auto) as well as renamed models, still only where the name is unique in the list. A group magpie found keeps its suffix. - zh, ja, de strings. Tests: - TestPlainOwnNamesGroups fails on the old code. - name-suffix-where-named.test.cjs (WebKit, en and zh) fails 4/4 on the old assets. - group-fold.test.cjs: viewport raised to 1500 for the taller editor. - Pass on WebKit: group-context, plain-names, provider-same-as, provider-levels-save, gui-ja, gui-de, click-scroll, agent-models, agent-model-groups, group-* and routing-*. - Fail the same on origin/main: group-from-model-add at 600x420, provider-levels-scroll. - go vet passes. The darwin, GOOS=linux nogui and GOOS=windows builds pass. go test -tags nogui -count=1 ./... passes under a temp HOME.
45 lines
1.7 KiB
Go
45 lines
1.7 KiB
Go
package provider
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
// With names the user set plain (PlainOwnNames, #92), a routing group they
|
|
// made is one of them (#868: 模型名称太长…路由组的名称也很长, an agent's
|
|
// narrow menu cut "· routing group" to "· rou…"): its name stands alone in
|
|
// the agents' lists. A group magpie found keeps "· routing group", the
|
|
// vendors' names keep their providers', and a name the list would show
|
|
// twice keeps its suffix, so a picker never shows one name twice.
|
|
func TestPlainOwnNamesGroups(t *testing.T) {
|
|
prefsHome(t)
|
|
if err := SetModelName("a/sol", "My Sol"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := SaveGroup(Group{ID: "fast", Name: "Fast", Members: []string{"a/sol", "b/sol"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
labels := func() []string {
|
|
shown, _ := CatalogFor("opencode")
|
|
out := Labels(shown)
|
|
slices.Sort(out)
|
|
return out
|
|
}
|
|
if got, want := labels(), []string{"Fast · routing group", "My Sol · A", "Sol · B", "Sol · routing group"}; !slices.Equal(got, want) {
|
|
t.Fatalf("by default: %q, want %q", got, want)
|
|
}
|
|
if err := SetSuffixMode(SuffixOwn); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got, want := labels(), []string{"Fast", "My Sol", "Sol · B", "Sol · routing group"}; !slices.Equal(got, want) {
|
|
t.Fatalf("own names plain: %q, want %q", got, want)
|
|
}
|
|
// a group named as a model the list has keeps its suffix
|
|
if err := SaveGroup(Group{ID: "fast", Name: "My Sol", Members: []string{"a/sol", "b/sol"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got, want := labels(), []string{"My Sol · A", "My Sol · routing group", "Sol · B", "Sol · routing group"}; !slices.Equal(got, want) {
|
|
t.Fatalf("a group named as a model: %q, want %q", got, want)
|
|
}
|
|
}
|