kaizen-agent 1.79.1 → 1.81.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/hermes.ts +20 -0
- package/cli/install.ts +20 -1
- package/cli/localsend.ts +61 -4
- package/cli/report.ts +7 -4
- package/cli/settings.ts +2 -8
- package/cli/state.ts +19 -3
- package/cli/task-results.ts +133 -0
- package/cli/task-service.ts +179 -0
- package/cli/tasks.ts +201 -0
- package/cli/ui-audit.allow.json +6 -0
- package/cli/ui-audit.ts +427 -0
- package/cli/web.ts +72 -1
- package/cli/whatsapp.ts +112 -0
- package/package.json +2 -1
- package/skills/kaizen/SKILL.md +4 -0
- package/skills/kaizen/adapters.md +4 -0
- package/skills/kaizen/spec-build.md +5 -1
- package/skills/kaizen/spec-main.md +4 -0
- package/skills/kaizen/spec-plan.md +4 -0
- package/skills/kaizen/spec-review.md +4 -0
- package/skills/kaizen/spec.md +52 -0
- package/web/board/add-project.ts +1 -1
- package/web/board/badge.ts +70 -8
- package/web/board/cards.ts +12 -4
- package/web/board/dom.ts +10 -0
- package/web/board/icebox.ts +2 -2
- package/web/board/keys.ts +1 -1
- package/web/board/live.ts +9 -5
- package/web/board/phone.ts +4 -3
- package/web/board/rich.ts +4 -2
- package/web/board/run-view.ts +16 -14
- package/web/board/settings-automations.ts +2 -2
- package/web/board/settings-skills.ts +2 -2
- package/web/board/settings.ts +12 -14
- package/web/board/task-page.ts +590 -0
- package/web/board/task-results.ts +232 -0
- package/web/board/tasks.ts +216 -200
- package/web/board/terms.ts +17 -2
- package/web/board/views.ts +35 -9
- package/web/board/whatsapp-setup.ts +137 -0
- package/web/board/workspace.ts +25 -2
- package/web/board/zoom.ts +90 -0
- package/web/board.html +139 -40
- package/web/board.js +355 -141
- package/web/notebook.js +367 -153
- package/web/notes.html +16 -11
- package/web/term.js +1 -1
- package/web/video.html +22 -11
- package/web/video.js +401 -187
- package/web/video.ts +5 -5
- package/web/board/new-agent.ts +0 -20
package/web/board/tasks.ts
CHANGED
|
@@ -1,226 +1,242 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// signal it came from (its `idea` text or `run` id); one typed by hand is "Manual".
|
|
4
|
-
// The data is the rail's (workspace.ts): no fetch of its own.
|
|
1
|
+
// An attention-first list of durable tasks. Legacy entries are adapted by the server
|
|
2
|
+
// and acquire their stable identity on open, so identical titles stay separate.
|
|
5
3
|
import { store } from "./store.ts";
|
|
6
|
-
import { $, html, ico, pageOf, pager, pagerHtml,
|
|
7
|
-
import { age
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { openWorkspace } from "./run-view.ts";
|
|
12
|
-
import { open } from "./panel.ts";
|
|
13
|
-
import { refreshBoardBadge } from "./badge.ts";
|
|
14
|
-
import { cardHref, drawSources, logo, railData, srcIcon, stateOf, titleOf } from "./workspace.ts";
|
|
4
|
+
import { $, html, ico, pageOf, pager, pagerHtml, wirePager } from "./dom.ts";
|
|
5
|
+
import { age } from "./labels.ts";
|
|
6
|
+
import { setTaskAttention } from "./badge.ts";
|
|
7
|
+
import { newTask } from "./cards.ts";
|
|
8
|
+
import { openTaskRecord, taskStatus, type TaskView } from "./task-page.ts";
|
|
15
9
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
10
|
+
export const TASK_FILTERS = [
|
|
11
|
+
["all", "All"],
|
|
12
|
+
["needs-you", "Needs you"],
|
|
13
|
+
["in-progress", "In progress"],
|
|
14
|
+
["completed", "Completed"],
|
|
15
|
+
] as const;
|
|
16
|
+
export function filteredTasks(tasks: TaskView[], filter = "all", query = "", dir = "") {
|
|
17
|
+
const q = query.trim().toLocaleLowerCase();
|
|
18
|
+
const rank = { "needs-you": 0, "in-progress": 1, completed: 2 };
|
|
19
|
+
return tasks
|
|
20
|
+
.filter(
|
|
21
|
+
(t) =>
|
|
22
|
+
(!dir || t.dir === dir) &&
|
|
23
|
+
(filter === "all" || t.attention.category === filter) &&
|
|
24
|
+
(!q ||
|
|
25
|
+
[t.title, t.goal, t.projectName, t.attention.reason, t.attention.action]
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.join(" ")
|
|
28
|
+
.toLocaleLowerCase()
|
|
29
|
+
.includes(q)),
|
|
30
|
+
)
|
|
31
|
+
.sort(
|
|
32
|
+
(a, b) =>
|
|
33
|
+
rank[a.attention.category] - rank[b.attention.category] ||
|
|
34
|
+
Number(new Date(b.updatedAt ?? 0)) - Number(new Date(a.updatedAt ?? 0)) ||
|
|
35
|
+
a.id.localeCompare(b.id),
|
|
36
|
+
);
|
|
40
37
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
let items: TaskView[] = [],
|
|
39
|
+
filter = "all",
|
|
40
|
+
sel = 0,
|
|
41
|
+
shown: TaskView[] = [],
|
|
42
|
+
loading = false,
|
|
43
|
+
again = false;
|
|
44
|
+
let sequence = 0,
|
|
45
|
+
loaded = false,
|
|
46
|
+
error = "",
|
|
47
|
+
active = false;
|
|
48
|
+
const pg = pager("tasks");
|
|
48
49
|
let docked: [Comment, HTMLElement][] = [];
|
|
49
50
|
function dock() {
|
|
50
|
-
if (!$("tk-bar"))
|
|
51
|
+
if (!$("tk-bar"))
|
|
52
|
+
$("tasksv").innerHTML = String(
|
|
53
|
+
html`<div class="tk-bar" id="tk-bar">
|
|
54
|
+
<div class="tk-row"><label class="tk-q" id="tk-q">${ico("search")}</label><span id="tk-tools"></span></div>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="tk-list" id="tk-list"></div>`,
|
|
57
|
+
);
|
|
51
58
|
if (docked.length) return;
|
|
52
|
-
for (const [id, to] of [
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
for (const [id, to] of [
|
|
60
|
+
["bq", "tk-q"],
|
|
61
|
+
["hx", "tk-tools"],
|
|
62
|
+
["newtop", "tk-tools"],
|
|
63
|
+
]) {
|
|
64
|
+
const el = $(id);
|
|
65
|
+
if (!el) continue;
|
|
66
|
+
const mark = new Comment();
|
|
55
67
|
el.before(mark);
|
|
56
68
|
docked.push([mark, el]);
|
|
57
69
|
$(to).append(el);
|
|
58
70
|
}
|
|
71
|
+
$("hx").innerHTML = String(
|
|
72
|
+
html`<button class="ib" id="tasks-refresh" title="Refresh tasks" aria-label="Refresh tasks">
|
|
73
|
+
${ico("refresh")}
|
|
74
|
+
</button><details class="ice-filt" id="tk-filt"><summary class="ib" id="tk-filt-sum" aria-label="Filter tasks" title="Filter tasks">${ico("filter")}</summary><div class="ice-fpop"><div class="ice-chips" id="tk-chips" role="group" aria-label="Task filters"></div></div></details>`,
|
|
75
|
+
);
|
|
76
|
+
$("tasks-refresh").onclick = () => void refreshTasks();
|
|
59
77
|
}
|
|
60
78
|
function undock() {
|
|
61
79
|
docked.forEach(([mark, el]) => mark.replaceWith(el));
|
|
62
80
|
docked = [];
|
|
63
81
|
}
|
|
82
|
+
export async function refreshTasks() {
|
|
83
|
+
if (!active) return;
|
|
84
|
+
if (loading) {
|
|
85
|
+
again = true;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
loading = true;
|
|
89
|
+
do {
|
|
90
|
+
again = false;
|
|
91
|
+
const gen = ++sequence;
|
|
92
|
+
try {
|
|
93
|
+
const r = await fetch("/tasks?all=1"),
|
|
94
|
+
body = await r.json();
|
|
95
|
+
if (gen !== sequence || !active) continue;
|
|
96
|
+
if (!r.ok) throw new Error(body.why || body.error || "Tasks could not be loaded");
|
|
97
|
+
items = body.tasks ?? [];
|
|
98
|
+
loaded = true;
|
|
99
|
+
error = "";
|
|
100
|
+
setTaskAttention(items);
|
|
101
|
+
dispatchEvent(new CustomEvent("kz-task-list", { detail: items }));
|
|
102
|
+
draw();
|
|
103
|
+
} catch (e) {
|
|
104
|
+
if (active) {
|
|
105
|
+
error = e instanceof Error ? e.message : "Tasks could not be loaded";
|
|
106
|
+
draw();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} while (again);
|
|
110
|
+
loading = false;
|
|
111
|
+
}
|
|
64
112
|
function draw() {
|
|
65
|
-
const box = $("tasksv");
|
|
66
113
|
if (!document.body.classList.contains("taskv")) return;
|
|
67
114
|
dock();
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
if (f.src !== "all" && !present.includes(f.src)) f.src = "all";
|
|
74
|
-
const dirs = [...new Set(cards.map((c) => c.state))];
|
|
75
|
-
// "Showing": the same projects-shown set as the Board and the Icebox (store.shown).
|
|
76
|
-
const shownDirs = dirs.filter((d) => store.shown.has(d));
|
|
77
|
-
// The Board's header is the Tasks header too (as on the Icebox): its project picker, its
|
|
78
|
-
// Showing list and its search box drive this table.
|
|
79
|
-
const proj = store.all ? "" : store.S?.dir ?? "";
|
|
80
|
-
const q = (($("bq") as HTMLInputElement | null)?.value ?? "").trim().toLowerCase();
|
|
81
|
-
const fin = (c) => c.status === "done" || c.status === "abandoned";
|
|
82
|
-
const matched = cards
|
|
83
|
-
.filter((c) => f.src === "all" || src.get(c) === f.src)
|
|
84
|
-
.filter((c) => (proj ? c.state === proj : !shownDirs.length || shownDirs.includes(c.state)))
|
|
85
|
-
// Open: tasks not started yet and runs in flight. Running: runs in flight only. Done: finished runs.
|
|
86
|
-
.filter((c) => (f.show === "done" ? fin(c) : f.show === "running" ? c.kind === "run" && !fin(c) : !fin(c)))
|
|
87
|
-
.filter((c) => !q || (titleOf(c) + " " + nameOf(c.state, projects)).toLowerCase().includes(q))
|
|
88
|
-
// On Open, tasks above runs or runs above tasks, as chosen; newest first within each.
|
|
89
|
-
.sort((a, b) => (f.show === "open" ? (a.kind === b.kind ? 0 : (a.kind === "idea") === (f.sort === "ideas") ? -1 : 1) : 0) || (b.moved ?? b.added ?? 0) - (a.moved ?? a.added ?? 0));
|
|
115
|
+
if ($("tk-list").contains(document.activeElement) && document.activeElement !== document.body) return;
|
|
116
|
+
const q = $("bq").value || "",
|
|
117
|
+
dir = !store.all ? (store.S.dir ?? "") : "";
|
|
118
|
+
const scoped = items.filter((t) => !dir || t.dir === dir);
|
|
119
|
+
const matched = filteredTasks(scoped, filter, q);
|
|
90
120
|
const rows = pageOf(pg, matched);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const srcName = (u) => (u === "all" ? "All sources" : u === "" ? "Manual" : known.get(u) ? srcLabel(known.get(u)) : srcLabel({ url: u }));
|
|
94
|
-
const srcMark = (u) => (u === "all" ? raw('<svg><use href="#r-bulb"/></svg>') : u === "" ? ico("pen") : srcIcon(known.get(u) ?? { url: u }));
|
|
95
|
-
const srcList = ["all", ...present.filter(Boolean), ...(present.includes("") ? [""] : [])];
|
|
96
|
-
// A pop-up picker: a button that opens a short list.
|
|
97
|
-
const pop = (id, label, rows) => html`<details class="combo ipop" id="${id}"><summary class="sel">${label}</summary><div class="menu-pop pick-list">${rows}</div></details>`;
|
|
98
|
-
const ck = raw('<svg class="ck"><use href="#i-check"/></svg>');
|
|
99
|
-
const sources = pop(
|
|
100
|
-
"ideas-src",
|
|
101
|
-
html`${srcMark(f.src)}<span>${srcName(f.src)}</span>`,
|
|
102
|
-
html`${srcList.map((u) => html`<button type="button" role="menuitemradio" data-src="${u}" aria-checked="${String(f.src === u)}">${srcMark(u)}<span>${srcName(u)}</span>${ck}</button>`)}`,
|
|
103
|
-
);
|
|
104
|
-
// Tasks' own filters, placed in the shared header after its search box.
|
|
105
|
-
const sortPop =
|
|
106
|
-
f.show === "open"
|
|
107
|
-
? pop(
|
|
108
|
-
"ideas-sort",
|
|
109
|
-
html`<span>${f.sort === "ideas" ? "Tasks first" : "Running first"}</span>`,
|
|
110
|
-
html`${[["ideas", "Tasks first"], ["runs", "Running first"]].map(([v, l]) => html`<button type="button" role="menuitemradio" data-sort="${v}" aria-checked="${String(f.sort === v)}"><span>${l}</span>${ck}</button>`)}`,
|
|
111
|
-
)
|
|
112
|
-
: "";
|
|
113
|
-
// Scope and filters first; search, refresh and New task sit at the right (CSS order).
|
|
114
|
-
const chips = html`${seg("open", "Open")}${seg("running", "Running")}${seg("done", "Done")}`;
|
|
115
|
-
const extra = html`${sources}${sortPop}<button class="ib" id="ideas-ref" title="Refresh" aria-label="Refresh">${ico("refresh")}</button>`;
|
|
116
|
-
const table = !rows.length ? html`<div class="tk-empty">${raw('<svg><use href="#r-bulb"/></svg>')}<p>Nothing matches.</p><span>Try a different search or filter.</span></div>` : html`<table class="itable"><thead><tr><th></th><th>Title / context</th><th>Status</th><th>Updated</th><th></th></tr></thead><tbody>${rows.map((c, i) => {
|
|
117
|
-
const name = nameOf(c.state, projects),
|
|
118
|
-
st = stateOf(c),
|
|
119
|
-
agent = (c.tags ?? []).find((t) => AGENTS.includes(t));
|
|
120
|
-
return html`<tr><td>${logo(c.state, name, projects)}</td><td><b>${titleOf(c)}</b><div class="ctx">${name}${agent ? html`<span class="tag">${NAMES[agent]}</span>` : ""}</div></td><td><span class="stc"><span class="si ${st}"></span>${WORDS[st]}</span></td><td class="d">${c.moved || c.added ? age(c.moved || c.added, now) + " ago" : ""}</td><td><div class="acts">${asking === key(c) ? html`<span class="q">Delete?</span><button class="btn ghost" data-keep="1">Keep</button><button class="btn danger" data-yes="${i}">Delete</button>` : html`${c.kind === "idea" ? html`<button class="del" data-i="${i}" title="Delete task" aria-label="Delete task">${ico("trash")}</button>` : ""}<button class="go" data-i="${i}">${c.kind === "idea" ? "Start" : "Open"} ${ico("arrow")}</button>`}</div></td></tr>`;
|
|
121
|
-
})}</tbody></table>`;
|
|
122
|
-
const hx = $("hx");
|
|
123
|
-
// Not while a pop-up in it is open: redrawing would close it under the pointer.
|
|
124
|
-
if (!hx.querySelector("details[open]")) hx.innerHTML = String(extra);
|
|
125
|
-
$("tk-chips").innerHTML = String(chips);
|
|
126
|
-
$("tk-list").innerHTML = String(html`${table}${pagerHtml(pg)}`);
|
|
127
|
-
wirePager(pg, () => ((sel = 0), draw()));
|
|
128
|
-
|
|
129
|
-
hx.querySelectorAll<HTMLElement>("[data-src]").forEach((b) => (b.onclick = () => ((f.src = b.dataset.src!), (hx.innerHTML = ""), draw())));
|
|
130
|
-
hx.querySelectorAll<HTMLElement>("[data-sort]").forEach(
|
|
131
|
-
(b) =>
|
|
132
|
-
(b.onclick = () => {
|
|
133
|
-
f.sort = b.dataset.sort!;
|
|
134
|
-
try {
|
|
135
|
-
localStorage.setItem("kz-ideas-sort", f.sort);
|
|
136
|
-
} catch {}
|
|
137
|
-
hx.innerHTML = "";
|
|
138
|
-
draw();
|
|
139
|
-
}),
|
|
121
|
+
$("tk-chips").innerHTML = String(
|
|
122
|
+
html`${TASK_FILTERS.map(([id, label]) => html`<button type="button" class="ice-chip${filter === id ? " on" : ""}" data-task-filter="${id}" aria-pressed="${String(filter === id)}">${label}<i>${id === "all" ? scoped.length : scoped.filter((t) => t.attention.category === id).length}</i></button>`)}`,
|
|
140
123
|
);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
124
|
+
$("tk-filt-sum").classList.toggle("on", filter !== "all");
|
|
125
|
+
const empty = error
|
|
126
|
+
? html`<p>${error}</p>
|
|
127
|
+
<button class="btn" type="button" id="tasks-retry">Try again</button>`
|
|
128
|
+
: !loaded
|
|
129
|
+
? html`<p role="status">Loading tasks…</p>`
|
|
130
|
+
: scoped.length
|
|
131
|
+
? html`<p>No tasks match</p>
|
|
132
|
+
<span>Try another search or show all tasks.</span
|
|
133
|
+
><button class="btn" type="button" id="tasks-reset">Clear search and filters</button>`
|
|
134
|
+
: html`<p>What would you like to make?</p>
|
|
135
|
+
<span>Describe a goal. Keep the decisions, results and later changes together.</span
|
|
136
|
+
><button class="btn pri" type="button" id="tasks-first">New task</button>`;
|
|
137
|
+
const list = rows.length
|
|
138
|
+
? html`<div class="tp-task-list" aria-label="Tasks">
|
|
139
|
+
${rows.map(
|
|
140
|
+
(t, i) =>
|
|
141
|
+
html`<button type="button" class="tp-task-row${sel === i ? " kb" : ""}" data-task-row="${String(i)}">
|
|
142
|
+
<span class="si ${t.attention.category === "needs-you" ? "wait" : t.attention.category === "completed" ? "done" : "idle"}"></span><span class="tp-task-main"
|
|
143
|
+
><strong>${t.title}</strong
|
|
144
|
+
><small
|
|
145
|
+
>${
|
|
146
|
+
t.projectName ||
|
|
147
|
+
(t.dir
|
|
148
|
+
? t.dir
|
|
149
|
+
.replace(/[\\/]\.kaizen$/, "")
|
|
150
|
+
.split(/[\\/]/)
|
|
151
|
+
.pop()
|
|
152
|
+
: "Project needed")
|
|
153
|
+
}${t.currentResultId ? " · Result available" : ""}</small
|
|
154
|
+
></span
|
|
155
|
+
><span class="tp-task-attention ${t.attention.category}"
|
|
156
|
+
><span>${taskStatus(t)}</span><small>${t.attention.action}</small></span
|
|
157
|
+
><span class="tp-task-age"
|
|
158
|
+
>${t.updatedAt ? age(Number(new Date(t.updatedAt)), Date.now()) + " ago" : ""}</span
|
|
159
|
+
>
|
|
160
|
+
</button>`,
|
|
161
|
+
)}
|
|
162
|
+
</div>`
|
|
163
|
+
: html`<div class="tk-empty">${ico("plus")}${empty}</div>`;
|
|
164
|
+
// List changes never replace a focused row during a background state tick.
|
|
165
|
+
if (!$("tk-list").contains(document.activeElement) || document.activeElement === document.body)
|
|
166
|
+
$("tk-list").innerHTML = String(html`${list}${pagerHtml(pg)}`);
|
|
167
|
+
wirePager(pg, () => {
|
|
168
|
+
sel = 0;
|
|
169
|
+
draw();
|
|
170
|
+
});
|
|
171
|
+
$("tasksv")
|
|
172
|
+
.querySelectorAll<HTMLElement>("[data-task-filter]")
|
|
173
|
+
.forEach(
|
|
174
|
+
(b) =>
|
|
175
|
+
(b.onclick = () => {
|
|
176
|
+
filter = b.dataset.taskFilter!;
|
|
177
|
+
$("tk-filt").removeAttribute("open");
|
|
178
|
+
sel = 0;
|
|
179
|
+
pg.at = 0;
|
|
180
|
+
draw();
|
|
181
|
+
}),
|
|
182
|
+
);
|
|
183
|
+
$("tasksv")
|
|
184
|
+
.querySelectorAll<HTMLElement>("[data-task-row]")
|
|
185
|
+
.forEach((b) => (b.onclick = () => void openTaskRecord(rows[Number(b.dataset.taskRow)])));
|
|
186
|
+
$("tasks-first") &&
|
|
187
|
+
($("tasks-first").onclick = () => newTask());
|
|
188
|
+
$("tasks-reset") &&
|
|
189
|
+
($("tasks-reset").onclick = () => {
|
|
190
|
+
filter = "all";
|
|
191
|
+
$("bq").value = "";
|
|
192
|
+
sel = 0;
|
|
193
|
+
draw();
|
|
194
|
+
$("bq").focus();
|
|
195
|
+
});
|
|
196
|
+
$("tasks-retry") && ($("tasks-retry").onclick = () => void refreshTasks());
|
|
197
|
+
shown = rows;
|
|
198
|
+
sel = Math.max(0, Math.min(sel, shown.length - 1));
|
|
153
199
|
}
|
|
154
|
-
|
|
155
|
-
// Start: the run form in a popup (agent pick, then go), then the run workspace. Open: the card.
|
|
156
|
-
// Cards of a project this board is not showing go through the board's deep link.
|
|
157
|
-
function act(c) {
|
|
158
|
-
const here = store.S.cards.find((x) => key(x) === key(c));
|
|
159
|
-
if (!here) {
|
|
160
|
-
location.href = c.kind === "run" ? cardHref(c) + "&all=1" : `/?all=1&dir=${encodeURIComponent(c.state)}&idea=${encodeURIComponent(c.text)}`;
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (c.kind === "run") return openWorkspace(here);
|
|
164
|
-
runPopup(here);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// A task is deleted as the board's card menu does it, not recorded anywhere.
|
|
168
|
-
let asking: string | null = null;
|
|
169
|
-
async function del(c) {
|
|
170
|
-
asking = null;
|
|
171
|
-
const r = await post("/inbox", { op: "delete", dir: c.state, text: c.text });
|
|
172
|
-
if (r.ok) toast("Deleted");
|
|
173
|
-
load();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// A row's own click: the card's detail panel over this page. Another project's card goes
|
|
177
|
-
// through the board's deep link, which opens the same panel there.
|
|
178
|
-
function detail(c) {
|
|
179
|
-
const here = store.S.cards.find((x) => key(x) === key(c));
|
|
180
|
-
if (here) return open(here);
|
|
181
|
-
const e = encodeURIComponent;
|
|
182
|
-
location.href = `/?all=1&dir=${e(c.state)}&${c.kind === "run" ? "run=" + e(c.id) : "idea=" + e(c.text)}`;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function mark() {
|
|
186
|
-
const trs = [...document.querySelectorAll<HTMLElement>("#tasksv tbody tr")];
|
|
187
|
-
trs.forEach((tr, i) => tr.classList.toggle("kb", i === sel));
|
|
188
|
-
trs[sel]?.scrollIntoView({ block: "nearest" });
|
|
189
|
-
}
|
|
190
|
-
addEventListener("keydown", (e) => {
|
|
191
|
-
if (!document.body.classList.contains("taskv") || !shownRows.length) return;
|
|
192
|
-
const t = e.target as HTMLElement;
|
|
193
|
-
// From the search box, or anywhere on the page that is not another field or a menu.
|
|
194
|
-
if (t.id !== "bq" && (t.closest("input,textarea,select,[contenteditable],details,dialog") || t.isContentEditable)) return;
|
|
195
|
-
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
196
|
-
e.preventDefault();
|
|
197
|
-
sel = Math.max(0, Math.min(shownRows.length - 1, sel + (e.key === "ArrowDown" ? 1 : -1)));
|
|
198
|
-
mark();
|
|
199
|
-
} else if (e.key === "Enter" && !e.isComposing) {
|
|
200
|
-
e.preventDefault();
|
|
201
|
-
act(shownRows[sel]);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
200
|
export function openTasks() {
|
|
201
|
+
active = true;
|
|
205
202
|
$("bq").placeholder = "Search tasks (press /)";
|
|
206
|
-
addEventListener(
|
|
207
|
-
|
|
203
|
+
addEventListener(
|
|
204
|
+
"kz-view",
|
|
205
|
+
() => {
|
|
206
|
+
active = false;
|
|
207
|
+
sequence++;
|
|
208
|
+
undock();
|
|
209
|
+
$("bq").placeholder = "Filter cards (press /)";
|
|
210
|
+
},
|
|
211
|
+
{ once: true },
|
|
212
|
+
);
|
|
208
213
|
draw();
|
|
214
|
+
void refreshTasks();
|
|
209
215
|
}
|
|
210
|
-
export function initTasks(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
addEventListener("
|
|
215
|
-
$("bq")?.addEventListener("input", () =>
|
|
216
|
-
|
|
216
|
+
export function initTasks(_goTo) {
|
|
217
|
+
addEventListener("kz-state", () => {
|
|
218
|
+
if (active) void refreshTasks();
|
|
219
|
+
});
|
|
220
|
+
$("tasksv")?.addEventListener("focusout", () => setTimeout(draw, 0));
|
|
221
|
+
$("bq")?.addEventListener("input", () => {
|
|
222
|
+
sel = 0;
|
|
223
|
+
pg.at = 0;
|
|
224
|
+
draw();
|
|
225
|
+
});
|
|
226
|
+
addEventListener("keydown", (e) => {
|
|
227
|
+
if (!active || !shown.length || e.defaultPrevented) return;
|
|
228
|
+
const t = e.target as HTMLElement;
|
|
229
|
+
if (t.id !== "bq" && t.closest("input,textarea,select,[contenteditable],details,dialog")) return;
|
|
230
|
+
if (["ArrowDown", "ArrowUp"].includes(e.key)) {
|
|
231
|
+
e.preventDefault();
|
|
232
|
+
sel = Math.max(0, Math.min(shown.length - 1, sel + (e.key === "ArrowDown" ? 1 : -1)));
|
|
233
|
+
$("tasksv")
|
|
234
|
+
.querySelectorAll<HTMLElement>("[data-task-row]")
|
|
235
|
+
.forEach((b, i) => b.classList.toggle("kb", i === sel));
|
|
236
|
+
$("tasksv").querySelector(`[data-task-row="${sel}"]`)?.scrollIntoView({ block: "nearest" });
|
|
237
|
+
} else if (e.key === "Enter" && t.id === "bq" && !e.isComposing) {
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
void openTaskRecord(shown[sel]);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
217
242
|
}
|
|
218
|
-
|
|
219
|
-
// A click outside the Tasks header's pop-ups closes them.
|
|
220
|
-
addEventListener(
|
|
221
|
-
"pointerdown",
|
|
222
|
-
(e) => {
|
|
223
|
-
if (!(e.target as Element).closest?.("details.ipop")) document.querySelectorAll<HTMLDetailsElement>("details.ipop[open]").forEach((d) => (d.open = false));
|
|
224
|
-
},
|
|
225
|
-
true,
|
|
226
|
-
);
|
package/web/board/terms.ts
CHANGED
|
@@ -147,11 +147,26 @@ export function openTerms() {
|
|
|
147
147
|
const hid = [...all.keys()].filter((k) => lay.hidden.includes(k) && all.get(k).pty.alive);
|
|
148
148
|
// The layout switch sits at the right of the page header.
|
|
149
149
|
$("tmodes").innerHTML = html`${MODES.map(([v, l, i]) => html`<button data-mode="${v}" class="${lay.mode === v ? "on" : ""}" aria-pressed="${String(lay.mode === v)}" title="${l}" aria-label="${l}">${ico(i)}</button>`)}`.s;
|
|
150
|
-
bar!.innerHTML = html`${hid.length ? html`<span class="dim">Hidden</span>${hid.map((k) => html`<button class="chip" data-show="${k}" title="Show this terminal">${ico("plus")}${nameOf(all.get(k))} - ${projOf(all.get(k))}</button>`)}` : ""}${phone.matches && keys.length
|
|
150
|
+
bar!.innerHTML = html`${hid.length ? html`<span class="dim">Hidden</span>${hid.map((k) => html`<button class="chip" data-show="${k}" title="Show this terminal">${ico("plus")}${nameOf(all.get(k))} - ${projOf(all.get(k))}</button>`)}` : ""}${phone.matches && keys.length ? html`<span class="ttabs" role="group" aria-label="Terminals">${keys.map((k) => html`<button class="${k === one ? "on" : ""}" data-pick="${k}" aria-pressed="${String(k === one)}"><span class="tdot ${tst(all.get(k))}"></span><span>${nameOf(all.get(k))} - ${projOf(all.get(k))}</span><i class="tx" data-close="${k}" title="Close terminal">×</i></button>`)}</span>` : ""}`.s;
|
|
151
151
|
termsBadge();
|
|
152
152
|
bar!.querySelectorAll<HTMLElement>("[data-pick]").forEach(
|
|
153
153
|
(b) =>
|
|
154
|
-
(b.onclick = () => {
|
|
154
|
+
(b.onclick = (e) => {
|
|
155
|
+
const close = (e.target as HTMLElement).closest<HTMLElement>("[data-close]");
|
|
156
|
+
if (close) {
|
|
157
|
+
e.stopPropagation();
|
|
158
|
+
const ck = close.dataset.close!;
|
|
159
|
+
const c = all.get(ck);
|
|
160
|
+
const off = tst(c) === "ended";
|
|
161
|
+
if (off) {
|
|
162
|
+
lay.hidden.push(ck);
|
|
163
|
+
save();
|
|
164
|
+
openTerms();
|
|
165
|
+
} else if (confirm("End this agent session? A run can be resumed from its tile or card.")) {
|
|
166
|
+
post("/pty/exit", { key: ck }).then(() => load(true));
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
155
170
|
pick = b.dataset.pick!;
|
|
156
171
|
openTerms();
|
|
157
172
|
}),
|
package/web/board/views.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { openSettings } from "./settings.ts";
|
|
|
6
6
|
import { openTerms, termsStop } from "./terms.ts";
|
|
7
7
|
import { openHome } from "./home.ts";
|
|
8
8
|
import { initTasks, openTasks } from "./tasks.ts";
|
|
9
|
+
import { initTaskPage, openTaskPage } from "./task-page.ts";
|
|
9
10
|
import { initRunView, openWorkspace, runStop, showRunView } from "./run-view.ts";
|
|
10
11
|
import { initPhone, isPhone, openPhone } from "./phone.ts";
|
|
11
12
|
|
|
@@ -13,18 +14,41 @@ import { initPhone, isPhone, openPhone } from "./phone.ts";
|
|
|
13
14
|
export let view = "board";
|
|
14
15
|
let boardBack = false;
|
|
15
16
|
// The board's own area, not the docked panel.
|
|
16
|
-
const AREA = ["board", "terminal", "home", "tasks", "run", "chat", "device"];
|
|
17
|
+
const AREA = ["board", "terminal", "home", "tasks", "task", "run", "chat", "device"];
|
|
17
18
|
export const markView = (v) => {
|
|
18
19
|
// A phone's run workspace belongs to its Runs tab.
|
|
19
|
-
const lit = v === "run" && isPhone() ? "device" : v;
|
|
20
|
+
const lit = v === "task" ? (isPhone() ? "device" : "tasks") : v === "run" && isPhone() ? "device" : v;
|
|
20
21
|
document
|
|
21
22
|
.querySelectorAll(".rail a[data-view]")
|
|
22
23
|
.forEach((a) =>
|
|
23
24
|
a.dataset.view === lit ? a.setAttribute("aria-current", "page") : a.removeAttribute("aria-current"),
|
|
24
25
|
);
|
|
25
26
|
// The Icebox is titled in the header, top left, like the board.
|
|
26
|
-
document.querySelector(".hdr h1").textContent =
|
|
27
|
-
|
|
27
|
+
document.querySelector(".hdr h1").textContent =
|
|
28
|
+
v === "sources"
|
|
29
|
+
? "Icebox"
|
|
30
|
+
: v === "tasks"
|
|
31
|
+
? "Tasks"
|
|
32
|
+
: v === "task"
|
|
33
|
+
? "Task"
|
|
34
|
+
: v === "run"
|
|
35
|
+
? "Run"
|
|
36
|
+
: v === "terminal"
|
|
37
|
+
? "Terminal"
|
|
38
|
+
: v === "home"
|
|
39
|
+
? isPhone()
|
|
40
|
+
? "kaizen"
|
|
41
|
+
: "Home"
|
|
42
|
+
: v === "chat"
|
|
43
|
+
? "Chat"
|
|
44
|
+
: v === "device"
|
|
45
|
+
? "Runs"
|
|
46
|
+
: "Board";
|
|
47
|
+
if (v === "home" && isPhone())
|
|
48
|
+
document.querySelector(".hdr h1").innerHTML =
|
|
49
|
+
'<pre class="mark" role="img" aria-label="kaizen">' +
|
|
50
|
+
document.querySelector(".rail pre.mark").innerHTML +
|
|
51
|
+
"</pre>";
|
|
28
52
|
};
|
|
29
53
|
export function go(v, push) {
|
|
30
54
|
store.pageGen++;
|
|
@@ -33,10 +57,9 @@ export function go(v, push) {
|
|
|
33
57
|
if (v === "icebox") v = "sources";
|
|
34
58
|
// A workspace address shows in the run view, which resolves it to a card.
|
|
35
59
|
if (v === "ws") v = "run";
|
|
36
|
-
if (!["settings", "sources", "terminal", "board", "tasks", "run", "chat", "device"].includes(v)) v = "home";
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
if (isPhone() ? ["board", "tasks"].includes(v) : v === "chat" || v === "device") v = "home";
|
|
60
|
+
if (!["settings", "sources", "terminal", "board", "tasks", "task", "run", "chat", "device"].includes(v)) v = "home";
|
|
61
|
+
// Phone keeps Runs and Tasks reachable; the desktop board and chat remain desktop views.
|
|
62
|
+
if (isPhone() ? ["board", "sources"].includes(v) : v === "chat" || v === "device") v = "home";
|
|
40
63
|
const was = view;
|
|
41
64
|
view = v;
|
|
42
65
|
markView(v);
|
|
@@ -49,6 +72,7 @@ export function go(v, push) {
|
|
|
49
72
|
document.body.classList.toggle("phomev", ph || v === "device");
|
|
50
73
|
document.body.classList.toggle("pdevv", v === "device");
|
|
51
74
|
document.body.classList.toggle("taskv", v === "tasks");
|
|
75
|
+
document.body.classList.toggle("taskpagev", v === "task");
|
|
52
76
|
document.body.classList.toggle("runv", v === "run");
|
|
53
77
|
// Leaving a workspace: its panel closes as the board's would, its terminals unmount.
|
|
54
78
|
if (was === "run" && v !== "run") {
|
|
@@ -58,7 +82,7 @@ export function go(v, push) {
|
|
|
58
82
|
view = v;
|
|
59
83
|
}
|
|
60
84
|
// The workspace's address names its card: openWorkspace() pushes it.
|
|
61
|
-
if (push && v !== was && v !== "run")
|
|
85
|
+
if (push && v !== was && v !== "run" && v !== "task")
|
|
62
86
|
history.pushState(null, "", v === "home" ? location.pathname : "?view=" + (v === "sources" ? "icebox" : v));
|
|
63
87
|
dispatchEvent(new Event("kz-view"));
|
|
64
88
|
const p = $("panel");
|
|
@@ -67,6 +91,7 @@ export function go(v, push) {
|
|
|
67
91
|
if ((v === "home" && !ph) || v === "chat") openHome();
|
|
68
92
|
openPhone(ph ? "home" : v === "device" ? "device" : null);
|
|
69
93
|
if (v === "tasks") openTasks();
|
|
94
|
+
if (v === "task") openTaskPage();
|
|
70
95
|
// After the panel handling below, which closes the board's panel on the way in.
|
|
71
96
|
if (v === "run") queueMicrotask(() => void showRunView(true));
|
|
72
97
|
// The Terminal page is the board's own area, not the docked panel: the panel closes as on the board.
|
|
@@ -101,6 +126,7 @@ export function initViews() {
|
|
|
101
126
|
$("phone-menu").setAttribute("aria-label", on ? "Hide navigation menu" : "Show navigation menu");
|
|
102
127
|
};
|
|
103
128
|
initTasks(go);
|
|
129
|
+
initTaskPage(go);
|
|
104
130
|
initRunView();
|
|
105
131
|
initPhone(go, openWorkspace);
|
|
106
132
|
document.querySelectorAll(".rail a[data-view]").forEach((a) => {
|