gui: a gateway's provider editor keeps its warm-up and check-ins (wolfing88, magpie-community/plugins#1065)
wolfing88 runs magpie in Docker, so magpie web is in gateway mode. Their WorkBuddy, Trae CN, 商汤小浣熊, MiniMax Code and Qoder CN plugins check in, and Settings' search sends each "每日自动签到" to that provider's editor, but the editor had no check-in field.bceeabd93(11-08) moved the warm-up, check-in and reset lists from Settings into the provider's editor and left them out in gateway mode, only Claude Code's run list kept (bc8b01d60). Before that move Settings showed them in gateway mode too, and they run on the gateway's own accounts, so provPrefsField and provPrefsOf now keep them. Run (wsl-run, magpie-desktop; mote and mica were over their load): - plugin-checkin.test.cjs, new case "a plugin's check-in in its provider's editor in gateway mode", 5 languages x 2 engines: red 5/5 in chromium on the old app.js, green on this one; the whole file 42/42. - one at a time: checkin-at, checkin-account, checkin-reason(-once), claude-tui-setting, claude-lean-prompt-setting, codex-auto-reset-settings, codex-reset-lead, provider-prefs(-layout), providers-reset-use, segs-press-redraw, settings-groups, usage-checkin, warm-now, warm-at-times, warm-at-own, gateway-mode, gateway-mode-sessions, editor-checkin-account, quota-warm: all ok. - red the same on1cc7b7267without this change, already filed: checkin-now-account (#6029), settings-search (#6133), i18n-keys "a plugin's words are its own" (#6422). - TestCoreScriptBudget at this head, rebased on04776ec6c: ok (win-run; mica was out of disk). Not tried: a real Docker image; the field is drawn from /api/settings' checkinPlugins, which the server fills the same in gateway mode.
This commit is contained in:
@@ -19712,7 +19712,7 @@ function homeProvPrefRows() {
|
||||
for (const g of provPrefMount?.own || []) if (g.classList.contains("ci-plugin") && g.parentElement !== plugins) plugins.append(g);
|
||||
}
|
||||
function provPrefsOf(agent) {
|
||||
const lists = (PROV_PREFS[agent] || []).filter((id) => !gatewayMode || id == "claudeRunList").map((id) => $("#" + id));
|
||||
const lists = (PROV_PREFS[agent] || []).map((id) => $("#" + id));
|
||||
const g = [...$("#pluginCheckinList").children].find((x) => x.dataset.provider === agent);
|
||||
return g ? [...lists, g] : lists;
|
||||
}
|
||||
@@ -19743,8 +19743,9 @@ function remountProvPrefs() {
|
||||
// editor's own fields, under Advanced (the owner, 11-09: a block of cards
|
||||
// under Routing took most of the editor)
|
||||
function provPrefsField(agent) {
|
||||
if (gatewayMode && agent != "claude" || !PROV_PREFS[agent] && !(prefs?.checkinPlugins || []).some((x) => x.id === agent) && prefs) return [];
|
||||
const keys = [...(PROV_PREFS[agent] || []).filter((id) => !gatewayMode || id == "claudeRunList"), "ci-plugin"];
|
||||
// a gateway keeps them: they run on its own accounts (#1065)
|
||||
if (!PROV_PREFS[agent] && !(prefs?.checkinPlugins || []).some((x) => x.id === agent) && prefs) return [];
|
||||
const keys = [...(PROV_PREFS[agent] || []), "ci-plugin"];
|
||||
const slots = keys.map((k) => {
|
||||
const slot = el("div", "prov-prefs");
|
||||
slot.dataset.list = k;
|
||||
|
||||
@@ -71,8 +71,8 @@ const quotas = () => [
|
||||
{ provider: "codex", name: "Codex", icon: "openai", plan: "Plus", windows: [{ name: "5 hours", used: 20 }] },
|
||||
];
|
||||
|
||||
function serve(lang, asked, more = []) {
|
||||
const settings = { theme: "light", lang, quotaLeft: false, currency: "usd", pluginCheckins: { fakeco: false },
|
||||
function serve(lang, asked, more = [], gateway = false) {
|
||||
const settings = { theme: "light", lang, quotaLeft: false, currency: "usd", pluginCheckins: { fakeco: false }, web: true, gatewayOn: gateway,
|
||||
checkinPlugins: [{ id: "fakeco", name: "FakeCo", on: false, checkins: [
|
||||
{ user: "ann", by: "plugin:fakeco", vendor: "FakeCo", day: today, outcome: "claimed", credit: 50, streak: 3 },
|
||||
{ user: "bob", by: "plugin:fakeco", vendor: "FakeCo", day: today, outcome: "captcha" },
|
||||
@@ -80,7 +80,7 @@ function serve(lang, asked, more = []) {
|
||||
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 === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true${gateway ? ",gateway:true" : ""}};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") {
|
||||
// stateJSON embeds settings.Settings; only settingsJSON adds this list.
|
||||
@@ -191,6 +191,29 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
// #1065 (wolfing88, magpie in Docker): magpie web serving other
|
||||
// computers' agents still checks in with its own plugin accounts, so the
|
||||
// provider's editor keeps the check-in there too
|
||||
test(`${engine} ${lang}: a plugin's check-in in its provider's editor in gateway mode`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await (await browser.newContext({ viewport: { width: 900, height: 900 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => { if (engine === "webkit" && /due to access control checks/.test(e.message)) return; errors.push(e.message); }); // a goto in WebKit can cut off a fetch (#1350)
|
||||
await page.route("**/*", serve(lang, [], [], true));
|
||||
await watchSettingsReads(page);
|
||||
await openProvPrefs(page, "fakeco");
|
||||
await settingsDrawn(page);
|
||||
assert.equal(await page.evaluate(() => gatewayMode), true, "the page is in gateway mode");
|
||||
const row = page.locator('.editor .prov-prefs .ci-plugin[data-provider="fakeco"] > .row.pref:first-child');
|
||||
await row.waitFor();
|
||||
assert.match(await row.locator(".name").innerText(), /FakeCo/);
|
||||
assert.match((await row.locator(".sub").innerText()).replace(/\s+/g, " "), w.sub);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: a plugin's check-in in its provider's editor at 440px`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
|
||||
Reference in New Issue
Block a user