create-pmos 0.587.0 → 0.589.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 +27 -27
- 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 +26 -0
- package/workspace/guide/home.md +13 -2
- package/workspace/guide/notes.md +14 -0
- package/workspace/lib/jira-status.js +10 -3
- package/workspace/lib/meeting-guest-page.js +53 -0
- package/workspace/lib/outbox-store.js +9 -2
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-outbox.js +17 -2
- package/workspace/lib/routes-waiting.js +24 -0
- package/workspace/lib/share-store.js +3 -2
- package/workspace/lib/waiting-on.js +252 -0
- package/workspace/milestone-suggest-test.js +5 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +1 -1
- package/workspace/program-order-test.js +3 -1
- package/workspace/public/pm/cozy-today.css +28 -0
- package/workspace/public/pm/good-morning.js +6 -2
- package/workspace/public/pm/home-app.js +60 -5
- package/workspace/public/pm/home-day.js +4 -1
- package/workspace/public/pm/home-list.js +3 -1
- package/workspace/public/pm/home-today.js +6 -3
- package/workspace/public/pm/home-top.js +102 -0
- package/workspace/public/pm/ini-tasks.js +6 -2
- package/workspace/public/pm/meeting-share.js +192 -0
- package/workspace/public/pm/move-rank.js +12 -3
- package/workspace/public/pm/outbox-view.js +54 -1
- package/workspace/public/pm/premium-vw-doc.css +28 -0
- package/workspace/public/pm/premium-vw-mtg.js +13 -8
- package/workspace/public/pm/premium-vw-share.js +70 -9
- package/workspace/server.js +41 -1
- package/workspace/share-server.js +14 -2
- package/workspace/sort-order-test.js +3 -1
- package/workspace/stage-card-tasks-test.js +2 -0
- package/workspace/test-lists/home-your-move-waiting.json +11 -0
- package/workspace/test-lists/meeting-share.json +9 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* waiting-on.js — Waiting on others: what the PM waits on a named person for, derived from records (initiative home-your-move-waiting,
|
|
3
|
+
* batch 30; design A′, board HmA2 on the main canvas). Nobody types a row: it is rebuilt from what PMOS already holds.
|
|
4
|
+
*
|
|
5
|
+
* derive(src, o) → { rows, gaps, ended } pure. src: { notes, jira, sent, mentions }; o: { me, now }
|
|
6
|
+
* track(state, d, now) → { state, closed } pure. The exit rule: a row that leaves gets one line that says why
|
|
7
|
+
* nudgeOf(row, entries) → the outbox entry PMOS drafted for the row, or null pure
|
|
8
|
+
* nudgesToDraft(rows, lines, now) → [entry] pure. The nudges to put in the outbox (drafted, never sent)
|
|
9
|
+
* view(rt, o) → { ok, rows, gaps, closed } the files: reads the records, writes <rt>/waiting/state.json and the drafts
|
|
10
|
+
* channelWord(channel) → 'Jira comment' · 'team note' · …
|
|
11
|
+
*
|
|
12
|
+
* THE SOURCES (the brief, item 2). A row exists only with a real who: a name or a Jira assignee.
|
|
13
|
+
* note a meeting note's action item whose owner is not the PM (the final notes' actions when they exist, else the local summary's).
|
|
14
|
+
* Only notes of the last WINDOW_DAYS. An agreed action with NO owner is not waiting on anyone: it is a gap, the PM's call
|
|
15
|
+
* ("… needs an owner"), and Your move shows it (pm/move-rank.js kind 'owner').
|
|
16
|
+
* jira a ticket assigned to someone else, not done, with no update for STALE_DAYS or more, on an initiative in Build
|
|
17
|
+
* (lib/jira-status.js readings, which carry the assignee's display name and the update time).
|
|
18
|
+
* message a message the PM sent from the outbox with no reply seen. A sent nudge is not a row of its own: its row says "Nudged".
|
|
19
|
+
*
|
|
20
|
+
* THE EXIT RULE. A reply seen closes a row: a mention from the row's person after the row's since (lib/mention-store.js entries), a Jira
|
|
21
|
+
* update after it, a ticket done, an action that became the PM's. The row leaves and the done line says so ("Faye replied on MSD-4388").
|
|
22
|
+
* A row never leaves in silence: when PMOS cannot say why, the line says it no longer sees the row in its source. Closed lines are kept
|
|
23
|
+
* CLOSED_DAYS.
|
|
24
|
+
*
|
|
25
|
+
* NUDGES. A row waiting NUDGE_DAYS or more gets one nudge drafted into the outbox (lib/outbox-store.js), origin 'agent', with `about` (the
|
|
26
|
+
* row's key) and its channel named. It is drafted once per row: a discarded nudge is not drafted again. It leaves PMOS only when the PM
|
|
27
|
+
* sends it from the Viewer (D106 class C, D107); with no sender registered nothing can leave.
|
|
28
|
+
*/
|
|
29
|
+
const fs = require('fs');
|
|
30
|
+
const path = require('path');
|
|
31
|
+
const crypto = require('crypto');
|
|
32
|
+
|
|
33
|
+
const DAY = 864e5;
|
|
34
|
+
const WINDOW_DAYS = 30; // a meeting note's actions are followed this long
|
|
35
|
+
const STALE_DAYS = 5; // a Jira ticket with no update this long waits on its assignee
|
|
36
|
+
const NUDGE_DAYS = 3; // a row this old gets a drafted nudge
|
|
37
|
+
const CLOSED_DAYS = 7; // a closed line is said this long
|
|
38
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
39
|
+
const NOBODY = /^(?:null|none|n\/a|tbd|tbc|nobody|no one|someone|somebody|anyone|everyone|everybody|all|team|the team|we|us|unassigned|unknown|\?+|-+)$/i;
|
|
40
|
+
const BUILD = /\b(build|execute|pull requests?|ci|merge|in development)\b/i;
|
|
41
|
+
const CHANNEL_WORD = { 'jira-write': 'Jira comment', 'team-note': 'team note', 'customer-note': 'customer note', 'calendar-hold': 'calendar hold' };
|
|
42
|
+
|
|
43
|
+
const str = (v) => (typeof v === 'string' ? v.replace(/\s+/g, ' ').trim() : '');
|
|
44
|
+
const T = (v) => { const t = typeof v === 'number' ? v : Date.parse(v || ''); return Number.isFinite(t) ? t : 0; };
|
|
45
|
+
const hash = (s) => crypto.createHash('sha1').update(String(s)).digest('hex').slice(0, 10);
|
|
46
|
+
const first = (who) => str(who).split(/\s+/)[0].toLowerCase();
|
|
47
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
48
|
+
const dm = (t, now) => { const d = new Date(t); return d.getDate() + ' ' + MON[d.getMonth()] + (d.getFullYear() !== new Date(now).getFullYear() ? ' ' + d.getFullYear() : ''); };
|
|
49
|
+
const ageWord = (d) => (d == null ? '' : d === 0 ? 'today' : plural(d, 'day', 'days'));
|
|
50
|
+
const channelWord = (c) => CHANNEL_WORD[c] || 'message';
|
|
51
|
+
|
|
52
|
+
/** A real who: a person's name or a Jira assignee. Empty, "team", "TBD", "we" and the like are nobody. */
|
|
53
|
+
function realWho(who) {
|
|
54
|
+
const w = str(who);
|
|
55
|
+
return !!w && w.length <= 80 && !NOBODY.test(w) && /\p{L}/u.test(w);
|
|
56
|
+
}
|
|
57
|
+
/** True when the name is the PM's: the whole name or its first word (lower case names from the Settings and git, as Mentions reads them). */
|
|
58
|
+
function isMe(who, me) {
|
|
59
|
+
const w = str(who).toLowerCase(); if (!w) return false;
|
|
60
|
+
if (w === 'me' || w === 'you' || w === 'pm') return true;
|
|
61
|
+
return (me || []).some((n) => n && (w === n || first(w) === n || w.split(/\s+and\s+/).every((p) => p.trim() === n)));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* ── the sources ── */
|
|
65
|
+
function fromNotes(notes, me, now) {
|
|
66
|
+
const rows = [], gaps = [], ended = new Map();
|
|
67
|
+
for (const n of notes || []) {
|
|
68
|
+
if (!n || !n.id || n.private) continue;
|
|
69
|
+
const at = T(n.at);
|
|
70
|
+
if (!at || now - at > WINDOW_DAYS * DAY) continue;
|
|
71
|
+
for (const a of n.actions || []) {
|
|
72
|
+
const text = str(a && a.text); if (!text) continue;
|
|
73
|
+
const key = 'nt:' + n.id + ':' + hash(text.toLowerCase());
|
|
74
|
+
const base = { key, title: text, since: new Date(at).toISOString(), where: str(n.title) || 'a meeting note', ws: n.ws || '', ini: n.ini || '', note: n.id };
|
|
75
|
+
const owner = str(a.owner);
|
|
76
|
+
if (!owner) { if (a.confirmed !== false) gaps.push({ ...base, key: 'gap:' + key.slice(3) }); continue; }
|
|
77
|
+
if (isMe(owner, me)) { ended.set(key, base.title + ' is yours now'); continue; }
|
|
78
|
+
if (!realWho(owner)) continue;
|
|
79
|
+
rows.push({ ...base, source: 'note', who: owner });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { rows, gaps, ended };
|
|
83
|
+
}
|
|
84
|
+
function fromJira(readings, me, now) {
|
|
85
|
+
const rows = [], ended = new Map();
|
|
86
|
+
for (const r of readings || []) {
|
|
87
|
+
if (!r || !r.key) continue;
|
|
88
|
+
const key = 'jr:' + r.key, who = str(r.assignee), up = T(r.updated);
|
|
89
|
+
if (r.category === 'done') { ended.set(key, r.key + ' is done'); continue; }
|
|
90
|
+
if (!realWho(who) || isMe(who, me)) { if (isMe(who, me)) ended.set(key, r.key + ' is assigned to you now'); continue; }
|
|
91
|
+
if (!BUILD.test(str(r.stage))) continue;
|
|
92
|
+
if (!up) continue; // no update time read: PMOS cannot say how long it waits, so it says nothing
|
|
93
|
+
if (now - up < STALE_DAYS * DAY) { ended.set(key, first(who).replace(/^./, (c) => c.toUpperCase()) + ' updated ' + r.key); continue; }
|
|
94
|
+
rows.push({ key, source: 'jira', who, title: (str(r.summary) || r.key) + ': Jira ' + r.key, since: new Date(up).toISOString(), where: r.key, ws: r.ws || '', ini: r.initiative || '', link: r.url || '', ticket: r.key });
|
|
95
|
+
}
|
|
96
|
+
return { rows, ended };
|
|
97
|
+
}
|
|
98
|
+
function fromSent(sent) {
|
|
99
|
+
const rows = [];
|
|
100
|
+
for (const e of sent || []) {
|
|
101
|
+
if (!e || !e.id || e.state !== 'sent' || e.about) continue; // a sent nudge is said on its own row ("Nudged"), not as a new one
|
|
102
|
+
const who = str(e.recipient); if (!realWho(who)) continue;
|
|
103
|
+
rows.push({ key: 'ms:' + e.id, source: 'message', who, title: str(e.subject) || str(e.body).split('\n')[0].slice(0, 100) || 'Your message', since: e.sent_at || e.at || e.created_at || '', where: channelWord(e.channel), outbox: e.id });
|
|
104
|
+
}
|
|
105
|
+
return rows;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A reply seen from the row's person after its since: a mention by the same first name; on a Jira row, a mention on that ticket. */
|
|
109
|
+
function replyOf(row, mentions) {
|
|
110
|
+
const who = first(row.who), since = T(row.since);
|
|
111
|
+
for (const m of mentions || []) {
|
|
112
|
+
if (!m || T(m.at) <= since) continue;
|
|
113
|
+
const by = first(m.who);
|
|
114
|
+
const onTicket = row.ticket && String(m.link || '').toUpperCase().includes(row.ticket.toUpperCase());
|
|
115
|
+
if (by && by === who && (!row.ticket || onTicket || m.source !== 'jira')) return m;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const Cap = (s) => String(s || '').replace(/^./, (c) => c.toUpperCase());
|
|
120
|
+
|
|
121
|
+
/** The derived list. src: { notes: [{ id, ws, ini, title, at, private, actions: [{ text, owner, confirmed }] }], jira: [{ key, summary,
|
|
122
|
+
* assignee, updated, category, stage, initiative, ws, url }], sent: outbox entries, mentions: [{ who, at, source, link }] }. Pure. */
|
|
123
|
+
function derive(src = {}, o = {}) {
|
|
124
|
+
const now = o.now || Date.now(), me = (o.me || []).map((x) => String(x).toLowerCase());
|
|
125
|
+
const N = fromNotes(src.notes, me, now), J = fromJira(src.jira, me, now);
|
|
126
|
+
const ended = new Map([...N.ended, ...J.ended]);
|
|
127
|
+
const rows = [];
|
|
128
|
+
for (const r of [...N.rows, ...J.rows, ...fromSent(src.sent)]) {
|
|
129
|
+
const m = replyOf(r, src.mentions);
|
|
130
|
+
if (m) { ended.set(r.key, Cap(first(r.who)) + ' replied' + (r.ticket ? ' on ' + r.ticket : r.source === 'note' ? ' about ' + r.title : '')); continue; }
|
|
131
|
+
const d = Math.max(0, Math.floor((now - T(r.since)) / DAY));
|
|
132
|
+
rows.push({ ...r, days: d, age: ageWord(d) });
|
|
133
|
+
}
|
|
134
|
+
rows.sort((a, b) => b.days - a.days || a.key.localeCompare(b.key));
|
|
135
|
+
return { rows, gaps: N.gaps, ended };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The exit rule. state: { open: { key: { title, who, source } }, closed: [{ key, title, who, why, at }] }. A key that was open and is not a
|
|
139
|
+
* row now is closed with the reason derive found, else the plain one; it is said CLOSED_DAYS. Pure. */
|
|
140
|
+
function track(state, d, now = Date.now()) {
|
|
141
|
+
const prev = (state && state.open) || {}, keep = ((state && state.closed) || []).filter((c) => c && now - T(c.at) < CLOSED_DAYS * DAY);
|
|
142
|
+
const open = {}, closed = [];
|
|
143
|
+
for (const r of d.rows) open[r.key] = { title: r.title, who: r.who, source: r.source };
|
|
144
|
+
for (const [key, p] of Object.entries(prev)) {
|
|
145
|
+
if (open[key]) continue;
|
|
146
|
+
const why = (d.ended && d.ended.get(key)) || (p.source === 'note' ? p.title + ': PMOS no longer sees it in the meeting note' : p.source === 'jira' ? p.title + ': PMOS no longer sees it in the Jira read' : p.title + ': PMOS no longer sees it waiting');
|
|
147
|
+
closed.push({ key, title: p.title, who: p.who, why, at: new Date(now).toISOString() });
|
|
148
|
+
}
|
|
149
|
+
const all = closed.concat(keep.filter((c) => !open[c.key] && !closed.some((x) => x.key === c.key)));
|
|
150
|
+
return { state: { v: 1, open, closed: all }, closed: all };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** The nudge PMOS drafted for a row (outbox entries with about === row.key), not yet sent; null when none. Pure. */
|
|
154
|
+
function nudgeOf(row, entries, now = Date.now()) {
|
|
155
|
+
const e = (entries || []).filter((x) => x && x.about === row.key).sort((a, b) => T(b.created_at) - T(a.created_at))[0];
|
|
156
|
+
if (!e) return null;
|
|
157
|
+
return { id: e.id, channel: e.channel, word: channelWord(e.channel), state: e.state, sent: e.state === 'sent', snoozed: T(e.snoozed_until) > now, until: e.snoozed_until || null };
|
|
158
|
+
}
|
|
159
|
+
/** The words of a nudge: short, kind, no claim PMOS cannot back. */
|
|
160
|
+
function nudgeBody(r, now) {
|
|
161
|
+
const hi = 'Hi ' + Cap(first(r.who)) + ', ';
|
|
162
|
+
if (r.source === 'jira') return hi + 'a quick check on ' + r.ticket + ': how is it going? I have not seen an update since ' + dm(T(r.since), now) + '. Thank you!';
|
|
163
|
+
if (r.source === 'note') return hi + 'from ' + r.where + ' on ' + dm(T(r.since), now) + ': ' + r.title.replace(/[.!]?$/, '.') + ' How is it going? Thank you!';
|
|
164
|
+
return hi + 'a gentle follow-up on my message from ' + dm(T(r.since), now) + ' (' + r.title + '). Thank you!';
|
|
165
|
+
}
|
|
166
|
+
/** The nudges to draft: a row waiting NUDGE_DAYS or more with no outbox line about it ever (a discarded one counts: drafted once). Pure.
|
|
167
|
+
* lines: the raw outbox log. → [{ channel, recipient, subject, body, about }] */
|
|
168
|
+
function nudgesToDraft(rows, lines, now = Date.now()) {
|
|
169
|
+
const had = new Set((lines || []).filter((l) => l && l.about).map((l) => l.about));
|
|
170
|
+
return (rows || []).filter((r) => r.days >= NUDGE_DAYS && !had.has(r.key)).map((r) => ({
|
|
171
|
+
channel: r.source === 'jira' ? 'jira-write' : 'team-note', recipient: r.source === 'jira' ? r.ticket : r.who,
|
|
172
|
+
subject: 'Nudge: ' + r.title.slice(0, 80), body: nudgeBody(r, now), about: r.key,
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* ── the files ── */
|
|
177
|
+
function readJson(f) { try { return JSON.parse(fs.readFileSync(f, 'utf8')); } catch { return null; } }
|
|
178
|
+
const stateFile = (rt) => path.join(rt, 'waiting', 'state.json');
|
|
179
|
+
|
|
180
|
+
/** The notes as derive reads them: the final notes' actions (the agent's, the PM can correct the owner), else the local summary's. */
|
|
181
|
+
function notesOf(rt, now) {
|
|
182
|
+
let files = []; try { files = fs.readdirSync(path.join(rt, 'notes')).filter((f) => f.endsWith('.json')); } catch { return []; }
|
|
183
|
+
let N = null; try { N = require('./notes.js'); } catch { N = null; }
|
|
184
|
+
const out = [];
|
|
185
|
+
for (const f of files) {
|
|
186
|
+
const n = readJson(path.join(rt, 'notes', f));
|
|
187
|
+
if (!n || !n.id || n.private) continue;
|
|
188
|
+
const at = n.recorded_from || (n.meeting && n.meeting.start) || n.created_at;
|
|
189
|
+
if (!T(at) || now - T(at) > WINDOW_DAYS * DAY) continue;
|
|
190
|
+
let actions = n.final_notes && Array.isArray(n.final_notes.actions) ? n.final_notes.actions : null;
|
|
191
|
+
if (!actions && N) { try { actions = (N.summarize(n).sections || {}).actions || []; } catch { actions = []; } }
|
|
192
|
+
const ini = n.initiative && typeof n.initiative === 'object' ? n.initiative.id : typeof n.initiative === 'string' ? n.initiative : '';
|
|
193
|
+
out.push({ id: n.id, ws: n.ws || '', ini: ini || '', title: n.title || (n.meeting && n.meeting.title) || '', at, private: !!n.private, actions: actions || [] });
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
/** The Jira readings of every workspace's linked initiatives, each with its initiative's one stage (lib/stage-read.js). */
|
|
198
|
+
function jiraOf(workspaces) {
|
|
199
|
+
const out = [];
|
|
200
|
+
let JS = null; try { JS = require('./jira-status.js'); } catch { return out; }
|
|
201
|
+
for (const w of workspaces || []) {
|
|
202
|
+
if (!w || !w.root) continue;
|
|
203
|
+
let linked = []; try { linked = JS.linkedInitiatives(w.root); } catch { linked = []; }
|
|
204
|
+
if (!linked.length) continue;
|
|
205
|
+
let label = () => ''; try { label = require('./stage-read.js').labelReader(w.root); } catch { /* no stage: no Jira row */ }
|
|
206
|
+
for (const q of linked) {
|
|
207
|
+
const s = JS.readSnapshot(w.root, q.initiative); if (!s) continue;
|
|
208
|
+
let stage = ''; try { stage = label(q.initiative) || ''; } catch { stage = ''; }
|
|
209
|
+
for (const r of s.tickets.values()) if (!r.stale) out.push({ ...r, initiative: q.initiative, ws: w.id, stage });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return out;
|
|
213
|
+
}
|
|
214
|
+
function mentionsOf(rt) {
|
|
215
|
+
const j = readJson(path.join(rt, 'mentions', 'store.json'));
|
|
216
|
+
const items = j && j.items && typeof j.items === 'object' ? Object.values(j.items) : [];
|
|
217
|
+
const out = [];
|
|
218
|
+
for (const e of items) {
|
|
219
|
+
if (!e) continue;
|
|
220
|
+
out.push({ who: e.who, at: e.at, source: e.source, link: e.link || '' });
|
|
221
|
+
for (const m of e.thread || []) out.push({ who: m.who, at: m.at, source: e.source, link: e.link || '' });
|
|
222
|
+
}
|
|
223
|
+
return out;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** GET /api/waiting: the rows, the gaps (Your move's "needs an owner"), the closed lines. Writes the state file and the drafted nudges.
|
|
227
|
+
* o: { now, me, workspaces } */
|
|
228
|
+
function view(rt, o = {}) {
|
|
229
|
+
const now = o.now || Date.now();
|
|
230
|
+
const store = require('./outbox-store.js');
|
|
231
|
+
const outbox = require('./repo-script.js');
|
|
232
|
+
const entries = store.readOutbox(rt);
|
|
233
|
+
const d = derive({ notes: notesOf(rt, now), jira: jiraOf(o.workspaces), sent: entries, mentions: mentionsOf(rt) }, { me: o.me, now });
|
|
234
|
+
// the nudges: drafted once per row, never sent here
|
|
235
|
+
const lines = store.readLines(store.outboxFile(rt));
|
|
236
|
+
const O = require(outbox.repoScript('outbox.js'));
|
|
237
|
+
let drafted = 0;
|
|
238
|
+
for (const n of nudgesToDraft(d.rows, lines, now)) {
|
|
239
|
+
try {
|
|
240
|
+
const e = O.draftOutbox({ channel: n.channel, recipient: n.recipient, subject: n.subject, body: n.body, origin: 'agent' });
|
|
241
|
+
store.appendEvent(rt, { event: 'queued', id: 'out-' + crypto.randomBytes(6).toString('hex'), ...e, about: n.about }, new Date(now));
|
|
242
|
+
drafted++;
|
|
243
|
+
} catch { /* a nudge that cannot be drafted leaves the row as it is */ }
|
|
244
|
+
}
|
|
245
|
+
const all = drafted ? store.readOutbox(rt) : entries;
|
|
246
|
+
const rows = d.rows.map((r) => ({ ...r, nudge: nudgeOf(r, all, now) }));
|
|
247
|
+
const t = track(readJson(stateFile(rt)), d, now);
|
|
248
|
+
try { fs.mkdirSync(path.dirname(stateFile(rt)), { recursive: true }); fs.writeFileSync(stateFile(rt), JSON.stringify(t.state) + '\n'); } catch { /* said next time */ }
|
|
249
|
+
return { ok: true, rows, gaps: d.gaps, closed: t.closed, as_of: new Date(now).toISOString() };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
module.exports = { WINDOW_DAYS, STALE_DAYS, NUDGE_DAYS, CLOSED_DAYS, realWho, isMe, derive, track, nudgeOf, nudgesToDraft, nudgeBody, channelWord, view, stateFile };
|
|
@@ -146,12 +146,13 @@ const withReview = (open, o = {}) => F.programs().map((p) => ({ ...p, ...(o.empt
|
|
|
146
146
|
|
|
147
147
|
/* ── M: Home's Your move ── */
|
|
148
148
|
const M = await open({ home: true });
|
|
149
|
-
// the program's milestone changes
|
|
149
|
+
// the program's milestone changes are one row of Your move at the top of Home (A′, HmA2: said once, so not on the program's card)
|
|
150
150
|
await until(() => M.page.evaluate(() => !!document.querySelector('[data-hm-prog]')), 10000);
|
|
151
|
-
const hm = await until(() => M.page.evaluate(() => { const
|
|
152
|
-
ok('M Home\'s
|
|
151
|
+
const hm = await until(() => M.page.evaluate(() => { const r = [...document.querySelectorAll('#hmList .hy .hy-r')].find((x) => /milestone change/.test(x.textContent)); return r ? [r.querySelector('b').textContent.trim(), r.querySelector('small').textContent.trim(), r.dataset.key] : null; }), 10000);
|
|
152
|
+
ok('M Home\'s Your move has one row for the program\'s milestone changes, with its kind word', !!hm && hm[0] === 'Project Ascent: 3 milestone changes to confirm' && /^Move the team reads · .*Pilot live to 2 Dec/.test(hm[1]), JSON.stringify(hm));
|
|
153
|
+
ok('M said once: the program\'s card has no milestone line of its own', await M.page.evaluate(() => !document.querySelector('[data-hm-sel="ms:project-ascent"]')));
|
|
153
154
|
if (hm) {
|
|
154
|
-
await M.page.click(
|
|
155
|
+
await M.page.click(`#hmList .hy .hy-r[data-key="${hm[2]}"] [data-yd="mv-open"]`);
|
|
155
156
|
ok('M a tap opens the program, where the changes lead its proposals', !!(await until(() => M.page.evaluate(() => { const b = document.querySelector('#czViewer [data-pv="props"]'); if (b && b.getAttribute('aria-expanded') !== 'true') b.click(); return !!document.querySelector('#czViewer .pv-props .msg-r'); }), 8000)));
|
|
156
157
|
}
|
|
157
158
|
// batch 16: on a desktop the greeting opens Your day in the Viewer, as on a phone; the calendar is under ⋯
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.589.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.589.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
package/workspace/panels-test.js
CHANGED
|
@@ -93,7 +93,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
|
93
93
|
const rows = (page) => page.evaluate(() => [...document.querySelectorAll('#hmList .hv-r.ini .hm-rm[data-hm-sel]')].map((b) => b.dataset.hmSel));
|
|
94
94
|
/** drag from the centre of a selector's element to (x, y) in steps, as a mouse does */
|
|
95
95
|
const drag = async (page, from, x, y, { hold } = {}) => {
|
|
96
|
-
const r = typeof from === 'string' ? await page.evaluate((s) => { const
|
|
96
|
+
const r = typeof from === 'string' ? await page.evaluate((s) => { const e = document.querySelector(s); e.scrollIntoView({ block: 'nearest' }); const b = e.getBoundingClientRect(); return { x: b.left + b.width / 2, y: b.top + b.height / 2 }; }, from) : from;
|
|
97
97
|
await page.mouse.move(r.x, r.y); await page.mouse.down();
|
|
98
98
|
for (let i = 1; i <= 12; i++) { await page.mouse.move(r.x + (x - r.x) * i / 12, r.y + (y - r.y) * i / 12); await sleep(16); }
|
|
99
99
|
if (hold) await hold();
|
|
@@ -132,7 +132,7 @@ const routePrograms = async (page) => {
|
|
|
132
132
|
await routePrograms(page);
|
|
133
133
|
const am = new Date(); am.setHours(10, 0, 0, 0); await page.clock.setFixedTime(am);
|
|
134
134
|
await page.goto(BASE + '/premium.html?theme=light');
|
|
135
|
-
await until(() => page.evaluate(() => !!document.querySelector('#hmList .hv-g.prg [data-po-id]')), 20000);
|
|
135
|
+
await until(() => page.evaluate(() => !!document.querySelector('#hmList .hv-g.prg [data-po-id]') && document.body.dataset.hmTop === '1'), 20000);
|
|
136
136
|
return { ctx, page, errors };
|
|
137
137
|
};
|
|
138
138
|
const hkids = (p) => p.evaluate(() => [...document.querySelectorAll('#hmList .hv-g.prg [data-po-id]')].map((r) => r.dataset.poId));
|
|
@@ -160,6 +160,8 @@ const routePrograms = async (page) => {
|
|
|
160
160
|
const grips = await p.evaluate(() => [...document.querySelectorAll('#hmList [data-po-grip]')].filter((g) => getComputedStyle(g).display !== 'none').length);
|
|
161
161
|
ok('H phone: no grip shows (hold the row instead)', grips === 0, String(grips));
|
|
162
162
|
// a hold, then a drag, through the touch events the page reads (CDP touch input)
|
|
163
|
+
// the top of Home (Your move, Waiting on others) sits above the groups: bring the rows into view first
|
|
164
|
+
await p.evaluate(() => document.querySelector('#hmList [data-po-id="descope-parity"]').scrollIntoView({ block: 'center' }));
|
|
163
165
|
const s = await p.locator('#hmList [data-po-id="descope-parity"]').boundingBox();
|
|
164
166
|
const t = await p.locator('#hmList [data-po-id="legacy-idp-sunset"]').boundingBox();
|
|
165
167
|
const cdp = await ctx.newCDPSession(p);
|
|
@@ -210,6 +210,7 @@ body.cz-home .hm-r.lr .hm-tile { width: 32px; height: 32px; }
|
|
|
210
210
|
body.cz-home.hm-plist .hm-list { display: flex; position: static; width: auto; background: none; padding: 22px 0 96px; border-radius: 0; box-shadow: none; border: 0; }
|
|
211
211
|
body.cz-home.hm-plist .hm-lsc { margin: 0; padding: 0; overflow: visible; }
|
|
212
212
|
body.cz-home.hm-plist .hm-chat, body.cz-home.hm-plist:not(.hm-vw-open) .hm-vw { display: none; }
|
|
213
|
+
body.cz-home.hm-plist.hm-vw-open { overflow: hidden; } /* the Viewer covers the list: the page under it does not scroll (a scroll would close an open picker) */
|
|
213
214
|
body.cz-home.hm-plist .cz-fabw { bottom: 24px; }
|
|
214
215
|
body.cz-home .hm-needs { display: none; }
|
|
215
216
|
body.cz-home .hm-top .hm-back { display: grid; }
|
|
@@ -727,3 +728,30 @@ body.cz-home .hm-hd.hv-bar > .hv-hi { flex: 1 0 auto; max-width: 100%; }
|
|
|
727
728
|
.yd-dn .yd-mvt b { font-weight: inherit; color: var(--cz-ink2); }
|
|
728
729
|
.ob-d h3 { margin: 12px 0 6px; font-size: var(--fs-row); font-weight: var(--fw-strong); }
|
|
729
730
|
.ob-body { white-space: pre-wrap; font: inherit; line-height: 1.5; margin: 8px 0; padding: 12px 14px; border-radius: 14px; background: var(--cz-well); color: var(--cz-ink); }
|
|
731
|
+
|
|
732
|
+
/* the top of Home: Your move and Waiting on others above today's list (home-your-move-waiting; board HmA2, A′). pm/home-top.js draws it. */
|
|
733
|
+
.hy { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
|
|
734
|
+
.hy * { box-sizing: border-box; }
|
|
735
|
+
.hy-h { display: flex; align-items: center; gap: 8px; padding: 6px 6px 2px; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink3); }
|
|
736
|
+
.hy-h + .hy-r { margin-top: 0; }
|
|
737
|
+
.hy .hy-h:not(:first-child) { margin-top: 6px; }
|
|
738
|
+
.hy-h .sp, .hy-q .sp, .hy-dn .sp { flex: 1 1 0%; }
|
|
739
|
+
.hy-h .n { font-variant-numeric: tabular-nums; }
|
|
740
|
+
.hy-r { display: flex; align-items: flex-start; gap: 10px; background: var(--cz-card); border-radius: 14px; padding: 10px 10px 10px 12px; }
|
|
741
|
+
.hy-r .st { color: var(--cz-blueink); margin-top: 2px; flex: 0 0 auto; }
|
|
742
|
+
.hy-r .st.w { color: var(--cz-ink3); }
|
|
743
|
+
.hy-r .tx { flex: 1 1 0%; min-width: 0; font-size: var(--fs-body); line-height: 1.38; color: var(--cz-ink); overflow-wrap: anywhere; }
|
|
744
|
+
.hy-r .tx b { font-weight: var(--fw-strong); }
|
|
745
|
+
.hy-r .tx small { display: block; margin-top: 2px; font-size: var(--fs-label); color: var(--cz-ink3); line-height: 1.4; }
|
|
746
|
+
.hy-r .tx small i { font-style: normal; color: var(--cz-risk); font-weight: var(--fw-strong); }
|
|
747
|
+
.hy-r .tx small i.k { color: var(--cz-ink2); }
|
|
748
|
+
.hy-r .tx small i svg { vertical-align: -2px; }
|
|
749
|
+
.hy-r .ac { display: flex; gap: 4px; flex: 0 0 auto; }
|
|
750
|
+
.hy-r .ac button { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 999px; border: 0; cursor: pointer; background: var(--cz-well); color: var(--cz-ink2); }
|
|
751
|
+
.hy-r .ac button.ok { background: var(--cz-blueink); color: var(--cz-onsolid); }
|
|
752
|
+
.hy-r .ac button:disabled { opacity: .5; cursor: default; }
|
|
753
|
+
.hy-q { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 10px 6px; font: inherit; font-size: var(--fs-label); color: var(--cz-ink3); text-align: left; cursor: pointer; }
|
|
754
|
+
.hy-dn { font-size: var(--fs-label); color: var(--cz-ink3); padding: 2px 6px; display: flex; gap: 8px; align-items: center; line-height: 1.4; }
|
|
755
|
+
.hy-lk { border: 0; background: none; padding: 0; font: inherit; color: var(--cz-blueink); font-weight: var(--fw-strong); cursor: pointer; }
|
|
756
|
+
.ob-edit { width: 100%; box-sizing: border-box; font: inherit; line-height: 1.5; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); resize: vertical; }
|
|
757
|
+
.ob-nc { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
@@ -210,6 +210,7 @@ export function callKindOf(r) {
|
|
|
210
210
|
if (r.kind === 'verdict') return 'Verdict';
|
|
211
211
|
if (r.kind === 'mention' || r.kind === 'outbox') return 'Message';
|
|
212
212
|
if (r.kind === 'meeting') return 'Move the team reads';
|
|
213
|
+
if (r.kind === 'owner') return 'Your call'; // an agreed action nobody owns (home-your-move-waiting)
|
|
213
214
|
if (r.kind !== 'call' || !r.call) return null;
|
|
214
215
|
const c = r.call, t = String(c.name || '') + ' ' + String((c.row && c.row.title) || '');
|
|
215
216
|
if (c.kind === 'update') return 'Message';
|
|
@@ -219,6 +220,9 @@ export function callKindOf(r) {
|
|
|
219
220
|
if (c.state === 'blocked') return 'Blocked';
|
|
220
221
|
return 'Your call';
|
|
221
222
|
}
|
|
223
|
+
/** The PM's calls of a ranked list (rankMove's rows, then its Can wait), in its order, each with its kind: the ONE source Good morning and
|
|
224
|
+
* Home's top read (home-your-move-waiting: one list, two views). */
|
|
225
|
+
export const callsIn = (rank) => (rank ? [...(rank.rows || []), ...(rank.wait || [])] : []).map((r) => ({ r, k: callKindOf(r) })).filter((x) => x.k).map(({ r, k }) => ({ ...r, callKind: k }));
|
|
222
226
|
/** At most this many of the PM's calls show; the rest fold under one line ("N more of your calls"). */
|
|
223
227
|
export const MOVE_CAP = 5;
|
|
224
228
|
const SINCE_MS = 24 * 3600e3;
|
|
@@ -245,8 +249,8 @@ export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
|
245
249
|
// wait"), each with its kind and why; the rest of W3's list is Claude's to do. With no ranked list, the calls Your day holds.
|
|
246
250
|
const all = Y.rank ? [...Y.rank.rows, ...(Y.rank.wait || [])] : (Y.calls || []).map((x) => ({ key: 'call:' + x.id, kind: 'call', call: x, title: x.name, sub: '', age: '' }));
|
|
247
251
|
const callWhy = (x) => (c && x.id === c.id && call && call.why) || (x.pick ? 'I’d ' + x.pick.charAt(0).toLowerCase() + x.pick.slice(1).replace(/\.?$/, '.') + ' It’s your call.' : x.when ? 'Goes out ' + x.when + '.' : x.sub || x.hint || '');
|
|
248
|
-
const mine = all.map((r) => ({ r,
|
|
249
|
-
.map((
|
|
252
|
+
const mine = (Y.rank ? callsIn(Y.rank) : all.map((r) => ({ ...r, callKind: callKindOf(r) })).filter((r) => r.callKind))
|
|
253
|
+
.map((r) => ({ ...r, sub: r.kind === 'call' ? callWhy(r.call) : r.sub, goal: tagOf(o.tags, r.ws, r.ini), late: r.days != null && r.days > 0 }));
|
|
250
254
|
const move = mine.slice(0, MOVE_CAP), more = mine.length - move.length;
|
|
251
255
|
// Claude did (AwA): what Claude finished by itself, newest first, each with its reason and Undo; a run that stopped is one amber line
|
|
252
256
|
const R = Y.rank || {}, recent = (x) => { const t = Date.parse(x.at || ''); return Number.isFinite(t) && now - t <= SINCE_MS; };
|
|
@@ -47,7 +47,9 @@ import * as L from './home-list.js';
|
|
|
47
47
|
import * as TD from './home-today.js';
|
|
48
48
|
import * as GW from './grill-words.js'; // Home's one line when Claude grilled something by itself (canvas FcPhone, Home)
|
|
49
49
|
import * as YD from './home-day.js';
|
|
50
|
-
import * as GM from './good-morning.js';
|
|
50
|
+
import * as GM from './good-morning.js';
|
|
51
|
+
import * as TOP from './home-top.js'; // the top of Home: Your move and Waiting on others (home-your-move-waiting, board HmA2)
|
|
52
|
+
import { rankMove } from './move-rank.js'; // Good morning is one page: the quarter, the reading column and the time rail (nyt-ui GM2)
|
|
51
53
|
import * as MSG from './ms-suggest.js'; // Your move's ✓ on a program's milestone changes confirms them all (workspace grill W3)
|
|
52
54
|
import * as AD from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2)
|
|
53
55
|
import * as OKL from './okr-list.js'; // the product page's Goals line (batch 16 item 6, GsProduct)
|
|
@@ -229,6 +231,9 @@ async function load() {
|
|
|
229
231
|
loadMoment();
|
|
230
232
|
readImpact();
|
|
231
233
|
loadGrillNews();
|
|
234
|
+
// the top of Home (A′): the ranked list's own reads and Waiting on others, after the first draw so they never hold the list up
|
|
235
|
+
document.body.dataset.hmTop = '0';
|
|
236
|
+
readWaiting().then(() => readMove()).catch(() => {}).then(() => { document.body.dataset.hmTop = '1'; }); // the top has read both: it holds still from here
|
|
232
237
|
// the boards of the other products Home reads, each its own closed group: read after the list is drawn, so a slow one never holds it up
|
|
233
238
|
const others = await Promise.all(otherProducts(D).map((a) => getRetry('/api/board-premium?ws=' + encodeURIComponent(a.ws), 4).then((r) => (r && r.ok && r.model ? { ws: a.ws, name: a.name, model: r.model } : null))));
|
|
234
239
|
const got = others.filter(Boolean);
|
|
@@ -358,11 +363,14 @@ function homeListHtml() {
|
|
|
358
363
|
const R = L.reviewModel(S.D, NOW());
|
|
359
364
|
// a group is open until the PM folds it; another product starts folded; "Not in an initiative" starts folded on a phone (HvAC, HvACDesk)
|
|
360
365
|
const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.kind === 'loose' ? !isPhone() : g.kind === 'program' || g.primary || M.products.length === 1);
|
|
366
|
+
// the top of Home (A′, HmA2): Your move from the same ranked list Good morning reads (rankMove + callKindOf), then Waiting on others
|
|
367
|
+
const T = S.ready && M.filter === 'today' ? topOf(M) : null;
|
|
368
|
+
S.topHtml = T ? TOP.topHtml(T) : ''; // drawn into its own node (drawTopNode), so a late read changes the top, never the rows under it
|
|
361
369
|
const sel = S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null);
|
|
362
370
|
S.lo = { sel, ses: S.ses, restOpen: (k) => S.rest.has(k), pin: S.pin, phone: false }; // the folded rail's card draws Home's rows with these
|
|
363
371
|
return TD.listHtml(M, todayModel(), {
|
|
364
372
|
sel, selHead: S.head, ses: S.ses, pOpen, here: isPhone() ? null : TD.groupOfOpen(M, sel) || S.head, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
|
|
365
|
-
pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, news: S.news && S.news.ok ? S.news.count : 0, top: S.ready ? revealLeft(S.reveal) + RECROW.html() + (S.drift ? DRIFT.rowHtml(S.drift.c, { esc, sel: S.sel === 'drift' }) : '') : '', // chief-of-staff C3: the Mentions and Your impact cards are gone; their asks land in Your move
|
|
373
|
+
pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, news: S.news && S.news.ok ? S.news.count : 0, top: S.ready ? revealLeft(S.reveal) + RECROW.html() + (S.drift ? DRIFT.rowHtml(S.drift.c, { esc, sel: S.sel === 'drift' }) : '') + (T ? '<i data-hm-topslot hidden></i>' : '') : '', held: T ? T.held : null, // chief-of-staff C3: the Mentions and Your impact cards are gone; their asks land in Your move
|
|
366
374
|
last: S.ready ? '' : LS.last(LAST_KEY), keep: S.ready && S.filter === 'today' && !S.ini ? (b) => LS.keepLast(LAST_KEY, b) : null,
|
|
367
375
|
imFace: IM.faceHtml(S.im, { joy: S.imJoy }), grill: S.ready ? grillNews() : null,
|
|
368
376
|
});
|
|
@@ -373,6 +381,33 @@ function homeListHtml() {
|
|
|
373
381
|
* minutes (the event 'cz:news-for-you') and again when Your day opens; a row opens the item in the Viewer, "N more" the whole list, ✓✓
|
|
374
382
|
* marks all seen. An item leaves once it is opened or marked seen. */
|
|
375
383
|
function dayHtml() { return ''; }
|
|
384
|
+
/** The top of Home's model: the ranked list (S.topRank, kept for the presses) and GET /api/waiting (S.wait). */
|
|
385
|
+
function topOf(M) {
|
|
386
|
+
S.topRank = rankMove({ ...rankIn(), calls: YD.callsOf(M.move), now: NOW() });
|
|
387
|
+
const products = ((M && M.products) || []).filter((p) => p.model).map((p) => ({ name: p.name, rows: ((p.model.initiatives || {}).list || {}).rows || p.model.rows || [] }));
|
|
388
|
+
return TOP.topModel({ rank: S.topRank, waiting: S.wait, products, all: !!S.topAll, now: NOW() });
|
|
389
|
+
}
|
|
390
|
+
/** GET /api/waiting (lib/waiting-on.js): Waiting on others, its exit lines and the meeting actions nobody owns. Read after the list is drawn. */
|
|
391
|
+
async function readWaiting() {
|
|
392
|
+
const r = await pmGet('/api/waiting').catch(() => null);
|
|
393
|
+
if (!r || !r.ok) return;
|
|
394
|
+
const same = JSON.stringify(r.rows) === JSON.stringify((S.wait && S.wait.rows) || null) && JSON.stringify(r.closed) === JSON.stringify((S.wait && S.wait.closed) || null) && JSON.stringify(r.gaps) === JSON.stringify((S.wait && S.wait.gaps) || null);
|
|
395
|
+
S.wait = r;
|
|
396
|
+
if (!same) { drawList(); redrawLater(); }
|
|
397
|
+
}
|
|
398
|
+
/** A press on Waiting on others: ↗ opens the drafted nudge in the Viewer (Send, Edit, Not now live there), else the row's own source. */
|
|
399
|
+
function waitPress(b) {
|
|
400
|
+
if (b.dataset.hmNudge) {
|
|
401
|
+
const e = (S.outbox || []).find((x) => x.id === b.dataset.hmNudge);
|
|
402
|
+
if (!e) { toast('The nudge is being read again. Try once more.'); readMove(); return; }
|
|
403
|
+
VW.drill(); import('./outbox-view.js').then((O) => O.openDraft(e, { pmPost, toast, toastUndo, reload: () => readMove().then(() => readWaiting()) }));
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const w = ((S.wait && S.wait.rows) || []).find((x) => x.key === b.dataset.hmWait); if (!w) return;
|
|
407
|
+
if (w.note) { openMeeting({ note: w.note }); return; }
|
|
408
|
+
if (w.link) { window.open(w.link, '_blank', 'noopener'); return; }
|
|
409
|
+
toast('Its source opens from ' + (w.where || 'its record') + '.');
|
|
410
|
+
}
|
|
376
411
|
/** Your move's ranked list (workspace grill W3, pm/move-rank.js): the products Home reads with their Board rows, the programs, and each
|
|
377
412
|
* product's GET /api/your-move answer (overdue verdicts, the first key result with no reading). */
|
|
378
413
|
function rankIn() {
|
|
@@ -386,7 +421,7 @@ function rankIn() {
|
|
|
386
421
|
if (S.impact && S.impact.c && !S.impact.c.looked) extra.push({ key: 'impact', go: 'impact', title: 'Your impact: ' + S.impact.c.label + ' is ready to check', sub: 'A thank-you and what really moved, from your records.' });
|
|
387
422
|
const lp = LPV.chipOf(); if (lp) extra.push({ key: 'loose', go: 'loose', title: 'Not in an initiative: ' + lp.n + (lp.n === 1 ? ' row' : ' rows') + ' to tidy', sub: 'PMOS proposes where each one belongs.' });
|
|
388
423
|
for (const l of S.lab || []) extra.push({ key: 'lab:' + l.ws, go: 'lab', ws: l.ws, board: l.board, title: 'Lab: ' + l.n + (l.n === 1 ? ' finding fits' : ' findings fit') + ' no initiative', sub: l.say || 'Keep one to start an initiative, or let it go.' });
|
|
389
|
-
return { products, programs: S.D.programs || [], move: S.move || {}, mentions: MEN.mentionsOf(S.D).waiting, outbox: S.outbox || [], extra };
|
|
424
|
+
return { products, programs: S.D.programs || [], move: S.move || {}, mentions: MEN.mentionsOf(S.D).waiting, outbox: S.outbox || [], gaps: (S.wait && S.wait.gaps) || [], extra };
|
|
390
425
|
}
|
|
391
426
|
/** Each product's GET /api/your-move, read when Your day opens (never on Home's first draw: page speed). */
|
|
392
427
|
async function readMove() {
|
|
@@ -412,7 +447,7 @@ async function readMove() {
|
|
|
412
447
|
const lab = labs.filter(Boolean);
|
|
413
448
|
const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []);
|
|
414
449
|
S.move = next; S.outbox = outbox; S.lab = lab;
|
|
415
|
-
if (!same) redrawLater();
|
|
450
|
+
if (!same) { redrawLater(); drawList(); }
|
|
416
451
|
// a demotion notice is said once: drawn now, then marked seen so the next read leaves it out
|
|
417
452
|
for (const [ws, m] of Object.entries(next)) for (const n of m.notices || []) pmPost('/api/autonomy/seen', { ws: ws || undefined, job: n.job, product: n.product, until: n.until }).catch(() => {});
|
|
418
453
|
}
|
|
@@ -425,7 +460,7 @@ function redrawLater() {
|
|
|
425
460
|
const mo = new MutationObserver(() => { if (!body.querySelector(PASSING)) { mo.disconnect(); redrawDay(); } });
|
|
426
461
|
mo.observe(body, { childList: true, subtree: true });
|
|
427
462
|
}
|
|
428
|
-
const moveRow = (key) => { const Y
|
|
463
|
+
const moveRow = (key) => { for (const Y of [S.Y && S.Y.rank, S.topRank]) { const r = Y ? Y.rows.concat(Y.wait || [], Y.older || []).find((x) => x.key === key) : null; if (r) return r; } return null; };
|
|
429
464
|
const insightsHref = (ws) => '/premium-intelligence.html' + (ws ? '?ws=' + encodeURIComponent(ws) : '');
|
|
430
465
|
/** The ✦ of one initiative of any product Home reads, over its page (pm/ini-props.js). */
|
|
431
466
|
async function openProps(ws, board, id) {
|
|
@@ -457,6 +492,7 @@ async function movePress(b) {
|
|
|
457
492
|
{ pmGet, pmPost, toast, toastUndo, reload: () => load().then(() => readMove()), full: () => openProps(r.ws, r.board, r.ini) })); return; }
|
|
458
493
|
if (r.kind === 'meeting') { if (prog) { VW.drill(); goProgram(prog.id); } else if (r.props[0]) { VW.drill(); openProps(r.props[0].ws, r.props[0].board, r.props[0].ini); } return; }
|
|
459
494
|
if (r.kind === 'call') { select(r.call.id); return; }
|
|
495
|
+
if (r.kind === 'owner') { if (r.gap && r.gap.note) openMeeting({ note: r.gap.note }); return; } // an agreed action nobody owns: its note
|
|
460
496
|
VW.drill(); openProps(r.ws, r.board, r.ini); return;
|
|
461
497
|
}
|
|
462
498
|
b.disabled = true;
|
|
@@ -829,6 +865,17 @@ function cardHtml(id, o = {}) {
|
|
|
829
865
|
+ `<div class="hm-acts"><button type="button" class="hm-cta${primary ? '' : ' alt'}" data-hm-cta>${esc(cta)}</button>`
|
|
830
866
|
+ `<button type="button" class="hm-ov" data-hm-ov aria-label="Overview of ${esc(title)} with PMOS" title="Overview with PMOS">${avHtml(CLAUDE, 24)}</button></div></div></section>`;
|
|
831
867
|
}
|
|
868
|
+
/** The top of Home lives in one node of its own (TOPEL) that the list's slot holds. GET /api/your-move and GET /api/waiting answer after
|
|
869
|
+
* the list is drawn: they change this node only, so the rows under it are never drawn again under a press, a hold or a drag. */
|
|
870
|
+
const TOPEL = document.createElement('div');
|
|
871
|
+
TOPEL.className = 'hy-wrap';
|
|
872
|
+
function drawTopNode(sc) {
|
|
873
|
+
const h = S.topHtml || '';
|
|
874
|
+
if (TOPEL.__h !== h) { TOPEL.__h = h; TOPEL.innerHTML = h; }
|
|
875
|
+
const slot = sc.querySelector('[data-hm-topslot]');
|
|
876
|
+
if (slot && h) slot.replaceWith(TOPEL); else if (slot) slot.remove();
|
|
877
|
+
if (!h && TOPEL.parentNode) TOPEL.remove();
|
|
878
|
+
}
|
|
832
879
|
function drawList() {
|
|
833
880
|
const el = $('#hmList');
|
|
834
881
|
// the list column: the groups scroll; the foot is empty since the Elsewhere card went (HbC: the list never leaves)
|
|
@@ -841,6 +888,7 @@ function drawList() {
|
|
|
841
888
|
sc.querySelectorAll('.hm-load i[data-f]').forEach((i) => i.style.setProperty('--bd-f', i.dataset.f)); // the day's load: run-time geometry
|
|
842
889
|
const c2 = sc.querySelector('#hmCap'); if (c2 && capV) { c2.value = capV; } if (c2 && capF) c2.focus(); // a task being typed survives a redraw
|
|
843
890
|
}
|
|
891
|
+
drawTopNode(sc);
|
|
844
892
|
const dh = dayHtml();
|
|
845
893
|
if (dy.__h !== dh) { dy.__h = dh; dy.innerHTML = dh; dy.querySelectorAll('.hm-load i[data-f]').forEach((i) => i.style.setProperty('--bd-f', i.dataset.f)); }
|
|
846
894
|
document.body.classList.toggle('hm-dayon', !!dh);
|
|
@@ -2086,6 +2134,13 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
|
|
|
2086
2134
|
const b = e.target.closest('button'); if (!b) return;
|
|
2087
2135
|
const d = b.dataset;
|
|
2088
2136
|
if ('hmRcx' in d) { railCard(null, { back: true }); return; } // × on the folded rail's card
|
|
2137
|
+
// the top of Home (home-your-move-waiting): a Your move row presses as it does on Good morning; Waiting on others opens its nudge or source
|
|
2138
|
+
if (b.closest('.hy')) {
|
|
2139
|
+
if (/^mv-/.test(d.yd || '')) { movePress(b); return; }
|
|
2140
|
+
if (d.yd === 'done-undo') { doneUndo(b); return; }
|
|
2141
|
+
if ('hmTopall' in d) { S.topAll = !S.topAll; drawList(); const f = $('#hmList [data-hm-topall]'); if (f) f.focus(); return; }
|
|
2142
|
+
if (d.hmNudge || d.hmWait) { waitPress(b); return; }
|
|
2143
|
+
}
|
|
2089
2144
|
// a pick in the rail's card: the card closes, the rail stays folded and the Viewer as wide (FlA4After)
|
|
2090
2145
|
if (S.rc && b.closest('.hv-rc') && (d.hmSel || d.hmProg || d.hmProdopen || d.hmSesnew)) { S.rc = null; S.ses = null; VW.keepWide(); }
|
|
2091
2146
|
if (d.hmSes) { sesPill(d.hmSes === S.ses ? null : d.hmSes); return; } // an initiative's pill: what sits in it, under it (a sheet on a phone)
|
|
@@ -168,13 +168,16 @@ export function dayModel(M, D, R, now = Date.now(), o = {}) {
|
|
|
168
168
|
if (!run && h < 17 && t.length) offer = { kind: 'prep', text: 'I haven’t prepared today yet.', sub: 'Shall I prep your meetings and draft what I can?' };
|
|
169
169
|
return {
|
|
170
170
|
mood, face: run && run.working && mood === 'calm' ? 'working' : mood, line, sub, chips, misses, offer, calls, drafts, wait, done, thanks, fail, failLead, calm, ask: o.ask || null,
|
|
171
|
-
rank: o.rank ? rankMove({ ...o.rank, calls, now }) : null,
|
|
171
|
+
rank: o.rank ? rankMove({ ...o.rank, calls: callsOf(move), now }) : null,
|
|
172
172
|
news: newsOf(o.news), digests: digestsOf(D), tomorrow: tomorrowOf(D, now),
|
|
173
173
|
next: next ? { meeting: next, now: next.state === 'now', time: hm(next.start), title: next.title || 'A meeting' } : null,
|
|
174
174
|
week: { sub: un || 'Weekly review' },
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
/** The rows of Home's list that are the PM's calls for the ranked list: the calls, and the weekly update (a message to people: it goes out
|
|
179
|
+
* only when the PM sends it). Good morning and Home's top both rank these (home-your-move-waiting: one source). */
|
|
180
|
+
export const callsOf = (move) => (move || []).filter((r) => r && (r.call || r.kind === 'update'));
|
|
178
181
|
/* Claude's face is Adler's M face (it replaced the yellow mood circle): the day's mood read as his */
|
|
179
182
|
export const ADLER = { glad: 'handled', calm: 'handled', delighted: 'celebrating', concerned: 'honest', working: 'thinking' };
|
|
180
183
|
export const faceHtml = (mood) => `<span class="yd-face ad ${esc(mood)}">${adler(ADLER[mood] || 'handled', 48, { label: 'PMOS is ' + mood })}</span>`;
|
|
@@ -224,7 +224,7 @@ function openNeeds(D) {
|
|
|
224
224
|
return needsOf(D).filter((x) => !x.ini || x.needSession || !shut.has(x.ini));
|
|
225
225
|
}
|
|
226
226
|
const sameName = (a, b) => String(a || '').toLowerCase() === String(b || '').toLowerCase();
|
|
227
|
-
/** o: { filter ('today' | 'kept' | 'done'), now }. The products are the ticked ones (productsOf). */
|
|
227
|
+
/** o: { filter ('today' | 'mine' | 'kept' | 'done'), now }. The products are the ticked ones (productsOf). */
|
|
228
228
|
export function homeList(D, o = {}) {
|
|
229
229
|
const now = o.now || D.now || Date.now();
|
|
230
230
|
const needs = openNeeds(D);
|
|
@@ -236,6 +236,7 @@ export function homeList(D, o = {}) {
|
|
|
236
236
|
const tabRows = (k) => { const t = tab(k); return t ? t.groups.flatMap((g) => g.rows || []) : []; };
|
|
237
237
|
// Kept and Done only (testing fixes: no Today or Waiting chip; the list is Today unless one of these two is on, and pressing it again goes back)
|
|
238
238
|
const filters = [
|
|
239
|
+
{ key: 'mine', label: 'Mine' }, // home-your-move-waiting: only the rows that wait on you (the existing Show menu, no new switch)
|
|
239
240
|
{ key: 'kept', label: 'Kept', n: (tab('kept') || {}).n || 0 },
|
|
240
241
|
{ key: 'done', label: 'Done' },
|
|
241
242
|
];
|
|
@@ -293,6 +294,7 @@ export function homeList(D, o = {}) {
|
|
|
293
294
|
}
|
|
294
295
|
const move = moveOf(groups, needs);
|
|
295
296
|
const yours = move.length;
|
|
297
|
+
if (o.filter === 'mine') list = { title: 'Waiting on you', rows: move.map((r) => ({ ...r, hint: r.sub || r.hint || '' })), empty: 'Nothing waits on you.' };
|
|
296
298
|
const nIni = groups.filter((g) => g.kind === 'product' || g.kind === 'program').reduce((n, g) => n + g.count, 0);
|
|
297
299
|
return { yours, move, greet: greeting(yours, now), word: greetWord(now), products, primary, filters, filter: o.filter || 'today', groups, list, untouched,
|
|
298
300
|
counts: { products: products.length, initiatives: nIni } };
|