Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gui: Settings' session rows are the sessions plugin's settings.js; app.js back under its budget

yetoneec789445dba9
diff --git a/docs/subsystems/gateway-sessions.md b/docs/subsystems/gateway-sessions.md
index 542897479..98565316a 100644
--- a/docs/subsystems/gateway-sessions.md
+++ b/docs/subsystems/gateway-sessions.md
@@ -232,7 +232,7 @@ covers them), and `sessions/manage` carries the same as `reads`. While
the sessions plugin): each agent found with a switch, off; Allow selected
saves `all: false` with each agent picked or not, Allow all `all: true`.
Settings › Privacy, *Agents' session history* (`renderSessionReads` in
-app.js), has *Agents found later* (`all`, sent with each listed agent
+the sessions plugin's `settings.js`), has *Agents found later* (`all`, sent with each listed agent
at the value its row shows) and a row per agent.
`magpie sessions read [on|off all|<agent>…]` shows and changes the same
choice from the CLI (`sessionReadsTo`); while it is not asked,
diff --git a/docs/subsystems/plugin-runtime.md b/docs/subsystems/plugin-runtime.md
index f51f268b0..749eeb728 100644
--- a/docs/subsystems/plugin-runtime.md
+++ b/docs/subsystems/plugin-runtime.md
@@ -113,8 +113,9 @@ as" (#3897).
so with no Sessions plugin it does nothing. With Sessions switched off,
a row of Usage's list unfolds its details in place instead
(`sessionItem`, #2311). Still in app.js: the Usage
- page's Sessions tab (`/api/sessions`) and Settings' session terminal row
- (`data-feature="sessions"`).
+ page's Sessions tab (`/api/sessions`). Settings' Session terminal row
+ (`data-feature="sessions"`) and Privacy's Agents' session history are its
+ `settings.js`, loaded after app.js and drawn whether it is on or off.
- **Library** (`plugins/library`, `Client: i18n.js, library.css,
client.js`): the page that was `library.js`. Its code runs at `mount`
only, where it wires its listeners (the dialog's backdrop and Escape,
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 62584d578..5fe65eab6 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -19969,40 +19969,6 @@ function renderLangPick(s, keep) {
};
}
-function renderSessionTerminal(s, keep) {
- const row = $("#sessionTerminalRow");
- row.hidden = !document.body.classList.contains("mac");
- if (row.hidden) return;
- const select = $("#sessionTerminalSelect");
- const apps = [...(s.terminalApps || [])];
- if (!apps.some((app) => app.id === "com.apple.Terminal")) apps.unshift({ id: "com.apple.Terminal", name: "Terminal" });
- const chosen = s.sessionTerminal || "system";
- // a default that is not a terminal opens Terminal, as the server does
- const defaultApp = apps.find((app) => app.id === s.terminalDefault) || apps.find((app) => app.id === "com.apple.Terminal");
- const options = [{ id: "system", name: t("System default ({name})", { name: defaultApp.name }) }];
- for (const app of apps) {
- if (app.id === defaultApp.id && app.id !== chosen) continue;
- options.push({ id: app.id, name: app.id === defaultApp.id ? t("{name} (fixed)", { name: app.name }) : app.name });
- }
- if (!options.some((app) => app.id === chosen)) {
- options.push({ id: chosen, name: t("Unavailable app ({id})", { id: chosen }) });
- }
- // the app's own menu, not a native select
- select.dataset.value = chosen;
- select.replaceChildren(el("span", "", options.find((app) => app.id === chosen).name), svg(CHEV, 11, 1.6));
- select.onclick = (e) => {
- e.stopPropagation();
- if (select.classList.contains("open")) return closeProtoMenu();
- openProtoMenu(select, options.map((app) => ({ v: app.id, name: app.name, note: "", literalName: true })), chosen, (v) => {
- if (v === chosen) return;
- // drawn at once; the save draws it again with what was kept
- select.dataset.value = v;
- select.firstChild.textContent = options.find((app) => app.id === v).name;
- savePrefs({ ...keep, sessionTerminal: v === "system" ? "" : v });
- }, "Session terminal", "sess-menu");
- };
-}
-
// renderSync: the Settings page's sync and backup — a remote keeping the
// setup the same on every computer, and a sealed file to carry by hand.
// One of the three opens a form below its row at a time.
@@ -21778,59 +21744,6 @@ function renderDiscovery(s) {
r.append(who, val);
box.replaceChildren(r);
}
-// renderSessionReads: which agents' own session history magpie reads
-// (RustCats on X: a new install showed every agent's sessions before
-// anyone agreed). The Sessions page asks once; here it changes later.
-// "Agents found later" is whether an agent with no row of its own is
-// read, and drawn from the settings at once; each agent found on this
-// computer has a row of its own, read from /api/sessions/reads when the
-// Privacy part is shown (loadSessionReads).
-let sessionReads = null; // /api/sessions/reads, as last read
-let sessionReadsSeq = 0;
-function renderSessionReads(s) {
- const box = $("#sessionReadsList");
- const r = sessionReads || { asked: !!s?.sessionReads?.asked, all: !!s?.sessionReads?.all, found: [] };
- const save = (body) => {
- const n = ++sessionReadsSeq;
- writingPrefs(api("sessions/reads", body))
- .then((got) => { if (n === sessionReadsSeq) { sessionReads = got; renderSessionReads(prefs); } })
- .catch((e) => { status(t(e.message), "err"); renderSessionReads(prefs); });
- };
- const row = (name, sub, on, fn) => {
- const rw = el("div", "row pref");
- const who = el("div", "who");
- who.append(el("div", "name", name));
- if (sub) who.append(el("div", "sub", sub));
- const val = el("div", "val");
- val.append(segs([["off", t("Off")], ["on", t("On")]], on ? "on" : "off", (v) => {
- if ((v === "on") !== on) fn(v === "on");
- }));
- rw.append(who, val);
- return rw;
- };
- const rows = [row(t("Agents found later"), t("Read the session history of an agent with no row here, one installed later too. Off, magpie reads only the agents turned on below; what its gateway served is counted either way"),
- r.asked && r.all, (on) => {
- // the agents with a row keep what their rows show
- const agents = {};
- for (const a of r.found || []) agents[a.agent] = !!a.on;
- save(Object.keys(agents).length ? { all: on, agents } : { all: on });
- })];
- for (const a of r.found || []) {
- const rw = row(a.name, "", a.on, (on) => save({ agents: { [a.agent]: on } }));
- rw.dataset.agent = a.agent;
- rows.push(rw);
- }
- box.replaceChildren(...rows);
-}
-function loadSessionReads() {
- const n = ++sessionReadsSeq;
- api("sessions/reads").then((got) => {
- if (n !== sessionReadsSeq) return;
- sessionReads = got;
- renderSessionReads(prefs);
- }).catch(() => {}); // the row drawn from the settings stays
-}
-
// what turning discovery off stops: the subscriptions signed in now, by
// name, the Providers list read for it when no page has yet
async function discoveryOffWarning() {
diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html
index 13d7049bd..f2f9978c3 100644
--- a/internal/gui/assets/index.html
+++ b/internal/gui/assets/index.html
@@ -540,6 +540,7 @@
<script src="plugins/otel/page.js"></script>
<script src="plugins/gateway/settings.js"></script>
<script src="plugins/search/settings.js"></script>
+<script src="plugins/sessions/settings.js"></script>
<script src="start.js"></script>
</body>
</html>
diff --git a/internal/gui/assets/plugins/sessions/settings.js b/internal/gui/assets/plugins/sessions/settings.js
new file mode 100644
index 000000000..d72899566
--- /dev/null
+++ b/internal/gui/assets/plugins/sessions/settings.js
@@ -0,0 +1,92 @@
+// The sessions plugin's part of Settings: General's Session terminal and
+// Privacy's Agents' session history. Run after app.js, whose helpers it
+// shares (el, segs, svg, api, writingPrefs, savePrefs, openProtoMenu,
+// status), and before start.js draws Settings; drawn whether the plugin is
+// on or off.
+
+function renderSessionTerminal(s, keep) {
+ const row = $("#sessionTerminalRow");
+ row.hidden = !document.body.classList.contains("mac");
+ if (row.hidden) return;
+ const select = $("#sessionTerminalSelect");
+ const apps = [...(s.terminalApps || [])];
+ if (!apps.some((app) => app.id === "com.apple.Terminal")) apps.unshift({ id: "com.apple.Terminal", name: "Terminal" });
+ const chosen = s.sessionTerminal || "system";
+ // a default that is not a terminal opens Terminal, as the server does
+ const defaultApp = apps.find((app) => app.id === s.terminalDefault) || apps.find((app) => app.id === "com.apple.Terminal");
+ const options = [{ id: "system", name: t("System default ({name})", { name: defaultApp.name }) }];
+ for (const app of apps) {
+ if (app.id === defaultApp.id && app.id !== chosen) continue;
+ options.push({ id: app.id, name: app.id === defaultApp.id ? t("{name} (fixed)", { name: app.name }) : app.name });
+ }
+ if (!options.some((app) => app.id === chosen)) {
+ options.push({ id: chosen, name: t("Unavailable app ({id})", { id: chosen }) });
+ }
+ // the app's own menu, not a native select
+ select.dataset.value = chosen;
+ select.replaceChildren(el("span", "", options.find((app) => app.id === chosen).name), svg(CHEV, 11, 1.6));
+ select.onclick = (e) => {
+ e.stopPropagation();
+ if (select.classList.contains("open")) return closeProtoMenu();
+ openProtoMenu(select, options.map((app) => ({ v: app.id, name: app.name, note: "", literalName: true })), chosen, (v) => {
+ if (v === chosen) return;
+ // drawn at once; the save draws it again with what was kept
+ select.dataset.value = v;
+ select.firstChild.textContent = options.find((app) => app.id === v).name;
+ savePrefs({ ...keep, sessionTerminal: v === "system" ? "" : v });
+ }, "Session terminal", "sess-menu");
+ };
+}
+
+// renderSessionReads: which agents' own session history magpie reads
+// (RustCats on X: a new install showed every agent's sessions before
+// anyone agreed). The Sessions page asks once; here it changes later.
+// "Agents found later" is whether an agent with no row of its own is
+// read, and drawn from the settings at once; each agent found on this
+// computer has a row of its own, read from /api/sessions/reads when the
+// Privacy part is shown (loadSessionReads).
+let sessionReads = null; // /api/sessions/reads, as last read
+let sessionReadsSeq = 0;
+function renderSessionReads(s) {
+ const box = $("#sessionReadsList");
+ const r = sessionReads || { asked: !!s?.sessionReads?.asked, all: !!s?.sessionReads?.all, found: [] };
+ const save = (body) => {
+ const n = ++sessionReadsSeq;
+ writingPrefs(api("sessions/reads", body))
+ .then((got) => { if (n === sessionReadsSeq) { sessionReads = got; renderSessionReads(prefs); } })
+ .catch((e) => { status(t(e.message), "err"); renderSessionReads(prefs); });
+ };
+ const row = (name, sub, on, fn) => {
+ const rw = el("div", "row pref");
+ const who = el("div", "who");
+ who.append(el("div", "name", name));
+ if (sub) who.append(el("div", "sub", sub));
+ const val = el("div", "val");
+ val.append(segs([["off", t("Off")], ["on", t("On")]], on ? "on" : "off", (v) => {
+ if ((v === "on") !== on) fn(v === "on");
+ }));
+ rw.append(who, val);
+ return rw;
+ };
+ const rows = [row(t("Agents found later"), t("Read the session history of an agent with no row here, one installed later too. Off, magpie reads only the agents turned on below; what its gateway served is counted either way"),
+ r.asked && r.all, (on) => {
+ // the agents with a row keep what their rows show
+ const agents = {};
+ for (const a of r.found || []) agents[a.agent] = !!a.on;
+ save(Object.keys(agents).length ? { all: on, agents } : { all: on });
+ })];
+ for (const a of r.found || []) {
+ const rw = row(a.name, "", a.on, (on) => save({ agents: { [a.agent]: on } }));
+ rw.dataset.agent = a.agent;
+ rows.push(rw);
+ }
+ box.replaceChildren(...rows);
+}
+function loadSessionReads() {
+ const n = ++sessionReadsSeq;
+ api("sessions/reads").then((got) => {
+ if (n !== sessionReadsSeq) return;
+ sessionReads = got;
+ renderSessionReads(prefs);
+ }).catch(() => {}); // the row drawn from the settings stays
+}