Settings > Images > Image generation now offers each routing group with a member that draws (gateway.GroupDraws: a member among its provider's Drawers), with no provider of its own, so the picker puts it under Routing groups as the Image recognition picker does. Picked, "group/<id>" is what a request naming no model draws with, the Magpie Image MCP's included: the gateway already drew on a group member by member in its routing's order (drawingGroup, #2005), it was only never offered. A picked group none of whose members draws any more (all removed, or a group of chat models) is DrawerMissing (drawerMissing): the row says the pick is missing and Automatic draws in its place, as for a removed model. Before, a group of chat models would have been sent the drawing. ListedDrawer and DrawerHidden leave a group ref as it is. Run: - mote, at this change one84f40369: gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., the Linux and Windows builds: ok. go test -count=1 -run "Draw|Drawer|Image|Budget|HiddenDrawers|Account|Aside" over internal/provider, gateway, gui and agent: all four ok (the new tests, TestImageGroupMovesOnToTheNextMember and the size budgets among them). - wsl-run, Chromium and WebKit: the seven image GUI files and i18n-keys, 182 of 182. - Rebased again onto4d9058a98(which changed app.js, api.go and i18n.js, "Picked only" among them) and run there: go vet ./internal/gui and go test -run "Budget|Image|Drawer" ./internal/gui ok; wsl-run, both engines: image-models-hide, provider-picked-only-shows-picks, images-missing and i18n-keys, 90 of 90. Pushed on0366e35c1, which changes only internal/catalog after it. New tests: TestImageGroupPickedInSettingsDraws (gateway: the group pick draws with no model named, over HTTP and through the Magpie Image MCP, moving past a member's 502; a chat-only group and one whose drawers are gone are missing), TestImageGenOffersDrawingGroups (gui). Broken by hand: - drawerMissing without the GroupDraws check: the gateway test is red ("chat-only group: drawer \"group/talkers\" missing \"\""). - api.go without the group loop: the gui test is red (group not offered). Not tried: a real group of real image accounts; a GUI test (app.js is unchanged: its picker already files an entry with no provider under Routing groups); the real Linux app.
65 lines
2.1 KiB
Go
65 lines
2.1 KiB
Go
package gui
|
||
|
||
import (
|
||
"os"
|
||
"testing"
|
||
|
||
"github.com/yetone/magpie/internal/provider"
|
||
"github.com/yetone/magpie/internal/settings"
|
||
)
|
||
|
||
// 7up6666 on X: Settings › Images offers each routing group with a member
|
||
// that draws, under the group's name with no provider of its own (the
|
||
// picker puts it with Routing groups); a group of chat models only isn't
|
||
// offered, and a picked group none of whose members draws is said missing.
|
||
func TestImageGenOffersDrawingGroups(t *testing.T) {
|
||
t.Setenv("HOME", t.TempDir())
|
||
t.Setenv("USERPROFILE", os.Getenv("HOME"))
|
||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
||
if err := provider.Save(provider.Provider{ID: "pics", Name: "Pics", Chat: "https://pics.example/v1", Key: "sk-p", Models: []string{"text", "gpt-image-1"}}); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
for _, g := range []provider.Group{
|
||
{ID: "painters", Name: "Painters", Members: []string{"pics/gpt-image-1"}},
|
||
{ID: "talkers", Name: "Talkers", Members: []string{"pics/text"}},
|
||
} {
|
||
if err := provider.SaveGroup(g); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
}
|
||
find := func(id string) (modelRef, bool) {
|
||
for _, m := range settingsState().ImageGenModels {
|
||
if m.ID == id {
|
||
return m, true
|
||
}
|
||
}
|
||
return modelRef{}, false
|
||
}
|
||
m, ok := find("group/painters")
|
||
if !ok || m.Provider != "" || m.Name != "Painters" {
|
||
t.Fatalf("drawing group offered as %+v %v", m, ok)
|
||
}
|
||
if _, ok := find("group/talkers"); ok {
|
||
t.Fatal("a chat-only group is offered to draw with")
|
||
}
|
||
if _, ok := find("pics/gpt-image-1"); !ok {
|
||
t.Fatal("the provider's own image model left the list")
|
||
}
|
||
st := settings.Load()
|
||
st.ImageGen = "group/talkers"
|
||
if err := settings.Save(st); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if s := settingsState(); s.ImageGenMissing != "group/talkers" {
|
||
t.Fatalf("a picked group that draws nothing isn't said missing: %q", s.ImageGenMissing)
|
||
}
|
||
st.ImageGen = "group/painters"
|
||
if err := settings.Save(st); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if s := settingsState(); s.ImageGenMissing != "" || s.ImageGenHidden {
|
||
t.Fatalf("a drawing group pick: missing %q hidden %v", s.ImageGenMissing, s.ImageGenHidden)
|
||
}
|
||
}
|