kaizen-agent 1.61.4 → 1.61.6

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/notes.test.ts CHANGED
@@ -238,3 +238,12 @@ test("web/notebook.js, web/term.js, web/board.js, web/video.js and bot/web/app.j
238
238
  expect(readFileSync(BOT_OUT, "utf8").split("\n", 1)[0]!).toContain(`kaizen bot page ${sourceHash()} `);
239
239
  expect(readFileSync(VIDEO_OUT, "utf8").split("\n", 1)[0]!).toContain(`kaizen video page ${sourceHash()} `);
240
240
  });
241
+
242
+ test("an installed app fits the window, not the screen", () => {
243
+ for (const f of ["board.html", "notes.html", "video.html"]) {
244
+ const s = readFileSync(join(root, "web", f), "utf8");
245
+ expect(s).not.toMatch(/--sh\b(?!a)/);
246
+ expect(s).toContain("inset:0 0 auto;height:100dvh");
247
+ expect(s).toContain("body::after{content");
248
+ }
249
+ });
package/cli/pty.ts CHANGED
@@ -125,7 +125,7 @@ export function startPty(key: string, cmd: string[], cwd: string, pidFile?: stri
125
125
  const ps = winPs();
126
126
  p.proc = Bun.spawn([ps, "-NoProfile", "-NonInteractive", "-EncodedCommand", conptyHost()], {
127
127
  cwd,
128
- env: { ...colorEnv(), KZ_PTY_CMD: innerCommand(ps, cmd), KZ_PTY_CWD: cwd, KZ_PTY_COLS: "120", KZ_PTY_ROWS: "32" },
128
+ env: { ...colorEnv(), KAIZEN_BOARD_PID: String(process.pid), KZ_PTY_CMD: innerCommand(ps, cmd), KZ_PTY_CWD: cwd, KZ_PTY_COLS: "120", KZ_PTY_ROWS: "32" },
129
129
  stdin: "pipe", stdout: "pipe", stderr: "pipe", windowsHide: true,
130
130
  });
131
131
  const read = async (s: ReadableStream<Uint8Array>) => {
@@ -137,7 +137,7 @@ export function startPty(key: string, cmd: string[], cwd: string, pidFile?: stri
137
137
  read(p.proc.stderr as ReadableStream<Uint8Array>).catch(() => {});
138
138
  } else p.proc = Bun.spawn(cmd, {
139
139
  cwd,
140
- env: { ...colorEnv(), TERM: "xterm-256color", COLORTERM: "truecolor" },
140
+ env: { ...colorEnv(), TERM: "xterm-256color", COLORTERM: "truecolor", KAIZEN_BOARD_PID: String(process.pid) },
141
141
  terminal: { cols: 120, rows: 32, data: (_t, d) => push(dec.decode(d, { stream: true })) },
142
142
  });
143
143
  if (opts.tmux && cmd[0] === tmuxBin()) p.tmux = opts.tmux;
@@ -298,7 +298,8 @@ export function loginEnv(shell = process.env.SHELL): Record<string, string> | nu
298
298
  if (!shell || process.platform === "win32") return null;
299
299
  const MARK = "__kaizen_env__";
300
300
  try {
301
- const r = Bun.spawnSync([shell, "-l", "-i", "-c", `echo ${MARK}; env -0`], { stdin: "ignore", stderr: "ignore", timeout: 5000, killSignal: "SIGKILL" });
301
+ // detached: an interactive shell takes the terminal foreground and never hands it back, which left ctrl-c reaching nothing.
302
+ const r = Bun.spawnSync([shell, "-l", "-i", "-c", `echo ${MARK}; env -0`], { stdin: "ignore", stderr: "ignore", timeout: 5000, killSignal: "SIGKILL", detached: true });
302
303
  const out = r.stdout.toString(), at = out.indexOf(MARK + "\n");
303
304
  if (r.exitCode !== 0 || at < 0) return null;
304
305
  const env: Record<string, string> = {};
@@ -167,3 +167,28 @@ test.skipIf(!posix)("a stopped or crashed board resumes its card agents, once af
167
167
  Bun.spawnSync(["pkill", "-f", `${bin}/claude`]);
168
168
  }
169
169
  }, 40_000);
170
+
171
+ // A phone reaches the board through a proxy pinned to its port, so the board an update
172
+ // starts has to outwait the old one instead of walking to the next port.
173
+ test.skipIf(!posix || !Bun.which("lsof"))("a new board takes over the port of a board slow to stop", async () => {
174
+ const port = 20000 + Math.floor(Math.random() * 20000);
175
+ const home = join(root, "takeover");
176
+ mkdirSync(home, { recursive: true });
177
+ const script = join(home, "old.ts");
178
+ writeFileSync(script, `Bun.serve({ hostname: "127.0.0.1", port: ${port}, fetch: () => new Response("old", { headers: { "x-kaizen-version": "0.0.0" } }) });
179
+ process.on("SIGTERM", () => setTimeout(() => process.exit(0), 1500));
180
+ console.log("up");`);
181
+ const old = Bun.spawn([process.execPath, script], { stdout: "pipe" });
182
+ await new Response(old.stdout).body!.getReader().read();
183
+ const fresh = Bun.spawn([process.execPath, join(import.meta.dir, "install.ts"), "web", "--port", String(port), "--no-open", "--foreground"], {
184
+ cwd: home, env: { ...process.env, HOME: home, USERPROFILE: home }, stdin: "ignore", stdout: "ignore", stderr: "ignore",
185
+ });
186
+ try {
187
+ let version: string | null = null;
188
+ for (let i = 0; i < 60 && (!version || version === "0.0.0"); i++) {
189
+ await Bun.sleep(200);
190
+ version = await fetch(`http://127.0.0.1:${port}/`).then((r) => r.headers.get("x-kaizen-version"), () => null);
191
+ }
192
+ expect(version).toBe(JSON.parse(readFileSync(join(import.meta.dir, "..", "package.json"), "utf8")).version);
193
+ } finally { fresh.kill("SIGKILL"); old.kill("SIGKILL"); }
194
+ }, 20000);
package/cli/web.ts CHANGED
@@ -513,9 +513,17 @@ export async function web(repoDir: string, opts: Opts = {}) {
513
513
  // older kaizen serves 404 for whatever came since; both are ours to stop.
514
514
  const pid = await pidOnPort(port);
515
515
  if (pid && pid !== process.pid) {
516
+ // This shell is a tab of that board: stopping it would end the shell running this.
517
+ if (process.env.KAIZEN_BOARD_PID === String(pid)) { console.log(`\n the board on ${port} hosts this terminal; restart it from a terminal outside the board\n`); process.exit(1); }
516
518
  try { process.kill(pid, "SIGTERM"); console.log(` stopped a ${up ? "stale" : "hung"} board on ${port} (pid ${pid})`); } catch { /* not ours to kill */ }
517
- await Bun.sleep(300);
518
- try { server = serve(port); continue; } catch { /* still held */ }
519
+ // A stopping board saves its agents first and can hold the port for seconds. Walking
520
+ // up now would strand this one on a port the phone's tailscale serve does not proxy.
521
+ for (let waited = 0; waited < 8000 && !server; waited += 200) {
522
+ await Bun.sleep(200);
523
+ if (waited === 5000) try { process.kill(pid, "SIGKILL"); } catch { /* already gone */ }
524
+ try { server = serve(port); } catch { /* still held */ }
525
+ }
526
+ if (server) continue;
519
527
  }
520
528
  console.log(` port ${port} refused by the OS and nothing answers there; trying ${port + 1}`);
521
529
  }
@@ -742,7 +750,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
742
750
  // id is read from that run's state.json, never taken from the page). Claude only: it is
743
751
  // the agent whose session id runs record. Refused while that session is still running
744
752
  // elsewhere, since two copies of one conversation overwrite each other's history.
745
- const runKey = typeof body.run === "string" && body.run.length <= 300 ? body.run : "";
753
+ const runKey = typeof body.run === "string" && body.run.length <= 2000 ? body.run : "";
746
754
  if (body.resume === true) {
747
755
  const id = runKey.startsWith("run:" + dir + ":") ? runKey.slice(dir.length + 5) : "";
748
756
  let st: any = {};
@@ -2022,7 +2030,12 @@ export async function web(repoDir: string, opts: Opts = {}) {
2022
2030
  await new Promise<void>((resolve) => {
2023
2031
  // The card agents are listed for the next board and ended (saveLive); the short wait
2024
2032
  // lets each take its /exit, or be ended with what it started, before this process goes.
2033
+ let stopping = false;
2025
2034
  const stop = () => {
2035
+ // A second ctrl-c, or a shutdown that hangs, still ends the process.
2036
+ if (stopping) process.exit(0);
2037
+ stopping = true;
2038
+ setTimeout(() => process.exit(0), 3000).unref();
2026
2039
  const live = ptyKeys().some((k) => ptyState(k)?.alive);
2027
2040
  saveLive();
2028
2041
  clearInterval(poll); clearInterval(ping); clearInterval(gather); clearInterval(loop); clearInterval(keepList);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaizen-agent",
3
- "version": "1.61.4",
3
+ "version": "1.61.6",
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": {
@@ -3,7 +3,9 @@
3
3
  // on a computer; a phone has Home, Chat, Runs and Settings.
4
4
  import { runPopup } from "./cards.ts";
5
5
  import { $, html, raw } from "./dom.ts";
6
- import { cardHref, logo, railData, stateOf, subline, titleOf, usageChips } from "./workspace.ts";
6
+ import { cardHref, logo, railData, stateOf, subline, titleOf, usageChips, wsHref } from "./workspace.ts";
7
+ import { toast } from "./toast.ts";
8
+ import { agentStatus, wsKey, type Agent, type Status } from "./ws-tabs.ts";
7
9
 
8
10
  export const isPhone = () => matchMedia("(max-width:640px)").matches;
9
11
 
@@ -11,6 +13,7 @@ type Computer = { name: string; dns: string; os: string; online: boolean };
11
13
  let net: { self: Computer | null; computers: Computer[]; tailscale: boolean } = { self: null, computers: [], tailscale: false };
12
14
  let usage: any[] = [];
13
15
  let mode: "home" | "device" | null = null;
16
+ let allDevices = false;
14
17
 
15
18
  const chev = raw(`<svg class="pchev" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>`);
16
19
  const runs = () => railData().cards.filter((c) => c.kind === "run" && !c.archived);
@@ -27,6 +30,81 @@ function row(c, now: number) {
27
30
  return html`<a class="prow" href="${cardHref(c)}" data-dir="${c.state}" data-id="${rowKey(c)}"><span class="si ${stateOf(c)}"></span><span class="pmain"><b>${titleOf(c)}</b><small>${logo(c.state, name, railData().projects)}${name}</small><code>${subline(c, now)}</code></span></a>`;
28
31
  }
29
32
 
33
+ // Home's slider: one card per workspace with an agent open, those asking first.
34
+ const WORD: Record<Status, string> = { asking: "Asking", working: "Working", done: "Done" };
35
+ const DOT: Record<Status, string> = { asking: "wait", working: "build", done: "done" };
36
+ const RANK: Record<Status, number> = { asking: 0, working: 1, done: 2 };
37
+ const agentIco = (a: Agent) => {
38
+ const id = "i-" + (a.agent || "").toLowerCase();
39
+ return raw(`<svg class="pag-ico" aria-hidden="true"><use href="#${document.getElementById(id) ? id : "i-ai"}"/></svg>`);
40
+ };
41
+ const wsName = (a: Agent) => a.ws?.split(/[\\/]/).pop() || "main";
42
+ const groupKey = (a: Agent) => a.dir + "\n" + (a.ws ?? ""); // a NUL would not survive innerHTML
43
+ function agentGroups(now: number) {
44
+ const groups = new Map<string, { a: Agent; st: Status }[]>();
45
+ for (const a of (railData().agents ?? []) as Agent[]) {
46
+ const k = groupKey(a);
47
+ groups.set(k, [...(groups.get(k) ?? []), { a, st: agentStatus(a, now) }]);
48
+ }
49
+ const list = [...groups].map(([k, rows]) => ({ k, rows: rows.sort((x, y) => RANK[x.st] - RANK[y.st]) }));
50
+ return list.sort((x, y) => RANK[x.rows[0].st] - RANK[y.rows[0].st]);
51
+ }
52
+ function agentCards(now: number) {
53
+ const groups = agentGroups(now);
54
+ const asking = groups.filter((g) => g.rows[0].st === "asking").length;
55
+ const cards = groups.map(({ k, rows }) => {
56
+ const { a, st } = rows[0];
57
+ return html`<button type="button" class="pag${st === "asking" ? " ask" : ""}" data-group="${k}"><span class="pag-st"><i class="si ${DOT[st]}"></i>${rows.length > 1 ? rows.length + " agents" : WORD[st]}<span class="pag-icos">${rows.map((r) => agentIco(r.a))}</span></span><span class="pag-ws">${wsName(a)}</span><small>${projName(a.dir)}</small></button>`;
58
+ });
59
+ return html`<section class="psec2"><div class="pag-h"><h3>Agents${asking ? html`<span class="pag-n">${asking} asking</span>` : ""}</h3><button type="button" class="pag-new">New</button></div>${groups.length ? html`<div class="pslide">${cards}</div>` : html`<p class="pnote">No agents running.</p>`}</section>`;
60
+ }
61
+ function openTerm(a: Agent) {
62
+ if (dispatchEvent(new CustomEvent("kz-open-term", { cancelable: true, detail: { dir: a.dir, ws: a.ws, key: a.key } }))) location.href = wsHref(a.dir, a.ws ?? "");
63
+ }
64
+ // Several agents in a workspace: a sheet picks which terminal to open.
65
+ function pickAgent(rows: { a: Agent; st: Status }[]) {
66
+ const d = document.createElement("dialog");
67
+ d.className = "pagsheet";
68
+ d.innerHTML = String(html`<h4>${wsName(rows[0].a)}</h4>${rows.map(({ a, st }, i) => html`<button type="button" data-i="${String(i)}">${agentIco(a)}${a.name || a.agent || "Terminal"}<i class="si ${DOT[st]}"></i><small>${WORD[st]}</small></button>`)}<button type="button" data-new="1">${agentIco({ agent: "" } as Agent)}New agent</button>`);
69
+ d.addEventListener("click", (e) => {
70
+ const b = (e.target as HTMLElement).closest<HTMLButtonElement>("button");
71
+ d.close();
72
+ if (b?.dataset.new) void newSheet(rows[0].a.dir, rows[0].a.ws);
73
+ else if (b) openTerm(rows[Number(b.dataset.i)].a);
74
+ });
75
+ d.addEventListener("close", () => d.remove());
76
+ document.body.append(d);
77
+ d.showModal();
78
+ }
79
+
80
+ // New: pick a workspace, then an agent or a plain shell. It starts as a tab of that
81
+ // workspace, the same POST the workspace's own + button makes.
82
+ async function newSheet(dir?: string, ws?: string) {
83
+ const spots = (railData().projects ?? []).flatMap((p) => (p.workspaces ?? []).map((w) => ({ dir: p.dir as string, ws: w.path as string, name: w.branch || w.path.split(/[\\/]/).pop() })));
84
+ const first = agentGroups(Date.now())[0]?.rows[0].a;
85
+ const on = spots.find((x) => x.dir === (dir ?? first?.dir) && x.ws === (ws ?? first?.ws)) ?? spots[0];
86
+ if (!on) return toast("Add a project on a computer first");
87
+ const list = await fetch("/agents?dir=" + encodeURIComponent(on.dir)).then((r) => r.json(), () => null);
88
+ const kinds: { cmd: string; name: string }[] = [...(list?.agents ?? []), { cmd: "", name: "Shell" }];
89
+ const d = document.createElement("dialog");
90
+ d.className = "pagsheet";
91
+ d.innerHTML = String(html`<h4>New in</h4><select aria-label="Workspace">${spots.map((x, i) => html`<option value="${String(i)}"${raw(x === on ? " selected" : "")}>${projName(x.dir)} ${x.name}</option>`)}</select>${kinds.map((k, i) => html`<button type="button" data-i="${String(i)}">${k.cmd ? agentIco({ agent: k.cmd } as Agent) : raw(`<svg class="pag-ico" aria-hidden="true"><use href="#i-term"/></svg>`)}${k.name}</button>`)}`);
92
+ d.addEventListener("click", async (e) => {
93
+ const b = (e.target as HTMLElement).closest<HTMLButtonElement>("button");
94
+ if (e.target === d) return d.close();
95
+ if (!b) return;
96
+ const at = spots[Number(d.querySelector("select")!.value)], cmd = kinds[Number(b.dataset.i)].cmd;
97
+ d.close();
98
+ const r = await fetch("/shell", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir: at.dir, ws: at.ws, run: wsKey(at.dir, at.ws), ...(cmd ? { agent: cmd } : {}) }) }).catch(() => null);
99
+ const sh = r?.ok ? await r.json() : null;
100
+ if (sh) openTerm({ dir: at.dir, ws: at.ws, key: sh.key } as Agent);
101
+ else toast("No new terminal: " + ((await r?.json().catch(() => null))?.error || "the board did not answer"));
102
+ });
103
+ d.addEventListener("close", () => d.remove());
104
+ document.body.append(d);
105
+ d.showModal();
106
+ }
107
+
30
108
  function home() {
31
109
  const now = Date.now();
32
110
  const all = runs();
@@ -34,12 +112,15 @@ function home() {
34
112
  const waiting = all.filter((c) => stateOf(c) === "wait").length;
35
113
  const projects = new Set(all.map((c) => c.state)).size;
36
114
  const me = net.self?.name || "This computer";
37
- const others = net.computers.map(
115
+ // Two devices show, this computer first; the rest wait behind Show more.
116
+ const others = net.computers.slice(0, allDevices ? undefined : 1).map(
38
117
  (d) =>
39
118
  html`<a class="pdev" href="${d.dns ? "https://" + d.dns + "/" : "#"}" target="_blank" rel="noopener"${raw(d.dns ? "" : ' aria-disabled="true"')}><span class="pico"><svg><use href="#r-desk"/></svg></span><span class="pmain"><b>${d.name}</b><small><i class="pdot${d.online ? " on" : ""}"></i>${d.online ? "Connected" : "Disconnected"}${d.os ? " · " + d.os : ""}</small></span>${chev}</a>`,
40
119
  );
41
120
  const recent = [...all].sort((a, b) => (b.moved ?? 0) - (a.moved ?? 0)).slice(0, 12);
42
- return html`<section class="psec2"><h3>Devices</h3><a class="pdev" href="/?view=device" data-dev="here"><span class="pico"><svg><use href="#r-desk"/></svg></span><span class="pmain"><b>${me}</b><small><i class="pdot on"></i>Connected · ${projects} project${projects === 1 ? "" : "s"} · ${active.length} active${waiting ? html` · <em>${waiting} waiting</em>` : ""}</small></span>${chev}</a>${others}${net.tailscale ? "" : html`<p class="pnote">Tailscale is off on this computer: other devices do not show.</p>`}</section>
121
+ const hidden = net.computers.length - 1;
122
+ const more = hidden > 0 ? html`<button type="button" class="pmore" aria-expanded="${String(allDevices)}"><span>${allDevices ? "Show less" : `Show ${hidden} more`}</span><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg></button>` : "";
123
+ return html`${agentCards(now)}<section class="psec2"><h3>Devices</h3><a class="pdev" href="/?view=device" data-dev="here"><span class="pico"><svg><use href="#r-desk"/></svg></span><span class="pmain"><b>${me}</b><small><i class="pdot on"></i>Connected · ${projects} project${projects === 1 ? "" : "s"} · ${active.length} active${waiting ? html` · <em>${waiting} waiting</em>` : ""}</small></span>${chev}</a>${others}${more}${net.tailscale ? "" : html`<p class="pnote">Tailscale is off on this computer: other devices do not show.</p>`}</section>
43
124
  <section class="psec2"><h3>Runs</h3><div class="plist2">${recent.map((c) => row(c, now))}${recent.length ? "" : html`<p class="pnote">No runs yet.</p>`}</div></section>${usage.length ? html`<section class="psec2"><h3>Usage</h3><div class="pusage">${raw(usageChips(usage))}</div></section>` : ""}`;
44
125
  }
45
126
 
@@ -59,7 +140,10 @@ function draw() {
59
140
  const el = $("phome");
60
141
  if (!el || !mode) return;
61
142
  const keep = mode === "device" ? [...el.querySelectorAll("details")].map((d) => d.open) : [];
143
+ const slid = el.querySelector(".pslide")?.scrollLeft ?? 0;
62
144
  el.innerHTML = String(mode === "home" ? home() : device());
145
+ const slide = el.querySelector(".pslide");
146
+ if (slide) slide.scrollLeft = slid;
63
147
  el.querySelectorAll("details").forEach((d, i) => keep[i] !== undefined && (d.open = keep[i]));
64
148
  }
65
149
 
@@ -103,7 +187,16 @@ export function initPhone(go: (v: string, push?: boolean) => void, openRun: (c)
103
187
  );
104
188
  $("phome")?.addEventListener("click", (e) => {
105
189
  if ((e as MouseEvent).ctrlKey || (e as MouseEvent).metaKey) return;
106
- const a = (e.target as HTMLElement).closest<HTMLAnchorElement>("a");
190
+ const t = e.target as HTMLElement;
191
+ if (t.closest(".pag-new")) return void newSheet();
192
+ if (t.closest(".pmore")) return (allDevices = !allDevices), draw();
193
+ const group = t.closest<HTMLElement>(".pag")?.dataset.group;
194
+ if (group) {
195
+ const rows = agentGroups(Date.now()).find((g) => g.k === group)?.rows;
196
+ if (rows) rows.length > 1 ? pickAgent(rows) : openTerm(rows[0].a);
197
+ return;
198
+ }
199
+ const a = t.closest<HTMLAnchorElement>("a");
107
200
  if (!a) return;
108
201
  if (a.dataset.dev) return (e.preventDefault(), go("device", true));
109
202
  if (a.getAttribute("aria-disabled")) return e.preventDefault();
@@ -23,6 +23,7 @@ export const markView = (v) => {
23
23
  );
24
24
  // The Icebox is titled in the header, top left, like the board.
25
25
  document.querySelector(".hdr h1").textContent = v === "sources" ? "Icebox" : v === "ideas" ? "Ideas" : v === "run" ? "Run" : v === "terminal" ? "Terminal" : v === "home" ? (isPhone() ? "kaizen" : "Home") : v === "chat" ? "Chat" : v === "device" ? "Runs" : "Board";
26
+ if (v === "home" && isPhone()) document.querySelector(".hdr h1").innerHTML = '<pre class="mark" role="img" aria-label="kaizen">' + document.querySelector(".rail pre.mark").innerHTML + "</pre>";
26
27
  };
27
28
  export function go(v, push) {
28
29
  store.pageGen++;
package/web/board.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
6
- <script>if(matchMedia("(display-mode:standalone)").matches||navigator.standalone){document.querySelector("meta[name=viewport]").content+=",maximum-scale=1,user-scalable=no";addEventListener("gesturestart",e=>e.preventDefault());if(navigator.standalone){const s=()=>{document.documentElement.style.setProperty("--sh",(innerWidth>innerHeight?Math.min:Math.max)(screen.width,screen.height)+"px");scrollTo(0,0)},r=()=>{s();setTimeout(s,400)};s();addEventListener("resize",r);addEventListener("orientationchange",r)}}</script>
6
+ <script>if(matchMedia("(display-mode:standalone)").matches||navigator.standalone){document.querySelector("meta[name=viewport]").content+=",maximum-scale=1,user-scalable=no";addEventListener("gesturestart",e=>e.preventDefault());if(navigator.standalone)addEventListener("resize",()=>scrollTo(0,0))}</script>
7
7
  <title>kaizen</title>
8
8
  <link rel="manifest" href="/manifest.webmanifest">
9
9
  <meta name="theme-color" content="#f7f7f7" media="(prefers-color-scheme: light)">
@@ -30,12 +30,13 @@
30
30
  :root[data-theme=dark]{--shade:rgb(0 0 0/.45);--canvas:color-mix(in srgb,var(--bg) 70%,black)}
31
31
  body{margin:0;background:var(--canvas);color:var(--ink);font:13px/1.5 var(--font);-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;height:100vh;height:100dvh;overflow:hidden;display:flex}
32
32
  html{background:var(--canvas);touch-action:manipulation}
33
- @media(display-mode:standalone){body{position:fixed;inset:0;height:auto;overscroll-behavior:none;touch-action:pan-x pan-y;-webkit-text-size-adjust:100%}}
34
- /* iOS 26 stops a fixed inset:0 body short of the screen bottom on phones, and 100lvh can miss it too: an iPhone app takes the height of the screen itself (--sh, set in the head) */
35
- @media(display-mode:standalone) and (max-width:640px){body{bottom:auto;height:var(--sh,100lvh)}}
33
+ /* the window, not the screen: a height taken from the screen can run past what iOS shows and crop the tab bar */
34
+ @media(display-mode:standalone){html{overflow:hidden;overscroll-behavior:none}body{position:fixed;inset:0 0 auto;height:100dvh;overscroll-behavior:none;touch-action:pan-x pan-y;-webkit-text-size-adjust:100%}}
36
35
  @media(max-width:640px),(display-mode:standalone){body{padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}}
37
36
  /* iOS 26 blurs the page under the status bar unless a fixed bar touches the top edge: give it one in the page colour */
38
37
  @media(display-mode:standalone){body::before{content:"";position:fixed;top:0;left:0;right:0;height:env(safe-area-inset-top);background:inherit;z-index:100;pointer-events:none}}
38
+ /* the same at the bottom edge, in the tab bar colour; the root matches it so no band shows if iOS stops the window short. The header sits under the status bar inset, so it drops its own top gap */
39
+ @media(display-mode:standalone) and (max-width:640px){html:root{background:var(--bg-2)}body::after{content:"";position:fixed;left:0;right:0;bottom:0;height:env(safe-area-inset-bottom);background:var(--bg-2);z-index:1;pointer-events:none}body .hdr,body aside.docked>header{padding-top:10px}}
39
40
  button,input,select{font:inherit;color:inherit;background:none;border:0;padding:0}
40
41
  button{cursor:pointer}
41
42
  :focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@@ -162,12 +163,20 @@ html body.runv .app{grid-template-rows:auto minmax(0,1fr)}html body.runv .hdr{di
162
163
  html body.runv #rtabs{padding:0 10px 6px}html body.runv .app{margin:0!important}
163
164
  .srow{grid-template-columns:minmax(0,1fr) auto}.srow select.sel{max-width:52vw}
164
165
  body.phomev .hdr>:not(h1):not(#newtop),body.phomev #board{display:none!important}
166
+ body.phomev:not(.pdevv) #newtop{display:none!important}
165
167
  body.phomev #phome{display:block;flex:1;min-height:0;overflow:auto;padding:4px 16px 24px;animation:fi .2s}
166
168
  }
167
169
  #phome h3{margin:18px 4px 8px;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--dim)}
168
170
  #phome .psec2:first-child h3{margin-top:6px}
169
171
  .pdev{display:flex;align-items:center;gap:12px;margin-bottom:8px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--bg-2);color:var(--ink);text-decoration:none}
170
172
  .pdev[aria-disabled]{opacity:.6}
173
+ .pslide{display:grid;grid-auto-flow:column;grid-template-rows:repeat(2,auto);grid-auto-columns:min(44vw,164px);gap:8px;overflow-x:auto;scroll-snap-type:x proximity;scroll-padding:0 16px;margin:0 -16px;padding:0 16px 4px;scrollbar-width:none;overscroll-behavior-x:contain}.pslide::-webkit-scrollbar{display:none}
174
+ .pag{all:unset;box-sizing:border-box;cursor:pointer;scroll-snap-align:start;display:flex;flex-direction:column;gap:6px;min-width:0;min-height:92px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--bg-2);color:var(--ink);transition:border-color .15s}.pag:active{border-color:var(--ink)}.pag:focus-visible,.pmore:focus-visible{outline:2px solid var(--accent)}.pag.ask{border-color:var(--warn)}
175
+ .pag-st{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:600}.pag-icos{display:flex;gap:4px;margin-left:auto}.pag-ico{width:16px;height:16px;flex:none}.pag-ws{font:12px var(--mono);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pag small{font-size:12px;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pag-n{float:right;text-transform:none;letter-spacing:0}
176
+ .pmore{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;justify-content:space-between;width:100%;min-height:48px;margin-bottom:8px;padding:0 12px;border:1px solid var(--line);border-radius:12px;background:var(--bg-2);font-size:15px;color:var(--ink);transition:background .15s}.pmore:active{background:var(--hover)}.pmore svg{width:18px;height:18px;fill:none;stroke:var(--dim);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transition:transform .2s}.pmore[aria-expanded=true] svg{transform:rotate(180deg)}
177
+ .pag-h{display:flex;align-items:center;justify-content:space-between;gap:8px}.pag-h h3{flex:1}.pag-new{all:unset;cursor:pointer;display:flex;align-items:center;min-height:44px;padding:0 4px 0 12px;font-size:14px;font-weight:600;color:var(--ink)}.pag-new:focus-visible{outline:2px solid var(--accent)}.pagsheet select{width:100%;min-height:44px;margin-bottom:8px;font:inherit;color:var(--ink);background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:0 8px}
178
+ .pagsheet{position:fixed;inset:auto 0 0;width:100%;max-width:none;margin:0;padding:12px 16px calc(20px + env(safe-area-inset-bottom));border:0;border-top:1px solid var(--line);border-radius:16px 16px 0 0;background:var(--bg-2);color:var(--ink)}.pagsheet::backdrop{background:rgb(0 0 0/.45)}.pagsheet h4{margin:0 0 8px;font:13px var(--mono)}.pagsheet button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:8px;width:100%;min-height:48px;border-top:1px solid var(--line);font-size:14px}.pagsheet small{margin-left:auto;font-size:12px;color:var(--dim)}
179
+ @media(prefers-reduced-motion:reduce){.pmore svg{transition:none}}
171
180
  .pico{width:36px;height:36px;display:grid;place-items:center;flex:none;border-radius:9px;background:var(--hover);color:var(--dim)}.pico svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8}
172
181
  .pmain{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
173
182
  .pmain b{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@@ -394,6 +403,7 @@ dialog.onb{border:1px solid var(--line);padding:0;background:var(--bg);color:var
394
403
  dialog.onb[open]{display:flex;flex-direction:column;padding:26px 32px 18px}
395
404
  dialog.onb::backdrop,dialog.onb-ask::backdrop{background:rgb(0 0 0/.55);backdrop-filter:blur(2px)}
396
405
  .onb pre.mark{font-size:6px}
406
+ .hdr h1 pre.mark{font-size:7px}
397
407
  .onb-prog{display:flex;align-items:center;gap:6px;margin:22px 0 0;font-size:var(--fs-s);color:var(--dim)}
398
408
  .onb-prog button{width:32px;height:3px;padding:0;border-radius:2px;background:var(--line);transition:background .2s,width .2s}
399
409
  .onb-prog button.was{background:color-mix(in srgb,var(--ink) 40%,var(--line))}