create-pmos 0.712.0 → 0.714.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 +99 -51
- package/payload/KIT-VERSION +1 -1
- package/payload/design-system/ui/README.md +1 -1
- package/payload/design-system/ui/components/State/README.md +21 -0
- package/payload/design-system/ui/components/State/preview.html +8 -0
- package/payload/design-system/ui/components/bundle.css +12 -0
- package/payload/design-system/ui/interactions.md +10 -0
- 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/workspace/bin/back-place-health.js +70 -0
- package/workspace/changelog.json +98 -0
- package/workspace/design-system/ui/README.md +1 -1
- package/workspace/design-system/ui/components/State/README.md +21 -0
- package/workspace/design-system/ui/components/State/preview.html +8 -0
- package/workspace/design-system/ui/components/bundle.css +12 -0
- package/workspace/design-system/ui/interactions.md +10 -0
- package/workspace/guide/breakdown.md +20 -1
- package/workspace/guide/claude-proposes.md +5 -1
- package/workspace/guide/cli.md +10 -1
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/initiatives-and-next-steps.md +13 -0
- package/workspace/guide/layout.md +27 -1
- package/workspace/guide/routine.md +10 -2
- package/workspace/guide/settings-and-switches.md +4 -0
- package/workspace/lib/briefing-premium-products.js +16 -2
- package/workspace/lib/changed-mark.js +34 -0
- package/workspace/lib/launch-cli.js +43 -5
- package/workspace/lib/launch-tiers.js +143 -0
- package/workspace/lib/moments.js +41 -3
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/parked-cli.js +105 -0
- package/workspace/lib/parked-reasons.js +245 -0
- package/workspace/lib/pmos-verbs.js +4 -1
- package/workspace/lib/prefs-sync.js +138 -0
- package/workspace/lib/product-dots.js +60 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-briefing-premium.js +11 -1
- package/workspace/lib/routes-moments.js +1 -1
- package/workspace/lib/routes-prefs.js +56 -0
- package/workspace/lib/routes-strategy-card.js +53 -0
- package/workspace/lib/routes-use-log.js +24 -3
- package/workspace/lib/routine-sentence.js +250 -0
- package/workspace/lib/strategy-card.js +133 -0
- package/workspace/lib/unused-controls.js +178 -0
- package/workspace/lib/use-log.js +27 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-doc-test.js +2 -0
- package/workspace/public/pm/action-keys.js +187 -0
- package/workspace/public/pm/back-place.js +87 -0
- package/workspace/public/pm/bd-pop-ds.css +10 -0
- package/workspace/public/pm/bd-pop-ds.js +27 -3
- package/workspace/public/pm/bd-strategy.js +85 -0
- package/workspace/public/pm/bd-views.js +2 -1
- package/workspace/public/pm/changed-mark.css +7 -0
- package/workspace/public/pm/changed-mark.js +117 -0
- package/workspace/public/pm/cozy-ev.css +7 -0
- package/workspace/public/pm/cozy-nav.js +2 -0
- package/workspace/public/pm/cozy-pick.css +12 -0
- package/workspace/public/pm/cozy-pop-work.css +10 -1
- package/workspace/public/pm/cozy-pop-work.js +201 -17
- package/workspace/public/pm/cozy-routine-job.js +50 -7
- package/workspace/public/pm/cozy-routine.css +2 -0
- package/workspace/public/pm/cozy-settings.js +21 -3
- package/workspace/public/pm/cozy-today-page.css +1 -0
- package/workspace/public/pm/cozy-viewer.css +1 -1
- package/workspace/public/pm/cozy-viewer.js +14 -2
- package/workspace/public/pm/cozy-vw-mtg.css +0 -2
- package/workspace/public/pm/cozy-vw.css +0 -1
- package/workspace/public/pm/home-app.js +21 -1
- package/workspace/public/pm/home-today.js +2 -0
- package/workspace/public/pm/ini-tasks.js +4 -1
- package/workspace/public/pm/komorebi.css +11 -0
- package/workspace/public/pm/page-chat.js +16 -0
- package/workspace/public/pm/prefs-sync.js +111 -0
- package/workspace/public/pm/premium-board.js +20 -2
- package/workspace/public/pm/premium-chart-tab.js +2 -1
- package/workspace/public/pm/premium-insights.js +2 -2
- package/workspace/public/pm/premium-mtg-replay.js +4 -3
- package/workspace/public/pm/premium-report-read.js +5 -4
- package/workspace/public/pm/premium-report-tab.js +4 -3
- package/workspace/public/pm/premium-vw-backlog.css +2 -1
- package/workspace/public/pm/premium-vw-backlog.js +4 -3
- package/workspace/public/pm/premium-vw-cal.css +1 -2
- package/workspace/public/pm/premium-vw-cal.js +14 -13
- package/workspace/public/pm/premium-vw-copies.js +3 -2
- package/workspace/public/pm/premium-vw-copy.css +0 -3
- package/workspace/public/pm/premium-vw-mtg.js +12 -11
- package/workspace/public/pm/product-switcher.js +41 -0
- package/workspace/public/pm/quiet-place.js +15 -2
- package/workspace/public/pm/report-orders-ui.js +2 -1
- package/workspace/public/pm/rp-parts.js +3 -2
- package/workspace/public/pm/state-blocks.js +67 -0
- package/workspace/public/pm/use-log.js +127 -1
- package/workspace/public/pm/work-select.js +92 -2
- package/workspace/public/pm/work-tree.js +70 -0
- package/workspace/public/premium-aud.html +1 -0
- package/workspace/public/premium-board.html +5 -0
- package/workspace/public/premium-buddy.html +1 -0
- package/workspace/public/premium-events.html +1 -0
- package/workspace/public/premium-goals.html +1 -0
- package/workspace/public/premium-intelligence.html +1 -0
- package/workspace/public/premium-library.html +1 -0
- package/workspace/public/premium-present.html +1 -0
- package/workspace/public/premium-rec.html +1 -0
- package/workspace/public/premium-routine.html +1 -0
- package/workspace/public/premium-viewer.html +1 -0
- package/workspace/public/premium-workflows.html +1 -0
- package/workspace/public/today.html +1 -0
- package/workspace/server.js +20 -0
- package/workspace/test-lists/action-keys.json +9 -0
- package/workspace/test-lists/back-place.json +9 -0
- package/workspace/test-lists/changed-mark.json +9 -0
- package/workspace/test-lists/launch-tiers.json +9 -0
- package/workspace/test-lists/parked-reasons.json +9 -0
- package/workspace/test-lists/prefs-follow-person.json +9 -0
- package/workspace/test-lists/product-switcher-dots.json +9 -0
- package/workspace/test-lists/routine-sentence.json +9 -0
- package/workspace/test-lists/shared-empty-states.json +9 -0
- package/workspace/test-lists/strategy-card.json +9 -0
- package/workspace/test-lists/unused-controls.json +9 -0
- package/workspace/test-lists/work-subtasks-followups.json +9 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* unused-controls.js — hide the buttons nobody presses (idea A454, initiative hide-unused-controls). THE ONE STORE and THE ONE RULE.
|
|
4
|
+
* lib/routes-use-log.js does the HTTP; public/pm/use-log.js is the page side (the ✦ suggestion, the Toast with Undo); Settings › General ›
|
|
5
|
+
* Use log lists every hidden button with Show and Show all, so a hidden button is never lost.
|
|
6
|
+
*
|
|
7
|
+
* LOCAL ONLY, like the use log (lib/use-log.js): <runtime>/hidden-controls.json on this computer, never sent. It keeps ids only, never a
|
|
8
|
+
* button's text: an id must match ID_RE and must not be a data- attribute name (those name a whole group of buttons, not one).
|
|
9
|
+
*
|
|
10
|
+
* THE STORE. { v: 1, seen, hidden, declined }
|
|
11
|
+
* seen { [page]: { [id]: { first: 'YYYY-MM-DD', days: ['YYYY-MM-DD'…] } } } the days a page showed the button (last SEEN_KEEP days)
|
|
12
|
+
* hidden [{ page, control, at, shown_at? }] a row with shown_at was shown again (Undo, Show, Show all): kept so re-shows can be counted
|
|
13
|
+
* declined [{ page, control, at }] the user said No: never proposed again
|
|
14
|
+
*
|
|
15
|
+
* THE RULE (proposeOf). A button on a page is proposed only when ALL hold:
|
|
16
|
+
* the use log has lines from WINDOW_DAYS or more days ago (it has watched long enough);
|
|
17
|
+
* the page was opened on MIN_DAYS or more of the last WINDOW_DAYS days;
|
|
18
|
+
* the button was first seen WINDOW_DAYS or more days ago and seen on MIN_DAYS or more of the last WINDOW_DAYS days;
|
|
19
|
+
* it was never pressed on that page in the last WINDOW_DAYS days; it is not hidden now and was not declined.
|
|
20
|
+
* At most MAX_PROPOSE at once.
|
|
21
|
+
*
|
|
22
|
+
* storeFile(dir) · readStore(dir) · cleanIds(list) → ids
|
|
23
|
+
* noteSeen(store, page, ids, now) → changed? PURE on the store object
|
|
24
|
+
* proposeOf({ store, lines, page, now }) → ids PURE
|
|
25
|
+
* hiddenOf(store, page?) → [{ page, control, at }] PURE, the rows hidden now
|
|
26
|
+
* seeAndPropose(dir, page, present, lines, now) → { ok, hidden, propose }
|
|
27
|
+
* hide(dir, page, ids, now) · show(dir, { page, controls } | { all: true }, now) · decline(dir, page, ids, now) · clearSeen(dir)
|
|
28
|
+
* CLI: node lib/unused-controls.js count → the buttons hidden now, on its last line (the health number) */
|
|
29
|
+
const fs = require('fs');
|
|
30
|
+
const path = require('path');
|
|
31
|
+
|
|
32
|
+
const FILE = 'hidden-controls.json';
|
|
33
|
+
const WINDOW_DAYS = 14;
|
|
34
|
+
const MIN_DAYS = 5;
|
|
35
|
+
const MAX_PROPOSE = 12;
|
|
36
|
+
const SEEN_KEEP = 30;
|
|
37
|
+
const MAX_IDS = 300;
|
|
38
|
+
const MAX_SHOWN = 500;
|
|
39
|
+
const DAY = 864e5;
|
|
40
|
+
const ID_RE = /^[A-Za-z][A-Za-z0-9_-]{0,79}$/;
|
|
41
|
+
const PAGE_RE = /^[a-z0-9][a-z0-9._-]{0,59}$/;
|
|
42
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
43
|
+
const say = (s) => { try { console.log('[unused-controls] ' + s); } catch { /* no console */ } };
|
|
44
|
+
const dayOf = (ms) => new Date(ms).toISOString().slice(0, 10);
|
|
45
|
+
|
|
46
|
+
function storeFile(dir) { return dir ? path.join(dir, FILE) : null; }
|
|
47
|
+
const empty = () => ({ v: 1, seen: {}, hidden: [], declined: [] });
|
|
48
|
+
|
|
49
|
+
function readStore(dir) {
|
|
50
|
+
const f = storeFile(dir); if (!f) return empty();
|
|
51
|
+
try {
|
|
52
|
+
const s = JSON.parse(fs.readFileSync(f, 'utf8'));
|
|
53
|
+
if (!isObj(s)) return empty();
|
|
54
|
+
return { v: 1, seen: isObj(s.seen) ? s.seen : {}, hidden: Array.isArray(s.hidden) ? s.hidden.filter(isObj) : [], declined: Array.isArray(s.declined) ? s.declined.filter(isObj) : [] };
|
|
55
|
+
} catch { return empty(); }
|
|
56
|
+
}
|
|
57
|
+
function writeStore(dir, s) {
|
|
58
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
59
|
+
const f = storeFile(dir), tmp = f + '.tmp';
|
|
60
|
+
fs.writeFileSync(tmp, JSON.stringify(s));
|
|
61
|
+
fs.renameSync(tmp, f);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Only ids: a value with text, a URL, an address or a data- attribute name is dropped. At most MAX_IDS, no repeats. */
|
|
65
|
+
function cleanIds(list) {
|
|
66
|
+
if (!Array.isArray(list)) return [];
|
|
67
|
+
const out = new Set();
|
|
68
|
+
for (const v of list) { const s = String(v == null ? '' : v); if (ID_RE.test(s) && !/^data-/i.test(s)) out.add(s); if (out.size >= MAX_IDS) break; }
|
|
69
|
+
return [...out];
|
|
70
|
+
}
|
|
71
|
+
const okPage = (p) => PAGE_RE.test(String(p || ''));
|
|
72
|
+
|
|
73
|
+
/** Note that the page showed these buttons today. Days older than SEEN_KEEP drop off. → true when the store changed. */
|
|
74
|
+
function noteSeen(store, page, ids, now = Date.now()) {
|
|
75
|
+
if (!okPage(page)) return false;
|
|
76
|
+
const today = dayOf(now), cut = dayOf(now - SEEN_KEEP * DAY);
|
|
77
|
+
const P = store.seen[page] = isObj(store.seen[page]) ? store.seen[page] : {};
|
|
78
|
+
let changed = false;
|
|
79
|
+
for (const id of cleanIds(ids)) {
|
|
80
|
+
const r = isObj(P[id]) ? P[id] : (changed = true, P[id] = { first: today, days: [] });
|
|
81
|
+
if (!Array.isArray(r.days)) r.days = [];
|
|
82
|
+
if (!r.days.includes(today)) { r.days.push(today); changed = true; }
|
|
83
|
+
const keep = r.days.filter((d) => d >= cut);
|
|
84
|
+
if (keep.length !== r.days.length) { r.days = keep; changed = true; }
|
|
85
|
+
}
|
|
86
|
+
const ids2 = Object.keys(P);
|
|
87
|
+
if (ids2.length > MAX_IDS) { // keep the ones seen most lately
|
|
88
|
+
const last = (id) => (P[id].days || []).slice(-1)[0] || '';
|
|
89
|
+
ids2.sort((a, b) => (last(a) < last(b) ? -1 : 1)).slice(0, ids2.length - MAX_IDS).forEach((id) => delete P[id]);
|
|
90
|
+
changed = true;
|
|
91
|
+
}
|
|
92
|
+
return changed;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const activeHidden = (store) => store.hidden.filter((h) => !h.shown_at);
|
|
96
|
+
function hiddenOf(store, page) {
|
|
97
|
+
return activeHidden(store).filter((h) => !page || h.page === page).map((h) => ({ page: h.page, control: h.control, at: h.at }));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function proposeOf({ store, lines, page, now = Date.now() }) {
|
|
101
|
+
if (!okPage(page) || !store || !isObj(store.seen) || !isObj(store.seen[page])) return [];
|
|
102
|
+
const since = now - WINDOW_DAYS * DAY, sinceDay = dayOf(since);
|
|
103
|
+
const L = Array.isArray(lines) ? lines : [];
|
|
104
|
+
const oldest = Math.min(...L.map((l) => Date.parse(l && l.at)).filter(Number.isFinite));
|
|
105
|
+
if (!(oldest <= since)) return []; // the use log has not watched for 14 days yet
|
|
106
|
+
const recent = L.filter((l) => Date.parse(l.at) >= since && l.page === page);
|
|
107
|
+
const openDays = new Set(recent.filter((l) => l.kind === 'open').map((l) => l.at.slice(0, 10)));
|
|
108
|
+
if (openDays.size < MIN_DAYS) return []; // a page opened rarely says nothing about its buttons
|
|
109
|
+
const pressed = new Set(recent.filter((l) => l.kind === 'use').map((l) => l.control));
|
|
110
|
+
const off = new Set(activeHidden(store).filter((h) => h.page === page).map((h) => h.control));
|
|
111
|
+
for (const d of store.declined) if (d.page === page) off.add(d.control);
|
|
112
|
+
const out = [];
|
|
113
|
+
for (const [id, r] of Object.entries(store.seen[page])) {
|
|
114
|
+
if (!ID_RE.test(id) || /^data-/i.test(id) || pressed.has(id) || off.has(id) || !isObj(r)) continue;
|
|
115
|
+
if (!(String(r.first || '9') <= sinceDay)) continue; // a new button gets its 14 days
|
|
116
|
+
if ((Array.isArray(r.days) ? r.days.filter((d) => d >= sinceDay) : []).length < MIN_DAYS) continue;
|
|
117
|
+
out.push(id);
|
|
118
|
+
}
|
|
119
|
+
return out.sort().slice(0, MAX_PROPOSE);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function seeAndPropose(dir, page, present, lines, now = Date.now()) {
|
|
123
|
+
if (!dir) return { ok: false, error: 'This workspace has no runtime folder, so PMOS cannot see which buttons go unused.' };
|
|
124
|
+
if (!okPage(page)) return { ok: false, error: 'page is a page file name' };
|
|
125
|
+
const s = readStore(dir);
|
|
126
|
+
if (noteSeen(s, page, present, now)) writeStore(dir, s);
|
|
127
|
+
return { ok: true, hidden: hiddenOf(s, page).map((h) => h.control), propose: proposeOf({ store: s, lines, page, now }) };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function hide(dir, page, ids, now = Date.now()) {
|
|
131
|
+
if (!dir) return { ok: false, error: 'This workspace has no runtime folder.' };
|
|
132
|
+
if (!okPage(page)) return { ok: false, error: 'page is a page file name' };
|
|
133
|
+
const s = readStore(dir), on = new Set(hiddenOf(s, page).map((h) => h.control)), at = new Date(now).toISOString();
|
|
134
|
+
const add = cleanIds(ids).filter((id) => !on.has(id));
|
|
135
|
+
for (const control of add) s.hidden.push({ page, control, at });
|
|
136
|
+
if (add.length) { writeStore(dir, s); say(`hid ${add.length} on ${page}`); }
|
|
137
|
+
return { ok: true, hidden: add.length };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function show(dir, what = {}, now = Date.now()) {
|
|
141
|
+
if (!dir) return { ok: false, error: 'This workspace has no runtime folder.' };
|
|
142
|
+
const s = readStore(dir), at = new Date(now).toISOString();
|
|
143
|
+
const all = what && what.all === true, page = what && what.page, ids = new Set(cleanIds(what && what.controls));
|
|
144
|
+
if (!all && (!okPage(page) || !ids.size)) return { ok: false, error: 'show takes { page, controls } or { all: true }' };
|
|
145
|
+
let n = 0;
|
|
146
|
+
for (const h of s.hidden) if (!h.shown_at && (all || (h.page === page && ids.has(h.control)))) { h.shown_at = at; n++; }
|
|
147
|
+
const shown = s.hidden.filter((h) => h.shown_at);
|
|
148
|
+
if (shown.length > MAX_SHOWN) { const drop = new Set(shown.slice(0, shown.length - MAX_SHOWN)); s.hidden = s.hidden.filter((h) => !drop.has(h)); }
|
|
149
|
+
if (n) { writeStore(dir, s); say(`showed ${n}${all ? ' (show all)' : ' on ' + page}`); }
|
|
150
|
+
return { ok: true, shown: n };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function decline(dir, page, ids, now = Date.now()) {
|
|
154
|
+
if (!dir) return { ok: false, error: 'This workspace has no runtime folder.' };
|
|
155
|
+
if (!okPage(page)) return { ok: false, error: 'page is a page file name' };
|
|
156
|
+
const s = readStore(dir), had = new Set(s.declined.filter((d) => d.page === page).map((d) => d.control)), at = new Date(now).toISOString();
|
|
157
|
+
const add = cleanIds(ids).filter((id) => !had.has(id));
|
|
158
|
+
for (const control of add) s.declined.push({ page, control, at });
|
|
159
|
+
if (add.length) { writeStore(dir, s); say(`declined ${add.length} on ${page}`); }
|
|
160
|
+
return { ok: true, declined: add.length };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Clear of the use log forgets what pages showed too; the hidden list stays (the user's own choice). */
|
|
164
|
+
function clearSeen(dir) {
|
|
165
|
+
if (!dir) return { ok: true };
|
|
166
|
+
const s = readStore(dir);
|
|
167
|
+
if (!Object.keys(s.seen).length) return { ok: true };
|
|
168
|
+
s.seen = {}; writeStore(dir, s);
|
|
169
|
+
return { ok: true };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
module.exports = { FILE, WINDOW_DAYS, MIN_DAYS, MAX_PROPOSE, ID_RE, storeFile, readStore, cleanIds, noteSeen, proposeOf, hiddenOf, seeAndPropose, hide, show, decline, clearSeen };
|
|
173
|
+
|
|
174
|
+
if (require.main === module) {
|
|
175
|
+
if (process.argv[2] !== 'count') { console.error('usage: node lib/unused-controls.js count (the buttons hidden now)'); process.exit(2); }
|
|
176
|
+
const dir = require('./state-root.js').defaultRoot({ env: process.env });
|
|
177
|
+
console.log(String(hiddenOf(readStore(dir)).length));
|
|
178
|
+
}
|
package/workspace/lib/use-log.js
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
* record(dir, events, now) → { ok, wrote } | { ok: false, error } at most MAX_BATCH events per call
|
|
20
20
|
* summary(lines, now) → { keep, days, opens, uses, pages: [{ page, n }], controls: [{ page, control, n }] } PURE, last KEEP_DAYS days
|
|
21
21
|
* clear(dir) → { ok }
|
|
22
|
-
*
|
|
22
|
+
* keys(lines, days, now) → { used, missed, pct } PURE, the action keys (bet A477)
|
|
23
|
+
* CLI: node lib/use-log.js count → the distinct days with a line in the last KEEP_DAYS days, on its last line (the health number)
|
|
24
|
+
* node lib/use-log.js keys [--days 7] → [action-keys] used n, [action-keys] missed n, then the hit percent on its last line */
|
|
23
25
|
const fs = require('fs');
|
|
24
26
|
const path = require('path');
|
|
25
27
|
|
|
@@ -118,9 +120,31 @@ function clear(dir) {
|
|
|
118
120
|
|
|
119
121
|
module.exports = { FILE, KEEP_DAYS, MAX_BATCH, KINDS, DEVICES, PAGE_RE, CONTROL_RE, ledgerFile, pageOf, clean, readLines, record, summary, clear };
|
|
120
122
|
|
|
123
|
+
/** PURE: the action keys (bet A477, pm/action-keys.js) in the last `days` days: { used, missed, pct }. used = presses that acted
|
|
124
|
+
* (control key-<action>), missed = presses with nothing to act on (key-miss), pct = used / all, 100 when there were none. */
|
|
125
|
+
function keys(lines, days = 7, now = Date.now()) {
|
|
126
|
+
const from = now - Math.max(1, Number(days) || 7) * DAY;
|
|
127
|
+
let used = 0, missed = 0;
|
|
128
|
+
for (const l of lines || []) {
|
|
129
|
+
if (!l || l.kind !== 'use' || !/^key-/.test(l.control || '') || !(Date.parse(l.at) >= from)) continue;
|
|
130
|
+
if (l.control === 'key-miss') missed++; else used++;
|
|
131
|
+
}
|
|
132
|
+
return { used, missed, pct: used + missed ? Math.round((100 * used) / (used + missed)) : 100 };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
module.exports.keys = keys;
|
|
136
|
+
|
|
121
137
|
if (require.main === module) {
|
|
122
138
|
const cmd = process.argv[2];
|
|
123
|
-
|
|
139
|
+
const usage = 'usage: node lib/use-log.js count (the distinct days with a line in the last ' + KEEP_DAYS + ' days)\n'
|
|
140
|
+
+ ' node lib/use-log.js keys [--days 7] (actions taken with a key, presses with nothing to act on, and the hit percent)';
|
|
141
|
+
if (cmd !== 'count' && cmd !== 'keys') { console.error(usage); process.exit(2); }
|
|
124
142
|
const dir = require('./state-root.js').defaultRoot({ env: process.env });
|
|
125
|
-
console.log(String(summary(readLines(dir)).days));
|
|
143
|
+
if (cmd === 'count') console.log(String(summary(readLines(dir)).days));
|
|
144
|
+
else {
|
|
145
|
+
const i = process.argv.indexOf('--days'), k = keys(readLines(dir), i > 0 ? process.argv[i + 1] : 7);
|
|
146
|
+
console.log('[action-keys] used ' + k.used);
|
|
147
|
+
console.log('[action-keys] missed ' + k.missed);
|
|
148
|
+
console.log(String(k.pct));
|
|
149
|
+
}
|
|
126
150
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.714.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.714.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -229,6 +229,8 @@ const everyPart = async (pg) => { await pg.waitForSelector('#czViewer .pw-ph', {
|
|
|
229
229
|
for (const [w, h, theme] of [[1280, 900, 'light'], [1280, 900, 'dark'], [390, 844, 'light'], [390, 844, 'dark']]) {
|
|
230
230
|
const R = await open({ w, h, theme, props: [prop()] });
|
|
231
231
|
await until(() => R.page.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
|
|
232
|
+
// the Viewer adds its stylesheets as it opens (premium-viewer.js, cozy-viewer.js): measure once every sheet has loaded, not before
|
|
233
|
+
await until(() => R.page.evaluate(() => [...document.querySelectorAll('link[rel="stylesheet"]')].every((l) => !!l.sheet)));
|
|
232
234
|
const f = await R.page.evaluate(([v, small]) => {
|
|
233
235
|
const bad = [], root = document.querySelector(v);
|
|
234
236
|
for (const e of root.querySelectorAll('button,input,textarea')) { const r = e.getBoundingClientRect(); if (r.width && r.height && r.height < (small ? 44 : 30)) bad.push(e.textContent.trim().slice(0, 20) + ':' + Math.round(r.height)); }
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/* pm/action-keys.js — one key each for the five actions people take most (bet A477, initiative action-keys).
|
|
2
|
+
*
|
|
3
|
+
* y Yes to what PMOS proposes o Open the item s Move it to the next sprint p Park it z Undo ? the list of keys
|
|
4
|
+
*
|
|
5
|
+
* A key presses the button the item ALREADY has: it adds no action and no route, so every page and every product built with PMOS gets it
|
|
6
|
+
* without wiring. The item is what the pointer is over, or what has focus, whichever moved last. Its button is found by its words
|
|
7
|
+
* (aria-label, then title, then text), in the item and its parents up to the list, section or dialog that holds it, never across the page,
|
|
8
|
+
* so `y` on one row never says Yes to the next row's proposal. Undo also takes the newest Toast's Undo, from anywhere.
|
|
9
|
+
*
|
|
10
|
+
* Hover explains: a button that has a key gets aria-keyshortcuts and its key in its tooltip ("Open the PRD (O)").
|
|
11
|
+
* Keys do nothing while typing, in a terminal, with Ctrl, Cmd or Alt, on a held key, or when the page already used the key.
|
|
12
|
+
* Each press is counted on this computer only (pm/use-log.js noteUse: `key-<action>` or `key-miss`, no text, no value).
|
|
13
|
+
*
|
|
14
|
+
* startActionKeys(doc) called once by the menu (pm/cozy-nav.js mountNav), which every page mounts; a second call does nothing
|
|
15
|
+
* actOf(words) PURE: 'approve' | 'open' | 'sprint' | 'park' | 'undo' | ''
|
|
16
|
+
* keyAct(e) PURE: the action a key event asks for, 'sheet' for ?, or null
|
|
17
|
+
* targetOf(act, here, doc) the button (or, for open, the row) the key presses, or null
|
|
18
|
+
* hint(el) put the key on a button's tooltip once
|
|
19
|
+
* sheetHtml(here) PURE: the ? list's markup; here = Set of the actions with something to act on */
|
|
20
|
+
import { noteUse } from './use-log.js';
|
|
21
|
+
|
|
22
|
+
export const KEYS = [
|
|
23
|
+
{ key: 'y', act: 'approve', say: 'Yes to what PMOS proposes' },
|
|
24
|
+
{ key: 'o', act: 'open', say: 'Open the item' },
|
|
25
|
+
{ key: 's', act: 'sprint', say: 'Move it to the next sprint' },
|
|
26
|
+
{ key: 'p', act: 'park', say: 'Park it' },
|
|
27
|
+
{ key: 'z', act: 'undo', say: 'Undo' },
|
|
28
|
+
];
|
|
29
|
+
const ACT_OF_KEY = Object.fromEntries(KEYS.map((k) => [k.key, k.act]));
|
|
30
|
+
const KEY_OF_ACT = Object.fromEntries(KEYS.map((k) => [k.act, k.key]));
|
|
31
|
+
// order matters: "Undo: open it again" is Undo, "Yes, open it" is Yes
|
|
32
|
+
const RULES = [
|
|
33
|
+
['undo', /^undo\b/i],
|
|
34
|
+
['approve', /^(yes|approve|accept)\b/i],
|
|
35
|
+
['sprint', /\bnext sprint\b/i],
|
|
36
|
+
['park', /^(park|put (it )?on hold|hold it|hold)\b/i],
|
|
37
|
+
['open', /^open\b/i],
|
|
38
|
+
];
|
|
39
|
+
export const PRESS = 'button, a[href], [role="button"], [role="menuitem"]';
|
|
40
|
+
const ROW = '[role="row"], [role="option"], [role="listitem"], .pm-li, li, tr, [data-open]';
|
|
41
|
+
// the item ends where its list, section or dialog starts: a key never reaches into another item
|
|
42
|
+
const STOP = 'body, main, [role="main"], section, [role="region"], dialog, [role="dialog"], nav, ul, ol, table, [role="list"], [role="listbox"], [role="grid"], [role="table"], [role="tree"]';
|
|
43
|
+
const TOAST = '.pm-toast, [data-c3-toast], .toast, [role="status"], [role="alert"]';
|
|
44
|
+
const TYPING = 'input, textarea, select, [contenteditable=""], [contenteditable="true"], [role="textbox"]';
|
|
45
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
46
|
+
const say = (s) => { try { console.info('[action-keys] ' + s); } catch { /* no console */ } };
|
|
47
|
+
|
|
48
|
+
/** The words a control is known by: aria-label, then title (without a key already added), then its text. */
|
|
49
|
+
export function wordsOf(el) {
|
|
50
|
+
if (!el || !el.getAttribute) return '';
|
|
51
|
+
const w = el.getAttribute('aria-label') || String(el.getAttribute('title') || '').replace(/\s*\([A-Z?]\)$/, '') || el.textContent || '';
|
|
52
|
+
return String(w).replace(/\s+/g, ' ').trim();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** PURE: the action some words name, or ''. */
|
|
56
|
+
export function actOf(words) {
|
|
57
|
+
const w = String(words || '').trim();
|
|
58
|
+
if (!w) return '';
|
|
59
|
+
for (const [act, re] of RULES) if (re.test(w)) return act;
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** PURE: the action a key event asks for ('sheet' for ?), or null when the key is not ours to take. */
|
|
64
|
+
export function keyAct(e) {
|
|
65
|
+
if (!e || e.defaultPrevented || e.repeat || e.ctrlKey || e.metaKey || e.altKey) return null;
|
|
66
|
+
const t = e.target;
|
|
67
|
+
if (t && t.closest && (t.closest(TYPING) || t.closest('.xterm'))) return null;
|
|
68
|
+
if (t && t.isContentEditable) return null;
|
|
69
|
+
if (e.key === '?') return 'sheet';
|
|
70
|
+
return ACT_OF_KEY[e.key] || null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const usable = (el) => {
|
|
74
|
+
if (!el || el.disabled || (el.getAttribute && (el.getAttribute('aria-disabled') === 'true' || el.hasAttribute('hidden')))) return false;
|
|
75
|
+
if (el.closest && el.closest('[hidden], [inert]')) return false;
|
|
76
|
+
return typeof el.getClientRects !== 'function' || el.getClientRects().length > 0; // display:none has no box
|
|
77
|
+
};
|
|
78
|
+
const matches = (el, sel) => !!(el && el.matches && el.matches(sel));
|
|
79
|
+
const pressesIn = (scope, act) => [...(matches(scope, PRESS) ? [scope] : []), ...(scope.querySelectorAll ? scope.querySelectorAll(PRESS) : [])]
|
|
80
|
+
.filter((c) => actOf(wordsOf(c)) === act && usable(c));
|
|
81
|
+
|
|
82
|
+
/** The button (or, for open, the row) a key presses for the item at `here`, or null. */
|
|
83
|
+
export function targetOf(act, here, doc = typeof document !== 'undefined' ? document : null) {
|
|
84
|
+
if (!KEY_OF_ACT[act]) return null;
|
|
85
|
+
let row = null;
|
|
86
|
+
for (let s = here && here.nodeType === 3 ? here.parentElement : here; s && !matches(s, STOP); s = s.parentElement) {
|
|
87
|
+
const c = pressesIn(s, act)[0];
|
|
88
|
+
if (c) return c;
|
|
89
|
+
if (!row && matches(s, ROW)) row = s;
|
|
90
|
+
}
|
|
91
|
+
if (act === 'undo' && doc && doc.querySelectorAll) { // the newest Toast's Undo, from anywhere on the page
|
|
92
|
+
const all = [...doc.querySelectorAll(TOAST)].flatMap((t) => pressesIn(t, 'undo'));
|
|
93
|
+
if (all.length) return all[all.length - 1];
|
|
94
|
+
}
|
|
95
|
+
if (act === 'open' && row && usable(row)) return row; // a row opens when it is pressed
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The actions with something to act on anywhere on this page (the ? list marks the others). */
|
|
100
|
+
export function actsHere(doc) {
|
|
101
|
+
const out = new Set();
|
|
102
|
+
if (!doc || !doc.querySelectorAll) return out;
|
|
103
|
+
for (const c of doc.querySelectorAll(PRESS)) { const a = actOf(wordsOf(c)); if (a && usable(c)) out.add(a); }
|
|
104
|
+
if (doc.querySelector && doc.querySelector(ROW)) out.add('open');
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Put the key on a button's tooltip once: "Open the PRD (O)". A button with no key is left alone. */
|
|
109
|
+
export function hint(el) {
|
|
110
|
+
if (!el || !el.getAttribute || el.getAttribute('aria-keyshortcuts')) return false;
|
|
111
|
+
const k = KEY_OF_ACT[actOf(wordsOf(el))];
|
|
112
|
+
if (!k) return false;
|
|
113
|
+
el.setAttribute('aria-keyshortcuts', k);
|
|
114
|
+
const t = el.getAttribute('title') || el.getAttribute('aria-label') || '';
|
|
115
|
+
if (t) el.setAttribute('title', t + ' (' + k.toUpperCase() + ')');
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const X = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 6l12 12M18 6L6 18"/></svg>';
|
|
120
|
+
|
|
121
|
+
/** PURE: the ? list. here = Set of the actions with something to act on on this page. */
|
|
122
|
+
export function sheetHtml(here = new Set()) {
|
|
123
|
+
const row = (k, words, on = true) => `<li class="pm-row"><kbd class="pm-kbd">${esc(k)}</kbd><span>${esc(words)}</span>${on ? '' : '<span class="pm-meta">Not on this page</span>'}</li>`;
|
|
124
|
+
return `<div class="pm-row ev-keys-head"><h2 class="pm-h-sm" id="akTitle">Keys</h2>`
|
|
125
|
+
+ `<button type="button" class="pm-btn" data-ak-close aria-label="Close" title="Close">${X}</button></div>`
|
|
126
|
+
+ '<p class="pm-meta">Point at an item, or tab to it, then press its key.</p>'
|
|
127
|
+
+ `<ul class="ev-keys-list">${KEYS.map((k) => row(k.key.toUpperCase(), k.say, here.has(k.act))).join('')}${row('?', 'This list')}</ul>`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
let started = false;
|
|
131
|
+
const S = { pointer: null, pointerT: 0, focusT: 0, sheet: null };
|
|
132
|
+
|
|
133
|
+
function hereOf(doc) {
|
|
134
|
+
const a = doc.activeElement;
|
|
135
|
+
const focused = a && a !== doc.body && a !== doc.documentElement ? a : null;
|
|
136
|
+
return focused && (S.focusT >= S.pointerT || !S.pointer || !S.pointer.isConnected) ? focused : (S.pointer && S.pointer.isConnected ? S.pointer : focused);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function sheet(doc, show) {
|
|
140
|
+
if (S.sheet && S.sheet.open) { S.sheet.close(); if (show !== true) return; }
|
|
141
|
+
if (show === false) return;
|
|
142
|
+
let d = S.sheet;
|
|
143
|
+
if (!d || !d.isConnected) {
|
|
144
|
+
d = doc.createElement('dialog');
|
|
145
|
+
d.className = 'pm-ds ev-keys'; // its look is in cozy-ev.css, which the menu adds to every page
|
|
146
|
+
d.setAttribute('aria-labelledby', 'akTitle');
|
|
147
|
+
doc.body.appendChild(d);
|
|
148
|
+
S.sheet = d;
|
|
149
|
+
}
|
|
150
|
+
d.innerHTML = sheetHtml(actsHere(doc));
|
|
151
|
+
if (typeof d.showModal === 'function') d.showModal(); else d.setAttribute('open', '');
|
|
152
|
+
say('list opened');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function startActionKeys(doc = typeof document !== 'undefined' ? document : null) {
|
|
156
|
+
if (started || !doc || !doc.addEventListener) return false;
|
|
157
|
+
started = true;
|
|
158
|
+
// Close, or a press on the backdrop, closes the ? list (delegated from the document, like every other part)
|
|
159
|
+
if (doc.defaultView) doc.defaultView.addEventListener('click', (e) => {
|
|
160
|
+
const d = S.sheet;
|
|
161
|
+
if (d && d.open && (e.target === d || (e.target && e.target.closest && e.target.closest('[data-ak-close]')))) d.close();
|
|
162
|
+
});
|
|
163
|
+
doc.addEventListener('pointerover', (e) => {
|
|
164
|
+
S.pointer = e.target; S.pointerT = Date.now();
|
|
165
|
+
const c = e.target && e.target.closest ? e.target.closest(PRESS) : null;
|
|
166
|
+
if (c) hint(c);
|
|
167
|
+
}, { passive: true });
|
|
168
|
+
doc.addEventListener('focusin', (e) => {
|
|
169
|
+
S.focusT = Date.now();
|
|
170
|
+
if (e.target && e.target.closest) { const c = e.target.closest(PRESS); if (c) hint(c); }
|
|
171
|
+
});
|
|
172
|
+
// the bubble phase, so a page's own key (j, k, x, t, a dialog's Esc) runs first and wins
|
|
173
|
+
doc.addEventListener('keydown', (e) => {
|
|
174
|
+
const act = keyAct(e);
|
|
175
|
+
if (!act) return;
|
|
176
|
+
if (act === 'sheet') { e.preventDefault(); sheet(doc); return; }
|
|
177
|
+
if (S.sheet && S.sheet.open) return; // the list is open: only Esc and ? act
|
|
178
|
+
const el = targetOf(act, hereOf(doc), doc);
|
|
179
|
+
if (!el) { noteUse('key-miss'); say(act + ': nothing here to act on'); return; }
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
hint(el);
|
|
182
|
+
el.click();
|
|
183
|
+
noteUse('key-' + act);
|
|
184
|
+
say(act);
|
|
185
|
+
});
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* PMOS: Back restores your place (bet A430, initiative back-restores-place).
|
|
2
|
+
*
|
|
3
|
+
* The Viewer draws an item again when ← or → (or the browser's Back and Forward) comes back to it, so the item would open at the top with
|
|
4
|
+
* every section closed. This module keeps the place of the item you leave and gives it back when you return:
|
|
5
|
+
* - how far its body was scrolled (top), and
|
|
6
|
+
* - which of its sections were open: a <details open>, or a press with aria-expanded="true" that opens a section (not a menu).
|
|
7
|
+
*
|
|
8
|
+
* capture(body) → { top, open: [keys], n } or null; pure over the element, so a unit test can give it a stand-in.
|
|
9
|
+
* restore(body, place, o) → applies the place now and again while the item's content arrives (a read can draw it later), until it
|
|
10
|
+
* lands, the person scrolls or presses, or o.wait ms pass (default 2500). Returns a stop function.
|
|
11
|
+
* keyOf(el, i) → the key of one section: its data-key, else its id, else its position among the sections ('#3').
|
|
12
|
+
*
|
|
13
|
+
* A section is opened again only by its own key. A position key ('#3') counts only when the item draws the same number of sections as
|
|
14
|
+
* when you left, so a changed list never opens the wrong row. A press is opened with click(), the same as the person's press; a menu
|
|
15
|
+
* (aria-haspopup) is never pressed.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const LOG = '[back-place]';
|
|
19
|
+
|
|
20
|
+
const isDetails = (el) => !!el && String(el.tagName || '').toUpperCase() === 'DETAILS';
|
|
21
|
+
const isOpen = (el) => (isDetails(el) ? !!el.open : el.getAttribute && el.getAttribute('aria-expanded') === 'true');
|
|
22
|
+
const sections = (body) => {
|
|
23
|
+
if (!body || typeof body.querySelectorAll !== 'function') return [];
|
|
24
|
+
return Array.from(body.querySelectorAll('details, [aria-expanded]')).filter((el) => isDetails(el) || !(el.getAttribute && el.getAttribute('aria-haspopup') && el.getAttribute('aria-haspopup') !== 'false'));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function keyOf(el, i) {
|
|
28
|
+
const g = (a) => (el && el.getAttribute ? el.getAttribute(a) : null);
|
|
29
|
+
const k = g('data-key') || (el && el.dataset && el.dataset.key) || g('id') || (el && el.id);
|
|
30
|
+
return k ? 'k:' + k : '#' + i;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The place of what the body shows now. Nothing to keep (no body): null. */
|
|
34
|
+
export function capture(body) {
|
|
35
|
+
if (!body) return null;
|
|
36
|
+
const all = sections(body);
|
|
37
|
+
const open = [];
|
|
38
|
+
all.forEach((el, i) => { if (isOpen(el)) open.push(keyOf(el, i)); });
|
|
39
|
+
return { top: Math.max(0, Math.round(Number(body.scrollTop) || 0)), open, n: all.length };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** One pass: open what was open, then scroll. Returns { opened, scrolled, done } — done when every kept section is open (or was pressed
|
|
43
|
+
* once already) and the body scrolled as far as it was. pressed: the keys pressed in an earlier pass, so a press that does not show
|
|
44
|
+
* aria-expanded="true" afterwards is never pressed twice. */
|
|
45
|
+
export function apply(body, place, pressed = new Set()) {
|
|
46
|
+
if (!body || !place) return { opened: 0, scrolled: false, done: true };
|
|
47
|
+
const all = sections(body);
|
|
48
|
+
const byKey = new Map(all.map((el, i) => [keyOf(el, i), el]));
|
|
49
|
+
let opened = 0, missing = 0;
|
|
50
|
+
for (const k of place.open || []) {
|
|
51
|
+
if (k[0] === '#' && all.length !== place.n) { missing++; continue; } // the list changed: a position no longer names the same row
|
|
52
|
+
const el = byKey.get(k);
|
|
53
|
+
if (!el) { missing++; continue; }
|
|
54
|
+
if (isOpen(el) || pressed.has(k)) continue;
|
|
55
|
+
if (isDetails(el)) el.open = true; else if (typeof el.click === 'function') { pressed.add(k); el.click(); }
|
|
56
|
+
opened++;
|
|
57
|
+
}
|
|
58
|
+
const want = place.top || 0;
|
|
59
|
+
const room = Math.max(0, (Number(body.scrollHeight) || 0) - (Number(body.clientHeight) || 0));
|
|
60
|
+
if (want && Math.abs((Number(body.scrollTop) || 0) - want) > 1) body.scrollTop = Math.min(want, room);
|
|
61
|
+
const scrolled = Math.abs((Number(body.scrollTop) || 0) - want) <= 1;
|
|
62
|
+
return { opened, scrolled, done: scrolled && !missing };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Give the place back, now and while the content arrives. The person's own scroll, wheel, touch or key ends it at once. */
|
|
66
|
+
export function restore(body, place, o = {}) {
|
|
67
|
+
if (!body || !place || (!place.top && !(place.open || []).length)) return () => {};
|
|
68
|
+
let stopped = false, mo = null, t = null;
|
|
69
|
+
const pressed = new Set();
|
|
70
|
+
const evs = ['wheel', 'touchstart', 'keydown', 'pointerdown'];
|
|
71
|
+
const stop = (why) => {
|
|
72
|
+
if (stopped) return;
|
|
73
|
+
stopped = true;
|
|
74
|
+
if (mo) mo.disconnect();
|
|
75
|
+
if (t) clearTimeout(t);
|
|
76
|
+
evs.forEach((e) => body.removeEventListener && body.removeEventListener(e, onUser, true));
|
|
77
|
+
if (why === 'timeout') { try { console.warn(LOG, 'place not restored', { top: place.top, open: (place.open || []).length }); } catch { /* no console */ } }
|
|
78
|
+
};
|
|
79
|
+
const onUser = () => stop('user');
|
|
80
|
+
const pass = () => { if (stopped) return; if (apply(body, place, pressed).done) stop('done'); };
|
|
81
|
+
pass();
|
|
82
|
+
if (stopped) return stop;
|
|
83
|
+
evs.forEach((e) => body.addEventListener && body.addEventListener(e, onUser, true));
|
|
84
|
+
if (typeof MutationObserver !== 'undefined') { mo = new MutationObserver(pass); mo.observe(body, { childList: true, subtree: true }); }
|
|
85
|
+
t = setTimeout(() => stop('timeout'), o.wait == null ? 2500 : o.wait);
|
|
86
|
+
return stop;
|
|
87
|
+
}
|
|
@@ -105,3 +105,13 @@ div.pwd-art { cursor: default; }
|
|
|
105
105
|
.pwd-list .pm-group.pwd-gh svg { margin-left: auto; flex: none; }
|
|
106
106
|
.pwd-list .pm-group.pwd-gh:hover { color: var(--ink); }
|
|
107
107
|
.pwd-list .pm-group.pwd-gh:focus-visible { outline: none; box-shadow: var(--glow); }
|
|
108
|
+
/* the follow-ups (initiative work-subtasks-followups): drag to nest or take out, the drop marks, the Source filter. Tokens only. */
|
|
109
|
+
.pwd-li[draggable="true"] { cursor: grab; }
|
|
110
|
+
.pwd-li.dragging { opacity: .5; }
|
|
111
|
+
.pwd-li.drop-on { box-shadow: inset 0 0 0 2px var(--blue); background: var(--blue-tint); }
|
|
112
|
+
.pwd-li.drop-before { box-shadow: inset 0 2px 0 var(--blue); }
|
|
113
|
+
.pwd-li.drop-after { box-shadow: inset 0 -2px 0 var(--blue); }
|
|
114
|
+
.pwd-li.drop-left { box-shadow: inset 3px 0 0 var(--blue); }
|
|
115
|
+
.pwd-gh.drop-on { box-shadow: inset 0 0 0 2px var(--blue); background: var(--blue-tint); }
|
|
116
|
+
.pwd-src { margin-left: auto; }
|
|
117
|
+
.pwd-list.holding .pwd-li { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
|
|
@@ -188,7 +188,9 @@ export function listHtml(rows, W, o = {}) {
|
|
|
188
188
|
const prog = x.kids ? `<span class="pwd-prog" aria-hidden="true"><i style="width:${x.nLeaf ? Math.round((x.nDone / x.nLeaf) * 100) : 0}%"></i></span><span class="pm-meta pwd-cnt">${esc(x.count)}</span>` : '';
|
|
189
189
|
const jira = keyChip(x) + (x.jsub ? ' <span class="pm-meta">Jira sub-task</span>' : '');
|
|
190
190
|
const dot = epicDot(x, o.epics);
|
|
191
|
-
|
|
191
|
+
// drag (work-subtasks-followups): onto a task nests it, left takes it out; a Jira sub-task stays under its ticket
|
|
192
|
+
const drag = o.drag && !o.ro && !x.jsub ? ' draggable="true"' : '';
|
|
193
|
+
return `<div class="pm-li pwd-li${x.done ? ' dn' : ''}${x.lit ? ' now' : ''}${sel.has(String(x.uid)) ? ' sel' : ''}${x.kids ? ' par' : ''}" data-pwli="${esc(x.uid)}" data-pw-row="${esc(x.uid)}"${drag}${x.depth ? ` style="--pwd-d:${x.depth}"` : ''}>${chev}${box}<span class="txt"><span class="pwd-tl">${title}${jira}</span>${sub ? `<span class="w${x.late ? ' late' : ''}">${esc(sub)}</span>` : ''}</span>${prog}${dot}${acts}</div>`;
|
|
192
194
|
};
|
|
193
195
|
const body = groups.map((G) => {
|
|
194
196
|
// a stage row from breakdownOf says whether it has tasks (can) and is open; a row without them is open when tasks follow it
|
|
@@ -202,12 +204,34 @@ export function listHtml(rows, W, o = {}) {
|
|
|
202
204
|
return head + (open ? G.tasks.map(li).join('') : '');
|
|
203
205
|
}).join('');
|
|
204
206
|
const fold = empty.length ? `<div class="pm-fold pwd-fold">${esc(empty.length === 1 ? empty[0] + ' has no tasks yet' : empty.slice(0, -1).join(', ') + ' and ' + empty[empty.length - 1] + ' have no tasks yet')}</div>` : '';
|
|
205
|
-
const cap = o.ro ? '' : sel.size ? selBar(sel.size) : `<input class="pm-input pwd-cap" data-pw-cap placeholder="Add a task; say its stage, or type "under Batch 2:" to add a subtask" aria-label="Add a task. Say its stage, or type under, a parent's name and a colon to add a subtask" maxlength="200" autocomplete="off">`;
|
|
206
|
-
const top = o.ro ? '' : (o.ask ? tickAskHtml(o.ask.x, o.ask.n) : '') + (o.fix && !sel.size ? epicSugHtml(o.fix) : '');
|
|
207
|
+
const cap = o.ro ? '' : sel.size ? selBar(sel.size, { epic: !!o.epicSel }) : `<input class="pm-input pwd-cap" data-pw-cap placeholder="Add a task; say its stage, or type "under Batch 2:" to add a subtask" aria-label="Add a task. Say its stage, or type under, a parent's name and a colon to add a subtask" maxlength="200" autocomplete="off">`;
|
|
208
|
+
const top = o.ro ? '' : (o.ask ? tickAskHtml(o.ask.x, o.ask.n) : '') + (o.fix && !sel.size ? epicSugHtml(o.fix) : '') + (o.group && !sel.size ? groupSugHtml(o.group) : '');
|
|
207
209
|
const loose = o.looseN && !o.ro ? `<p class="pwd-loose"><button type="button" class="pw-lk" data-pw-backlog>${esc(o.looseN === 1 ? '1 task with no stage is in the Backlog' : o.looseN + ' tasks with no stage are in the Backlog')}${SV(I.right, 13)}</button></p>` : '';
|
|
208
210
|
return cap + top + `<div class="pwd-list${sel.size ? ' picking' : ''}" role="list" aria-label="Work breakdown">${body || (fold ? '' : '<p class="pm-meta pwd-none">No task yet.</p>')}${fold}</div>` + loose;
|
|
209
211
|
}
|
|
210
212
|
|
|
213
|
+
/* ── the follow-ups (initiative work-subtasks-followups) ── */
|
|
214
|
+
/** The ✦ grouping proposal (WorkSubtasksDS): Why, PMOS will, What changes; ✓ makes the parents (one Undo), ✕ hides it. Never by itself. */
|
|
215
|
+
export function groupSugHtml(g) {
|
|
216
|
+
if (!g) return '';
|
|
217
|
+
return `<div class="pm-sug x" role="group" aria-label="PMOS suggests"><div class="ttl">${SV(I.star)}<b class="say">${esc(g.say)}</b></div>`
|
|
218
|
+
+ `<dl><dt>Why</dt><dd>${esc(g.why)}</dd><dt>PMOS will</dt><dd><ul>${g.will.map((w) => `<li>${esc(w)}</li>`).join('')}</ul></dd><dt>What changes</dt><dd>${esc('The stage reads as ' + g.groups.length + ' batches you can fold. One Undo takes them out again.')}</dd></dl>`
|
|
219
|
+
+ `<div class="ans"><button type="button" class="pm-btn primary" data-pw-group="${esc(g.stage)}" aria-label="Yes, group them" title="Yes, group them">${SV(I.ok)}</button>`
|
|
220
|
+
+ `<button type="button" class="pm-btn outline" data-pw-group-drop="${esc(g.stage)}" aria-label="No" title="No">${SV(I.x)}</button></div></div>`;
|
|
221
|
+
}
|
|
222
|
+
const SRC = [['all', 'All'], ['jira', 'In Jira'], ['pmos', 'Only in PMOS'], ['epic', 'Epic to fix']];
|
|
223
|
+
/** The Source filter (WorkJiraDS): "Source: All", its menu lists each source with its count. Nothing when every task is from one source and
|
|
224
|
+
* no ticket needs its epic fixed (zero is silence). c: sourceCounts(); f: the current filter. */
|
|
225
|
+
export function sourceHtml(c, f = 'all') {
|
|
226
|
+
if (!c || !c.all || ((!c.jira || !c.pmos) && !c.epic)) return '';
|
|
227
|
+
const cur = SRC.find(([k]) => k === f) || SRC[0];
|
|
228
|
+
return `<button type="button" class="pm-btn outline pwd-src" data-pw-src-menu aria-haspopup="menu" aria-label="${esc('Source: ' + cur[1] + '. Change it')}">Source: ${esc(cur[1])}${SV(I.down, 14)}</button>`;
|
|
229
|
+
}
|
|
230
|
+
/** The Source menu's rows: All · In Jira 12 · Only in PMOS 3 · Epic to fix 3 (a source with no task is left out, All stays). */
|
|
231
|
+
export function sourceItems(c, f = 'all') {
|
|
232
|
+
return SRC.filter(([k]) => k === 'all' || c[k]).map(([k, l]) => ({ k, label: l, n: c[k], on: k === f }));
|
|
233
|
+
}
|
|
234
|
+
|
|
211
235
|
/* ── the side column ── */
|
|
212
236
|
/** The case: the lines PMOS read from the records, each a press that edits it in place; a line not written offers a PMOS draft. No line
|
|
213
237
|
* written: one Suggestion drafts them all (✓ sends the asks to Ask PMOS), ✕ says not now, the pencil starts the first line yourself. */
|