create-pmos 0.401.0 → 0.403.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +25 -30
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/board-programs-test.js +227 -0
- package/workspace/board-shot.js +54 -0
- package/workspace/briefing-premium-adddoc-test.js +28 -22
- package/workspace/briefing-premium-board-test.js +107 -82
- package/workspace/briefing-premium-calendar-2-test.js +23 -10
- package/workspace/briefing-premium-calendar-3-test.js +23 -19
- package/workspace/briefing-premium-calendar-test.js +20 -15
- package/workspace/briefing-premium-initiative-test.js +25 -12
- package/workspace/briefing-premium-insights-test.js +31 -18
- package/workspace/briefing-premium-metrics-test.js +8 -8
- package/workspace/briefing-premium-sources-test.js +15 -10
- package/workspace/briefing-premium-test.js +39 -16
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/board-premium-facts.js +20 -3
- package/workspace/fixtures/briefing-premium-facts.js +18 -2
- package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
- package/workspace/fixtures/program-ascent.js +101 -0
- package/workspace/guide/home.md +11 -7
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/jira.md +38 -6
- package/workspace/guide/programs.md +37 -0
- package/workspace/home-rows-test.js +184 -0
- package/workspace/lib/briefing-premium-products.js +4 -4
- package/workspace/lib/briefing-premium.js +2 -2
- package/workspace/lib/calendar-layers.js +8 -4
- package/workspace/lib/initiative-layout.js +4 -3
- package/workspace/lib/jira-cli.js +17 -12
- package/workspace/lib/jira-status.js +1 -1
- package/workspace/lib/jira-tickets.js +126 -24
- package/workspace/lib/meeting-files.js +58 -0
- package/workspace/lib/meeting-learn.js +139 -0
- package/workspace/lib/meeting-material.js +12 -5
- package/workspace/lib/notes.js +3 -0
- package/workspace/lib/programs.js +129 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-brief-page.js +8 -1
- package/workspace/lib/routes-briefing-premium.js +1 -1
- package/workspace/lib/routes-calendar-views.js +24 -3
- package/workspace/lib/routes-meeting-material.js +38 -0
- package/workspace/lib/routes-meeting-points.js +23 -3
- package/workspace/lib/routes-programs.js +122 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +31 -25
- package/workspace/premium-chat-context-test.js +1 -1
- package/workspace/premium-chat-goal-view-test.js +1 -1
- package/workspace/premium-chat-viewer-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +13 -7
- package/workspace/premium-discuss-landing-test.js +83 -0
- package/workspace/premium-link-suggest-test.js +103 -0
- package/workspace/premium-report-read-test.js +86 -82
- package/workspace/premium-vw-backlog-test.js +6 -5
- package/workspace/premium-vw-cal-test.js +45 -19
- package/workspace/premium-vw-item-test.js +8 -6
- package/workspace/premium-vw-jira-test.js +3 -2
- package/workspace/premium-vw-meet-test.js +122 -66
- package/workspace/premium-vw-notes-test.js +7 -6
- package/workspace/premium-vw-rec-test.js +14 -13
- package/workspace/premium-vw-slides-test.js +11 -5
- package/workspace/program-panel-test.js +152 -0
- package/workspace/public/pm/bd-acts.js +24 -15
- package/workspace/public/pm/bd-asks.js +111 -30
- package/workspace/public/pm/bd-ini-panel.js +229 -0
- package/workspace/public/pm/bd-pop.js +2 -2
- package/workspace/public/pm/bd-prog-panel.js +436 -0
- package/workspace/public/pm/bd-prog.js +191 -0
- package/workspace/public/pm/bd-span.js +98 -15
- package/workspace/public/pm/bd-views.js +93 -29
- package/workspace/public/pm/cozy-board.css +214 -20
- package/workspace/public/pm/cozy-evui.js +4 -2
- package/workspace/public/pm/cozy-home-rows.css +54 -0
- package/workspace/public/pm/cozy-home.css +35 -0
- package/workspace/public/pm/cozy-insights.css +1 -2
- package/workspace/public/pm/cozy-mtg-present.css +160 -0
- package/workspace/public/pm/cozy-panel.css +155 -0
- package/workspace/public/pm/cozy-rec-pill.css +12 -0
- package/workspace/public/pm/cozy-rec-pill.js +46 -0
- package/workspace/public/pm/cozy-today.css +189 -0
- package/workspace/public/pm/cozy-viewer.js +307 -43
- package/workspace/public/pm/cozy-vw-mtg.css +96 -94
- package/workspace/public/pm/cozy-vw-rp.css +40 -25
- package/workspace/public/pm/cozy-vw-shell.css +127 -0
- package/workspace/public/pm/cozy-xv.css +51 -0
- package/workspace/public/pm/cozy-xv.js +34 -0
- package/workspace/public/pm/home-app.js +192 -72
- package/workspace/public/pm/home-chat.js +17 -4
- package/workspace/public/pm/home-data.js +1 -1
- package/workspace/public/pm/home-day.js +64 -0
- package/workspace/public/pm/home-ini-model.js +1 -1
- package/workspace/public/pm/home-ini.js +197 -54
- package/workspace/public/pm/home-list.js +100 -27
- package/workspace/public/pm/home-mentions.js +187 -0
- package/workspace/public/pm/home-rec-row.js +67 -0
- package/workspace/public/pm/home-review.js +20 -10
- package/workspace/public/pm/home-task.js +19 -18
- package/workspace/public/pm/home-today.js +137 -59
- package/workspace/public/pm/premium-board.js +294 -288
- package/workspace/public/pm/premium-insights.js +118 -82
- package/workspace/public/pm/premium-mtg-present.js +408 -100
- package/workspace/public/pm/premium-mtg-replay.js +70 -10
- package/workspace/public/pm/premium-report-read.js +118 -63
- package/workspace/public/pm/premium-vw-cal.js +62 -34
- package/workspace/public/pm/premium-vw-mtg.js +348 -192
- package/workspace/public/pm/program-model.js +192 -0
- package/workspace/public/pm/rec-state.js +63 -0
- package/workspace/public/pm/rp-parts.js +33 -8
- package/workspace/public/pm/tk-draft.js +107 -0
- package/workspace/public/pm/tk-model.js +134 -0
- package/workspace/public/pm/tk-send.js +124 -0
- package/workspace/public/pm/tk-tasks.css +120 -0
- package/workspace/public/premium-board.html +4 -2
- package/workspace/server.js +4 -2
- package/workspace/skills/jira-push.skill +3 -3
- package/workspace/test-lists/board-programs.json +9 -0
- package/workspace/test-lists/prd-to-jira.json +6 -0
- package/workspace/test-lists/program-hierarchy.json +11 -0
- package/workspace/test-lists/program-panel.json +9 -0
- package/workspace/test-lists/viewer-home-rows.json +9 -0
- package/workspace/test-lists/viewer-meetings.json +9 -0
- package/workspace/test-lists/viewer-shell-a.json +15 -0
- package/workspace/tk-tasks-test.js +199 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/* pm/home-list.js — Home's one list, pure (initiative premium-uncovered-features, H1 and H2; canvas HmMyWork, HmReview, HmProducts, HmDay,
|
|
2
|
-
* HmDecide, HmMic, HmPhone, HmPhone2)
|
|
2
|
+
* HmDecide, HmMic, HmPhone, HmPhone2), in the Home A + C design with programs (initiative program-hierarchy, H1 to H4; canvas HvAC, HvAOpen,
|
|
3
|
+
* HvACDesk, PgHomePhone, PgHomeDesk).
|
|
3
4
|
*
|
|
4
5
|
* There is no Needs you group and no Your list (PM, canvas review 2026-10-22/23): every next step sits under its initiative, and the list is
|
|
5
6
|
* grouped by product. This file turns what the routes answer into what the list draws, and touches no page, so a node test imports it:
|
|
6
7
|
* productsOf(D) the products the list shows: the board's own first, then every product Home reads (GET /api/briefing-premium products)
|
|
7
8
|
* and every product a next step names; each with its goals line ("2 of 4 goals on track")
|
|
8
|
-
* homeList(D, o) { greet, yours, filters, groups, untouched, filter } for the list column
|
|
9
|
+
* homeList(D, o) { greet, yours, move, filters, groups, untouched, filter } for the list column; move is Your move (HvAOpen):
|
|
10
|
+
* every row that waits on the PM, the late ones of the PM's own tasks and items first. yours is its length
|
|
9
11
|
* todayCard(D, o) the Today card through the day: day (greeting and the day's load), soon (a meeting in 15 minutes or less), live
|
|
10
12
|
* (a meeting on now), rec (a recording that is no calendar meeting), eod (the end of a day with something open), clear
|
|
11
13
|
* staleInis(D, now, days) open initiatives with no change for `days` days or more, the longest first
|
|
@@ -14,6 +16,8 @@
|
|
|
14
16
|
* D is home-data.js's D plus { work (GET /api/my-work-premium model), items (GET /api/boards/items), others ([{ ws, name, model }], the boards of
|
|
15
17
|
* the other products), phoneDay (GET /api/phone-day), review (GET /api/home-review) }. A part that did not answer is left out, never guessed. */
|
|
16
18
|
import { needsOf, boardRows, productCard, productName, sessionRow, iniOfSession, todayOf, live, OPEN, hm } from './home-data.js';
|
|
19
|
+
import { programState, groupRows } from './program-model.js';
|
|
20
|
+
import { STEPS, stageKey } from './premium-initiative-head.js';
|
|
17
21
|
|
|
18
22
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
23
|
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
@@ -35,11 +39,17 @@ export function greeting(n, now = Date.now()) {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/* ── products ── */
|
|
42
|
+
/** The product tiles' tints (HvAC .tl.a, .tl.b, .tl.c): a product keeps its tint by its place in the list, in its group and in a program. */
|
|
43
|
+
export const TONES = 3;
|
|
44
|
+
// a product's tile: the workspace's own abbreviation when it has one (Settings, the rail's initials: "MS"), else two letters of its name
|
|
45
|
+
const codeOf = (p) => { const c = String((p && p.code) || '').replace(/[^A-Za-z0-9]/g, '').slice(0, 3).toUpperCase(); return c || initialsOf(p && p.name); };
|
|
38
46
|
const initialsOf = (name) => { const w = String(name || '').trim().split(/[\s_-]+/).filter(Boolean); return (w.length > 1 ? w[0][0] + w[1][0] : String(name || '?').slice(0, 2)).toUpperCase(); };
|
|
39
|
-
|
|
47
|
+
/** A product's goals line and dots from its Board model (the Board's product groups draw the same dots, pm/bd-prog.js). */
|
|
48
|
+
export function goalsOf(model) {
|
|
40
49
|
const C = productCard({ board: model });
|
|
41
50
|
const n = C.items.length, ok = C.items.filter((x) => x.kind === 'ok').length;
|
|
42
|
-
|
|
51
|
+
// the header's goal dots (HvAC .gd): one per KR or budget, green on track, amber at risk
|
|
52
|
+
return { ok, n, text: n ? ok + ' of ' + n + ' goals on track' : 'No goal anchored yet', dots: C.items.map((x) => x.kind === 'ok') };
|
|
43
53
|
}
|
|
44
54
|
/* A row the brief tags "Across products" names no product: it is not a group of its own, it sits with the rows that name none. */
|
|
45
55
|
const ACROSS = 'Across products';
|
|
@@ -47,13 +57,13 @@ const prodOf = (x) => (x && x.product && x.product !== ACROSS ? x.product : '');
|
|
|
47
57
|
/** The products the list shows, the board's own product first. Each: { key, ws, name, initials, primary, model, goals, on }. */
|
|
48
58
|
export function productsOf(D) {
|
|
49
59
|
const out = [];
|
|
50
|
-
const add = (p) => { const k = p.ws || 'n:' + String(p.name).toLowerCase(); if (out.some((x) => x.key === k || x.name.toLowerCase() === String(p.name).toLowerCase())) return; out.push({ ...p, key: k, initials:
|
|
60
|
+
const add = (p) => { const k = p.ws || 'n:' + String(p.name).toLowerCase(); if (out.some((x) => x.key === k || x.name.toLowerCase() === String(p.name).toLowerCase())) return; out.push({ ...p, key: k, initials: codeOf(p) }); };
|
|
51
61
|
const b = D.board && D.board.board;
|
|
52
62
|
const av = (D.brief && D.brief.products && D.brief.products.available) || [];
|
|
53
|
-
const
|
|
54
|
-
if (D.board) add({ ws: (b && b.ws) || '', name: (b && b.product) || named(b && b.ws) || productName(D), primary: true, model: D.board, goals: goalsOf(D.board) });
|
|
55
|
-
for (const o of D.others || []) if (o && o.model) add({ ws: o.ws, name: o.name || productName({ board: o.model }), primary: false, model: o.model, goals: goalsOf(o.model) });
|
|
56
|
-
for (const a of av) if (a.on) add({ ws: a.ws, name: a.name, primary: false, model: null, goals: null });
|
|
63
|
+
const avOf = (ws) => (ws && av.find((a) => a.ws === ws)) || {}, named = (ws) => avOf(ws).name || '';
|
|
64
|
+
if (D.board) add({ ws: (b && b.ws) || '', name: (b && b.product) || named(b && b.ws) || productName(D), code: avOf(b && b.ws).initials, primary: true, model: D.board, goals: goalsOf(D.board) });
|
|
65
|
+
for (const o of D.others || []) if (o && o.model) add({ ws: o.ws, name: o.name || productName({ board: o.model }), code: avOf(o.ws).initials, primary: false, model: o.model, goals: goalsOf(o.model) });
|
|
66
|
+
for (const a of av) if (a.on) add({ ws: a.ws, name: a.name, code: a.initials, primary: false, model: null, goals: null });
|
|
57
67
|
for (const r of needsOf(D)) if (prodOf(r)) add({ ws: '', name: r.product, primary: false, model: null, goals: null });
|
|
58
68
|
return out;
|
|
59
69
|
}
|
|
@@ -87,18 +97,17 @@ export function tasksOf(D, ini, now = Date.now()) {
|
|
|
87
97
|
function meetRow(m, ini) {
|
|
88
98
|
return { id: 'm:' + (m.id || m.title), kind: 'meeting', ini: ini || null, name: m.title, hint: (m.state === 'now' ? 'Now' : hm(m.start)) + (ini ? ' meeting' : ' · not linked'), state: m.state === 'now' ? 'working' : 'quiet', icon: 'clock', meeting: m };
|
|
89
99
|
}
|
|
90
|
-
/** Today's unread mentions of the PM (GET /api/brief-page mentions). One that names an initiative is that initiative's next step. */
|
|
91
|
-
const mentionsOf = (D) => (D.today && Array.isArray(D.today.mentions) ? D.today.mentions : []).filter((m) => m && !m.read && !m.done);
|
|
92
|
-
function mentionRow(m, ini) {
|
|
93
|
-
return { id: 'men:' + (m.id || m.at), kind: 'mention', ini: ini || null, name: (m.who ? m.who + ' ' : '') + (m.text ? 'asks: ' + m.text : 'named you'),
|
|
94
|
-
hint: (ini ? 'Next step · ' : '') + 'Mention' + (m.where ? ' · ' + m.where : m.source ? ' · ' + cap1(m.source) : ''), state: 'needs', mention: m, link: m.link || '', step: !!ini };
|
|
95
|
-
}
|
|
96
100
|
const meetIni = (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null;
|
|
97
101
|
/** A next step's hint without its product's name: the product is the group's header. */
|
|
98
102
|
const bareHint = (x) => { const h = String(x.hint || ''), p = prodOf(x); return p && h.startsWith(p + ' · ') ? h.slice(p.length + 3) : p && h === p ? '' : h; }; // the group names the product; "Across products" stays
|
|
103
|
+
/** Where an initiative is on the eight stages (the row's stage track, HvAC .mt): 0 Triage … 7 Evaluate, or -1 when its stage is not one of them. */
|
|
104
|
+
export const stageAt = (stage) => { const k = stageKey(stage); return k ? STEPS.findIndex((s) => s.key === k) : -1; };
|
|
105
|
+
/** A row under an initiative that is the PM's move now (Your move, and the initiative's count badge): a next step, a session
|
|
106
|
+
* that waits on the PM, or a task of the PM's own that is late. */
|
|
107
|
+
const isMove = (k) => k.step || (k.kind === 'session' && (k.state === 'needs' || k.state === 'blocked')) || (k.kind === 'task' && k.mine && k.late);
|
|
99
108
|
function iniRowOf(D, r, needs, now) {
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
// a mention is not a row here: Mentions is its own row at the top of Home (home-mentions.js, XvANew), so it shows once
|
|
110
|
+
const steps = needs.filter((x) => x.ini === r.id && !x.needSession).map((x) => ({ ...x, step: true, hint: 'Next step' + (bareHint(x) ? ' · ' + bareHint(x) : '') }));
|
|
102
111
|
const ses = (D.sessions || []).filter((s) => live(s) && iniOfSession(s) === r.id).map((s) => sessionRow(s, D.desk && D.desk.roles));
|
|
103
112
|
const tasks = tasksOf(D, r.id, now);
|
|
104
113
|
const meet = todayOf(D).filter((m) => meetIni(m) === r.id && m.state !== 'past').map((m) => meetRow(m, r.id));
|
|
@@ -109,7 +118,49 @@ function iniRowOf(D, r, needs, now) {
|
|
|
109
118
|
// next steps, sessions and today's meetings always show; tasks show the TASKS_SHOWN most urgent, the rest behind "Show N more tasks"
|
|
110
119
|
const kids = [...steps, ...ses.sort((a, b) => (RANK[b.state] || 0) - (RANK[a.state] || 0)), ...tasks.map((t, i) => (i < TASKS_SHOWN ? t : { ...t, extra: true })), ...meet];
|
|
111
120
|
const hint = r.made ? [cap1(r.lane), r.stage].filter(Boolean).join(' · ') : [cap1(r.lane || 'feature'), r.stage].filter(Boolean).join(' · ');
|
|
112
|
-
return { id: 'i:' + r.id, kind: 'ini', ini: r.id, name: r.title, hint, right, turn, busy: kids.length > 0, state: turn ? 'needs' : run ? 'working' : 'quiet', kids, board: r, updated: r.updated || ''
|
|
121
|
+
return { id: 'i:' + r.id, kind: 'ini', ini: r.id, name: r.title, hint, right, turn, busy: kids.length > 0, state: turn ? 'needs' : run ? 'working' : 'quiet', kids, board: r, updated: r.updated || '',
|
|
122
|
+
stage: r.stage || '', at: stageAt(r.stage), yours: kids.filter(isMove).length, late: kids.some((k) => k.kind === 'task' && k.mine && k.late) };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* ── programs (initiative program-hierarchy, H4; canvas PgHomePhone, PgHomeDesk) ── */
|
|
126
|
+
const closedOf = (n, turnN) => [n ? plural(n, 'initiative', 'initiatives') : '', turnN ? turnN + ' your turn' : ''].filter(Boolean).join(' · ') || 'Nothing open';
|
|
127
|
+
const isMe = (D, who) => { const me = String((D.today && D.today.me) || '').toLowerCase(), w = String(who || '').toLowerCase(); return !w || /^(pm|you)(:|$)/.test(w) || (!!me && (w === me || w.startsWith(me + ' '))); };
|
|
128
|
+
/** One group per program that has an initiative or an open task in the products shown, placed above the products. The grouping is
|
|
129
|
+
* groupRows (program-model.js), the one Board and Kanban use: a program's initiatives leave their product's group, so each initiative shows
|
|
130
|
+
* once, and sit under one sub-heading per product, in the order the products first appear. The program's own open tasks come first.
|
|
131
|
+
* With one product picked, only that product's initiatives and tasks show. D.programs is GET /api/programs' programs. */
|
|
132
|
+
export function programGroups(D, groups, products, o, now) {
|
|
133
|
+
const rowsOf = (ws) => { const p = products.find((x) => x.ws === ws); return p ? { name: p.name, rows: (p.model && p.model.initiatives && p.model.initiatives.list && p.model.initiatives.list.rows) || (p.primary ? boardRows(D) : []) } : null; };
|
|
134
|
+
const pgs = groups.filter((g) => g.kind === 'product');
|
|
135
|
+
const items = pgs.flatMap((g) => g.inis.concat(g.rest).map((r) => ({ id: r.ini, ws: g.product.ws, product: g.name, r, g })));
|
|
136
|
+
const grouped = groupRows(items, D.programs, { productOf: (x) => x.product, wsOf: (x) => x.ws });
|
|
137
|
+
const out = [];
|
|
138
|
+
for (const pr of (D.programs || []).filter((p) => p && !p.archived)) {
|
|
139
|
+
const G = grouped.find((x) => x.kind === 'program' && x.program.id === pr.id);
|
|
140
|
+
for (const x of (G && G.rows) || []) {
|
|
141
|
+
const g = x.g;
|
|
142
|
+
for (const k of ['inis', 'rest']) { const i = g[k].indexOf(x.r); if (i >= 0) g[k].splice(i, 1); }
|
|
143
|
+
g.count -= 1;
|
|
144
|
+
if (x.r.turn) g.turnN -= 1;
|
|
145
|
+
g.yours -= x.r.yours;
|
|
146
|
+
g.late = g.inis.concat(g.rest).some((i) => i.late);
|
|
147
|
+
g.closedLine = closedOf(g.count, g.turnN);
|
|
148
|
+
}
|
|
149
|
+
const tasks = (pr.tasks || []).filter((t) => !t.done && (!o.product || !t.ws || products.some((p) => p.key === o.product && p.ws === t.ws))).map((t) => {
|
|
150
|
+
const d = t.due ? dayDiff(t.due, now) : null;
|
|
151
|
+
return { id: 'pt:' + pr.id + ':' + t.key, kind: 'ptask', program: pr.id, key: t.key, ws: t.ws, name: t.title, check: true, state: 'quiet', mine: isMe(D, t.owner), late: d != null && d < 0, due: t.due || '',
|
|
152
|
+
hint: [t.owner, d == null ? '' : d < 0 ? plural(-d, 'day', 'days') + ' late' : d === 0 ? 'due today' : 'due ' + shortDay(t.due)].filter(Boolean).join(' · ') };
|
|
153
|
+
});
|
|
154
|
+
const subs = ((G && G.products) || []).map((sp) => { const at = products.findIndex((p) => p.name === sp.name); return { name: sp.name, initials: at >= 0 ? products[at].initials : initialsOf(sp.name), tone: Math.max(0, at) % TONES, inis: sp.rows.map((x) => x.r) }; });
|
|
155
|
+
const inis = subs.flatMap((x) => x.inis);
|
|
156
|
+
if (!inis.length && !tasks.length) continue;
|
|
157
|
+
const st = programState(pr, rowsOf, now);
|
|
158
|
+
const turnN = inis.filter((x) => x.turn).length;
|
|
159
|
+
out.push({ key: 'g:' + pr.id, kind: 'program', program: pr, st, name: pr.title, subs, inis, rest: [], tasks, count: inis.length, turnN,
|
|
160
|
+
yours: inis.reduce((n, x) => n + x.yours, 0) + tasks.filter((t) => t.mine && t.late).length, late: inis.some((x) => x.late) || tasks.some((t) => t.late),
|
|
161
|
+
products: st.products, closedLine: closedOf(inis.length, turnN) });
|
|
162
|
+
}
|
|
163
|
+
return out;
|
|
113
164
|
}
|
|
114
165
|
|
|
115
166
|
/* ── the list ── */
|
|
@@ -148,19 +199,21 @@ export function homeList(D, o = {}) {
|
|
|
148
199
|
const flat = mineNeeds.filter((x) => !x.ini || !ids.has(x.ini)).filter((x) => !x.needSession).map((x) => ({ ...x, flat: true, hint: bareHint(x) }));
|
|
149
200
|
const turnN = inis.filter((x) => x.turn).length + flat.length;
|
|
150
201
|
const shown = inis.filter((x) => x.turn || x.busy);
|
|
151
|
-
groups.push({ key: 'p:' + p.key, kind: 'product', product: p, name: p.name, primary: !!p.primary, goals: p.goals, flat, inis: shown, rest: inis.filter((x) => !shown.includes(x)),
|
|
152
|
-
count: inis.length, turnN, closedLine: [inis.length ? plural(inis.length, 'initiative', 'initiatives') : '', turnN ? turnN + ' your turn' : ''].filter(Boolean).join(' · ') || 'Nothing open' });
|
|
202
|
+
groups.push({ key: 'p:' + p.key, kind: 'product', product: p, name: p.name, initials: p.initials, tone: products.indexOf(p) % TONES, primary: !!p.primary, goals: p.goals, flat, inis: shown, rest: inis.filter((x) => !shown.includes(x)),
|
|
203
|
+
count: inis.length, turnN, yours: inis.reduce((n, x) => n + x.yours, 0) + flat.length, late: inis.some((x) => x.late), closedLine: [inis.length ? plural(inis.length, 'initiative', 'initiatives') : '', turnN ? turnN + ' your turn' : ''].filter(Boolean).join(' · ') || 'Nothing open' });
|
|
153
204
|
}
|
|
205
|
+
// programs first (program-hierarchy P3): each program takes its initiatives out of their product groups, so an initiative shows once
|
|
206
|
+
groups.unshift(...programGroups(D, groups, products, o, now));
|
|
154
207
|
// sessions that wait on the PM and belong to no initiative of a product: they are next steps too, under "Not in an initiative"
|
|
155
208
|
const looseNeeds = needs.filter((x) => !used.has(x.id) && !(x.ini && groups.some((g) => g.inis.concat(g.rest).some((i) => i.ini === x.ini))));
|
|
156
209
|
const loose = [];
|
|
157
210
|
for (const x of looseNeeds) loose.push({ ...x, flat: true });
|
|
158
|
-
for (const r of tabRows('today')) loose.push({ id: 'w:' + r.key, kind: 'item', key: r.key, name: r.title, hint: [r.overdue ? 'late' : '', String(r.sub || '').replace(/^Yours\b\s*(·\s*)?/, '')].filter(Boolean).join(' · '), check: true, item: r }); // the check box says it is the PM's own: no "your own note" on every row (testing fixes)
|
|
159
|
-
const inIni = new Set(groups.flatMap((g) => g.inis.concat(g.rest)).map((i) => i.ini));
|
|
160
|
-
for (const m of mentionsOf(D).filter((x) => !(x.initiative && inIni.has(x.initiative)))) loose.push(mentionRow(m, null));
|
|
211
|
+
for (const r of tabRows('today')) loose.push({ id: 'w:' + r.key, kind: 'item', key: r.key, name: r.title, hint: [r.overdue ? 'late' : '', String(r.sub || '').replace(/^Yours\b\s*(·\s*)?/, '')].filter(Boolean).join(' · '), check: true, mine: true, late: !!r.overdue, item: r }); // the check box says it is the PM's own: no "your own note" on every row (testing fixes)
|
|
161
212
|
for (const m of todayOf(D).filter((x) => !meetIni(x) && x.state !== 'past')) loose.push(meetRow(m, null));
|
|
162
213
|
for (const s of (D.sessions || []).filter((s) => live(s) && !iniOfSession(s) && s.shown !== 'needs' && s.shown !== 'blocked')) loose.push({ ...sessionRow(s, D.desk && D.desk.roles), loose: true });
|
|
163
|
-
|
|
214
|
+
// the folded line's signals (HvAC .lh): a blue dot when a row waits on the PM, an amber square when one of the PM's own is late
|
|
215
|
+
const lsig = { needs: loose.filter((r) => r.state === 'needs' || r.state === 'blocked').length, sessions: loose.filter((r) => r.kind === 'session' || r.needSession).length, tasks: loose.filter((r) => r.check).length, late: loose.filter((r) => r.check && r.late).length };
|
|
216
|
+
if (!o.product || o.product === 'loose') groups.push({ key: 'loose', kind: 'loose', name: 'Not in an initiative', rows: loose, n: loose.length, sig: lsig });
|
|
164
217
|
const stale = staleInis(D, now);
|
|
165
218
|
const untouched = { n: stale.length + ((W && W.review && W.review.n) || 0), inis: stale.length, items: (W && W.review && W.review.n) || 0, day: new Date(now).getDay() === REVIEW_DAY ? 'today' : 'Fri' };
|
|
166
219
|
// a filter other than Today shows one plain list from the PM's own list (the items carry no initiative)
|
|
@@ -172,12 +225,32 @@ export function homeList(D, o = {}) {
|
|
|
172
225
|
for (const f of fin) done.push({ id: 'fin:' + (f.id || f.title), kind: 'finished', name: f.title, hint: f.status === 'review' ? 'Finished · waits for your review' : 'Finished', done: true, finished: f });
|
|
173
226
|
list = { title: 'Done today', rows: done, empty: 'Nothing is done yet today.' };
|
|
174
227
|
}
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
|
|
228
|
+
const move = moveOf(groups, needs);
|
|
229
|
+
const yours = move.length;
|
|
230
|
+
const nIni = groups.filter((g) => g.kind === 'product' || g.kind === 'program').reduce((n, g) => n + g.count, 0);
|
|
231
|
+
return { yours, move, greet: greeting(yours, now), word: greetWord(now), products, primary, filters, filter: o.filter || 'today', groups, list, untouched,
|
|
178
232
|
counts: { products: products.length, initiatives: nIni } };
|
|
179
233
|
}
|
|
180
234
|
|
|
235
|
+
/* ── Your move (HvAOpen) ── */
|
|
236
|
+
/** Every row that is the PM's move, in one list for the Your day sheet: the PM's own late tasks and items first, then each next step and
|
|
237
|
+
* waiting session in the list's order. A row keeps its list id, so a press opens what the list row opens. Each row:
|
|
238
|
+
* { id, name, sub (its initiative, or the hint of a row with none), late, state, when (the weekly update's send time) }. */
|
|
239
|
+
function moveOf(groups, needs) {
|
|
240
|
+
const late = [], rest = [], seen = new Set();
|
|
241
|
+
const put = (L, r, sub) => { if (!r || seen.has(r.id)) return; seen.add(r.id); L.push({ id: r.id, name: r.name, sub: sub || '', late: !!r.late, state: r.state || 'needs', check: !!(r.check || r.kind === 'task'), when: whenOf(r) }); };
|
|
242
|
+
for (const g of groups) {
|
|
243
|
+
if (g.kind === 'loose') { for (const r of g.rows) if (r.check && r.late) put(late, r); else if (r.state === 'needs' || r.state === 'blocked') put(rest, r, r.kind === 'session' ? '' : bareHint(r)); continue; }
|
|
244
|
+
for (const t of g.tasks || []) if (t.mine && t.late) put(late, t, g.name);
|
|
245
|
+
for (const r of g.flat || []) put(rest, r, '');
|
|
246
|
+
for (const i of (g.inis || []).concat(g.rest || [])) for (const k of i.kids) if (isMove(k)) put(k.kind === 'task' ? late : rest, k, i.name);
|
|
247
|
+
}
|
|
248
|
+
for (const r of needs) if (!seen.has(r.id) && !r.needSession) put(rest, r, r.kind === 'session' ? '' : bareHint(r));
|
|
249
|
+
return late.concat(rest);
|
|
250
|
+
}
|
|
251
|
+
/** "Wed 09:00" from the weekly update's "goes out Wed 09:00"; '' for any other row. */
|
|
252
|
+
export const whenOf = (r) => { const m = /goes out (.+)$/.exec(String((r && r.hint) || '')); return m ? m[1] : ''; };
|
|
253
|
+
|
|
181
254
|
/* ── the Today card through the day ── */
|
|
182
255
|
const DAY_FROM = 9, DAY_TO = 18;
|
|
183
256
|
/** The day's load bar from 09 to 18: free and meeting stretches, the meeting on now marked. { segs: [{ flex, m, now }], sub } */
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/* pm/home-mentions.js — @Mentions on Home: a permanent row at the top of the list and the Mentions Viewer (Viewer kit; canvas XvANew,
|
|
2
|
+
* XvAMention, XvAMentionJira, XvAMentionDoc, XvAMentionMail).
|
|
3
|
+
*
|
|
4
|
+
* rowHtml(D, { sel }) → the row's markup: "@ Mentions" and "N new" while some are unread. With none new the row stays, with no count
|
|
5
|
+
* (zero is silence). The press is data-hr-mentions; home-app.js opens the Viewer.
|
|
6
|
+
* openMentions(ctx) → the Mentions Viewer: the summary card (how many are new, who asked what, ONE primary: Reply to <first>), then
|
|
7
|
+
* "New" (open) and "Earlier" (folded, the ones already read). A mention opens with back: true, so ← returns here.
|
|
8
|
+
* openOne(m, ctx, { back }) → one mention: how long it waits on the PM, what it is about, where it is, ONE primary (Draft a reply), the
|
|
9
|
+
* source excerpt with the mention outlined, What I checked (only the brief's own checks), Open in <source> and its
|
|
10
|
+
* initiative with its stage. ⋯ holds Make it a task and Mark read (or Mark unread).
|
|
11
|
+
* ctx: { D() → Home's data, pmPost, toast, reload(), iniTitle(id), stageOf(id), goIni(id), draft(m) }
|
|
12
|
+
*
|
|
13
|
+
* The mentions are today's (GET /api/brief-page mentions, Home's D.today). New = not marked read. Mark read is POST /api/mentions/read;
|
|
14
|
+
* Make it a task is POST /api/pm-items/add. Nothing here replies or posts: Draft a reply opens Home's chat to write it, and the PM sends
|
|
15
|
+
* it where the mention is. A mention shows only here: it is no longer a row under its initiative (say it once). */
|
|
16
|
+
import * as VW from './cozy-viewer.js';
|
|
17
|
+
|
|
18
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
19
|
+
const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail', gmail: 'Gmail', figma: 'Figma', doc: 'the document' };
|
|
20
|
+
const ICON = { jira: 'jira', confluence: 'doc', doc: 'doc', mail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7', gmail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7' };
|
|
21
|
+
const TICK = 'M5 12.5l4.5 4.5L19 7.5';
|
|
22
|
+
const svg = (d, w = 16, sw = 2) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
23
|
+
const srcName = (s) => SRC[s] || (s ? String(s).charAt(0).toUpperCase() + String(s).slice(1) : 'its source');
|
|
24
|
+
const first = (who) => String(who || 'someone').trim().split(/\s+/)[0];
|
|
25
|
+
const clip = (s, n) => { s = String(s || '').replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
26
|
+
const https = (u) => (/^https:\/\/\S+$/i.test(String(u || '')) ? u : '');
|
|
27
|
+
const isMail = (s) => s === 'mail' || s === 'gmail';
|
|
28
|
+
const isDoc = (s) => s === 'confluence' || s === 'doc';
|
|
29
|
+
|
|
30
|
+
/* ── the data ── */
|
|
31
|
+
/** Today's mentions: { all, fresh (not read yet), earlier (read) }, newest first as the server sends them. */
|
|
32
|
+
export function mentionsOf(D) {
|
|
33
|
+
const all = (D && D.today && Array.isArray(D.today.mentions) ? D.today.mentions : []).filter((m) => m && m.id && !m.done);
|
|
34
|
+
return { all, fresh: all.filter((m) => !m.read), earlier: all.filter((m) => m.read) };
|
|
35
|
+
}
|
|
36
|
+
/** "40 min", "2 h", "1 day", "3 days"; '' with no time. */
|
|
37
|
+
export function age(at, now = Date.now()) {
|
|
38
|
+
const t = Date.parse(at || ''); if (!Number.isFinite(t)) return '';
|
|
39
|
+
const m = Math.max(0, Math.round((now - t) / 60000));
|
|
40
|
+
if (m < 60) return Math.max(1, m) + ' min';
|
|
41
|
+
const h = Math.round(m / 60); if (h < 24) return h + ' h';
|
|
42
|
+
const d = Math.round(h / 24); return d === 1 ? '1 day' : d + ' days';
|
|
43
|
+
}
|
|
44
|
+
/** Where the mention is, the way the frames say it: "Slack #product", "SLV-144 comment", "comment on PRD v3", "email". */
|
|
45
|
+
export function placeOf(m) {
|
|
46
|
+
const w = String(m.where || '').trim();
|
|
47
|
+
if (m.source === 'slack') return 'Slack' + (w ? ' ' + w : '');
|
|
48
|
+
if (m.source === 'jira') return (w || 'Jira') + ' comment';
|
|
49
|
+
if (isDoc(m.source)) return 'comment on ' + (w || srcName(m.source));
|
|
50
|
+
if (isMail(m.source)) return 'email';
|
|
51
|
+
return [srcName(m.source), w].filter(Boolean).join(' ');
|
|
52
|
+
}
|
|
53
|
+
const whoOf = (m) => m.who || srcName(m.source);
|
|
54
|
+
const askWord = (m) => (m.reply ? 'asks' : 'wrote');
|
|
55
|
+
|
|
56
|
+
/* ── the row on Home (XvANew .row) ── */
|
|
57
|
+
export function rowHtml(D, o = {}) {
|
|
58
|
+
const n = mentionsOf(D).fresh.length;
|
|
59
|
+
const sel = o.sel === 'mentions';
|
|
60
|
+
return `<div class="hv-card hr-card hr-men-card"><div class="hm-r hv-r hr-men${sel ? ' sel' : ''}${n ? ' new' : ''}" data-id="mentions">`
|
|
61
|
+
+ `<button type="button" class="hm-rm" data-hr-mentions${sel ? ' aria-current="true"' : ''} aria-label="Mentions${n ? ', ' + n + ' new' : ''}">`
|
|
62
|
+
+ '<span class="hv-mk hr-at" aria-hidden="true">@</span><span class="hm-rt"><b>Mentions</b></span>'
|
|
63
|
+
+ (n ? `<span class="hv-st hr-new">${n} new</span>` : '') + '<span class="hv-xc" aria-hidden="true"></span></button></div></div>';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* ── the Mentions Viewer (XvANew .vw) ── */
|
|
67
|
+
function itemHtml(m, now) {
|
|
68
|
+
const head = [whoOf(m), placeOf(m), m.at ? age(m.at, now) + ' ago' : ''].filter(Boolean).join(' · ');
|
|
69
|
+
const sub = [m.text ? '“' + clip(m.text, 120) + '”' : '', m.checks && m.checks[0] ? 'I checked: ' + clip(m.checks[0], 80) : ''].filter(Boolean).join(' · ');
|
|
70
|
+
return `<button type="button" class="hr-mi" data-hr-mi="${esc(m.id)}" aria-label="${esc(whoOf(m) + ', ' + placeOf(m) + '. Open')}">`
|
|
71
|
+
+ `<span class="hr-mdot${m.read ? ' read' : ''}" aria-hidden="true"></span><span class="hr-mw"><b>${esc(head)}</b>${sub ? `<span>${esc(sub)}</span>` : ''}</span>`
|
|
72
|
+
+ `<span class="hr-mcv">${svg('M10 7l5 5-5 5', 15)}</span></button>`;
|
|
73
|
+
}
|
|
74
|
+
function listHtml(ctx) {
|
|
75
|
+
const now = Date.now();
|
|
76
|
+
const { fresh, earlier } = mentionsOf(ctx.D());
|
|
77
|
+
const n = fresh.length;
|
|
78
|
+
const end = (t) => (/[.?!…]”?$/.test(t) ? t : t + '.');
|
|
79
|
+
const said = fresh.slice(0, 2).map((m) => end(first(whoOf(m)) + ' ' + askWord(m) + (m.text ? ' “' + clip(m.text, 70) + '”' : ' something'))).join(' ');
|
|
80
|
+
const sum = n
|
|
81
|
+
? VW.czSummary({ line: n + ' new since this morning', tone: 'you', text: said + (n > 2 ? ' And ' + (n - 2) + ' more.' : ''), primary: { label: 'Reply to ' + first(whoOf(fresh[0])), act: 'reply' } })
|
|
82
|
+
: VW.czSummary({ text: earlier.length ? 'Nothing new. What you already read today is under Earlier.' : 'Nobody has mentioned you today.' });
|
|
83
|
+
const secs = VW.czSections([
|
|
84
|
+
n ? { id: 'new', title: 'New', count: n, open: true, html: '<div class="hr-ml">' + fresh.map((m) => itemHtml(m, now)).join('') + '</div>' } : null,
|
|
85
|
+
earlier.length ? { id: 'earlier', title: 'Earlier', count: earlier.length, open: false, html: '<div class="hr-ml">' + earlier.map((m) => itemHtml(m, now)).join('') + '</div>' } : null,
|
|
86
|
+
], { key: 'mentions' });
|
|
87
|
+
return '<div class="hr-vb">' + sum + secs + '</div>';
|
|
88
|
+
}
|
|
89
|
+
export function openMentions(ctx) {
|
|
90
|
+
sheet();
|
|
91
|
+
const draw = (b) => {
|
|
92
|
+
b.innerHTML = listHtml(ctx);
|
|
93
|
+
b.onclick = (e) => {
|
|
94
|
+
const t = e.target.closest('[data-hr-mi],[data-czs-act]'); if (!t || !b.contains(t)) return;
|
|
95
|
+
const { all, fresh } = mentionsOf(ctx.D());
|
|
96
|
+
if (t.dataset.hrMi) { const m = all.find((x) => x.id === t.dataset.hrMi); if (m) openOne(m, ctx, { back: true }); return; }
|
|
97
|
+
if (t.dataset.czsAct === 'reply' && fresh[0]) ctx.draft(fresh[0]);
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const { fresh } = mentionsOf(ctx.D());
|
|
101
|
+
return VW.open({ id: 'mentions', kind: 'Mentions', title: 'Mentions', icon: 'spark', render: draw,
|
|
102
|
+
more: fresh.length ? [{ label: 'Mark all read', on: () => markAll(ctx) }] : [] });
|
|
103
|
+
}
|
|
104
|
+
async function markAll(ctx) {
|
|
105
|
+
const { fresh } = mentionsOf(ctx.D());
|
|
106
|
+
let ok = 0;
|
|
107
|
+
for (const m of fresh) { const r = await ctx.pmPost('/api/mentions/read', { id: m.id, read: true }); if (r && r.ok) { m.read = true; ok++; } }
|
|
108
|
+
ctx.toast(ok === fresh.length ? 'Marked read.' : 'Marked ' + ok + ' of ' + fresh.length + ' read. The server did not take the rest.');
|
|
109
|
+
if (VW.current() && VW.current().id === 'mentions') openMentions(ctx);
|
|
110
|
+
ctx.reload();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* ── one mention (XvAMention, XvAMentionJira, XvAMentionDoc, XvAMentionMail) ── */
|
|
114
|
+
const hm = (at) => { const t = Date.parse(at || ''); if (!Number.isFinite(t)) return ''; const d = new Date(t); return String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0'); };
|
|
115
|
+
const ini2 = (who) => esc(String(who || '?').replace(/[^A-Za-z]/g, '').slice(0, 2) || '?');
|
|
116
|
+
const msgHtml = (x, me) => `<div class="hr-msg${me ? ' me' : ''}"><span class="hr-av" aria-hidden="true">${ini2(x.who)}</span><span class="hr-w"><small><b>${esc(x.who || 'Someone')}</b>${hm(x.at) ? ' · ' + hm(x.at) : ''}</small><span>${esc(x.text)}</span></span></div>`;
|
|
117
|
+
/** The source excerpt, with the mention outlined. Only what the record holds: the thread when the brief kept it, else the mention's words. */
|
|
118
|
+
export function excerptHtml(m) {
|
|
119
|
+
const own = { who: whoOf(m), at: m.at, text: m.text || '' };
|
|
120
|
+
const thread = Array.isArray(m.thread) && m.thread.length ? m.thread : null;
|
|
121
|
+
// the mention in the thread: the last message of its author (the server keeps the author's last time as m.at)
|
|
122
|
+
let at = -1;
|
|
123
|
+
if (thread) for (let i = thread.length - 1; i >= 0; i--) if (!m.who || thread[i].who === m.who) { at = i; break; }
|
|
124
|
+
const msgs = thread ? thread.map((x, i) => msgHtml(i === at && !x.text ? { ...x, text: m.text } : x, i === at)).join('') + (at < 0 && m.text ? msgHtml(own, true) : '') : msgHtml(own, true);
|
|
125
|
+
if (m.source === 'jira') return `<div class="hr-tkt">${m.where ? `<div class="hr-kv"><span>${esc(m.where)}</span></div>` : ''}${msgs}</div>`;
|
|
126
|
+
if (isMail(m.source)) return `<div class="hr-mail">${m.where ? `<b>${esc(m.where)}</b>` : ''}<span>${esc([whoOf(m), hm(m.at), thread && thread.length > 1 ? thread.length + ' messages' : ''].filter(Boolean).join(' · '))}</span></div>`
|
|
127
|
+
+ (m.text ? `<div class="hr-quote">${esc(m.text)}</div>` : '');
|
|
128
|
+
if (isDoc(m.source)) return msgs;
|
|
129
|
+
return `<div class="hr-thr">${msgs}</div>`;
|
|
130
|
+
}
|
|
131
|
+
const checksHtml = (m) => (Array.isArray(m.checks) && m.checks.length
|
|
132
|
+
? `<div class="hr-chk"><b>What I checked</b>${m.checks.map((c) => `<div class="hr-cl"><span class="hr-ok">${svg(TICK, 15, 2.2)}</span><span>${esc(c)}</span></div>`).join('')}</div>` : '');
|
|
133
|
+
function oneHtml(m, ctx) {
|
|
134
|
+
const a = age(m.at);
|
|
135
|
+
const line = m.reply ? 'Waiting on you' + (a ? ' · ' + a : '') : 'Mentioned you' + (a ? ' · ' + a + ' ago' : '');
|
|
136
|
+
const text = whoOf(m) + (m.reply ? ' asks you something in ' : ' named you in ') + placeOf(m) + '.';
|
|
137
|
+
const meta = [m.initiative ? ctx.iniTitle(m.initiative) : '', m.where && !isMail(m.source) ? m.where : ''].filter(Boolean).join(' · ');
|
|
138
|
+
const sum = VW.czSummary({ line: m.read ? line + ' · read' : line, tone: m.reply && !m.read ? 'warn' : '', text, meta, primary: { label: 'Draft a reply', act: 'draft' } });
|
|
139
|
+
const link = https(m.link);
|
|
140
|
+
const secs = VW.czSections([
|
|
141
|
+
link ? { id: 'src', title: 'Open in ' + srcName(m.source), on: 'src' } : null,
|
|
142
|
+
m.initiative ? { id: 'ini', title: ctx.iniTitle(m.initiative), count: ctx.stageOf(m.initiative) || '', on: 'ini' } : null,
|
|
143
|
+
], { key: 'mention' });
|
|
144
|
+
return '<div class="hr-vb">' + sum + excerptHtml(m) + checksHtml(m) + secs + '</div>';
|
|
145
|
+
}
|
|
146
|
+
const taskLine = (m) => (m.reply ? 'Reply to ' + first(whoOf(m)) + ' (' + srcName(m.source) + ') by today' : 'Read ' + first(whoOf(m)) + '\'s note (' + srcName(m.source) + ')');
|
|
147
|
+
export function openOne(m, ctx, o = {}) {
|
|
148
|
+
sheet();
|
|
149
|
+
const more = () => [
|
|
150
|
+
{ label: 'Make it a task', on: async () => {
|
|
151
|
+
const r = await ctx.pmPost('/api/pm-items/add', { line: taskLine(m) });
|
|
152
|
+
ctx.toast(r && r.ok !== false ? 'Added to your tasks: ' + taskLine(m).replace(/ by today$/, '') : 'That did not go through' + (r && r.error ? ': ' + r.error : '.'));
|
|
153
|
+
if (r && r.ok !== false) ctx.reload();
|
|
154
|
+
} },
|
|
155
|
+
{ label: m.read ? 'Mark unread' : 'Mark read', on: async () => {
|
|
156
|
+
const to = !m.read;
|
|
157
|
+
const r = await ctx.pmPost('/api/mentions/read', { id: m.id, read: to });
|
|
158
|
+
if (!r || !r.ok) { ctx.toast('That did not go through' + (r && r.error ? ': ' + r.error : '.')); return; }
|
|
159
|
+
m.read = to; ctx.toast(to ? 'Marked read.' : 'Marked unread.');
|
|
160
|
+
const c = VW.current(); if (c && c.id === 'mention:' + m.id) openOne(m, ctx, { _again: true });
|
|
161
|
+
ctx.reload();
|
|
162
|
+
} },
|
|
163
|
+
];
|
|
164
|
+
const draw = (b) => {
|
|
165
|
+
b.innerHTML = oneHtml(m, ctx);
|
|
166
|
+
b.onclick = (e) => {
|
|
167
|
+
const t = e.target.closest('[data-czs-act]'); if (!t || !b.contains(t)) return;
|
|
168
|
+
const k = t.dataset.czsAct;
|
|
169
|
+
if (k === 'draft') ctx.draft(m);
|
|
170
|
+
else if (k === 'src') { const l = https(m.link); if (l) window.open(l, '_blank', 'noopener'); }
|
|
171
|
+
else if (k === 'ini') ctx.goIni(m.initiative);
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
const args = { id: 'mention:' + m.id, kind: 'Mention', title: whoOf(m) + ' · ' + placeOf(m), icon: ICON[m.source] || 'at', render: draw, more: more() };
|
|
175
|
+
// Mark read redraws in place: the item is replaced by itself, so ← still goes back to the list behind it
|
|
176
|
+
if (o._again) return VW.open({ ...args, back: false, _back: true });
|
|
177
|
+
return VW.open({ ...args, back: !!o.back });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* ── the look: cozy-home-rows.css, loaded once ── */
|
|
181
|
+
export function sheet() {
|
|
182
|
+
if (typeof document === 'undefined' || document.getElementById('czHomeRowsCss')) return;
|
|
183
|
+
const l = document.createElement('link'); l.id = 'czHomeRowsCss'; l.rel = 'stylesheet';
|
|
184
|
+
try { l.href = new URL('./cozy-home-rows.css', import.meta.url).href; } catch { l.href = '/pm/cozy-home-rows.css'; }
|
|
185
|
+
document.head.appendChild(l);
|
|
186
|
+
}
|
|
187
|
+
sheet();
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* pm/home-rec-row.js — the pinned recording row at the very top of Home (Viewer kit; canvas XvARecHome).
|
|
2
|
+
*
|
|
3
|
+
* While a meeting records, a row sits above @Mentions: a red outline, a red dot, the meeting's title and "Recording · 12:40", and the
|
|
4
|
+
* clock ticks. It stays while the PM opens other items. A press opens the live meeting (data-hm-recopen, which home-app.js already opens
|
|
5
|
+
* in place). Paused: "Paused · 12:40", quieter, and the clock stands still. With no recording there is no row.
|
|
6
|
+
*
|
|
7
|
+
* mountRecRow({ notes, refresh, redraw }) → { html() }
|
|
8
|
+
* notes() the notes Home already reads (premium-meeting.js recCore().notes()), the fallback while rec-state.js is not on the page
|
|
9
|
+
* refresh() reads the notes again (every 10 s while rec-state.js is not on the page)
|
|
10
|
+
* redraw() Home draws its list again: called when the recording starts, pauses, resumes, stops or changes its title
|
|
11
|
+
*
|
|
12
|
+
* The state comes from rec-state.js (onRecording, the meetings workstream) when the page has it, else from the notes, read by the same rule
|
|
13
|
+
* (a note recording or paused; meeting_ms is the meeting time heard). Nothing is written here. */
|
|
14
|
+
import { sheet } from './home-mentions.js';
|
|
15
|
+
|
|
16
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
17
|
+
const OFF = { on: false, paused: false, id: '', title: '', elapsedMs: 0, readAt: 0 };
|
|
18
|
+
|
|
19
|
+
/** The recording now, from a list of notes (pure; the rule of rec-state.js stateOf). */
|
|
20
|
+
export function stateOfNotes(rows, now = Date.now()) {
|
|
21
|
+
const live = (Array.isArray(rows) ? rows : []).filter((n) => n && (n.state === 'recording' || n.state === 'paused'));
|
|
22
|
+
if (!live.length) return { ...OFF, readAt: now };
|
|
23
|
+
const n = live.find((x) => x.state === 'recording') || live[0];
|
|
24
|
+
return { on: true, paused: n.state === 'paused', id: String(n.id), title: String((n.meeting && n.meeting.title) || n.title || 'Meeting'), elapsedMs: Math.max(0, Number(n.meeting_ms) || 0), readAt: now };
|
|
25
|
+
}
|
|
26
|
+
/** "12:40", or "1:02:40" past the hour. */
|
|
27
|
+
export function clockOf(ms) {
|
|
28
|
+
const s = Math.max(0, Math.floor((Number(ms) || 0) / 1000)), h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), x = String(s % 60).padStart(2, '0');
|
|
29
|
+
return h ? h + ':' + String(m).padStart(2, '0') + ':' + x : m + ':' + x;
|
|
30
|
+
}
|
|
31
|
+
const elapsed = (st, now = Date.now()) => st.elapsedMs + (st.paused ? 0 : Math.max(0, now - (st.readAt || now)));
|
|
32
|
+
/** The row's markup for a state; '' when nothing records. Pure. */
|
|
33
|
+
export function recRowHtml(st, now = Date.now()) {
|
|
34
|
+
if (!st || !st.on) return '';
|
|
35
|
+
const word = st.paused ? 'Paused' : 'Recording';
|
|
36
|
+
return `<div class="hv-card hr-card hr-rec-card${st.paused ? ' paused' : ''}"><div class="hm-r hv-r hr-rec" data-id="rec:${esc(st.id)}">`
|
|
37
|
+
+ `<button type="button" class="hm-rm" data-hm-recopen="${esc(st.id)}" aria-label="${esc(st.title)}. ${word}. Open the meeting">`
|
|
38
|
+
+ `<span class="hv-mk"><span class="hr-rdot" aria-hidden="true"></span></span><span class="hm-rt"><b>${esc(st.title)}</b></span>`
|
|
39
|
+
+ `<span class="hv-st hr-rst">${word} · <span data-hr-clock>${clockOf(elapsed(st, now))}</span></span><span class="hv-xc" aria-hidden="true"></span></button></div></div>`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function mountRecRow({ notes, refresh, redraw } = {}) {
|
|
43
|
+
sheet();
|
|
44
|
+
let live = null; // the state rec-state.js gave, once it answers; null: read the notes
|
|
45
|
+
let seen = '';
|
|
46
|
+
const fromNotes = () => {
|
|
47
|
+
const st = stateOfNotes(typeof notes === 'function' ? notes() : []);
|
|
48
|
+
// the notes carry no read time of their own: the clock runs from the first time this page saw this stretch of the recording
|
|
49
|
+
if (st.on && !st.paused) { const k = st.id + ':' + st.elapsedMs; if (fromNotes.k !== k) { fromNotes.k = k; fromNotes.at = Date.now(); } st.readAt = fromNotes.at; }
|
|
50
|
+
return st;
|
|
51
|
+
};
|
|
52
|
+
const state = () => live || fromNotes();
|
|
53
|
+
const changed = (st) => { const k = st.on ? [st.id, st.paused, st.title].join('|') : ''; if (k === seen) return false; seen = k; return true; };
|
|
54
|
+
import('./rec-state.js').then((M) => {
|
|
55
|
+
M.onRecording((st) => { live = st && typeof st === 'object' ? st : null; if (changed(state()) && redraw) redraw(); });
|
|
56
|
+
}).catch(() => { // not on this page yet: the notes answer, read again every 10 s
|
|
57
|
+
if (typeof refresh === 'function') setInterval(() => { if (!document.hidden) Promise.resolve(refresh()).then(() => { if (changed(state()) && redraw) redraw(); }).catch(() => {}); }, 10000);
|
|
58
|
+
});
|
|
59
|
+
setInterval(() => { // the clock ticks in place; the list is not drawn again for it
|
|
60
|
+
const st = state();
|
|
61
|
+
if (changed(st) && redraw) { redraw(); return; }
|
|
62
|
+
if (!st.on || st.paused) return;
|
|
63
|
+
const t = clockOf(elapsed(st));
|
|
64
|
+
document.querySelectorAll('[data-hr-clock]').forEach((el) => { if (el.textContent !== t) el.textContent = t; });
|
|
65
|
+
}, 1000);
|
|
66
|
+
return { html: () => { const st = state(); changed(st); return recRowHtml(st); }, state };
|
|
67
|
+
}
|
|
@@ -53,26 +53,36 @@ export function openReview(h) {
|
|
|
53
53
|
if (key === 'untouched') { const R = reviewModel(h.D(), h.now()); return plural(Object.keys(R.kept || {}).length, 'looked at', 'looked at'); }
|
|
54
54
|
return st.picked.size ? st.picked.size + ' picked' : 'None picked';
|
|
55
55
|
}
|
|
56
|
+
// shell A (canvas XvAReview): the summary card names the step on now, says what it asks, and holds the one primary (Continue);
|
|
57
|
+
// each step is a folding row: a done step shows its note, the step on now is open with its rows, a later step waits.
|
|
58
|
+
const ASK = {
|
|
59
|
+
sort: (R) => { const n = tab('inbox').concat(tab('tray')).length; return n ? plural(n, 'thing came in that is', 'things came in that are') + ' not placed. Put each in Today, or keep it.' : 'Nothing came in that is not placed.'; },
|
|
60
|
+
wait: () => { const n = (work() && work().waiting ? work().waiting.rows : []).length; return n ? plural(n, 'thing is', 'things are') + ' owed to you. Mark what came in.' : 'Nobody owes you anything.'; },
|
|
61
|
+
untouched: () => { const n = staleInis(h.D(), h.now()).length; return n ? plural(n, 'initiative has', 'initiatives have') + ' not moved for two weeks. Keep them going, or ask in chat.' : 'Nothing has sat untouched for 14 days.'; },
|
|
62
|
+
pick: () => "Pick next week's three. Each one becomes P1 on your list.",
|
|
63
|
+
};
|
|
56
64
|
const draw = (b) => {
|
|
57
65
|
const R = reviewModel(h.D(), h.now());
|
|
58
|
-
const steps = R.steps.
|
|
59
|
-
|
|
60
|
-
if (s.now) return `<div class="ut-step now" role="group" aria-label="${esc(s.label)}, now"><div class="h"><span class="ut-chk"></span><b>${esc(s.label)}</b><span class="ut-small ut-bl"><b>Now</b></span></div>`
|
|
61
|
-
+ `<div>${stepBody(s, R)}</div><div class="ut-acts"><button type="button" class="ut-btn sm pri" data-rv-step="${s.key}"${st.busy ? ' disabled' : ''}>Done with this step</button></div></div>`;
|
|
62
|
-
return `<div class="ut-step later"><span class="ut-chk"></span><b>${esc(s.label)}</b></div>`;
|
|
63
|
-
}).join('');
|
|
66
|
+
const at = R.steps.findIndex((s) => s.now), left = R.steps.filter((s) => !s.done).length;
|
|
67
|
+
const now = at >= 0 ? R.steps[at] : null;
|
|
64
68
|
const last = R.last ? 'Last review: ' + dayLabel(R.last.week) + (R.last.minutes ? ' · ' + plural(R.last.minutes, 'minute', 'minutes') : '') : 'This is your first weekly review here.';
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
const sum = h.VW.czSummary({ line: R.done ? 'Done for this week' : now ? 'Step ' + (at + 1) + ' of ' + R.steps.length : '', tone: R.done ? 'ok' : 'you',
|
|
70
|
+
text: R.done ? 'Each step kept what you decided.' : now ? (ASK[now.key] || ASK.pick)(R) : 'Four short steps. Each one keeps what you decided.',
|
|
71
|
+
meta: R.done ? last : 'About ' + plural(left * 3, 'minute', 'minutes') + ' left · ' + last,
|
|
72
|
+
primary: now ? { label: 'Continue', act: 'step:' + now.key, disabled: st.busy } : null });
|
|
73
|
+
const secs = h.VW.czSections(R.steps.map((s) => ({ id: s.key, title: s.label, count: s.done ? s.note || 'done' : '', open: !!s.now,
|
|
74
|
+
html: s.now ? `<div class="ut-steps1">${stepBody(s, R)}</div>` : '' })), { key: 'review:' + R.label });
|
|
75
|
+
b.innerHTML = sum + `<div class="cz-ladder" role="img" aria-label="${R.steps.filter((x) => x.done).length} of 4 steps done">${R.steps.map((s) => `<i class="${s.done ? 'done' : s.now ? 'now' : ''}"></i>`).join('')}</div>`
|
|
76
|
+
+ secs + `<p class="ut-small ut-mut" role="status" id="rvMsg">${esc(st.msg)}</p>`;
|
|
68
77
|
};
|
|
69
|
-
const body = h.VW.open({ id: 'review', kind: 'Weekly review', title: 'Weekly review', icon: 'list', render: draw });
|
|
78
|
+
const body = h.VW.open({ id: 'review', kind: 'Weekly review', title: 'Weekly review · ' + reviewModel(h.D(), h.now()).label, icon: 'list', render: draw });
|
|
70
79
|
const say = (m) => { st.msg = m; const el = body.querySelector('#rvMsg'); if (el) el.textContent = m; };
|
|
71
80
|
const post = async (path, b) => { const r = await h.pmPost(path, b).catch(() => null); if (!r || r.ok !== true) { say((r && r.error) || 'Nothing was changed.'); return null; } return r; };
|
|
72
81
|
const redraw = async () => { await h.reload(); if (body.isConnected) draw(body); };
|
|
73
82
|
body.onclick = async (e) => {
|
|
74
83
|
const b = e.target.closest('button'); if (!b || b.disabled) return;
|
|
75
84
|
const d = b.dataset;
|
|
85
|
+
if (/^step:/.test(d.czsAct || '')) d.rvStep = d.czsAct.slice(5); // the summary's Continue is the step's own Done
|
|
76
86
|
if (d.rvToday) { if (await post('/api/pm-items/flag', { id: d.rvToday, flagged: true })) { st.done[d.k] = 'today'; draw(body); } return; }
|
|
77
87
|
if (d.rvKeep) { if (await post('/api/pm-items/keep', { id: d.rvKeep })) { st.done[d.k] = 'kept'; draw(body); } return; }
|
|
78
88
|
if (d.rvDone) { if (await post('/api/pm-items/done', { id: d.rvDone })) { st.done[d.k] = 'done'; draw(body); } return; }
|