create-pmos 0.837.0 → 0.838.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 +78 -35
- package/payload/KIT-VERSION +1 -1
- 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/changelog.json +77 -4
- package/workspace/guide/cli.md +11 -0
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/initiatives-and-next-steps.md +8 -0
- package/workspace/lib/features.json +1 -0
- package/workspace/lib/hire-draft.js +4 -3
- package/workspace/lib/initiative-rows.js +3 -0
- package/workspace/lib/meeting-stance.js +199 -0
- package/workspace/lib/people-cli.js +44 -1
- package/workspace/lib/pmos-verbs.js +4 -1
- package/workspace/lib/route-modules.js +3 -0
- package/workspace/lib/routes-meeting-stance.js +43 -0
- package/workspace/lib/routes-segments.js +47 -0
- package/workspace/lib/routes-surface-moments.js +36 -0
- package/workspace/lib/segments-cli.js +102 -0
- package/workspace/lib/segments.js +214 -0
- package/workspace/lib/surface-moments.js +185 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-board.css +11 -0
- package/workspace/public/pm/cozy-pop-work.js +5 -2
- package/workspace/public/pm/cozy-today-app.js +42 -1
- package/workspace/public/pm/cozy-today-model.js +70 -3
- package/workspace/public/pm/cozy-today-view.js +6 -0
- package/workspace/public/pm/meeting-stance.js +113 -0
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/segments.js +113 -0
- package/workspace/public/premium-board.html +2 -0
- package/workspace/test-lists/meeting-stance.json +9 -0
- package/workspace/test-lists/segments.json +9 -0
- package/workspace/test-lists/surface-moments.json +9 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* surface-moments.js — five features that show by themselves in Your move on Today when the PM's own data says it is time (initiative surface-moments,
|
|
3
|
+
* job #1985; LINE.md Rule 12, board SfA on Exploring 3 page surface). Each was reachable only by a typed ask. The chat and the `pmos` verbs stay
|
|
4
|
+
* as the fallback. lib/routes-surface-moments.js is the HTTP side; pm/cozy-today-model.js finds the calendar and Today-line moments and draws the rows.
|
|
5
|
+
*
|
|
6
|
+
* rowsOf({ ws, today, minutes, away, worth, hire, steer }) PURE → [row] one row per moment whose condition is true; [] when none is
|
|
7
|
+
* row { key, kind, title, why, label, act } label: the ✓ button's words for a screen reader; act: what POST /api/surface-moments takes
|
|
8
|
+
* minutes time-box-pick result for a free gap (lib/time-box-pick.js pick): a row only when something fits (I have N minutes, #1875)
|
|
9
|
+
* away { day, word, set }: leave on the calendar or a Today line within 7 days; no row while already away (away days, #1856)
|
|
10
|
+
* worth worth-it rows (lib/worth-it.js worthOf) and the kinds already off: one row per flagged kind still on (AI worth, #1886)
|
|
11
|
+
* hire { pick, recent }: hire-draft's pick (lib/hire-draft.js gapOf) and the briefs drafted in 14 days (next hire, #1880)
|
|
12
|
+
* steer { program: { id, title }, day, word }: a steering meeting for a program within 2 working days (steering pack, #1847)
|
|
13
|
+
* read(ctx, w, q) → rowsOf over what PMOS holds now. READ-ONLY: it writes nothing and sends nothing.
|
|
14
|
+
* act(ctx, w, body) → { ok, said, file?, undo? } | { ok: false, error } the PM's ✓ (or its Undo); lib/routes-surface-moments.js calls it only
|
|
15
|
+
* after pm-guard requirePagePress. Every press logs [moments] and one momentAct use-log line.
|
|
16
|
+
*
|
|
17
|
+
* WHAT ✓ DOES. minutes: nothing is written; the row opens the item. away: sets the away days and drafts the handover note (Undo: back).
|
|
18
|
+
* worth: pauses that kind of AI run in Settings (Undo: on). hire: drafts the role brief (Undo: the new draft is removed). steer: drafts the
|
|
19
|
+
* one-page steering pack into planning/steering/ (Undo: the new draft is removed). A draft the PM already has is never written over or removed.
|
|
20
|
+
* Nothing here calls a model or sends anything. */
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
|
|
24
|
+
const TAG = '[moments]';
|
|
25
|
+
const GAP_MIN = 15, GAP_MAX = 90;
|
|
26
|
+
const AWAY_DAYS = 7, HIRE_DAYS = 14;
|
|
27
|
+
const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
28
|
+
const KINDS = ['minutes', 'away', 'worth', 'hire', 'steer'];
|
|
29
|
+
const pct = (r) => Math.round((Number(r) || 0) * 100) + '%';
|
|
30
|
+
const one = (v, n = 120) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
31
|
+
const localDay = (ms = Date.now()) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
32
|
+
const dn = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(d || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
|
|
33
|
+
const log = (s) => { try { console.log(TAG + ' ' + s); } catch { /* no console */ } };
|
|
34
|
+
|
|
35
|
+
/** The rows, one per moment whose condition is true. PURE. */
|
|
36
|
+
function rowsOf({ ws = '', today = '', minutes = null, away = null, worth = null, hire = null, steer = null } = {}) {
|
|
37
|
+
const out = [], k = (s) => 'moment:' + (ws || '') + ':' + s;
|
|
38
|
+
if (minutes && minutes.pick && minutes.minutes >= GAP_MIN && minutes.minutes <= GAP_MAX) {
|
|
39
|
+
const p = minutes.pick;
|
|
40
|
+
out.push({ key: k('minutes:' + today + ':' + minutes.minutes + ':' + (p.key || p.title)), kind: 'minutes', title: minutes.line, why: 'A free ' + minutes.minutes + ' min starts now',
|
|
41
|
+
label: 'Open it: ' + p.title, act: { kind: 'minutes', ini: p.ini || null } });
|
|
42
|
+
}
|
|
43
|
+
if (away && DAY_RE.test(away.day || '') && !away.set) {
|
|
44
|
+
const d = dn(away.day) - dn(today);
|
|
45
|
+
if (d >= 0 && d <= AWAY_DAYS) out.push({ key: k('away:' + away.day), kind: 'away', title: 'You are off ' + (away.word || away.day) + ': set the away days and draft the handover note',
|
|
46
|
+
why: away.from === 'calendar' ? 'Leave is on your calendar' : 'Your Today line says so', label: 'Set me away until ' + (away.word || away.day) + ' and draft the handover note',
|
|
47
|
+
act: { kind: 'away', until: away.day } });
|
|
48
|
+
}
|
|
49
|
+
if (worth && Array.isArray(worth.rows)) {
|
|
50
|
+
const off = new Set(worth.off || []);
|
|
51
|
+
for (const r of worth.rows) {
|
|
52
|
+
if (!r || !r.flag || off.has(r.kind)) continue;
|
|
53
|
+
out.push({ key: k('worth:' + r.kind + ':' + today.slice(0, 7)), kind: 'worth', title: 'Pause ' + r.kind + '? It took ' + pct(r.share) + ' of this month’s AI cost and you kept ' + r.kept + ' of ' + r.decided + ' of its ✦',
|
|
54
|
+
why: 'Costs most, kept least', label: 'Pause ' + r.kind + ' runs', act: { kind: 'worth', job: r.kind } });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (hire && hire.pick && !(hire.recent > 0)) {
|
|
58
|
+
const g = hire.pick, role = g.role;
|
|
59
|
+
out.push({ key: k('hire:' + role + ':' + today), kind: 'hire', title: 'Draft a role brief for ' + role + ': ' + g.load + ' open tasks and asks per person wait',
|
|
60
|
+
why: 'The work that waits most is on one role', label: 'Draft the role brief for ' + role, act: { kind: 'hire' } });
|
|
61
|
+
}
|
|
62
|
+
if (steer && steer.program && steer.program.id) {
|
|
63
|
+
out.push({ key: k('steer:' + steer.program.id + ':' + (steer.day || today)), kind: 'steer', title: 'Steering for ' + steer.program.title + ' ' + (steer.word || steer.day) + ': draft the one-page pack',
|
|
64
|
+
why: 'The meeting is in 2 working days or less', label: 'Draft the steering pack for ' + steer.program.title, act: { kind: 'steer', id: steer.program.id } });
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* ── reading what PMOS holds now ─────────────────────────────────────────────────────────────── */
|
|
70
|
+
function rootsOf(runtimeDir, w) {
|
|
71
|
+
let reg = [];
|
|
72
|
+
try { reg = JSON.parse(fs.readFileSync(path.join(runtimeDir, 'workspaces.json'), 'utf8')); } catch { reg = []; }
|
|
73
|
+
const out = (Array.isArray(reg) ? reg : []).filter((x) => x && typeof x.root === 'string').map((x) => path.resolve(x.root));
|
|
74
|
+
if (w && w.root && !out.includes(path.resolve(w.root))) out.push(path.resolve(w.root));
|
|
75
|
+
return [...new Set(out)];
|
|
76
|
+
}
|
|
77
|
+
function worthNow(runtimeDir, w, now) {
|
|
78
|
+
const W = require('./worth-it.js');
|
|
79
|
+
const since = W.monthStart(now);
|
|
80
|
+
let runs = []; try { runs = require('./run-tokens.js').read(runtimeDir, { sinceMs: since }); } catch { runs = []; }
|
|
81
|
+
let items = []; try { items = require('./orchestrator-keeprate.js').readAll(rootsOf(runtimeDir, w)).items; } catch { items = []; }
|
|
82
|
+
let off = []; try { off = require('./ai-guard.js').status({ stateDir: runtimeDir, settingsDir: runtimeDir }).settingsOff || []; } catch { off = []; }
|
|
83
|
+
return { ...W.worthOf({ runs, items, since }), off };
|
|
84
|
+
}
|
|
85
|
+
function programsOf(w, now) {
|
|
86
|
+
const PL = require('./program-line.js');
|
|
87
|
+
return PL.read(PL.rootsOf([w.root], process.env, true), { now });
|
|
88
|
+
}
|
|
89
|
+
/** The program a steering meeting is for: its title names the program, and "steering". */
|
|
90
|
+
function steerProgram(title, programs) {
|
|
91
|
+
const t = String(title || '').toLowerCase();
|
|
92
|
+
if (!/steer/.test(t)) return null;
|
|
93
|
+
return (programs || []).filter((p) => p && p.title && t.includes(String(p.title).toLowerCase())).sort((a, b) => b.title.length - a.title.length)[0] || null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** rowsOf over the files. q: { free (minutes), away (YYYY-MM-DD), awayWord, awayFrom, steer (meeting title), steerDay, steerWord }. */
|
|
97
|
+
function read(ctx, w, q = {}, { now = Date.now() } = {}) {
|
|
98
|
+
const today = localDay(now), runtimeDir = ctx.runtimeDir;
|
|
99
|
+
const stateDir = ctx.stateDirFor ? ctx.stateDirFor(w) : undefined;
|
|
100
|
+
const parts = { ws: w.id || '', today };
|
|
101
|
+
const free = Number(q.free);
|
|
102
|
+
if (free >= GAP_MIN && free <= GAP_MAX) {
|
|
103
|
+
try {
|
|
104
|
+
let sessions = []; try { sessions = ctx.sessionList ? ctx.sessionList() : []; } catch { sessions = []; }
|
|
105
|
+
parts.minutes = require('./time-box-pick.js').read({ w, stateDir, runtimeDir, sessions, minutes: free });
|
|
106
|
+
} catch { parts.minutes = null; }
|
|
107
|
+
}
|
|
108
|
+
if (DAY_RE.test(q.away || '') && runtimeDir) {
|
|
109
|
+
try { const AH = require('./away-handover.js'); const S = AH.stateOf(AH.readLines(runtimeDir), today); parts.away = { day: q.away, word: one(q.awayWord, 30), from: q.awayFrom === 'calendar' ? 'calendar' : 'line', set: !!S.away }; } catch { parts.away = null; }
|
|
110
|
+
}
|
|
111
|
+
if (runtimeDir) { try { parts.worth = worthNow(runtimeDir, w, now); } catch { parts.worth = null; } }
|
|
112
|
+
try {
|
|
113
|
+
const HD = require('./hire-draft.js');
|
|
114
|
+
const G = HD.gapOf(HD.sourcesOf(w.root, { now, records: [] })); // records: [] keeps the read fast: the contradiction scan takes seconds on a big repository and would hold the page's server
|
|
115
|
+
if (G.pick) parts.hire = { pick: G.pick, recent: HD.count(w.root, { days: HIRE_DAYS, now }) };
|
|
116
|
+
} catch { parts.hire = null; }
|
|
117
|
+
if (q.steer) {
|
|
118
|
+
try { const P = steerProgram(q.steer, programsOf(w, now).programs); if (P) parts.steer = { program: { id: P.id, title: P.title }, day: DAY_RE.test(q.steerDay || '') ? q.steerDay : '', word: one(q.steerWord, 30) }; } catch { parts.steer = null; }
|
|
119
|
+
}
|
|
120
|
+
const rows = rowsOf(parts);
|
|
121
|
+
console.info(TAG + ' ws=' + (w.id || '') + ' rows=' + rows.length + (rows.length ? ' kinds=' + rows.map((r) => r.kind).join(',') : ''));
|
|
122
|
+
return rows;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* ── the PM's ✓ and its Undo ──────────────────────────────────────────────────────────────────── */
|
|
126
|
+
function used(runtimeDir, now) { try { require('./use-log.js').record(runtimeDir, [{ kind: 'use', page: 'today', control: 'momentAct', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ } }
|
|
127
|
+
const rel = (root, f) => path.relative(root, f).split(path.sep).join('/');
|
|
128
|
+
/** A draft this press wrote, removed by its Undo: only a file under the given folder, named for today. */
|
|
129
|
+
function removeDraft(root, dir, file, today) {
|
|
130
|
+
const abs = path.resolve(root, String(file || ''));
|
|
131
|
+
if (path.dirname(abs) !== path.resolve(dir) || !path.basename(abs).includes(today)) return { ok: false, error: 'that is not a draft from this press' };
|
|
132
|
+
try { fs.unlinkSync(abs); } catch { return { ok: false, error: 'the draft is already gone' }; }
|
|
133
|
+
return { ok: true };
|
|
134
|
+
}
|
|
135
|
+
function steerDir(root) { const kit = fs.existsSync(path.join(root, 'pmos', 'state')); return path.join(root, ...(kit ? ['pmos', 'planning'] : ['planning']), 'steering'); }
|
|
136
|
+
function hireDir(root) { const kit = fs.existsSync(path.join(root, 'pmos', 'state')); return path.join(root, ...(kit ? ['pmos', 'planning'] : ['planning']), 'hires'); }
|
|
137
|
+
|
|
138
|
+
function act(ctx, w, body = {}, { now = Date.now() } = {}) {
|
|
139
|
+
const kind = String(body.kind || ''), undo = body.undo === true, runtimeDir = ctx.runtimeDir, root = w.root, today = localDay(now);
|
|
140
|
+
if (!KINDS.includes(kind) || kind === 'minutes') return { ok: false, error: 'kind is away, worth, hire or steer' };
|
|
141
|
+
let r;
|
|
142
|
+
if (kind === 'away') {
|
|
143
|
+
const AH = require('./away-handover.js');
|
|
144
|
+
if (undo) { const b = AH.back(runtimeDir, { now }); r = b.ok ? { ok: true, said: 'You are not set as away.' } : b; }
|
|
145
|
+
else {
|
|
146
|
+
const s = AH.set(runtimeDir, { until: body.until }, { now });
|
|
147
|
+
if (!s.ok) return s;
|
|
148
|
+
const d = AH.draft(root, runtimeDir, { now });
|
|
149
|
+
r = { ok: true, said: 'Away until ' + body.until + '. The handover note is a draft' + (d.ok ? ': ' + rel(root, d.file) : '') + '. Nothing is sent.', file: d.ok ? rel(root, d.file) : null, undo: { kind, undo: true } };
|
|
150
|
+
}
|
|
151
|
+
} else if (kind === 'worth') {
|
|
152
|
+
const job = String(body.job || '');
|
|
153
|
+
const s = require('./ai-guard.js').setOff(runtimeDir, job, !undo);
|
|
154
|
+
if (!s || !s.ok) return { ok: false, error: (s && s.error) || 'not saved' };
|
|
155
|
+
r = { ok: true, said: undo ? job + ' runs are on again.' : job + ' runs are paused. Turn them on again in Settings or with Undo.', undo: undo ? null : { kind, job, undo: true } };
|
|
156
|
+
} else if (kind === 'hire') {
|
|
157
|
+
const HD = require('./hire-draft.js');
|
|
158
|
+
if (undo) r = removeDraft(root, hireDir(root), body.file, today);
|
|
159
|
+
else {
|
|
160
|
+
const d = HD.draft(root, { now });
|
|
161
|
+
if (!d.ok) return { ok: false, error: d.none ? 'no role stands out any more' : d.error || 'not drafted' };
|
|
162
|
+
r = { ok: true, said: (d.kept ? 'The role brief is already there: ' : 'Drafted the role brief: ') + rel(root, d.file) + '. Edit it and share it yourself.', file: rel(root, d.file), undo: d.kept ? null : { kind, file: rel(root, d.file), undo: true } };
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
if (undo) r = removeDraft(root, steerDir(root), body.file, today);
|
|
166
|
+
else {
|
|
167
|
+
const SP = require('./steering-pack.js');
|
|
168
|
+
const R = require('./program-line.js').read(require('./program-line.js').rootsOf([root], process.env, true), { now, only: String(body.id || '') || null });
|
|
169
|
+
const L = (R.programs || []).find((p) => p.id === body.id);
|
|
170
|
+
if (!L) return { ok: false, error: 'no open program ' + body.id };
|
|
171
|
+
const file = path.join(steerDir(root), today + '-' + String(L.id).replace(/[^a-z0-9-]+/gi, '-').toLowerCase() + '.md');
|
|
172
|
+
const kept = fs.existsSync(file);
|
|
173
|
+
if (!kept) {
|
|
174
|
+
const md = SP.markdown(SP.packOf(L, R.clashes, { now }));
|
|
175
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
176
|
+
fs.writeFileSync(file, `---\ntype: Research\ntitle: ${JSON.stringify('Steering pack: ' + L.title)}\ntimestamp: ${today}\nkind: steering-pack\n---\n\n` + md.trimEnd() + '\n');
|
|
177
|
+
}
|
|
178
|
+
r = { ok: true, said: (kept ? 'The steering pack is already there: ' : 'Drafted the steering pack: ') + rel(root, file) + '. Bring it to the meeting; PMOS sends nothing.', file: rel(root, file), undo: kept ? null : { kind, file: rel(root, file), undo: true } };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (r.ok) { used(runtimeDir, now); log(kind + (undo ? ' undo' : '') + ' ws=' + (w.id || '')); }
|
|
182
|
+
return r;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
module.exports = { TAG, KINDS, GAP_MIN, GAP_MAX, AWAY_DAYS, HIRE_DAYS, rowsOf, steerProgram, read, act };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.838.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.838.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -1627,6 +1627,17 @@ html.ro body.wk-on .bd-hd { display: none; } /* find and tune moved to the top
|
|
|
1627
1627
|
.bd-bc .t .bd-sg { margin-right: 6px; }
|
|
1628
1628
|
.bd-bc .s.ln { color: var(--cz-ink2); }
|
|
1629
1629
|
.bd-lrow .s.ln { color: var(--cz-ink2); white-space: normal; }
|
|
1630
|
+
/* Segments under the principles (pm/segments.js, idea A327): the health bar's width is run-time geometry (--bd-seg-h); the alert colour only on the row the line names */
|
|
1631
|
+
.bd-seg-head { flex: 1; }
|
|
1632
|
+
.bd-seg-sub { display: block; }
|
|
1633
|
+
.bd-seg-bar { display: inline-flex; width: 60px; height: 6px; }
|
|
1634
|
+
.bd-seg-bar > span { width: var(--bd-seg-h, 0%); background: var(--leaf); }
|
|
1635
|
+
.bd-seg-alert .bd-seg-bar > span { background: var(--alert); }
|
|
1636
|
+
.bd-seg-alert .bd-seg-road { color: var(--alert); }
|
|
1637
|
+
.bd-seg-acts { text-align: right; white-space: nowrap; }
|
|
1638
|
+
.bd-seg-said { margin: 8px 0 0; }
|
|
1639
|
+
.bd-seg-offer { display: flex; align-items: center; gap: 8px; }
|
|
1640
|
+
.bd-seg-offer > span { flex: 1; }
|
|
1630
1641
|
/* the product's code map (pm/code-map.js, idea A176, board BatchCodeDS panel 13): one box per main part; a risky part takes the alert tint */
|
|
1631
1642
|
.bd-cm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-8); }
|
|
1632
1643
|
.bd-cm-part { min-width: 0; background: var(--card); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--line); padding: 6px 8px; font: var(--fw-regular) var(--fs-meta)/var(--lh-meta) var(--cz-sans); }
|
|
@@ -43,6 +43,7 @@ import * as STMAP from './story-map.js'; // a new bet's story map with the Rel
|
|
|
43
43
|
import * as TLY from './three-layouts.js'; // three layouts for a new screen, pick one (initiative three-layouts, A317)
|
|
44
44
|
import * as PR from './print-pdf.js'; // Print or PDF under ⋯ (job #1911, A379)
|
|
45
45
|
import * as SMAP from './stakeholder-map.js'; // the People block: who decides, must agree, needs to know (stakeholder-map, A371)
|
|
46
|
+
import * as MST from './meeting-stance.js'; // before the meeting: the two questions for a contested decision, and where each stands (meeting-stance, A333)
|
|
46
47
|
import * as PD from './bd-pop-ds.js'; // the popup on a computer, built from the design system's blocks (initiative work-ds-popup) // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
|
|
47
48
|
|
|
48
49
|
const CSS = new URL('./cozy-pop-work.css', import.meta.url).href, DSCSS = new URL('./bd-pop-ds.css', import.meta.url).href;
|
|
@@ -499,7 +500,9 @@ function dsHtml(r, v, o, W, S, C, mode) {
|
|
|
499
500
|
// a new screen's three layouts under the stages (three-layouts, A317): zero is silence, so an initiative that adds no screen shows nothing
|
|
500
501
|
const lay = TLY.html(TLY.seen(id));
|
|
501
502
|
// the People block under the Overview (stakeholder-map, BatchPeopleDS panel 9): drawn from memory, read once per initiative; no name, no block
|
|
502
|
-
const
|
|
503
|
+
const ppl0 = SMAP.blockFor(id, o.ws, () => { if (artRedraw) artRedraw(); });
|
|
504
|
+
// before the meeting (meeting-stance, BatchPeopleDS panel 10): under People; no contested decision, no block
|
|
505
|
+
const ppl = ppl0 + MST.blockFor(id, o.ws, () => { if (artRedraw) artRedraw(); });
|
|
503
506
|
// the story map (A419): a new bet's journey and its Release 1 line, above the breakdown; nothing when there is no map and the bet has tasks
|
|
504
507
|
const smap = STMAP.blockHtml({ id, ws: o.ws || '', title: W.title || '', tasks: stagesOf(r, v, { ...o, today: W.today, subAll: true }).filter((x) => x.kind === 'task').length });
|
|
505
508
|
return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}${ppl}<div class="pwd-main">${PD.stagesHtml(st, W)}${lay}${smap}${crit}${BVD.html(id, o.ws)}${wbs}</div></div>`;
|
|
@@ -926,7 +929,7 @@ export function wire(body, h0, x0) {
|
|
|
926
929
|
wireGrip(body);
|
|
927
930
|
STMAP.wire(body, { redraw: () => { if (body.querySelector('.pw')) redraw(); } }); // the story map's presses and drag (A419)
|
|
928
931
|
// the People block's presses (stakeholder-map), before the popup's own handler below
|
|
929
|
-
body.addEventListener('click', (e) => {
|
|
932
|
+
body.addEventListener('click', (e) => { const say = (t) => { const hh = body.__pwh; if (hh && hh.toast) hh.toast(t); }; if (!SMAP.press(e, body, { say })) MST.press(e, body, { say }); });
|
|
930
933
|
// a phone: a proposal swiped right says yes, left says no (its own hidden Yes and No presses, so the popup's writes and Undo stay theirs)
|
|
931
934
|
wireSwipe(body, { on: phone, act: (row, way) => { const b = row.querySelector(way === 'right' ? '[data-sw-yes]' : '[data-sw-no]'); if (b) b.click(); } });
|
|
932
935
|
body.addEventListener('submit', (e) => {
|
|
@@ -48,6 +48,7 @@ export function mountToday(ctx) {
|
|
|
48
48
|
readQuestions();
|
|
49
49
|
readSignoffs();
|
|
50
50
|
readSwitches();
|
|
51
|
+
readMoments();
|
|
51
52
|
readLine();
|
|
52
53
|
readDigest();
|
|
53
54
|
readSync();
|
|
@@ -206,6 +207,41 @@ export function mountToday(ctx) {
|
|
|
206
207
|
await readSwitches();
|
|
207
208
|
return after(true);
|
|
208
209
|
}
|
|
210
|
+
/* surface-moments (job #1985, LINE.md Rule 12): each product's moments (GET /api/surface-moments), one Your move row each. What Today's own
|
|
211
|
+
* data shows (a free gap, leave, a steering meeting) goes with the ask; the server checks the rest against the files. A product that does not
|
|
212
|
+
* answer is left out; with no moment there is no row (zero is silence). The same AI run kind is one row however many products name it. */
|
|
213
|
+
let momentsAt = 0;
|
|
214
|
+
async function readMoments() {
|
|
215
|
+
const now = ctx.now(), today = day();
|
|
216
|
+
momentsAt = now;
|
|
217
|
+
const P = ((ctx.S.M && ctx.S.M.products) || []).filter((p) => p && p.model);
|
|
218
|
+
const L = [...new Set((P.length ? P.map((p) => p.ws || ctx.boardWs() || '') : [ctx.boardWs() || '']))];
|
|
219
|
+
const free = TM.gapNow(ctx.meetings() || [], now), away = TM.awayOf((X.log && X.log.entries) || [], X.events || [], today), steer = TM.steerOf(X.events || [], today);
|
|
220
|
+
const q = new URLSearchParams();
|
|
221
|
+
if (free) q.set('free', String(free));
|
|
222
|
+
if (away) { q.set('away', away.day); q.set('awayWord', away.word); q.set('awayFrom', away.from); }
|
|
223
|
+
if (steer) { q.set('steer', steer.title); q.set('steerDay', steer.day); q.set('steerWord', steer.word); }
|
|
224
|
+
const got = await Promise.all(L.map((ws) => { const qq = new URLSearchParams(q); if (ws) qq.set('ws', ws); return ctx.pmGet('/api/surface-moments?' + qq.toString()).catch(() => null); }));
|
|
225
|
+
const rows = [], seen = new Set();
|
|
226
|
+
got.forEach((r, i) => { if (!r || !r.ok) return; for (const m of r.rows || []) { const one = m.kind === 'worth' ? 'worth:' + m.act.job : m.kind === 'away' ? 'away' : m.key; if (seen.has(one)) continue; seen.add(one); rows.push({ ...m, ws: L[i] }); } });
|
|
227
|
+
console.info('[moments] products=' + L.length + ' rows=' + rows.length);
|
|
228
|
+
const next = JSON.stringify(rows);
|
|
229
|
+
if (next === (X.moSeen || '[]')) return;
|
|
230
|
+
X.moSeen = next; X.moments = rows;
|
|
231
|
+
draw();
|
|
232
|
+
}
|
|
233
|
+
setInterval(() => { if (ctx.now() - momentsAt > 5 * 60e3) readMoments(); }, 60e3); // a free gap is a matter of minutes
|
|
234
|
+
/** ✓ on a moment: its one step, with Undo in the toast. A free gap's ✓ opens what fits it; nothing is written. */
|
|
235
|
+
async function momentPress(r) {
|
|
236
|
+
const m = r.ref || {}, a = m.act || {};
|
|
237
|
+
if (a.kind === 'minutes') { if (a.ini && ctx.hasIni(a.ini)) ctx.goIni(a.ini); return; }
|
|
238
|
+
const res = await ctx.pmPost('/api/surface-moments', { ws: m.ws || null, ...a }).catch(() => null);
|
|
239
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'It did not go through. Nothing changed.');
|
|
240
|
+
const undo = res.undo ? async () => { const u = await ctx.pmPost('/api/surface-moments', { ws: m.ws || null, ...res.undo }).catch(() => null); await readMoments(); return u || { ok: false }; } : null;
|
|
241
|
+
if (undo) ctx.toastUndo(res.said, undo); else ctx.toast(res.said);
|
|
242
|
+
await readMoments();
|
|
243
|
+
return after(true);
|
|
244
|
+
}
|
|
209
245
|
/** ✓ on a sign-off row: recorded with its source; when it was the stage's last missing item the stage moves in the same press. One Undo. */
|
|
210
246
|
async function signoffRecord(r) {
|
|
211
247
|
const s = r.ref || {};
|
|
@@ -313,7 +349,9 @@ export function mountToday(ctx) {
|
|
|
313
349
|
if (!r || !r.ok) return;
|
|
314
350
|
const today = day();
|
|
315
351
|
X.reports = (r.items || []).filter((x) => x && x.kind === 'report' && x.date === today && x.time).map((x) => ({ key: x.key, title: x.title, time: x.time }));
|
|
352
|
+
X.events = (r.items || []).filter((x) => x && x.kind === 'meeting').map((x) => ({ kind: 'meeting', date: x.date, title: x.title })); // surface-moments: leave and steering
|
|
316
353
|
draw();
|
|
354
|
+
readMoments();
|
|
317
355
|
}
|
|
318
356
|
// the head's clock: the time on it moves each minute, and only its words change
|
|
319
357
|
setInterval(() => { const w = el && el.querySelector('.td-when'); if (w) w.textContent = TM.headModel(ctx.now()).when; }, 30000);
|
|
@@ -339,6 +377,7 @@ export function mountToday(ctx) {
|
|
|
339
377
|
own: X.log.entries, marks: X.log.marks, lab, questions: X.questions || [], titleOf: ctx.titleOf, productOf, now, fixed: X.log.fixed || {},
|
|
340
378
|
signoffs: X.signoffs || [], signoffSuggest: X.signoffSuggest || [],
|
|
341
379
|
switches: X.switches || [],
|
|
380
|
+
moments: X.moments || [],
|
|
342
381
|
// your-move (A468): an initiative's ship date is its board end date; a line with no default on work that ships soon blocks it
|
|
343
382
|
shipOf: (id) => { const r = byId.get('i:' + id); return (r && r.board && r.board.end) || ''; } });
|
|
344
383
|
if (L.move.length !== X.ymN) { X.ymN = L.move.length; console.info('[your-move] rows=' + L.move.length + ' shown=' + L.first.length + (L.move[0] ? ' first-tier=' + L.move[0].tier : '')); }
|
|
@@ -489,6 +528,7 @@ export function mountToday(ctx) {
|
|
|
489
528
|
if (r.src === 'question') { openQuestion(ref); return; }
|
|
490
529
|
if (r.src === 'signoff') { if (ref.ini && ctx.hasIni(ref.ini)) ctx.goIni(ref.ini); return; }
|
|
491
530
|
if (r.src === 'switch') { location.href = '/premium-board.html' + (ref.ws ? '?ws=' + encodeURIComponent(ref.ws) : ''); return; } // the Switches block on Work
|
|
531
|
+
if (r.src === 'moment') { momentPress(r); return; }
|
|
492
532
|
if (r.src === 'signoff-by') { if (ref.ini && ctx.hasIni(ref.ini)) ctx.goIni(ref.ini); return; }
|
|
493
533
|
if (r.src === 'draft') { pop(r); ctx.openFinished(ref.fin); return; }
|
|
494
534
|
if (r.src === 'review') { pop(r); ctx.openReviewVw(); return; }
|
|
@@ -791,7 +831,7 @@ export function mountToday(ctx) {
|
|
|
791
831
|
}
|
|
792
832
|
if (act === 'open' && key === 'digest') { openDigest(); return; }
|
|
793
833
|
const r = rowOf(key); if (!r) return;
|
|
794
|
-
if (r.tier != null && (act === 'open' || act === 'done' || act === 'tomorrow' || /^(so|sb|sw)-/.test(act))) noteUse('ym-act'); // your-move's health number
|
|
834
|
+
if (r.tier != null && (act === 'open' || act === 'done' || act === 'tomorrow' || /^(so|sb|sw|mo)-/.test(act))) noteUse('ym-act'); // your-move's health number
|
|
795
835
|
if (act === 'q-remind') { remindQuestion(r.ref); return; }
|
|
796
836
|
if (act === 'open') { open(r); return; }
|
|
797
837
|
if (act === 'so-open') { signoffOpen(r); return; }
|
|
@@ -810,6 +850,7 @@ export function mountToday(ctx) {
|
|
|
810
850
|
else if (act === 'lab-keep' || act === 'lab-drop') await lab(r, act === 'lab-keep');
|
|
811
851
|
else if (act === 'so-record') await signoffRecord(r);
|
|
812
852
|
else if (act === 'sw-yes' || act === 'sw-no') await switchPress(r, act === 'sw-yes');
|
|
853
|
+
else if (act === 'mo-yes') await momentPress(r);
|
|
813
854
|
else if (act === 'so-ask') await signoffAsk(r);
|
|
814
855
|
else if (act === 'sb-keep' || act === 'sb-change') await signoffSuggest(r, act === 'sb-keep');
|
|
815
856
|
else if (act === 'lk-yes' || act === 'lk-no') await looks(r, act === 'lk-yes');
|
|
@@ -143,7 +143,7 @@ function typeOf(r) {
|
|
|
143
143
|
const ref = r.ref || {};
|
|
144
144
|
if (r.bullet === 'note' || r.src === 'note') return 'Note';
|
|
145
145
|
if (r.src === 'draft') return 'Report';
|
|
146
|
-
if (r.src === 'lab' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch') return 'Decision';
|
|
146
|
+
if (r.src === 'lab' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch' || r.src === 'moment') return 'Decision';
|
|
147
147
|
if (r.src !== 'ask') return 'Task';
|
|
148
148
|
switch (ref.kind) {
|
|
149
149
|
case 'mention': return 'Ask';
|
|
@@ -162,7 +162,8 @@ function typeOf(r) {
|
|
|
162
162
|
* shipOf(ini) → its ship date 'YYYY-MM-DD' or '' (Your move: a line with no default on work that ships soon blocks it), now,
|
|
163
163
|
* fixed: GET /api/today-log fixed ({ [ws]: keys }, quiet-rows: the line rows Your move shows today per product),
|
|
164
164
|
* signoffs: GET /api/stage-signoffs rows, each with its ws; signoffSuggest: its suggest list (factory-signoffs-reach-you);
|
|
165
|
-
* switches: GET /api/switches rows with a waiting turn, each with its ws (switch-owners)
|
|
165
|
+
* switches: GET /api/switches rows with a waiting turn, each with its ws (switch-owners),
|
|
166
|
+
* moments: GET /api/surface-moments rows, each with its ws (surface-moments) }
|
|
166
167
|
* quiet-rows: the drafts in the outbox are one row, Today's batch (pm/quiet-rows.js batchRow); Your move keeps at most 3 line rows a day per
|
|
167
168
|
* product (capLine), the rest wait under Later (`held`), and `toFix` is what the page writes once to the day ledger.
|
|
168
169
|
* A row: { key, src, bullet, first, title, work, ini, ws, job, when, late, carried, done, dates: 'task' | 'item' | 'mark', drop, ref }
|
|
@@ -280,6 +281,11 @@ export function logModel(o = {}) {
|
|
|
280
281
|
put({ key: 'switch:' + (w.ws || '') + ':' + w.id, src: 'switch', bullet: 'task', title: 'Turn ' + w.name + ' ' + w.waiting.to + ' for ' + w.customer, ini: null, ws: w.ws || '', work: '', job: 'Decide',
|
|
281
282
|
carried: 0, late: false, when: '', reason: 'Waits for you: PMOS turns nothing', age: at ? Math.max(0, between(at, today) || 0) : 0, ref: w });
|
|
282
283
|
}
|
|
284
|
+
// surface-moments (job #1985, LINE.md Rule 12): a feature that shows by itself when the PM's data says it is time; one ✓ and Put off a day
|
|
285
|
+
for (const m of o.moments || []) {
|
|
286
|
+
if (!m || !m.key || !m.title) continue;
|
|
287
|
+
put({ key: m.key, src: 'moment', bullet: 'task', title: m.title, ini: null, ws: m.ws || '', work: '', job: 'Decide', carried: 0, late: false, when: '', reason: m.why || '', age: 0, ref: m });
|
|
288
|
+
}
|
|
283
289
|
oneLine(out);
|
|
284
290
|
// a row done today whose source has let it go keeps its × from what it said when it was done
|
|
285
291
|
for (const [k, m] of Object.entries(marks)) {
|
|
@@ -456,7 +462,7 @@ export function costOf(r, today, shipOf = () => '') {
|
|
|
456
462
|
if (r.type === 'Ask' && !(r.who && r.who.length)) return null; // nobody waits on the answer
|
|
457
463
|
if (r.src === 'batch') return [2, r.left == null ? QR.LAPSE_DAYS : r.left, r.why]; // quiet-rows: Today's batch, a send today, soonest lapse first
|
|
458
464
|
const ref = r.ref || {}, c = ref.call || null, ld = lateDays(r, today);
|
|
459
|
-
const waits = r.src === 'ask' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch' || r.src === 'draft' || r.src === 'review' || (r.src === 'own' && r.first) || ld > 0;
|
|
465
|
+
const waits = r.src === 'ask' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch' || r.src === 'moment' || r.src === 'draft' || r.src === 'review' || (r.src === 'own' && r.first) || ld > 0;
|
|
460
466
|
if (!waits) return null;
|
|
461
467
|
if (r.src === 'own' && r.first) return [0, 0, 'You marked it first'];
|
|
462
468
|
const age = r.src === 'question' || r.src === 'signoff' || r.src === 'switch' ? r.age || 0 : r.carried || 0;
|
|
@@ -470,6 +476,7 @@ export function costOf(r, today, shipOf = () => '') {
|
|
|
470
476
|
if (c && c.kind === 'session' && (c.state === 'blocked' || c.state === 'needs')) return [3, 0, 'A session waits on you; its work stops until you answer'];
|
|
471
477
|
if (r.src === 'question') return [4, -age, r.reason || 'Waits on you ' + plural(age, 'day', 'days')];
|
|
472
478
|
if (r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch') return [4, -age, r.reason || 'Waits on you'];
|
|
479
|
+
if (r.src === 'moment') return [4, 0, '✦ ' + (r.reason || 'PMOS suggests it now')];
|
|
473
480
|
const w = whyOf(r, today);
|
|
474
481
|
return [4, -age, w && !/^Waits on you$/.test(w) ? w : age ? 'Waits on you ' + plural(age, 'day', 'days') : 'Waits on you'];
|
|
475
482
|
}
|
|
@@ -647,3 +654,63 @@ export function syncSuggest(parts, o = {}) {
|
|
|
647
654
|
why: 'Someone set these in PMOS by hand, and Jira says otherwise. PMOS changes nothing in Jira. Undo puts back what PMOS said.' + (p.unread ? ' ' + p.unread + (p.unread === 1 ? ' task' : ' tasks') + ' could not be read and are not counted.' : '') };
|
|
648
655
|
});
|
|
649
656
|
}
|
|
657
|
+
|
|
658
|
+
/* surface-moments (job #1985, LINE.md Rule 12): the moments Today's own data shows. Each is PURE; pm/cozy-today-app.js passes what it finds to
|
|
659
|
+
* GET /api/surface-moments, which checks the rest against the files (lib/surface-moments.js). */
|
|
660
|
+
const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
661
|
+
const WD_RE = /\b(sun|mon|tues?|wed(?:nes)?|thu(?:rs?)?|fri|sat(?:ur)?)(?:day)?\b/i;
|
|
662
|
+
const LEAVE_RE = /\b(ooo|out of office|on leave|annual leave|leave|holiday|vacation|day off|pto|cuti)\b/i;
|
|
663
|
+
const OFF_RE = /\b(off|away|on leave|out of office|ooo|holiday|vacation|day off)\b/i;
|
|
664
|
+
/** "Fri 28 Nov" for a YYYY-MM-DD. */
|
|
665
|
+
export function weekdayWord(k) { const t = dayMs(k); if (t == null) return ''; const d = new Date(t); return WD[d.getDay()] + ' ' + d.getDate() + ' ' + MON[d.getMonth()]; }
|
|
666
|
+
/** Weekdays after `from`, up to and including `to` (0 for the same day). */
|
|
667
|
+
export function workDays(from, to) {
|
|
668
|
+
const a = dayMs(from), b = dayMs(to); if (a == null || b == null || b < a) return -1;
|
|
669
|
+
let n = 0; for (let t = new Date(a); t.getTime() < b;) { t.setDate(t.getDate() + 1); const w = t.getDay(); if (w !== 0 && w !== 6) n++; }
|
|
670
|
+
return n;
|
|
671
|
+
}
|
|
672
|
+
/** The minutes of a free gap that starts within 10 minutes, 15 to 90, between 09:00 and 18:00; 0 when there is none. meetings: Today's. */
|
|
673
|
+
export function gapNow(meetings, now) {
|
|
674
|
+
const d0 = new Date(now); d0.setHours(9, 0, 0, 0); const d1 = new Date(now); d1.setHours(18, 0, 0, 0);
|
|
675
|
+
if (now < d0.getTime() || now >= d1.getTime()) return 0;
|
|
676
|
+
const S = (meetings || []).filter((m) => m && m.start && Number.isFinite(Date.parse(m.start))).map(span).sort((x, y) => x.a - y.a);
|
|
677
|
+
let start = now;
|
|
678
|
+
const cur = S.find((x) => x.a <= now && x.b > now);
|
|
679
|
+
if (cur) { if (cur.b - now > 10 * 60000) return 0; start = cur.b; }
|
|
680
|
+
const next = S.find((x) => x.a >= start);
|
|
681
|
+
const end = Math.min(next ? next.a : d1.getTime(), d1.getTime());
|
|
682
|
+
const mins = Math.floor((end - start) / 60000 / 5) * 5;
|
|
683
|
+
return mins >= 15 && mins <= 90 ? mins : 0;
|
|
684
|
+
}
|
|
685
|
+
/** The day a Today line names: "tomorrow", a weekday (the next one from today), or "28 Nov". '' when none. */
|
|
686
|
+
function namedDay(text, today) {
|
|
687
|
+
const t = String(text || '');
|
|
688
|
+
if (/\btomorrow\b/i.test(t)) return addDays(today, 1);
|
|
689
|
+
const dm1 = /\b(\d{1,2})\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\b/i.exec(t);
|
|
690
|
+
if (dm1) { const y = +today.slice(0, 4), m = MON.findIndex((x) => x.toLowerCase() === dm1[2].slice(0, 3).toLowerCase()); const k = y + '-' + String(m + 1).padStart(2, '0') + '-' + String(+dm1[1]).padStart(2, '0'); return k >= today ? k : (y + 1) + k.slice(4); }
|
|
691
|
+
const w = WD_RE.exec(t);
|
|
692
|
+
if (w) { const want = WD.findIndex((x) => x.toLowerCase() === w[1].slice(0, 3).toLowerCase()); for (let i = 1; i <= 7; i++) { const k = addDays(today, i); if (new Date(dayMs(k)).getDay() === want) return k; } }
|
|
693
|
+
return '';
|
|
694
|
+
}
|
|
695
|
+
/** Leave within 7 days: an all-day or leave event on the calendar, else an open Today line ("off Friday"). { day, word, from } | null. */
|
|
696
|
+
export function awayOf(own, events, today) {
|
|
697
|
+
const near = (k) => { const n = between(today, k); return n != null && n >= 0 && n <= 7; };
|
|
698
|
+
for (const e of events || []) {
|
|
699
|
+
if (!e || e.kind !== 'meeting' || !LEAVE_RE.test(e.title || '')) continue;
|
|
700
|
+
const k = String(e.date || '').slice(0, 10); if (near(k)) return { day: k, word: weekdayWord(k), from: 'calendar' };
|
|
701
|
+
}
|
|
702
|
+
for (const e of own || []) {
|
|
703
|
+
if (!e || e.done || !OFF_RE.test(e.text || '')) continue;
|
|
704
|
+
const k = namedDay(e.text, today); if (k && near(k)) return { day: k, word: weekdayWord(k), from: 'line' };
|
|
705
|
+
}
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
/** A steering meeting within 2 working days: { title, day, word } | null. events: GET /api/events-place items. */
|
|
709
|
+
export function steerOf(events, today) {
|
|
710
|
+
for (const e of (events || []).slice().sort((a, b) => String(a.date).localeCompare(String(b.date)))) {
|
|
711
|
+
if (!e || e.kind !== 'meeting' || !/steer/i.test(e.title || '')) continue;
|
|
712
|
+
const k = String(e.date || '').slice(0, 10), n = workDays(today, k);
|
|
713
|
+
if (n >= 0 && n <= 2) return { title: e.title, day: k, word: k === today ? 'today' : weekdayWord(k) };
|
|
714
|
+
}
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
@@ -93,6 +93,9 @@ export function switchActs(r) {
|
|
|
93
93
|
return ib('sw-yes', 'I turned ' + w.name + ' ' + to + ' for ' + w.customer, I.yes, r.key) + ib('sw-no', 'Keep ' + w.name + ' ' + (w.on ? 'on' : 'off') + ' for ' + w.customer, I.no, r.key);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/** surface-moments (job #1985): ✓ does the moment's one step, with Undo in the toast. */
|
|
97
|
+
export function momentAct(r) { const m = r.ref || {}; return ib('mo-yes', m.label || 'Do it: ' + r.title, I.yes, r.key); }
|
|
98
|
+
|
|
96
99
|
/** name-links (A536): the words of a line you typed, with the names that resolve to one record as links (r.ref.links: GET /api/name-links);
|
|
97
100
|
* any other row's words, escaped. The words never change. */
|
|
98
101
|
export function ownWords(r) { return r && r.src === 'own' && r.ref && r.ref.links ? linkedHtml(r.title, r.ref.links, esc) : esc(r && r.title); }
|
|
@@ -106,6 +109,7 @@ export function rowHtml(r, o = {}) {
|
|
|
106
109
|
if (r.src === 'question') acts = ib('open', 'Answer: ' + t, I.decide, r.key); // the register's line: it is answered where it opens, not marked done here
|
|
107
110
|
else if (r.src === 'signoff' || r.src === 'signoff-by') acts = signoffActs(r);
|
|
108
111
|
else if (r.src === 'switch') acts = switchActs(r);
|
|
112
|
+
else if (r.src === 'moment') acts = momentAct(r) + ib('tomorrow', 'Move to tomorrow: ' + t, I.tomorrow, r.key);
|
|
109
113
|
else if (r.src === 'lab') acts = ib('lab-keep', 'Keep it: start an initiative from ' + t, I.yes, r.key) + ib('lab-drop', 'Drop it: ' + t, I.no, r.key);
|
|
110
114
|
else {
|
|
111
115
|
const j = JOB_ACT[r.job];
|
|
@@ -201,6 +205,7 @@ function moveAct(r) {
|
|
|
201
205
|
if (r.src === 'question') return ib('open', 'Answer: ' + t, I.decide, r.key);
|
|
202
206
|
if (r.src === 'signoff' || r.src === 'signoff-by') return signoffActs(r);
|
|
203
207
|
if (r.src === 'switch') return switchActs(r);
|
|
208
|
+
if (r.src === 'moment') return momentAct(r);
|
|
204
209
|
const j = JOB_ACT[r.job];
|
|
205
210
|
if (j) return ib('open', j[1] + ': ' + t, j[2], r.key);
|
|
206
211
|
if (r.members) return ib('open', 'Show them: ' + t, I.more, r.key, ` aria-expanded="false"`);
|
|
@@ -355,6 +360,7 @@ export function swipeActs(r) {
|
|
|
355
360
|
if (r.members && r.drafts) return { right: 'same-yes', left: 'same-no' };
|
|
356
361
|
// a Your move row (your-move): right does its action, so a reply, an answer, a decision or a send opens the item; left puts it off a day
|
|
357
362
|
if (r.src === 'switch') return { right: '', left: 'tomorrow' }; // a turn is recorded by a press, never by a swipe
|
|
363
|
+
if (r.src === 'moment') return { right: '', left: 'tomorrow' }; // a moment acts on a press, never on a swipe
|
|
358
364
|
if (r.src === 'signoff-by') return { right: 'sb-keep', left: 'tomorrow' };
|
|
359
365
|
if (r.src === 'signoff') { const a = (r.ref || {}).action; return { right: a === 'record' ? 'so-record' : a === 'open' ? 'so-open' : 'so-ask', left: 'tomorrow' }; }
|
|
360
366
|
if (r.tier != null && (r.src === 'question' || JOB_ACT[r.job] || r.members)) return { right: 'open', left: 'tomorrow' };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* pm/meeting-stance.js — "Before the meeting: who agrees", under the People block of an initiative on Work: the two questions PMOS drafted
|
|
2
|
+
* for the contested decision, and where each person stands (initiative meeting-stance, job #1897, idea A333; board BatchPeopleDS panel 10,
|
|
3
|
+
* agreed 2026-11-25).
|
|
4
|
+
*
|
|
5
|
+
* blockHtml(stance) → the block's markup ('' when no decision is contested: zero is silence). Pure, so the test reads it.
|
|
6
|
+
* stance: GET /api/meeting-stance → stance
|
|
7
|
+
* blockFor(ini, ws, redraw) → the block for the popup drawn now: reads GET /api/meeting-stance once per initiative, then draws from memory
|
|
8
|
+
* press(e, body, { say }) → the popup's click listener hands each press here first: copy, I sent them, an answer cell
|
|
9
|
+
*
|
|
10
|
+
* Built only from the system parts on the board: pm-block, pm-table, pm-said, pm-btn, pm-meta. The two buttons are icon-only with an
|
|
11
|
+
* aria-label. Before the send the grid's cells are dashes and a ✦ line says PMOS drafted the questions; the PM copies them and sends them.
|
|
12
|
+
* PMOS NEVER SENDS THEM: "I sent them" only records it (POST act sent). Then each cell is a press that goes yes → no → empty, and the ✦
|
|
13
|
+
* line names the point the meeting must settle. Each write offers Undo in the toast. The UI says PMOS, never Claude. */
|
|
14
|
+
import { pmGet, pmPost } from './http.js';
|
|
15
|
+
import { noteUse } from './use-log.js';
|
|
16
|
+
import { undoToast } from './hi-pop.js';
|
|
17
|
+
|
|
18
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
19
|
+
const SV = (d, w = 16) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
20
|
+
const I = { spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', copy: 'M9 9h10v10H9zM5 15V5h10', sent: 'M4 12l16-8-6 16-3-7z' };
|
|
21
|
+
const btn = (attrs, label, icon, kind = '') => `<button type="button" class="pm-btn${kind ? ' ' + kind : ''}" ${attrs} aria-label="${esc(label)}" title="${esc(label)}">${SV(icon)}</button>`;
|
|
22
|
+
/** The next answer a press on a cell gives: empty → yes → no → empty. */
|
|
23
|
+
export const NEXT_SAYS = Object.freeze({ '': 'yes', yes: 'no', no: '' });
|
|
24
|
+
|
|
25
|
+
export function blockHtml(s) {
|
|
26
|
+
if (!s || !Array.isArray(s.grid) || !s.grid.length || !Array.isArray(s.people) || !s.people.length) return '';
|
|
27
|
+
const asked = !!s.asked;
|
|
28
|
+
const head = `<tr><th scope="col"><span class="ms-sr">Question</span></th>${s.people.map((p) => `<th scope="col">${esc(p.name)}</th>`).join('')}</tr>`;
|
|
29
|
+
const cell = (r, c) => {
|
|
30
|
+
const word = c.says || '—';
|
|
31
|
+
if (!asked) return `<td>${esc(word)}</td>`;
|
|
32
|
+
const label = `${c.name} on "${r.q}": ${c.says || 'no answer yet'}. Press to record ${NEXT_SAYS[c.says || ''] || 'no answer'}`;
|
|
33
|
+
return `<td${c.diff ? ' class="ms-diff"' : ''}><button type="button" class="ms-cell" data-ms-act="answer" data-ms-person="${esc(c.id)}" data-ms-name="${esc(c.name)}" data-ms-q="${r.n}" data-ms-says="${esc(NEXT_SAYS[c.says || ''])}" aria-label="${esc(label)}">${esc(word)}</button></td>`;
|
|
34
|
+
};
|
|
35
|
+
const rows = s.grid.map((r) => `<tr><td>${esc(r.q)}</td>${r.cells.map((c) => cell(r, c)).join('')}</tr>`).join('');
|
|
36
|
+
const said = !asked
|
|
37
|
+
? `<div class="pm-said ms-said" role="group" aria-label="PMOS drafted these questions; you send them">${SV(I.spark, 14)}<p>PMOS drafted these two questions for ${esc(s.people.map((p) => p.name).join(', '))}. You send them.</p>`
|
|
38
|
+
+ `<span class="ms-b">${btn('data-ms-act="copy"', 'Copy the questions', I.copy, 'outline')}${btn('data-ms-act="sent"', 'I sent them', I.sent, 'primary')}</span></div>`
|
|
39
|
+
: s.settle ? `<div class="pm-said ms-said">${SV(I.spark, 14)}<p>${esc(s.settle)}</p></div>` : '';
|
|
40
|
+
const meta = asked ? `<p class="pm-meta ms-meta">${s.answered} of ${s.total} answered · ${esc(s.askedWord)}</p>` : '';
|
|
41
|
+
return `<section class="pm-block ms-block" aria-label="Before the meeting" data-ms-ini="${esc(s.ini)}" data-ms-dec="${esc(s.decision && s.decision.id)}">`
|
|
42
|
+
+ `<table class="pm-table ms-grid"><thead>${head}</thead><tbody>${rows}</tbody></table>${said}${meta}</section>`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* ── the popup ── */
|
|
46
|
+
const ST = new Map(); // ws|ini → stance | null while reading | false when there is none
|
|
47
|
+
const kOf = (ini, ws) => (ws || '') + '|' + ini;
|
|
48
|
+
let CSS_DONE = false;
|
|
49
|
+
function css() {
|
|
50
|
+
if (CSS_DONE || typeof document === 'undefined' || !document.head) return;
|
|
51
|
+
CSS_DONE = true;
|
|
52
|
+
const s = document.createElement('style');
|
|
53
|
+
s.textContent = '.ms-block .ms-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}.ms-block .ms-grid td:first-child{width:50%}'
|
|
54
|
+
+ '.ms-block .ms-cell{all:unset;cursor:pointer;min-width:44px;min-height:32px;display:inline-flex;align-items:center}.ms-block .ms-cell:focus-visible{outline:2px solid var(--blue);outline-offset:2px}'
|
|
55
|
+
+ '.ms-block .ms-diff{color:var(--state-late)}.ms-block .ms-said{max-width:none;margin:8px 0 0;align-items:flex-start}.ms-block .ms-said p{flex:1;margin:0}'
|
|
56
|
+
+ '.ms-block .ms-said>svg{color:var(--blue);flex:none;margin-top:3px}.ms-block .ms-b{display:flex;gap:4px}.ms-block .ms-meta{margin:4px 0 0}';
|
|
57
|
+
document.head.appendChild(s);
|
|
58
|
+
}
|
|
59
|
+
let lastRedraw = null, lastWs = '';
|
|
60
|
+
function load(ini, ws, again = false) {
|
|
61
|
+
const k = kOf(ini, ws);
|
|
62
|
+
if (!again) ST.set(k, null);
|
|
63
|
+
pmGet('/api/meeting-stance?ini=' + encodeURIComponent(ini) + (ws ? '&ws=' + encodeURIComponent(ws) : ''))
|
|
64
|
+
.then((x) => { ST.set(k, x && x.ok && x.stance ? x.stance : false); if (x && x.ok && (x.stance || again) && lastRedraw) lastRedraw(); })
|
|
65
|
+
.catch(() => ST.set(k, false));
|
|
66
|
+
}
|
|
67
|
+
export function blockFor(ini, ws, redraw) {
|
|
68
|
+
if (!ini) return '';
|
|
69
|
+
lastRedraw = redraw; lastWs = ws || '';
|
|
70
|
+
const k = kOf(ini, ws);
|
|
71
|
+
if (!ST.has(k)) load(ini, ws);
|
|
72
|
+
const s = ST.get(k);
|
|
73
|
+
if (!s) return '';
|
|
74
|
+
css();
|
|
75
|
+
return blockHtml(s);
|
|
76
|
+
}
|
|
77
|
+
if (typeof document !== 'undefined' && document.addEventListener) document.addEventListener('cz:chat-turn', () => { ST.clear(); if (lastRedraw) lastRedraw(); });
|
|
78
|
+
|
|
79
|
+
async function write(ini, body) {
|
|
80
|
+
const r = await pmPost('/api/meeting-stance', { ws: lastWs || null, ini, ...body }).catch(() => null);
|
|
81
|
+
load(ini, lastWs, true);
|
|
82
|
+
return r;
|
|
83
|
+
}
|
|
84
|
+
/** One press inside the popup body: the popup's own click listener (pm/cozy-pop-work.js) hands every press here first; true when it was
|
|
85
|
+
* this block's, so the popup leaves it alone. */
|
|
86
|
+
export function press(e, body, { say } = {}) {
|
|
87
|
+
const b = e.target.closest && e.target.closest('[data-ms-act]');
|
|
88
|
+
if (!b || !body || !body.contains(b)) return false;
|
|
89
|
+
const sec = b.closest('[data-ms-ini]');
|
|
90
|
+
if (!sec) return false;
|
|
91
|
+
e.stopImmediatePropagation();
|
|
92
|
+
act(b, sec, say);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
async function act(b, sec, say) {
|
|
96
|
+
const ini = sec.dataset.msIni, decision = sec.dataset.msDec, what = b.dataset.msAct;
|
|
97
|
+
const s = ST.get(kOf(ini, lastWs));
|
|
98
|
+
if (!s) return;
|
|
99
|
+
const tell = (text, undoIt) => { if (undoIt) undoToast(text, undoIt); else if (say) say(text); };
|
|
100
|
+
if (what === 'copy') {
|
|
101
|
+
noteUse('meetingStanceCopy');
|
|
102
|
+
try { await navigator.clipboard.writeText(s.draft || ''); tell('Copied. Send them from your mail or chat.'); } catch { tell('Select the questions and copy them.'); }
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
noteUse(what === 'sent' ? 'meetingStanceSent' : 'meetingStanceAnswer');
|
|
106
|
+
b.disabled = true;
|
|
107
|
+
const body = what === 'sent' ? { decision, act: 'sent', people: s.people }
|
|
108
|
+
: { decision, act: 'answer', person: b.dataset.msPerson, name: b.dataset.msName, q: Number(b.dataset.msQ), says: b.dataset.msSays || '' };
|
|
109
|
+
const r = await write(ini, body);
|
|
110
|
+
if (!r || !r.ok) { b.disabled = false; tell((r && r.error) || 'Not saved.'); return; }
|
|
111
|
+
const word = what === 'sent' ? 'Marked: you sent the questions' : `${b.dataset.msName}: ${b.dataset.msSays || 'answer cleared'}`;
|
|
112
|
+
tell(word, () => { write(ini, { decision, act: 'undo' }); });
|
|
113
|
+
}
|