gui: Settings › Privacy puts the local model first, marked New
The owner asked for "Find with a local model" to come earlier on Settings › Privacy, where people see it at once, with a light mark. "How it's found" (#findList) moves from below the try box to right under the masking card, before "What to mask", and its first row is the local model, then Rules. The model's name carries a small accent "New" badge (.badge.new: accent-soft background, accent text; en New, zh/zh-TW 新, ja 新着, de Neu). app.js stays inside its budget with no raise (1,343,322 of 1,343,324): comments were trimmed to fit. Tests: privacy-model checks the badge in every language, that the model's row is the page's first settings row, and that #findList comes before #redactList. redact-rule-row and redact-words-any-case wheel their row into view first (wheelTo, reach): with the section above them, at 640px their row sat under the bar along the page's foot, and the second control under the sticky tabs in WebKit. Run at 35c648593 (on616c87256), both engines: - go test ./internal/gui: ok - GUI: account-discovery, account-mask-sessions, account-mask, click-scroll, i18n-keys, mask-actions, mask-emails, masking-records, privacy-hides-accounts, privacy-model, privacy-usage-stats, provider-unmasked, redact-kinds, redact-rule-edit, redact-rule-row, redact-words-any-case, settings-search, settings-sections, sidebar-glide, sidebar-overlay-scrollbar, sidebar-tab-top, sidebar: all pass - Screenshots in zh, light and dark, 1100 and 640, Chromium and WebKit. Rebased onef37b6fb7: go test ./internal/gui -run 'Budget|I18n|Key', i18n-keys, privacy-model and redact-rule-row pass again (and redact-words-any-case). Broken by hand: with the old index.html order, privacy-model is 11 of 12 red in Chromium. Not tried: the real Linux and Windows apps, the whole GUI suite.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -376,14 +376,14 @@
|
||||
<section class="set-page" id="setPage-privacy" role="tabpanel" aria-labelledby="setTab-privacy">
|
||||
<div class="mask-obs" id="maskObs"></div>
|
||||
<div class="mask-recs" id="maskRecs" hidden></div>
|
||||
<div class="row-head"><span class="label" data-t>How it's found</span></div>
|
||||
<div class="list prefs" id="findList"></div>
|
||||
<div class="row-head"><span class="label" data-t>What to mask</span></div>
|
||||
<div class="list prefs" id="redactList"></div>
|
||||
<div class="row-head"><span class="label" data-t>When a value is found</span></div>
|
||||
<div class="list prefs" id="maskActList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Try it</span></div>
|
||||
<div class="list prefs" id="maskTryList"></div>
|
||||
<div class="row-head"><span class="label" data-t>How it's found</span></div>
|
||||
<div class="list prefs" id="findList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Sharing</span></div>
|
||||
<div class="list prefs" id="shareList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Agents' sign-ins</span></div>
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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 }; };
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user