diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 2a601e492..667cf70e0 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -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; diff --git a/internal/gui/tests/plugin-checkin.test.cjs b/internal/gui/tests/plugin-checkin.test.cjs index 897dac483..3048dee2d 100644 --- a/internal/gui/tests/plugin-checkin.test.cjs +++ b/internal/gui/tests/plugin-checkin.test.cjs @@ -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());