Skip to content

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

masking: the Masking page turns masking off as it turns it on

yetone449231c19f98
diff --git a/internal/gui/assets/plugins/redact/i18n.js b/internal/gui/assets/plugins/redact/i18n.js
index 6de278ab0..3027c8cde 100644
--- a/internal/gui/assets/plugins/redact/i18n.js
+++ b/internal/gui/assets/plugins/redact/i18n.js
@@ -3,6 +3,9 @@
magpie.strings({
zh: {
"Turn on masking": "打开脱敏",
+ "Turn off masking": "关闭脱敏",
+ "Turn off in Settings": "去设置里关闭",
+ "Your own masked words still mask until you take them out, in Settings › Privacy": "你自己加的脱敏词会一直脱敏,要在「设置 › 隐私」里删掉",
"You can also change it in": "也可以在这里调整:",
"Requests go to vendors as they are": "请求按原样发给厂商",
"Turned on, keys, passwords and tokens become placeholders before they leave this computer, and are put back in each answer. Emails and phone numbers too once Mask personal data is on. What each request had masked shows here.": "打开脱敏后,密钥、密码、令牌这些值在离开这台电脑前会换成占位符,回复里再换回来。打开「脱敏个人信息」后,邮箱和手机号也会。每条请求遮了什么,都会显示在这里。",
@@ -95,6 +98,9 @@ magpie.strings({
},
"zh-TW": {
"Turn on masking": "開啟脫敏",
+ "Turn off masking": "關閉脫敏",
+ "Turn off in Settings": "到設定裡關閉",
+ "Your own masked words still mask until you take them out, in Settings › Privacy": "你自己加的脫敏詞會一直脫敏,要在「設定 › 隱私」裡刪掉",
"You can also change it in": "也可以在這裡調整:",
"Requests go to vendors as they are": "請求照原樣發給廠商",
"Turned on, keys, passwords and tokens become placeholders before they leave this computer, and are put back in each answer. Emails and phone numbers too once Mask personal data is on. What each request had masked shows here.": "開啟脫敏後,金鑰、密碼、權杖這些值在離開這台電腦前會換成佔位符,回覆裡再換回來。開啟「脫敏個人資訊」後,電子郵件和手機號碼也會。每則請求遮了什麼,都會顯示在這裡。",
@@ -187,6 +193,9 @@ magpie.strings({
},
ja: {
"Turn on masking": "マスクをオンにする",
+ "Turn off masking": "マスクをオフにする",
+ "Turn off in Settings": "設定でオフにする",
+ "Your own masked words still mask until you take them out, in Settings › Privacy": "自分で追加したマスクする語は、設定 › プライバシーで削除するまでマスクされ続けます",
"You can also change it in": "こちらでも変更できます:",
"Requests go to vendors as they are": "リクエストはそのままベンダーに送られます",
"Turned on, keys, passwords and tokens become placeholders before they leave this computer, and are put back in each answer. Emails and phone numbers too once Mask personal data is on. What each request had masked shows here.": "オンにすると、キー・パスワード・トークンはこのコンピュータを出る前にプレースホルダーに置き換わり、返答の中で元に戻されます。「個人情報をマスク」をオンにすると、メールアドレスと電話番号も対象になります。各リクエストで何をマスクしたかがここに表示されます。",
@@ -279,6 +288,9 @@ magpie.strings({
},
de: {
"Turn on masking": "Maskierung einschalten",
+ "Turn off masking": "Maskierung ausschalten",
+ "Turn off in Settings": "In den Einstellungen ausschalten",
+ "Your own masked words still mask until you take them out, in Settings › Privacy": "Ihre eigenen maskierten Wörter werden weiter maskiert, bis Sie sie unter Einstellungen › Datenschutz entfernen",
"You can also change it in": "Auch zu ändern unter",
"Requests go to vendors as they are": "Anfragen gehen unverändert an die Anbieter",
"Turned on, keys, passwords and tokens become placeholders before they leave this computer, and are put back in each answer. Emails and phone numbers too once Mask personal data is on. What each request had masked shows here.": "Eingeschaltet werden Schlüssel, Passwörter und Tokens zu Platzhaltern, bevor sie diesen Computer verlassen, und in jeder Antwort zurückgesetzt. E-Mails und Telefonnummern ebenso, sobald „Personenbezogene Daten maskieren“ an ist. Was jede Anfrage maskiert hatte, steht hier.",
diff --git a/internal/gui/assets/plugins/redact/page.js b/internal/gui/assets/plugins/redact/page.js
index 304288353..dfbdd1de5 100644
--- a/internal/gui/assets/plugins/redact/page.js
+++ b/internal/gui/assets/plugins/redact/page.js
@@ -112,7 +112,7 @@ function drawMaskCard() {
if (!box) return;
// until the window's state is read, agents would show as their ids
const on = maskOn(), sum = maskSumDays === maskDays && load.done ? maskSum : null;
- const key = JSON.stringify([document.documentElement.lang, maskDays, on, sum, state?.agents?.length, (providers || maskProv)?.providers?.length]);
+ const key = JSON.stringify([document.documentElement.lang, maskDays, on, !!maskSettings().redactWords?.length, sum, state?.agents?.length, (providers || maskProv)?.providers?.length]);
if (key === maskDrawn && box.firstChild) return;
maskDrawn = key;
// it moves when it first has numbers to say, and for other days: not
@@ -133,7 +133,7 @@ function drawMaskCard() {
b.type = "button";
b.onclick = maskTurnOn;
head.append(b);
- }
+ } else head.append(maskOffButton());
if (sum?.requests || maskDays === 30) head.append(segs([["7", t("7 days")], ["30", t("30 days")]], String(maskDays), (v) => {
maskDays = +v;
try { localStorage.setItem("magpie.maskDays", v); } catch {}
@@ -201,11 +201,44 @@ function maskNone() {
box.append(" ", link);
return box;
}
+// the way off, beside the way on (ZekeXiao on X: "脱敏好像只有一个打开
+// 开关,不能关?"). Both switches go off at once. Your own words mask with neither
+// on, and only Settings › Privacy can take them out, so with words the
+// button opens it there, and says so, rather than leave the page
+// saying off while words still mask
+function maskOffButton() {
+ const words = maskSettings().redactWords?.length;
+ const b = el("button", "text", t(words ? "Turn off in Settings" : "Turn off masking"));
+ b.type = "button";
+ if (words) {
+ b.title = t("Your own masked words still mask until you take them out, in Settings › Privacy");
+ b.onclick = (e) => openSettingsAt(e, "privacy");
+ return b;
+ }
+ b.onclick = () => {
+ b.disabled = true;
+ (prefs ? Promise.resolve() : loadSettings())
+ .then(() => {
+ // turned on again from this page, it comes back as it was
+ maskWasPersonal = !!prefs.redactPersonal;
+ return savePrefs({ ...prefsKeep(prefs), redact: false, redactPersonal: false });
+ })
+ .then(() => { maskDrawn = ""; drawMaskCard(); })
+ .finally(() => { b.disabled = false; });
+ };
+ return b;
+}
+let maskWasPersonal = false;
function maskTurnOn(e) {
const b = e.currentTarget;
b.disabled = true;
(prefs ? Promise.resolve() : loadSettings())
- .then(() => savePrefs({ ...prefsKeep(prefs), redact: true }))
+ .then(() => {
+ const back = maskWasPersonal;
+ maskWasPersonal = false;
+ if (back) window.hideAccounts?.set(true);
+ return savePrefs({ ...prefsKeep(prefs), redact: true, ...(back ? { redactPersonal: true } : {}) });
+ })
.then(() => { maskDrawn = ""; drawMaskCard(); })
.finally(() => { b.disabled = false; });
}
diff --git a/internal/gui/tests/masking-records.test.cjs b/internal/gui/tests/masking-records.test.cjs
index c1ac2c4f8..0dd910c2a 100644
--- a/internal/gui/tests/masking-records.test.cjs
+++ b/internal/gui/tests/masking-records.test.cjs
@@ -400,14 +400,61 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
});
test(`${engine} ${lang}: your own words alone are masking on`, async (t) => {
const empty = (d) => ({ ...summary(d), requests: 0, n: 0, distinct: 0, blocked: 0, kinds: [], agents: [], providers: [], values: [], by: {} });
- const { browser, page, errors } = await open(engine, lang, 640, empty, null, { off: true, none: true, settings: { redactWords: ["Nightjar"] } });
+ const { browser, page, errors, asked } = await open(engine, lang, 640, empty, null, { off: true, none: true, settings: { redactWords: ["Nightjar"] } });
t.after(() => browser.close());
await page.locator("#maskCard .msk-head").waitFor();
assert.equal(await page.locator("#maskCard.off").count(), 0, "words alone mask, the card says off");
- assert.equal(await page.locator("#maskCard .msk-head button").count(), 0, "no Turn on masking while words mask");
+ // the way off is Settings › Privacy, where the words are: a click
+ // here that turned the switches off would leave words masking
+ const off = page.locator("#maskCard .msk-head button");
+ assert.equal(await off.count(), 1, "one way off, no Turn on masking while words mask");
+ if (lang === "en") assert.equal(await off.innerText(), "Turn off in Settings");
+ else assert(!(await off.innerText()).includes("Turn"), "Turn off in Settings left in English");
assert(!(await page.locator("#maskCard .msk-flow-none").innerText()).includes("Only keys"), "words alone: not the secrets-only line");
+ await off.click();
+ await page.locator("#view-settings").waitFor({ state: "visible" });
+ assert(!asked.some((x) => x.startsWith("settings")), "opening Settings saves nothing");
assert.deepEqual(errors, []);
});
+ // masking on, the page turns it off as it turns it on (ZekeXiao on X:
+ // "脱敏好像只有一个打开开关,不能关?"): both switches go off, the page
+ // then says off, and Turn on masking brings back what was on
+ for (const width of [1100, 640]) {
+ test(`${engine} ${lang} ${width}px: masking on, the page turns it off and on again`, async (t) => {
+ const { browser, page, errors, asked } = await open(engine, lang, width, summary);
+ t.after(() => browser.close());
+ const head = page.locator("#maskCard .msk-head");
+ await page.locator("#maskCard .msk-num").waitFor();
+ const off = head.locator("button.text");
+ assert.equal(await off.count(), 1, "a way off while masking is on");
+ if (lang === "en") assert.equal(await off.innerText(), "Turn off masking");
+ else assert(!(await off.innerText()).includes("Turn"), "Turn off masking left in English");
+ assert.deepEqual(await wide(page), { page: false, over: [] });
+ await shot(page, `${engine}-${lang}-${width}-on-off`);
+ const offText = await off.innerText();
+ await stillClick(page, off);
+ await until(() => asked.some((x) => x.startsWith("settings")));
+ const sent = JSON.parse(asked.find((x) => x.startsWith("settings")).slice(9));
+ assert.equal(sent.redact, false);
+ assert.equal(sent.redactPersonal, false);
+ // what the page says after is true: off, and the way back on
+ const on = head.locator("button.text");
+ await page.waitForFunction((was) => { const b = document.querySelector("#maskCard .msk-head button.text"); return b && !b.disabled && b.textContent !== was; }, offText);
+ if (lang === "en") {
+ assert.equal(await head.locator(".msk-sub").innerText(), "Masking is off: requests go to vendors as they are");
+ assert.equal(await on.innerText(), "Turn on masking");
+ }
+ assert.deepEqual(await wide(page), { page: false, over: [] });
+ asked.length = 0;
+ await stillClick(page, on);
+ await until(() => asked.some((x) => x.startsWith("settings")));
+ const back = JSON.parse(asked.find((x) => x.startsWith("settings")).slice(9));
+ assert.equal(back.redact, true);
+ assert.equal(back.redactPersonal, true, "personal data comes back on as it was");
+ await page.waitForFunction((was) => document.querySelector("#maskCard .msk-head button.text")?.textContent === was, offText);
+ assert.deepEqual(errors, []);
+ });
+ }
}
test(`${engine}: a masked call on the Gateway page, and a key in the address, open its request`, async (t) => {