gui: every alert row says when notifications won't show, in sight; Bark says it gets them all
The scan's item 9. When the system blocks magpie's notifications, or
can't show them, Settings › Usage's four alerts said so after their
description, but the Masking alert in Settings › Privacy didn't. Both
take the line from one helper now (notifyWarn in app.js), and the
Masking alert appends it as the others do.
On a computer with a pointer that warning was never in sight anyway:
Settings holds a row's explaining line out of sight for the hover card
(app.css, 11-02), and the warning sat inside that line. The comment
there says a warning stays; the rule didn't. A line holding a .warn now
stays in place, so the warning is read without hovering.
Bark gets every notification magpie shows (sendAs → barkPush), even
while the system's are turned off. Its row now says so, in every
language, rather than following a separate set of choices.
New test notify-warn-places.test.cjs: denied and unavailable, the
Masking alert's and the usage alert's warning on screen (wider than the
1px a held line gets, no clip-path), none when nothing is wrong, Bark's
line, nothing past the edge; every language, 900 and 380, both engines.
Run (mote, at this tree; mote at load ~50 and mica at ~160, mote the
lighter):
- notify-warn-places, mask-alert, builtin-places, i18n-keys, bark,
settings-hints, usage-alert, reset-reminder, turn-done, settings-search,
settings-search-reach, settings-groups, gui-de, editor-hints,
privacy-hides-accounts, Chromium and WebKit: reds only these, each red
on an origin/main 888d4eba5 copy too and filed: bark's "Bark is set…"
at 900px, the click moves the page 2px (#6543), editor-hints WebKit
(#6156), settings-groups "warm-ups and check-in" (#6597).
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS':
ok, no budget raised.
Broken by hand, each red, then put back:
- the :has(> .warn) exemption removed: notify-warn-places 30 of 30 red.
- the Masking alert's warning not appended: 30 of 30 red.
- Bark's line removed from index.html: 30 of 30 red.
Not tried: the real app with notifications turned off in System
Settings, and a real Bark push.
This commit is contained in:
@@ -4451,7 +4451,7 @@ input.words.window-in { width: 96px; font-variant-numeric: tabular-nums; }
|
||||
sends, who the allow list lets in), a line with a button or link in
|
||||
it. A touch screen, with no hover, keeps them all. */
|
||||
@media (hover: hover) {
|
||||
:is(#view-settings:not(.set-searching), .editor.roomy .prov-prefs) .row.pref > .who > .sub:not(.err, .bad, .say, .proxy-check, .lib-way, .image-gen-hidden, .sync-sign-in, .no-names, .pv-hits, .feat-why, .vision-not-marked, .video-gen-how, .font-note, .acts, [role="status"], #proxySub):not(#otelSessionsRow *, #allowList *, .disabled-model *) {
|
||||
:is(#view-settings:not(.set-searching), .editor.roomy .prov-prefs) .row.pref > .who > .sub:not(.err, .bad, .say, .proxy-check, .lib-way, .image-gen-hidden, .sync-sign-in, .no-names, .pv-hits, .feat-why, .vision-not-marked, .video-gen-how, .font-note, .acts, [role="status"], #proxySub, :has(> .warn)):not(#otelSessionsRow *, #allowList *, .disabled-model *) {
|
||||
--hint: 1; position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
|
||||
}
|
||||
/* the line held out of sight stays in its row's box: placed against the
|
||||
|
||||
@@ -21213,9 +21213,14 @@ function renderWarmNow(agent, users, rowId) {
|
||||
// renderAlerts draws the usage alerts (#368): a notification when a window
|
||||
// that routing counts reaches the share set, or a balance falls to the
|
||||
// amount set, each once; Off, or the number in a field beside On.
|
||||
function renderAlerts(s, keep) {
|
||||
const problem = s.notifyProblem === "denied" ? t("Notifications are turned off for magpie in the system's settings")
|
||||
// notifyWarn: why a notification set here wouldn't be seen, said beside
|
||||
// each alert, the Masking alert's in Privacy too
|
||||
function notifyWarn(s) {
|
||||
return s.notifyProblem === "denied" ? t("Notifications are turned off for magpie in the system's settings")
|
||||
: s.notifyProblem === "unavailable" ? t("Notifications can't be shown on this system") : "";
|
||||
}
|
||||
function renderAlerts(s, keep) {
|
||||
const problem = notifyWarn(s);
|
||||
const sub = (id, what) => {
|
||||
const box = $(id);
|
||||
box.textContent = what;
|
||||
|
||||
@@ -1529,6 +1529,7 @@ const I18N = {
|
||||
"{n} h before": "提前 {n} 小时",
|
||||
"Task done alert": "任务完成提醒",
|
||||
"Bark": "Bark",
|
||||
"Every notification magpie shows goes here too, even while the system's notifications are off": "magpie 显示的每条通知也会发到这里,系统通知关闭时也照发",
|
||||
"Bark daily summary": "Bark 每日汇总",
|
||||
"Server": "服务器",
|
||||
"Device key": "设备密钥",
|
||||
@@ -7014,6 +7015,7 @@ const I18N = {
|
||||
"{n} h before": "提前 {n} 小時",
|
||||
"Task done alert": "任務完成提醒",
|
||||
"Bark": "Bark",
|
||||
"Every notification magpie shows goes here too, even while the system's notifications are off": "magpie 顯示的每則通知也會發到這裡,系統通知關閉時也照發",
|
||||
"Bark daily summary": "Bark 每日彙總",
|
||||
"Server": "伺服器",
|
||||
"Device key": "裝置金鑰",
|
||||
@@ -12449,6 +12451,7 @@ const I18N = {
|
||||
"{n} h before": "{n} 時間前",
|
||||
"Task done alert": "タスク完了通知",
|
||||
"Bark": "Bark",
|
||||
"Every notification magpie shows goes here too, even while the system's notifications are off": "magpie が表示する通知はすべてここにも届きます。システムの通知がオフでも届きます",
|
||||
"Bark daily summary": "Bark の毎日のまとめ",
|
||||
"Server": "サーバー",
|
||||
"Device key": "デバイスキー",
|
||||
@@ -17933,6 +17936,7 @@ const I18N = {
|
||||
"{n} h before": "{n} Std. vorher",
|
||||
"Task done alert": "Benachrichtigung bei fertiger Aufgabe",
|
||||
"Bark": "Bark",
|
||||
"Every notification magpie shows goes here too, even while the system's notifications are off": "Jede Benachrichtigung von magpie kommt auch hierher, auch wenn die des Systems aus sind",
|
||||
"Bark daily summary": "Bark-Tagesübersicht",
|
||||
"Server": "Server",
|
||||
"Device key": "Geräteschlüssel",
|
||||
|
||||
@@ -392,7 +392,7 @@
|
||||
<div id="turnDoneSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="barkRow">
|
||||
<div class="who"><div class="name" data-t>Bark</div></div>
|
||||
<div class="who"><div class="name" data-t>Bark</div><div class="sub" data-t>Every notification magpie shows goes here too, even while the system's notifications are off</div></div>
|
||||
<div id="barkBox" class="bark-box"></div>
|
||||
</div>
|
||||
<div class="row pref" id="barkDailyRow" hidden>
|
||||
|
||||
@@ -403,7 +403,11 @@ function ruleBulk(s, sel) {
|
||||
const r = el("div", "row pref");
|
||||
r.id = "maskAlertRow";
|
||||
const who = el("div", "who");
|
||||
who.append(el("div", "name", t("Masking alert")), el("div", "sub wraps", t("A notification when masking swaps a value for the first time: its kind and how many, never the value itself")));
|
||||
const sub = el("div", "sub wraps", t("A notification when masking swaps a value for the first time: its kind and how many, never the value itself"));
|
||||
// and why it wouldn't be seen, as Settings › Usage's alerts say it
|
||||
const warn = notifyWarn(s);
|
||||
if (warn) sub.append(" · ", el("span", "warn", warn));
|
||||
who.append(el("div", "name", t("Masking alert")), sub);
|
||||
const v = el("div", "val");
|
||||
v.id = "maskAlertSegs";
|
||||
v.append(segs([["off", t("Off")], ["on", t("On")]], s.maskAlert ? "on" : "off", (x) => savePrefs({ ...keep, maskAlert: x === "on" })));
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// When the system blocks magpie's notifications, or can't show them, every
|
||||
// row that sets an alert says so beside it: Settings › Usage's alerts did,
|
||||
// the Masking alert in Settings › Privacy didn't, and on a computer with
|
||||
// a pointer both were held out of sight with the line explaining the row,
|
||||
// for the card the pointer brings. And Bark's row says it gets every
|
||||
// notification magpie shows, even while the system's are off, since
|
||||
// sendAs pushes to Bark whatever the system does with it. Every
|
||||
// language, wide and narrow, both engines; the API is faked here.
|
||||
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 { watchSettingsReads, settingsDrawn } = require("./reader.cjs");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
|
||||
function server(lang, notifyProblem) {
|
||||
const cur = {
|
||||
theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd", dock: false, dockWindow: false, proxy: "",
|
||||
redact: true, redactPersonal: false, redactWords: [], codexWarmup: "", claudeWarmup: "", codexWarmAt: "", claudeWarmAt: "",
|
||||
trayUsage: "", trayUsageEvery: 3, vision: "", imageGen: "", version: "0.1.900", dir: "~/.config/magpie",
|
||||
gateway: "http://127.0.0.1:3425", proxyNow: "none", proxySource: "none", visionModels: [], imageGenModels: [], lanURLs: [],
|
||||
fx: { rate: 7.2, at: new Date().toISOString(), stale: false }, turnDoneAlert: 0, featuresOff: [],
|
||||
maskAlert: true, usageAlert: 80, notifyProblem,
|
||||
};
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.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:false,featuresOff:[]};` });
|
||||
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: { lang, theme: "light" }, fx: cur.fx });
|
||||
if (url.pathname === "/api/settings") return json(cur);
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
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)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
const words = {
|
||||
en: { denied: "Notifications are turned off for magpie in the system's settings", unavailable: "Notifications can't be shown on this system",
|
||||
bark: "Every notification magpie shows goes here too, even while the system's notifications are off" },
|
||||
zh: { denied: "系统设置里关闭了 magpie 的通知", bark: "magpie 显示的每条通知也会发到这里,系统通知关闭时也照发" },
|
||||
"zh-TW": { denied: "系統設定裡關閉了 magpie 的通知", bark: "magpie 顯示的每則通知也會發到這裡,系統通知關閉時也照發" },
|
||||
ja: { denied: "システム設定で magpie の通知がオフになっています", bark: "magpie が表示する通知はすべてここにも届きます。システムの通知がオフでも届きます" },
|
||||
de: { denied: "Benachrichtigungen für magpie sind in den Systemeinstellungen ausgeschaltet",
|
||||
bark: "Jede Benachrichtigung von magpie kommt auch hierher, auch wenn die des Systems aus sind" },
|
||||
};
|
||||
|
||||
// shown on the page: a line held out of sight for the hover card is 1px
|
||||
const seen = (page, sel) => page.locator(sel).evaluate((e) => {
|
||||
const r = e.getBoundingClientRect();
|
||||
return r.width > 40 && r.height > 8 && getComputedStyle(e.closest(".sub")).clipPath === "none";
|
||||
});
|
||||
|
||||
async function open(browser, width, lang, problem, tab) {
|
||||
const context = await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce" });
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, problem));
|
||||
await watchSettingsReads(page);
|
||||
await page.goto("http://magpie.test/?view=settings&tab=" + tab);
|
||||
await settingsDrawn(page);
|
||||
return { page, errors, context };
|
||||
}
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of (process.env.LANGS ? process.env.LANGS.split(",") : Object.keys(words))) {
|
||||
test(`${engine} ${lang}: every alert row says when notifications won't show, and Bark says it gets them all`, async (t) => {
|
||||
const w = words[lang];
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const width of [900, 380]) {
|
||||
await t.test(`${width}px`, async () => {
|
||||
// blocked: the Masking alert says so, as the usage alert does
|
||||
let { page, errors, context } = await open(browser, width, lang, "denied", "privacy");
|
||||
await page.locator("#maskAlertRow .sub").waitFor();
|
||||
assert.equal(await page.locator("#maskAlertRow .sub .warn").textContent(), w.denied, "masking alert");
|
||||
// in sight, not held for the hover card with the line it is in
|
||||
assert.ok(await seen(page, "#maskAlertRow .sub .warn"), "the masking alert's warning in sight");
|
||||
assert.deepEqual(errors, []);
|
||||
await context.close();
|
||||
|
||||
({ page, errors, context } = await open(browser, width, lang, "denied", "usage"));
|
||||
await page.locator("#usageAlertSub .warn").waitFor({ state: "attached" });
|
||||
assert.equal(await page.locator("#usageAlertSub .warn").textContent(), w.denied, "usage alert");
|
||||
assert.ok(await seen(page, "#usageAlertSub .warn"), "the usage alert's warning in sight");
|
||||
assert.equal((await page.locator("#barkRow .sub").textContent()).trim(), w.bark, "Bark's row");
|
||||
const over = await page.evaluate(() => [...document.querySelectorAll("#barkRow *")]
|
||||
.filter((e) => e.getBoundingClientRect().right > innerWidth + 1).map((e) => e.className || e.id));
|
||||
assert.deepEqual(over, [], "nothing past the edge");
|
||||
assert.deepEqual(errors, []);
|
||||
await context.close();
|
||||
|
||||
// nothing wrong: nothing said
|
||||
({ page, errors, context } = await open(browser, width, lang, "", "privacy"));
|
||||
await page.locator("#maskAlertRow .sub").waitFor();
|
||||
assert.equal(await page.locator("#maskAlertRow .warn").count(), 0, "no warning when notifications show");
|
||||
await context.close();
|
||||
if (w.unavailable) {
|
||||
({ page, errors, context } = await open(browser, width, lang, "unavailable", "privacy"));
|
||||
await page.locator("#maskAlertRow .sub").waitFor();
|
||||
assert.equal(await page.locator("#maskAlertRow .warn").textContent(), w.unavailable);
|
||||
await context.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user