gui: Get started put away comes back from Settings › General

Once the Agents page's Get started card was hidden (POST
/api/settings/guide {hidden:true}) nothing in the app brought it back.
Hiding it now says where it comes back ("Get started hidden; Settings ›
General brings it back"), and General has a Get started row with Show,
only while the card is hidden and would otherwise show (setup not done,
not gateway mode). Show posts {hidden:false}, redraws the Agents page and
says so; the row goes. The row lives in guideback.js, imported by
navpages.js beside the sidebar's pages, so the core grows by one status
line. Settings' search finds it by its name.

Run (mote, at this tree):
- getting-started, nav-pages-hidden, nav-pages-order, settings-general,
  settings-search, i18n-keys, gui-de, Chromium and WebKit, every
  language: 117 tests, all pass after the fake server answered
  /api/settings with the guide flag as the real one does.
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok.

Broken by hand, each red, then put back:
- renderNavPages not calling guideBack: getting-started 20 of 60 red
  (the row never shows).
- the hide's status line removed: getting-started 30 of 60 red.

Not tried: the real app window.
This commit is contained in:
yetone
2026-11-18 13:46:51 +08:00
parent 36d784da4b
commit cb1fe6d5d9
7 changed files with 70 additions and 2 deletions
+1 -1
View File
@@ -796,7 +796,7 @@ covers it in both engines, every language and a narrow window.
- The Providers page has a search box over its list (#1614, `findProviders` in [`app.js`](../../internal/gui/assets/app.js)): the words typed keep the rows, on and off, whose text or data say them all: name, id, preset, addresses, every model's id and name, the account's user and plan and each login's, account names and key names. The Turned off fold stays open while searching; Escape or clearing the box shows every row and the fold as it was. A row that is on reorders by dragging its logo, Alt+↑/↓, Alt+Shift+↑/↓ (top, bottom) or its right-click menu (`openProviderMenu`: Move to top, Move up, Move down, Move to bottom). While searching, a step or a drop moves it among the rows shown (it takes the place of the row it passes, `stepProvider`, `shownToOn`) and the hidden ones keep their order; Move to top and Move to bottom go to the ends of the whole list. Every move saves the whole order through `POST /api/providers/arrange`. See `provider-find.test.cjs` and `provider-order.test.cjs`.
- Providers are removed several at once from Select, beside the search box (`#pvSelect`, shown with two providers or more; eiyuuzaki2333 on X). Picking (`pvSel` in [`app.js`](../../internal/gui/assets/app.js); `pickedProviderRow`, `pvSelBar` and `removePicked` in [`pvpick.js`](../../internal/gui/assets/pvpick.js), imported when Select is first clicked, so the core carries only the button and two lines in `renderProviders`) puts a box on every row, takes the handle and switch away and opens no editor: a click on a row picks it, Shift picks the rows shown between, and the bar's box picks every row shown (a search narrows it; the closed Turned off fold's rows are not shown). Remove asks once, in the app's own dialog (`confirmAction`), with the count and every name, and posts `POST /api/providers/delete {ids}` (`providerRoutes` in [`providers.go`](../../internal/gui/providers.go)). That runs `provider.Delete` for each id, as the editor's Remove does, inside one `agent.Reseat`, so agents move once, to where they end up. A provider it can't remove comes back in `unremoved` with why, stays picked and is named in the status; it is refused only when nothing was removed. Done, Escape or a removal that leaves nothing picked ends picking. See `provider-bulk-remove.test.cjs` and `TestProvidersDeleteSeveral`.
- Hide accounts (`window.hideAccounts` at the end of [`app.js`](../../internal/gui/assets/app.js)) masks every account name and address in the window's text and tooltips, its menus and dialogs too, by one switch for the whole window and the tray panel. Routing's, Usage's and Providers' buttons (`#rtMask`, `#usageMask`, `#pvMask` beside Providers' search box) and Settings › Privacy's row are that one switch, stored in `magpie.maskEmails`: turned on any page, every page is hidden and every button says so, and another window or the panel follows through the `storage` event (paultian in #feedback: Providers had a switch of its own, so one page was hidden while another wasn't). A `magpie.maskProviders` left by the versions that had Providers' own switch is folded in once and removed: hidden on either page then is hidden everywhere now. While it is not chosen, it follows Mask personal data, and turning that on turns it on (`provider-mask.test.cjs`). While it is on, an account's name on the provider editor's row (`accountNameButton`, and the one-account line) and on its Usage card (`quotaWho`), and on the tray panel's Usage card (`panelQuotaCard`'s `.pq-who`, in sight while the card is hovered), has an eye (`hideAccounts.eye`), in sight on hover or keyboard focus. A click shows that one account, its address and the name the user gave it together (`kin`), everywhere that page draws it, tooltips included, while the others stay hidden (yogurt36 on Discord, for a screen share). The accounts shown are a set held in memory that `hits()` skips; nothing stores them. The window and the panel are pages of their own, each with its own set: one shown in the window stays hidden in the panel and the other way round, so a screenshot of either shows only what was shown there. Closing the window hides them again: the page stays loaded while the window is hidden, so `hideMain` runs `mainClosedJS` (`hideAccounts.closed`) first. Putting the panel away hides the panel's again, from its `visibilitychange` (the one that drops `panelPeek`) (`account-eye.test.cjs`, `TestClosingHidesShownAccounts`). What it hides is the accounts: their addresses, their vendors' values (`user`, `account`, Routing's `who`) and a name that stands for one, a plugin's (`accountUsers`, a card's `alias` without `named`) or a seat's. The name the user gave an account (`AccountNames`; a card's `alias` with `named`, which `withAccountNames` sets) is no account and stays in sight, beside the account it names, hidden (faketrader in #3656: several accounts couldn't be told apart). A label is scoped by its element, never by its value: in the user's own name (`.own-name`), a plan (`.plan`, the Providers row's `.acct-plan`), a model (`.model-value`) and a Usage card's title (`.subscription-head > b`) only an address is hidden, so an Antigravity account whose value is "Google" leaves "Google AI Pro" readable while an address written in a plan is still hidden; the same holds for the tooltips of plans and models (`TIPS`), not for the own name's, which says the account (`LABELS` in app.js, `account-mask-alias-plan.test.cjs`). The tray panel card's tooltip joins the account and the plan in one string, and still hides a plan's word that is an account's value.
- A new user's Agents page (the window's first page and the panel's Agents tab) has a *Get started* card above the agents in the welcome's place (wangye1644294 on X, `guideCard` in [`app.js`](../../internal/gui/assets/app.js)). Its three steps are: add a model source; connect an agent, where the agents magpie found that can be connected are named and each is connected in one click (`agents/connect`); and, optional, a routing group, with the most harmless starter template that can be made from the user's models (`provider.Templates`, Never stuck first) added in one click through `POST /api/groups/template`. Every tick comes from the state: the models magpie serves (`served` in `/api/state`, groups left out), an agent wired, or a group that isn't automatic. None comes from the card having been seen. The card goes once the first two steps are done. Its close button saves `settings.GuideHidden` through `POST /api/settings/guide`, so the panel, the window and a reload agree, and the Settings save keeps it. See `getting-started.test.cjs`.
- A new user's Agents page (the window's first page and the panel's Agents tab) has a *Get started* card above the agents in the welcome's place (wangye1644294 on X, `guideCard` in [`app.js`](../../internal/gui/assets/app.js)). Its three steps are: add a model source; connect an agent, where the agents magpie found that can be connected are named and each is connected in one click (`agents/connect`); and, optional, a routing group, with the most harmless starter template that can be made from the user's models (`provider.Templates`, Never stuck first) added in one click through `POST /api/groups/template`. Every tick comes from the state: the models magpie serves (`served` in `/api/state`, groups left out), an agent wired, or a group that isn't automatic. None comes from the card having been seen. The card goes once the first two steps are done. Its close button saves `settings.GuideHidden` through `POST /api/settings/guide`, so the panel, the window and a reload agree, and the Settings save keeps it. Hiding it says where it comes back: Settings › General has a *Get started* row with Show while it is hidden and setup isn't done (`guideback.js`, imported by `navpages.js`; `getting-started.test.cjs`). See `getting-started.test.cjs`.
- A connected agent's row in the window opens and closes on a click anywhere on it that isn't one of its controls, as a disclosure row does on the Mac (NG_shiyu on X, `connectRow` in [`app.js`](../../internal/gui/assets/app.js)): the click is handed to the row's *Models {n}* link (`expandLink`), which stays the control the keyboard and a screen reader use and keeps `aria-expanded`. Buttons, links, inputs, anything with a role, the grip and the opened sheet (`.ag-exp`) keep their own clicks, and a click that ends a text selection does nothing. The panel's rows did this already (`agent-row-disclose.test.cjs`).
- An agent whose own model menu is the list picked in magpie (ZCode, Claude Desktop, Cursor Private Inference, …: `listsMenu`) says that list as its ticks are, on its button and on the panel row (`menuSaid` in [`app.js`](../../internal/gui/assets/app.js)): every model ticked is *All N models*, one or two by their names, more as *Showing x / N models*, none as *No models*. It never says the first names and a +N: routing groups come first, so that read as a pick of one group and one model while every model was on (NG_shiyu on X). Other agents' start pickers still say the one model or group they start on (`agent-menu-label.test.cjs`).
- Every page of the window keeps to one width, at most 1200px of content centred, with a 16px gutter in a narrow window (`padding: max(16px, calc(50% - 600px))` on each `#view-…`, #860). Routing, Usage and Sessions are in that rule too (面条 on Discord), so a large screen doesn't stretch them edge to edge while the others sit in the middle; their columns follow the room they get (`byWidth`). See `page-width.test.cjs`.
+1
View File
@@ -1949,6 +1949,7 @@ async function hideGuide() {
state.settings = prefs;
guideBusy = "";
renderAgents();
status(t("Get started hidden; Settings › General brings it back"), "ok");
} catch (err) {
guideBusy = "";
guideRedraw();
+28
View File
@@ -0,0 +1,28 @@
// Settings › General › Get started: the Agents page's card, once its ×
// put it away, brought back (nothing did, and a user who hid it before
// setting up had no guide left). The row shows only while the card is
// hidden and would show otherwise, so it is seldom there. navpages.js
// imports this when Settings draws, so it weighs nothing on the core.
window.guideBack = function () {
const row = $("#guideBackRow");
if (!row || !state) return;
const set = ((state.served || 0) > 0 || anyMagpieModels()) && state.agents.some((a) => a.wired);
row.hidden = gatewayMode || !state.settings?.guideHidden || set;
if (row.hidden || row.querySelector("button")) return;
const b = el("button", "text", t("Show"));
b.type = "button";
b.onclick = async () => {
b.disabled = true;
try {
prefs = await writingPrefs(api("settings/guide", { hidden: false }));
state.settings = prefs;
renderAgents();
status(t("Get started is back on the Agents page"), "ok");
} catch (err) {
statusTErr(err);
}
b.disabled = false;
window.guideBack();
};
row.append(b);
};
+8
View File
@@ -273,6 +273,8 @@ const I18N = {
"Get started": "快速上手",
"{n} of {m} done": "已完成 {n}/{m}",
"Hide Get started": "隐藏快速上手",
"Get started hidden; Settings › General brings it back": "已隐藏快速上手,可在 设置 › 常规 里恢复",
"Get started is back on the Agents page": "快速上手已回到 Agent 页",
"Add a model source": "添加模型来源",
"{n} models ready to use": "已有 {n} 个模型可用",
"A subscription you already pay for, a provider, or an API key": "你已经付费的订阅、一个供应商,或一个 API 密钥",
@@ -5759,6 +5761,8 @@ const I18N = {
"Get started": "快速上手",
"{n} of {m} done": "已完成 {n}/{m}",
"Hide Get started": "隱藏快速上手",
"Get started hidden; Settings › General brings it back": "已隱藏快速上手,可在 設定 › 常規 裡恢復",
"Get started is back on the Agents page": "快速上手已回到 Agent 頁",
"Add a model source": "新增模型來源",
"{n} models ready to use": "已有 {n} 個模型可用",
"A subscription you already pay for, a provider, or an API key": "你已經付費的訂閱、一個供應商,或一個 API 金鑰",
@@ -11215,6 +11219,8 @@ const I18N = {
"Get started": "はじめに",
"{n} of {m} done": "{m} 件中 {n} 件完了",
"Hide Get started": "「はじめに」を隠す",
"Get started hidden; Settings › General brings it back": "「はじめに」を隠しました。設定 › 一般 で戻せます",
"Get started is back on the Agents page": "「はじめに」をエージェントページに戻しました",
"Add a model source": "モデルの提供元を追加",
"{n} models ready to use": "{n} 個のモデルが使えます",
"A subscription you already pay for, a provider, or an API key": "契約済みのサブスクリプション、プロバイダ、または API キー",
@@ -16680,6 +16686,8 @@ const I18N = {
"Get started": "Erste Schritte",
"{n} of {m} done": "{n} von {m} erledigt",
"Hide Get started": "Erste Schritte ausblenden",
"Get started hidden; Settings › General brings it back": "Erste Schritte ausgeblendet; Einstellungen › Allgemein holt sie zurück",
"Get started is back on the Agents page": "Erste Schritte sind wieder auf der Seite Agenten",
"Add a model source": "Eine Modellquelle hinzufügen",
"{n} models ready to use": "{n} Modelle einsatzbereit",
"A subscription you already pay for, a provider, or an API key": "Ein Abo, das Sie schon bezahlen, ein Anbieter oder ein API-Schlüssel",
+3
View File
@@ -221,6 +221,9 @@
<div class="row pref" id="navPagesRow" hidden>
<div class="who"><div class="name" data-t>Sidebar pages</div></div>
</div>
<div class="row pref" id="guideBackRow" hidden>
<div class="who"><div class="name" data-t>Get started</div></div>
</div>
<div class="row pref app-only" id="textSizeRow">
<div class="who"><div class="name" data-t>Text size</div></div>
<div id="textSizeSegs"></div>
+2
View File
@@ -8,6 +8,7 @@
// always shown. app.js imports this when Settings draws, so it weighs
// nothing on the core.
import "./navorder.js";
import "./guideback.js";
const navPagesOf = (nav) => [...nav.querySelectorAll(":scope > button[data-view]")]
.filter((b) => !(gatewayMode && GATEWAY_HIDES.includes(b.dataset.view)) && !featureHides(b))
.map((b) => ({ v: b.dataset.view, name: (b.querySelector("span[data-t]") || b.querySelector("span"))?.textContent || b.textContent.trim(), plugin: "pluginPage" in b.dataset }));
@@ -108,6 +109,7 @@ function navPagesMenu(anchor) {
}
window.renderNavPages = function () {
window.guideBack(); // Get started, beside these (guideback.js)
const row = $("#navPagesRow"), nav = $("#nav");
if (!row) return;
// only a window has a sidebar: the panel has no #nav (#6139)
+27 -1
View File
@@ -10,7 +10,8 @@
// Renzexi01 on X (一进来就这么复杂): while the card shows, the agents'
// list is folded under it, behind "Show all {n} agents", since its second
// step names the ones found here; one connected, or the card put away,
// and the list is in view as before.
// and the list is in view as before. Put away, its line says Settings ›
// General brings it back, and a row there does (the window).
// Both engines, a wide and a narrow window and the panel, every language.
// No backend, the API is faked here.
const assert = require("node:assert/strict");
@@ -59,6 +60,7 @@ function server(lang, w, posts) {
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (req.method() === "POST") posts.push(url.pathname + url.search);
if (url.pathname === "/api/state") return json(state());
if (url.pathname === "/api/settings") return json(settings());
if (url.pathname === "/api/settings/guide") {
w.hidden = !!req.postDataJSON().hidden;
return json(settings());
@@ -223,6 +225,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.locator(".guide").waitFor({ state: "detached" });
assert.ok(posts.includes("/api/settings/guide"));
assert.equal(w.hidden, true);
assert.equal(await page.locator("#status").textContent(), await page.evaluate(() => t("Get started hidden; Settings › General brings it back")));
// put away, the list is in view as it was before there was a card
assert.equal(await folded(page), 0);
assert.deepEqual(await tops(page), top, "no click moved the page");
@@ -236,6 +239,29 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await again.page.locator(".guide").count(), 0);
assert.equal(await again.page.evaluate(() => { try { return Object.keys(localStorage).filter((k) => /guide/i.test(k)).length; } catch { return 0; } }), 0, "nothing kept in localStorage");
assert.deepEqual(again.page.errors, []);
if (layout.name === "panel") return;
// and brought back from Settings › General, where its hide said:
// a row there only while it is away and would show
const pg = again.page, tr = (s) => pg.evaluate((s) => t(s), s);
await pg.goto("http://magpie.test/?view=settings&tab=general");
const back = pg.locator("#guideBackRow");
await back.locator("button").waitFor();
assert.equal(await back.locator(".name").textContent(), await tr("Get started"));
// Settings' search finds it by its name
await pg.locator("#setQ").fill((await tr("Get started")).toLowerCase());
await pg.waitForTimeout(150);
assert.ok(await back.isVisible(), "the search finds the row");
await pg.locator("#setQ").fill("");
const before = await pg.locator("#view-settings").evaluate((v) => v.scrollTop);
await back.locator("button").click();
await back.waitFor({ state: "hidden" });
assert.equal(w.hidden, false);
assert.equal(await pg.locator("#status").textContent(), await tr("Get started is back on the Agents page"));
assert.equal(await pg.locator("#view-settings").evaluate((v) => v.scrollTop), before, "no click moved the page");
await pg.goto("http://magpie.test" + layout.url);
await pg.locator("#agentsLead .guide").waitFor();
assert.deepEqual(pg.errors, []);
});
}
}