kaizen-agent 1.78.1 → 1.79.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli/accounts.ts CHANGED
@@ -82,6 +82,44 @@ export function addAccount(tool: unknown, name: unknown): { id: string } | { err
82
82
  // Whether the tool has saved a login here. The file is only looked at, never read.
83
83
  export const signedIn = (dir: string, tool: Tool) => existsSync(join(dir, tool === "claude" ? ".credentials.json" : "auth.json"));
84
84
 
85
+ // Who is signed in, as the tool itself says: `claude auth status --json` / `codex login status`,
86
+ // pointed at an account folder (`dir`) or at the normal login. kaizen never opens the login
87
+ // files; without the CLI (or when it hangs past 5 s) it falls back to whether the file exists.
88
+ export type Login = { signedIn: boolean; who?: string; plan?: string; via?: string; checked: "cli" | "file" };
89
+ export async function loginStatus(tool: Tool, dir?: string, env: NodeJS.ProcessEnv = process.env, timeoutMs = 5000): Promise<Login> {
90
+ const home = env.HOME || homedir();
91
+ const fallback = (): Login => ({ signedIn: signedIn(dir ?? join(home, tool === "claude" ? ".claude" : ".codex"), tool), checked: "file" });
92
+ const bin = Bun.which(tool, { PATH: env.PATH ?? "" });
93
+ if (!bin) return fallback();
94
+ const e: Record<string, string> = {};
95
+ for (const [k, v] of Object.entries(env)) if (typeof v === "string") e[k] = v;
96
+ if (dir) e[ACCOUNT_VAR[tool]] = dir; else delete e[ACCOUNT_VAR[tool]];
97
+ let p: ReturnType<typeof Bun.spawn> | null = null, timer: ReturnType<typeof setTimeout> | undefined;
98
+ // Raced against the clock: a killed CLI's own children can keep its output open, so the
99
+ // answer never waits on the pipes past the timeout.
100
+ const late = new Promise<Login>((done) => { timer = setTimeout(() => { try { p?.kill(); } catch { /* gone */ } done(fallback()); }, timeoutMs); });
101
+ const ask = (async (): Promise<Login> => {
102
+ p = Bun.spawn(tool === "claude" ? [bin, "auth", "status", "--json"] : [bin, "login", "status"], { env: e, stdin: "ignore", stdout: "pipe", stderr: "pipe" });
103
+ const [out, err] = await Promise.all([new Response(p.stdout as ReadableStream).text(), new Response(p.stderr as ReadableStream).text()]);
104
+ await p.exited;
105
+ return read(out, err);
106
+ })().catch(fallback);
107
+ try { return await Promise.race([ask, late]); } finally { clearTimeout(timer); }
108
+ function read(out: string, err: string): Login {
109
+ if (tool === "claude") {
110
+ const j = JSON.parse(out);
111
+ const str = (v: unknown) => (typeof v === "string" && v.trim() ? v.trim().slice(0, 120) : undefined);
112
+ return { signedIn: j?.loggedIn === true, who: str(j?.email), plan: str(j?.subscriptionType) ?? str(j?.planTier), via: str(j?.authMethod), checked: "cli" };
113
+ }
114
+ const txt = (out + "\n" + err).trim();
115
+ const m = /^Logged in using (.+)$/im.exec(txt);
116
+ // "an API key - sk-…": only the method, never a piece of the key.
117
+ if (m) return { signedIn: true, via: m[1]!.split(" - ")[0]!.trim().slice(0, 60), checked: "cli" };
118
+ if (/not logged in/i.test(txt)) return { signedIn: false, checked: "cli" };
119
+ return fallback();
120
+ }
121
+ }
122
+
85
123
  export function removeAccount(id: string, deleteFolder = false): string | null {
86
124
  const a = readAccounts();
87
125
  if (!validId(id) || !a.accounts.some((x) => x.id === id)) return "unknown account";
package/cli/web.ts CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  reviewFindings, pickFindings, backlogItem, startedBacklog, closeBacklog, markBacklogDone, fixPrompt, approvalPrompt, canApproveAwaiting, gateOf, recordAcceptance, healRuns, finishRun, nativePath, closeSessions, sweepSessions, issueUrl,
12
12
  launchMode, pruneRuns, pruneSessions, readSessions, ownerOf, runIndex, resumePrompt, runAgent, firstSession, webHosts,
13
13
  } from "./state.ts";
14
- import { ACCOUNT_VAR, accountDir, addAccount, readAccounts, renameAccount, signedIn, removeAccount, resolveAccount, setDefaultAccount } from "./accounts.ts";
14
+ import { ACCOUNT_VAR, accountDir, addAccount, loginStatus, readAccounts, renameAccount, removeAccount, resolveAccount, setDefaultAccount, type Login } from "./accounts.ts";
15
15
  import { readReport, signalOf } from "./report.ts";
16
16
  import { MAX_IMAGE, saveImage } from "./term-image.ts";
17
17
  import { shellHistory } from "./term-history.ts";
@@ -350,6 +350,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
350
350
  let usageCache: Usage[] = [];
351
351
  let usageAt = 0;
352
352
  const acctUsage = new Map<string, { at: number; usage: Usage | null }>();
353
+ const acctLogin = new Map<string, { at: number; login: Login }>();
353
354
  let pending: ReturnType<typeof setTimeout> | null = null;
354
355
  const prBusy = new Set<string>();
355
356
  // /state costs ~250 ms of this one thread on a big board (git status per project), and
@@ -1021,8 +1022,9 @@ export async function web(repoDir: string, opts: Opts = {}) {
1021
1022
  const a = KNOWN_AGENTS.find((k) => k.cmd === body.agent);
1022
1023
  if (!a || !agentUsable(a.cmd)) return bad("unknown agent", 400);
1023
1024
  agent = a.cmd;
1024
- // A sign-in names its account and runs plain: no bypass, no arguments.
1025
- const signIn = typeof body.account === "string" && body.account !== "";
1025
+ // A sign-in names its account and runs plain: no bypass, no arguments. `account: ""`
1026
+ // with `login: true` signs in the normal login (~/.claude, ~/.codex), never a default account.
1027
+ const signIn = typeof body.account === "string" && (body.account !== "" || body.login === true);
1026
1028
  const acct = resolveAccount(a.cmd, signIn ? body.account : undefined);
1027
1029
  if (acct.error) return bad(acct.error, 400);
1028
1030
  bypass = !signIn && bypassForLaunch(a.cmd, body.yolo, !!YOLO_FLAGS[a.cmd]);
@@ -1586,9 +1588,18 @@ export async function web(repoDir: string, opts: Opts = {}) {
1586
1588
  if (why) return bad(why);
1587
1589
  added = r?.id;
1588
1590
  acctUsage.clear();
1591
+ acctLogin.clear();
1589
1592
  changed();
1590
1593
  }
1591
1594
  const a = readAccounts();
1595
+ // Who is signed in, asked of the tool itself (cli/accounts.ts loginStatus), a minute at a time.
1596
+ const who = async (key: string, tool: "claude" | "codex", dir?: string): Promise<Login> => {
1597
+ const hit = acctLogin.get(key);
1598
+ if (hit && Date.now() - hit.at < 60_000) return hit.login;
1599
+ const login = await loginStatus(tool, dir);
1600
+ acctLogin.set(key, { at: Date.now(), login });
1601
+ return login;
1602
+ };
1592
1603
  const rows = await Promise.all(a.accounts.map(async (x) => {
1593
1604
  const dir = accountDir(x.id);
1594
1605
  let hit = acctUsage.get(x.id);
@@ -1596,9 +1607,22 @@ export async function web(repoDir: string, opts: Opts = {}) {
1596
1607
  hit = { at: Date.now(), usage: x.tool === "claude" ? await claudeUsageAt(dir) : codexUsageAt(dir) };
1597
1608
  acctUsage.set(x.id, hit);
1598
1609
  }
1599
- return { ...x, isDefault: a.default[x.tool] === x.id, signedIn: signedIn(dir, x.tool), usage: hit.usage, signIn: `${ACCOUNT_VAR[x.tool]}=${dir} ${x.tool}${x.tool === "codex" ? " login" : ""}` };
1610
+ const l = await who(x.id, x.tool, dir);
1611
+ return { ...x, isDefault: a.default[x.tool] === x.id, signedIn: l.signedIn, who: l.who, plan: l.plan, via: l.via, usage: hit.usage, signIn: `${ACCOUNT_VAR[x.tool]}=${dir} ${x.tool}${x.tool === "codex" ? " login" : ""}` };
1612
+ }));
1613
+ // The normal login of each installed tool (~/.claude, ~/.codex): the one runs use unless an
1614
+ // account above is the default.
1615
+ const normal = await Promise.all((["claude", "codex"] as const).filter((t) => onPath(t)).map(async (t) => {
1616
+ const key = "normal:" + t;
1617
+ let hit = acctUsage.get(key);
1618
+ if (!hit || Date.now() - hit.at > 60_000) {
1619
+ hit = { at: Date.now(), usage: t === "claude" ? await claudeUsage(home) : codexUsage(home) };
1620
+ acctUsage.set(key, hit);
1621
+ }
1622
+ const l = await who(key, t);
1623
+ return { tool: t, isDefault: !a.default[t], signedIn: l.signedIn, who: l.who, plan: l.plan, via: l.via, usage: hit.usage, signIn: t === "claude" ? "claude auth login" : "codex login" };
1600
1624
  }));
1601
- return json({ accounts: rows, windows: process.platform === "win32", ...(added ? { added } : {}) });
1625
+ return json({ accounts: rows, normal, windows: process.platform === "win32", ...(added ? { added } : {}) });
1602
1626
  }
1603
1627
 
1604
1628
  // Settings → General → Cleanup: what `kaizen prune` would remove from this page's project,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaizen-agent",
3
- "version": "1.78.1",
3
+ "version": "1.79.1",
4
4
  "description": "Staged workflow for AI agents — code, writing, research, operations: plan, human approval, build, independent review, bounded fix loop.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,7 +5,11 @@ import { store } from "./store.ts";
5
5
  import { toast } from "./toast.ts";
6
6
 
7
7
  // Settings → AI Provider Accounts. /accounts never carries a token.
8
- type Row = { id: string; tool: string; name: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any };
8
+ type Row = { id: string; tool: string; name: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any; who?: string; plan?: string; via?: string };
9
+ type Normal = { tool: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any; who?: string; plan?: string; via?: string };
10
+ // Who the tool says is signed in: an email (Claude), else how (Codex: "ChatGPT"), and the plan.
11
+ const whoLine = (a: { signedIn: boolean; who?: string; plan?: string; via?: string }) =>
12
+ a.signedIn && (a.who || a.via || a.plan) ? html`<span class="ac-who">${[a.who ?? (a.via ? `via ${a.via}` : ""), a.plan].filter(Boolean).join(" · ")}</span>` : "";
9
13
  const TOOL: Record<string, string> = { claude: "Claude", codex: "Codex" };
10
14
 
11
15
  function usageLine(u: any, signed: boolean) {
@@ -17,15 +21,25 @@ function usageLine(u: any, signed: boolean) {
17
21
 
18
22
  const row = (a: Row) =>
19
23
  html`<div class="sk" data-q="account ${a.name.toLowerCase()} ${a.tool}">
20
- <div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[a.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><input class="sel ac-name" data-ac-name="${a.id}" value="${a.name}" aria-label="Account name, click to rename" title="Click to rename" maxlength="60" autocomplete="off" spellcheck="false">${usageLine(a.usage, a.signedIn)}</span>
24
+ <div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[a.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><input class="sel ac-name" data-ac-name="${a.id}" value="${a.name}" aria-label="Account name, click to rename" title="Click to rename" maxlength="60" autocomplete="off" spellcheck="false">${whoLine(a)}${usageLine(a.usage, a.signedIn)}</span>
21
25
  ${a.signedIn && !a.usage?.expired ? "" : html`<button type="button" class="btn" data-ac-sign="${a.id}" data-tool="${a.tool}">Sign in</button>`}
22
26
  <button type="button" class="btn" data-ac-def="${a.isDefault ? "" : a.id}" data-tool="${a.tool}" aria-pressed="${String(a.isDefault)}">${a.isDefault ? "✓ Default" : "Default"}</button>
23
27
  <button type="button" class="btn" data-ac-rm="${a.id}" data-name="${a.name}">Remove</button></div>
24
28
  ${a.signedIn && !a.usage?.expired ? "" : html`<div class="sk-a"><code>${a.signIn}</code></div>`}
25
29
  </div>`;
26
30
 
27
- export const accountRows = (d: { accounts: Row[]; windows: boolean }) =>
28
- html`${["claude", "codex"].filter((t) => d.accounts.some((a) => a.tool === t)).map((t) => html`<h3 class="sg">${TOOL[t]} accounts</h3><div class="sgrp">${d.accounts.filter((a) => a.tool === t).map(row)}</div>`)}
31
+ // The login the tool uses on its own (~/.claude, ~/.codex): first in its section, Default unless an
32
+ // account below is.
33
+ const normalRow = (n: Normal) =>
34
+ html`<div class="sk ac-normal" data-q="account login normal default ${n.tool} ${(n.who ?? "").toLowerCase()}">
35
+ <div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[n.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><span class="ac-nm">Your login <i>~/.${n.tool}</i></span>${whoLine(n)}${usageLine(n.usage, n.signedIn)}</span>
36
+ ${n.signedIn && !n.usage?.expired ? "" : html`<button type="button" class="btn" data-ac-sign="" data-tool="${n.tool}">Sign in</button>`}
37
+ <button type="button" class="btn" data-ac-def="" data-tool="${n.tool}" aria-pressed="${String(n.isDefault)}"${n.isDefault ? " disabled" : ""} title="${n.isDefault ? "Runs use this login" : "Use this login for runs again"}">${n.isDefault ? "✓ Default" : "Default"}</button></div>
38
+ ${n.signedIn && !n.usage?.expired ? "" : html`<div class="sk-a"><code>${n.signIn}</code></div>`}
39
+ </div>`;
40
+
41
+ export const accountRows = (d: { accounts: Row[]; normal?: Normal[]; windows: boolean }) =>
42
+ html`${["claude", "codex"].filter((t) => d.accounts.some((a) => a.tool === t) || (d.normal ?? []).some((n) => n.tool === t)).map((t) => html`<h3 class="sg">${TOOL[t]}</h3><div class="sgrp">${(d.normal ?? []).filter((n) => n.tool === t).map(normalRow)}${d.accounts.filter((a) => a.tool === t).map(row)}</div>`)}
29
43
  <h3 class="sg">Add an account</h3><div class="sgrp"><div class="ac-add" data-q="add account sign in claude codex provider">
30
44
  <div class="achips">${["claude", "codex"].map((t) => html`<button type="button" data-ac-new="${t}"${d.windows ? " disabled" : ""}><img src="${AGENT_FAVICONS[t]}" alt="" width="16" height="16">Add ${TOOL[t]} account</button>`)}</div></div></div>`;
31
45
 
@@ -51,7 +65,7 @@ export function wireAccounts(redraw: () => Promise<unknown>) {
51
65
  const signIn = async (id: string, tool: string) => {
52
66
  const dir = store.dir || store.S?.dir;
53
67
  if (!dir) return toast("Open a project first, or run the line shown here in a terminal");
54
- const j = await post("/shell", { dir, agent: tool, account: id });
68
+ const j = await post("/shell", { dir, agent: tool, account: id, login: true });
55
69
  if (j.error || !j.key) return toast(j.error || "Could not open a terminal. Run the line shown here");
56
70
  const opened = !dispatchEvent(new CustomEvent("kz-open-term", { cancelable: true, detail: { dir, ws: j.ws, key: j.key } }));
57
71
  toast(opened ? "Sign in, then close the terminal" : "Terminal started. Open it from the side menu");
@@ -4,7 +4,7 @@ export type SettingsPage = { id: string; title: string; desc: string; ico: strin
4
4
  export const SETTINGS_NAV: [string, SettingsPage[]][] = [
5
5
  ["AI Capabilities", [
6
6
  { id: "agents", title: "Agents", desc: "Manage AI agents, set a default, and customize commands.", ico: "ai" },
7
- { id: "accounts", title: "AI Provider Accounts", desc: "Optional. Your normal logins keep working; add accounts only to switch between them.", ico: "link" },
7
+ { id: "accounts", title: "AI Provider Accounts", desc: "Who is signed in to each AI tool kaizen runs. Add accounts only to switch between more than one.", ico: "link" },
8
8
  { id: "orchestration", title: "Orchestration", desc: "Split a run into workers, each in its own terminal. Off by default.", ico: "ai" },
9
9
  { id: "skills", title: "Skills", desc: "What your agents can do. Changes apply to new sessions.", ico: "note" },
10
10
  { id: "voice", title: "Voice", desc: "Speech-to-text dictation, run in the browser.", ico: "mic" },
package/web/board.html CHANGED
@@ -153,6 +153,24 @@ body .rail a.upd::after{left:calc(50% + 6px);top:4px}body .toast{left:16px;botto
153
153
  .rail a.it[aria-current=page]{font-weight:600}
154
154
  }
155
155
  [data-hide="1"] .rail{width:calc(var(--btn-s) + 12px);padding-inline:6px;align-items:center}[data-hide="1"] .rail>:not(.top){display:none}[data-hide="1"] .rail .top{padding:0}[data-hide="1"] .rail .top>:not(#fold){display:none}
156
+ /* Desktop feel (2026-11-09-desktop-feel). With a mouse, scrollbars show only while the pointer is
157
+ over the area. In the desktop app (html.desk): chrome is not text (content stays selectable),
158
+ buttons use the arrow, nothing bounces, and the side menu's top row and each page's header are
159
+ the window's title bar, with room for the window buttons. */
160
+ @media (hover:hover) and (pointer:fine){*{scrollbar-width:thin;scrollbar-color:transparent transparent}*:hover{scrollbar-color:color-mix(in srgb,var(--ink) 28%,transparent) transparent}}
161
+ html.desk,html.desk body{overscroll-behavior:none}
162
+ html.desk :is(button,.btn,.ib,.rail,.hdr,nav,label,summary,[role=tab],[role=tablist],[role=menu],[role=menuitem],[role=option],.chip,.ice-chip,.tk-bar,.sg,.pstrip){-webkit-user-select:none;user-select:none}
163
+ html.desk :is(input,textarea,select,[contenteditable],pre,code,.xterm,.md,.ice-notes,.ice-t,.ice-ct){-webkit-user-select:text;user-select:text}
164
+ html.desk :is(button,.btn,.ib,a.it,[role=tab],[role=option],[role=menuitem],summary,.chip,.ice-chip){cursor:default}
165
+ html.desk :is(.hdr,.rail>.top){-webkit-app-region:drag}
166
+ html.desk :is(.hdr,.rail>.top) :is(button,a,input,select,textarea,.combo,.sel,.bar,[role=button],[role=group],[contenteditable],label,summary,details){-webkit-app-region:no-drag}
167
+ html.desk{--wco:max(0px,calc(100vw - env(titlebar-area-x,0px) - env(titlebar-area-width,100vw)));--wch:env(titlebar-area-height,0px)}
168
+ html.desk .hdr{padding-right:calc(16px + var(--wco))}
169
+ html.desk #rbar{padding-right:calc(6px + var(--wco));-webkit-app-region:drag}
170
+ html.desk #rbar :is(button,summary,details,a,input,select,.rtab,[role=button]){-webkit-app-region:no-drag}
171
+ html.desk body.runv #panel>header{padding-right:calc(12px + var(--wco))}
172
+ html.desk body.runv .pstrip{padding-top:calc(14px + var(--wch))}
173
+ html.desk.mac .rail>.top{padding-top:22px}
156
174
  /* end side menu */
157
175
  @media(max-width:640px){
158
176
  body .hdr{padding:10px 16px 12px;gap:8px;border-bottom:0}
@@ -806,7 +824,7 @@ aside .foot .more .menu-pop{left:0;right:auto;top:auto;bottom:calc(100% + 4px)}.
806
824
  .srow>:nth-child(2){grid-column:2;grid-row:1;align-self:center;justify-self:end}
807
825
  .srow .hint{grid-column:1/-1;grid-row:2;margin:0;font-size:12px;color:var(--dim);line-height:1.45;max-width:46ch}
808
826
  .srow .sreset{border:0;background:none;padding:0;font:inherit;color:var(--accent);cursor:pointer;text-decoration:underline;text-underline-offset:2px}
809
- .ac-add .achips{margin:0;align-items:center}.ac-add{padding:8px 0}.sk:has(.ac-name){padding-left:0;padding-right:0}.sk .ac-name{display:block;width:100%;max-width:280px;min-height:0;height:24px;margin:0 0 0 -6px;padding:0 6px;border-color:transparent;background:none;font-weight:500}.sk .ac-name:hover,.sk .ac-name:focus{border-color:var(--line)}.ac-u{font-size:12px;color:var(--dim)}.ac-u.bad{color:var(--warn)}.sk code{font-size:12px;overflow-wrap:anywhere}#run-acct{margin-top:6px;max-width:100%}
827
+ .ac-add .achips{margin:0;align-items:center}.ac-add{padding:8px 0}.sk:has(.ac-name){padding-left:0;padding-right:0}.sk .ac-name{display:block;width:100%;max-width:280px;min-height:0;height:24px;margin:0 0 0 -6px;padding:0 6px;border-color:transparent;background:none;font-weight:500}.sk .ac-name:hover,.sk .ac-name:focus{border-color:var(--line)}.ac-u{font-size:12px;color:var(--dim)}.ac-who{display:block;font-size:12px;color:var(--ink)}.ac-nm{display:block;font-weight:500}.ac-nm i{font-style:normal;font-family:var(--mono);font-size:11px;color:var(--dim);margin-left:6px}.ac-normal .btn[disabled]{opacity:1}.sk.ac-normal{padding-left:0;padding-right:0}.ac-u.bad{color:var(--warn)}.sk code{font-size:12px;overflow-wrap:anywhere}#run-acct{margin-top:6px;max-width:100%}
810
828
  @media(max-width:640px){.ac-add{grid-template-columns:1fr}}
811
829
  .sk-i{width:24px;height:24px;flex:none;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.sk-ag{border-radius:3px}.sk-ag.off{opacity:.3;filter:grayscale(1)}.sk-h~.sk-a{margin-left:34px;align-items:center}.sk:has(.ac-name) .sk-a{margin-left:0}
812
830
  .sk{padding:11px 16px}.sk~.sk{border-top:1px solid var(--line)}.sk-h{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.sk-n{flex:1 1 200px;min-width:0}.sk-n b{display:block;font-weight:500}.sk-n span{font-size:12px;color:var(--dim)}.sk-a{display:flex;flex-wrap:wrap;gap:4px 12px;margin-top:6px;font-size:12px;color:var(--dim)}.sk-a .miss{color:var(--warn)}
@@ -1309,7 +1327,9 @@ html body.wsb:not(.paged) #board{grid-template-columns:repeat(4,minmax(200px,1fr
1309
1327
  wide.addEventListener("change",rail);phone.addEventListener("change",rail);rail();
1310
1328
  document.getElementById("fold").onclick=()=>{fold=r.dataset.rail==="min"?"full":"min";try{localStorage.setItem("kz-rail",fold)}catch(e){}rail()};
1311
1329
  // Theme: light, dark, or unset for system, in kz-theme. The toggle shows what is on screen and flips it.
1312
- const paint=()=>{const d=r.dataset.theme?r.dataset.theme==="dark":os.matches;const b=document.getElementById("themet");if(b){b.dataset.dark=d;b.title=d?"Dark theme: switch to light":"Light theme: switch to dark";b.setAttribute("aria-label",b.title)}};
1330
+ // The desktop app: its own rules (html.desk, html.mac) and window buttons that follow the theme.
1331
+ const desk=window.kaizenDesktop;if(desk){r.classList.add("desk");if(desk.platform==="darwin")r.classList.add("mac")}
1332
+ const paint=()=>{const d=r.dataset.theme?r.dataset.theme==="dark":os.matches;desk&&desk.titleBar&&desk.titleBar(d);const b=document.getElementById("themet");if(b){b.dataset.dark=d;b.title=d?"Dark theme: switch to light":"Light theme: switch to dark";b.setAttribute("aria-label",b.title)}};
1313
1333
  // Colour: unset for monochrome, or blue, in kz-color. kz-theme repaints the terminals and Settings.
1314
1334
  window.setColor=c=>{if(c==="blue")r.dataset.color=c;else delete r.dataset.color;try{c==="blue"?localStorage.setItem("kz-color",c):localStorage.removeItem("kz-color")}catch(e){}dispatchEvent(new Event("kz-theme"))};
1315
1335
  try{if(localStorage.getItem("kz-color")==="blue")r.dataset.color="blue"}catch(e){}