gui: Names in agents' lists names the connected agents it changes nothing in (love1sbug on X)
love1sbug on X found Names in agents' lists seemed to do nothing. Claude Code and Qwen Code follow it now; a sweep of every agent in a sandbox HOME (each set to one relay model, the setting switched, the files compared) found the rest that follow it, and those that can't: - handed the models' ids alone, their formats having no name for one: Goose, jcode, Hermes Agent, Reasonix Studio, AtomCode, fx, Antigravity CLI, AstrBot, Mister Morph; - with no list of magpie's models: Gemini CLI, Snow CLI; - reading the gateway's /v1/models themselves, whose display_name is the name alone on purpose (a remote magpie relies on it): Empryo, Cursor Private Inference. Those carry agent.NoNames (copied to an agent in WSL), sent to the GUI as noNames. Where the setting is offered (Settings › Provider in model names, Routing's Names in agents' lists, a provider's Names & levels) a line names the connected ones: "Changes nothing in Goose, Hermes Agent: magpie's names don't reach their model lists", in every language. With none connected nothing is said, so the Settings row keeps no line under its name (1ooogle on X, model-suffix-own's check). A page drawn before the agents are read (Routing, an open provider editor) says it once they are (redrawNoNames, beside redrawSuffix). name-suffix-no-names.test.cjs checks the three places in chromium and webkit, en/zh/zh-TW/ja/de, at 900px and 390px with no sideways scroll, that an agent not connected or following it isn't named, that none says nothing, and, with /api/state answered 1.5s late, that all three still say it. On the old assets 12 of the first 13 chromium tests fail; the late case failed on this commit's first version too (found when a loaded run failed the editor's case; reproduced with the injected delay). Run: that test and i18n-keys, gateway-mode, model-suffix-own, name-suffix-remote, name-suffix-saved, name-suffix-where-named, settings-general/groups/search/sections in both engines; go test -tags nogui ./internal/agent ./internal/gui ./internal/provider ./internal/gateway (before the rebase); gofmt -l; go vet darwin/linux/windows. With 11 files at once at load 80-120, webkit failed once on this test's "no page errors" check (ja 900px, the late case) beside settings-sections' "Settings in parts"; not reproduced in 3 runs since (10 files, then 8 copies at once), and the errors weren't kept. Not tried: the GUI against a real magpie with Goose connected.
This commit is contained in:
@@ -123,6 +123,14 @@ type Agent struct {
|
||||
// list magpie writes into its files, magpieModels(id), where its only
|
||||
// field puts magpie in its picker (ZCode, Pencil: #1508)
|
||||
ListsModels bool
|
||||
// NoNames: the agent's own list doesn't name magpie's models as
|
||||
// Names in agents' lists says (provider.Labels): magpie hands it the
|
||||
// models' ids alone, its format having no name for one (Goose, Hermes,
|
||||
// jcode …), it lists no models of magpie's at all (Gemini CLI, Snow),
|
||||
// or it reads the gateway's /v1/models itself, whose display_name is
|
||||
// the name alone (Empryo, Cursor Private Inference). The setting says
|
||||
// so for each one connected, rather than seeming to do nothing.
|
||||
NoNames bool
|
||||
// Sync, for an agent that reads magpie's models from a file of its own
|
||||
// rather than asking the gateway, rewrites that list as the catalog is
|
||||
// now — where magpie wrote one; nothing else changes (see SyncCatalog).
|
||||
|
||||
@@ -1102,7 +1102,7 @@ func gooseIn(at place, cfg string) *Agent {
|
||||
keyEnv = func(string) string { return "" }
|
||||
}
|
||||
return &Agent{
|
||||
ID: "goose", Name: "Goose", Icon: "goose", Bin: "goose", Dir: filepath.Dir(path), Path: path, Spelled: prefixed,
|
||||
ID: "goose", Name: "Goose", Icon: "goose", Bin: "goose", Dir: filepath.Dir(path), Path: path, Spelled: prefixed, NoNames: true,
|
||||
UA: []string{"goose"},
|
||||
Check: func() string {
|
||||
if p, _ := gooseActive(path); p != gooseProviderID {
|
||||
|
||||
@@ -98,7 +98,7 @@ func agy(home string) *Agent {
|
||||
return edit.SetJSON(path, edit.KV{Path: key, Value: v})
|
||||
}
|
||||
return &Agent{
|
||||
ID: "agy", Name: "Antigravity CLI", Icon: "antigravity-color", Aliases: []string{"antigravity-cli"}, Spelled: prefixed,
|
||||
ID: "agy", Name: "Antigravity CLI", Icon: "antigravity-color", Aliases: []string{"antigravity-cli"}, Spelled: prefixed, NoNames: true,
|
||||
Bin: "agy", Dir: dir, Path: path,
|
||||
Launch: func() string {
|
||||
if v := get(); usesMagpie(v) {
|
||||
|
||||
@@ -243,7 +243,7 @@ func astrbotAt(at place) *Agent {
|
||||
return setPick(v)
|
||||
}
|
||||
return atomic(&Agent{
|
||||
ID: "astrbot", Name: "AstrBot", Icon: "astrbot", Spelled: prefixed,
|
||||
ID: "astrbot", Name: "AstrBot", Icon: "astrbot", Spelled: prefixed, NoNames: true,
|
||||
Bin: "astrbot", Dir: data, Path: path,
|
||||
Notice: func() string {
|
||||
return noticeAstrbot.String()
|
||||
|
||||
@@ -112,7 +112,7 @@ func atomcodeIn(at place) *Agent {
|
||||
return edit.SetTOMLTablesMatching(path, atomcodeAccountNames, atomcodeTablePrefixes, nil)
|
||||
}
|
||||
return atomic(&Agent{
|
||||
ID: "atomcode", Name: "AtomCode", Icon: "atomcode", Spelled: prefixed,
|
||||
ID: "atomcode", Name: "AtomCode", Icon: "atomcode", Spelled: prefixed, NoNames: true,
|
||||
UA: []string{"atomcode"},
|
||||
Bin: "atomcode", Dir: dir, Path: path,
|
||||
Sync: func() error {
|
||||
|
||||
@@ -281,7 +281,7 @@ func KeepCursorLocalEnv(context.Context) {
|
||||
|
||||
func cursorLocal() *Agent {
|
||||
return &Agent{
|
||||
ID: CursorLocalID, Name: cursorLocalName, Icon: "cursor", Aliases: []string{"cursor-private-inference"},
|
||||
ID: CursorLocalID, Name: cursorLocalName, Icon: "cursor", Aliases: []string{"cursor-private-inference"}, NoNames: true,
|
||||
// its model picker lists the gateway's /models as its key is shown
|
||||
// them, which the row's Models button picks
|
||||
ListsModels: true,
|
||||
|
||||
@@ -102,7 +102,7 @@ func empryoAt(at place) *Agent {
|
||||
return edit.SetJSON(path, edit.KV{Path: empryoModel, Value: v})
|
||||
}
|
||||
return atomic(&Agent{
|
||||
ID: "empryo", Name: "Empryo", Icon: "empryo-color", Aliases: []string{"soulforge"}, Spelled: prefixed,
|
||||
ID: "empryo", Name: "Empryo", Icon: "empryo-color", Aliases: []string{"soulforge"}, Spelled: prefixed, NoNames: true,
|
||||
Bin: "empryo", Dir: dir, Path: path,
|
||||
Notice: func() string {
|
||||
if Running(`(^|/)empryo( |$)`) {
|
||||
|
||||
@@ -57,7 +57,7 @@ func fxIn(at place) *Agent {
|
||||
return edit.DelJSON(path, keys...)
|
||||
}
|
||||
return &Agent{
|
||||
ID: "fx", Name: "fx", Icon: "fx", Spelled: prefixed,
|
||||
ID: "fx", Name: "fx", Icon: "fx", Spelled: prefixed, NoNames: true,
|
||||
Dir: dir, Path: path,
|
||||
// ~/.fx is where its settings are. No command: `fx` is a common name
|
||||
// (the JSON viewer has it too), as in WSL (wsl.go).
|
||||
|
||||
@@ -182,7 +182,7 @@ func geminiIn(at place) *Agent {
|
||||
}
|
||||
|
||||
return &Agent{
|
||||
ID: "gemini", Name: "Gemini CLI", Icon: "geminicli-color", Aliases: []string{"gemini-cli"},
|
||||
ID: "gemini", Name: "Gemini CLI", Icon: "geminicli-color", Aliases: []string{"gemini-cli"}, NoNames: true,
|
||||
UA: []string{"geminicli", "gemini-cli"},
|
||||
Bin: "gemini", Dir: dir, Path: path,
|
||||
// its model's default forgets what it had before magpie, its
|
||||
|
||||
@@ -83,7 +83,7 @@ func hermesIn(at place) *Agent {
|
||||
return edit.SetYAML(path, kvs...)
|
||||
}
|
||||
return &Agent{
|
||||
ID: "hermes", Name: "Hermes Agent", Icon: "hermes", Aliases: []string{"hermes-agent"}, Spelled: prefixed,
|
||||
ID: "hermes", Name: "Hermes Agent", Icon: "hermes", Aliases: []string{"hermes-agent"}, Spelled: prefixed, NoNames: true,
|
||||
UA: []string{"hermes-agent"},
|
||||
Bin: "hermes", Dir: dir, Path: path,
|
||||
Sync: func() error {
|
||||
|
||||
@@ -285,7 +285,7 @@ func jcodeAt(at place) *Agent {
|
||||
return edit.SetTOMLTablesMatching(path, []string{jcodeProfile}, []string{jcodeProfile + "."}, nil)
|
||||
}
|
||||
return atomic(&Agent{
|
||||
ID: "jcode", Name: "jcode", Icon: "jcode", Spelled: prefixed,
|
||||
ID: "jcode", Name: "jcode", Icon: "jcode", Spelled: prefixed, NoNames: true,
|
||||
Bin: "jcode", Dir: dir, Path: path,
|
||||
Notice: func() string {
|
||||
if Running(`(^|/)jcode( |$)`) {
|
||||
|
||||
@@ -89,7 +89,7 @@ func morphIn(at place) *Agent {
|
||||
return 0
|
||||
}
|
||||
return &Agent{
|
||||
ID: "morph", Name: "Mister Morph", Icon: "mistermorph-color", Aliases: []string{"mistermorph", "mister-morph"}, Spelled: prefixed,
|
||||
ID: "morph", Name: "Mister Morph", Icon: "mistermorph-color", Aliases: []string{"mistermorph", "mister-morph"}, Spelled: prefixed, NoNames: true,
|
||||
UA: []string{morphUA},
|
||||
// no Bin: morph is other tools' name too; ~/.morph is made by its
|
||||
// first run, `morph install` or the desktop app's setup
|
||||
|
||||
@@ -297,7 +297,7 @@ func reasonixIn(at place) *Agent {
|
||||
}
|
||||
|
||||
a := &Agent{
|
||||
ID: "reasonix", Name: "Reasonix Studio", Icon: "reasonix-color", Aliases: []string{"reasonix-studio"},
|
||||
ID: "reasonix", Name: "Reasonix Studio", Icon: "reasonix-color", Aliases: []string{"reasonix-studio"}, NoNames: true,
|
||||
Bin: "reasonix", Dir: dir, Path: path, UA: []string{"reasonix"},
|
||||
detect: func() bool { return reasonixDetected(at.home) },
|
||||
Notice: func() string {
|
||||
|
||||
@@ -218,7 +218,7 @@ func snowIn(at place) *Agent {
|
||||
}
|
||||
|
||||
return atomic(&Agent{
|
||||
ID: "snow", Name: "Snow CLI", Icon: "snow", Aliases: []string{"snow-cli", "snow-ai", "snow-app"}, Spelled: prefixed,
|
||||
ID: "snow", Name: "Snow CLI", Icon: "snow", Aliases: []string{"snow-cli", "snow-ai", "snow-app"}, Spelled: prefixed, NoNames: true,
|
||||
Bin: "snow", Dir: dir, Path: ours,
|
||||
Sync: func() error {
|
||||
b, err := edit.Read(ours)
|
||||
|
||||
@@ -741,7 +741,7 @@ func wslAgent(k wslKind, d distro) *Agent {
|
||||
// files, which starts the distro.
|
||||
func asleep(live *Agent, k wslKind, d distro) *Agent {
|
||||
started := false
|
||||
a := &Agent{ID: live.ID, Name: live.Name, Icon: live.Icon, WSL: d.Name, detect: live.detect, Spelled: live.Spelled, ModelAliases: live.ModelAliases,
|
||||
a := &Agent{ID: live.ID, Name: live.Name, Icon: live.Icon, WSL: d.Name, detect: live.detect, Spelled: live.Spelled, ModelAliases: live.ModelAliases, NoNames: live.NoNames,
|
||||
Notice: func() string {
|
||||
if started {
|
||||
return live.Notice()
|
||||
|
||||
@@ -198,6 +198,9 @@ type agentJSON struct {
|
||||
// Menu: its own model menu is the models picked here, no one model to
|
||||
// start on (agent.ListsModels): ZCode's, Cursor Private Inference's
|
||||
Menu bool `json:"menu,omitempty"`
|
||||
// NoNames: its own list doesn't name magpie's models as Names in agents'
|
||||
// lists says (agent.NoNames), for that setting to say so
|
||||
NoNames bool `json:"noNames,omitempty"`
|
||||
// Source: what an agent not connected runs on now (agent.Source), and
|
||||
// Stale: copies of a connected one still running on the list they
|
||||
// started with (agent.Stale), for the line under its name
|
||||
@@ -2036,6 +2039,7 @@ func state() stateJSON {
|
||||
aj := agentJSON{ID: a.ID, Name: a.Name, Icon: a.Icon, Path: tilde(a.Path), Fields: agentFields(a, vals)}
|
||||
aj.Models = agentModelCount(a, aj.Fields)
|
||||
aj.Menu = a.ListsModels
|
||||
aj.NoNames = a.NoNames
|
||||
aj.Drift = a.Drift()
|
||||
aj.Wired = a.Wired()
|
||||
if aj.Wired {
|
||||
|
||||
@@ -2916,6 +2916,7 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
/* how the agents' lists will call them, and the setting that says so (#868) */
|
||||
.msuffix { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 2px 8px 4px; font-size: 12px; }
|
||||
.msuffix .hint { font-size: 11px; color: var(--faint); overflow-wrap: anywhere; }
|
||||
.msuffix .no-names { flex-basis: 100%; font-size: 11px; color: var(--faint); overflow-wrap: anywhere; }
|
||||
.mname { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
|
||||
.mname .mwho { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 0; }
|
||||
.mname .mwho input { flex: 1; min-width: 0; max-width: 220px; height: 25px; }
|
||||
|
||||
@@ -3818,6 +3818,7 @@ async function load(again) {
|
||||
tintTitleBar();
|
||||
renderAgents();
|
||||
redrawSuffix();
|
||||
redrawNoNames();
|
||||
// Update all's outcome stays until the agents are read again
|
||||
if (cliAll && cliAll.done >= cliAll.n) cliAll = null;
|
||||
paintUpdateAll(true);
|
||||
@@ -10886,6 +10887,7 @@ function renderModels(p) {
|
||||
};
|
||||
sayLabel();
|
||||
sfx.append(el("span", "", t("Provider in model names")), suffixSegs(sayLabel), sfxSaid);
|
||||
sfx.append(noNamesLine("span", "said"));
|
||||
names.append(sfx);
|
||||
// the APIs a model can be asked on alone: those of a key's provider
|
||||
// it has a URL for, when it has more than one (01huadalang on Discord:
|
||||
@@ -21721,6 +21723,38 @@ function suffixSegs(drawn) {
|
||||
seg.drawnAgain = drawn;
|
||||
return seg;
|
||||
}
|
||||
// noNamesSaid: what Provider in model names can't change, said under it:
|
||||
// the connected agents whose own lists don't name magpie's models as it
|
||||
// says (agent.NoNames: handed ids alone, or the gateway's names alone).
|
||||
// love1sbug on X found the setting seemed to do nothing; "" when none is.
|
||||
function noNamesSaid() {
|
||||
const names = (state.agents || []).filter((a) => a.wired && a.noNames).map((a) => a.name);
|
||||
return names.length ? t("Changes nothing in {agents}: magpie’s names don’t reach their model lists", { agents: names.join(", ") }) : "";
|
||||
}
|
||||
// noNamesLine is that line, hidden while it says nothing: a page drawn
|
||||
// before the agents are read (Routing, a provider's editor) is said again
|
||||
// once they are (redrawNoNames)
|
||||
function noNamesLine(tag, cls) {
|
||||
const e = el(tag, cls + " no-names");
|
||||
e.dataset.noNames = "";
|
||||
e.textContent = noNamesSaid();
|
||||
e.hidden = !e.textContent;
|
||||
return e;
|
||||
}
|
||||
function redrawNoNames() {
|
||||
for (const e of document.querySelectorAll("[data-no-names]")) {
|
||||
e.textContent = noNamesSaid();
|
||||
e.hidden = !e.textContent;
|
||||
}
|
||||
if ($("#plainNamesSegs")) sayNoNamesInSettings();
|
||||
}
|
||||
// the Settings row's name says enough on its own (1ooogle on X): a line
|
||||
// under it only for an agent it changes nothing in
|
||||
function sayNoNamesInSettings() {
|
||||
const who = $("#plainNamesSegs").parentElement.querySelector(".who"), said = noNamesSaid();
|
||||
who.querySelector(".no-names")?.remove();
|
||||
if (said) who.append(el("div", "sub no-names", said));
|
||||
}
|
||||
// redrawSuffix draws each suffix choice in the page again when the
|
||||
// settings that came in say another mode than it was drawn with: a page
|
||||
// drawn before the state's first read (Routing's groups can come back
|
||||
@@ -21763,6 +21797,7 @@ function renderTrayUsage(s, keep) {
|
||||
(v) => savePrefs({ ...keep, chineseUnits: v })));
|
||||
renderAlerts(s, keep);
|
||||
$("#plainNamesSegs").replaceChildren(suffixSegs());
|
||||
sayNoNamesInSettings();
|
||||
// Codex's own models in multi-agent V1 (their subagents' tasks go as text),
|
||||
// so a GPT lead can run a subagent on magpie's other models (#141). Where
|
||||
// Codex's own multi_agent_v2 is on in the config magpie routes it wins, and
|
||||
|
||||
@@ -893,6 +893,7 @@ const I18N = {
|
||||
"Provider in model names": "模型名带供应商",
|
||||
"Not on names I set": "自定义名称不带供应商",
|
||||
"Agents’ lists show “{label}”": "Agent 的模型列表里显示为「{label}」",
|
||||
"Changes nothing in {agents}: magpie’s names don’t reach their model lists": "对 {agents} 不起作用:它们的模型列表里没有 magpie 给的名称",
|
||||
"In agents’ lists": "Agent 列表里的名称",
|
||||
"Names in agents’ lists": "Agent 列表里的名称",
|
||||
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.": "Agent 的模型列表里,路由组名后面是否带「· routing group」。这是所有路由组共用的一个设置,也决定模型名后面是否带供应商,和「设置」里的是同一个。",
|
||||
@@ -5512,6 +5513,7 @@ const I18N = {
|
||||
"Provider in model names": "模型名帶供應商",
|
||||
"Not on names I set": "自定義名稱不帶供應商",
|
||||
"Agents’ lists show “{label}”": "Agent 的模型列表裡顯示為「{label}」",
|
||||
"Changes nothing in {agents}: magpie’s names don’t reach their model lists": "對 {agents} 不起作用:它們的模型列表裡沒有 magpie 給的名稱",
|
||||
"In agents’ lists": "Agent 列表裡的名稱",
|
||||
"Names in agents’ lists": "Agent 列表裡的名稱",
|
||||
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.": "Agent 的模型列表裡,路由組名後面是否帶「· routing group」。這是所有路由組共用的一個設定,也決定模型名後面是否帶供應商,和「設定」裡的是同一個。",
|
||||
@@ -10096,6 +10098,7 @@ const I18N = {
|
||||
"Provider in model names": "モデル名にプロバイダ",
|
||||
"Not on names I set": "自分で付けた名前には付けない",
|
||||
"Agents’ lists show “{label}”": "エージェントの一覧では「{label}」と表示されます",
|
||||
"Changes nothing in {agents}: magpie’s names don’t reach their model lists": "{agents} には効きません:そのモデル一覧には magpie の名前が出ません",
|
||||
"In agents’ lists": "エージェントの一覧での名前",
|
||||
"Names in agents’ lists": "エージェントの一覧での名前",
|
||||
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.": "エージェントの一覧でグループ名の後に「· routing group」を付けるかどうか。すべてのグループに共通の設定で、モデル名の後のプロバイダ名にも効きます(「設定」と同じものです)。",
|
||||
@@ -14701,6 +14704,7 @@ const I18N = {
|
||||
"Provider in model names": "Anbieter in Modellnamen",
|
||||
"Not on names I set": "Nicht bei eigenen Namen",
|
||||
"Agents’ lists show “{label}”": "In den Listen der Agenten: „{label}“",
|
||||
"Changes nothing in {agents}: magpie’s names don’t reach their model lists": "Wirkt nicht in {agents}: deren Modelllisten zeigen magpies Namen nicht",
|
||||
"In agents’ lists": "In den Listen der Agenten",
|
||||
"Names in agents’ lists": "Namen in den Listen der Agenten",
|
||||
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.": "Ob in den Listen der Agenten „· routing group“ auf den Namen einer Gruppe folgt: eine Einstellung für alle Gruppen, und für den Anbieter nach jedem Modellnamen, wie in den Einstellungen.",
|
||||
|
||||
@@ -3733,6 +3733,8 @@
|
||||
function drawNames() {
|
||||
const txt = el("div", "txt");
|
||||
txt.append(el("b", "", t("Names in agents’ lists")), el("small", "", t("Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.")));
|
||||
// an agent the setting can't reach is named, not left to seem broken
|
||||
txt.append(noNamesLine("small", ""));
|
||||
// an open editor says what its group will be called: drawn again with it
|
||||
gNames.replaceChildren(txt, suffixSegs(() => renderGroups()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// love1sbug on X (v0.1.1220): Names in agents' lists (Agent 列表里的名称)
|
||||
// changed nothing in the agent's model list. Claude Code's and Qwen Code's
|
||||
// lists follow it now; an agent whose list magpie hands the models' ids
|
||||
// alone, or that reads the gateway's names itself (agent.NoNames), can't,
|
||||
// so each place the setting is offered names the connected ones it changes
|
||||
// nothing in: under Settings › Provider in model names, under Routing's
|
||||
// Names in agents' lists, and in a provider's Names & levels. One not
|
||||
// connected, or one whose list follows it, isn't named; with none, nothing
|
||||
// is said. Every language, at a narrow width too.
|
||||
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 said = {
|
||||
en: "Changes nothing in Goose, Hermes Agent: magpie’s names don’t reach their model lists",
|
||||
zh: "对 Goose, Hermes Agent 不起作用:它们的模型列表里没有 magpie 给的名称",
|
||||
"zh-TW": "對 Goose, Hermes Agent 不起作用:它們的模型列表裡沒有 magpie 給的名稱",
|
||||
ja: "Goose, Hermes Agent には効きません:そのモデル一覧には magpie の名前が出ません",
|
||||
de: "Wirkt nicht in Goose, Hermes Agent: deren Modelllisten zeigen magpies Namen nicht",
|
||||
};
|
||||
const names = { en: "Names & levels", zh: "名称与推理档位" };
|
||||
|
||||
function serve(lang, agents, late = 0) {
|
||||
const cur = { lang, theme: "light", plainNames: false, plainOwnNames: false };
|
||||
const state = { agents, profiles: [], settings: cur };
|
||||
const models = [{ id: "glm-4.6", name: "GLM-4.6", default: "glm-4.6", on: true, efforts: [], images: false }];
|
||||
const provider = { id: "relay", name: "Relay", icon: "generic", chat: "https://relay.example/v1", responses: "", anthropic: "", models, agents: [], key: { set: true, masked: "sk-…1234" }, ready: true };
|
||||
const groups = { models: [{ id: "relay/glm-4.6", name: "GLM-4.6", providerName: "Relay", icon: "generic" }], pools: [],
|
||||
groups: [{ id: "fast", name: "Fast", members: ["relay/glm-4.6"], routing: "order", ready: true, memberInfo: [{ id: "relay/glm-4.6", ready: true }] }] };
|
||||
return async (r) => {
|
||||
const url = new URL(r.request().url());
|
||||
const json = (data) => r.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
// late: the agents read after the page is drawn, as at a start (#1519)
|
||||
if (url.pathname === "/api/state") return setTimeout(() => json(state).catch(() => {}), late);
|
||||
if (url.pathname === "/api/settings") return json(cur);
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/gateway/trace") {
|
||||
if (url.searchParams.get("wait")) return new Promise(() => {});
|
||||
return json({ mine: true, now: new Date().toISOString(), seq: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
|
||||
}
|
||||
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
|
||||
if (url.pathname === "/api/groups") return json(groups);
|
||||
if (url.pathname === "/api/providers") return json({ providers: [provider], presets: [], excluded: [], gateway: { running: true, window: true, url: "http://127.0.0.1:3999" } });
|
||||
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 r.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
async function launch(t, engine, lang, agents, width = 900, late = 0) {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 1000 }, 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}-no-names.png`) });
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
page.setDefaultTimeout(5000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, agents, late));
|
||||
return { page, errors };
|
||||
}
|
||||
|
||||
// Goose and Hermes are connected and can't follow it; Claude Code is
|
||||
// connected and does; Jcode can't but isn't connected
|
||||
const agents = [
|
||||
{ id: "claude", name: "Claude Code", path: "/test/claude", fields: [], wired: true },
|
||||
{ id: "goose", name: "Goose", path: "/test/goose", fields: [], wired: true, noNames: true },
|
||||
{ id: "hermes", name: "Hermes Agent", path: "/test/hermes", fields: [], wired: true, noNames: true },
|
||||
{ id: "jcode", name: "jcode", path: "/test/jcode", fields: [], noNames: true },
|
||||
];
|
||||
const overflows = (page) => page.evaluate(() => document.documentElement.scrollWidth > document.documentElement.clientWidth);
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of Object.keys(said)) {
|
||||
for (const width of [900, 390]) {
|
||||
test(`${engine} ${lang} ${width}px: Settings and Routing name the connected agents the setting changes nothing in`, async (t) => {
|
||||
const { page, errors } = await launch(t, engine, lang, agents, width);
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
const sub = page.locator(".row.pref", { has: page.locator("#plainNamesSegs") }).locator(".sub.no-names");
|
||||
await sub.waitFor();
|
||||
assert.equal(await sub.textContent(), said[lang]);
|
||||
assert.equal(await overflows(page), false, "the page scrolls sideways");
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
const note = page.locator(".rt-gnames .no-names");
|
||||
await note.waitFor();
|
||||
assert.equal(await note.textContent(), said[lang]);
|
||||
assert.equal(await overflows(page), false, "the page scrolls sideways");
|
||||
assert.equal(await note.evaluate((e) => getComputedStyle(e).borderLeftWidth), "0px");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const lang of ["en", "zh"]) {
|
||||
test(`${engine} ${lang}: a provider's Names & levels says it too`, async (t) => {
|
||||
const { page, errors } = await launch(t, engine, lang, agents);
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await page.locator(".row.provider").click();
|
||||
if (!(await page.locator(".mnames:not([hidden])").count())) await page.getByRole("button", { name: names[lang], exact: true }).click();
|
||||
const note = page.locator(".mnames:not([hidden]) .msuffix .no-names");
|
||||
await note.waitFor();
|
||||
assert.equal(await note.textContent(), said[lang]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
// drawn before the agents are read, each place says it once they are
|
||||
test(`${engine}: read after the page is drawn, the agents are named all the same`, async (t) => {
|
||||
const { page, errors } = await launch(t, engine, "en", agents, 900, 1500);
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await page.locator(".row.provider").click();
|
||||
if (!(await page.locator(".mnames:not([hidden])").count())) await page.getByRole("button", { name: names.en, exact: true }).click();
|
||||
const note = page.locator(".mnames:not([hidden]) .msuffix .no-names");
|
||||
await note.waitFor();
|
||||
assert.equal(await note.textContent(), said.en);
|
||||
for (const [view, sel] of [["routing", ".rt-gnames .no-names"], ["settings", ".row.pref .sub.no-names"]]) {
|
||||
await page.goto(`http://magpie.test/?view=${view}`);
|
||||
await page.locator(sel).waitFor();
|
||||
assert.equal(await page.locator(sel).textContent(), said.en);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
test(`${engine}: with every connected agent following it, nothing is said`, async (t) => {
|
||||
const { page, errors } = await launch(t, engine, "en", agents.filter((a) => a.id === "claude" || a.id === "jcode"));
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.locator("#plainNamesSegs .opt").first().waitFor();
|
||||
assert.equal(await page.locator(".row.pref", { has: page.locator("#plainNamesSegs") }).locator(".sub").count(), 0);
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
await page.locator(".rt-gnames .segs").waitFor();
|
||||
assert.equal(await page.locator(".rt-gnames .no-names:visible").count(), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user