gui: Sessions' Settings › names the session terminal too, beside history
The Sessions page's head had one Settings › link, and it went to Privacy's Agents' session history. The other setting the page uses, the terminal a session opens in (General's Session terminal), had no way there from Sessions. Where that row exists (a Mac, or a terminal found on Windows or Linux), Settings › now opens the app's menu with both, each noting its tab (Settings › Privacy, Settings › General), and each opens Settings at its row, lit, with Back to Sessions. Without a terminal row it goes straight to Privacy as before; gateway mode still has no link. When the row shows is one rule now (window.sessionTerminalShows in sessions/settings.js), asked by both. No new strings; the core is unchanged. Run (mote, at this tree): - sessions-to-settings (now also on a Mac: the menu, both items, each reaching its row, nothing moved, the menu inside the window at 420), sessions-reads, gateway-mode-sessions, settings-search, i18n-keys, Chromium and WebKit, every language: 104 of 104 pass. - go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok. Broken by hand, each red, then put back: - Settings › going straight to Privacy always: sessions-to-settings 20 of 20 red. - the terminal item aimed at the history rows: 20 of 20 red. Not tried: the real app window.
This commit is contained in:
@@ -633,12 +633,22 @@ magpie.plugin("sessions", (ctx) => {
|
||||
if (data?.trash.length) tr.append(el("em", "", String(data.trash.length)));
|
||||
tr.onclick = () => { trashOn = !trashOn; selecting = false; picked.clear(); draw(); speedsOn(); };
|
||||
// which agents' history is read is Settings › Privacy's (the scattered
|
||||
// settings audit after netube99 on X); gateway mode reads none there
|
||||
// settings audit after netube99 on X); gateway mode reads none there.
|
||||
// The terminal a session opens in is General's: with that row here,
|
||||
// a menu names both
|
||||
const go = el("button", "text sm-toset");
|
||||
go.type = "button";
|
||||
go.append(el("span", "", t("Settings")), " ›");
|
||||
go.hidden = !!data?.reads?.gateway;
|
||||
go.onclick = (e) => openSettingsAt(e, "privacy", "#sessionReadsList .row");
|
||||
const at = { privacy: "#sessionReadsList .row", general: "#sessionTerminalRow" };
|
||||
const where = (tab) => t("Settings") + " › " + $("#setTab-" + tab).textContent;
|
||||
go.onclick = (e) => {
|
||||
if (!sessionTerminalShows(prefs)) return openSettingsAt(e, "privacy", at.privacy);
|
||||
e.stopPropagation();
|
||||
if (go.classList.contains("open")) return closeProtoMenu();
|
||||
openProtoMenu(go, [{ v: "privacy", name: "Agents' session history", note: where("privacy") }, { v: "general", name: "Session terminal", note: where("general") }],
|
||||
null, (v, ev) => openSettingsAt(ev, v, at[v]), "Settings", "sess-menu", "right");
|
||||
};
|
||||
h.append(q, sel, tr, go);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
// status), and before start.js draws Settings; drawn whether the plugin is
|
||||
// on or off.
|
||||
|
||||
// a Mac's, and Windows' and Linux's when a terminal is found there; the
|
||||
// Sessions page's Settings › asks it too
|
||||
window.sessionTerminalShows = (s) => !web && (document.body.classList.contains("mac") || !!s?.terminalApps?.length);
|
||||
|
||||
function renderSessionTerminal(s, keep) {
|
||||
const row = $("#sessionTerminalRow");
|
||||
// a Mac's, and Windows' and Linux's when a terminal is found there
|
||||
const mac = document.body.classList.contains("mac");
|
||||
const apps = [...(s.terminalApps || [])];
|
||||
row.hidden = web || !mac && !apps.length;
|
||||
row.hidden = !sessionTerminalShows(s);
|
||||
if (row.hidden) return;
|
||||
const select = $("#sessionTerminalSelect");
|
||||
if (mac && !apps.some((app) => app.id === "com.apple.Terminal")) apps.unshift({ id: "com.apple.Terminal", name: "Terminal" });
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
// and the Sessions page it is about didn't lead there once its first ask was
|
||||
// answered (the scattered settings audit after netube99 on X). Its head now
|
||||
// has a Settings › that opens Privacy at those rows, lit, with Back to
|
||||
// Sessions; gateway mode, which reads no agent's history, has none. Every
|
||||
// Sessions; gateway mode, which reads no agent's history, has none. Where
|
||||
// a session can open in a terminal (a Mac, or a terminal found), General's
|
||||
// Session terminal is Sessions' too, so Settings › is a menu of both, and
|
||||
// each reaches its row lit. Every
|
||||
// language, Chromium and WebKit, at 1100 and 420 wide, nothing past the
|
||||
// window's edge or over the head's other buttons.
|
||||
const assert = require("node:assert/strict");
|
||||
@@ -49,8 +52,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
test(`${engine} ${lang} ${width}: Sessions leads to Settings › Privacy's session history`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const open = async (gateway) => {
|
||||
const open = async (gateway, platform = "Linux x86_64") => {
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
|
||||
await page.addInitScript((p) => Object.defineProperty(Navigator.prototype, "platform", { get: () => p }), platform);
|
||||
page.setDefaultTimeout(6000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.errors = [];
|
||||
@@ -89,6 +93,30 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.locator("#view-sessions .sm-head").waitFor();
|
||||
assert.deepEqual(page.errors, []);
|
||||
|
||||
// on a Mac a session opens in a terminal: Settings › names both
|
||||
// places, and each one reaches its row, lit, the page unmoved
|
||||
for (const [tab, row, name] of [["privacy", "#sessionReadsList .row", "Agents' session history"], ["general", "#sessionTerminalRow", "Session terminal"]]) {
|
||||
page = await open(false, "MacIntel");
|
||||
const top = await page.locator(".sm-head").evaluate((h) => h.getBoundingClientRect().top);
|
||||
await page.locator(".sm-head .sm-toset").click();
|
||||
const menu = page.locator(".proto-menu");
|
||||
await menu.waitFor();
|
||||
const items = menu.locator(".pm-item");
|
||||
assert.equal(await items.count(), 2);
|
||||
assert.deepEqual(await items.locator(".pm-name").allTextContents(), [await tr(page, "Agents' session history"), await tr(page, "Session terminal")]);
|
||||
assert.equal(await page.locator(".sm-head").evaluate((h) => h.getBoundingClientRect().top), top, "opening the menu moved nothing");
|
||||
const mb = await menu.boundingBox();
|
||||
assert(mb.x >= 0 && mb.x + mb.width <= width + 1, "the menu inside the window");
|
||||
const set = (await tr(page, "Settings")) + " › " + await page.locator("#setTab-" + tab).textContent();
|
||||
const item = items.filter({ has: page.locator(".pm-name", { hasText: await tr(page, name) }) });
|
||||
assert.equal(await item.locator(".pm-note").textContent(), set);
|
||||
await item.click();
|
||||
await page.locator(`#view-settings ${row}.flash`).first().waitFor();
|
||||
assert.equal(await page.locator("#setTab-" + tab).getAttribute("aria-selected"), "true");
|
||||
assert.equal(await page.evaluate(() => document.scrollingElement.scrollTop), 0, "the window itself is not scrolled");
|
||||
assert.deepEqual(page.errors, []);
|
||||
}
|
||||
|
||||
// gateway mode reads no agent's history: no link
|
||||
page = await open(true);
|
||||
assert.equal(await page.locator(".sm-head .sm-toset").isVisible(), false, "no Settings › in gateway mode");
|
||||
|
||||
Reference in New Issue
Block a user