A provider's editor lists its image models as chips under "Image models"
("图像模型"); a click unticks one, and Save keeps it as the provider's
HiddenDrawers, a deny list beside the Models allow list. An unticked
model leaves Settings > Images' picker, Automatic's choice (and so the
Magpie Image MCP's when nothing is picked), the gateway's /v1/models
image entries and Aside's image options (gateway.OfferedDrawers).
A hidden model still draws when a request names it (resolveDrawing reads
Drawers), and a Settings > Images pick made before it was hidden stays
the pick: it is still listed, as picked, and the row says it is unticked
in its provider and leaves the list once another is picked
(ImageGenHidden), so a pick never stops drawing in silence. A Save that
leaves hiddenDrawers out keeps them; [] clears them. Strings in en, zh,
zh-TW, ja, de. docs/subsystems/gateway-routing.md has the section.
Run, at this and the next commit on e84f40369:
- mote: gofmt -l (none); go vet ./...; GOOS=linux go vet -tags nogui
./...; GOOS=windows go vet ./...; GOOS=linux go build -tags nogui;
GOOS=windows go build: ok. go test -count=1 -run
"Draw|Drawer|Image|Budget|HiddenDrawers|Account|Aside" over
internal/provider, gateway, gui and agent: all four ok.
- wsl-run (magpie-desktop, Playwright 1.62.0), Chromium and WebKit:
image-models-hide (new: en, zh, zh-TW, ja, de at 1000px and 360px),
images-missing, images-codex-one, image-mcp, image-timeout-setting,
images-library-way and i18n-keys: 182 of 182.
- Rebased again onto 4d9058a98 (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 on 0366e35c1, which changes only internal/catalog after it.
Before the rebase (on e15b2277c): the same vet and builds ok, and the
four packages whole with -timeout 45m: internal/provider ok (1061s);
gateway, gui and agent were still running on a loaded mote when this
was pushed (the owner's rule: no commit held behind a full suite).
- New tests: TestHiddenDrawerLeavesListsButStillDraws (gateway),
TestImageModelsHidden (gui), the HiddenDrawers round-trip in
account_test.go.
Broken by hand:
- OfferedDrawers returning every drawer: the gateway test is red
("offered [gpt-image-hidden gpt-image-shown]").
- The GUI test against the old app.js, api.go, draw.go and i18n.js:
21 of 26 red.
Not tried: real accounts; a full ./... run (mote at load 200 to 300);
the GUI run on mote (its Chromium crashed under that load, so the GUI
ran on WSL); the real Linux app.
91 lines
2.9 KiB
Go
91 lines
2.9 KiB
Go
package gateway
|
||
|
||
import (
|
||
"net/http"
|
||
"net/http/httptest"
|
||
"slices"
|
||
"testing"
|
||
|
||
"github.com/yetone/magpie/internal/catalog"
|
||
"github.com/yetone/magpie/internal/provider"
|
||
"github.com/yetone/magpie/internal/settings"
|
||
)
|
||
|
||
// 321sssrt on X: an image model unticked in its provider's editor
|
||
// (HiddenDrawers) leaves what lists image models to pick from, and
|
||
// Automatic, but still draws when named or picked in Settings › Images.
|
||
func TestHiddenDrawerLeavesListsButStillDraws(t *testing.T) {
|
||
fresh(t)
|
||
drawingRelay(t, "hd", "gpt-image-hidden", "gpt-image-shown")
|
||
found, err := provider.Find("hd")
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
p := *found
|
||
p.HiddenDrawers = []string{"gpt-image-hidden"}
|
||
if err := provider.Save(p); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
found, _ = provider.Find("hd")
|
||
p = *found
|
||
ids := func(ms []catalog.Model) (out []string) {
|
||
for _, m := range ms {
|
||
out = append(out, m.ID)
|
||
}
|
||
return
|
||
}
|
||
if got := ids(OfferedDrawers(p)); !slices.Equal(got, []string{"gpt-image-shown"}) {
|
||
t.Fatalf("offered %v", got)
|
||
}
|
||
if got := ids(Drawers(p)); !slices.Contains(got, "gpt-image-hidden") {
|
||
t.Fatalf("drawers lost the hidden one: %v", got)
|
||
}
|
||
if !DrawerHidden("hd/gpt-image-hidden") || DrawerHidden("hd/gpt-image-shown") || DrawerHidden("nope/gpt-image-hidden") {
|
||
t.Fatal("DrawerHidden")
|
||
}
|
||
|
||
var listed []string
|
||
for _, o := range drawerObjects(httptest.NewRequest(http.MethodGet, "/v1/models", nil)) {
|
||
listed = append(listed, o["id"].(string))
|
||
}
|
||
if slices.Contains(listed, "hd/gpt-image-hidden") || !slices.Contains(listed, "hd/gpt-image-shown") {
|
||
t.Fatalf("drawer objects %v", listed)
|
||
}
|
||
|
||
// Automatic never lands on the hidden one, whichever order it reads
|
||
for range 3 {
|
||
if a := AutoDrawer(); a == "hd/gpt-image-hidden" {
|
||
t.Fatalf("automatic picked the hidden model")
|
||
}
|
||
}
|
||
p.HiddenDrawers = []string{"gpt-image-hidden", "gpt-image-shown"}
|
||
if err := provider.Save(p); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if a := AutoDrawer(); a != "" {
|
||
t.Fatalf("automatic with every model hidden: %q", a)
|
||
}
|
||
|
||
// named, or picked in Settings, it still draws
|
||
if _, id, ok := resolveDrawing("hd/gpt-image-hidden"); !ok || id != "gpt-image-hidden" {
|
||
t.Fatalf("resolve named hidden: %q %v", id, ok)
|
||
}
|
||
if _, id, ok := resolveDrawing("gpt-image-hidden"); !ok || id != "gpt-image-hidden" {
|
||
t.Fatalf("resolve bare hidden: %q %v", id, ok)
|
||
}
|
||
st := settings.Load()
|
||
st.ImageGen = "hd/gpt-image-hidden"
|
||
if err := settings.Save(st); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if Drawer() != "hd/gpt-image-hidden" || DrawerMissing() != "" {
|
||
t.Fatalf("a hidden pick isn't what draws: %q missing %q", Drawer(), DrawerMissing())
|
||
}
|
||
s := New()
|
||
drawingMainTurn(t, s, "hd/text", "session", "turn", "", "magpie-codex")
|
||
code, answer, raw := drawingToolCall(t, s, "/v1/images/generations", "", "", "turn", "magpie-codex")
|
||
if code != 200 || answer.Model != "hd/gpt-image-hidden" {
|
||
t.Fatalf("settings pick hidden: %d %s", code, raw)
|
||
}
|
||
}
|