create-pmos 0.443.0 → 0.445.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/package.json +25 -25
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/adler-moments-test.js +8 -0
- package/workspace/adler-seasons-art-test.js +3 -0
- package/workspace/board-columns-test.js +168 -0
- package/workspace/board-programs-test.js +1 -1
- package/workspace/briefing-premium-board-test.js +91 -8
- package/workspace/briefing-premium-insights-test.js +83 -38
- package/workspace/briefing-premium-test.js +2 -1
- package/workspace/calm-timeline-test.js +3 -1
- package/workspace/changelog.json +24 -0
- package/workspace/goals-clear-ui-test.js +34 -20
- package/workspace/guide/home.md +5 -0
- package/workspace/guide/jira.md +13 -1
- package/workspace/guide/ready-made-dashboards.md +2 -2
- package/workspace/intel-report-ui-test.js +1 -1
- package/workspace/lib/board-fold.js +33 -5
- package/workspace/lib/board-premium.js +1 -1
- package/workspace/lib/console-state.js +5 -1
- package/workspace/lib/engine/boards.js +9 -2
- package/workspace/lib/factory-join.js +46 -14
- package/workspace/lib/freshness.js +14 -1
- package/workspace/lib/initiative-rows.js +38 -4
- package/workspace/lib/issues.js +8 -1
- package/workspace/lib/jira-cli.js +18 -2
- package/workspace/lib/jira-moves.js +119 -0
- package/workspace/lib/jira-tickets.js +23 -4
- package/workspace/lib/notes.js +4 -2
- package/workspace/lib/offloop.js +75 -29
- package/workspace/lib/page-build.js +97 -0
- package/workspace/lib/plan-items.js +24 -3
- package/workspace/lib/plan-tree.js +62 -9
- package/workspace/lib/ready-reports.js +22 -8
- package/workspace/lib/refresh.js +14 -2
- package/workspace/lib/routes-board-premium.js +9 -1
- package/workspace/lib/routes-boards.js +114 -16
- package/workspace/lib/routes-brief-page.js +3 -1
- package/workspace/lib/routes-calendar-import.js +13 -1
- package/workspace/lib/routes-ready-reports.js +28 -5
- package/workspace/lib/task-links.js +12 -1
- package/workspace/lib/workflows-store.js +14 -3
- package/workspace/live-pill-round-test.js +178 -0
- package/workspace/milestone-pins-test.js +1 -1
- package/workspace/okr-goals-ui-test.js +21 -19
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +375 -0
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-item-test.js +10 -2
- package/workspace/premium-vw-jira-test.js +3 -0
- package/workspace/program-panel-test.js +6 -6
- package/workspace/public/pm/bd-cols.js +149 -0
- package/workspace/public/pm/bd-ini-panel.js +3 -2
- package/workspace/public/pm/bd-pane.js +41 -0
- package/workspace/public/pm/bd-span.js +29 -11
- package/workspace/public/pm/cozy-adler.js +21 -0
- package/workspace/public/pm/cozy-board.css +45 -0
- package/workspace/public/pm/cozy-divider.css +32 -0
- package/workspace/public/pm/cozy-divider.js +45 -0
- package/workspace/public/pm/cozy-insights.css +22 -0
- package/workspace/public/pm/cozy-live-pill.css +17 -22
- package/workspace/public/pm/cozy-live-pill.js +38 -18
- package/workspace/public/pm/cozy-panels.css +80 -0
- package/workspace/public/pm/cozy-panels.js +691 -0
- package/workspace/public/pm/cozy-viewer.js +148 -70
- package/workspace/public/pm/dash-view.js +5 -2
- package/workspace/public/pm/goals-clear.js +9 -2
- package/workspace/public/pm/home-app.js +30 -19
- package/workspace/public/pm/home-ini.js +9 -3
- package/workspace/public/pm/home-today.js +4 -2
- package/workspace/public/pm/ini-edit.js +405 -0
- package/workspace/public/pm/ini-tasks.js +175 -46
- package/workspace/public/pm/ini-versions.js +18 -4
- package/workspace/public/pm/ini-view-model.js +12 -7
- package/workspace/public/pm/ini-view.css +162 -26
- package/workspace/public/pm/ini-view.js +44 -13
- package/workspace/public/pm/ini-wf-model.js +9 -0
- package/workspace/public/pm/ini-wf.js +14 -9
- package/workspace/public/pm/ins-pane.js +55 -0
- package/workspace/public/pm/jira-move.js +50 -0
- package/workspace/public/pm/live-model.js +3 -2
- package/workspace/public/pm/pn-narrow.js +76 -0
- package/workspace/public/pm/premium-board.js +85 -32
- package/workspace/public/pm/premium-insights.js +211 -43
- package/workspace/public/pm/task-card.css +2 -0
- package/workspace/public/pm/task-card.js +4 -1
- package/workspace/public/premium-board.html +2 -0
- package/workspace/ready-dash-ui-test.js +4 -4
- package/workspace/server.js +71 -20
- package/workspace/skills/jira-move.skill +35 -0
- package/workspace/stage-card-tasks-test.js +397 -0
- package/workspace/stage-card-test.js +1 -1
- package/workspace/task-delete-test.js +9 -1
- package/workspace/task-links-test.js +1 -0
- package/workspace/task-milestones-test.js +3 -3
- package/workspace/task-plans-test.js +1 -1
- package/workspace/task-press-test.js +12 -4
- package/workspace/task-views-test.js +166 -13
- package/workspace/test-lists/batch18-live-pill-round.json +10 -0
- package/workspace/test-lists/batch18-panels.json +9 -0
- package/workspace/test-lists/board-columns.json +5 -0
- package/workspace/test-lists/jira-moves.json +11 -0
- package/workspace/test-lists/page-speed-fold.json +5 -0
- package/workspace/test-lists/page-speed-reads.json +5 -0
- package/workspace/test-lists/stage-card-tasks.json +6 -0
- package/workspace/timeline-holds-test.js +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* (c3-initiative-boards; planning/prd/c3-initiative-boards-prd.md "Model", "State", "API contract").
|
|
4
4
|
*
|
|
5
5
|
* GET /api/boards → { ok, boards: [portfolio row] } every workspace; `ws` is ignored
|
|
6
|
+
* GET /api/boards?names=1 → the same rows without health, counts and next release (no row is derived)
|
|
6
7
|
* GET /api/boards/board?ws&board → { ok, board, counts: { total, byStage, byStatus }, asks, nextRelease, recent }
|
|
7
8
|
* GET /api/boards/backlog?ws&board&q&stage&status&owner&horizon&anchor&view&sort&offset&limit
|
|
8
9
|
* → { ok, total, offset, limit, rows, facets: { stage, status, owner, horizon } }
|
|
@@ -24,7 +25,10 @@
|
|
|
24
25
|
* POST /api/boards/settings { ws, board, buildDeliver?, jira?, offer?, defTpl? } → { ok, board } jira: one key or a list
|
|
25
26
|
* POST /api/boards/ini-workflow { ws, board, id, template?, stages, moveTo? } → { ok, row, moved }
|
|
26
27
|
* POST /api/boards/ini-epics { ws, board, id, epics: [Jira key] } → { ok, row } the Jira epics of an initiative ([] unlinks)
|
|
27
|
-
* POST /api/boards/tasks/add { ws, board, initiative, title, type?, epic?, start?, due?, owner?, notes? } → { ok, item } also `pmos task add`
|
|
28
|
+
* POST /api/boards/tasks/add { ws, board, initiative, title, type?, epic?, start?, due?, owner?, notes?, section? } → { ok, item } also `pmos task add`
|
|
29
|
+
* (section: the stage it goes under, as tasks/edit's section: the + on a stage of the Tasks list, batch 18 item 16)
|
|
30
|
+
* POST /api/boards/tasks/order { ws, board, initiative, section, tasks: [id] } → { ok, from } the PM's order inside one stage (a drag in the
|
|
31
|
+
* Tasks list, batch 18 item 16): a task-order line; tasks [] takes the order out; Undo sends `from` back
|
|
28
32
|
* POST /api/boards/tasks/state { ws, board, task, state } → { ok, item }
|
|
29
33
|
* POST /api/boards/tasks/reschedule { ws, board, task, days } → { ok, item }
|
|
30
34
|
* POST /api/boards/tasks/undo-add { ws, board, task } → { ok } takes back a task added in the last 2 minutes, still To do
|
|
@@ -106,10 +110,21 @@ function ledgerFile(ctx, w) {
|
|
|
106
110
|
const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
107
111
|
return d ? path.join(d, LEDGER) : null;
|
|
108
112
|
}
|
|
113
|
+
// The ledger's lines, read again only when its stat changes (a write shows on the next read). The lines are strings; every
|
|
114
|
+
// caller folds them into objects of its own, so nothing a caller changes reaches the memo.
|
|
115
|
+
const ledgerMemo = new Map(); // file -> { key, lines }
|
|
109
116
|
function readLedger(ctx, w) {
|
|
110
117
|
const f = ledgerFile(ctx, w);
|
|
111
118
|
if (!f) return [];
|
|
112
|
-
|
|
119
|
+
let key = null;
|
|
120
|
+
try { const st = fs.statSync(f); key = `${st.ino}:${st.size}:${st.mtimeMs}:${st.ctimeMs}`; } catch { return []; }
|
|
121
|
+
const hit = ledgerMemo.get(f);
|
|
122
|
+
if (hit && hit.key === key) return hit.lines.slice();
|
|
123
|
+
let lines;
|
|
124
|
+
try { lines = fs.readFileSync(f, 'utf8').split('\n').filter(Boolean); } catch { return []; }
|
|
125
|
+
if (ledgerMemo.size > 100) ledgerMemo.clear();
|
|
126
|
+
ledgerMemo.set(f, { key, lines });
|
|
127
|
+
return lines.slice();
|
|
113
128
|
}
|
|
114
129
|
function append(file, actor, ev) {
|
|
115
130
|
const line = { at: new Date().toISOString(), by: actor.by, ...ev };
|
|
@@ -233,7 +248,18 @@ function statusOf(rec, healthLevel, end, day) {
|
|
|
233
248
|
}
|
|
234
249
|
|
|
235
250
|
/** The board-independent part of every work row of a repository, cached by the read signature. */
|
|
236
|
-
|
|
251
|
+
/* A READ PASS (ctx.boardsPass, a Map): a page that asks several of these routes for one answer (GET /api/board-premium asks ten)
|
|
252
|
+
* hands them one pass, and each workspace's frame and base rows are then derived once for all of them, not once per route. A
|
|
253
|
+
* pass lives for that one request; without one every call derives again, as before. */
|
|
254
|
+
const inPass = (ctx, key, make) => {
|
|
255
|
+
const m = ctx && ctx.boardsPass;
|
|
256
|
+
if (!(m instanceof Map)) return make();
|
|
257
|
+
if (m.has(key)) return m.get(key);
|
|
258
|
+
const v = make(); m.set(key, v); return v;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
function baseRows(w, ctx) { return inPass(ctx, 'base\u0000' + w.root, () => baseRowsRead(w)); }
|
|
262
|
+
function baseRowsRead(w) {
|
|
237
263
|
const got = rowsLib.rowsFor(w.root);
|
|
238
264
|
if (got.pending) return { pending: true };
|
|
239
265
|
if (!got.ok) return { ok: false, error: got.error || 'the initiatives could not be read' };
|
|
@@ -356,9 +382,22 @@ function taskSpanOf(folded, id) {
|
|
|
356
382
|
}
|
|
357
383
|
/** Each dated task of an initiative as { start, due, stage } (Won't do and Archived left out). stage: the PM's placement (a task-section line),
|
|
358
384
|
* else the stage whose To finish entry made it, else null. */
|
|
385
|
+
// each fold's tasks by initiative, made once per fold (a fold is never changed after it is made: a write folds again), so a row
|
|
386
|
+
// does not walk every task of the board
|
|
387
|
+
const tasksByIni = new WeakMap();
|
|
388
|
+
function tasksOfIni(folded, id) {
|
|
389
|
+
if (!folded || !folded.tasks) return [];
|
|
390
|
+
let by = tasksByIni.get(folded);
|
|
391
|
+
if (!by) {
|
|
392
|
+
by = new Map();
|
|
393
|
+
for (const t of folded.tasks.values()) { if (!t) continue; if (!by.has(t.initiative)) by.set(t.initiative, []); by.get(t.initiative).push(t); }
|
|
394
|
+
tasksByIni.set(folded, by);
|
|
395
|
+
}
|
|
396
|
+
return by.get(id) || [];
|
|
397
|
+
}
|
|
359
398
|
function taskSpansOf(folded, id) {
|
|
360
399
|
const out = [], SEC = (folded && folded.sections) || new Map();
|
|
361
|
-
for (const t of (folded
|
|
400
|
+
for (const t of tasksOfIni(folded, id)) {
|
|
362
401
|
if (!t || t.initiative !== id || t.state === "Won't do" || t.state === 'Archived') continue;
|
|
363
402
|
const a = t.start || t.due, z = t.due || t.start;
|
|
364
403
|
const stage = SEC.has(t.id) ? SEC.get(t.id) || null : (t.from && t.from.stage) || null;
|
|
@@ -400,16 +439,32 @@ function boardRow(board, base, folded, lib) {
|
|
|
400
439
|
}
|
|
401
440
|
|
|
402
441
|
/** Everything a read of one workspace needs. */
|
|
403
|
-
function frameFor(ctx, w) {
|
|
442
|
+
function frameFor(ctx, w) { return inPass(ctx, 'frame\u0000' + w.root, () => frameRead(ctx, w)); }
|
|
443
|
+
function frameRead(ctx, w) {
|
|
404
444
|
const folded = B.fold(readLedger(ctx, w));
|
|
405
445
|
const boards = boardsOf(ctx, w, folded);
|
|
406
446
|
const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
407
447
|
folded.wfLib = WS.library(d); // D99: the workflow library rides on the fold, so every boardRow call reads one copy
|
|
408
448
|
return { w, folded, boards };
|
|
409
449
|
}
|
|
410
|
-
/** A fresh fold with the workflow library on it (frameFor's, without the boards). */
|
|
411
|
-
function foldOf(ctx, w) { const f = B.fold(readLedger(ctx, w)); const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null; f.wfLib = WS.library(d); return f; }
|
|
450
|
+
/** A fresh fold with the workflow library on it (frameFor's, without the boards). Inside a read pass, the pass's own fold. */
|
|
451
|
+
function foldOf(ctx, w) { if (ctx && ctx.boardsPass instanceof Map) return frameFor(ctx, w).folded; const f = B.fold(readLedger(ctx, w)); const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null; f.wfLib = WS.library(d); return f; }
|
|
412
452
|
const libOf = (folded) => (folded && folded.wfLib) || WS.library(null);
|
|
453
|
+
/** A workflow by id for workspace w: its own library first, then the home workspace's, then any other open workspace's (not archived there).
|
|
454
|
+
* → { wf, ws: null } | { wf, ws: <the workspace it came from> } | null */
|
|
455
|
+
function workflowFor(ctx, w, lib, id) {
|
|
456
|
+
const own = lib.byId.get(id);
|
|
457
|
+
if (own) return { wf: own, ws: null };
|
|
458
|
+
const home = ctx.getWs ? ctx.getWs(null) : null;
|
|
459
|
+
const others = [home, ...(ctx.workspaceList ? ctx.workspaceList() : [])].filter((x, i, a) => x && x !== w && x.id !== w.id && a.indexOf(x) === i);
|
|
460
|
+
for (const x of others) {
|
|
461
|
+
let d = null; try { d = ctx.stateDirFor ? ctx.stateDirFor(x) : null; } catch { d = null; }
|
|
462
|
+
if (!d) continue;
|
|
463
|
+
const wf = WS.library(d).byId.get(id);
|
|
464
|
+
if (wf && !wf.archived) return { wf, ws: x };
|
|
465
|
+
}
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
413
468
|
function rowsOfBoard(fr, board, base) {
|
|
414
469
|
const rows = base.filter((r) => boardIdOf(r, fr.boards, fr.folded, fr.w) === board.id).map((r) => boardRow(board, r, fr.folded));
|
|
415
470
|
// c3-initiative-lifecycle: what was merged into each row, and the likely duplicates among the active rows of this board.
|
|
@@ -435,7 +490,7 @@ function stageTasks(file, folded, board, row, by) {
|
|
|
435
490
|
if (!list.length) return 0;
|
|
436
491
|
const have = new Set();
|
|
437
492
|
// a To finish task the PM deleted stays deleted: the next read must not make it again (batch 17 item 2: "Deleting task, but keep appearing")
|
|
438
|
-
for (const t of [...folded.
|
|
493
|
+
for (const t of [...tasksOfIni(folded, row.id), ...(folded.removed ? folded.removed.values() : [])]) if (t.initiative === row.id && t.from && t.from.stage === st.key) have.add(t.from.finish);
|
|
439
494
|
let n = 0;
|
|
440
495
|
for (const f of list) {
|
|
441
496
|
if (have.has(f)) continue;
|
|
@@ -549,6 +604,18 @@ function itemsOf(w, fr, board, rows) {
|
|
|
549
604
|
// a task's place in the breakdown (one view): the PM's own choice, else the stage whose To finish entry made it
|
|
550
605
|
const SEC = fr.folded.sections || new Map();
|
|
551
606
|
for (const x of out) if (x.src === 'pmos' && x.kind !== 'Epic') { if (SEC.has(x.uid)) x.section = SEC.get(x.uid); else if (x.from && x.from.stage) x.section = x.from.stage; }
|
|
607
|
+
// the PM's order inside a stage (batch 18 item 16, task-order lines): rank = the place in its stage's list. A task named in two lists (it
|
|
608
|
+
// moved since) takes the list of the stage it sits in now
|
|
609
|
+
const OR = fr.folded.orders || new Map();
|
|
610
|
+
if (OR.size) {
|
|
611
|
+
const byIni = new Map();
|
|
612
|
+
for (const [k, ids] of OR) { const [ini, sec] = k.split('\u0000'); if (!byIni.has(ini)) byIni.set(ini, []); byIni.get(ini).push({ sec, ids }); }
|
|
613
|
+
for (const x of out) {
|
|
614
|
+
if (x.src !== 'pmos' || x.kind === 'Epic' || !byIni.has(x.ini)) continue;
|
|
615
|
+
const L = byIni.get(x.ini), hit = (typeof x.section === 'string' && L.find((o) => o.sec === x.section && o.ids.includes(x.uid))) || L.find((o) => o.ids.includes(x.uid));
|
|
616
|
+
if (hit) x.rank = hit.ids.indexOf(x.uid);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
552
619
|
// a task flagged as a milestone (feedback batch 11 item 3): the PM's flag on the board ledger, else a breakdown item's own plan-items flag
|
|
553
620
|
const MS = fr.folded.milestones || new Map();
|
|
554
621
|
for (const x of out) if (x.kind !== 'Epic') { const on = MS.has(x.uid) ? MS.get(x.uid) : !!x.milestone; if (on) x.milestone = true; else delete x.milestone; }
|
|
@@ -582,18 +649,21 @@ function wsOf(ctx, wsParam) {
|
|
|
582
649
|
}
|
|
583
650
|
const fail = (ctx, res, status, error, extra = {}) => { ctx.json(res, { ok: false, error, ...extra }, status); return true; };
|
|
584
651
|
|
|
585
|
-
|
|
652
|
+
/** Every board of every workspace. With `names` (GET /api/boards?names=1), only who each board is (ws, id, name and the board's
|
|
653
|
+
* own settings, no rows): a page that only needs the board list does not derive the rows of every workspace. */
|
|
654
|
+
function portfolio(ctx, { names = false } = {}) {
|
|
586
655
|
const list = ctx.workspaceList ? ctx.workspaceList() : [];
|
|
587
656
|
const releases = readReleases(ctx);
|
|
588
657
|
const out = [];
|
|
589
658
|
for (const w of list) {
|
|
590
659
|
let fr;
|
|
591
660
|
try { fr = frameFor(ctx, w); } catch (e) { out.push({ ws: w.id, id: w.id, name: w.name, error: String((e && e.message) || e).slice(0, 160) }); continue; }
|
|
661
|
+
if (names) { for (const board of fr.boards) out.push({ ...board, health: null, counts: null, asks: openAsks(fr.folded, board.id), nextRelease: null }); continue; }
|
|
592
662
|
let base = null;
|
|
593
663
|
let pending = false;
|
|
594
664
|
let error = null;
|
|
595
665
|
try {
|
|
596
|
-
const b = baseRows(w);
|
|
666
|
+
const b = baseRows(w, ctx);
|
|
597
667
|
if (b.pending) pending = true; else if (!b.ok) error = b.error; else base = b.rows;
|
|
598
668
|
} catch (e) { error = String((e && e.message) || e).slice(0, 160); }
|
|
599
669
|
for (const board of fr.boards) {
|
|
@@ -622,7 +692,7 @@ function boardRead(ctx, res, url, { rows = true } = {}) {
|
|
|
622
692
|
const board = fr.boards.find((b) => b.id === bid);
|
|
623
693
|
if (!board) { fail(ctx, res, 404, `no board ${bid} in this workspace`); return null; }
|
|
624
694
|
if (!rows) return { w, fr, board, rows: null };
|
|
625
|
-
const b = baseRows(w);
|
|
695
|
+
const b = baseRows(w, ctx);
|
|
626
696
|
if (b.pending) { ctx.json(res, { ok: true, pending: true, ws: w.id, board: board.id }, 202); return null; }
|
|
627
697
|
if (!b.ok) { fail(ctx, res, 500, b.error); return null; }
|
|
628
698
|
return { w, fr, board, base: b.rows, rows: rowsOfBoard(fr, board, b.rows) };
|
|
@@ -1029,18 +1099,22 @@ const WRITES = {
|
|
|
1029
1099
|
if (body.why != null && body.why !== '' && !ONE_LINE(body.why, 500)) return fail(ctx, res, 400, 'why is one line of at most 500 characters');
|
|
1030
1100
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1031
1101
|
const lib = libOf(p.fr.folded);
|
|
1032
|
-
const
|
|
1033
|
-
if (!
|
|
1102
|
+
const found = workflowFor(ctx, p.w, lib, body.wf);
|
|
1103
|
+
if (!found) return fail(ctx, res, 404, 'That workflow could not be found. It may have been removed in Settings, Workflows.');
|
|
1104
|
+
const to = found.wf;
|
|
1034
1105
|
if (to.archived) return fail(ctx, res, 409, `${to.name} is archived. Bring it back first.`);
|
|
1035
1106
|
const base = needRows(ctx, res, p.w);
|
|
1036
1107
|
if (!base) return;
|
|
1037
1108
|
const b0 = base.find((r) => r.id === body.id);
|
|
1038
|
-
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404,
|
|
1109
|
+
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404, 'That initiative is not on this board any more.');
|
|
1039
1110
|
const before = boardRow(p.board, b0, p.fr.folded);
|
|
1040
1111
|
const from = WF.resolve(lib, before.wf.id);
|
|
1041
1112
|
let target = WF.switchTarget(from, to, before.wfStage.key);
|
|
1042
|
-
if (body.to != null) { const t = WF.stageByRef(to, body.to); if (!t) return fail(ctx, res, 400, `
|
|
1113
|
+
if (body.to != null) { const t = WF.stageByRef(to, body.to); if (!t) return fail(ctx, res, 400, `That stage is not part of ${to.name}.`); target = t.key; }
|
|
1043
1114
|
const moved = { from: before.wfStage.key, to: target };
|
|
1115
|
+
// A workflow the PM saved in another workspace's library (Settings opens on the home workspace) is written into this one's first, so
|
|
1116
|
+
// this workspace's own record still reads the initiative's workflow when the other workspace is not open.
|
|
1117
|
+
if (found.ws) { const a = WS.adopt(ctx.stateDirFor(p.w), to, g.actor, found.ws.id); if (!a.ok) return fail(ctx, res, a.status || 400, a.error); }
|
|
1044
1118
|
append(p.file, g.actor, { kind: 'ini-wf', board: p.board.id, id: body.id, wf: to.id, from: from.id, moved, why: body.why ? body.why.trim() : '', ...(body.pmos === true ? { pmos: true } : {}) });
|
|
1045
1119
|
const f1 = foldOf(ctx, p.w), row = boardRow(p.board, b0, f1);
|
|
1046
1120
|
const made = stageTasks(p.file, f1, p.board, row, g.actor.by);
|
|
@@ -1139,14 +1213,38 @@ const WRITES = {
|
|
|
1139
1213
|
if (!base) return;
|
|
1140
1214
|
const b0 = base.find((r) => r.id === body.initiative);
|
|
1141
1215
|
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404, `no initiative ${body.initiative} on this board`);
|
|
1216
|
+
// the + on a stage of the Tasks list (batch 18 item 16): the task goes under that stage
|
|
1217
|
+
if (body.section != null) {
|
|
1218
|
+
if (typeof body.section !== 'string' || body.section.length > 80) return fail(ctx, res, 400, "section is a stage key of the initiative's workflow, or '' for Not in a stage");
|
|
1219
|
+
const st = boardRow(p.board, b0, p.fr.folded).wfStages || [];
|
|
1220
|
+
if (body.section && !st.some((x) => x.key === body.section)) return fail(ctx, res, 400, `"${body.section}" is not a stage of this initiative's workflow: one of ${st.map((x) => x.key).join(', ')}, or ''`);
|
|
1221
|
+
}
|
|
1142
1222
|
const id = `task-${crypto.randomBytes(5).toString('hex')}`;
|
|
1143
1223
|
const start = body.start || (body.due && body.due < B.shiftDay(today(), 1) ? body.due : B.shiftDay(today(), 1));
|
|
1144
1224
|
const due = body.due || B.shiftDay(start, 7);
|
|
1145
1225
|
append(p.file, g.actor, { kind: 'task', board: p.board.id, task: id, type: body.type || 'Task', initiative: body.initiative, title: body.title.trim(), epic: body.epic ? String(body.epic).trim() : null,
|
|
1146
1226
|
owner: body.owner ? String(body.owner).trim() : actorLib.pageName(g.actor.by), state: 'To do', start, due, ...(body.notes && body.notes.trim() ? { notes: body.notes.replace(/\s+$/, '') } : {}) });
|
|
1227
|
+
if (typeof body.section === 'string') append(p.file, g.actor, { kind: 'task-section', board: p.board.id, task: id, section: body.section, why: body.section ? 'placed under ' + body.section : 'placed under no stage' });
|
|
1147
1228
|
const t = B.taskOf(B.fold(readLedger(ctx, p.w)), id);
|
|
1148
1229
|
ctx.json(res, { ok: true, item: B.rollupItems([B.taskItem(t)])[0] });
|
|
1149
1230
|
},
|
|
1231
|
+
'/api/boards/tasks/order': (ctx, res, body, g) => {
|
|
1232
|
+
// the PM's order inside one stage (batch 18 item 16): a drag in the Tasks list writes the stage's open tasks top to bottom; [] takes it out
|
|
1233
|
+
const p = postFrame(ctx, res, body);
|
|
1234
|
+
if (!p) return;
|
|
1235
|
+
if (typeof body.initiative !== 'string' || !body.initiative) return fail(ctx, res, 400, 'initiative is required');
|
|
1236
|
+
if (typeof body.section !== 'string' || body.section.length > 80) return fail(ctx, res, 400, "section is a stage key of the initiative's workflow, or '' for Not in a stage");
|
|
1237
|
+
if (!Array.isArray(body.tasks) || body.tasks.length > 500 || body.tasks.some((x) => typeof x !== 'string' || !x || x.length > 120)) return fail(ctx, res, 400, 'tasks is a list of at most 500 task ids, top to bottom');
|
|
1238
|
+
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1239
|
+
const base = needRows(ctx, res, p.w);
|
|
1240
|
+
if (!base) return;
|
|
1241
|
+
const b0 = base.find((r) => r.id === body.initiative);
|
|
1242
|
+
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404, `no initiative ${body.initiative} on this board`);
|
|
1243
|
+
const O0 = p.fr.folded.orders || new Map(), from = O0.get(body.initiative + '\u0000' + body.section) || [];
|
|
1244
|
+
const tasks = [...new Set(body.tasks)];
|
|
1245
|
+
append(p.file, g.actor, { kind: 'task-order', board: p.board.id, initiative: body.initiative, section: body.section, tasks, why: tasks.length ? 'reordered under ' + (body.section || 'no stage') : 'order taken out' });
|
|
1246
|
+
ctx.json(res, { ok: true, from });
|
|
1247
|
+
},
|
|
1150
1248
|
'/api/boards/tasks/state': (ctx, res, body, g) => {
|
|
1151
1249
|
const p = postFrame(ctx, res, body);
|
|
1152
1250
|
if (!p) return;
|
|
@@ -1500,7 +1598,7 @@ const WRITES = {
|
|
|
1500
1598
|
async function handle(req, res, url, ctx) {
|
|
1501
1599
|
const p = url.pathname;
|
|
1502
1600
|
if (req.method === 'GET') {
|
|
1503
|
-
if (p === '/api/boards') { ctx.json(res, portfolio(ctx)); return true; }
|
|
1601
|
+
if (p === '/api/boards') { ctx.json(res, portfolio(ctx, { names: url.searchParams.get('names') === '1' })); return true; }
|
|
1504
1602
|
const fn = READS[p];
|
|
1505
1603
|
if (!fn) return fail(ctx, res, 404, 'not found');
|
|
1506
1604
|
fn(ctx, res, url);
|
|
@@ -213,7 +213,9 @@ function build(query, deps = {}) {
|
|
|
213
213
|
|
|
214
214
|
function notesAdapter(runtimeDir) {
|
|
215
215
|
let notes; try { notes = require('./notes.js'); } catch { return {}; }
|
|
216
|
-
|
|
216
|
+
// one list per adapter: lastBefore asks once per meeting of the day, and the list is the same for all of them (page-speed)
|
|
217
|
+
let listed = null;
|
|
218
|
+
const rows = () => { if (listed) return listed; try { const l = notes.list(runtimeDir); listed = l && l.ok ? l.notes.filter((n) => !n.private) : []; } catch { listed = []; } return listed; };
|
|
217
219
|
let links = null;
|
|
218
220
|
return {
|
|
219
221
|
linkOf: (e) => {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* (scripts/calendar-import.js through scripts/trust/import-guard.js). Writes pass pm-guard requirePagePress, so an agent
|
|
11
11
|
* token is refused (403). readEvents(runtimeDir) is for routes-calendar-views.js.
|
|
12
12
|
* File: <runtime>/calendar-import/events.jsonl (append only, scripts/trust/ledger.js). */
|
|
13
|
+
const fs = require('fs');
|
|
13
14
|
const path = require('path');
|
|
14
15
|
const guard = require('./pm-guard.js');
|
|
15
16
|
const { repoScript } = require('./repo-script.js');
|
|
@@ -19,7 +20,18 @@ const L = require(repoScript('trust/ledger.js'));
|
|
|
19
20
|
const fileOf = (runtimeDir) => path.join(runtimeDir, 'calendar-import', 'events.jsonl');
|
|
20
21
|
const fail = (status, error) => ({ status, body: { ok: false, error } });
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
// The fold is kept until the ledger's size or time changes (page-speed): Home, Your day and the calendar read it on every load. The
|
|
24
|
+
// events are shared, so a caller must copy before it changes one (calendar-events.js readAll does).
|
|
25
|
+
const folds = new Map(); // file -> { sig, events }
|
|
26
|
+
function readEvents(runtimeDir) {
|
|
27
|
+
const f = fileOf(runtimeDir);
|
|
28
|
+
let sig = 'none'; try { const st = fs.statSync(f); sig = st.size + ':' + st.mtimeMs + ':' + st.ino; } catch { /* no ledger yet */ }
|
|
29
|
+
const hit = folds.get(f);
|
|
30
|
+
if (hit && hit.sig === sig) return hit.events;
|
|
31
|
+
const events = CI.foldEvents(CI.readLines(f));
|
|
32
|
+
folds.set(f, { sig, events });
|
|
33
|
+
return events;
|
|
34
|
+
}
|
|
23
35
|
|
|
24
36
|
function list(runtimeDir) { return { status: 200, body: { ok: true, events: readEvents(runtimeDir) } }; }
|
|
25
37
|
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
* tick(ctx, now) drafts each weekly that is due (skipped in a week where nothing moved), each checkpoint and Did it work? at its
|
|
17
17
|
* moment, and a heads-up for a broken health budget or a critical slip. server.js runs it after the setups tick.
|
|
18
18
|
*
|
|
19
|
-
* SEND IS ISSUE. PMOS sends nothing outward: Send on a report row is the
|
|
20
|
-
* so every row with a document carries cadence, slot, sha and path.
|
|
21
|
-
*
|
|
19
|
+
* SEND IS ISSUE. PMOS sends nothing outward: Send on a report row is the Issue press, POST /api/report/issue { ws, cadence, slot, sha },
|
|
20
|
+
* so every row with a document carries cadence, slot, sha and path. A calm week's weekly (RR.autoOk: no miss, no decision, nothing off plan) goes by
|
|
21
|
+
* itself (Wawan 2026-10-28, "Calm weeks send themselves"): the tick issues it 10 minutes after its time as the schedule (agent:unknown, D98), unless
|
|
22
|
+
* the PM held it or turned "Send by itself" off for that report, and writes an `auto-sent` line so its row says "Sent … by itself". A busy week still
|
|
23
|
+
* waits for the PM's press.
|
|
22
24
|
* Every POST passes pm-guard requirePagePress. With no state folder the reads answer and the writes answer 409. */
|
|
23
25
|
const fs = require('fs');
|
|
24
26
|
const path = require('path');
|
|
@@ -180,7 +182,10 @@ function reportRows(w, X) {
|
|
|
180
182
|
let sha = null; try { sha = issues.blobSha(fs.readFileSync(path.join(abs, x.path))); } catch { sha = null; }
|
|
181
183
|
const d = setup ? setup.drafted.find((y) => y.slot === x.slot) : null;
|
|
182
184
|
let md = ''; try { md = fs.readFileSync(path.join(abs, x.path), 'utf8'); } catch { md = ''; }
|
|
183
|
-
|
|
185
|
+
const key = RR.keyOf(setup.ready.scope, setup.ready.kind);
|
|
186
|
+
// auto: a calm weekly that goes by itself, or, once issued, one the schedule sent by itself (batch 17 item 6)
|
|
187
|
+
const auto = x.issued ? X.st.autoSent.has(key + '|' + x.slot) : setup.ready.kind === 'weekly' && RR.autoOn(X.st, key) && RR.autoOk(md);
|
|
188
|
+
return { slot: x.slot, path: x.path, issued: x.issued, sha, draftSha: d ? d.sha || null : null, auto };
|
|
184
189
|
});
|
|
185
190
|
docsBy.set(id, list);
|
|
186
191
|
return list;
|
|
@@ -410,6 +415,8 @@ async function tickScope(ctx, w, s, now, cache = null) {
|
|
|
410
415
|
if (!moved) { RR.append(RR.ledgerFile(stateDir(w)), { ev: 'quiet', key: RR.keyOf(s.scope, 'weekly'), slot }, { now }); out.push({ scope: s.scope, kind: 'weekly', slot, ok: true, why: 'quiet' }); }
|
|
411
416
|
else { const r = await SR.draftIntelligence(ctx, w, wk, slot, { model: X.model, now, ready: extras(X) }); out.push({ scope: s.scope, kind: 'weekly', slot, ...r }); }
|
|
412
417
|
}
|
|
418
|
+
// a calm weekly goes by itself 10 minutes after its time (batch 17 item 6)
|
|
419
|
+
if (wk && wk.status === 'active' && wk.drafted.length) out.push(...autoSend(w, wk, st, s.scope, X, now));
|
|
413
420
|
const items = X.row ? (X.f.checklist || []) : [];
|
|
414
421
|
for (const m of RR.momentsOf(P.level, { today, row: X.row, rows: X.rows, program: X.program, checklist: items, quarterEnd: RR.quarterEndOf(today) })) {
|
|
415
422
|
const key = RR.keyOf(s.scope, m.kind);
|
|
@@ -436,6 +443,22 @@ async function tickScope(ctx, w, s, now, cache = null) {
|
|
|
436
443
|
}
|
|
437
444
|
return out;
|
|
438
445
|
}
|
|
446
|
+
/** Issue the newest drafted weekly when it is calm and its time + 10 minutes has passed. → [{ scope, kind, slot, ok, why: 'auto-sent' | error }] */
|
|
447
|
+
function autoSend(w, wk, st, scope, X, now) {
|
|
448
|
+
const last = wk.drafted[wk.drafted.length - 1];
|
|
449
|
+
if (!last || !last.path) return [];
|
|
450
|
+
const key = RR.keyOf(scope, 'weekly');
|
|
451
|
+
const done = issues.readIssues(w.root);
|
|
452
|
+
const issued = issues.isIssued(done, wk.id, last.slot);
|
|
453
|
+
let md = '', sha = null;
|
|
454
|
+
try { const buf = fs.readFileSync(path.join(path.resolve(w.root), last.path)); md = buf.toString('utf8'); sha = issues.blobSha(buf); } catch { return []; }
|
|
455
|
+
const auto = RR.autoOn(st, key) && RR.autoOk(md);
|
|
456
|
+
if (!RR.autoDue({ slot: last.slot, issued, auto }, { time: (RS.scheduleOf(wk) || {}).time, now: now.getTime(), hold: st.holds.get(key + '|' + last.slot), stale: X.f && X.f.stale })) return [];
|
|
457
|
+
const r = issues.appendFromSchedule(w.root, [{ ev: 'issued', cadence: wk.id, slot: last.slot, path: last.path, sha }], { now: now.getTime() });
|
|
458
|
+
if (!r.ok) return [{ scope, kind: 'weekly', slot: last.slot, ok: false, error: r.error }];
|
|
459
|
+
RR.append(RR.ledgerFile(stateDir(w)), { ev: 'auto-sent', key, slot: last.slot }, { now });
|
|
460
|
+
return [{ scope, kind: 'weekly', slot: last.slot, ok: true, why: 'auto-sent' }];
|
|
461
|
+
}
|
|
439
462
|
/** The sections a ready report adds: milestones (a program), the tickets closed this week, the products not read, the held source's note. */
|
|
440
463
|
function readyExtras(X) {
|
|
441
464
|
const S = RR.stageOf(X.P.level, { today: X.f.today, row: X.row, rows: X.rows, jira: X.row ? X.f.jiraOf[X.row.id] : null, jiraOf: X.f.jiraOf, program: X.program, intel: X.model, kept: X.f.kept, multi: X.f.products.length > 1 });
|
|
@@ -452,4 +475,4 @@ function headsUpMd(setup, h, today) {
|
|
|
452
475
|
`Source: ${h.why === 'budget' ? 'the health budget readings' : 'the Jira tickets and the promise date'}, read ${today}.`, ''].join('\n');
|
|
453
476
|
}
|
|
454
477
|
|
|
455
|
-
module.exports = { prefixes: ['/api/ready-reports'], handle, tick, factsFor, readyExtras, ensureSetup };
|
|
478
|
+
module.exports = { prefixes: ['/api/ready-reports'], handle, tick, factsFor, readyExtras, ensureSetup, autoSend };
|
|
@@ -255,8 +255,19 @@ function namedIn(text, tasks) {
|
|
|
255
255
|
}
|
|
256
256
|
return best;
|
|
257
257
|
}
|
|
258
|
-
/** The PRD's sentences that say an order: "B once A", "B after A", "after A, B", "B with A". → [{ from, to, type, text }]
|
|
258
|
+
/** The PRD's sentences that say an order: "B once A", "B after A", "after A, B", "B with A". → [{ from, to, type, text }]
|
|
259
|
+
* PURE, so the answer for the same text and the same task titles is kept: the Board asks for every initiative on every read. */
|
|
260
|
+
const prdMemo = new Map();
|
|
259
261
|
function prdOrders(text, tasks) {
|
|
262
|
+
const key = String(text || '') + '\u0000' + JSON.stringify((tasks || []).map((t) => [t.uid, t.title]));
|
|
263
|
+
const hit = prdMemo.get(key);
|
|
264
|
+
if (hit) return hit.map((x) => ({ ...x }));
|
|
265
|
+
const out = prdOrdersRead(text, tasks);
|
|
266
|
+
if (prdMemo.size > 500) prdMemo.clear();
|
|
267
|
+
prdMemo.set(key, out.map((x) => ({ ...x })));
|
|
268
|
+
return out;
|
|
269
|
+
}
|
|
270
|
+
function prdOrdersRead(text, tasks) {
|
|
260
271
|
const out = [];
|
|
261
272
|
const body = String(text || '').replace(/^---\n[\s\S]*?\n---\n?/, '').replace(/[`*_>#|]/g, ' ');
|
|
262
273
|
for (const raw of body.split(/(?<=[.!?;])\s+|\n+/)) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* library(stateDir) → the folded library (scripts/workflows.js fold)
|
|
5
5
|
* save(stateDir, { wf, moveRemoved }, actor, { standing }) → { ok, workflow, moved } | { ok:false, status, error, inUse? }
|
|
6
6
|
* copy(stateDir, id, name, actor) → { ok, workflow }
|
|
7
|
+
* adopt(stateDir, wf, actor, fromWs) → { ok, workflow } another workspace's workflow written into this library
|
|
7
8
|
* archive(stateDir, id, archived, actor, { inUse }) → { ok }
|
|
8
9
|
* saveDraft(stateDir, { draft, note }, actor) → { ok, draft } (the chat's draft; null clears it)
|
|
9
10
|
* readDraft(stateDir) → { draft, note, at } | null
|
|
@@ -63,7 +64,7 @@ function copy(stateDir, id, name, actor) {
|
|
|
63
64
|
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
64
65
|
const lib = library(stateDir);
|
|
65
66
|
const src = lib.byId.get(id);
|
|
66
|
-
if (!src) return { ok: false, status: 404, error:
|
|
67
|
+
if (!src) return { ok: false, status: 404, error: 'That workflow could not be found. It may have been removed.' };
|
|
67
68
|
const wf = W.copyOf(src, name, new Set(lib.byId.keys()));
|
|
68
69
|
const c = W.check(wf);
|
|
69
70
|
if (!c.ok) return c;
|
|
@@ -71,11 +72,21 @@ function copy(stateDir, id, name, actor) {
|
|
|
71
72
|
return { ok: true, workflow: c.workflow };
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
/** An initiative here switches to a workflow saved in another workspace's library: the same definition (same id) is saved here. */
|
|
76
|
+
function adopt(stateDir, wf, actor, fromWs) {
|
|
77
|
+
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
78
|
+
if (!wf || wf.id === W.PRODUCT_FEATURE_ID) return { ok: true, workflow: wf };
|
|
79
|
+
const c = W.check({ id: wf.id, name: wf.name, icon: wf.icon, decide: wf.decide, stages: wf.stages });
|
|
80
|
+
if (!c.ok) return c;
|
|
81
|
+
append(fileOf(stateDir), actor, { kind: 'wf-save', wf: c.workflow, ...(fromWs ? { adoptedFrom: fromWs } : {}) });
|
|
82
|
+
return { ok: true, workflow: c.workflow };
|
|
83
|
+
}
|
|
84
|
+
|
|
74
85
|
function archive(stateDir, id, archived, actor, { inUse = [] } = {}) {
|
|
75
86
|
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
76
87
|
if (id === W.PRODUCT_FEATURE_ID) return { ok: false, status: 409, error: 'Product feature is built in and stays.' };
|
|
77
88
|
const lib = library(stateDir);
|
|
78
|
-
if (!lib.byId.has(id)) return { ok: false, status: 404, error:
|
|
89
|
+
if (!lib.byId.has(id)) return { ok: false, status: 404, error: 'That workflow could not be found. It may have been removed.' };
|
|
79
90
|
if (archived && inUse.length) return { ok: false, status: 409, error: `${inUse.length} ${inUse.length === 1 ? 'initiative runs' : 'initiatives run'} this workflow. Move ${inUse.length === 1 ? 'it' : 'them'} to another workflow first.`, inUse };
|
|
80
91
|
append(fileOf(stateDir), actor, { kind: 'wf-archive', id, archived: !!archived });
|
|
81
92
|
return { ok: true };
|
|
@@ -105,4 +116,4 @@ function judge(stateDir, { board, id, stage, runs, why, cite, undo } = {}, actor
|
|
|
105
116
|
return { ok: true };
|
|
106
117
|
}
|
|
107
118
|
|
|
108
|
-
module.exports = { FILE, library, save, copy, archive, saveDraft, readDraft, judge, fileOf };
|
|
119
|
+
module.exports = { FILE, library, save, copy, adopt, archive, saveDraft, readDraft, judge, fileOf };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* live-pill-round-test.js — the Live pill as a round number, the panel divider's look and the list head's fold (feedback batch 18 item 15,
|
|
4
|
+
* slice 15-B; canvas TbT1Split, TbT4Off, TbT9Divider; brief next18/briefs/15-arrange-panels-build.md rules 9 to 11). The real pages from the
|
|
5
|
+
* real server; GET /api/live is answered by the suite, so the pill's state is the suite's.
|
|
6
|
+
* L1 nothing live: no pill · L2 the pill is a 44 px round button stacked above the menu button, with the number of live items and no marks
|
|
7
|
+
* L3 Claude asks: blue with a glow · L4 with the panels engine a press goes to czPanels.slideOver(item) · L6 false from it: today's open
|
|
8
|
+
* L5 the open menu hides the pill · V1 the first divider wears the sprout, the others only the handle · V2 the day's charm replaces the
|
|
9
|
+
* sprout, fitted to its box · V3 Settings > Adler > Off: the handle only · F1 Home's list head folds the list, and the button brings it back
|
|
10
|
+
* F2 a phone: no fold · every page: no page error
|
|
11
|
+
* PMOS_SHOTS=<dir> also saves the screenshots. */
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const { spawn } = require('child_process');
|
|
15
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
16
|
+
const T = require('./test-run').configure({ name: 'live-pill-round' });
|
|
17
|
+
|
|
18
|
+
const BASE = T.BASE;
|
|
19
|
+
const SHOTS = process.env.PMOS_SHOTS || '';
|
|
20
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
21
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
22
|
+
const results = [];
|
|
23
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
|
|
24
|
+
let srv = null; let browser = null;
|
|
25
|
+
const finish = async (code) => {
|
|
26
|
+
if (browser) await browser.close().catch(() => {});
|
|
27
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
28
|
+
T.killTmux();
|
|
29
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
30
|
+
console.log(`\n${results.length - bad}/${results.length} live-pill-round assertions passed`);
|
|
31
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
32
|
+
};
|
|
33
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
34
|
+
|
|
35
|
+
const min = (n) => new Date(Date.now() - n * 60000).toISOString();
|
|
36
|
+
const RUNNING = () => [
|
|
37
|
+
{ id: 'a', name: 'chat: Draft CIAM tender workflow', shown: 'working', created: min(90), touched_at: min(4), origin: 'chat:init:tender' },
|
|
38
|
+
{ id: 'd', name: 'List migration tasks', shown: 'working', created: min(200), touched_at: min(25) },
|
|
39
|
+
];
|
|
40
|
+
const ASKS = () => RUNNING().concat([{ id: 'b', name: 'Redistribute plan items', shown: 'needs', created: min(80), touched_at: min(1), initiative: 'tender' }]);
|
|
41
|
+
|
|
42
|
+
(async () => {
|
|
43
|
+
const exe = process.env.PMOS_CHROME || findBrowser();
|
|
44
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the live-pill-round suite cannot run'); return finish(1); }
|
|
45
|
+
let chromium;
|
|
46
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
47
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
48
|
+
await T.waitForServer(BASE);
|
|
49
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
50
|
+
if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
|
|
51
|
+
const shot = async (page, name) => { if (SHOTS) { await sleep(300); await page.screenshot({ path: path.join(SHOTS, name + '.png') }); } };
|
|
52
|
+
|
|
53
|
+
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
|
54
|
+
let live = [];
|
|
55
|
+
await ctx.route('**/api/live', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, sessions: live, titles: { tender: 'Tender new CIAM' } }) }));
|
|
56
|
+
const page = await ctx.newPage();
|
|
57
|
+
const errors = [];
|
|
58
|
+
page.on('pageerror', (e) => errors.push(String(e)));
|
|
59
|
+
const kick = () => page.evaluate(() => document.dispatchEvent(new Event('cz:live')));
|
|
60
|
+
|
|
61
|
+
/* L1 */
|
|
62
|
+
await page.goto(BASE + '/premium-board.html');
|
|
63
|
+
await until(() => page.evaluate(() => !!document.getElementById('czLive')), 30000);
|
|
64
|
+
await sleep(500);
|
|
65
|
+
ok('L1 nothing live: no pill (zero is silence)', await page.evaluate(() => document.getElementById('czLive').hidden));
|
|
66
|
+
|
|
67
|
+
/* L2 */
|
|
68
|
+
live = RUNNING(); await kick();
|
|
69
|
+
const l2 = await until(() => page.evaluate(() => {
|
|
70
|
+
const l = document.getElementById('czLive'), f = document.getElementById('czFab'); if (!l || l.hidden) return null;
|
|
71
|
+
const a = l.getBoundingClientRect(), b = f.getBoundingClientRect();
|
|
72
|
+
return { text: l.textContent.trim(), w: Math.round(a.width), h: Math.round(a.height), round: getComputedStyle(l).borderRadius, marks: l.querySelectorAll('.lv-m').length,
|
|
73
|
+
above: a.bottom <= b.top, centred: Math.abs((a.left + a.width / 2) - (b.left + b.width / 2)) <= 1, label: l.getAttribute('aria-label'), asks: l.classList.contains('asks') };
|
|
74
|
+
}));
|
|
75
|
+
ok('L2 the pill shows the number of live items and no marks', l2 && l2.text === '2' && l2.marks === 0 && !l2.asks, JSON.stringify(l2));
|
|
76
|
+
ok('L2 it is a 44 px round button, stacked above the menu button on its centre line', l2 && l2.w === 44 && l2.h === 44 && l2.round === '50%' && l2.above && l2.centred, JSON.stringify(l2));
|
|
77
|
+
ok('L2 its name still says what it holds and its key', l2 && /^What you work on now: 2 running\. Open \(Ctrl J\)$/.test(l2.label), l2 && l2.label);
|
|
78
|
+
await shot(page, 'pill-running');
|
|
79
|
+
|
|
80
|
+
/* L3 */
|
|
81
|
+
live = ASKS(); await kick();
|
|
82
|
+
const l3 = await until(() => page.evaluate(() => { const l = document.getElementById('czLive'); return l && l.classList.contains('asks') ? { text: l.textContent.trim(), bg: getComputedStyle(l).backgroundColor, card: getComputedStyle(document.body).getPropertyValue('--cz-card') } : null; }));
|
|
83
|
+
ok('L3 Claude asks: the pill turns blue, with the count', l3 && l3.text === '3' && !/255, 255, 255/.test(l3.bg), JSON.stringify(l3));
|
|
84
|
+
await shot(page, 'pill-asks');
|
|
85
|
+
|
|
86
|
+
/* L4 */
|
|
87
|
+
await page.click('#czLive');
|
|
88
|
+
const rows = await until(() => page.evaluate(() => { const r = [...document.querySelectorAll('#czLiveList a[data-lv]')]; return r.length ? r.length : null; }));
|
|
89
|
+
ok('L4 the list opens with its rows (the panels engine drags a[data-lv] to an edge)', rows === 3, String(rows));
|
|
90
|
+
await shot(page, 'pill-list');
|
|
91
|
+
await page.evaluate(() => { window.__slid = []; window.czPanels = { slideOver: (x) => window.__slid.push(x), list: () => [] }; });
|
|
92
|
+
const before = page.url();
|
|
93
|
+
await page.click('#czLiveList a[data-lv="s:b"]');
|
|
94
|
+
const l4 = await until(() => page.evaluate(() => (window.__slid && window.__slid.length ? { id: window.__slid[0].id, sid: window.__slid[0].sid, open: !document.getElementById('czLiveList').hidden } : null)));
|
|
95
|
+
ok('L4 with the panels engine, a row goes to czPanels.slideOver(item) and the list closes; the page stays', l4 && l4.id === 's:b' && l4.sid === 'b' && !l4.open && page.url() === before, JSON.stringify(l4));
|
|
96
|
+
await page.evaluate(() => { delete window.czPanels; });
|
|
97
|
+
|
|
98
|
+
/* L5 */
|
|
99
|
+
await page.click('#czFab');
|
|
100
|
+
ok('L5 the open menu takes the place above the menu button: the pill hides', await until(() => page.evaluate(() => getComputedStyle(document.getElementById('czLive')).visibility === 'hidden')));
|
|
101
|
+
await page.keyboard.press('Escape');
|
|
102
|
+
await page.evaluate(() => { const m = document.getElementById('czMenu'); if (m && !m.hidden) document.getElementById('czFab').click(); });
|
|
103
|
+
|
|
104
|
+
/* V1–V3: the divider, mounted the way the engine mounts it */
|
|
105
|
+
const v1 = await page.evaluate(async () => {
|
|
106
|
+
const D = await import('/pm/cozy-divider.js'), A = await import('/pm/cozy-adler.js');
|
|
107
|
+
A.setPrefs({ 'adler.amount': 'full' }); A.setDress(null);
|
|
108
|
+
const box = document.createElement('div'); box.id = 'dvTest'; box.style.cssText = 'position:fixed;left:200px;top:100px;width:600px;height:400px;display:flex;gap:12px;z-index:99';
|
|
109
|
+
// as cozy-panels.js mounts it: a 0-wide separator, and the look inside a wrapper centred on it
|
|
110
|
+
const div = (first) => `<div class="cz-pn-div" role="separator" tabindex="0" style="position:relative;width:0;margin:0 -6px"><span class="cz-pn-in" style="position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)">${D.dividerHtml({ first })}</span></div>`;
|
|
111
|
+
box.innerHTML = `<div style="flex:1;background:var(--cz-card)"></div>${div(true)}<div style="flex:1;background:var(--cz-card)"></div>${div(false)}<div style="flex:1;background:var(--cz-card)"></div>`;
|
|
112
|
+
document.body.appendChild(box);
|
|
113
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
114
|
+
const [a, b] = box.querySelectorAll('.cz-pn-div'), hd = a.querySelector('.cz-dv-hd').getBoundingClientRect(), dv = a.getBoundingClientRect();
|
|
115
|
+
const sp = a.querySelector('.cz-dv-top .cz-dv-sp'), spr = sp && sp.getBoundingClientRect();
|
|
116
|
+
return { dots: a.querySelectorAll('.cz-dv-hd b').length, sprout: !!sp, second: !b.querySelector('.cz-dv-top'), hidden: a.querySelector('.cz-dv-top').getAttribute('aria-hidden'),
|
|
117
|
+
centred: Math.abs((hd.left + hd.width / 2) - (dv.left + dv.width / 2)) <= 1 && Math.abs((hd.top + hd.height / 2) - (dv.top + dv.height / 2)) <= 1,
|
|
118
|
+
onTop: !!spr && spr.bottom <= hd.top + 1 && Math.abs((spr.left + spr.width / 2) - (hd.left + hd.width / 2)) <= 2, face: !!a.querySelector('.ad-face') };
|
|
119
|
+
});
|
|
120
|
+
ok('V1 the first divider: a handle with 3 dots in its middle, and Adler\'s sprout on top (never his face)', v1.dots === 3 && v1.sprout && v1.centred && v1.onTop && !v1.face && v1.hidden === 'true', JSON.stringify(v1));
|
|
121
|
+
ok('V1 any other divider: the handle only', v1.second, JSON.stringify(v1));
|
|
122
|
+
const hov = await page.evaluate(async () => { const a = document.querySelector('#dvTest .cz-pn-div'), hd = a.querySelector('.cz-dv-hd'); const rest = getComputedStyle(hd).backgroundColor; a.classList.add('hov'); await new Promise((r) => setTimeout(r, 250)); const on = getComputedStyle(hd).backgroundColor; const lf = getComputedStyle(a.querySelector('.cz-dv-lf.l1')).transform; a.classList.remove('hov'); a.classList.add('drag'); await new Promise((r) => setTimeout(r, 300)); const lean = getComputedStyle(a.querySelector('.cz-dv-sp')).transform; a.classList.remove('drag'); return { rest, on, lf, lean }; });
|
|
123
|
+
ok('V1 hover turns the handle blue and opens the leaves; a drag leans the sprout (the engine draws the line)', hov.rest !== hov.on && hov.lf !== 'none' && hov.lean !== 'none', JSON.stringify(hov));
|
|
124
|
+
await page.evaluate(() => document.querySelector('#dvTest .cz-pn-div').classList.add('hov'));
|
|
125
|
+
await shot(page, 'divider-sprout-hover');
|
|
126
|
+
await page.evaluate(() => document.querySelector('#dvTest .cz-pn-div').classList.remove('hov'));
|
|
127
|
+
const v2 = await page.evaluate(async () => {
|
|
128
|
+
const A = await import('/pm/cozy-adler.js');
|
|
129
|
+
A.setDress({ key: 'deepavali', name: 'Deepavali' });
|
|
130
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
131
|
+
const t = document.querySelector('#dvTest .cz-dv-top'), s = t.querySelector('.cz-dv-ch svg');
|
|
132
|
+
return { charm: t.querySelector('.cz-dv-ch') && t.querySelector('.cz-dv-ch').dataset.charm, sprout: !!t.querySelector('.cz-dv-sp'), fitted: !!s && !s.hasAttribute('data-ad-fit'), box: s && s.getAttribute('viewBox'), w: s && Math.round(s.getBoundingClientRect().width), second: !document.querySelectorAll('#dvTest .cz-pn-div')[1].querySelector('.cz-dv-top') };
|
|
133
|
+
});
|
|
134
|
+
ok('V2 the day\'s charm (Deepavali) sits there instead of the sprout, fitted to its 26 px box, first divider only', v2.charm === 'deepavali' && !v2.sprout && v2.fitted && v2.w === 26 && v2.second, JSON.stringify(v2));
|
|
135
|
+
await shot(page, 'divider-charm');
|
|
136
|
+
const v3 = await page.evaluate(async () => {
|
|
137
|
+
const A = await import('/pm/cozy-adler.js');
|
|
138
|
+
A.setPrefs({ 'adler.amount': 'face' }); await new Promise((r) => setTimeout(r, 100));
|
|
139
|
+
const face = { sprout: !!document.querySelector('#dvTest .cz-dv-sp'), charm: !!document.querySelector('#dvTest .cz-dv-ch') };
|
|
140
|
+
A.setPrefs({ 'adler.amount': 'off' }); await new Promise((r) => setTimeout(r, 100));
|
|
141
|
+
const off = document.querySelector('#dvTest .cz-dv-top').innerHTML === '' && document.querySelectorAll('#dvTest .cz-dv-hd').length === 2;
|
|
142
|
+
A.setPrefs({ 'adler.amount': 'full' }); A.setDress(null); document.getElementById('dvTest').remove();
|
|
143
|
+
return { face, off };
|
|
144
|
+
});
|
|
145
|
+
ok('V3 Settings > Adler > Face only: the sprout, no charm; Off: the handle only', v3.face.sprout && !v3.face.charm && v3.off, JSON.stringify(v3));
|
|
146
|
+
|
|
147
|
+
/* L6 */
|
|
148
|
+
await page.evaluate(() => { window.czPanels = { slideOver: () => false, list: () => [] }; });
|
|
149
|
+
await page.click('#czLive');
|
|
150
|
+
await until(() => page.$('#czLiveList a[data-lv="s:b"]'));
|
|
151
|
+
await Promise.all([page.waitForURL(/premium\.html\?session=b/, { timeout: 15000 }).catch(() => null), page.click('#czLiveList a[data-lv="s:b"]')]);
|
|
152
|
+
ok('L6 czPanels.slideOver(item) gives false (it did nothing): the row opens as today', /premium\.html\?session=b/.test(page.url()), page.url());
|
|
153
|
+
|
|
154
|
+
/* F1 */
|
|
155
|
+
await page.goto(BASE + '/premium.html');
|
|
156
|
+
const f1 = await until(() => page.evaluate(() => { const b = document.querySelector('#hmList .hm-hd [data-hm-fold]'); return b ? { label: b.getAttribute('aria-label'), title: b.title, text: b.textContent.trim(), svg: !!b.querySelector('svg') } : null; }), 30000);
|
|
157
|
+
ok('F1 the list head has an icon-only fold, named and with a tooltip', f1 && f1.label === 'Fold the list to the rail' && f1.title === f1.label && !f1.text && f1.svg, JSON.stringify(f1));
|
|
158
|
+
await shot(page, 'home-fold');
|
|
159
|
+
await page.click('#hmList .hm-hd [data-hm-fold]');
|
|
160
|
+
ok('F1 with no Viewer open, the press folds the list away', await until(() => page.evaluate(() => document.body.classList.contains('hm-folded') && getComputedStyle(document.querySelector('#hmList')).display === 'none')));
|
|
161
|
+
await page.click('#hmUnfold');
|
|
162
|
+
ok('F1 the button at the top left brings it back', await until(() => page.evaluate(() => !document.body.classList.contains('hm-folded') && !!document.querySelector('#hmList .hm-hd [data-hm-fold]'))));
|
|
163
|
+
ok('every page: no page error', errors.length === 0, errors.join(' | '));
|
|
164
|
+
|
|
165
|
+
/* F2 */
|
|
166
|
+
const pctx = await browser.newContext({ viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true });
|
|
167
|
+
await pctx.route('**/api/live', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, sessions: ASKS(), titles: {} }) }));
|
|
168
|
+
const ph = await pctx.newPage();
|
|
169
|
+
await ph.goto(BASE + '/premium-board.html');
|
|
170
|
+
const f2 = await until(() => ph.evaluate(() => { const l = document.getElementById('czLive'), f = document.getElementById('czFab'); if (!l || l.hidden) return null; const a = l.getBoundingClientRect(), b = f.getBoundingClientRect(); return { above: a.bottom <= b.top, right: Math.abs((a.left + a.width / 2) - (b.left + b.width / 2)) <= 1, w: Math.round(a.width), text: l.textContent.trim() }; }), 30000);
|
|
171
|
+
ok('F2 a phone: the round pill stacks above the menu button at the bottom right', f2 && f2.above && f2.right && f2.w === 44 && f2.text === '3', JSON.stringify(f2));
|
|
172
|
+
await shot(ph, 'phone-pill');
|
|
173
|
+
await ph.goto(BASE + '/premium.html');
|
|
174
|
+
await until(() => ph.evaluate(() => !!document.querySelector('#hmList .hm-hd')), 30000);
|
|
175
|
+
ok('F2 a phone has no rail, so no fold', await ph.evaluate(() => !document.querySelector('[data-hm-fold]')));
|
|
176
|
+
await pctx.close();
|
|
177
|
+
await finish();
|
|
178
|
+
})();
|