iceloon on X: under a base-URL provider's Image models a video model sat with no way to move it. A chat model's chip already had Makes… (#1399); the Image models and Video models chips now have the same right-click (Copy model ID, Makes: …), on a provider whose models can be marked (marksKinds). The pick is staged as on a chat chip and sent with Save as modelPrefs' kind; the chip's tick is untouched. /api/providers carries mediaKinds, so a marked media chip shows its tag and its pick. A subscription's image models get no such menu. No new strings. The core script budget goes up 316: the chat chip's Makes… is now shared with the media chips (kindAct, kindTag), and the media chip's Copy model ID was left out to pack it; the provider's editor draws these chips, so there is no page to move them to. Run (at077421733+ both commits): - mica: go vet -tags nogui ./internal/gui; go test -tags nogui -count=1 ./internal/gui ./internal/catalog: ok (before the rebase and the last 2-byte pack); mote: TestCoreScriptBudget, TestImageModelMarkedVideo and node --check at the pushed tree: ok. - mote, Chromium and WebKit, en/zh/ja/de, 900 and 420 wide: media-kind (new) and model-kind 32 of 32; i18n-keys, video-models-hide, image-models-hide ok. - mote, 106 GUI files the editor's chips reach (model-*, models-*, provider-*, image/video-models, i18n-*), before the rebase: 2259 pass, 106 red in 9 files. The same 9 files run at origin/main077421733are red the same (102 of 138): model-api-preset, model-chip-steady, model-copy-id, models-works-only, provider-fetch-again, provider-many-keys, provider-max-output, provider-models-rest, provider-picks-stay, filed as #6532, #6209, #4621 and #4388. - Broken by hand, each red, then restored: the media chip's right-click removed (media-kind 16 of 16 red), mediaKinds not filled in /api/providers (TestImageModelMarkedVideo).
61 lines
2.4 KiB
Go
61 lines
2.4 KiB
Go
package gui
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// An image model's chip in the editor can be said to make videos (iceloon
|
|
// on X: a Grok channel's video model sat among its Image models with no
|
|
// way to move it). Saved as modelPrefs' kind, it moves to the video
|
|
// models, and the editor is told what was said of it (mediaKinds), so its
|
|
// chip shows the tag and the menu its pick.
|
|
func TestImageModelMarkedVideo(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())
|
|
mux := http.NewServeMux()
|
|
providerRoutes(mux, nil)
|
|
post := func(body string) {
|
|
t.Helper()
|
|
w := httptest.NewRecorder()
|
|
mux.ServeHTTP(w, httptest.NewRequest("POST", "/api/provider/save", strings.NewReader(body)))
|
|
if w.Code != 200 {
|
|
t.Fatalf("%d %s", w.Code, w.Body.String())
|
|
}
|
|
}
|
|
const base = `"id":"chan","name":"Chan","key":"sk-c","chat":"https://chan.example/v1","icon":"generic"`
|
|
post(`{` + base + `,"new":true}`)
|
|
if err := catalog.SaveLive("chan", "https://chan.example/v1", []catalog.Model{{ID: "grok-4.3"}, {ID: "img-a", Draws: true}, {ID: "clip-x", Draws: true}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
info := func() providerJSON {
|
|
t.Helper()
|
|
p, err := provider.Find("chan")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return providerInfo(*p, nil)
|
|
}
|
|
if got := info(); !slices.Equal(got.DrawIDs, []string{"img-a", "clip-x"}) || len(got.FilmIDs) != 0 || got.MediaKinds != nil {
|
|
t.Fatalf("before: images %v videos %v kinds %v", got.DrawIDs, got.FilmIDs, got.MediaKinds)
|
|
}
|
|
post(`{` + base + `,"from":"chan","models":[],"headers":{},"modelPrefs":{"clip-x":{"kind":"video"}}}`)
|
|
got := info()
|
|
if !slices.Equal(got.DrawIDs, []string{"img-a"}) || !slices.Equal(got.FilmIDs, []string{"clip-x"}) || got.MediaKinds["clip-x"] != "video" || len(got.MediaKinds) != 1 {
|
|
t.Fatalf("after: images %v videos %v kinds %v", got.DrawIDs, got.FilmIDs, got.MediaKinds)
|
|
}
|
|
post(`{` + base + `,"from":"chan","models":[],"headers":{},"modelPrefs":{"clip-x":{"kind":""}}}`)
|
|
if got := info(); !slices.Equal(got.DrawIDs, []string{"img-a", "clip-x"}) || len(got.FilmIDs) != 0 || got.MediaKinds != nil {
|
|
t.Fatalf("back to Auto: images %v videos %v kinds %v", got.DrawIDs, got.FilmIDs, got.MediaKinds)
|
|
}
|
|
}
|