kaizen-agent 1.53.1 → 1.55.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/agents/kaizen-planner.md +4 -1
- package/agents/kaizen-reviewer.md +5 -0
- package/cli/chat.test.ts +2 -2
- package/cli/chat.ts +1 -1
- package/cli/install.ts +20 -1
- package/cli/knowledge.test.ts +179 -0
- package/cli/knowledge.ts +216 -0
- package/cli/sources.test.ts +10 -1
- package/cli/sources.ts +11 -1
- package/cli/video.test.ts +6 -1
- package/cli/web.ts +19 -6
- package/package.json +1 -1
- package/skills/kaizen/adapters.md +3 -0
- package/skills/kaizen/config.default.yml +6 -0
- package/skills/kaizen/spec-main.md +3 -1
- package/skills/kaizen/spec-plan.md +5 -1
- package/skills/kaizen/spec-review.md +52 -0
- package/skills/kaizen-help/SKILL.md +2 -0
- package/web/board/icebox.ts +220 -18
- package/web/board/settings.ts +1 -1
- package/web/board/toast.test.ts +77 -0
- package/web/board/toast.ts +8 -3
- package/web/board.html +30 -1
- package/web/board.js +40 -40
- package/web/notebook.js +1 -1
- package/web/sounds/Adara.mp3 +0 -0
- package/web/sounds/Alya.mp3 +0 -0
- package/web/sounds/Bellatrix.mp3 +0 -0
- package/web/sounds/Beryllium.mp3 +0 -0
- package/web/sounds/Cobalt.mp3 +0 -0
- package/web/sounds/Fluorine.mp3 +0 -0
- package/web/sounds/Krypton.mp3 +0 -0
- package/web/sounds/LICENSE-2.0.txt +202 -0
- package/web/sounds/Palladium.mp3 +0 -0
- package/web/sounds/Rubidium.mp3 +0 -0
- package/web/sounds/SOURCES.md +14 -0
- package/web/sounds/Xenon.mp3 +0 -0
- package/web/term.js +1 -1
- package/web/video.js +1 -1
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";
|
|
@@ -25,6 +25,7 @@ import { listChats, readChat, sendChat, stopChat, deleteChat, okId as okChatId,
|
|
|
25
25
|
const PAGE = join(dirname(import.meta.dir), "web", "board.html");
|
|
26
26
|
// The board's script: web/board/*.ts, bundled into one file by `bun run build:web`.
|
|
27
27
|
const BOARD_JS = join(dirname(import.meta.dir), "web", "board.js");
|
|
28
|
+
const SOUNDS_DIR = join(dirname(import.meta.dir), "web", "sounds");
|
|
28
29
|
// The notebook: its page, and the CodeMirror bundle `bun run build:web` commits beside it.
|
|
29
30
|
const NOTES_PAGE = join(dirname(import.meta.dir), "web", "notes.html");
|
|
30
31
|
const ICO = join(dirname(import.meta.dir), "assets", "kaizen.ico");
|
|
@@ -353,7 +354,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
353
354
|
// Social sources need a reader that picks posts: only ChatGPT can do that unattended.
|
|
354
355
|
const gpt = await setting("sources.agent") === "chatgpt" && chatgpt.status().connected;
|
|
355
356
|
for (const s of list) {
|
|
356
|
-
if (!due(s, ms, Date.now())) continue;
|
|
357
|
+
if (s.paused || !due(s, ms, Date.now())) continue;
|
|
357
358
|
if (!socialOf(s.url)) { if ((await gatherSource(dir, s.url)).added) changed(); }
|
|
358
359
|
else if (gpt) { await chatgpt.gatherSource(dir, s.url, await setting("sources.model"), (await setting("sources.effort")) || "low"); changed(); }
|
|
359
360
|
}
|
|
@@ -399,6 +400,8 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
399
400
|
function serve(port: number) { return Bun.serve({
|
|
400
401
|
hostname: "127.0.0.1",
|
|
401
402
|
port,
|
|
403
|
+
// Local only, so attachments may be large: Bun's 128 MB default would cut them.
|
|
404
|
+
maxRequestBodySize: 512 * 1024 * 1024,
|
|
402
405
|
// Bun drops a request after 10s idle by default. A slow /state (git status in a
|
|
403
406
|
// big repo, on Windows) then comes back as nothing, and the page shows an empty
|
|
404
407
|
// board. Loopback only, so nothing waits on us but our own page.
|
|
@@ -443,6 +446,13 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
443
446
|
return new Response(body, { headers: { "content-type": "application/javascript; charset=utf-8", "cache-control": "no-store" } });
|
|
444
447
|
}
|
|
445
448
|
|
|
449
|
+
if (req.method === "GET" && path.startsWith("/sounds/")) {
|
|
450
|
+
const name = /^\/sounds\/([A-Za-z]+)\.mp3$/.exec(path)?.[1];
|
|
451
|
+
const file = name && join(SOUNDS_DIR, `${name}.mp3`);
|
|
452
|
+
if (!file || !existsSync(file)) return new Response("not found", { status: 404 });
|
|
453
|
+
return new Response(Bun.file(file), { headers: { "content-type": "audio/mpeg", "cache-control": "public, max-age=86400" } });
|
|
454
|
+
}
|
|
455
|
+
|
|
446
456
|
if (req.method === "GET" && (path === "/notebook" || path === "/notebook.js")) {
|
|
447
457
|
const [f, type] = path === "/notebook" ? [NOTES_PAGE, "text/html; charset=utf-8"] : [NOTES_JS, "application/javascript; charset=utf-8"];
|
|
448
458
|
const body = served(f);
|
|
@@ -921,11 +931,11 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
921
931
|
let body: any;
|
|
922
932
|
let uploads: ChatUpload[] = [];
|
|
923
933
|
if (path === "/chat" && req.headers.get("content-type")?.startsWith("multipart/form-data")) {
|
|
924
|
-
if (Number(req.headers.get("content-length")) >
|
|
934
|
+
if (Number(req.headers.get("content-length")) > 320 * 1024 * 1024) return bad("attachments too large", 413);
|
|
925
935
|
let form: FormData;
|
|
926
936
|
try { form = await req.formData(); } catch { return bad("form data expected"); }
|
|
927
937
|
const files = form.getAll("files");
|
|
928
|
-
if (files.length >
|
|
938
|
+
if (files.length > 20 || files.some((f) => !(f instanceof File) || f.size > 100 * 1024 * 1024) || files.reduce((n, f) => n + (f instanceof File ? f.size : 0), 0) > 300 * 1024 * 1024) return bad("up to 20 files, 100 MB each and 300 MB total", 413);
|
|
929
939
|
body = { id: form.get("id"), text: form.get("text") ?? "", project: form.get("project") };
|
|
930
940
|
uploads = await Promise.all(files.map(async (f) => ({ name: (f as File).name, bytes: new Uint8Array(await (f as File).arrayBuffer()) })));
|
|
931
941
|
} else try { body = await req.json(); } catch { return bad("json body expected"); }
|
|
@@ -1181,6 +1191,9 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1181
1191
|
} else if (body.op === "writeback") {
|
|
1182
1192
|
const why = setWriteback(dir, link, body.on === true);
|
|
1183
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);
|
|
1184
1197
|
} else if (body.op === "remove") {
|
|
1185
1198
|
const why = removeSource(dir, link);
|
|
1186
1199
|
if (why) return bad(why, 404);
|
|
@@ -1213,7 +1226,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1213
1226
|
// Files added with a hand-written icebox item: saved beside the state, linked in its notes.
|
|
1214
1227
|
const iceFiles = (state: string, files: unknown) => {
|
|
1215
1228
|
const fs: { name: string; data: string }[] = Array.isArray(files) ? files : [];
|
|
1216
|
-
if (fs.reduce((t, f) => t + (f.data?.length ?? 0), 0) >
|
|
1229
|
+
if (fs.reduce((t, f) => t + (f.data?.length ?? 0), 0) > 400_000_000) throw new Error("attachments over 300MB");
|
|
1217
1230
|
return fs.map((f) => {
|
|
1218
1231
|
const rel = saveAttachment(state, null, String(f.name ?? "file"), Buffer.from(String(f.data).replace(/^data:[^,]*,/, ""), "base64"));
|
|
1219
1232
|
return (/\.(png|jpe?g|gif|webp|svg)$/i.test(rel) ? "!" : "") + `[${String(f.name ?? "file")}](${rel})`;
|
|
@@ -1336,7 +1349,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1336
1349
|
const files: { name: string; data: string }[] = Array.isArray(body.files) ? body.files : [];
|
|
1337
1350
|
let total = 0;
|
|
1338
1351
|
for (const f of files) total += (f.data?.length ?? 0);
|
|
1339
|
-
if (total >
|
|
1352
|
+
if (total > 400_000_000) return bad("attachments over 300MB");
|
|
1340
1353
|
const links = files.map((f) => {
|
|
1341
1354
|
const bytes = Buffer.from(String(f.data).replace(/^data:[^,]*,/, ""), "base64");
|
|
1342
1355
|
const rel = saveAttachment(dir, id, String(f.name ?? "file"), bytes).replace(/\\/g, "/");
|
package/package.json
CHANGED
|
@@ -32,6 +32,9 @@ continue from the stage it names. Never advance a run whose `awaiting` field is
|
|
|
32
32
|
non-null without a recorded human decision in `02-approval.md` — another tool or
|
|
33
33
|
session may be mid-run.
|
|
34
34
|
|
|
35
|
+
Before non-trivial work, run `kaizen recall --track <track> --query "<topic>"` and
|
|
36
|
+
treat what it returns as past experience from other projects to verify, not as rules.
|
|
37
|
+
|
|
35
38
|
Codex has no separate subagents, so run the stages sequentially in one session,
|
|
36
39
|
but keep them clean: start each stage by reading only that stage's declared inputs
|
|
37
40
|
from its stage file, and write its artifact before moving on. When reviewing, judge the
|
|
@@ -73,6 +73,12 @@ review:
|
|
|
73
73
|
# prunes stale or superseded lessons before appending rather than growing the file.
|
|
74
74
|
memory_max_lines: 100
|
|
75
75
|
|
|
76
|
+
knowledge:
|
|
77
|
+
# Lessons that hold beyond one project go to ~/.kaizen/knowledge/<track>.md through
|
|
78
|
+
# `kaizen remember`; planners and Claude Code sessions read them with `kaizen recall`.
|
|
79
|
+
# false: this project never writes there (recall still reads). For confidential work.
|
|
80
|
+
global: true
|
|
81
|
+
|
|
76
82
|
backlog:
|
|
77
83
|
# Capture work explicitly deferred, unresolved findings after the bounded fix loop,
|
|
78
84
|
# and verification the user still needs to settle.
|
|
@@ -136,7 +136,9 @@ Controlled by `approvals.review`, skipped in `auto`.
|
|
|
136
136
|
Report: what was built (for a code run, show its Preview proof), verification results, findings fixed, findings still open,
|
|
137
137
|
every criterion the reviewer answered `CANNOT VERIFY` with the check it says a human
|
|
138
138
|
must make, anything the builder noted as out of scope, and the notes the *Docs gate*
|
|
139
|
-
touched
|
|
139
|
+
touched, and the `## Remembered` lines from `04-review.md` verbatim, so what the run
|
|
140
|
+
saved to memory and to global knowledge is visible without opening a file (deleting
|
|
141
|
+
or editing a line in `~/.kaizen/knowledge/` is the undo). Where the run used `runner: lite` and reviewed inline (`review.executor: inline`), say
|
|
140
142
|
so in that report — the reviewer saw the work, and nobody should read a same-session
|
|
141
143
|
review as an independent one because the output looked the same.
|
|
142
144
|
Later build requests in the same session follow *Follow-ups are runs too* in [`spec.md`](spec.md): a revise of this run until it is `done`, then a new linked run.
|
|
@@ -10,7 +10,11 @@ planner's and the plan approval's contract. The builder and reviewer do not read
|
|
|
10
10
|
the run directory when present — links, paths, and background the user attached from
|
|
11
11
|
the board, binding like the request itself — `memory.md`, `notes/Project/Index.md` in the state
|
|
12
12
|
directory when present — the project's map, written by `/kaizen docs`; open only the
|
|
13
|
-
notes it lists for areas the request touches —
|
|
13
|
+
notes it lists for areas the request touches — the output of
|
|
14
|
+
`kaizen recall --track <track> --tags <stack tags> --query "<words from the request>"`
|
|
15
|
+
— past experience from other projects, to verify against this one, never binding
|
|
16
|
+
like project rules; the Framing ends with `Recalled: <n> lessons; used: <the lines it
|
|
17
|
+
relied on>` or `Recalled: none` — and the existing material —
|
|
14
18
|
the codebase, the manuscript, the current campaign, whatever this run builds on.
|
|
15
19
|
**Output:** `01-plan.md`.
|
|
16
20
|
|
|
@@ -135,6 +135,58 @@ them. Keep it under `review.memory_max_lines` (default 100): before appending, d
|
|
|
135
135
|
any lesson that is now wrong, already enforced by a test or a lint rule, or restated
|
|
136
136
|
by a newer entry. A memory file that only grows stops being read carefully.
|
|
137
137
|
|
|
138
|
+
**Global knowledge.** Some lessons hold beyond this project — still true in another
|
|
139
|
+
repository on the same stack, or another piece of work on the same track. For each
|
|
140
|
+
lesson, decide its scope. Project lessons go to `memory.md` as above.
|
|
141
|
+
|
|
142
|
+
Global knowledge is read by every future project, so it stays high-signal, not a
|
|
143
|
+
history of what was built. A lesson goes global only when all four hold:
|
|
144
|
+
|
|
145
|
+
1. **Reusable** — still true in another repository on the same stack or track.
|
|
146
|
+
2. **High-signal** — knowing it would change what someone does: a discovery that cost
|
|
147
|
+
real investigation, a measured improvement, an architectural trade-off and when it
|
|
148
|
+
tips, or a fix that saves the next person the same search. Documented behaviour
|
|
149
|
+
counts when it was the answer to a real problem here; rare is not the test, useful is.
|
|
150
|
+
3. **Evidenced** — it comes from something this run actually hit: a finding, a failing
|
|
151
|
+
test, an error, a measurement. Name it in `--applies` (`seen: finding 3`). An opinion
|
|
152
|
+
with nothing behind it in this run is not a lesson.
|
|
153
|
+
4. **New** — run `kaizen recall --tags <tags> --query "<key words>"` first. If a line
|
|
154
|
+
already says it, skip yours, or `--replace` that line only when this run adds a
|
|
155
|
+
correction, a version limit or stronger evidence.
|
|
156
|
+
|
|
157
|
+
Skip: framework basics a competent developer already knows, routine implementation,
|
|
158
|
+
trivial and typo fixes, this project's own conventions (those are `memory.md`), and
|
|
159
|
+
anything recall already returned. Zero global lessons is the normal outcome. More
|
|
160
|
+
than two from one run is a reason to re-check each against the four tests, not to
|
|
161
|
+
drop them.
|
|
162
|
+
|
|
163
|
+
Global lessons go through `kaizen remember`, never by editing `~/.kaizen/knowledge/`
|
|
164
|
+
directly:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
kaizen remember --track <code|writing|communication|operations|research> \
|
|
168
|
+
--tags <tag,tag@version> --applies "<versions, platform, limits>" --run <run id> "<lesson>"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
- Generalize before saving. Keep commands, flags, versions, error strings and public
|
|
172
|
+
documentation URLs: they are the lesson. Replace paths, hosts, client and person
|
|
173
|
+
names, internal URLs and business figures with `<project>`, `<host>` and the like.
|
|
174
|
+
- Phrase it as a fact about behaviour ("X causes Y"), never as an order to an agent.
|
|
175
|
+
- `--applies` is required: where the lesson holds and where it does not, so it never
|
|
176
|
+
reads as a universal rule. Versions and frameworks also go in the tags (`bun@1.2`),
|
|
177
|
+
which keeps lessons for different versions apart.
|
|
178
|
+
- `remember` appends and prints any existing lines that share a tag, numbered. If one
|
|
179
|
+
says the same thing, rewrite it with `--replace <n>` or drop yours; nothing is merged
|
|
180
|
+
without that explicit choice.
|
|
181
|
+
- Never write the `preferences` track: the user keeps it by hand.
|
|
182
|
+
- A refusal is final for that wording: the secret check rejects keys, tokens, emails,
|
|
183
|
+
IP addresses and private hosts; `knowledge.global: false` means the project opted out.
|
|
184
|
+
|
|
185
|
+
Record every attempt, project and global, in a `## Remembered` section of
|
|
186
|
+
`04-review.md`, one line each: `Remembered (project): …`, `Remembered (global): …` as
|
|
187
|
+
`remember` printed it, or `Rejected: <reason> — <lesson>`. Write `None` when nothing
|
|
188
|
+
was worth keeping; most runs teach nothing durable, and that is fine.
|
|
189
|
+
|
|
138
190
|
---
|
|
139
191
|
|
|
140
192
|
## Stage 4 — Fix loop
|
|
@@ -38,6 +38,8 @@ anything.
|
|
|
38
38
|
| `/kaizen config` | Show this project's settings and change them, one picker per setting |
|
|
39
39
|
| `/kaizen init` | Set up this project folder: `.kaizen/` with `spec.md`, config, and — in a git repo — the gitignore entry |
|
|
40
40
|
| `/kaizen install` | Install the workflow itself globally or per-project |
|
|
41
|
+
| `kaizen recall [--track t] [--tags a,b] [--query "<words>"]` | Lessons from other projects that match (global knowledge, `~/.kaizen/knowledge/`) |
|
|
42
|
+
| `kaizen remember --track t --tags a,b --applies "<where>" --run <id> "<lesson>"` | Save a lesson that holds beyond this project; the reviewer calls it |
|
|
41
43
|
|
|
42
44
|
`/kaizen` with no argument: `status` if a run is in progress, else ask what to build.
|
|
43
45
|
|
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/settings.ts
CHANGED
|
@@ -102,7 +102,7 @@ export async function openSettings() {
|
|
|
102
102
|
<h3 class="sg">Browser</h3><div class="sgrp">${row("Theme", ctl("th", ["system", "light", "dark"], cur), "", "th", "theme light dark system browser")}
|
|
103
103
|
${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")}
|
|
104
104
|
${row("Notifications", html`<button class="chk${nton ? " on" : ""}" id="nt" role="switch" aria-checked="${String(nton)}"></button>`, ntHelp, "nt", "notifications " + ntHelp + " browser")}
|
|
105
|
-
${row("Notification sound", ctl("ns", SOUNDS, soundPick()), "Plays with each notice. Changing it plays it.", "ns", "notification sound
|
|
105
|
+
${row("Notification sound", ctl("ns", SOUNDS, soundPick()), "Plays with each notice. Changing it plays it.", "ns", "notification sound audio browser " + SOUNDS.join(" "), !nton)}</div>
|
|
106
106
|
<p class="snone" id="snone" hidden></p>`;
|
|
107
107
|
// Hides rows that do not match, then any group (and its chip) left with none.
|
|
108
108
|
updBar();
|