diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 43b9857b6..c01119a02 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -3248,6 +3248,7 @@ body:not(.side-nav) #view-settings .set-head.stuck::before { box-shadow: 0 1px 0 .static-pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 7px; font-size: 12px; color: var(--muted); background: var(--pill); white-space: nowrap; } .static-pill.on { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); } #privacyModelRow.pm-wait .name { color: var(--muted); } +#privacyModelRow .badge.new { margin-left: 7px; background: var(--accent-soft); color: var(--accent); } /* Privacy › what masking kept from vendors (renderMaskObs): a quiet card over the switches, in the other cards' own colour. Flat only: no diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 6b11b0cb0..e5f785d17 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -21834,9 +21834,8 @@ async function discoveryOffWarning() { // renderRedact: what the gateway masks before a request goes to a vendor — // secrets, personal data, the user's own words — and puts back in what the // vendor answers. The page says it in three parts under what masking did -// (renderMaskObs): what to mask, how it is found (the rules always, the -// local model beside them: layered, not one or the other) and what is -// shared. +// (renderMaskObs): how it is found (the local model first, then the +// rules), what to mask, what is shared. function renderRedact(s, keep) { const box = $("#redactList"), find = $("#findList"), share = $("#shareList"); box.replaceChildren(); @@ -21892,13 +21891,13 @@ function renderRedact(s, keep) { renderRedactRules(s, row); renderMaskActions(s); renderMaskTry(s); - // how it is found: the rules on every request that masks anything, and - // the local model on top of them, for what no pattern can tell + // how it is found: the local model, for what no pattern can tell, over + // the rules on every request that masks anything const masking = s.redact || s.redactPersonal; const why = t("Turn on Mask secrets or Mask personal data first"); + privacyModelRow(find, masking ? "" : why); const always = el("span", "static-pill" + (masking ? " on" : ""), masking ? t("Always on") : t("Off")); rowIn(find, t("Rules"), masking ? t("Keys, tokens, emails and numbers whose checksum adds up: patterns that are certain, checked on every request") : why, always).id = "maskRulesRow"; - privacyModelRow(find, masking ? "" : why); // Routing's and Usage's Hide accounts, here too, where privacy is looked for if (window.hideAccounts) rowIn(share, t("Hide accounts"), t("Email addresses and account names on Usage and Routing are blurred, for a screenshot to share"), onOff(window.hideAccounts.on(), (on) => { window.hideAccounts.set(on); renderSettings(); })); @@ -21919,11 +21918,12 @@ function privacyModelRow(box, why) { const r = el("div", "row pref" + (why ? " pm-wait" : "")); r.id = "privacyModelRow"; box.append(r); + const name = () => { const n = el("div", "name", t("Find with a local model")); n.append(el("span", "badge new", t("New"))); return n; }; // nothing is masked: the model has nothing to find more of if (why) { clearTimeout(pmTimer); const who = el("div", "who"); - who.append(el("div", "name", t("Find with a local model")), el("div", "sub", why)); + who.append(name(), el("div", "sub", why)); r.append(who); return; } @@ -21931,7 +21931,7 @@ function privacyModelRow(box, why) { const draw = (m) => { if (!r.isConnected) return; const who = el("div", "who"), val = el("div", "val"); - who.append(el("div", "name", t("Find with a local model")), el("div", "sub", pmSub(m))); + who.append(name(), el("div", "sub", pmSub(m))); if (m?.supported || m?.installed) { if (m.downloading) { const c = el("button", "text", t("Cancel")); diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index bb60055f5..d3346e378 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -376,14 +376,14 @@
+
How it's found
+
What to mask
When a value is found
Try it
-
How it's found
-
Sharing
Agents' sign-ins
diff --git a/internal/gui/tests/privacy-model.test.cjs b/internal/gui/tests/privacy-model.test.cjs index 5c5414414..b9b31c0ee 100644 --- a/internal/gui/tests/privacy-model.test.cjs +++ b/internal/gui/tests/privacy-model.test.cjs @@ -15,11 +15,11 @@ const { wheelTo, watchSettingsReads, settingsDrawn } = require("./reader.cjs"); const assets = path.resolve(__dirname, "../assets"); const size = 1637572192; const words = { - en: { name: "Find with a local model", on: "On", gpu: "On, on the GPU (MTL0)" }, - zh: { name: "用本地模型查找", on: "开启", gpu: "已开启,运行在 GPU(MTL0)" }, - "zh-TW": { name: "用本機模型查找", on: "開啟", gpu: "已開啟,執行於 GPU(MTL0)" }, - ja: { name: "ローカルモデルで検出", on: "オン", gpu: "オン、GPU で実行中(MTL0)" }, - de: { name: "Mit lokalem Modell finden", on: "An", gpu: "An, auf der GPU (MTL0)" }, + en: { name: "Find with a local model", badge: "New", on: "On", gpu: "On, on the GPU (MTL0)" }, + zh: { name: "用本地模型查找", badge: "新", on: "开启", gpu: "已开启,运行在 GPU(MTL0)" }, + "zh-TW": { name: "用本機模型查找", badge: "新", on: "開啟", gpu: "已開啟,執行於 GPU(MTL0)" }, + ja: { name: "ローカルモデルで検出", badge: "新着", on: "オン", gpu: "オン、GPU で実行中(MTL0)" }, + de: { name: "Mit lokalem Modell finden", badge: "Neu", on: "An", gpu: "An, auf der GPU (MTL0)" }, }; // model is the page's /api/privacy-model: a POST is recorded and moves it @@ -72,13 +72,14 @@ async function open(engine, lang, width, masking, model, posts) { return { browser, page, errors }; } -// what the row shows: its words, whether they are cut, and that it is -// inside the list +// what the row shows: its words and its New mark, whether they are cut, +// that it is inside the list, and that it is the page's first setting const look = (page) => page.evaluate(() => { const r = document.querySelector("#privacyModelRow"), list = r.closest(".list").getBoundingClientRect(); const sub = r.querySelector(".sub"), b = r.getBoundingClientRect(), v = r.querySelector(".val").getBoundingClientRect(); return { - name: r.querySelector(".name").textContent, sub: sub.textContent, + name: r.querySelector(".name").firstChild.textContent, badge: r.querySelector(".name .badge.new")?.textContent, sub: sub.textContent, + first: r === document.querySelector("#setPage-privacy .list.prefs > .row"), on: r.querySelector(".segs .opt.on")?.textContent, buttons: [...r.querySelectorAll("button.text")].map((x) => x.textContent), cut: sub.scrollWidth > sub.clientWidth + 1 || sub.scrollHeight > sub.clientHeight + 1, inside: b.left >= list.left - 1 && b.right <= list.right + 1 && v.right <= b.right + 1, @@ -98,6 +99,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await row.locator(".segs").waitFor(); let m = await look(page); assert.equal(m.name, w.name); + assert.equal(m.badge, w.badge); + assert(m.first, "the model is the first setting under the card"); assert(m.sub.includes("1.6 GB"), `says what it downloads: ${m.sub}`); if (lang !== "en") assert(!/no rule can find|Turning it on/.test(m.sub), `translated: ${m.sub}`); assert(!m.cut && m.inside && !m.wide, `shown in full and inside: ${JSON.stringify(m)}`); @@ -155,13 +158,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const { browser, page, errors } = await open(engine, "en", 1100, false, { supported: true, size }, []); t.after(() => browser.close()); await page.locator("#redactList .row", { hasText: "Mask personal data" }).waitFor(); - // How it's found: the rules first, then the model, both waiting on - // something to mask, with nothing to press + // How it's found, before What to mask: the model first, marked new, + // then the rules, both waiting on something to mask, with nothing to + // press const found = await page.$$eval("#findList > .row", (rs) => rs.map((r) => [r.id, r.querySelector(".name").textContent, r.querySelector(".sub").textContent, r.querySelectorAll("button").length])); assert.deepEqual(found, [ + ["privacyModelRow", "Find with a local model" + "New", "Turn on Mask secrets or Mask personal data first", 0], ["maskRulesRow", "Rules", "Turn on Mask secrets or Mask personal data first", 0], - ["privacyModelRow", "Find with a local model", "Turn on Mask secrets or Mask personal data first", 0], ]); + assert(await page.evaluate(() => document.querySelector("#findList").compareDocumentPosition(document.querySelector("#redactList")) & Node.DOCUMENT_POSITION_FOLLOWING), "How it's found comes before What to mask"); assert.equal(await page.locator("#privacyModelRow.pm-wait").count(), 1); await browser.close(); diff --git a/internal/gui/tests/redact-rule-row.test.cjs b/internal/gui/tests/redact-rule-row.test.cjs index 2a9762e9c..f30bd0049 100644 --- a/internal/gui/tests/redact-rule-row.test.cjs +++ b/internal/gui/tests/redact-rule-row.test.cjs @@ -9,7 +9,7 @@ const fs = require("node:fs/promises"); const path = require("node:path"); const { test } = require("node:test"); const { chromium, webkit } = require("playwright"); -const { watchSettingsReads, settingsDrawn } = require("./reader.cjs"); +const { wheelTo, watchSettingsReads, settingsDrawn } = require("./reader.cjs"); const assets = path.resolve(__dirname, "../assets"); const settings = (lang) => ({ lang, theme: "light", redact: true, redactRules: [{ kind: "GATEWAY_KEY", prefix: "oc_sk_" }] }); @@ -53,7 +53,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const row = page.locator("#redactList .row.rule-row"); await row.waitFor(); await settingsDrawn(page); // the row found is the one that stays (#1653) - await row.scrollIntoViewIfNeeded(); + // the local model's section is above it: wheel it up, clear of the + // bar along a phone-width page's foot + await wheelTo(page, row, 300); const m = await row.evaluate((r) => { const box = (e) => { const b = e.getBoundingClientRect(); return { l: b.left, r: b.right, t: b.top, b: b.bottom, mid: (b.top + b.bottom) / 2 }; }; diff --git a/internal/gui/tests/redact-words-any-case.test.cjs b/internal/gui/tests/redact-words-any-case.test.cjs index 38bd8adbc..8938d7e72 100644 --- a/internal/gui/tests/redact-words-any-case.test.cjs +++ b/internal/gui/tests/redact-words-any-case.test.cjs @@ -10,7 +10,7 @@ const fs = require("node:fs/promises"); const path = require("node:path"); const { test } = require("node:test"); const { chromium, webkit } = require("playwright"); -const { watchSettingsReads, settingsDrawn } = require("./reader.cjs"); +const { reach, wheelTo, watchSettingsReads, settingsDrawn } = require("./reader.cjs"); const assets = path.resolve(__dirname, "../assets"); const words = { @@ -62,6 +62,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const row = page.locator("#redactWordsAnyCaseRow"); await row.waitFor(); await settingsDrawn(page); + // the local model's section is above it: wheel it up, clear of the + // bar along a phone-width page's foot + await wheelTo(page, row, 300); const m = await row.evaluate((r) => { const sub = r.querySelector(".sub"), list = document.querySelector("#redactList").getBoundingClientRect(), b = r.getBoundingClientRect(); @@ -94,6 +97,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", // another choice on the page keeps it const p = page.locator("#redactList .row").nth(1).locator(".segs .opt", { hasText: w.on }); + await reach(page, p); // above it now, maybe under the tabs await p.click(); await page.waitForFunction(() => document.querySelector("#redactList .row:nth-child(2) .segs .opt.on")?.textContent === t("On")); await new Promise((r) => setTimeout(r, 300));