kaizen-agent 1.60.1 → 1.61.0
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/knowledge.ts +1 -1
- package/cli/notes.test.ts +2 -1
- package/cli/onboarding.test.ts +70 -0
- package/cli/onboarding.ts +63 -0
- package/cli/pty.test.ts +15 -1
- package/cli/pty.ts +14 -3
- package/cli/shell-agent.test.ts +23 -0
- package/cli/state.test.ts +105 -1
- package/cli/state.ts +157 -19
- package/cli/web-decide.test.ts +41 -0
- package/cli/web.ts +145 -27
- package/package.json +1 -1
- package/web/board/add-project.ts +14 -4
- package/web/board/api.ts +37 -4
- package/web/board/approvals.ts +6 -6
- package/web/board/badge.ts +6 -2
- package/web/board/cards.ts +4 -2
- package/web/board/fixes.ts +1 -1
- package/web/board/git.ts +171 -97
- package/web/board/live.ts +2 -1
- package/web/board/main.ts +2 -0
- package/web/board/onboarding.ts +223 -0
- package/web/board/panel.ts +24 -14
- package/web/board/run-view.ts +86 -7
- package/web/board/settings-pages.test.ts +19 -0
- package/web/board/settings-pages.ts +44 -0
- package/web/board/settings.ts +118 -62
- package/web/board/store.ts +4 -0
- package/web/board/update.ts +1 -1
- package/web/board/views.ts +5 -1
- package/web/board/workspace.ts +92 -3
- package/web/board/ws-name.test.ts +10 -0
- package/web/board/ws-tabs.test.ts +14 -1
- package/web/board/ws-tabs.ts +12 -1
- package/web/board.html +165 -21
- package/web/board.js +107 -104
- package/web/notebook.js +29 -24
- package/web/notebook.ts +1 -0
- package/web/notes.html +28 -10
- package/web/popup.html +2 -2
- package/web/term.js +20 -20
- package/web/term.ts +8 -3
- package/web/video.html +28 -10
- package/web/video.js +56 -51
package/web/board/panel.ts
CHANGED
|
@@ -24,7 +24,7 @@ const TABS = [
|
|
|
24
24
|
["Backlog", "backlog"],
|
|
25
25
|
["Work", "impl"],
|
|
26
26
|
["Review", "review"],
|
|
27
|
-
["
|
|
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
|
|
125
|
-
//
|
|
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
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
|
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">
|
|
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
|
-
? "
|
|
267
|
+
? " Has questions: answer in its terminal."
|
|
258
268
|
: qs.length
|
|
259
|
-
? `
|
|
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
|
|
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 ? "
|
|
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 = () => {
|
package/web/board/run-view.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { load, post } from "./api.ts";
|
|
|
19
19
|
import { attach, md, preview } from "./markdown.ts";
|
|
20
20
|
import { layout } from "./terms.ts";
|
|
21
21
|
import { cardHref, markCurrent, railData, stateOf, titleOf, wsHref, wsOfCard } from "./workspace.ts";
|
|
22
|
-
import { type Node, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
22
|
+
import { type Node, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, newRun, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
23
23
|
import { drawPick, hidePick, initPick, setOpen } from "./run-pick.ts";
|
|
24
24
|
import { age } from "./labels.ts";
|
|
25
25
|
import { go } from "./views.ts";
|
|
@@ -105,10 +105,12 @@ function tabs(): Tab[] {
|
|
|
105
105
|
const named = (a?: string) => agents.find((x) => x.cmd === a)?.name ?? "Agent";
|
|
106
106
|
const live = wsCards(),
|
|
107
107
|
liveKeys = new Set(live.map(key));
|
|
108
|
+
// A finished run's agent that is still open keeps its tab, as the sidebar keeps it.
|
|
109
|
+
const open = store.S.cards.filter((c) => c.state === ctx!.dir && wsOfCard(c) === ctx!.ws && !liveKeys.has(key(c)) && c.pty?.alive);
|
|
108
110
|
// Each live run's terminals: its stage terminals ("Build · Claude"), other sessions, shells, the waiting note.
|
|
109
|
-
for (const c of live) {
|
|
111
|
+
for (const c of [...live, ...open]) {
|
|
110
112
|
const k = key(c),
|
|
111
|
-
runAgent = AGENTS.find((a) => c.tags?.includes(a)) ?? undefined;
|
|
113
|
+
runAgent = AGENTS.find((a) => a === c.pty?.agent) ?? AGENTS.find((a) => c.tags?.includes(a)) ?? undefined;
|
|
112
114
|
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
115
|
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
116
|
// The run's own session is running in another terminal: a tab that says so.
|
|
@@ -173,6 +175,7 @@ export async function showRunView(nav = false) {
|
|
|
173
175
|
// Each workspace has its own centre: switching unmounts this one's panes (its shells keep running on the server).
|
|
174
176
|
if (fresh) (stopPanes(), (card = null), (ctx = { dir, ws, k }));
|
|
175
177
|
if (fresh && !was.has(k)) was.set(k, new Set(mineNow().filter(reviewing).map(key))); // what is already in review does not open the Browser
|
|
178
|
+
if (fresh) seenRuns.set(k, new Set(mineNow().map(key))); // what is here on arrival is not new
|
|
176
179
|
// The header titles a phone's workspace: the run, else the branch.
|
|
177
180
|
const w = railData().projects?.find((x) => x.dir === dir)?.workspaces?.find((x) => x.path === ws);
|
|
178
181
|
document.querySelector(".hdr h1")!.textContent = want ? titleOf(want) : w?.branch || ws.split(/[\\/]/).pop() || "Workspace";
|
|
@@ -198,7 +201,10 @@ export async function showRunView(nav = false) {
|
|
|
198
201
|
// session is not open anywhere on the board is resumed here, once per visit.
|
|
199
202
|
if (!noPty) {
|
|
200
203
|
if (!tabs().length && !autoShell.has(k)) return void (autoShell.add(k), newPty());
|
|
201
|
-
|
|
204
|
+
// Not while a launch from the board is coming up: its terminal is not tied to the new run card yet, and
|
|
205
|
+
// resuming the run here would open a second agent on the same session beside it (the stray "Agent" tab).
|
|
206
|
+
const launching = !!store.wantPty && Date.now() - store.wantPty.at < 20_000;
|
|
207
|
+
if (want && want.kind === "run" && !finished(want) && !want.pty && !launching && !shells.some((x) => x.run === key(want)) && !autoShell.has(key(want))) {
|
|
202
208
|
autoShell.add(key(want));
|
|
203
209
|
void openAgent(want, false, false);
|
|
204
210
|
}
|
|
@@ -208,8 +214,13 @@ export async function showRunView(nav = false) {
|
|
|
208
214
|
// The terminal the sidebar asked for, selected once the workspace's tabs are known.
|
|
209
215
|
let wantTerm: string | null = null;
|
|
210
216
|
function showTerm() {
|
|
211
|
-
|
|
217
|
+
// A launch from the board names its terminal (store.wantPty): it is selected once its tab exists,
|
|
218
|
+
// and the ask lapses after a while so a launch that never came up cannot pull focus later.
|
|
219
|
+
const w = store.wantPty && Date.now() - store.wantPty.at < 20_000 ? store.wantPty.key : null;
|
|
220
|
+
if (store.wantPty && !w) store.wantPty = null;
|
|
221
|
+
const t = tabs().find((x) => x.key === (wantTerm || w));
|
|
212
222
|
wantTerm = null;
|
|
223
|
+
if (t && store.wantPty?.key === t.key) store.wantPty = null;
|
|
213
224
|
return !!t && (show(t.id), true);
|
|
214
225
|
}
|
|
215
226
|
const autoShell = new Set<string>();
|
|
@@ -269,8 +280,19 @@ function draw() {
|
|
|
269
280
|
// The run panel (#panel) stays docked on the right of the centre and shows one run: the one picked
|
|
270
281
|
// in its header (run-pick.ts), first the run waiting on you, else the newest. A pick is sticky; a
|
|
271
282
|
// run that starts waiting later does not replace it: the picker's trigger and, with the panel
|
|
272
|
-
// collapsed, the panel button show a dot.
|
|
283
|
+
// collapsed, the panel button show a dot. Only a run created during the visit takes the pick
|
|
284
|
+
// (followNew). With no run the panel is parked.
|
|
273
285
|
const picked = new Map<string, string>();
|
|
286
|
+
// Every card seen in the workspace this visit. It only grows, so a restored run or a /state tick
|
|
287
|
+
// missing cards never reads as new.
|
|
288
|
+
const seenRuns = new Map<string, Set<string>>();
|
|
289
|
+
function followNew() {
|
|
290
|
+
const seen = ctx && seenRuns.get(ctx.k);
|
|
291
|
+
if (!seen) return;
|
|
292
|
+
const c = newRun(pickable(store.S.cards, ctx!.dir, ctx!.ws, wsOfCard), seen, key);
|
|
293
|
+
for (const m of mineNow()) seen.add(key(m));
|
|
294
|
+
if (c) picked.set(ctx!.k, key(c));
|
|
295
|
+
}
|
|
274
296
|
let pickOpen = false;
|
|
275
297
|
// Shows a run in the panel (a picker row, a History row); the centre stays as it is.
|
|
276
298
|
const pickRun = (k: string) => (picked.set(ctx!.k, k), draw()); // the sidebar count asked for the picker dropped down
|
|
@@ -593,7 +615,15 @@ async function closeTab(id: string) {
|
|
|
593
615
|
if (id.startsWith("sh:")) {
|
|
594
616
|
await post("/pty/exit", { key: id.slice(3) });
|
|
595
617
|
shells = shells.filter((x) => "sh:" + x.key !== id);
|
|
596
|
-
} else if (id.startsWith("agent:"))
|
|
618
|
+
} else if (id.startsWith("agent:")) {
|
|
619
|
+
// Closing the tab ends the agent, so the sidebar stops listing it; one mid-turn asks first.
|
|
620
|
+
const k = id.slice(6),
|
|
621
|
+
a = store.S.agents?.find((x) => x.key === k);
|
|
622
|
+
if (a?.busy && !confirm("This agent is still working. End it?")) return;
|
|
623
|
+
s.hidden.push(id);
|
|
624
|
+
await post("/pty/exit", { key: k });
|
|
625
|
+
load(true);
|
|
626
|
+
}
|
|
597
627
|
else if (id.startsWith("wait:")) elsewhere.delete(id.slice(5));
|
|
598
628
|
else s.tabs = s.tabs.filter((t) => t.id !== id);
|
|
599
629
|
save();
|
|
@@ -821,6 +851,53 @@ async function autoBrowse() {
|
|
|
821
851
|
}
|
|
822
852
|
}
|
|
823
853
|
|
|
854
|
+
// A phone's run sheet: drag it down from anywhere its content is at the top, or tap outside it.
|
|
855
|
+
function initSheet() {
|
|
856
|
+
const p = $("panel"),
|
|
857
|
+
b = document.body;
|
|
858
|
+
const on = () => isPhone() && b.classList.contains("runv") && b.classList.contains("rflip");
|
|
859
|
+
const shut = () => $("pclose").click();
|
|
860
|
+
let y0: number | null = null,
|
|
861
|
+
t0 = 0,
|
|
862
|
+
dy = 0;
|
|
863
|
+
const scrolled = (t: EventTarget | null) => ((t as Element).closest?.(".body")?.scrollTop ?? 0) > 0;
|
|
864
|
+
p.addEventListener(
|
|
865
|
+
"touchstart",
|
|
866
|
+
(e) => {
|
|
867
|
+
y0 = on() && e.touches.length === 1 && !scrolled(e.target) ? e.touches[0].clientY : null;
|
|
868
|
+
t0 = Date.now();
|
|
869
|
+
dy = 0;
|
|
870
|
+
},
|
|
871
|
+
{ passive: true },
|
|
872
|
+
);
|
|
873
|
+
p.addEventListener(
|
|
874
|
+
"touchmove",
|
|
875
|
+
(e) => {
|
|
876
|
+
if (y0 === null) return;
|
|
877
|
+
if (scrolled(e.target)) return void (y0 = null);
|
|
878
|
+
dy = e.touches[0].clientY - y0;
|
|
879
|
+
// A finger drifts a few pixels in a tap; taking those as a drag would cancel its click.
|
|
880
|
+
if (dy <= 10) return void (p.style.translate = "");
|
|
881
|
+
e.preventDefault();
|
|
882
|
+
p.style.transition = "none";
|
|
883
|
+
p.style.translate = `0 ${dy}px`;
|
|
884
|
+
},
|
|
885
|
+
{ passive: false },
|
|
886
|
+
);
|
|
887
|
+
const end = () => {
|
|
888
|
+
if (y0 === null) return;
|
|
889
|
+
y0 = null;
|
|
890
|
+
p.style.transition = "";
|
|
891
|
+
if (dy > 100 || (dy > 30 && Date.now() - t0 < 250)) {
|
|
892
|
+
p.style.translate = "0 100%";
|
|
893
|
+
setTimeout(() => (shut(), (p.style.translate = "")), 180);
|
|
894
|
+
} else p.style.translate = "";
|
|
895
|
+
};
|
|
896
|
+
p.addEventListener("touchend", end);
|
|
897
|
+
p.addEventListener("touchcancel", end);
|
|
898
|
+
addEventListener("click", (e) => on() && !(e.target as Element).closest?.("#panel,#rside,dialog,.toast") && shut());
|
|
899
|
+
}
|
|
900
|
+
|
|
824
901
|
export function initRunView() {
|
|
825
902
|
// A phone's sheet closes with the panel's ×, which here hides the sheet rather than closing the card.
|
|
826
903
|
document.addEventListener(
|
|
@@ -833,6 +910,7 @@ export function initRunView() {
|
|
|
833
910
|
},
|
|
834
911
|
true,
|
|
835
912
|
);
|
|
913
|
+
initSheet();
|
|
836
914
|
initPick(pickRun);
|
|
837
915
|
// The sidebar's agent mark: open that workspace with the agent's terminal tab selected.
|
|
838
916
|
addEventListener("kz-open-term", (e: any) => {
|
|
@@ -866,6 +944,7 @@ export function initRunView() {
|
|
|
866
944
|
// A /state change: new or ended sessions, the card's own state. Panes stay mounted.
|
|
867
945
|
addEventListener("kz-state", () => {
|
|
868
946
|
void autoBrowse();
|
|
947
|
+
followNew();
|
|
869
948
|
if (ctx && document.body.classList.contains("runv")) void showRunView();
|
|
870
949
|
});
|
|
871
950
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { placeOf, SETTINGS_NAV } from "./settings-pages.ts";
|
|
4
|
+
|
|
5
|
+
const pages = new Set(SETTINGS_NAV.flatMap(([, ps]) => ps.map((p) => p.id)));
|
|
6
|
+
const keys = [...readFileSync(new URL("../../cli/settings.ts", import.meta.url), "utf8").matchAll(/\{ key: "([\w.]+)", label:/g)].map((m) => m[1]);
|
|
7
|
+
|
|
8
|
+
test("every setting lands on a real page, under a named subsection", () => {
|
|
9
|
+
expect(keys.length).toBeGreaterThan(30);
|
|
10
|
+
for (const k of keys) {
|
|
11
|
+
const [page, sub] = placeOf(k);
|
|
12
|
+
expect(pages.has(page)).toBe(true);
|
|
13
|
+
expect([k, sub === "Other"]).toEqual([k, false]);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("a setting not placed yet falls back to General", () => {
|
|
18
|
+
expect(placeOf("new.thing")).toEqual(["general", "Other"]);
|
|
19
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Settings' sidebar, grouped as Orca's is. Only the page knows this: a setting's `group`
|
|
2
|
+
// in cli/settings.ts still decides its scope and the TUI's headings.
|
|
3
|
+
export type SettingsPage = { id: string; title: string; desc: string; ico: string };
|
|
4
|
+
export const SETTINGS_NAV: [string, SettingsPage[]][] = [
|
|
5
|
+
["AI Capabilities", [
|
|
6
|
+
{ id: "agents", title: "Agents", desc: "Which tool runs, and who does each stage.", ico: "ai" },
|
|
7
|
+
{ id: "voice", title: "Voice", desc: "Speech-to-text dictation, run in the browser.", ico: "mic" },
|
|
8
|
+
]],
|
|
9
|
+
["Set Up", [
|
|
10
|
+
{ id: "general", title: "General", desc: "Which settings you are editing, folders, and maintenance.", ico: "gear" },
|
|
11
|
+
{ id: "integrations", title: "Integrations", desc: "Request sources and your Google account.", ico: "link" },
|
|
12
|
+
{ id: "mobile", title: "Mobile", desc: "Open this board from your phone.", ico: "send" },
|
|
13
|
+
]],
|
|
14
|
+
["Workflows", [
|
|
15
|
+
{ id: "approvals", title: "Approvals", desc: "Where a run stops and waits for you.", ico: "check" },
|
|
16
|
+
{ id: "autofix", title: "Auto-fix", desc: "What happens to review findings.", ico: "bug" },
|
|
17
|
+
{ id: "git", title: "Git & Source Control", desc: "Branches and commits for each run.", ico: "pen" },
|
|
18
|
+
{ id: "terminal", title: "Terminal", desc: "The terminal dashboard.", ico: "term" },
|
|
19
|
+
]],
|
|
20
|
+
["Interface", [
|
|
21
|
+
{ id: "appearance", title: "Appearance", desc: "Theme, color and motion in this browser.", ico: "note" },
|
|
22
|
+
{ id: "notifications", title: "Notifications", desc: "Notices and sounds in this browser.", ico: "clock" },
|
|
23
|
+
{ id: "shortcuts", title: "Shortcuts", desc: "Keyboard shortcuts for common actions.", ico: "kbd" },
|
|
24
|
+
]],
|
|
25
|
+
];
|
|
26
|
+
// First match wins: [key pattern, page, subsection].
|
|
27
|
+
const PLACES: [RegExp, string, string][] = [
|
|
28
|
+
[/^preset$/, "agents", "Defaults"],
|
|
29
|
+
[/^(runner|build\.|review\.executor|agent\.|subagents\.)/, "agents", "Agents"],
|
|
30
|
+
[/^dictation\./, "voice", "Dictation"],
|
|
31
|
+
[/^sources\./, "integrations", "Request sources"],
|
|
32
|
+
[/^(mode|approvals\.|auto_accept)/, "approvals", "Approvals"],
|
|
33
|
+
[/^auto_fix\./, "autofix", "Auto-fix"],
|
|
34
|
+
[/^git\./, "git", "Git"],
|
|
35
|
+
[/^ui\./, "terminal", "Terminal"],
|
|
36
|
+
[/^board\.chat_hotkey$/, "shortcuts", "Shortcuts"],
|
|
37
|
+
[/^board\./, "general", "Board"],
|
|
38
|
+
[/^(review\.|state\.)/, "general", "Project"],
|
|
39
|
+
];
|
|
40
|
+
// A setting nobody has placed yet still shows, on General.
|
|
41
|
+
export const placeOf = (key: string): [string, string] => {
|
|
42
|
+
const p = PLACES.find(([re]) => re.test(key));
|
|
43
|
+
return p ? [p[1], p[2]] : ["general", "Other"];
|
|
44
|
+
};
|
package/web/board/settings.ts
CHANGED
|
@@ -2,22 +2,22 @@ import { store } from "./store.ts";
|
|
|
2
2
|
import { termStop } from "./agent-term.ts";
|
|
3
3
|
import { load, post } from "./api.ts";
|
|
4
4
|
import { stopDictation } from "./dictation.ts";
|
|
5
|
-
import { $, html, SKEL } from "./dom.ts";
|
|
5
|
+
import { $, html, ico, SKEL } from "./dom.ts";
|
|
6
6
|
import { close } from "./panel.ts";
|
|
7
|
+
import { placeOf, SETTINGS_NAV } from "./settings-pages.ts";
|
|
7
8
|
import { askNotify, notifyOn, playSound, soundPick, SOUNDS, toast } from "./toast.ts";
|
|
8
9
|
import { updBar } from "./update.ts";
|
|
9
|
-
import { view } from "./views.ts";
|
|
10
|
+
import { go, view } from "./views.ts";
|
|
10
11
|
|
|
11
12
|
// ---- settings
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
13
|
+
const PAGES = SETTINGS_NAV.flatMap(([, ps]) => ps);
|
|
14
|
+
const narrow = () => matchMedia("(max-width:640px)").matches;
|
|
15
|
+
// Ctrl+F searches settings, as in Orca. Only while the page shows: elsewhere it stays the browser's.
|
|
16
|
+
addEventListener("keydown", (e) => {
|
|
17
|
+
if (view !== "settings" || !(e.ctrlKey || e.metaKey) || e.key.toLowerCase() !== "f") return;
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
$("sq")?.focus();
|
|
20
|
+
});
|
|
21
21
|
export async function openSettings() {
|
|
22
22
|
if (view !== "settings") return;
|
|
23
23
|
const gen = ++store.pageGen;
|
|
@@ -38,6 +38,7 @@ export async function openSettings() {
|
|
|
38
38
|
$("ptabs").innerHTML = "";
|
|
39
39
|
$("pfoot").innerHTML = "";
|
|
40
40
|
const cur = document.documentElement.dataset.theme || "system";
|
|
41
|
+
const colour = document.documentElement.dataset.color || "monochrome";
|
|
41
42
|
let cfg = await fetch("/settings?scope=" + encodeURIComponent(store.setScope))
|
|
42
43
|
.then((r) => (r.ok ? r.json() : null))
|
|
43
44
|
.catch(() => null);
|
|
@@ -63,10 +64,11 @@ export async function openSettings() {
|
|
|
63
64
|
.map((v) => html`<button id="${id}-${v}" data-v="${v}" class="${v === on ? "on" : ""}" aria-pressed="${String(v === on)}">${v}</button>`)}</span>`;
|
|
64
65
|
if (vals.length === 2 && vals.includes("true") && vals.includes("false")) {
|
|
65
66
|
const yes = on === "true";
|
|
66
|
-
return html`<button class="chk${yes ? " on" : ""}" id="${id}" data-v="${yes ? "false" : "true"}" role="switch" aria-checked="${String(yes)}" title="${yes ? "On" : "Off"}"></button>`;
|
|
67
|
+
return html`<button class="chk sm${yes ? " on" : ""}" id="${id}" data-v="${yes ? "false" : "true"}" role="switch" aria-checked="${String(yes)}" title="${yes ? "On" : "Off"}"></button>`;
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
// Short choices sit side by side, joined, as Orca's do; a long list keeps the stepper.
|
|
70
|
+
if (vals.every((v) => /^\d+$/.test(v)) || (vals.length <= 5 && vals.every((v) => v) && vals.join("").length <= 32))
|
|
71
|
+
return html`<span class="bar" id="${id}" role="group" aria-labelledby="${id}-l">${vals.map((v) => html`<button id="${id}-${v}" data-v="${v}" class="${v === on ? "on" : ""}" aria-pressed="${String(v === on)}">${v}</button>`)}</span>`;
|
|
70
72
|
// Wired by stepper() below; the group takes its name from the row's label.
|
|
71
73
|
return html`<span class="step" id="${id}" role="group" aria-labelledby="${id}-l"><button id="${id}-prev" aria-label="Previous">‹</button><output aria-live="polite">${on === "" ? "—" : on}</output><button id="${id}-next" aria-label="Next">›</button></span>`;
|
|
72
74
|
};
|
|
@@ -87,51 +89,71 @@ export async function openSettings() {
|
|
|
87
89
|
const np = typeof Notification === "undefined" ? null : Notification.permission;
|
|
88
90
|
const nton = notifyOn();
|
|
89
91
|
const ntHelp = !nton ? "Off in this browser" : np === "granted" ? "" : np === "denied" ? "Pop-ups blocked by this browser; the sound still plays" : np ? "Pop-ups wait for the browser to ask; the sound still plays" : "Pop-ups not supported here; the sound still plays";
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
);
|
|
122
|
-
})}</div>`,
|
|
123
|
-
)
|
|
124
|
-
: html`<p class="snone">Settings could not be read. Run <code>kaizen settings</code>.</p>`
|
|
92
|
+
// Each page's subsections, in the order they first appear.
|
|
93
|
+
const pageRows = new Map<string, Map<string, unknown[]>>(PAGES.map((p) => [p.id, new Map()]));
|
|
94
|
+
const put = (page, sub, r) => {
|
|
95
|
+
const m = pageRows.get(page);
|
|
96
|
+
if (!m.has(sub)) m.set(sub, []);
|
|
97
|
+
m.get(sub).push(r);
|
|
98
|
+
};
|
|
99
|
+
if (cfg) {
|
|
100
|
+
put("general", "Scope", row(
|
|
101
|
+
"Settings for",
|
|
102
|
+
html`<select class="sel" id="s-scope">${[{ dir: "all", label: "All projects" }, ...cfg.projects].map((p) => html`<option value="${p.dir}"${p.dir === cfg.scope ? " selected" : ""}>${p.label}</option>`)}</select>`,
|
|
103
|
+
scoped ? "This project's own .kaizen/config.yml; anything it does not set comes from All projects." : "~/.kaizen/config.yml; a project's own config wins where it sets a value.",
|
|
104
|
+
"s-scope",
|
|
105
|
+
"settings for scope project all projects",
|
|
106
|
+
));
|
|
107
|
+
for (const r of cfg.rows) {
|
|
108
|
+
const id = "s-" + r.key.replace(/\./g, "-");
|
|
109
|
+
const [page, sub] = placeOf(r.key);
|
|
110
|
+
put(page, sub + (scoped && r.group === "Board" ? " · all projects" : ""), row(
|
|
111
|
+
r.label,
|
|
112
|
+
r.text
|
|
113
|
+
? r.folder
|
|
114
|
+
? html`<span class="fpick"><input class="sel" id="${id}" value="${r.value}" placeholder="not set" spellcheck="false"><button class="btn" id="${id}-pick" type="button">Browse…</button></span>`
|
|
115
|
+
: html`<input class="sel" id="${id}" value="${r.value}" placeholder="not set" spellcheck="false">`
|
|
116
|
+
: ctl(id, r.values, r.value),
|
|
117
|
+
((t, n) => (t && n ? html`${t} · ${n}` : n || t))([r.help, r.idle].filter(Boolean).join(" · "), scopeNote(r, id)),
|
|
118
|
+
id,
|
|
119
|
+
[r.label, r.help, r.key, r.group, ...r.values].join(" "),
|
|
120
|
+
!!r.idle,
|
|
121
|
+
));
|
|
122
|
+
}
|
|
125
123
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
put("mobile", "Phone", row("Phone address", cfg?.phoneUrls?.length ? html`<span class="phoneurls">${cfg.phoneUrls.map((url) => html`<a href="${url}" target="_blank" rel="noopener">${url}</a>`)}</span>` : html`<span>Not set</span>`, cfg?.phoneUrls?.length ? "Configured address; Tailscale must be running on both devices." : "Run kaizen setup on this PC to connect your phone.", "phone-url", "phone address url tailscale setup"));
|
|
125
|
+
put("integrations", "Google", row("OAuth client id", html`<input class="sel" id="gg-id" placeholder="${gg.hasClient ? "Saved. Paste a new one to replace it" : "Desktop app client id from Google Cloud"}" spellcheck="false" autocomplete="off">`, "", "gg-id", "google oauth client id sheets write back"));
|
|
126
|
+
put("integrations", "Google", row("OAuth client secret", html`<span class="fpick"><input class="sel" id="gg-secret" type="password" placeholder="${gg.hasClient ? "Saved. Paste a new one to replace it" : ""}" spellcheck="false" autocomplete="off"><button class="btn" id="gg-save" type="button">Save</button></span>`, "", "gg-secret", "google oauth client secret"));
|
|
127
|
+
put("integrations", "Google", row("Google account", html`<button class="btn${gg.connected ? "" : " pri"}" id="gg-conn" type="button"${gg.hasClient || gg.connected ? "" : " disabled"}>${gg.connected ? "Disconnect" : "Connect"}</button>`, "", "gg-conn", "google account connect sheets write back"));
|
|
128
|
+
put("appearance", "Browser", row("Theme", ctl("th", ["system", "light", "dark"], cur), "", "th", "theme light dark system browser"));
|
|
129
|
+
put("appearance", "Browser", row("Color", ctl("co", ["monochrome", "blue"], colour), "", "co", "color colour palette monochrome blue theme browser"));
|
|
130
|
+
put("appearance", "Browser", row("Motion", ctl("mo", ["system", "full", "reduce"], document.documentElement.dataset.motion || "system"), "Animations on the board and notes. System follows the device's reduce-motion setting.", "mo", "motion animation reduce reduced browser"));
|
|
131
|
+
put("notifications", "Browser", row("Notifications", html`<button class="chk sm${nton ? " on" : ""}" id="nt" role="switch" aria-checked="${String(nton)}"></button>`, ntHelp, "nt", "notifications " + ntHelp + " browser"));
|
|
132
|
+
put("notifications", "Browser", row("Notification sound", ctl("ns", SOUNDS, soundPick()), "Plays with each notice. Changing it plays it.", "ns", "notification sound audio browser " + SOUNDS.join(" "), !nton));
|
|
133
|
+
// A narrow screen starts on the list of pages, a wide one on the first page.
|
|
134
|
+
store.setPage ??= new URLSearchParams(location.search).get("page") || "";
|
|
135
|
+
const scopeName = scoped ? cfg.projects.find((p) => p.dir === cfg.scope)?.label : "";
|
|
136
|
+
// A save redraws the page: the rows stay where they were scrolled to.
|
|
137
|
+
const top = $("smain")?.scrollTop || 0;
|
|
138
|
+
$("pbody").innerHTML = html`<div class="sset" id="sset">
|
|
139
|
+
<nav class="snav" aria-label="Settings">
|
|
140
|
+
<button class="sback" id="sback" type="button">${ico("chev")}Back to app</button>
|
|
141
|
+
<div class="sq"><input class="sel" id="sq" type="search" placeholder="Search settings" aria-label="Search settings" spellcheck="false" autocomplete="off" value="${store.setQ}"></div>
|
|
142
|
+
<div class="snavs">${SETTINGS_NAV.map(([g, ps]) => html`<div class="snavg"><p>${g}</p>${ps.map((p) => html`<button type="button" data-page="${p.id}">${ico(p.ico)}<span>${p.title}</span></button>`)}</div>`)}</div>
|
|
143
|
+
</nav>
|
|
144
|
+
<div class="smain" id="smain">
|
|
145
|
+
${PAGES.map((p) => html`<div class="spage" data-page="${p.id}">
|
|
146
|
+
<button class="sup" type="button">${ico("chev")}Settings</button>
|
|
147
|
+
<header><h2>${p.title}</h2><p>${p.desc}${scopeName ? ` Editing ${scopeName}.` : ""}</p></header>
|
|
148
|
+
${p.id === "general" ? html`<div id="supd"></div>` : ""}
|
|
149
|
+
<div class="scard">${[...pageRows.get(p.id)].map(([sub, rows]) => html`<h3 class="sg">${sub}</h3><div class="sgrp">${rows}</div>`)}</div>
|
|
150
|
+
</div>`)}
|
|
151
|
+
${cfg ? "" : html`<p class="snone">Settings could not be read. Run <code>kaizen settings</code>.</p>`}
|
|
152
|
+
<p class="snone" id="snone" hidden></p>
|
|
153
|
+
</div>
|
|
154
|
+
</div>`;
|
|
155
|
+
// Hides rows that do not match, then any subsection and page left with none. The page
|
|
156
|
+
// shown is the one picked, or while searching the first that still has a match.
|
|
135
157
|
updBar();
|
|
136
158
|
const heads = [...$("pbody").querySelectorAll(".sg")];
|
|
137
159
|
const filter = () => {
|
|
@@ -148,7 +170,31 @@ export async function openSettings() {
|
|
|
148
170
|
});
|
|
149
171
|
$("snone").hidden = any;
|
|
150
172
|
$("snone").textContent = `No setting matches “${store.setQ.trim()}”.`;
|
|
173
|
+
const has = (s) => !!s.querySelector(".sg:not([hidden])");
|
|
174
|
+
const secs = [...$("pbody").querySelectorAll<HTMLElement>(".spage")];
|
|
175
|
+
const hits = secs.filter(has);
|
|
176
|
+
const picked = store.setPage && secs.find((s) => s.dataset.page === store.setPage);
|
|
177
|
+
const cur = (picked && has(picked) ? picked : null) || (q || !narrow() ? hits[0] : null);
|
|
178
|
+
secs.forEach((s) => (s.hidden = s !== cur));
|
|
179
|
+
$("sset").classList.toggle("pick", !cur);
|
|
180
|
+
$("pbody").querySelectorAll<HTMLElement>(".snavg button").forEach((b) => {
|
|
181
|
+
const on = b.dataset.page === cur?.dataset.page;
|
|
182
|
+
b.hidden = !hits.some((s) => s.dataset.page === b.dataset.page);
|
|
183
|
+
on ? b.setAttribute("aria-current", "page") : b.removeAttribute("aria-current");
|
|
184
|
+
});
|
|
185
|
+
$("pbody").querySelectorAll<HTMLElement>(".snavg").forEach((g) => (g.hidden = !g.querySelector("button:not([hidden])")));
|
|
151
186
|
};
|
|
187
|
+
// The page goes in the address, without a history step per page: Back to app leaves in one.
|
|
188
|
+
const pick = (id) => {
|
|
189
|
+
store.setPage = id;
|
|
190
|
+
history.replaceState(null, "", "?view=settings" + (id ? "&page=" + id : ""));
|
|
191
|
+
filter();
|
|
192
|
+
$("pbody").scrollTop = $("smain").scrollTop = 0;
|
|
193
|
+
};
|
|
194
|
+
$("pbody").querySelectorAll<HTMLElement>(".snavg button").forEach((b) => (b.onclick = () => pick(b.dataset.page)));
|
|
195
|
+
$("pbody").querySelectorAll<HTMLElement>(".sup").forEach((b) => (b.onclick = () => pick("")));
|
|
196
|
+
// Back where Settings was opened from; arriving by address, Home.
|
|
197
|
+
$("sback").onclick = () => (store.setBack ? history.back() : go("home", true));
|
|
152
198
|
$("sq").oninput = (e) => {
|
|
153
199
|
store.setQ = e.target.value;
|
|
154
200
|
filter();
|
|
@@ -164,6 +210,7 @@ export async function openSettings() {
|
|
|
164
210
|
} else close();
|
|
165
211
|
};
|
|
166
212
|
filter();
|
|
213
|
+
$("smain").scrollTop = top;
|
|
167
214
|
if (hadFocus) {
|
|
168
215
|
const f = $("sq");
|
|
169
216
|
f.focus();
|
|
@@ -211,10 +258,19 @@ export async function openSettings() {
|
|
|
211
258
|
// Re-rendering replaces the arrows, so the one pressed gets focus back.
|
|
212
259
|
const refocus = async (f) => {
|
|
213
260
|
await openSettings();
|
|
214
|
-
if (f && /^s
|
|
261
|
+
if (f && /^s-/.test(f)) $(f)?.focus();
|
|
262
|
+
};
|
|
263
|
+
// A browser choice drawn as joined segments applies on click; a long list steps.
|
|
264
|
+
const choice = (el, vals, on, apply) => {
|
|
265
|
+
if (el.matches(".step")) return stepper(el, vals, on, apply);
|
|
266
|
+
el.querySelectorAll("[data-v]").forEach((b) => (b.onclick = () => {
|
|
267
|
+
apply(b.dataset.v);
|
|
268
|
+
openSettings();
|
|
269
|
+
}));
|
|
215
270
|
};
|
|
216
|
-
|
|
217
|
-
|
|
271
|
+
choice($("th"), ["system", "light", "dark"], cur, setTheme);
|
|
272
|
+
choice($("co"), ["monochrome", "blue"], colour, setColor);
|
|
273
|
+
choice($("mo"), ["system", "full", "reduce"], document.documentElement.dataset.motion || "system", setMotion);
|
|
218
274
|
$("nt").onclick = () => {
|
|
219
275
|
const on = !notifyOn();
|
|
220
276
|
try {
|
|
@@ -223,7 +279,7 @@ export async function openSettings() {
|
|
|
223
279
|
if (on) askNotify();
|
|
224
280
|
setTimeout(openSettings, 300);
|
|
225
281
|
};
|
|
226
|
-
|
|
282
|
+
choice($("ns"), SOUNDS, soundPick(), (v) => {
|
|
227
283
|
try {
|
|
228
284
|
localStorage.setItem("kz-sound", v);
|
|
229
285
|
} catch (e) {}
|
package/web/board/store.ts
CHANGED
|
@@ -19,12 +19,16 @@ 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.
|
|
25
27
|
setQ: "",
|
|
26
28
|
// Settings' scope: "all" or a project's state dir. Set on opening; never moves the board.
|
|
27
29
|
setScope: "all",
|
|
30
|
+
setPage: null as string | null,
|
|
31
|
+
setBack: false,
|
|
28
32
|
// Settings and the Icebox fill the same panel after a fetch: a fill only lands if no other view
|
|
29
33
|
// or fill started since, or a slow answer paints one page under the other's title.
|
|
30
34
|
pageGen: 0,
|
package/web/board/update.ts
CHANGED
|
@@ -31,7 +31,7 @@ export function updBar() {
|
|
|
31
31
|
d.innerHTML = html`<span>kaizen <b>${upd.latest}</b> is available. You are running ${upd.version}.</span><span class="updact">${news}<button class="btn" id="upd-chk">Check for updates</button><button class="btn pri" id="upd-go">Update kaizen</button></span>`;
|
|
32
32
|
}
|
|
33
33
|
if (ver && ver.failed) d.insertAdjacentHTML("afterbegin", html`<span class="updfail" role="alert">Last update failed: ${ver.failed}</span>`);
|
|
34
|
-
$("pbody").prepend(d);
|
|
34
|
+
($("supd") || $("pbody")).prepend(d);
|
|
35
35
|
const check = $("upd-chk");
|
|
36
36
|
check.onclick = async () => {
|
|
37
37
|
check.disabled = true;
|