diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css
index b147aa6f8..fa0c1f127 100644
--- a/internal/gui/assets/app.css
+++ b/internal/gui/assets/app.css
@@ -1910,6 +1910,15 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
.warm-tabs button.on { color: var(--fg); background: var(--pill); }
.warm-tabs button[hidden] { display: none; }
.warm-panes { margin-bottom: 8px; }
+/* the page's parts (#471): a tab each at the top in the same look, a line
+ more when they don't fit across (a narrow window, a larger text size),
+ the part picked alone under them */
+#view-settings .set-head { height: auto; min-height: 26px; flex: none; }
+.set-tabs { flex-wrap: wrap; row-gap: 2px; min-width: 0; }
+.set-tabs button { flex: none; white-space: nowrap; }
+.set-page { flex: none; }
+.set-page[hidden] { display: none; }
+.set-page > .list:not(:last-child) { margin-bottom: 8px; }
.row.pref { min-height: 50px; padding: 8px 12px 8px 14px; gap: 14px; }
.row.pref .who { flex: 1 1 auto; }
.row.pref .sub { margin-top: 2px; }
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index c67bc8a47..275a3bf62 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -10712,29 +10712,27 @@ function setWarmTab(tab, remember) {
b.setAttribute("aria-selected", String(on));
b.tabIndex = on ? 0 : -1;
$("#" + list).hidden = !on;
- // a pill drawn while its card was hidden measured nothing: its thumb is
- // put under the option picked, still, once the card is shown
- if (on) for (const th of $("#" + list).querySelectorAll(".segs > .thumb")) {
- const opt = th.parentElement.querySelector(":scope > .on");
- if (!opt || parseFloat(th.style.width) === opt.offsetWidth) continue;
- th.classList.add("still");
- th.style.transform = `translateX(${opt.offsetLeft}px)`;
- th.style.width = opt.offsetWidth + "px";
- void th.offsetWidth;
- th.classList.remove("still");
- }
+ if (on) thumbsUnderPicks($("#" + list));
}
}
-{
- const tabs = $("#warmTabs");
- tabs.onclick = (e) => {
- const b = e.target.closest("button[data-warm]");
- if (b) setWarmTab(b.dataset.warm, true);
- };
- // the arrows, Home and End move along the tabs, as a tab list's do: the
- // tab reached is clicked, so the page is held as for a click
+// a pill drawn while its card was hidden measured nothing: its thumb is
+// put under the option picked, still, once the card is shown
+function thumbsUnderPicks(box) {
+ for (const th of box.querySelectorAll(".segs > .thumb")) {
+ const opt = th.parentElement.querySelector(":scope > .on");
+ if (!opt || !opt.offsetParent || parseFloat(th.style.width) === opt.offsetWidth) continue;
+ th.classList.add("still");
+ th.style.transform = `translateX(${opt.offsetLeft}px)`;
+ th.style.width = opt.offsetWidth + "px";
+ void th.offsetWidth;
+ th.classList.remove("still");
+ }
+}
+// A tab list's keys: the arrows, Home and End move along its shown tabs,
+// and the tab reached is clicked, so the page is held as for a click
+function tabKeys(tabs, sel) {
tabs.onkeydown = (e) => {
- const shown = [...tabs.querySelectorAll("button[data-warm]:not([hidden])")];
+ const shown = [...tabs.querySelectorAll(sel + ":not([hidden])")];
const i = shown.indexOf(document.activeElement);
if (i < 0) return;
const j = { ArrowLeft: i - 1, ArrowRight: i + 1, Home: 0, End: shown.length - 1 }[e.key];
@@ -10746,6 +10744,69 @@ function setWarmTab(tab, remember) {
b.click();
};
}
+{
+ const tabs = $("#warmTabs");
+ tabs.onclick = (e) => {
+ const b = e.target.closest("button[data-warm]");
+ if (b) setWarmTab(b.dataset.warm, true);
+ };
+ tabKeys(tabs, "button[data-warm]");
+}
+
+// The Settings page is a page per part (#471: one long scroll of some 45
+// rows): a tab for each over them, in the warm-ups' look, its rows alone
+// under it. The part is kept in the address (?view=settings&tab=privacy) so
+// a reload comes back to it, and remembered for the window opened again.
+// A part with no row to show here (every one hidden on this system) has no
+// tab. A click on a tab, like every click, leaves the page where it is: the
+// tabs at the top stay where they were and the part comes in under them.
+const SET_TABS = ["general", "usage", "network", "models", "privacy", "otel", "sync", "about"];
+let setTab = "general";
+try { const k = localStorage.getItem("magpie.settingsTab"); if (SET_TABS.includes(k)) setTab = k; } catch {}
+let setShown = setTab; // the part shown: the one picked, or the first there
+// A part has a tab while a row of it shows: one not hidden itself nor within
+// it (a service's card under the warm-ups' tabs counts, picked or not). A
+// part not drawn yet, with no rows at all, keeps its tab.
+const partShows = (page) => {
+ const rows = [...page.querySelectorAll(".row")];
+ return !rows.length || rows.some((r) => {
+ for (let n = r; n && n !== page; n = n.parentElement) if (n.hidden && !n.matches('[role="tabpanel"]')) return false;
+ return true;
+ });
+};
+function setSetTab(tab, remember) {
+ if (remember) {
+ setTab = tab;
+ try { localStorage.setItem("magpie.settingsTab", tab); } catch {}
+ }
+ for (const id of SET_TABS) $("#setTab-" + id).hidden = !partShows($("#setPage-" + id));
+ if (!SET_TABS.includes(tab) || $("#setTab-" + tab).hidden) tab = SET_TABS.find((id) => !$("#setTab-" + id).hidden) || "general";
+ for (const id of SET_TABS) {
+ const b = $("#setTab-" + id), on = id === tab;
+ b.classList.toggle("on", on);
+ b.setAttribute("aria-selected", String(on));
+ b.tabIndex = on ? 0 : -1;
+ $("#setPage-" + id).hidden = !on;
+ if (on) thumbsUnderPicks($("#setPage-" + id));
+ }
+ setShown = tab;
+ $("#setTabs").setAttribute("aria-label", t("Settings"));
+ if (view === "settings") syncURL();
+}
+{
+ const tabs = $("#setTabs");
+ tabs.onclick = (e) => {
+ const b = e.target.closest("button[data-set]");
+ if (b) setSetTab(b.dataset.set, true);
+ };
+ tabKeys(tabs, "button[data-set]");
+ // opened on a part (a reload, a link): that part, and remembered
+ if (mode === "window" && params.get("view") === "settings" && SET_TABS.includes(params.get("tab"))) {
+ setTab = params.get("tab");
+ try { localStorage.setItem("magpie.settingsTab", setTab); } catch {}
+ }
+ setSetTab(setTab);
+}
function renderSettings() {
const s = prefs;
@@ -10856,6 +10917,8 @@ function renderSettings() {
repo.title = "github.com/yetone/magpie";
repo.onclick = () => api("open", { url: "https://github.com/yetone/magpie" }).catch(() => {});
row(t("Community"), t("questions, ideas and feedback, on Discord or GitHub"), "", join, repo);
+ // the parts' tabs, one gone whose rows are all hidden here
+ setSetTab(setTab);
}
function renderSessionTerminal(s, keep) {
@@ -12038,6 +12101,10 @@ addEventListener("click", (e) => {
purposeUntil = 0; // what came before the click (Space pressed on a button, a tremble) is no scroll
const v = e.target.closest?.(".view");
if (!v || v.hidden) { held = null; return; }
+ // a click before a frame has held the one before it (a tab list's keys
+ // pressed in quick turn) holds that one first: the page it shrank is put
+ // back, so this one is taken where the reader left it, not at the top
+ if (held?.v === v) hold(held);
const chain = [];
const from = e.target.closest?.("[data-unrolls]")?.parentElement || e.target;
for (let n = from; n && n !== v; n = n.parentElement) {
@@ -12085,6 +12152,7 @@ function syncURL() {
const q = new URLSearchParams(location.search);
if (view === "agents") q.delete("view"); else q.set("view", view);
if (view === "providers" && typeof editing === "string") q.set("edit", editing); else q.delete("edit");
+ if (view === "settings") q.set("tab", setShown); else q.delete("tab");
const s = q.size ? "?" + q : location.pathname;
if (s !== location.search) history.replaceState(null, "", s);
}
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 71ced1793..f7882d3e4 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -1366,6 +1366,9 @@ const I18N = {
// settings
"Preferences": "偏好",
+ // the Settings page's parts, a tab each
+ "General": "常规",
+ "Network and sharing": "网络与共享",
"Session terminal": "会话终端",
"Used by the terminal button in Sessions; only apps registered for .command files appear": "用于会话列表中的终端按钮;仅显示已注册处理 .command 文件的应用",
"System default ({name})": "系统默认({name})",
diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html
index 138e897a1..a93108137 100644
--- a/internal/gui/assets/index.html
+++ b/internal/gui/assets/index.html
@@ -211,128 +211,153 @@
-
Preferences
-
-
-
Appearance
Light or dark, or whatever the system is showing
Follows the Omarchy theme, as picked in Omarchy's menu
-
-
-
-
Language
Applies at once, no restart
-
-
-
-
Text size
-
-
-
-
Tray icon
What clicking magpie’s icon in the menu bar or tray opens
-
-
-
-
Bar icon
magpie’s icon beside Omarchy’s own in the bar; right-click opens the window
-
-
-
-
Usage in the menu bar
-
-
-
-
Menu bar refresh
How often the usage beside the icon is asked for again
-
-
-
-
Menu bar logos
Each subscription's logo before its numbers; off, the numbers alone with a thin line between subscriptions
-
-
-
-
Usage shows
How much of each window is used, or how much is left, on the Usage page, the panel and the menu bar
-
-
-
-
Currency
-
-
-
-
Number units
How a large count of tokens or requests is shortened on the Usage page and the panel
-
-
-
-
Usage alert
-
-
-
-
Low balance alert
-
-
-
-
Provider in model names
Agents’ lists put each model’s provider after its name, or not after names you set
-
-
-
-
Open at login
Start magpie in the tray when you log in, so agents find the gateway from the start
-
-
-
-
Dock
Keep magpie in the Dock too, always or while its window is open, for Cmd-Tab and a menu bar too full to show its icon
-
-
-
-
Session terminal
Used by the terminal button in Sessions; only apps registered for .command files appear
-
-
-
-
Proxy
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
Warm up on reset
-
+
+
+
+
Appearance
Light or dark, or whatever the system is showing
Follows the Omarchy theme, as picked in Omarchy's menu
+
+
+
+
Language
Applies at once, no restart
+
+
+
+
Text size
+
+
+
+
Tray icon
What clicking magpie’s icon in the menu bar or tray opens
+
+
+
+
Bar icon
magpie’s icon beside Omarchy’s own in the bar; right-click opens the window
+
+
+
+
Provider in model names
Agents’ lists put each model’s provider after its name, or not after names you set
+
+
+
+
Open at login
Start magpie in the tray when you log in, so agents find the gateway from the start
+
+
+
+
Dock
Keep magpie in the Dock too, always or while its window is open, for Cmd-Tab and a menu bar too full to show its icon
+
+
+
+
Session terminal
Used by the terminal button in Sessions; only apps registered for .command files appear
+
+
-
-
Daily warm-up
-
+
+
+
+
+
Usage in the menu bar
+
+
+
+
Menu bar refresh
How often the usage beside the icon is asked for again
+
+
+
+
Menu bar logos
Each subscription's logo before its numbers; off, the numbers alone with a thin line between subscriptions
+
+
+
+
Usage shows
How much of each window is used, or how much is left, on the Usage page, the panel and the menu bar
+
+
+
+
Currency
+
+
+
+
Number units
How a large count of tokens or requests is shortened on the Usage page and the panel