kaizen-agent 1.60.1 → 1.60.2

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.
@@ -24,7 +24,7 @@ const TABS = [
24
24
  ["Backlog", "backlog"],
25
25
  ["Work", "impl"],
26
26
  ["Review", "review"],
27
- ["Git", "git"],
27
+ ["Source control", "git"],
28
28
  ["Preview", "preview"],
29
29
  ];
30
30
  // keepTab: a link already chose the tab.
@@ -121,19 +121,29 @@ function steps(c) {
121
121
  STEPS.map((n, i) => `<span class="${i < at ? "ok" : i === at ? "now" : ""}"><i></i>${n}</span>`).join(""),
122
122
  )}</span>`;
123
123
  }
124
- // The run workspace's header, as in its mockup: project · runner · agent · mode, then
125
- // five bars (request, plan, build, review, done): done green, the current one amber.
124
+ // The run workspace's header: the project beside the picker (runner, agent, mode in its
125
+ // tooltip), then the stage the run is in as one word and a bar that slides to it.
126
+ let lastAt = { id: "", w: 0 };
126
127
  function meta(c) {
127
128
  let st: any = {};
128
129
  try {
129
130
  st = JSON.parse(store.runDoc?.state || "{}");
130
131
  } catch {}
131
132
  const proj = String(c.where || "").split(/[\\/]/).filter(Boolean).pop() || "";
132
- const parts = [proj, st.runner, st.agent, st.mode].filter(Boolean);
133
- const at = c.status === "done" ? 5 : Math.max(1, c.column || 1);
134
- return html`<div class="rmeta">${parts.join(" · ")}</div><div class="rbars" title="${cap(WORD[c.status] || c.status)}">${raw(
135
- [0, 1, 2, 3, 4].map((i) => `<i class="${i < at ? "ok" : i === at ? "now" : ""}"></i>`).join(""),
136
- )}</div>`;
133
+ const at = c.status === "done" ? 3 : Math.min(3, Math.max(0, (c.column || 1) - 1)),
134
+ word = STEPS[at] + (c.status === "waiting" ? ", needs you" : c.status === "stalled" ? ", stalled" : ""),
135
+ w = c.status === "done" ? 100 : ((at + 0.5) / 4) * 100;
136
+ const from = lastAt.id === c.id ? lastAt.w : 0;
137
+ lastAt = { id: c.id, w };
138
+ if (from !== w)
139
+ requestAnimationFrame(() => {
140
+ const i = $("psub").querySelector(".rprog i") as HTMLElement;
141
+ if (!i) return;
142
+ i.style.width = from + "%";
143
+ i.offsetWidth;
144
+ i.style.width = w + "%";
145
+ });
146
+ return html`<div class="rmeta" title="${[st.runner, st.agent, st.mode].filter(Boolean).join(", ")}">${proj}</div><div class="rprog s-${c.status}" title="${cap(WORD[c.status] || c.status) + (c.awaiting ? `: ${need(c.awaiting)}` : "")}"><span>${word}</span><b><i style="width:${w}%"></i></b></div>`;
137
147
  }
138
148
  // An idea's panel: its terminal while the run it started is being born there, else its notes.
139
149
  export function ideaBody(c) {
@@ -236,9 +246,9 @@ export async function openRun(c, refresh, again) {
236
246
  const foot = $("pfoot");
237
247
  // A refresh while the commit is being confirmed would wipe the message.
238
248
  if (refresh && foot.querySelector(".inl,[data-busy],.more[open]")) return;
239
- // Git work left on a finished run: the footer points at the Git tab, which holds it.
249
+ // Git work left on a finished run: the footer points at the Source control tab, which holds it.
240
250
  const arch =
241
- (k !== "git" && gitPending(c) ? `<button class="btn" data-a="gittab">Git…</button>` : "") +
251
+ (k !== "git" && gitPending(c) ? `<button class="btn" data-a="gittab">Source control</button>` : "") +
242
252
  (c.archived
243
253
  ? `<button class="btn pri" data-a="restore">Restore</button>`
244
254
  : `<button class="btn ghost" data-a="archive">Archive</button>`);
@@ -254,21 +264,21 @@ export async function openRun(c, refresh, again) {
254
264
  else if ((c.status === "waiting" || c.awaiting === "findings") && APPROVAL[c.awaiting]) {
255
265
  const sent = decided.has(answer(c)),
256
266
  asks = !pq
257
- ? " It has open questions the board cannot show: answer them in the terminal running this run, or approve and your agent asks them."
267
+ ? " Has questions: answer in its terminal."
258
268
  : qs.length
259
- ? ` Approve first asks you ${qs.length === 1 ? "its question" : "its " + qs.length + " questions"}.`
269
+ ? ` ${qs.length === 1 ? "1 question" : qs.length + " questions"}.`
260
270
  : "";
261
271
  const more =
262
272
  `<button data-a="archive">Archive</button><hr><button data-a="ab" class="danger">Abandon</button>`;
263
273
  foot.innerHTML = html`<span class="note">${sent ? "Sent to your agent." : APPROVAL[c.awaiting] + asks}</span><details class="more"><summary class="btn ghost">More</summary><div class="menu-pop">${raw(more)}</div></details>${raw(rs)}<span class="dec"><button class="btn" data-a="revise"${sent ? " disabled" : ""}>Revise</button><button class="btn pri" data-a="approve"${sent ? " disabled" : ""}>${c.awaiting === "findings" ? "Approve as-is" : "Approve"}</button></span>`;
264
274
  } else if (c.status === "waiting")
265
- foot.innerHTML = html`<span class="note">Waiting on you: ${need(c.awaiting)}. Answer in the ${c.pty && c.pty.alive ? "terminal (button at the top)" : "terminal running this run"}.</span>${raw(arch)}<button class="btn ghost" data-a="ab">Abandon</button>${raw(rs)}`;
275
+ foot.innerHTML = html`<span class="note">Waiting: ${need(c.awaiting)}.</span>${raw(arch)}<button class="btn ghost" data-a="ab">Abandon</button>${raw(rs)}`;
266
276
  else if (c.status === "done" && c.accept === "needs")
267
277
  foot.innerHTML = html`<span class="note">Done, not approved: its agent finished without your approval. Nothing is committed until you approve.</span>${raw(arch + rs)}<button class="btn pri" data-a="accept">Approve</button>`;
268
278
  else if (c.status === "done") foot.innerHTML = raw(arch + rs);
269
279
  else if (c.status === "abandoned") foot.innerHTML = raw(arch);
270
280
  else
271
- foot.innerHTML = html`<span class="note">${c.pty && !c.pty.alive ? "Its agent ended before the stage finished. Resume continues it here." : c.status === "stalled" ? "No progress for a while. Resume it, or abandon it." : c.pty ? "" : "Running in your agent."}</span>${raw(arch)}<button class="btn ghost" data-a="ab">Abandon run</button>${resumable(c) ? html`<button class="btn pri" data-a="resume">Resume</button>` : ""}`;
281
+ foot.innerHTML = html`<span class="note">${c.pty && !c.pty.alive ? "Agent ended early." : c.status === "stalled" ? "Stalled." : ""}</span>${raw(arch)}<button class="btn ghost" data-a="ab">Abandon</button>${resumable(c) ? html`<button class="btn pri" data-a="resume">Resume</button>` : ""}`;
272
282
  foot.querySelectorAll("[data-a]").forEach(
273
283
  (b) =>
274
284
  (b.onclick = () => {
@@ -108,7 +108,7 @@ function tabs(): Tab[] {
108
108
  // Each live run's terminals: its stage terminals ("Build · Claude"), other sessions, shells, the waiting note.
109
109
  for (const c of live) {
110
110
  const k = key(c),
111
- runAgent = AGENTS.find((a) => c.tags?.includes(a)) ?? undefined;
111
+ runAgent = AGENTS.find((a) => a === c.pty?.agent) ?? AGENTS.find((a) => c.tags?.includes(a)) ?? undefined;
112
112
  for (const t of stageTabs(c, named(runAgent))) out.push({ id: "agent:" + t.key, kind: "agent", agent: runAgent, title: t.title, key: t.key });
113
113
  for (const sh of shells.filter((x) => x.run === k)) out.push({ id: "sh:" + sh.key, kind: sh.agent ? "agent" : "shell", agent: sh.agent || undefined, title: sh.title, key: sh.key });
114
114
  // The run's own session is running in another terminal: a tab that says so.
@@ -198,7 +198,10 @@ export async function showRunView(nav = false) {
198
198
  // session is not open anywhere on the board is resumed here, once per visit.
199
199
  if (!noPty) {
200
200
  if (!tabs().length && !autoShell.has(k)) return void (autoShell.add(k), newPty());
201
- if (want && want.kind === "run" && !finished(want) && !want.pty && !shells.some((x) => x.run === key(want)) && !autoShell.has(key(want))) {
201
+ // Not while a launch from the board is coming up: its terminal is not tied to the new run card yet, and
202
+ // resuming the run here would open a second agent on the same session beside it (the stray "Agent" tab).
203
+ const launching = !!store.wantPty && Date.now() - store.wantPty.at < 20_000;
204
+ if (want && want.kind === "run" && !finished(want) && !want.pty && !launching && !shells.some((x) => x.run === key(want)) && !autoShell.has(key(want))) {
202
205
  autoShell.add(key(want));
203
206
  void openAgent(want, false, false);
204
207
  }
@@ -208,8 +211,13 @@ export async function showRunView(nav = false) {
208
211
  // The terminal the sidebar asked for, selected once the workspace's tabs are known.
209
212
  let wantTerm: string | null = null;
210
213
  function showTerm() {
211
- const t = wantTerm && tabs().find((x) => x.key === wantTerm);
214
+ // A launch from the board names its terminal (store.wantPty): it is selected once its tab exists,
215
+ // and the ask lapses after a while so a launch that never came up cannot pull focus later.
216
+ const w = store.wantPty && Date.now() - store.wantPty.at < 20_000 ? store.wantPty.key : null;
217
+ if (store.wantPty && !w) store.wantPty = null;
218
+ const t = tabs().find((x) => x.key === (wantTerm || w));
212
219
  wantTerm = null;
220
+ if (t && store.wantPty?.key === t.key) store.wantPty = null;
213
221
  return !!t && (show(t.id), true);
214
222
  }
215
223
  const autoShell = new Set<string>();
@@ -593,7 +601,15 @@ async function closeTab(id: string) {
593
601
  if (id.startsWith("sh:")) {
594
602
  await post("/pty/exit", { key: id.slice(3) });
595
603
  shells = shells.filter((x) => "sh:" + x.key !== id);
596
- } else if (id.startsWith("agent:")) s.hidden.push(id);
604
+ } else if (id.startsWith("agent:")) {
605
+ // Closing the tab ends the agent, so the sidebar stops listing it; one mid-turn asks first.
606
+ const k = id.slice(6),
607
+ a = store.S.agents?.find((x) => x.key === k);
608
+ if (a?.busy && !confirm("This agent is still working. End it?")) return;
609
+ s.hidden.push(id);
610
+ await post("/pty/exit", { key: k });
611
+ load(true);
612
+ }
597
613
  else if (id.startsWith("wait:")) elsewhere.delete(id.slice(5));
598
614
  else s.tabs = s.tabs.filter((t) => t.id !== id);
599
615
  save();
@@ -821,6 +837,52 @@ async function autoBrowse() {
821
837
  }
822
838
  }
823
839
 
840
+ // A phone's run sheet: drag it down from anywhere its content is at the top, or tap outside it.
841
+ function initSheet() {
842
+ const p = $("panel"),
843
+ b = document.body;
844
+ const on = () => isPhone() && b.classList.contains("runv") && b.classList.contains("rflip");
845
+ const shut = () => $("pclose").click();
846
+ let y0: number | null = null,
847
+ t0 = 0,
848
+ dy = 0;
849
+ const scrolled = (t: EventTarget | null) => ((t as Element).closest?.(".body")?.scrollTop ?? 0) > 0;
850
+ p.addEventListener(
851
+ "touchstart",
852
+ (e) => {
853
+ y0 = on() && e.touches.length === 1 && !scrolled(e.target) ? e.touches[0].clientY : null;
854
+ t0 = Date.now();
855
+ dy = 0;
856
+ },
857
+ { passive: true },
858
+ );
859
+ p.addEventListener(
860
+ "touchmove",
861
+ (e) => {
862
+ if (y0 === null) return;
863
+ if (scrolled(e.target)) return void (y0 = null);
864
+ dy = e.touches[0].clientY - y0;
865
+ if (dy <= 0) return void (p.style.translate = "");
866
+ e.preventDefault();
867
+ p.style.transition = "none";
868
+ p.style.translate = `0 ${dy}px`;
869
+ },
870
+ { passive: false },
871
+ );
872
+ const end = () => {
873
+ if (y0 === null) return;
874
+ y0 = null;
875
+ p.style.transition = "";
876
+ if (dy > 100 || (dy > 30 && Date.now() - t0 < 250)) {
877
+ p.style.translate = "0 100%";
878
+ setTimeout(() => (shut(), (p.style.translate = "")), 180);
879
+ } else p.style.translate = "";
880
+ };
881
+ p.addEventListener("touchend", end);
882
+ p.addEventListener("touchcancel", end);
883
+ addEventListener("click", (e) => on() && !(e.target as Element).closest?.("#panel,#rside,dialog,.toast") && shut());
884
+ }
885
+
824
886
  export function initRunView() {
825
887
  // A phone's sheet closes with the panel's ×, which here hides the sheet rather than closing the card.
826
888
  document.addEventListener(
@@ -833,6 +895,7 @@ export function initRunView() {
833
895
  },
834
896
  true,
835
897
  );
898
+ initSheet();
836
899
  initPick(pickRun);
837
900
  // The sidebar's agent mark: open that workspace with the agent's terminal tab selected.
838
901
  addEventListener("kz-open-term", (e: any) => {
@@ -19,6 +19,8 @@ export const store = {
19
19
  // The Ideas column's severity menu, on its Backlog tab.
20
20
  sevMenu: false,
21
21
  wantTerm: null,
22
+ // The terminal a launch just opened (its pty key), selected in the run workspace once its tab exists.
23
+ wantPty: null as null | { key: string; at: number },
22
24
  // Live shells from GET /shells (the footer reads them): tiles on the Terminal page.
23
25
  shells: [] as { key: string; dir: string; title: string; agent: string }[],
24
26
  // The settings search survives the re-render each save does; the gear button starts it empty.
@@ -84,6 +84,73 @@ const folded: Set<string> = (() => {
84
84
  return new Set();
85
85
  }
86
86
  })();
87
+ // Pinned worktrees (dir\0ws), kept per browser.
88
+ const pins: Set<string> = (() => {
89
+ try {
90
+ return new Set(JSON.parse(localStorage.getItem("kz-ws-pins") || "[]"));
91
+ } catch {
92
+ return new Set();
93
+ }
94
+ })();
95
+ // The right-click menu on a worktree row: update, copy path, copy name, pin, delete.
96
+ function wsMenu(e: MouseEvent, a: HTMLElement) {
97
+ e.preventDefault();
98
+ document.getElementById("wsmenu")?.remove();
99
+ const dir = a.dataset.dir!, ws = a.dataset.ws!, key = dir + "\0" + ws;
100
+ const w = last.projects?.find((p) => p.dir === dir)?.workspaces?.find((x) => x.path === ws);
101
+ if (!w) return;
102
+ const name = wsLabel(w);
103
+ const say = (m: string) => {
104
+ const t = $("toast");
105
+ t.textContent = m;
106
+ t.classList.add("on");
107
+ setTimeout(() => t.classList.remove("on"), 4000);
108
+ };
109
+ const copy = (text: string) => navigator.clipboard.writeText(text).then(() => say("Copied"), () => say("Could not copy"));
110
+ const op = async (o: string) => {
111
+ say(o === "update" ? "Updating…" : "Deleting…");
112
+ const r = await fetch("/workspace", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir, ws, op: o }) }).catch(() => null);
113
+ const j = await r?.json().catch(() => ({}));
114
+ say(r?.ok ? (o === "update" ? j.out || "Updated" : "Deleted") : j?.error || j?.why || "Failed");
115
+ };
116
+ const items: [string, () => void][] = [
117
+ ...(w.main ? [] : ([["Update", () => op("update")]] as [string, () => void][])),
118
+ ["Copy path", () => copy(ws)],
119
+ ["Copy worktree name", () => copy(name)],
120
+ [pins.has(key) ? "Unpin" : "Pin", () => {
121
+ pins.has(key) ? pins.delete(key) : pins.add(key);
122
+ try {
123
+ localStorage.setItem("kz-ws-pins", JSON.stringify([...pins]));
124
+ } catch {}
125
+ drawList();
126
+ }],
127
+ ...(w.main ? [] : ([["Delete", async () => {
128
+ const dl = modal(html`<div class="gdis" style="display:flex;flex-direction:column;gap:12px">
129
+ <b>Delete worktree "${name}"?</b>
130
+ <p>Removes the folder. Refused while it has uncommitted changes. The branch stays.</p>
131
+ <div class="gpath" style="font:12px monospace;overflow-wrap:anywhere">${ws}</div>
132
+ <div class="row"><button class="btn" value="no">Cancel</button><button class="btn danger" value="yes">Delete</button></div>
133
+ </div>`);
134
+ dl.addEventListener("close", () => dl.returnValue === "yes" && op("delete"));
135
+ }]] as [string, () => void][])),
136
+ ];
137
+ const m = document.createElement("div");
138
+ m.id = "wsmenu";
139
+ m.style.cssText = `position:fixed;left:${Math.min(e.clientX, innerWidth - 190)}px;top:${Math.min(e.clientY, innerHeight - items.length * 34 - 16)}px;z-index:50;min-width:170px;padding:6px;background:var(--bg-2);border:1px solid var(--line);border-radius:var(--r);box-shadow:0 8px 24px #0004;display:flex;flex-direction:column`;
140
+ for (const [label, fn] of items) {
141
+ const b = document.createElement("button");
142
+ b.type = "button";
143
+ b.textContent = label;
144
+ b.style.cssText = "text-align:left;padding:7px 10px;font-size:13px;color:var(--ink);border-radius:var(--r-s)";
145
+ b.onmouseenter = () => (b.style.background = "var(--hover)");
146
+ b.onmouseleave = () => (b.style.background = "");
147
+ b.onclick = () => (m.remove(), fn());
148
+ m.append(b);
149
+ }
150
+ document.body.append(m);
151
+ const off = () => (m.remove(), removeEventListener("click", off), removeEventListener("keydown", off));
152
+ setTimeout(() => (addEventListener("click", off), addEventListener("keydown", off)));
153
+ }
87
154
  // Workspace cards with their agent list open (dir\0ws -> true), kept per browser.
88
155
  const wsOpen: Record<string, true> = (() => {
89
156
  try {
@@ -106,6 +173,16 @@ function fold(dir: string) {
106
173
  } catch {}
107
174
  drawList();
108
175
  }
176
+ const svg = (d: string) => `<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
177
+ const FA_OPEN = svg("M4 3l4 3 4-3M4 13l4-3 4 3");
178
+ const FA_SHUT = svg("M4 6l4-3 4 3M4 10l4 3 4-3");
179
+ const foldAll = (shut: boolean) => {
180
+ for (const d of last.projects?.map((p) => p.dir) ?? []) shut ? folded.add(d) : folded.delete(d);
181
+ try {
182
+ localStorage.setItem("kz-rail-folded", JSON.stringify([...folded]));
183
+ } catch {}
184
+ drawList();
185
+ };
109
186
  // A card's workspace row: its own (a run's worktree) when the project lists it, else the
110
187
  // main checkout's, so a run whose worktree is gone, an idea or an old run never vanishes.
111
188
  export function wsOfCard(c, projects = last.projects) {
@@ -116,6 +193,7 @@ export const wsHref = (dir, ws) => `/?view=ws&dir=${encodeURIComponent(dir)}&ws=
116
193
  export const RANK = { wait: 0, plan: 1, build: 2, review: 3, stalled: 4, idle: 5, done: 6, aband: 7 };
117
194
  export const folderOf = (w) => w.path.split(/[\\/]/).pop() || w.path;
118
195
  // A worktree's mark on line 2 of its card.
196
+ const PIN = html`<svg viewBox="0 0 24 24" aria-label="Pinned" style="width:12px;height:12px;flex:none;margin-left:4px;color:var(--accent)"><path d="M12 17v5M9 3h6l-1 6 3 3v2H7v-2l3-3z" fill="currentColor" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`;
119
197
  const WT = html`<svg viewBox="0 0 24 24" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="8" r="2"/><path d="M6 8v8M18 10c0 4-6 3-12 6"/></g></svg>`;
120
198
  let settleT: ReturnType<typeof setTimeout> | undefined;
121
199
  let drawn = "";
@@ -140,7 +218,9 @@ function drawList() {
140
218
  const rows = p.workspaces
141
219
  .map((w) => ({ w, cs: by.get(p.dir + "\0" + w.path) ?? [] }))
142
220
  // An empty workspace or one with a run going is active; one holding only finished runs is done.
143
- .filter(({ cs }) => filt[cs.length && cs.every((c) => kindOf(c) === "done") ? "done" : "active"]);
221
+ .filter(({ cs }) => filt[cs.length && cs.every((c) => kindOf(c) === "done") ? "done" : "active"])
222
+ // Pinned worktrees first (a stable sort keeps the rest in git's order).
223
+ .sort((a, b) => +pins.has(p.dir + "\0" + b.w.path) - +pins.has(p.dir + "\0" + a.w.path));
144
224
  return { p, rows, top: Math.min(9, ...rows.map((r) => top(r.cs))) };
145
225
  })
146
226
  .filter((g) => g.rows.length)
@@ -171,13 +251,17 @@ function drawList() {
171
251
  const st0 = cs.length ? stateOf([...cs].sort((a, b) => RANK[stateOf(a)] - RANK[stateOf(b)])[0]) : "";
172
252
  const st = st0 === "wait" || rows[0]?.st === "asking" ? "wait" : rows.some((r) => r.st === "working") ? "build" : st0 || (rows.length ? "done" : "");
173
253
  // The agent buttons are siblings of the link (a button inside a link is invalid).
174
- return html`<div class="wsr wsc"><a class="row ws" href="${wsHref(dir, w.path)}" data-dir="${dir}" data-ws="${w.path}" title="${w.path}"><span class="si ${st || "none"}"></span><div class="wl"><span class="l1"><b>${wsLabel(w)}</b></span><span class="l2"><span>${folderOf(w)}</span>${w.main ? "" : WT}</span></div></a>${agentsHtml(rows, now, !!wsOpen[dir + "\0" + w.path], dir, w.path)}</div>`;
254
+ return html`<div class="wsr wsc"><a class="row ws" href="${wsHref(dir, w.path)}" data-dir="${dir}" data-ws="${w.path}" title="${w.path}"><span class="si ${st || "none"}"></span><div class="wl"><span class="l1"><b>${wsLabel(w)}</b>${pins.has(dir + "\0" + w.path) ? PIN : ""}</span><span class="l2"><span>${folderOf(w)}</span>${w.main ? "" : WT}</span></div></a>${agentsHtml(rows, now, !!wsOpen[dir + "\0" + w.path], dir, w.path)}</div>`;
175
255
  })}`;
176
256
  })
177
257
  .join("") || `<div class="none">No projects</div>`;
178
258
  // The same markup is not written again: hover and focus stay, and a tick that changed nothing costs no layout.
179
259
  if (out !== drawn) box.innerHTML = drawn = out;
180
260
  markCurrent();
261
+ box.oncontextmenu = (e) => {
262
+ const a = (e.target as HTMLElement).closest<HTMLElement>("a.row.ws");
263
+ if (a) wsMenu(e, a);
264
+ };
181
265
  box.onclick = (e) => {
182
266
  const t = e.target as HTMLElement;
183
267
  const term = t.closest<HTMLElement>("[data-term]");
@@ -252,15 +336,20 @@ function drawPop(all: Set<string>) {
252
336
  const dirs = [...all];
253
337
  const shown = dirs.filter((d) => projName(d, last.projects).toLowerCase().includes(pq.toLowerCase()));
254
338
  const box = (on: boolean, attrs: string, label) => html`<label class="pfrow"><input type="checkbox" ${raw(attrs)}${on ? raw(" checked") : ""}>${label}</label>`;
339
+ const allShut = dirs.length > 0 && dirs.every((d) => folded.has(d));
255
340
  const had = document.activeElement?.id;
256
341
  p.innerHTML = String(
257
- html`${dirs.length > 6 ? html`<input class="sel" id="pfq" placeholder="Search projects…" aria-label="Search projects" value="${pq}" autocomplete="off" spellcheck="false">` : ""}${box(!filt.dirs.length, 'data-all="1"', "All projects")}${shown.map((d) => box(filt.dirs.includes(d), `data-dir="${encodeURIComponent(d)}"`, html`${logo(d, projName(d, last.projects), last.projects)}<span>${projName(d, last.projects)}</span>`))}<div class="pfh">Show</div>${(["active", "done"] as const).map((k) => box(filt[k], `data-k="${k}"`, { active: "Active runs", done: "Done (last day)" }[k]))}`,
342
+ html`${dirs.length > 6 ? html`<input class="sel" id="pfq" placeholder="Search projects…" aria-label="Search projects" value="${pq}" autocomplete="off" spellcheck="false">` : ""}<div class="pfall">${box(!filt.dirs.length, 'data-all="1"', "All projects")}<button type="button" class="pfb" data-fa="${allShut ? "0" : "1"}" title="${allShut ? "Expand all" : "Collapse all"}" aria-label="${allShut ? "Expand all projects" : "Collapse all projects"}">${raw(allShut ? FA_OPEN : FA_SHUT)}</button></div>${shown.map((d) => box(filt.dirs.includes(d), `data-dir="${encodeURIComponent(d)}"`, html`${logo(d, projName(d, last.projects), last.projects)}<span>${projName(d, last.projects)}</span>`))}<div class="pfh">Show</div>${(["active", "done"] as const).map((k) => box(filt[k], `data-k="${k}"`, { active: "Active runs", done: "Done (last day)" }[k]))}`,
258
343
  );
259
344
  if (had === "pfq") {
260
345
  const q = $("pfq") as HTMLInputElement;
261
346
  q.focus();
262
347
  q.setSelectionRange(pq.length, pq.length);
263
348
  }
349
+ p.onclick = (e) => {
350
+ const b = (e.target as HTMLElement).closest("[data-fa]") as HTMLElement | null;
351
+ if (b) foldAll(b.dataset.fa === "1");
352
+ };
264
353
  p.oninput = (e) => {
265
354
  const t = e.target as HTMLInputElement;
266
355
  if (t.id === "pfq") pq = t.value;