OoopsHh on X: with Ultrafast picked on a routing group's member, the group list's card still said "· fast". The Routing page's summaries (the card's member line, the member menus' notes and the route view's tag) read Group.Fast alone. They now say Ultrafast where the group sends the member so and an account offers it (memberJSON.Ultra), as the editor's speed button and `magpie group` already did. The TUI's group view did the same and now says Ultrafast too. The route trace's Weighed gains Ultra so the route view's tag can tell the two apart (#7095). Fixes #6881 and #7095 (paul-tian). ggbdpq took #6881 and posted a patch on it; its TUI test and the Codex GPT-6-Astra fixture are ported here with credit. Siblings checked: `magpie group` (groups_cli.go) and the Agents page (agentspeed.js) and search tags (fastTag) already said Ultrafast; the tray has no group speed summary. Tests: - group-member-fast.test.cjs: a group "Astra" with an Ultrafast member; its card says "gpt-6.2-sol · Ultrafast" / "· 极速" (en, zh; Chromium, WebKit). Red on7d5db0f29(4 of 4: "Relay gpt-6.2-sol · fast"). The same card now also holds #6881's Codex gpt-6-astra member (ggbdpq's fixture) and checks it reads Ultrafast, not fast. - routing-ultra-row.test.cjs (new, #7095): the route view tags a member sent Ultrafast "Ultrafast" with its own title, and one sent fast "fast"; every language, Chromium and WebKit. Red on7d5db0f29(10 of 10: both tagged "fast"). - TestGroupMemberUltrafastShown (tui) and ggbdpq's TestGroupMemberUltraShown (a Codex gpt-6-astra member; a member set fast alone still says fast): both red on7d5db0f29. - routing-service-tier.test.cjs: 20 of 20 green. - GUI run of the group-*, routing-*, panel-routing, fast-*, codex-service-tier, picker-speeds, agent-speed, i18n-*, gui-de/ja/zh-tw and header-relang files on mote: 4295 tests, 84 red in 10 files. The 10 files then run at this head and at origin/main3869aee3bon mote: the same 84 reds on both, each filed: fast-pick/fast-ultra #6201, group-editor-selected #5049, gui-ja #7144, routing-pin-away #6512, routing-provider-off and routing-rows-fit #7016, routing-row-swap #3799, routing-signin #6520, routing-story-shrinks #3954. Co-authored-by: ggbdpq <ggbdpq@gmail.com>
113 lines
4.4 KiB
Go
113 lines
4.4 KiB
Go
package tui
|
|
|
|
import (
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// E steps the picked member's own effort, F sends it in its vendor's fast
|
|
// mode or not; a model with none is refused it, and the group shows both.
|
|
func TestGroupMemberEffortAndFast(t *testing.T) {
|
|
home(t)
|
|
if err := provider.Save(provider.Provider{ID: "an", Name: "Anthropic", Key: "k", Anthropic: "https://api.anthropic.com", Models: []string{"claude-opus-5-5"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SaveGroup(provider.Group{ID: "opus", Name: "Opus", Members: []string{"an/claude-opus-5-5", "a/m"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m := press(t, model{w: 120, h: 40}, "3", "enter")
|
|
if m.mode != modeGroup || m.gsel != 0 {
|
|
t.Fatalf("mode %d, picked %d", m.mode, m.gsel)
|
|
}
|
|
m = press(t, m, "F")
|
|
wantFlash(t, m, true, "an/claude-opus-5-5 fast")
|
|
if g := group(t, "opus"); !slices.Equal(g.Fast, []string{"an/claude-opus-5-5"}) {
|
|
t.Fatalf("fast %v", g.Fast)
|
|
}
|
|
if v := m.View(); !strings.Contains(v, "· fast") {
|
|
t.Fatalf("fast not shown:\n%s", v)
|
|
}
|
|
m = press(t, m, "E")
|
|
wantFlash(t, m, true, "an/claude-opus-5-5:low set")
|
|
m = press(t, m, "E")
|
|
if g := group(t, "opus"); !slices.Equal(g.Members, []string{"an/claude-opus-5-5:medium", "a/m"}) || !slices.Equal(g.Fast, []string{"an/claude-opus-5-5:medium"}) {
|
|
t.Fatalf("members %v fast %v", g.Members, g.Fast)
|
|
}
|
|
m = press(t, m, "F")
|
|
if g := group(t, "opus"); len(g.Fast) != 0 {
|
|
t.Fatalf("still fast %v", g.Fast)
|
|
}
|
|
// a/m is on a relay: no fast mode to ask for
|
|
m = press(t, m, "down", "F")
|
|
wantFlash(t, m, false, "no fast mode")
|
|
}
|
|
|
|
// Taking a model out of a group whose other one is off is refused; while
|
|
// the in-process gateway holds the catalog, the group stays as it was, not
|
|
// shifted down a model with an empty one at its end.
|
|
func TestGroupTakeOutRefusedWhileHeld(t *testing.T) {
|
|
home(t)
|
|
if err := provider.SaveGroup(provider.Group{ID: "pair", Name: "Pair", Members: []string{"a/m", "b/gpt-5.5"}, Off: []string{"b/gpt-5.5"}, Rules: []provider.Rule{{Use: "a/m", Tokens: 5}}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer provider.Hold()()
|
|
m := press(t, model{w: 120, h: 40}, "3", "enter")
|
|
if m.mode != modeGroup || m.gsel != 0 {
|
|
t.Fatalf("mode %d, picked %d", m.mode, m.gsel)
|
|
}
|
|
m = press(t, m, "d", "d")
|
|
wantFlash(t, m, false, "switched off")
|
|
if g := group(t, "pair"); !slices.Equal(g.Members, []string{"a/m", "b/gpt-5.5"}) || len(g.Rules) != 1 || g.Rules[0].Use != "a/m" {
|
|
t.Fatalf("members %v rules %+v", g.Members, g.Rules)
|
|
}
|
|
}
|
|
|
|
// A rule naming several models shows them in order; taking one out of the
|
|
// group leaves the rule on the others.
|
|
func TestGroupTakeOutKeepsARulesOtherModels(t *testing.T) {
|
|
home(t)
|
|
if err := provider.SaveGroup(provider.Group{ID: "pair", Name: "Pair", Members: []string{"a/m", "b/gpt-5.5"},
|
|
Rules: []provider.Rule{{Use: "a/m", More: []string{"b/gpt-5.5"}, Tokens: 5}}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m := press(t, model{w: 120, h: 40}, "3", "enter")
|
|
if m.mode != modeGroup {
|
|
t.Fatalf("mode %d", m.mode)
|
|
}
|
|
if v := m.View(); !strings.Contains(v, "a/m, b/gpt-5.5") {
|
|
t.Fatalf("rule not shown with both models:\n%s", v)
|
|
}
|
|
m = press(t, m, "d")
|
|
if strings.Contains(m.flash, "its rules") {
|
|
t.Fatalf("flash %q: the rule keeps b/gpt-5.5", m.flash)
|
|
}
|
|
press(t, m, "d")
|
|
if g := group(t, "pair"); !slices.Equal(g.Members, []string{"b/gpt-5.5"}) || len(g.Rules) != 1 || g.Rules[0].Use != "b/gpt-5.5" || g.Rules[0].More != nil {
|
|
t.Fatalf("members %v rules %+v", g.Members, g.Rules)
|
|
}
|
|
}
|
|
|
|
// A member sent Ultrafast reads "· Ultrafast" in the group's list, not
|
|
// "· fast", as the CLI and the GUI say it (OoopsHh on X).
|
|
func TestGroupMemberUltrafastShown(t *testing.T) {
|
|
home(t)
|
|
if err := provider.Save(provider.Provider{ID: "oa", Name: "OpenAI", Key: "k", Responses: "https://api.openai.com/v1", Models: []string{"gpt-6.2-sol", "gpt-6.1-sol"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SaveGroup(provider.Group{ID: "sol", Name: "Sol", Members: []string{"oa/gpt-6.2-sol", "oa/gpt-6.1-sol"},
|
|
Fast: []string{"oa/gpt-6.2-sol", "oa/gpt-6.1-sol"}, Ultra: []string{"oa/gpt-6.2-sol"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m := press(t, model{w: 120, h: 40}, "3", "enter")
|
|
v := m.View()
|
|
if !strings.Contains(v, "gpt-6.2-sol · Ultrafast") || strings.Contains(v, "gpt-6.2-sol · fast") {
|
|
t.Fatalf("Ultrafast not shown:\n%s", v)
|
|
}
|
|
if !strings.Contains(v, "gpt-6.1-sol · fast") {
|
|
t.Fatalf("fast not shown:\n%s", v)
|
|
}
|
|
}
|