jzw690 on X: the Routing page's group editor ("Add a model") listed no
image models, so a group of image models, to draw at
/v1/images/generations and to pick in Settings > Images, couldn't be
made.
What changed:
- /api/groups gains `drawers`: each provider's image models
(gateway.Drawers, less ones unticked in its editor unless a group
names them), apart from the chat `models`. The picker offers them
after the chat models, noted "<provider> · Image model" (an existing,
translated key); a member row says so and offers no reasoning level.
Decision-model groups don't offer them. Image models stay out of the
chat catalog, so agents are not offered them.
- An image member drew only when its provider had no picks: picks are
of chat models, so membersFound dropped it as unpicked, and GroupDraws,
resolveDrawing, the group's turns and DrawerMissing all failed.
provider.FindDrawingGroup keeps such a member when drawsModel holds;
the image path uses it (drawingMembers), video keeps FindGroup.
DrawerMissing for a group ref asks GroupDraws.
- Routing card: such a member reads ready (groupsState), and Settings >
Images lists every group that draws, not only those reached through
Served.
- docs/subsystems/gateway-routing.md says so.
Tests:
- TestImageGroupOfUnpickedImageModelsDraws (gateway), from the
reporter's case: two key providers whose live lists hold gpt-5.5 and
gpt-image-2, one with gpt-5.5 picked. group/<id> draws at
/v1/images/generations (the first member's 502 moves on to the next),
as the Settings pick a request naming no model draws, and the model
gone from the list makes it missing.
- TestGroupEditorOffersImageModels (gui): drawers listed, an unticked
one not offered unless a group names it, none among chat models, the
group's members ready, Settings offers the group.
- group-pick-drawers.test.cjs: the picker offers it with its note, adds
it, no reasoning button, Save posts it; en and zh, Chromium and
WebKit.
Broken by hand: drawingMembers passing nil instead of drawsModel made
the gateway test red ("group/pix-images doesn't draw"); turning off the
groups.go drawer branch made the gui test red ("group not ready").
Run at b295d1196 plus this change (mote unless said):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok.
- go test -count=1 -timeout 45m ./internal/provider ./internal/gateway
./internal/gui: provider ok. Two reds, neither on this path:
TestCodexPoolSaysTheClientsVersion (full run only, passes alone 3/3;
#4807) and TestMainWindowCorners (red on origin/main f49f6ba68 too,
macOS 27; #3949). Both commented.
- GUI on the Linux VM (Playwright 1.62.0, both engines), 62 files:
group-*, routing-group*, settings-groups, fallback-group,
agent-model-groups, image*/images*, panel-routing*, routing-manual,
routing-levels, i18n-keys. 698/710. i18n-keys was red on a comment of
this change saying ", with an image" (reworded; 4/4 after). The
WebKit reds under concurrency 4 passed on a serial run except
group-member-info webkit zh, red 2/2 on origin/main f49f6ba68 too
(#1745, commented).
Rebased on origin/main 809801f1f (its 8 commits change client.js and
gateway-routing.md), then again on mote: gofmt clean, go test -run
of the budgets, TestImageGroup*, TestDrawing*, TestGroupMember* and
TestGroupEditorOffersImageModels in gateway, gui and provider: ok; on
the Linux VM, both engines, group-pick-drawers, group-pick-filter,
group-decide-members, group-editor-fits, group-member-off,
routing-levels, settings-groups, image-models-hide, i18n-keys: 96/96.
Rebased last onto 03d7927a8 (search strings, i18n.js values only;
none of this change's files), not run again.
Not tried: a real provider's image model drawn through a group in the
running app; Windows and the real Linux app (WebKitGTK).
77 lines
2.7 KiB
Go
77 lines
2.7 KiB
Go
package gui
|
||
|
||
import (
|
||
"os"
|
||
"slices"
|
||
"testing"
|
||
|
||
"github.com/yetone/magpie/internal/catalog"
|
||
"github.com/yetone/magpie/internal/provider"
|
||
)
|
||
|
||
// jzw690 on X: the group editor's "Add a model" offers a provider's
|
||
// image models (its live list's gpt-image-2) beside its chat models, as
|
||
// drawers apart from them; a group holding one, from a provider whose
|
||
// picks leave it out, shows it ready, and Settings › Images offers that
|
||
// group. One unticked in its provider's editor isn't offered, unless a
|
||
// group names it already.
|
||
func TestGroupEditorOffersImageModels(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())
|
||
live := []catalog.Model{{ID: "gpt-5.5"}, {ID: "gpt-image-2", Draws: true}, {ID: "gpt-image-1", Draws: true}}
|
||
for _, p := range []provider.Provider{
|
||
{ID: "relay", Name: "Relay", Key: "k", Chat: "http://127.0.0.1:1/v1"},
|
||
{ID: "pix", Name: "Pix", Key: "k", Chat: "http://127.0.0.1:2/v1", Models: []string{"gpt-5.5"}, HiddenDrawers: []string{"gpt-image-1"}},
|
||
} {
|
||
if err := provider.Save(p); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if err := catalog.SaveLive(p.ID, p.Chat, live); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
}
|
||
ids := func(ms []modelRef) []string {
|
||
var out []string
|
||
for _, m := range ms {
|
||
out = append(out, m.ID)
|
||
}
|
||
return out
|
||
}
|
||
st := groupsState()
|
||
for _, want := range []string{"relay/gpt-image-2", "relay/gpt-image-1", "pix/gpt-image-2"} {
|
||
if !slices.Contains(ids(st.Drawers), want) {
|
||
t.Fatalf("%s not offered: drawers %v", want, ids(st.Drawers))
|
||
}
|
||
}
|
||
if slices.Contains(ids(st.Drawers), "pix/gpt-image-1") {
|
||
t.Fatalf("an unticked image model is offered: %v", ids(st.Drawers))
|
||
}
|
||
for _, m := range st.Models {
|
||
if slices.Contains(ids(st.Drawers), m.ID) || m.ID == "pix/gpt-image-2" {
|
||
t.Fatalf("an image model among the chat models: %s", m.ID)
|
||
}
|
||
}
|
||
|
||
if err := provider.SaveGroup(provider.Group{ID: "pix-images", Name: "Pix images", Members: []string{"pix/gpt-image-2", "pix/gpt-image-1"}}); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
st = groupsState()
|
||
if !slices.Contains(ids(st.Drawers), "pix/gpt-image-1") {
|
||
t.Fatalf("an unticked image model a group names isn't listed for its card: %v", ids(st.Drawers))
|
||
}
|
||
i := slices.IndexFunc(st.Groups, func(g groupJSON) bool { return g.ID == "pix-images" })
|
||
if i < 0 || !st.Groups[i].Ready {
|
||
t.Fatalf("group not ready: %+v", st.Groups)
|
||
}
|
||
for _, m := range st.Groups[i].Info {
|
||
if !m.Ready || m.Provider != "pix" || m.Model == "" {
|
||
t.Fatalf("member shown as missing: %+v", m)
|
||
}
|
||
}
|
||
if !slices.ContainsFunc(settingsState().ImageGenModels, func(m modelRef) bool { return m.ID == "group/pix-images" }) {
|
||
t.Fatal("Settings › Images doesn't offer the group")
|
||
}
|
||
}
|