Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gui: an account's eye shows that provider's account, and a Kiro account's eye works

yetonea6f6e86e8037
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index fe465a732..c5d1cf41e 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -9227,7 +9227,7 @@ function drawEditor(p, presetID) {
if (p.move) ed.append(...renderMove(p));
} else {
const acct = el("div", "acct");
- acct.append(icon(a.agentIcon), el("span", "n", a.user), hideAccounts.eye(a.user), el("span", "plan", accountPlan(a)));
+ acct.append(icon(a.agentIcon), el("span", "n", a.user), hideAccounts.eye(a.user, p.id), el("span", "plan", accountPlan(a)));
ed.append(...field(t("Account"), acct, t("{agent}'s sign-in, read from its own files. Sign out there and this provider goes away.", { agent: a.agentName })));
}
ed.append(...field(t("Models"), renderModels(p), ""));
@@ -13595,7 +13595,7 @@ function accountNameButton(p, user) {
s.title = t("The same seat as the key plan {name}, shown once, on this account's card", { name: seat });
wrap.append(s);
}
- wrap.append(hideAccounts.eye(user));
+ wrap.append(hideAccounts.eye(user, p.id));
return wrap;
}
// an account or key list's last row, adding one
@@ -17237,7 +17237,7 @@ function panelQuotaCard(q) {
// and its eye while Hide accounts is on, as on the Usage page (yogurt36)
const who = el("span", "pq-who");
who.append(el("span", "pq-user", q.alias || q.user || q.name));
- if ((q.user || q.alias) && window.hideAccounts) who.append(hideAccounts.eye(q.user || q.alias));
+ if ((q.user || q.alias) && window.hideAccounts) who.append(hideAccounts.eye(q.user || q.alias, q.provider));
card.append(who);
card.title = [q.name, q.alias, q.user, q.seat && q.seat !== q.alias && "≡ " + q.seat, q.plan, q.until ? planTerm(q) : "", q.balance && t("Balance") + " " + q.balance].filter(Boolean).join(" · ");
if (q.error) {
@@ -24324,7 +24324,9 @@ window.noteAccounts = noteAccounts;
const ns = names(), key = ns.join("\n");
if (key !== findKey) {
findKey = key;
- find = ns.length ? new RegExp(EMAIL.source + "|" + ns.map(esc).join("|"), "g") : EMAIL;
+ // whole, not its address: Kiro's "[email protected] (GitHub)" (outloudvi)
+ const at = (n) => n.includes("@");
+ find = ns.length ? new RegExp([...ns.filter(at).map(esc), EMAIL.source, ...ns.filter((n) => !at(n)).map(esc)].join("|"), "g") : EMAIL;
}
return find;
}
@@ -24336,12 +24338,19 @@ window.noteAccounts = noteAccounts;
const joined = (s, i, step) => WORD.test(s[i] || "") || (JOIN.test(s[i] || "") && WORD.test(s[i + step] || ""));
// accounts shown while the rest stay hidden (yogurt36), this page's
// only: the window and the tray panel are pages of their own, so one
- // shown in either never shows in the other
- const shown = new Set(), low = (x) => String(x).trim().toLowerCase();
- function* hits(s, re) {
+ // shown in either never shows in the other; kept by provider
+ // (outloudvi: one address on two services showed on both)
+ const shown = new Set(), low = (x) => String(x).trim().toLowerCase(), sk = (p, k) => p + "\n" + low(k);
+ // by an eye, its provider's only; elsewhere, shown under any
+ const isShown = (k, e) => {
+ if (!shown.size) return false;
+ for (; e && e !== document.body; e = e.parentElement) { const b = e.querySelector?.(":scope>.acct-eye,:scope>*>.acct-eye"); if (b?._p) return shown.has(sk(b._p, k)); }
+ return [...shown].some((s) => s.endsWith("\n" + low(k)));
+ };
+ function* hits(s, re, at) {
re.lastIndex = 0; // matchAll starts where the pattern's last test ended
for (const m of s.matchAll(re)) {
- if (shown.has(low(m[0]))) continue;
+ if (isShown(m[0], at)) continue;
const name = !m[0].includes("@"), end = m.index + m[0].length;
if (name && ((WORD.test(m[0][0]) && joined(s, m.index - 1, -1)) || (WORD.test(m[0].at(-1)) && joined(s, end, 1)))) continue;
yield m;
@@ -24385,7 +24394,7 @@ window.noteAccounts = noteAccounts;
for (const n of found) {
const bits = [];
let last = 0;
- for (const m of hits(n.data, reOf(n.parentElement))) {
+ for (const m of hits(n.data, reOf(n.parentElement), n.parentElement)) {
if (m.index > last) bits.push(n.data.slice(last, m.index));
const s = el("span", "pii", dots(m[0]));
s.dataset.raw = m[0];
@@ -24403,7 +24412,7 @@ window.noteAccounts = noteAccounts;
// one masked already reads as an account too, its stars and all
if (!e.dataset || "piiTitle" in e.dataset || !e.title) continue;
let out = "", last = 0;
- for (const m of hits(e.title, reOf(e))) {
+ for (const m of hits(e.title, reOf(e), e)) {
out += e.title.slice(last, m.index) + m[0].replace(m[0].includes("@") ? /[^@.]/g : /./gu, "•"); // a tooltip can't blur
last = m.index + m[0].length;
}
@@ -24464,14 +24473,14 @@ window.noteAccounts = noteAccounts;
if (!keep) { chosen = on ? "1" : "0"; try { localStorage.setItem("magpie.maskEmails", chosen); } catch {} }
for (const set of pages) set(on);
}
- const kin = (u) => {
+ const kin = (u, pid) => {
const k = [u];
- for (const p of providers?.providers || []) for (const [a, n] of Object.entries(p.accountNames || {})) if (a === low(u) || n === u) k.push(a, n);
- for (const q of quotas || []) if (q.user === u || q.alias === u) k.push(q.user, q.alias);
- return k.filter(Boolean).map(low);
+ for (const p of providers?.providers || []) if (p.id === pid) for (const [a, n] of Object.entries(p.accountNames || {})) if (a === low(u) || n === u) k.push(a, n);
+ for (const q of quotas || []) if (q.provider === pid && (q.user === u || q.alias === u)) k.push(q.user, q.alias);
+ return k.filter(Boolean).map((x) => sk(pid, x));
};
const paint = (b) => {
- const on = shown.has(low(b._u));
+ const on = shown.has(sk(b._p, b._u));
b.setAttribute("aria-pressed", on);
b.title = t(on ? "Hide this account" : "Show this account");
b.querySelector("path").setAttribute("d", on ? EYE : EYE_OFF);
@@ -24482,17 +24491,18 @@ window.noteAccounts = noteAccounts;
};
// Settings' Privacy has the same switch, and the settings follow
window.hideAccounts = {
- eye: (u) => {
+ eye: (u, p) => {
const b = el("button", "acct-eye");
b._u = u;
+ b._p = p;
b.setAttribute("aria-label", t("Show this account"));
b.append(svg("", 13, 2));
b.firstChild.setAttribute("viewBox", "0 0 24 24");
paint(b);
b.onclick = (e) => {
e.stopPropagation();
- const on = !shown.has(low(u));
- for (const k of kin(u)) on ? shown.add(k) : shown.delete(k);
+ const on = !shown.has(sk(p, u));
+ for (const k of kin(u, p)) on ? shown.add(k) : shown.delete(k);
redraw();
};
return b;
diff --git a/internal/gui/assets/plugins/usage/page.js b/internal/gui/assets/plugins/usage/page.js
index 9d39bba18..5eadc0111 100644
--- a/internal/gui/assets/plugins/usage/page.js
+++ b/internal/gui/assets/plugins/usage/page.js
@@ -405,7 +405,7 @@ function quotaWho(q) {
out.push(s);
} else if (q.seat) out[0].title += "\n" + t("The same seat as the key plan {name}, shown once, on this account's card", { name: q.seat });
if (q.sharedKeys) out.push(sharedKeysNote(q));
- if (q.user || q.alias) out.push(hideAccounts.eye(q.user || q.alias));
+ if (q.user || q.alias) out.push(hideAccounts.eye(q.user || q.alias, q.provider));
return out;
}
diff --git a/internal/gui/tests/account-eye-provider.test.cjs b/internal/gui/tests/account-eye-provider.test.cjs
new file mode 100644
index 000000000..6fb3137c5
--- /dev/null
+++ b/internal/gui/tests/account-eye-provider.test.cjs
@@ -0,0 +1,106 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// Usage's per-account eye, with Hide accounts on (outloudvi on Discord):
+// - a Kiro plugin account is named "email (way it was signed in to)"; its
+// eye showed nothing, since the address inside the name was found and
+// hidden alone while the eye kept the whole name. Pressed, it shows that
+// account, and the account of the same email signed in another way
+// stays hidden.
+// - one address on two services is two accounts: the eye on one card shows
+// that card's, the other card's stays hidden. A sentence elsewhere in the
+// window naming the address follows the account shown, as before.
+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 SAME = "[email protected]", KG = "[email protected] (Google)", KH = "[email protected] (GitHub)";
+const inHours = (h) => new Date(Date.now() + h * 3600e3 + 60e3).toISOString();
+const card = (provider, name, user, plan) => ({ provider, name, icon: provider, plan, user, windows: [{ name: "5 hours", used: 30, resetsAt: inHours(3) }] });
+const quotas = () => [
+ card("kiro", "Kiro", KG, "Pro"),
+ card("kiro", "Kiro", KH, "Free"),
+ card("codex", "Codex", SAME, "Plus"),
+ card("zcode", "ZCode", SAME, "Lite"),
+];
+
+function serve(lang) {
+ const settings = { theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd" };
+ const providers = { providers: [], presets: [], excluded: [], gateway: { running: true, window: true } };
+ 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({ agents: [], profiles: [], settings });
+ if (url.pathname === "/api/settings") return json(settings);
+ if (url.pathname === "/api/providers") return json(providers);
+ if (url.pathname === "/api/usage/quotas") return json(quotas());
+ if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
+ if (url.pathname === "/api/plugins") return json({ plugins: [] });
+ 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)];
+ try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
+ };
+}
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ for (const lang of ["en", "zh"]) {
+ test(`${engine} ${lang}: a Usage card's eye shows its own provider's account, a Kiro plugin account included`, async (t) => {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ t.after(() => browser.close());
+ for (const width of [900, 360]) {
+ const context = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
+ const page = await context.newPage();
+ page.setDefaultTimeout(5000);
+ const errors = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", serve(lang));
+ await page.goto("http://magpie.test/?view=usage");
+ await page.locator(".subscription-account").nth(3).waitFor();
+ const row = (provider, user) => page.locator(`.subscription-account[data-card="${provider}|${user}"]`);
+ const hidden = (provider, user) => row(provider, user).evaluate((e) => e.querySelectorAll(".pii").length > 0 && !e.textContent.includes(e.dataset.card.split("|")[1]));
+ const shown = (provider, user) => row(provider, user).evaluate((e) => !e.querySelector(".pii") && e.textContent.includes(e.dataset.card.split("|")[1]));
+ const settle = () => page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
+
+ await page.locator("#usageMask").click();
+ await page.evaluate((same) => {
+ const d = document.createElement("div");
+ d.id = "sample";
+ d.textContent = `mail ${same} today`;
+ document.querySelector("main, body").append(d);
+ }, SAME);
+ await page.waitForFunction(() => document.querySelectorAll(".subscription-account .pii").length >= 4 && document.querySelector("#sample .pii"));
+ for (const [p, u] of [["kiro", KG], ["kiro", KH], ["codex", SAME], ["zcode", SAME]]) assert.ok(await hidden(p, u), `${p} ${u} is hidden first`);
+
+ // Kiro's account named by its email and its way in: the eye shows it
+ await row("kiro", KG).locator(".acct-eye").click();
+ await settle();
+ assert.ok(await shown("kiro", KG), "the Kiro account's eye shows it");
+ assert.equal(await row("kiro", KG).locator(".acct-eye").getAttribute("aria-pressed"), "true");
+ assert.ok(await hidden("kiro", KH), "the same email signed in with GitHub stays hidden");
+ assert.equal(await row("kiro", KH).locator(".acct-eye").getAttribute("aria-pressed"), "false");
+
+ // one address on two services: the Codex card's eye shows Codex's only
+ await row("codex", SAME).locator(".acct-eye").click();
+ await settle();
+ assert.ok(await shown("codex", SAME), "Codex's account shows");
+ assert.ok(await hidden("zcode", SAME), "the same address on ZCode stays hidden");
+ assert.equal(await row("zcode", SAME).locator(".acct-eye").getAttribute("aria-pressed"), "false");
+ assert.equal(await page.locator("#sample").textContent(), `mail ${SAME} today`, "a sentence elsewhere follows the account shown");
+
+ // pressed again: hidden again, everywhere
+ await row("codex", SAME).locator(".acct-eye").click();
+ await page.waitForFunction(() => document.querySelector("#sample .pii"));
+ assert.ok(await hidden("codex", SAME));
+ assert.ok(await shown("kiro", KG), "the Kiro account stays shown");
+
+ assert.equal(await page.locator("select").count(), 0, "no native select");
+ assert.deepEqual(errors, []);
+ await context.close();
+ }
+ });
+ }
+}