kaizen-agent 1.54.0 → 1.56.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/chat.ts +8 -1
- package/cli/sources.test.ts +10 -1
- package/cli/sources.ts +11 -1
- package/cli/web.ts +5 -2
- package/package.json +1 -1
- package/web/board/home.ts +2 -2
- package/web/board/icebox.ts +220 -18
- package/web/board/panel.ts +13 -4
- package/web/board.html +34 -5
- package/web/board.js +40 -40
- package/web/notebook.js +1 -1
- package/web/term.js +21 -21
- package/web/term.ts +52 -35
- package/web/video.js +1 -1
package/cli/chat.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { basename, dirname, join } from "node:path";
|
|
8
|
-
import { CHILD_ENV, readText } from "./state.ts";
|
|
8
|
+
import { CHILD_ENV, readRuns, readText } from "./state.ts";
|
|
9
9
|
|
|
10
10
|
export type Step = { kind: "cmd" | "edit" | "tool" | "project"; text: string; ok?: boolean };
|
|
11
11
|
export type Attachment = { name: string; path: string; image: boolean };
|
|
@@ -64,11 +64,18 @@ function saveUploads(base: string, id: string, uploads: Upload[]): Attachment[]
|
|
|
64
64
|
export function brief(c: Chat, board: Board) {
|
|
65
65
|
const here = board.projects.find((p) => p.dir === c.project);
|
|
66
66
|
const list = board.projects.slice(0, 80).map((p) => `- ${p.label} — ${dirname(p.dir)}`).join("\n");
|
|
67
|
+
// So "what's waiting on me?" has an answer without a project.
|
|
68
|
+
const waiting = board.projects.slice(0, 80).flatMap((p) => readRuns(p.dir)
|
|
69
|
+
.filter((r) => r.awaiting && r.stage !== "done" && r.stage !== "abandoned")
|
|
70
|
+
.map((r) => `- ${p.label}: ${r.id} (${r.stage}, waiting on ${r.awaiting})`)).join("\n");
|
|
67
71
|
return `[kaizen board context, not written by the user]
|
|
68
72
|
You are kaizen's main agent, talking with the user from the kaizen board's Home page.
|
|
69
73
|
Project of this chat: ${here ? `${here.label} (${dirname(here.dir)})` : "none — you are in a scratch folder"}.
|
|
70
74
|
Projects on the board:
|
|
71
75
|
${list || "(none)"}
|
|
76
|
+
Runs waiting on the user:
|
|
77
|
+
${waiting || "(none)"}
|
|
78
|
+
Each project's kaizen runs live in <project>/.kaizen/runs/<id>/ (state.json has stage and awaiting; 01-plan.md, 04-review.md, 06-backlog.md beside it); read them to answer questions about the board.
|
|
72
79
|
You can read, analyse and edit files in any project folder listed above directly by its path; you do not need to switch to it. Do not write outside those folders and your working folder.
|
|
73
80
|
Switching only changes this chat's home project (where you run and which project the board shows). On a line of its own write [[kaizen:project <folder>]] to switch to a listed project, or [[kaizen:new-project <name>]] to create one (a plain folder name). Switch only when the user asks; when what they want fits no listed project, ask whether to create a new one. After a successful move, the board starts one follow-up turn in the new project to finish the pending request; do not ask the user to repeat it.
|
|
74
81
|
When the user asks you to develop, fix, change or enhance something (not a question, analysis or reading), first ask which way, as numbered options, and do nothing until they pick:
|
package/cli/sources.test.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { readInbox, writeInbox, replaceIdea, parseItem } from "./state.ts";
|
|
|
8
8
|
import {
|
|
9
9
|
readSources, addSource, removeSource, ingest, checkUrl, resolvesPublic, exportUrl, fetchText, split, sift,
|
|
10
10
|
gatherSource, freshImages, gatherAll, due, takeImages, sheetImages, docImages, imagesUrl, SIGN_IN, UNREADABLE, CAP, moveSource, gatherDirs, writeSources,
|
|
11
|
-
readIcebox, writeIcebox, promote, markDone, addItem, githubRepo, dismiss, markReplied, setCategory, socialUrl, socialOf, AGENT_ONLY, PLATFORMS,
|
|
11
|
+
readIcebox, writeIcebox, promote, markDone, addItem, githubRepo, dismiss, markReplied, setCategory, setPaused, socialUrl, socialOf, AGENT_ONLY, PLATFORMS,
|
|
12
12
|
} from "./sources.ts";
|
|
13
13
|
|
|
14
14
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "kaizen-src-"))); // macOS: tmpdir is a symlink into /private
|
|
@@ -34,6 +34,15 @@ test("sources: add, list, remove; refuses a duplicate and a bad link", () => {
|
|
|
34
34
|
expect(readSources(state)).toEqual([]);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
test("setPaused: on pauses the source, off clears the flag", () => {
|
|
38
|
+
addSource(state, SHEET);
|
|
39
|
+
expect(setPaused(state, SHEET, true)).toBeNull();
|
|
40
|
+
expect(readSources(state)[0]!.paused).toBe(true);
|
|
41
|
+
expect(setPaused(state, SHEET, false)).toBeNull();
|
|
42
|
+
expect("paused" in readSources(state)[0]!).toBe(false);
|
|
43
|
+
expect(setPaused(state, "https://example.com/none", true)).toBe("no such source");
|
|
44
|
+
});
|
|
45
|
+
|
|
37
46
|
test("exportUrl: sheet, published sheet, doc, anything else", () => {
|
|
38
47
|
expect(exportUrl(SHEET)).toEqual({ url: "https://docs.google.com/spreadsheets/d/abc123/export?format=tsv&gid=7", kind: "sheet" });
|
|
39
48
|
expect(exportUrl("https://docs.google.com/spreadsheets/d/abc123/edit?gid=42").url).toEndWith("gid=42");
|
package/cli/sources.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { lookup as dnsLookup } from "node:dns/promises";
|
|
|
10
10
|
import { readInbox, writeInbox, normalise, formatNote, parseItem, readRuns, readText } from "./state.ts";
|
|
11
11
|
|
|
12
12
|
export type Last = { at: string; ok: boolean; added: number; note: string };
|
|
13
|
-
export type Source = { url: string; label?: string; category?: string; added: string; last?: Last; seen: string[]; writeback?: boolean };
|
|
13
|
+
export type Source = { url: string; label?: string; category?: string; added: string; last?: Last; seen: string[]; writeback?: boolean; paused?: boolean };
|
|
14
14
|
export type Result = { url: string } & Last;
|
|
15
15
|
|
|
16
16
|
const file = (state: string) => join(state, "sources.json");
|
|
@@ -94,6 +94,16 @@ export function setWriteback(state: string, url: string, on: boolean): string |
|
|
|
94
94
|
return null;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
// Whether the board's scheduled gather skips this source. Check now still reads it.
|
|
98
|
+
export function setPaused(state: string, url: string, on: boolean): string | null {
|
|
99
|
+
const list = readSources(state);
|
|
100
|
+
const src = list.find((s) => s.url === url);
|
|
101
|
+
if (!src) return "no such source";
|
|
102
|
+
if (on) src.paused = true; else delete src.paused;
|
|
103
|
+
writeSources(state, list);
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
97
107
|
// Drops the entry and its seen list. Items already gathered stay in the icebox.
|
|
98
108
|
export function removeSource(state: string, url: string): string | null {
|
|
99
109
|
const list = readSources(state);
|
package/cli/web.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
launchMode, readSessions, ownerOf, runIndex, resumePrompt, runAgent, firstSession, webHosts,
|
|
11
11
|
} from "./state.ts";
|
|
12
12
|
import { attachPty, writePty, resizePty, exitPty, ptyState, ptyKeys, adoptLoginEnv } from "./pty.ts";
|
|
13
|
-
import { readSources, addSource, removeSource, moveSource, setCategory, setWriteback, readIcebox, promote, dismiss, restore, addItem, githubRepo, markDone, markReplied, gatherSource, freshImages, gatherAll, gatherDirs, due, socialUrl, socialOf } from "./sources.ts";
|
|
13
|
+
import { readSources, addSource, removeSource, moveSource, setCategory, setWriteback, setPaused, readIcebox, promote, dismiss, restore, addItem, githubRepo, markDone, markReplied, gatherSource, freshImages, gatherAll, gatherDirs, due, socialUrl, socialOf } from "./sources.ts";
|
|
14
14
|
import { projectLogo, LOGO_TYPES } from "./logo.ts";
|
|
15
15
|
import * as chatgpt from "./chatgpt.ts";
|
|
16
16
|
import * as google from "./google.ts";
|
|
@@ -354,7 +354,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
354
354
|
// Social sources need a reader that picks posts: only ChatGPT can do that unattended.
|
|
355
355
|
const gpt = await setting("sources.agent") === "chatgpt" && chatgpt.status().connected;
|
|
356
356
|
for (const s of list) {
|
|
357
|
-
if (!due(s, ms, Date.now())) continue;
|
|
357
|
+
if (s.paused || !due(s, ms, Date.now())) continue;
|
|
358
358
|
if (!socialOf(s.url)) { if ((await gatherSource(dir, s.url)).added) changed(); }
|
|
359
359
|
else if (gpt) { await chatgpt.gatherSource(dir, s.url, await setting("sources.model"), (await setting("sources.effort")) || "low"); changed(); }
|
|
360
360
|
}
|
|
@@ -1191,6 +1191,9 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1191
1191
|
} else if (body.op === "writeback") {
|
|
1192
1192
|
const why = setWriteback(dir, link, body.on === true);
|
|
1193
1193
|
if (why) return bad(why, 404);
|
|
1194
|
+
} else if (body.op === "paused") {
|
|
1195
|
+
const why = setPaused(dir, link, body.on === true);
|
|
1196
|
+
if (why) return bad(why, 404);
|
|
1194
1197
|
} else if (body.op === "remove") {
|
|
1195
1198
|
const why = removeSource(dir, link);
|
|
1196
1199
|
if (why) return bad(why, 404);
|
package/package.json
CHANGED
package/web/board/home.ts
CHANGED
|
@@ -69,7 +69,7 @@ function msg(m, i) {
|
|
|
69
69
|
const runs = runsIn(m.text + " " + (m.steps || []).map((s) => s.text).join(" "));
|
|
70
70
|
// Nothing yet: the typing dots stand in for the reply.
|
|
71
71
|
if (!steps.length && !m.text && !m.error && !active) return "";
|
|
72
|
-
return html`<div class="hm a${anim}">${
|
|
72
|
+
return html`<div class="hm a${anim}">${m.text ? html`<div class="hb md">${raw(md(m.text))}</div>` : ""}${steps.length ? html`<details class="hsteps"><summary>${steps.length} step${steps.length > 1 ? "s" : ""}</summary><ul>${steps}</ul></details>` : ""}${m.error ? html`<div class="herr">${m.error}</div>` : ""}${moved.map((s) => html`<div class="hmove${s.ok === false ? " bad" : ""}">${ico("board")}${s.text}</div>`)}${runs.map((id) => html`<button class="btn ghost sm hrun" data-run="${id}">${ico("board")}Open ${id}</button>`)}${active ? html`<div class="hactivity" role="status"><span class="hmascot" aria-hidden="true"><i class="mascot"></i><i class="hlaptop"></i></span><span class="hactivity-copy"><span>${m.activity || "Thinking…"}</span><span class="hdots" aria-hidden="true"><i></i><i></i><i></i></span></span></div>` : ""}</div>`;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function hero() {
|
|
@@ -180,7 +180,7 @@ function draw() {
|
|
|
180
180
|
if (shown !== (cur && cur.id)) seen = 0;
|
|
181
181
|
if (side === null) side = sideAtStart();
|
|
182
182
|
h.classList.toggle("hopen", side);
|
|
183
|
-
h.innerHTML = String(html`<div class="hside">${list()}</div><div class="hscrim" id="hscrim"></div><div class="hmain${empty ? " hfresh" : ""}"><div class="htop"><button class="ib" id="htog" aria-label="Chats" aria-expanded="${String(side)}" title="${side ? "Hide chats" : "Show chats"}">${ico("side")}</button
|
|
183
|
+
h.innerHTML = String(html`<div class="hside">${list()}</div><div class="hscrim" id="hscrim"></div><div class="hmain${empty ? " hfresh" : ""}"><div class="htop"><button class="ib" id="htog" aria-label="Chats" aria-expanded="${String(side)}" title="${side ? "Hide chats" : "Show chats"}">${ico("side")}</button></div><div class="hlog" id="hlog" aria-live="polite">${empty ? hero() : cur.messages.map(msg)}</div><form class="hbox" id="hbox"><input id="hfile" type="file" multiple hidden><button type="button" class="ib hattach" id="hattach" aria-label="Attach files" title="Attach files">${ico("clip")}</button><div class="hinput"><div class="hatt" id="hatt"></div><textarea id="hq" rows="1" placeholder="Ask anything, or describe what to build…" aria-label="Message the agent"></textarea></div>${empty ? "" : html`<span class="hwhere" title="Project">${ico("board")}${cur.project ? name(cur.project) : "No project"}</span>`}${sendButton()}</form>${empty ? chips() : ""}</div>`);
|
|
184
184
|
seen = empty ? 0 : cur.messages.length;
|
|
185
185
|
shown = cur && cur.id;
|
|
186
186
|
$("htog").onclick = () => setSide(!side);
|
package/web/board/icebox.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { termStop } from "./agent-term.ts";
|
|
|
3
3
|
import { load, post } from "./api.ts";
|
|
4
4
|
import { via } from "./cards.ts";
|
|
5
5
|
import { mic, stopDictation } from "./dictation.ts";
|
|
6
|
-
import { $, dataUrls, html, ico, modal, raw, SKEL } from "./dom.ts";
|
|
6
|
+
import { $, dataUrls, html, ico, modal, motion, raw, SKEL } from "./dom.ts";
|
|
7
7
|
import { ideaCombo, newDir, plogo, setShown, short, showable } from "./projects.ts";
|
|
8
|
-
import { toast } from "./toast.ts";
|
|
8
|
+
import { playSound, soundPick, toast } from "./toast.ts";
|
|
9
9
|
import { go, view } from "./views.ts";
|
|
10
10
|
|
|
11
11
|
// ---- the icebox: requests gathered from request sources, read like an inbox, until
|
|
@@ -42,6 +42,13 @@ export let iceForm = null,
|
|
|
42
42
|
iceBusy = false,
|
|
43
43
|
iceNav = null;
|
|
44
44
|
const iceSel = new Set();
|
|
45
|
+
// The swipe view: one waiting request at a time, decided by drag, button or arrow key.
|
|
46
|
+
// Null when the list shows. It counts this session's decisions, keeps the last dismiss
|
|
47
|
+
// for Undo, and how often each request was skipped (skipped ones go to the back).
|
|
48
|
+
let iceSwipe = null;
|
|
49
|
+
// A rebuild while the card is held would drop the drag: it waits for the release.
|
|
50
|
+
let swHeld = false,
|
|
51
|
+
swLate = false;
|
|
45
52
|
const PLAT = { x: "X", tiktok: "TikTok", instagram: "Instagram", threads: "Threads" };
|
|
46
53
|
export const srcOpen = () => $("panel").classList.contains("open") && $("ptitle").textContent === SRC;
|
|
47
54
|
const ago = (at) => {
|
|
@@ -109,6 +116,10 @@ function wirePick(id, set) {
|
|
|
109
116
|
};
|
|
110
117
|
}
|
|
111
118
|
export async function openSources() {
|
|
119
|
+
if (swHeld) {
|
|
120
|
+
swLate = true;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
112
123
|
if (view !== "sources") return;
|
|
113
124
|
const gen = ++store.pageGen;
|
|
114
125
|
stopDictation(true);
|
|
@@ -217,7 +228,7 @@ export async function openSources() {
|
|
|
217
228
|
: html`<span class="src-badge warn"><svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" stroke="currentColor" fill="none" stroke-width="1.8"/><path d="M8 5v3.5M8 11v.1" stroke="currentColor" fill="none" stroke-width="2" stroke-linecap="round"/></svg>Failed: ${s.last.note}</span><span class="hint" style="margin:0">${ago(s.last.at)}</span>`;
|
|
218
229
|
const kind = st === "sheet" ? "sheet" : st === "doc" ? "doc" : st === "social" ? "at" : "link",
|
|
219
230
|
bare = s.url.replace(/^https?:\/\/(www\.)?/, "");
|
|
220
|
-
return html`<div class="src-card" id="src-card-${i}"><div class="src-hd"><span class="src-ico" title="${st === "social" ? (PLAT[s.social] || "social") : st}">${fav(s.url, kind, s.social)}</span><div class="src-info"><span class="src-title" title="${title}">${title}</span><a class="src-url" href="${s.url}" target="_blank" rel="noopener noreferrer" title="${s.url}"><span>${bare}</span>${ico("ext")}</a></div><div class="src-acts">${s.social ? html`<button class="ib sm" id="src-ag-${i}" data-ag="${i}" aria-label="Gather ${title} with your agent" title="${chatOn ? "Gather with your ChatGPT plan" : "Gather: opens your agent on /kaizen gather"}">${ico("refresh")}</button>` : html`<button class="ib sm" id="src-chk-${i}" data-chk="${i}" aria-label="Check ${title} now" title="Check now">${ico("refresh")}</button>`}<button class="ib sm danger" id="src-rm-${i}" data-rm="${i}" aria-label="Remove ${title}" title="Remove source">${ico("trash")}</button></div></div><div class="src-status">${statusHtml}</div><div class="src-fields"><label class="src-f" title="Category"><span>Category</span><input class="sel" id="src-ct-${i}" data-ct="${i}" data-k="${s.dir + " " + s.url}" value="${s.category || ""}" placeholder="${platOf(s)}" maxlength="40" aria-label="Category of ${title}"><button class="btn sm pri" id="src-cs-${i}" aria-label="Save the category of ${title}" disabled>Save</button></label><label class="src-f" title="Project"><span>Project</span>${plogo(s.dir, s.project || "")}<select class="sel" id="src-mv-${i}" data-mv="${i}" data-k="${s.dir + " " + s.url}" aria-label="Project of ${title}">${opts(s.dir, s.project)}</select><button class="btn sm pri" id="src-mb-${i}" aria-label="Move ${title} to the chosen project" disabled>Move</button></label>${st === "sheet" || /github\.com/.test(s.url) ? html`<label class="src-
|
|
231
|
+
return html`<div class="src-card" id="src-card-${i}"><div class="src-hd"><span class="src-ico" title="${st === "social" ? (PLAT[s.social] || "social") : st}">${fav(s.url, kind, s.social)}</span><div class="src-info"><span class="src-title" title="${title}">${title}</span><a class="src-url" href="${s.url}" target="_blank" rel="noopener noreferrer" title="${s.url}"><span>${bare}</span>${ico("ext")}</a></div><div class="src-acts">${s.social ? html`<button class="ib sm" id="src-ag-${i}" data-ag="${i}" aria-label="Gather ${title} with your agent" title="${chatOn ? "Gather with your ChatGPT plan" : "Gather: opens your agent on /kaizen gather"}">${ico("refresh")}</button>` : html`<button class="ib sm" id="src-chk-${i}" data-chk="${i}" aria-label="Check ${title} now" title="Check now">${ico("refresh")}</button>`}<button class="ib sm danger" id="src-rm-${i}" data-rm="${i}" aria-label="Remove ${title}" title="Remove source">${ico("trash")}</button></div></div><div class="src-status">${statusHtml}</div><div class="src-fields"><label class="src-f" title="Category"><span>Category</span><input class="sel" id="src-ct-${i}" data-ct="${i}" data-k="${s.dir + " " + s.url}" value="${s.category || ""}" placeholder="${platOf(s)}" maxlength="40" aria-label="Category of ${title}"><button class="btn sm pri" id="src-cs-${i}" aria-label="Save the category of ${title}" disabled>Save</button></label><label class="src-f" title="Project"><span>Project</span>${plogo(s.dir, s.project || "")}<select class="sel" id="src-mv-${i}" data-mv="${i}" data-k="${s.dir + " " + s.url}" aria-label="Project of ${title}">${opts(s.dir, s.project)}</select><button class="btn sm pri" id="src-mb-${i}" aria-label="Move ${title} to the chosen project" disabled>Move</button></label></div><div class="src-sws">${st === "sheet" || /github\.com/.test(s.url) ? html`<label class="src-sw">Write back<button class="chk sm${s.writeback ? " on" : ""}" id="src-wb-${i}" data-wb="${i}" role="switch" aria-checked="${String(!!s.writeback)}" aria-label="Write back to ${title}"></button></label>` : ""}<label class="src-sw" title="Off: the scheduled gather skips this source; Check now still reads it">Auto gather<button class="chk sm${s.paused ? "" : " on"}" id="src-ag-on-${i}" data-ag-on="${i}" role="switch" aria-checked="${String(!s.paused)}" aria-label="Auto gather ${title}"></button></label></div></div>`;
|
|
221
232
|
});
|
|
222
233
|
const fails = ((d && d.failed) || []).map((f) => html`<p style="color:var(--dim)">The sources of ${f} could not be read.</p>`);
|
|
223
234
|
const emptyState = html`<div class="src-empty"><div class="src-empty-ico">${ico("link")}</div><h4>No sources yet</h4></div>`;
|
|
@@ -279,6 +290,7 @@ export async function openSources() {
|
|
|
279
290
|
});
|
|
280
291
|
// Rows in the order they are drawn, which is the order j and k walk.
|
|
281
292
|
const order = [...groups.values()].flat();
|
|
293
|
+
const isWaiting = (it) => !["promoted", "dismissed", "done"].includes(it.status);
|
|
282
294
|
// A checked request a filter hides is unchecked: a bulk action only ever acts on what shows.
|
|
283
295
|
{
|
|
284
296
|
const vis = new Set(order.map((i) => iceKey(ice[i])));
|
|
@@ -324,7 +336,7 @@ export async function openSources() {
|
|
|
324
336
|
)}`,
|
|
325
337
|
)
|
|
326
338
|
: ""}`;
|
|
327
|
-
const bar = html`<div class="ice-bar">${order.length ? html`<input type="checkbox" id="ice-all" aria-label="Select every request shown"${nSel && nSel === order.length ? " checked" : ""}>` : ""}<span class="count">${iceCat === "Dismissed" || iceCat === "Done" ? `${order.length} ${iceCat.toLowerCase()}` : `${order.length < waiting ? `${order.length} of ${waiting}` : waiting} waiting`}</span><span class="end"></span>${String(chips) ? html`<details class="ice-filt"><summary class="ib${iceCat || iceSrc ? " on" : ""}" aria-label="Filter requests" title="Filter requests">${ico("filter")}</summary><div class="ice-fpop">${chips}</div></details>` : ""}<button class="btn ghost sm" id="ice-new" title="Add a request by hand">${ico("plus")} Add</button><button class="btn sm" id="src-go"${list.length ? "" : " disabled"}>${ico("refresh")} Gather all</button><button class="btn ghost sm" id="src-tog" aria-expanded="${String(!!srcShow)}" aria-controls="src-sec">${ico("link")} Sources · ${list.length}</button></div>`;
|
|
339
|
+
const bar = html`<div class="ice-bar">${order.length ? html`<input type="checkbox" id="ice-all" aria-label="Select every request shown"${nSel && nSel === order.length ? " checked" : ""}>` : ""}<span class="count">${iceCat === "Dismissed" || iceCat === "Done" ? `${order.length} ${iceCat.toLowerCase()}` : `${order.length < waiting ? `${order.length} of ${waiting}` : waiting} waiting`}</span><span class="end"></span>${String(chips) ? html`<details class="ice-filt"><summary class="ib${iceCat || iceSrc ? " on" : ""}" aria-label="Filter requests" title="Filter requests">${ico("filter")}</summary><div class="ice-fpop">${chips}</div></details>` : ""}${order.some((i) => isWaiting(ice[i])) ? html`<button class="btn ghost sm" id="ice-sw" title="Sort one at a time: swipe right to promote, left to dismiss"><span aria-hidden="true">⇆</span> Swipe</button>` : ""}<button class="btn ghost sm" id="ice-new" title="Add a request by hand">${ico("plus")} Add</button><button class="btn sm" id="src-go"${list.length ? "" : " disabled"}>${ico("refresh")} Gather all</button><button class="btn ghost sm" id="src-tog" aria-expanded="${String(!!srcShow)}" aria-controls="src-sec">${ico("link")} Sources · ${list.length}</button></div>`;
|
|
328
340
|
const bulk = iceSel.size
|
|
329
341
|
? html`<div class="ice-bulk" role="toolbar" aria-label="Selected requests"><span>${iceSel.size} selected</span><span class="end"></span><button class="btn sm" id="ice-bp" title="Promote (p)">${ico("plus")} Promote</button><button class="btn ghost sm" id="ice-bd" title="Dismiss (d)">${ico("x")} Dismiss</button><button class="btn ghost sm" id="ice-bc" title="Clear selection (Esc)">Clear</button></div>`
|
|
330
342
|
: "";
|
|
@@ -347,13 +359,15 @@ export async function openSources() {
|
|
|
347
359
|
if (r.wait) return html`<div class="ice-form-acts"><span class="hint">Drafting…</span></div>`;
|
|
348
360
|
return html`<div class="ice-form"><label for="ice-reply" class="hint" style="margin:0">Your reply${r.note ? ` · ${r.note}` : ""}</label><textarea class="sel" id="ice-reply" rows="3" maxlength="2000" aria-label="Your reply"${r.busy || r.again ? " disabled" : ""}>${r.text}</textarea><span class="hint" id="ice-rn" style="margin:0">${r.again ? "Writing another…" : `${r.text.length} chars`}</span><div class="ice-form-acts"><span class="end"></span>${G.connected ? html`${style(r.busy || r.again)}<button class="btn ghost sm" id="ice-rg"${r.busy || r.again ? " disabled" : ""}>Regenerate</button>` : ""}<button class="btn ghost sm" id="ice-rc"${r.busy ? " disabled" : ""}>Cancel</button><button class="btn pri sm" id="ice-rs"${r.busy || r.again || !r.text.trim() ? " disabled" : ""}>${r.busy ? "Sending…" : "Send reply"}</button></div></div>`;
|
|
349
361
|
};
|
|
362
|
+
const imgs = (it) =>
|
|
363
|
+
(it.images || []).filter((u) => /^https:\/\//.test(u)).length ? html`<details class="ice-imgs"><summary>Show images (${it.images.filter((u) => /^https:\/\//.test(u)).length}) — loads them from the source's site</summary>${it.images.filter((u) => /^https:\/\//.test(u)).map((u, n) => { const src = `/ice-image?dir=${encodeURIComponent(it.dir)}&id=${encodeURIComponent(it.id)}&i=${n}`; return html`<a href="${src}" target="_blank" rel="noopener noreferrer"><img data-src="${src}" alt="" referrerpolicy="no-referrer"></a>`; })}</details>` : "";
|
|
350
364
|
const row = (i) => {
|
|
351
365
|
const it = ice[i],
|
|
352
366
|
k = iceKey(it),
|
|
353
367
|
open = iceForm === k;
|
|
354
368
|
const head = html`<div class="ice-row${iceCur === k ? " cur" : ""}${iceSel.has(k) ? " sel" : ""}" data-i="${i}" data-k="${k}"><input type="checkbox" id="ice-ck-${i}" data-ck="${i}"${iceSel.has(k) ? " checked" : ""} aria-label="Select: ${it.text}"><span class="ice-src" title="${srcName(it)}">${fav(it.source, "link", list.find((x) => x.dir === it.dir && x.url === it.source)?.social)}</span><button class="ice-t" id="ice-o-${i}" data-o="${i}" aria-expanded="${String(open)}" title="${it.text}">${it.text}</button><span class="ice-meta">${many ? html`<span class="nm" title="${it.project || ""}">${plogo(it.dir, it.project || "")}${short(it.project || "")}</span>` : ""}${it.status === "done" && it.written ? html`<span title="Written back ${ago(it.written)}">written back</span>` : ""}${it.status === "done" && it.writeError ? html`<span title="${it.writeError}">write-back failed</span>` : ""}${it.status === "promoted" ? html`<span title="Promoted to Ideas: ${it.idea || ""}">promoted</span>` : ""}${it.replied ? html`<span title="Replied ${ago(it.replied)}">replied</span>` : ""}<span class="ice-age">${ago(it.at)}</span><span class="ice-ra">${it.status === "promoted" || it.status === "done" ? "" : html`<button class="btn ghost sm" id="ice-pr-${i}" data-pr="${i}" title="Promote to Ideas (p)" aria-label="Promote to Ideas: ${it.text}">${ico("plus")}</button>`}${it.status === "promoted" || it.status === "done" ? "" : it.status === "dismissed" ? html`<button class="btn ghost sm" id="ice-rs-${i}" data-rs="${i}" title="Restore to waiting" aria-label="Restore: ${it.text}">Restore</button>` : html`<button class="btn ghost sm" id="ice-ds-${i}" data-ds="${i}" title="Dismiss (d)" aria-label="Dismiss: ${it.text}">${ico("x")}</button>`}</span></span></div>`;
|
|
355
369
|
const more = open
|
|
356
|
-
? html`<div class="ice-open">${it.notes ? html`<div class="ice-notes">${it.notes}</div>` : ""}${
|
|
370
|
+
? html`<div class="ice-open">${it.notes ? html`<div class="ice-notes">${it.notes}</div>` : ""}${imgs(it)}<span class="hint" style="margin:0">From ${srcName(it)} · ${ago(it.at)}${it.post ? html` · <a href="${it.post}" target="_blank" rel="noopener">open post</a>` : ""}</span>${replyBox(it)}${icePro === k ? form(it) : ""}</div>`
|
|
357
371
|
: "";
|
|
358
372
|
return html`${head}${more}`;
|
|
359
373
|
};
|
|
@@ -363,6 +377,51 @@ export async function openSources() {
|
|
|
363
377
|
: order.length
|
|
364
378
|
? html`<div class="ice-list">${[...groups].map(([g, ix]) => html`<div class="ice-cat">${g}<i>${ix.length}</i></div>${ix.map(row)}`)}</div>`
|
|
365
379
|
: html`<div class="ice-zero"><h4>Nothing waiting</h4><p>Requests gathered from your sources wait here until you turn them into ideas.</p>${list.length ? "" : html`<p style="margin-top:10px"><button class="btn sm pri" id="ice-addsrc">${ico("plus")} Add a source</button></p>`}</div>`;
|
|
380
|
+
// Swipe: the waiting requests the filters show, least skipped first; a restored one
|
|
381
|
+
// comes back on top. Nothing is written by a skip.
|
|
382
|
+
const deck = iceSwipe
|
|
383
|
+
? order.filter((i) => isWaiting(ice[i])).sort((a, b) => (iceSwipe.skip.get(iceKey(ice[a])) || 0) - (iceSwipe.skip.get(iceKey(ice[b])) || 0))
|
|
384
|
+
: [];
|
|
385
|
+
// The card always names its project: a swipe decides for that project's Ideas.
|
|
386
|
+
const pName = (it) => it.project || store.S.projects.find((p) => p.dir === it.dir)?.label || "";
|
|
387
|
+
const swCard = (i, back) => {
|
|
388
|
+
const it = ice[i];
|
|
389
|
+
return html`<div class="sw-card${back ? " back" : ""}"${back ? raw(' aria-hidden="true"') : raw(' id="sw-card" tabindex="-1" aria-label="Request: swipe or press → to promote, ← to dismiss"')}><div class="sw-hd">${fav(it.source, "link", srcOf(it)?.social)}<span class="sw-src" title="${srcName(it)}">${srcName(it)}</span><span class="sw-proj" title="${pName(it)}">${plogo(it.dir, pName(it))}${short(pName(it))}</span><span class="ice-age">${ago(it.at)}</span></div><p class="sw-t">${it.text}</p>${back ? "" : html`${it.notes ? html`<div class="ice-notes">${it.notes}</div>` : ""}${imgs(it)}${it.post ? html`<a class="hint" href="${it.post}" target="_blank" rel="noopener">open post</a>` : ""}<span class="sw-stamp pro">Promote</span><span class="sw-stamp dis">Dismiss</span>`}</div>`;
|
|
390
|
+
};
|
|
391
|
+
// Icebox zero: the day's streak counts days in a row the stack was emptied, per project
|
|
392
|
+
// filter, in this browser only.
|
|
393
|
+
const swZero = () => {
|
|
394
|
+
const S = iceSwipe;
|
|
395
|
+
if (S.n && S.days === undefined) {
|
|
396
|
+
const key = "kz-ice-streak:" + (dir || "all"),
|
|
397
|
+
day = (t) => new Date(t).toLocaleDateString("sv"),
|
|
398
|
+
today = day(Date.now());
|
|
399
|
+
let st = { last: "", days: 0 };
|
|
400
|
+
try {
|
|
401
|
+
st = JSON.parse(localStorage.getItem(key) || "") || st;
|
|
402
|
+
} catch (e) {}
|
|
403
|
+
if (st.last !== today) st = { last: today, days: st.last === day(Date.now() - 864e5) ? st.days + 1 : 1 };
|
|
404
|
+
try {
|
|
405
|
+
localStorage.setItem(key, JSON.stringify(st));
|
|
406
|
+
} catch (e) {}
|
|
407
|
+
S.days = st.days;
|
|
408
|
+
}
|
|
409
|
+
const s = Math.round((Date.now() - S.t0) / 1000),
|
|
410
|
+
took = s < 60 ? s + " s" : Math.floor(s / 60) + " min " + (s % 60) + " s";
|
|
411
|
+
const bits = motion() ? html`<div class="sw-confetti" aria-hidden="true">${Array.from({ length: 14 }, (_, n) => raw(`<i style="--x:${(n * 37) % 100}%;--d:${(n % 5) * 0.08}s;--h:${(n * 53) % 360}"></i>`))}</div>` : "";
|
|
412
|
+
return html`<div class="sw-zero">${S.n ? bits : ""}<h4>✨ Icebox zero ✨</h4><p>${S.n ? `${S.n} sorted · ${S.pro} promoted · ${S.dis} dismissed · in ${took}` : "Nothing waiting here."}</p>${S.days ? html`<p>🗓 ${S.days}-day streak${S.days > 1 ? " — cleared every day" : ""}</p>` : ""}<p style="margin-top:14px"><button class="btn pri sm" id="sw-back">Back to list</button></p></div>`;
|
|
413
|
+
};
|
|
414
|
+
const swipe = () => {
|
|
415
|
+
const S = iceSwipe,
|
|
416
|
+
total = S.n + deck.length,
|
|
417
|
+
pop = S.pop;
|
|
418
|
+
S.pop = false;
|
|
419
|
+
const top = html`<div class="sw-top"><button class="btn ghost sm" id="sw-x" title="Back to the list (Esc)">← List</button><div class="sw-prog" role="progressbar" aria-valuemin="0" aria-valuemax="${total}" aria-valuenow="${S.n}"><i style="width:${total ? Math.round((S.n / total) * 100) : 100}%"></i></div><span class="sw-of">${deck.length ? `${S.n + 1} of ${total}` : `${total} of ${total}`}</span><span class="sw-streak" title="Sorted this session">🔥 ${S.n}${pop ? html`<b class="sw-plus">+1</b>` : ""}</span></div>`;
|
|
420
|
+
if (!deck.length) return html`<div class="sw" id="sw">${top}${swZero()}</div>`;
|
|
421
|
+
const b = (id, cls, icon, label, key, off = false) =>
|
|
422
|
+
html`<button class="sw-b ${cls}" id="${id}" aria-label="${label} (${key})" title="${label} (${key})"${off ? " disabled" : ""}><span>${icon}</span><small>${label}</small></button>`;
|
|
423
|
+
return html`<div class="sw" id="sw">${top}<div class="sw-stack">${deck[1] !== undefined ? swCard(deck[1], true) : ""}${swCard(deck[0], false)}</div><div class="sw-acts">${b("sw-d", "dis", ico("x"), "Dismiss", "←")}${b("sw-s", "", "↓", "Skip", "↓", deck.length < 2)}${b("sw-u", "", ico("restore"), "Undo", "z", !S.last)}${b("sw-p", "pro", ico("check"), "Promote", "→")}</div></div>`;
|
|
424
|
+
};
|
|
366
425
|
// The sources, in the right-hand drawer: shut until asked for. Slid in only when opened;
|
|
367
426
|
// a rebuild while open shows it in place.
|
|
368
427
|
const drawer = !!srcShow,
|
|
@@ -380,7 +439,9 @@ export async function openSources() {
|
|
|
380
439
|
? html`<p style="color:var(--dim)">${d.error}</p>`
|
|
381
440
|
: !d
|
|
382
441
|
? html`<p style="color:var(--dim)">The icebox could not be read.</p>`
|
|
383
|
-
:
|
|
442
|
+
: iceSwipe
|
|
443
|
+
? html`${swipe()}${sec}`
|
|
444
|
+
: html`${onb}${bar}${bulk}${fails}${inbox}${sec}`;
|
|
384
445
|
if (!d || d.error) return;
|
|
385
446
|
const body = $("src-sec")?.querySelector(".body");
|
|
386
447
|
if (body) body.scrollTop = at;
|
|
@@ -481,12 +542,13 @@ export async function openSources() {
|
|
|
481
542
|
srcShut();
|
|
482
543
|
}
|
|
483
544
|
};
|
|
484
|
-
|
|
545
|
+
const srcTog = () => {
|
|
485
546
|
if ($("src-sec").classList.contains("open")) return srcShut();
|
|
486
547
|
srcShow = true;
|
|
487
548
|
openSources().then(() => srcShow && $("src-url")?.focus());
|
|
488
549
|
};
|
|
489
|
-
if ($("
|
|
550
|
+
if ($("src-tog")) $("src-tog").onclick = srcTog;
|
|
551
|
+
if ($("ice-addsrc")) $("ice-addsrc").onclick = srcTog;
|
|
490
552
|
wirePick("ice-fs", (v) => {
|
|
491
553
|
iceSrc = v;
|
|
492
554
|
openSources();
|
|
@@ -539,18 +601,26 @@ export async function openSources() {
|
|
|
539
601
|
.querySelectorAll("[data-wb]")
|
|
540
602
|
.forEach((m) => {
|
|
541
603
|
const s = list[+m.dataset.wb];
|
|
542
|
-
m.
|
|
543
|
-
|
|
604
|
+
m.onclick = () => {
|
|
605
|
+
const on = !m.classList.contains("on");
|
|
606
|
+
if (on && s.social === undefined && /docs\.google\.com/.test(s.url) && !(d.google || {}).connected) {
|
|
544
607
|
alert("Connect Google first (Sources header), so kaizen can write to the sheet.");
|
|
545
|
-
m.checked = false;
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
if (m.checked && !confirm("When a promoted request's run is done, kaizen will write that back to this source. A closed issue or a changed cell is visible to others. Turn on?")) {
|
|
549
|
-
m.checked = false;
|
|
550
608
|
return;
|
|
551
609
|
}
|
|
552
|
-
|
|
553
|
-
|
|
610
|
+
if (on && !confirm("When a promoted request's run is done, kaizen will write that back to this source. A closed issue or a changed cell is visible to others. Turn on?")) return;
|
|
611
|
+
act({ op: "writeback", dir: s.dir, url: s.url, on }, () =>
|
|
612
|
+
toast(on ? "Write back on" : "Write back off"),
|
|
613
|
+
);
|
|
614
|
+
};
|
|
615
|
+
});
|
|
616
|
+
$("pbody")
|
|
617
|
+
.querySelectorAll("[data-ag-on]")
|
|
618
|
+
.forEach((m) => {
|
|
619
|
+
const s = list[+m.dataset.agOn];
|
|
620
|
+
m.onclick = () => {
|
|
621
|
+
const on = !m.classList.contains("on");
|
|
622
|
+
act({ op: "paused", dir: s.dir, url: s.url, on: !on }, () =>
|
|
623
|
+
toast(on ? "Auto gather on" : "Auto gather off"),
|
|
554
624
|
);
|
|
555
625
|
};
|
|
556
626
|
});
|
|
@@ -802,10 +872,142 @@ export async function openSources() {
|
|
|
802
872
|
if (e.key === "Escape") $("ice-cancel").click();
|
|
803
873
|
};
|
|
804
874
|
}
|
|
875
|
+
// Swipe: a decision flies the card off, clicks (when the board's sound is on), then posts.
|
|
876
|
+
const swGo = async (op) => {
|
|
877
|
+
const S = iceSwipe,
|
|
878
|
+
i = deck[0];
|
|
879
|
+
if (!S || S.busy || i === undefined) return;
|
|
880
|
+
const it = ice[i],
|
|
881
|
+
k = iceKey(it);
|
|
882
|
+
if (op === "skip") {
|
|
883
|
+
if (deck.length < 2) return;
|
|
884
|
+
S.skip.set(k, Math.max(...deck.map((x) => S.skip.get(iceKey(ice[x])) || 0)) + 1);
|
|
885
|
+
return openSources();
|
|
886
|
+
}
|
|
887
|
+
S.busy = true;
|
|
888
|
+
const c = $("sw-card");
|
|
889
|
+
if (c && motion()) {
|
|
890
|
+
lift(c);
|
|
891
|
+
const dir = op === "promote" ? 1 : -1;
|
|
892
|
+
await c
|
|
893
|
+
.animate([{ transform: getComputedStyle(c).transform }, { transform: `translateX(${dir * innerWidth}px) rotate(${dir * 30}deg)`, opacity: 0 }], {
|
|
894
|
+
duration: 320,
|
|
895
|
+
easing: "cubic-bezier(.3,.6,.4,1)",
|
|
896
|
+
fill: "forwards",
|
|
897
|
+
})
|
|
898
|
+
.finished.catch(() => {});
|
|
899
|
+
}
|
|
900
|
+
if (soundPick() !== "off") playSound("pop");
|
|
901
|
+
const j = await post("/icebox", { op, dir: it.dir, ids: [it.id] });
|
|
902
|
+
S.busy = false;
|
|
903
|
+
if (j.ok) {
|
|
904
|
+
S.n++;
|
|
905
|
+
op === "promote" ? S.pro++ : S.dis++;
|
|
906
|
+
// Only a dismiss can be undone here: a promote has already made an idea card.
|
|
907
|
+
S.last = op === "dismiss" ? it : null;
|
|
908
|
+
S.pop = true;
|
|
909
|
+
} else toast(`Could not ${op}: ${j.error || "the board did not answer"}`);
|
|
910
|
+
load();
|
|
911
|
+
if (srcOpen()) openSources();
|
|
912
|
+
};
|
|
913
|
+
const swUndo = async () => {
|
|
914
|
+
const S = iceSwipe,
|
|
915
|
+
it = S && S.last;
|
|
916
|
+
if (!it || S.busy) return;
|
|
917
|
+
S.busy = true;
|
|
918
|
+
const j = await post("/icebox", { op: "restore", dir: it.dir, ids: [it.id] });
|
|
919
|
+
S.busy = false;
|
|
920
|
+
if (j.ok) {
|
|
921
|
+
S.n--;
|
|
922
|
+
S.dis--;
|
|
923
|
+
S.last = null;
|
|
924
|
+
S.skip.set(iceKey(it), -1);
|
|
925
|
+
toast("Restored");
|
|
926
|
+
}
|
|
927
|
+
load();
|
|
928
|
+
if (srcOpen()) openSources();
|
|
929
|
+
};
|
|
930
|
+
const swExit = () => {
|
|
931
|
+
iceSwipe = null;
|
|
932
|
+
openSources().then(focusCur);
|
|
933
|
+
};
|
|
934
|
+
if ($("ice-sw"))
|
|
935
|
+
$("ice-sw").onclick = () => {
|
|
936
|
+
iceSwipe = { n: 0, pro: 0, dis: 0, t0: Date.now(), last: null, skip: new Map(), busy: false, pop: false };
|
|
937
|
+
openSources().then(() => $("sw-card")?.focus());
|
|
938
|
+
};
|
|
939
|
+
if ($("sw-x")) $("sw-x").onclick = swExit;
|
|
940
|
+
if ($("sw-back")) $("sw-back").onclick = swExit;
|
|
941
|
+
if ($("sw-d")) $("sw-d").onclick = () => swGo("dismiss");
|
|
942
|
+
if ($("sw-p")) $("sw-p").onclick = () => swGo("promote");
|
|
943
|
+
if ($("sw-s")) $("sw-s").onclick = () => swGo("skip");
|
|
944
|
+
if ($("sw-u")) $("sw-u").onclick = swUndo;
|
|
945
|
+
// A held or flying card is fixed to the window where it sits, so the panel's scroll box
|
|
946
|
+
// and the page's own overflow cannot crop it on the way out.
|
|
947
|
+
const lift = (c) => {
|
|
948
|
+
if (c.classList.contains("lift")) return;
|
|
949
|
+
const r = c.getBoundingClientRect();
|
|
950
|
+
Object.assign(c.style, { left: r.left + "px", top: r.top + "px", width: r.width + "px", height: r.height + "px" });
|
|
951
|
+
c.classList.add("lift");
|
|
952
|
+
};
|
|
953
|
+
const drop = (c) => {
|
|
954
|
+
c.classList.remove("lift");
|
|
955
|
+
for (const k of ["left", "top", "width", "height", "transform"]) c.style.removeProperty(k);
|
|
956
|
+
c.style.removeProperty("--p");
|
|
957
|
+
};
|
|
958
|
+
// Drag: the card follows the pointer and tilts; past 100 px it decides, short of that it
|
|
959
|
+
// springs back. --p (-1..1) fades the stamp in. Controls inside the card still click.
|
|
960
|
+
const card = $("sw-card");
|
|
961
|
+
if (card)
|
|
962
|
+
card.onpointerdown = (e) => {
|
|
963
|
+
if (e.button || e.target.closest("a,button,summary,details")) return;
|
|
964
|
+
const x0 = e.clientX;
|
|
965
|
+
let dx = 0;
|
|
966
|
+
card.setPointerCapture(e.pointerId);
|
|
967
|
+
card.classList.add("drag");
|
|
968
|
+
lift(card);
|
|
969
|
+
swHeld = true;
|
|
970
|
+
card.onpointermove = (m) => {
|
|
971
|
+
dx = m.clientX - x0;
|
|
972
|
+
// Tilt by share of the card's width: a wide desktop card leans as much as a phone one.
|
|
973
|
+
card.style.transform = `translateX(${dx}px) rotate(${(dx / card.offsetWidth) * 18}deg)`;
|
|
974
|
+
card.style.setProperty("--p", String(Math.max(-1, Math.min(1, dx / 100))));
|
|
975
|
+
};
|
|
976
|
+
card.onpointerup = card.onpointercancel = () => {
|
|
977
|
+
card.onpointermove = card.onpointerup = card.onpointercancel = null;
|
|
978
|
+
card.classList.remove("drag");
|
|
979
|
+
swHeld = false;
|
|
980
|
+
const late = swLate;
|
|
981
|
+
swLate = false;
|
|
982
|
+
if (Math.abs(dx) > 100) swGo(dx > 0 ? "promote" : "dismiss");
|
|
983
|
+
else {
|
|
984
|
+
const from = card.style.transform;
|
|
985
|
+
card.style.removeProperty("--p");
|
|
986
|
+
const a = motion() && from ? card.animate([{ transform: from }, { transform: "none" }], { duration: 260, easing: "cubic-bezier(.3,1.4,.5,1)" }) : null;
|
|
987
|
+
card.style.transform = "";
|
|
988
|
+
(a ? a.finished.catch(() => {}) : Promise.resolve()).then(() => {
|
|
989
|
+
drop(card);
|
|
990
|
+
if (late) openSources();
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
};
|
|
805
995
|
// Keys, read by the page's keydown while the icebox shows. True when the key was used.
|
|
806
996
|
iceNav = (e) => {
|
|
807
997
|
if (e.altKey || e.ctrlKey || e.metaKey) return false;
|
|
808
|
-
const k = e.key
|
|
998
|
+
const k = e.key;
|
|
999
|
+
if (iceSwipe) {
|
|
1000
|
+
if (k === "Escape" && $("src-sec")?.classList.contains("open")) {
|
|
1001
|
+
srcShut();
|
|
1002
|
+
return true;
|
|
1003
|
+
}
|
|
1004
|
+
const f = { ArrowLeft: () => swGo("dismiss"), ArrowRight: () => swGo("promote"), ArrowDown: () => swGo("skip"), z: swUndo, Escape: swExit }[k];
|
|
1005
|
+
if (!f) return false;
|
|
1006
|
+
e.preventDefault();
|
|
1007
|
+
f();
|
|
1008
|
+
return true;
|
|
1009
|
+
}
|
|
1010
|
+
const
|
|
809
1011
|
at = order.findIndex((i) => iceKey(ice[i]) === iceCur),
|
|
810
1012
|
i = order[at];
|
|
811
1013
|
if (k === "Escape") {
|
package/web/board/panel.ts
CHANGED
|
@@ -51,7 +51,7 @@ export function open(c, keepTab) {
|
|
|
51
51
|
$("pterm").hidden = true;
|
|
52
52
|
if (c.kind === "idea") {
|
|
53
53
|
store.runDoc = null;
|
|
54
|
-
$("psub").innerHTML = html`<span class="pst"><span class="st d-idea"><svg><use href="#s-idea"/></svg></span>Idea</span><span class="pst dim">${c.where.split(/[\\/]/).pop() || c.where}</span>`;
|
|
54
|
+
$("psub").innerHTML = c.status === "starting" && !c.archived ? steps(c) : html`<span class="pst"><span class="st d-idea"><svg><use href="#s-idea"/></svg></span>Idea</span><span class="pst dim">${c.where.split(/[\\/]/).pop() || c.where}</span>`;
|
|
55
55
|
$("ptabs").innerHTML = "";
|
|
56
56
|
ideaBody(c);
|
|
57
57
|
const foot = $("pfoot");
|
|
@@ -105,6 +105,16 @@ function showProgress(c) {
|
|
|
105
105
|
bar.style.width = lastProg.w + "%";
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
// The header's Plan → Build → Review → Done bar: steps before the card's column are done,
|
|
109
|
+
// its own is ringed in the run's status colour (waiting amber, stalled red), the rest wait.
|
|
110
|
+
const STEPS = ["Plan", "Build", "Review", "Done"];
|
|
111
|
+
function steps(c) {
|
|
112
|
+
const at = c.status === "done" ? 4 : Math.max(0, (c.column || 0) - 1),
|
|
113
|
+
tip = cap(WORD[c.status] || c.status) + (c.awaiting ? `: ${need(c.awaiting)}` : "");
|
|
114
|
+
return html`<span class="steps s-${c.status}" title="${tip}" aria-label="${tip}">${raw(
|
|
115
|
+
STEPS.map((n, i) => `<span class="${i < at ? "ok" : i === at ? "now" : ""}"><i></i>${n}</span>`).join(""),
|
|
116
|
+
)}</span>`;
|
|
117
|
+
}
|
|
108
118
|
// An idea's panel: its terminal while the run it started is being born there, else its notes.
|
|
109
119
|
export function ideaBody(c) {
|
|
110
120
|
if (c.pty) showTerm(c);
|
|
@@ -128,10 +138,9 @@ export async function openRun(c, refresh, again) {
|
|
|
128
138
|
const ta = $("pbody").querySelector(".notes textarea");
|
|
129
139
|
if (refresh && ta && document.activeElement === ta) return;
|
|
130
140
|
// The board's own status mark, then what it waits on: chips, not a dotted line.
|
|
131
|
-
$("psub").innerHTML =
|
|
132
|
-
html`<span class="pst"><span class="st d-${ICON[c.status] || "idea"}"><svg><use href="#s-${ICON[c.status] || "idea"}"/></svg></span>${cap(WORD[c.status] || c.status)}</span>` +
|
|
141
|
+
$("psub").innerHTML = c.status === "abandoned" ? html`<span class="pst"><span class="st d-${ICON[c.status] || "idea"}"><svg><use href="#s-${ICON[c.status] || "idea"}"/></svg></span>${cap(WORD[c.status] || c.status)}</span>` +
|
|
133
142
|
(c.awaiting ? html`<span class="pst dim">${cap(need(c.awaiting))}</span>` : "") +
|
|
134
|
-
(c.parent ? html`<span class="pst link" title="Filed by this run">${c.parent}</span>` : "");
|
|
143
|
+
(c.parent ? html`<span class="pst link" title="Filed by this run">${c.parent}</span>` : "") : steps(c);
|
|
135
144
|
// Only tabs with something in them show. A card whose agent runs in the board gets its
|
|
136
145
|
// terminal behind the header's terminal button, chosen once right after a launch from here.
|
|
137
146
|
const tabs = TABS.filter(
|