gui: an image or video model's chip says what it makes from its right-click
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).
This commit is contained in:
+44
-28
@@ -11338,24 +11338,6 @@ function renderModels(p) {
|
||||
status(v ? t("{model} is asked on {api} once saved", { model: id, api: apiLabel(v) }) : t("{model} is asked as its vendor's list says once saved", { model: id }), "ok");
|
||||
}, "API this model is asked on", "model-api-menu");
|
||||
};
|
||||
// what a model makes, said by the user (shen-joe, #1399), staged as its API is
|
||||
const kindNow = (id) => draft.modelPrefs?.[id]?.kind ?? p.models.find((m) => m.id === id)?.kind ?? "";
|
||||
const KIND_NAMES = { "": "Auto", image: "Image model", video: "Video model" };
|
||||
const pickKind = (c, id) => {
|
||||
const m = p.models.find((x) => x.id === id) || { id };
|
||||
const opts = [{ v: "", name: "Auto", note: "As its vendor's model list and its name say" },
|
||||
{ v: "image", name: "Image model", note: "Draws at the provider's images API (/images/generations), listed under Image generation" },
|
||||
{ v: "video", name: "Video model", note: "Makes videos at the provider's videos API (POST /videos, then GET /videos/<id>)" }];
|
||||
openProtoMenu(c, opts, kindNow(id), (v) => {
|
||||
if (v === kindNow(id)) return;
|
||||
const prefs = draft.modelPrefs = draft.modelPrefs || {};
|
||||
prefs[id] = prefs[id] || {};
|
||||
if (v === (m.kind || "")) delete prefs[id].kind; else prefs[id].kind = v;
|
||||
if (!Object.keys(prefs[id]).length) delete prefs[id];
|
||||
draw();
|
||||
status(t(v === "video" ? "{model} makes videos once saved" : v === "image" ? "{model} draws images once saved" : "{model} makes what its vendor's list says once saved", { model: id }), "ok");
|
||||
}, "What this model makes", "model-kind-menu");
|
||||
};
|
||||
// staged as Model settings' tick stages it (archsiono on X)
|
||||
const setImages = (id, m, v) => {
|
||||
const P = draft.modelPrefs = draft.modelPrefs || {}, x = P[id] = P[id] || {};
|
||||
@@ -11402,10 +11384,7 @@ function renderModels(p) {
|
||||
const on = x?.ownImages ? !!m.ownImages : x?.images ?? !!m.images;
|
||||
acts.push({ name: on ? "Turn off image input" : "Turn on image input", icon: "M2.5 3.5h11v9h-11zM2.5 10.5l3-3 2.5 2.5 2-2 3 3", tip: t("Whether agents are told {id} can see images", { id }), run: () => setImages(id, m, !on) });
|
||||
}
|
||||
if (p.marksKinds && !decidesModel(p, id)) {
|
||||
const k = kindNow(id);
|
||||
acts.push({ name: k ? t("Makes: {kind}…", { kind: t(KIND_NAMES[k]) }) : t("Makes: Auto…"), icon: "M2.5 4h11v8h-11zM6.5 6.25v3.5L9.5 8z", tip: t("Say this model makes images or videos, when the provider's model list doesn't"), run: () => pickKind(c, id) });
|
||||
}
|
||||
if (p.marksKinds && !decidesModel(p, id)) acts.push(kindAct(c, p, id, draw));
|
||||
openRowMenu(c, acts, { x: e.clientX, y: e.clientY });
|
||||
};
|
||||
// the API it is asked on, when one is picked (or staged)
|
||||
@@ -11415,12 +11394,7 @@ function renderModels(p) {
|
||||
tag.title = t("Asked on {api} alone; right-click to change", { api: apiLabel(now) });
|
||||
c.append(tag);
|
||||
}
|
||||
const kind = p.marksKinds && !decidesModel(p, id) ? kindNow(id) : "";
|
||||
if (kind) {
|
||||
const tag = el("span", "badge mkind-tag", t(kind === "video" ? "video" : "image"));
|
||||
tag.title = t("{kind}, as you said; right-click to change", { kind: t(KIND_NAMES[kind]) });
|
||||
c.append(tag);
|
||||
}
|
||||
if (p.marksKinds && !decidesModel(p, id)) kindTag(c, modelKindNow(p, id));
|
||||
};
|
||||
const box = el("div", "models");
|
||||
const chips = el("div", "mchips");
|
||||
@@ -12191,11 +12165,53 @@ function mediaChips(cls, ids, key, p, names) {
|
||||
show();
|
||||
};
|
||||
show();
|
||||
// its right-click says what it makes, as a chat model's does: a
|
||||
// video model its id doesn't name sat among the image models with
|
||||
// no way to move it (iceloon on X)
|
||||
if (p.marksKinds) {
|
||||
const tag = () => kindTag(c, modelKindNow(p, id));
|
||||
tag();
|
||||
c.oncontextmenu = (e) => {
|
||||
e.preventDefault();
|
||||
const again = agentMenu?.anchor === c || protoMenu?.anchor === c;
|
||||
closeAgentMenu(); closeProtoMenu();
|
||||
again || openRowMenu(c, [kindAct(c, p, id, tag)], { x: e.clientX, y: e.clientY });
|
||||
};
|
||||
}
|
||||
chips.append(c);
|
||||
}
|
||||
return chips;
|
||||
}
|
||||
|
||||
// what a model makes, said by the user (shen-joe, #1399), staged in
|
||||
// draft.modelPrefs as its API is: a chat model's, or an image or video
|
||||
// model's, listed apart (p.mediaKinds)
|
||||
const KIND_NAMES = { "": "Auto", image: "Image model", video: "Video model" };
|
||||
const savedModelKind = (p, id) => p.models.find((m) => m.id === id)?.kind ?? p.mediaKinds?.[id] ?? "";
|
||||
const modelKindNow = (p, id) => draft.modelPrefs?.[id]?.kind ?? savedModelKind(p, id);
|
||||
|
||||
// kindAct: the right-click menu's Makes… for p's model id, staged in
|
||||
// draft.modelPrefs; redraw shows what was staged
|
||||
function kindAct(c, p, id, redraw) {
|
||||
const k = modelKindNow(p, id);
|
||||
return { name: k ? t("Makes: {kind}…", { kind: t(KIND_NAMES[k]) }) : t("Makes: Auto…"), icon: "M2.5 4h11v8h-11zM6.5 6.25v3.5L9.5 8z", tip: t("Say this model makes images or videos, when the provider's model list doesn't"), run: () => openProtoMenu(c, [{ v: "", name: "Auto", note: "As its vendor's model list and its name say" },
|
||||
{ v: "image", name: "Image model", note: "Draws at the provider's images API (/images/generations), listed under Image generation" },
|
||||
{ v: "video", name: "Video model", note: "Makes videos at the provider's videos API (POST /videos, then GET /videos/<id>)" }], k, (v) => {
|
||||
if (v == k) return;
|
||||
const P = draft.modelPrefs ||= {}, x = P[id] ||= {};
|
||||
if (v == savedModelKind(p, id)) delete x.kind; else x.kind = v;
|
||||
if (!Object.keys(x).length) delete P[id];
|
||||
redraw();
|
||||
status(t(v === "video" ? "{model} makes videos once saved" : v === "image" ? "{model} draws images once saved" : "{model} makes what its vendor's list says once saved", { model: id }), "ok");
|
||||
}, "What this model makes", "model-kind-menu") };
|
||||
}
|
||||
|
||||
// kindTag: chip c's tag of what the user said it makes, or none
|
||||
function kindTag(c, kind) {
|
||||
c.querySelector(".mkind-tag")?.remove();
|
||||
if (kind) c.append(Object.assign(el("span", "badge mkind-tag", t(kind === "video" ? "video" : "image")), { title: t("{kind}, as you said; right-click to change", { kind: t(KIND_NAMES[kind]) }) }));
|
||||
}
|
||||
|
||||
// renderRouting: spread over keys or accounts and stickiness, staged in
|
||||
// the draft and made with Save (01huadalang on Discord)
|
||||
const ROUTINGS = [
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
// `git log -L` of this file.
|
||||
const (
|
||||
appScriptBudget = 1_086_267 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had
|
||||
coreScriptBudget = 1_268_645 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line
|
||||
coreScriptBudget = 1_268_961 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to
|
||||
)
|
||||
|
||||
// codeBytes is how many bytes of b are code: its blank lines, its lines
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -441,8 +441,12 @@ type providerJSON struct {
|
||||
// (provider.HiddenVideomakers)
|
||||
FilmIDs []string `json:"filmIds,omitempty"`
|
||||
HiddenVideomakers []string `json:"hiddenVideomakers,omitempty"`
|
||||
Unlisted bool `json:"unlisted"` // its models serve only through routing groups
|
||||
NoModels bool `json:"noModels"` // Select none: none of its models served (#1818)
|
||||
// what the user said those image and video models make
|
||||
// (provider.ModelKind), by id: they aren't among Models, whose kind is
|
||||
// said there, and a chip's right-click starts from it (iceloon on X)
|
||||
MediaKinds map[string]string `json:"mediaKinds,omitempty"`
|
||||
Unlisted bool `json:"unlisted"` // its models serve only through routing groups
|
||||
NoModels bool `json:"noModels"` // Select none: none of its models served (#1818)
|
||||
// Best in family: with nothing picked, only the newest model of each
|
||||
// family it lists is served (provider.Provider.BestInFamily)
|
||||
BestInFamily bool `json:"bestInFamily"`
|
||||
@@ -1309,6 +1313,14 @@ func providerInfoWith(p provider.Provider, ls provider.Listing, agents []agentUs
|
||||
out.HiddenVideomakers = append(out.HiddenVideomakers, m.ID)
|
||||
}
|
||||
}
|
||||
for _, id := range append(slices.Clone(out.DrawIDs), out.FilmIDs...) {
|
||||
if k := p.ModelKind(id); k != "" {
|
||||
if out.MediaKinds == nil {
|
||||
out.MediaKinds = map[string]string{}
|
||||
}
|
||||
out.MediaKinds[id] = k
|
||||
}
|
||||
}
|
||||
if t, ok := p.Listed(); ok {
|
||||
out.Fetched = &t
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// An image model's chip says what it makes from its right-click, as a chat
|
||||
// model's does (iceloon on X: a Grok channel's video models sat under Image
|
||||
// models, and nothing there could mark them Video). On a provider set up
|
||||
// with a base URL (marksKinds), an Image models chip's right-click has
|
||||
// "Makes: Auto…": the pick opens the app's menu, is staged — the chip
|
||||
// tagged, its tick unchanged, nothing saved — and goes with the Save as
|
||||
// modelPrefs' kind. A Video models chip the user marked shows its tag and
|
||||
// its pick. A subscription's image models have no such menu. In English,
|
||||
// Chinese, Japanese and German, at a wide and a narrow window.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const base = { icon: "generic", catalog: "", agents: [], fallback: [], headers: {}, keyList: [], balanceToken: { takes: false, set: false }, proxy: "" };
|
||||
const relay = {
|
||||
...base, id: "relay", name: "Relay", chat: "https://relay.example.com/v1", responses: "", anthropic: "", marksKinds: true,
|
||||
models: [{ id: "grok-4.3", name: "grok-4.3", on: true }],
|
||||
drawIds: ["grok-imagine-image", "clip-x"], filmIds: ["film-z"], mediaKinds: { "film-z": "video" },
|
||||
key: { set: true, masked: "sk-…one" },
|
||||
};
|
||||
const sub = {
|
||||
...base, id: "codex", name: "Codex Sub", icon: "openai",
|
||||
chat: "https://chatgpt.com/backend-api/codex", responses: "", anthropic: "",
|
||||
account: { agent: "codex", user: "octo", accounts: [] },
|
||||
models: [{ id: "gpt-9", name: "GPT-9", on: true }], drawIds: ["gpt-image-9"],
|
||||
key: { set: false, masked: "" },
|
||||
};
|
||||
|
||||
function serve(lang, posts) {
|
||||
const providers = { providers: [relay, sub], presets: [], excluded: [], gateway: { running: true, window: true } };
|
||||
const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json(state);
|
||||
if (url.pathname === "/api/providers") return json(providers);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/provider/save") { posts.push(route.request().postDataJSON()); return json(providers); }
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
const words = {
|
||||
en: { auto: "Makes: Auto…", video: "Video model", videoAct: "Makes: Video model…", tagVideo: "video", save: "Save", staged: "clip-x makes videos once saved" },
|
||||
zh: { auto: "类型:自动…", video: "视频模型", videoAct: "类型:视频模型…", tagVideo: "视频", save: "保存", staged: "保存后 clip-x 将作为视频模型" },
|
||||
ja: { auto: "種類:自動…", video: "動画モデル", videoAct: "種類:動画モデル…", tagVideo: "動画", save: "保存", staged: "保存すると clip-x は動画モデルになります" },
|
||||
de: { auto: "Erzeugt: Automatisch…", video: "Videomodell", videoAct: "Erzeugt: Videomodell…", tagVideo: "Video", save: "Speichern", staged: "clip-x erzeugt nach dem Speichern Videos" },
|
||||
};
|
||||
|
||||
// scroll the chip in and let the frame pass before the right-click, or
|
||||
// Chromium's late scroll event closes the menu it opened
|
||||
async function rclick(loc) {
|
||||
await loc.click({ button: "right", trial: true });
|
||||
await loc.page().evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
|
||||
await loc.click({ button: "right" });
|
||||
}
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of Object.keys(words)) {
|
||||
for (const width of [900, 420]) {
|
||||
const w = words[lang];
|
||||
test(`${engine} ${lang} ${width}: an image model's chip marked a video model, staged and saved`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-media-kind.png`) });
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
const posts = [];
|
||||
await page.route("**/*", serve(lang, posts));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
const open = async (name) => {
|
||||
await page.locator(".row.provider", { hasText: name }).first().click();
|
||||
await page.locator(".editor .mchips.drawers .mchip").first().waitFor();
|
||||
};
|
||||
const drawer = (id) => page.locator(".editor .mchips.drawers .mchip", { hasText: id });
|
||||
const film = (id) => page.locator(".editor .mchips.videomakers .mchip", { hasText: id });
|
||||
const rowMenu = page.locator(".pop.row-menu");
|
||||
const kindMenu = page.locator(".pop.proto-menu.model-kind-menu");
|
||||
|
||||
await open("Relay");
|
||||
// a video model the user marked: its tag, and its pick in the menu
|
||||
assert.equal(await film("film-z").locator(".mkind-tag").textContent(), w.tagVideo);
|
||||
await rclick(film("film-z"));
|
||||
await rowMenu.getByRole("menuitem", { name: w.videoAct }).waitFor();
|
||||
await page.keyboard.press("Escape");
|
||||
await rowMenu.waitFor({ state: "detached" });
|
||||
|
||||
const clip = drawer("clip-x");
|
||||
assert.equal(await clip.locator(".mkind-tag").count(), 0);
|
||||
const pressed = await clip.getAttribute("aria-pressed");
|
||||
await rclick(clip);
|
||||
await rowMenu.getByRole("menuitem", { name: w.auto }).waitFor();
|
||||
assert.equal(await rowMenu.getByRole("menuitem").count(), 1, "Makes… alone");
|
||||
await rowMenu.getByRole("menuitem", { name: w.auto }).click();
|
||||
await kindMenu.waitFor();
|
||||
assert.equal(await kindMenu.locator(".pm-item").count(), 3, "Auto, image and video");
|
||||
assert.equal(await page.locator(".editor select").count(), 0, "no native select");
|
||||
const box = await kindMenu.boundingBox();
|
||||
assert(box.x >= 0 && box.x + box.width <= width + 0.5, `the menu fits the window: ${JSON.stringify(box)}`);
|
||||
await kindMenu.locator(".pm-item", { hasText: w.video }).click();
|
||||
await kindMenu.waitFor({ state: "detached" });
|
||||
await clip.locator(".mkind-tag").waitFor();
|
||||
assert.equal(await clip.locator(".mkind-tag").textContent(), w.tagVideo);
|
||||
assert.equal(await page.locator("#status").textContent(), w.staged);
|
||||
assert.equal(await clip.getAttribute("aria-pressed"), pressed, "the right-click didn't tick or untick it");
|
||||
assert.equal(await drawer("grok-imagine-image").locator(".mkind-tag").count(), 0, "only the one marked");
|
||||
assert.equal(posts.length, 0, "staged, not saved");
|
||||
await page.locator(".editor").getByRole("button", { name: w.save, exact: true }).click();
|
||||
for (let i = 0; i < 40 && !posts.length; i++) await page.waitForTimeout(50);
|
||||
assert.deepEqual(posts[0]?.modelPrefs, { "clip-x": { kind: "video" } });
|
||||
|
||||
// a subscription's image models can't be marked: on a page loaded
|
||||
// afresh, the Save's own reply left aside
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await open("Codex Sub");
|
||||
await rclick(drawer("gpt-image-9"));
|
||||
await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
|
||||
assert.equal(await rowMenu.count(), 0, "no menu to mark it");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user