create-pmos 0.615.0 → 0.617.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 +75 -45
- 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 +115 -1940
- package/workspace/extension/README.md +13 -1
- package/workspace/extension/panel.js +7 -5
- package/workspace/guide/backlog.md +70 -0
- package/workspace/guide/cli.md +1 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/layout.md +3 -2
- package/workspace/guide/notes.md +17 -3
- package/workspace/guide/programs.md +1 -1
- package/workspace/guide/routine.md +1 -1
- package/workspace/lib/backlog.js +323 -0
- package/workspace/lib/day-run.js +3 -2
- package/workspace/lib/doc-library.js +26 -3
- package/workspace/lib/jira-status.js +4 -1
- package/workspace/lib/meeting-focus.js +40 -8
- package/workspace/lib/mention-cli.js +7 -5
- package/workspace/lib/mention-store.js +9 -5
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-backlog.js +283 -0
- package/workspace/lib/routes-boards.js +13 -0
- package/workspace/lib/routes-brief-page.js +6 -2
- package/workspace/lib/routes-meeting-focus.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog.css +158 -0
- package/workspace/public/pm/bd-backlog.js +531 -0
- package/workspace/public/pm/bk-model.js +169 -0
- package/workspace/public/pm/buddy-core.js +166 -0
- package/workspace/public/pm/buddy-press.js +66 -0
- package/workspace/public/pm/cozy-buddy.css +52 -0
- package/workspace/public/pm/cozy-buddy.js +115 -0
- package/workspace/public/pm/cozy-pick.js +6 -3
- package/workspace/public/pm/cozy-rec-now.js +35 -4
- package/workspace/public/pm/cozy-rec-tab.js +5 -1
- package/workspace/public/pm/cozy-routine.js +3 -2
- package/workspace/public/pm/cozy-today-app.js +36 -6
- package/workspace/public/pm/cozy-today-model.js +49 -12
- package/workspace/public/pm/cozy-today-page.css +15 -1
- package/workspace/public/pm/cozy-today-view.js +21 -12
- package/workspace/public/pm/home-app.js +6 -1
- package/workspace/public/pm/mention-one-model.js +6 -4
- package/workspace/public/pm/premium-board.js +21 -3
- package/workspace/public/pm/premium-goals.js +12 -9
- package/workspace/public/pm/premium-library.js +15 -3
- package/workspace/public/pm/premium-meeting.js +2 -2
- package/workspace/public/pm/rec-tab-core.js +5 -2
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-buddy.html +27 -0
- package/workspace/server.js +1 -1
- package/workspace/skills/morning-brief.skill +1 -1
- package/workspace/test-lists/backlog.json +9 -0
- package/workspace/test-lists/meeting-buddy.json +9 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/* pm/bk-model.js — the pure half of the Backlog in Work (initiative work-backlog; boards BkList and BkSelect on Exploring 2): which group a
|
|
2
|
+
* task sits in, the quick filters with their counts, the tune panel's facets and sort, and the "Showing … · N hidden" line. No DOM, no fetch:
|
|
3
|
+
* pm/bd-backlog.js draws and wires; bk-model.test.js tests this file in node.
|
|
4
|
+
*
|
|
5
|
+
* THE GROUPS, in this order (brief Part A 4): Needs your review · PMOS is working · PMOS can take these · With people · Nobody has these ·
|
|
6
|
+
* No home · Done by PMOS today. With Part B off (partB false) only With people, Nobody has these and No home exist; the grouping is the same code, so Part B adds
|
|
7
|
+
* groups without a redraw. A task is in one group: what PMOS is doing with it first, then where it lives (no initiative = No home), then
|
|
8
|
+
* whether PMOS can take it, then whether a person has it.
|
|
9
|
+
*
|
|
10
|
+
* Stage is not a task's (Wawan, 2026-11-19: "Stage not apply to task, it only apply to initiative"): nothing here reads a task's stage. */
|
|
11
|
+
|
|
12
|
+
export const GROUPS = [
|
|
13
|
+
{ k: 'review', n: 'Needs your review', sub: 'PMOS finished these and cannot pass them alone', open: true, b: true },
|
|
14
|
+
{ k: 'working', n: 'PMOS is working', sub: 'nothing needed from you', open: true, b: true },
|
|
15
|
+
{ k: 'take', n: 'PMOS can take these', sub: 'it has what it needs to start', open: true, b: true },
|
|
16
|
+
{ k: 'people', n: 'With people', sub: '', open: false },
|
|
17
|
+
{ k: 'open', n: 'Nobody has these', sub: '', open: false }, // design check 1: "Open" already means every open task (the first chip)
|
|
18
|
+
{ k: 'nohome', n: 'No home', sub: 'in no initiative', open: false },
|
|
19
|
+
{ k: 'done', n: 'Done by PMOS today', sub: 'passed its checks, no review needed. Undo is on each', open: false, b: true },
|
|
20
|
+
];
|
|
21
|
+
export const CHIPS = [
|
|
22
|
+
['all', 'All open'], ['review', 'Needs you'], ['working', 'PMOS working'], ['take', 'PMOS can take'], ['people', 'With people'], ['nohome', 'No home'], ['jira', 'Jira tickets'], ['sprint', 'This sprint'],
|
|
23
|
+
];
|
|
24
|
+
const GROUP_CHIPS = new Set(['review', 'working', 'take', 'people', 'nohome']);
|
|
25
|
+
export const FACETS = [['ini', 'Initiative'], ['who', 'Who'], ['epic', 'Epic'], ['sprint', 'Sprint'], ['status', 'Status']];
|
|
26
|
+
export const SORTS = [['due', 'Due date'], ['ini', 'Initiative'], ['who', 'Who'], ['name', 'Name']];
|
|
27
|
+
export const SHOW = 5; // the rows an open group shows before its "N more"
|
|
28
|
+
|
|
29
|
+
/** The group of one task. */
|
|
30
|
+
export function groupOf(t, partB = true) {
|
|
31
|
+
const a = t.agent;
|
|
32
|
+
if (partB && a && a.state === 'review') return 'review';
|
|
33
|
+
if (partB && a && a.state === 'working') return 'working';
|
|
34
|
+
if (partB && a && a.state === 'done' && a.today !== false) return 'done'; // an earlier day's result is a plain row again
|
|
35
|
+
if (!t.ini) return 'nohome';
|
|
36
|
+
if (partB && t.take && !t.declined) return 'take';
|
|
37
|
+
if (t.whoKind && t.whoKind !== 'none') return 'people';
|
|
38
|
+
return 'open';
|
|
39
|
+
}
|
|
40
|
+
/** An open task: anything but a task PMOS finished today. */
|
|
41
|
+
export const isOpen = (t) => !(t.agent && t.agent.state === 'done' && t.agent.today !== false);
|
|
42
|
+
|
|
43
|
+
/** The value of a facet on a task (what the tune panel lists and filters by). */
|
|
44
|
+
export function facetOf(t, f) {
|
|
45
|
+
if (f === 'ini') return t.iniTitle || 'No initiative';
|
|
46
|
+
if (f === 'who') return t.agent && t.agent.state !== 'failed' ? 'PMOS' : t.who || 'None';
|
|
47
|
+
if (f === 'epic') return t.src === 'jira' ? (t.epic ? t.epic.name || t.epic.key : 'No epic') : 'Not a Jira ticket';
|
|
48
|
+
if (f === 'sprint') return t.sprint ? t.sprint.name : 'No sprint';
|
|
49
|
+
if (f === 'status') return t.state;
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
/** Each facet's values with their counts, most first: { ini: [[value, n]], … } over `tasks`. */
|
|
53
|
+
export function facetsOf(tasks) {
|
|
54
|
+
const out = {};
|
|
55
|
+
for (const [f] of FACETS) {
|
|
56
|
+
const m = new Map();
|
|
57
|
+
for (const t of tasks) { const v = facetOf(t, f); m.set(v, (m.get(v) || 0) + 1); }
|
|
58
|
+
out[f] = [...m].sort((a, b) => b[1] - a[1] || String(a[0]).localeCompare(String(b[0])));
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Does task `t` pass the quick filters `chips` (a Set) and the facet picks `pick` ({ facet: Set of values })? Group chips widen each
|
|
64
|
+
* other (Needs you + No home shows both); Jira tickets and This sprint narrow. */
|
|
65
|
+
export function keeps(t, chips, pick, partB = true) {
|
|
66
|
+
const C = chips || new Set();
|
|
67
|
+
const groups = [...C].filter((c) => GROUP_CHIPS.has(c));
|
|
68
|
+
if (groups.length && !groups.includes(groupOf(t, partB))) return false;
|
|
69
|
+
if (C.has('jira') && t.src !== 'jira') return false;
|
|
70
|
+
if (C.has('sprint') && !(t.sprint && t.sprint.state === 'active')) return false;
|
|
71
|
+
for (const [f, set] of Object.entries(pick || {})) if (set && set.size && !set.has(facetOf(t, f))) return false;
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
/** The counts the chips show: over the open tasks, each chip alone. */
|
|
75
|
+
export function chipCounts(tasks, partB = true) {
|
|
76
|
+
const open = tasks.filter(isOpen), n = { all: open.length };
|
|
77
|
+
for (const [k] of CHIPS) if (k !== 'all') n[k] = open.filter((t) => keeps(t, new Set([k]), null, partB)).length;
|
|
78
|
+
return n;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const dueKey = (t) => (t.due ? String(t.due).slice(0, 10) : '9999');
|
|
82
|
+
/** The rows in an order: late first by how late, then by due day, then by name; or by initiative, who or name. */
|
|
83
|
+
export function sortRows(rows, by = 'due') {
|
|
84
|
+
const name = (t) => String(t.title || '').toLowerCase();
|
|
85
|
+
const cmp = {
|
|
86
|
+
due: (a, b) => (b.late || 0) - (a.late || 0) || dueKey(a).localeCompare(dueKey(b)) || name(a).localeCompare(name(b)),
|
|
87
|
+
ini: (a, b) => String(a.iniTitle || '~').localeCompare(String(b.iniTitle || '~')) || dueKey(a).localeCompare(dueKey(b)),
|
|
88
|
+
who: (a, b) => String(a.who || '~').localeCompare(String(b.who || '~')) || dueKey(a).localeCompare(dueKey(b)),
|
|
89
|
+
name: (a, b) => name(a).localeCompare(name(b)),
|
|
90
|
+
}[by] || ((a, b) => name(a).localeCompare(name(b)));
|
|
91
|
+
return rows.slice().sort(cmp);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The groups to draw: [{ k, n, sub, rows, people? }], empty groups left out (zero is silence). o: { chips, pick, sort, partB, ini }. */
|
|
95
|
+
export function groupsOf(tasks, o = {}) {
|
|
96
|
+
const partB = o.partB !== false;
|
|
97
|
+
// o.ini: one initiative's tasks only (the initiative popup draws its tasks with this list; No home is then empty)
|
|
98
|
+
const shown = tasks.filter((t) => (!o.ini || t.ini === o.ini) && keeps(t, o.chips, o.pick, partB));
|
|
99
|
+
const out = [];
|
|
100
|
+
for (const g of GROUPS) {
|
|
101
|
+
if (g.b && !partB) continue;
|
|
102
|
+
let rows = sortRows(shown.filter((t) => groupOf(t, partB) === g.k), o.sort);
|
|
103
|
+
if (g.k === 'nohome') rows = rows.filter((t) => t.propose).concat(rows.filter((t) => !t.propose)); // PMOS's ✦ proposals first
|
|
104
|
+
if (!rows.length) continue;
|
|
105
|
+
let sub = g.sub;
|
|
106
|
+
if (g.k === 'people') {
|
|
107
|
+
const by = new Map();
|
|
108
|
+
for (const t of rows) by.set(t.who, (by.get(t.who) || 0) + 1);
|
|
109
|
+
sub = [...by].sort((a, b) => (a[0] === 'You') - (b[0] === 'You') || b[1] - a[1]).map(([w, n]) => (w === 'You' ? 'you' : w) + ' ' + n).join(', ');
|
|
110
|
+
}
|
|
111
|
+
if (g.k === 'nohome') { const p = rows.filter((t) => t.propose).length; sub = 'in no initiative' + (p ? '. PMOS can place ' + p : ''); }
|
|
112
|
+
out.push({ k: g.k, n: g.n, sub, rows, open: g.open });
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The "Showing … · N hidden · Show all" line: '' when nothing is filtered. */
|
|
118
|
+
export function showingLine(tasks, o = {}) {
|
|
119
|
+
const open = tasks.filter(isOpen), partB = o.partB !== false;
|
|
120
|
+
const on = (o.chips && o.chips.size) || Object.values(o.pick || {}).some((s) => s && s.size);
|
|
121
|
+
if (!on) return null;
|
|
122
|
+
const kept = open.filter((t) => keeps(t, o.chips, o.pick, partB)).length;
|
|
123
|
+
const what = [...(o.chips || [])].map((c) => (CHIPS.find(([k]) => k === c) || [c, c])[1]);
|
|
124
|
+
for (const [f, set] of Object.entries(o.pick || {})) if (set && set.size) what.push((FACETS.find(([k]) => k === f) || [f, f])[1] + ': ' + [...set].join(', '));
|
|
125
|
+
return { text: 'Showing ' + what.join(' · '), hidden: open.length - kept };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The State cell's words: the state, then one short note (late, what PMOS will do, where PMOS stands). → { dot, text, note, tone }
|
|
129
|
+
* In "PMOS can take these" the point of the row is what PMOS will do: late first (red, short), then the action, and no "To do" (the group
|
|
130
|
+
* says it). A reason is two or three words ("goes out to Daryl", "changes sign-in", "goes to the CFO"). */
|
|
131
|
+
const REVIEW_WORD = { pr: 'Pull request ready', message: 'Message ready', doc: 'Document ready' };
|
|
132
|
+
export function stateOf(t, gk, o = {}) {
|
|
133
|
+
const a = t.agent;
|
|
134
|
+
// o.noLate: a Due column shows beside (the initiative popup's list), so the late words live there and State says only the state
|
|
135
|
+
const late = t.late && !o.noLate ? t.late + (t.late === 1 ? ' day late' : ' days late') : '';
|
|
136
|
+
if (a && a.state === 'review') return { dot: 'amber', text: REVIEW_WORD[a.review] || 'Ready', note: a.why || '', tone: '' };
|
|
137
|
+
if (a && a.state === 'working') {
|
|
138
|
+
if (a.pr) return { dot: 'blue', text: 'Pull request open', note: "the repo's checks decide", tone: '' };
|
|
139
|
+
return { dot: 'blue', text: 'Working', note: a.why || '', tone: '' };
|
|
140
|
+
}
|
|
141
|
+
if (a && a.state === 'done' && a.today !== false) return { dot: 'green', text: 'Done', note: a.why || '', tone: '' };
|
|
142
|
+
if (a && a.state === 'failed') return { dot: 'grey', text: t.state, note: 'PMOS could not finish: ' + (a.why || 'it stopped'), tone: 'late' };
|
|
143
|
+
if ((gk ? gk === 'take' : groupOf(t) === 'take') && t.take) {
|
|
144
|
+
return late ? { dot: 'red', text: late, note: t.take.what, tone: 'late' } : { dot: 'grey', text: t.take.what, note: '', tone: '' };
|
|
145
|
+
}
|
|
146
|
+
if (late) return { dot: 'red', text: t.state, note: late, tone: 'late' };
|
|
147
|
+
return { dot: t.state === 'To do' ? 'grey' : 'blue', text: t.state, note: '', tone: '' };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** The line under the chips: the kind of work and what it means. modes: [{ product, mode, label, kinds: { product, project, sdlc } }].
|
|
151
|
+
* The line is true (design check 1): one kind on every initiative → "IDPF runs as Full SDLC: …"; kinds that differ → "Most work here runs
|
|
152
|
+
* as Full SDLC (9 of 12 initiatives): …". → { lead, label, tail, what } | '' */
|
|
153
|
+
const WHAT = {
|
|
154
|
+
product: 'PMOS writes documents and drafts replies; a reply waits for you before it goes.',
|
|
155
|
+
project: 'PMOS also chases dates and drafts status notes; anything that goes out waits for you.',
|
|
156
|
+
sdlc: 'PMOS does the task and asks you only when the result cannot be undone or goes out to people.',
|
|
157
|
+
};
|
|
158
|
+
const LABEL = { product: 'Product management', project: 'Project management', sdlc: 'Full SDLC' };
|
|
159
|
+
export function modeLine(modes) {
|
|
160
|
+
const L = (modes || []).filter(Boolean);
|
|
161
|
+
if (!L.length) return '';
|
|
162
|
+
const n = { product: 0, project: 0, sdlc: 0 };
|
|
163
|
+
for (const m of L) for (const k of Object.keys(n)) n[k] += (m.kinds && m.kinds[k]) || 0;
|
|
164
|
+
const total = n.product + n.project + n.sdlc;
|
|
165
|
+
const top = total ? ['sdlc', 'project', 'product'].reduce((b, k) => (n[k] > n[b] ? k : b), 'sdlc') : (L[0].mode || 'product');
|
|
166
|
+
const name = L.length === 1 ? L[0].product : null;
|
|
167
|
+
if (!total || n[top] === total) return { lead: (name || 'All work here') + ' runs as ', label: LABEL[top], tail: '', what: WHAT[top] };
|
|
168
|
+
return { lead: 'Most work here runs as ', label: LABEL[top], tail: ` (${n[top]} of ${total} initiatives)`, what: WHAT[top] };
|
|
169
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/* pm/buddy-core.js — the meeting buddy, the pure half (initiative meeting-buddy; Exploring 2, page "Meeting buddy and one-press start",
|
|
2
|
+
* boards 1 · Where the buddy lives, 2 · What the buddy does, 4 · Consent).
|
|
3
|
+
*
|
|
4
|
+
* The buddy is PMOS in the meeting, seen only by the PM. It is quiet by default: it files what it hears (each with Undo), pulls up
|
|
5
|
+
* context when a topic comes up, answers a question the PM types, nudges once on time, and drafts a line for the call chat. It never
|
|
6
|
+
* speaks or posts to the room: every line for the room is a draft the PM copies and posts.
|
|
7
|
+
*
|
|
8
|
+
* buddyModel(F, o) → Model F = GET /api/meeting-focus's answer. o: { now?, toldAt?, nudgeOff? (Set of nudge keys), consentOff? }
|
|
9
|
+
* filedHtml(m) · nudgeHtml(m) · contextHtml(m) · draftsHtml(m) · consentHtml(m) · answerHtml(m) → string the parts, each '' at zero
|
|
10
|
+
* buddyHtml(m) → string the Meet panel's body: the topic, Now, the nudge, the consent line, Filed, Context, drafts, the answer
|
|
11
|
+
* headOf(m) → { text, tone } the panel's header line: "Listening · Topic 2 of 4", "Paused", "Not listening"; tone ok | warn | off
|
|
12
|
+
* CONSENT_LINE the line the PM may paste in the call chat to tell the room PMOS listens
|
|
13
|
+
* buddyKey(F) · marksOf(storage, F) · markIn(storage, F, patch) the PM's own marks on a meeting, kept in this browser
|
|
14
|
+
* heardHtml(m) → string the recording tab's card: the consent line, the nudge, Filed and the chat drafts
|
|
15
|
+
*
|
|
16
|
+
* Every press carries data-mb="…": undo (data-bid), redo (data-bid), nudge-x (data-key), copy (data-id: a chat draft, or "consent"),
|
|
17
|
+
* chat-x (data-id), consent-x. The page that mounts the buddy (cozy-buddy.js, cozy-rec-now.js) does the writing.
|
|
18
|
+
* The words name PMOS only. Text from records goes through esc(). Node imports this file (meeting-buddy.test.js). */
|
|
19
|
+
|
|
20
|
+
export const CONSENT_LINE = 'I am taking notes on this call with PMOS, an assistant that listens. Tell me if you would rather it did not.';
|
|
21
|
+
export const NUDGE_MIN = 10; // the nudge shows when this many minutes or fewer are left
|
|
22
|
+
const FILED_MAX = 4, CONTEXT_MAX = 2;
|
|
23
|
+
|
|
24
|
+
const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
25
|
+
const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
|
|
26
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
27
|
+
const hm = (ms) => { const d = new Date(ms); return pad(d.getHours()) + ':' + pad(d.getMinutes()); };
|
|
28
|
+
const P = {
|
|
29
|
+
undo: 'M9 7L4 12l5 5M4 12h10a6 6 0 0 1 0 12', x: 'M6 6l12 12M18 6L6 18', open: 'M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5',
|
|
30
|
+
copy: 'M8 8h12v12H8zM16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2', spark: 'M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z',
|
|
31
|
+
};
|
|
32
|
+
const svg = (d, n = 16) => `<svg aria-hidden="true" width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
33
|
+
const ib = (act, label, d, attrs = '', cls = '') => `<button type="button" class="mb-ib${cls ? ' ' + cls : ''}" data-mb="${act}"${attrs} aria-label="${esc(label)}" title="${esc(label)}">${svg(d)}</button>`;
|
|
34
|
+
const KIND_WORD = { decision: 'decision', action: 'action', question: 'open question' };
|
|
35
|
+
const FROM_WORDS = { talk: 'the talk', screen: 'the screen', prep: 'the prep', last: 'last time' };
|
|
36
|
+
|
|
37
|
+
/** Where this browser keeps the PM's own marks on one meeting (the consent line copied, the nudges dismissed): one key per meeting and day. */
|
|
38
|
+
export const buddyKey = (F) => 'pmos.buddy.' + (F && F.event ? F.event.id + '|' + (F.date || String(F.event.at || '').slice(0, 10)) : '');
|
|
39
|
+
/** The PM's marks read from a Storage, wrapped: a blocked store gives none. → { toldAt, consentOff, nudgeOff: Set } */
|
|
40
|
+
export function marksOf(storage, F) {
|
|
41
|
+
let o = null; try { o = JSON.parse((storage && storage.getItem(buddyKey(F))) || 'null'); } catch { o = null; }
|
|
42
|
+
o = o && typeof o === 'object' ? o : {};
|
|
43
|
+
return { toldAt: Number.isFinite(o.toldAt) ? o.toldAt : null, consentOff: !!o.consentOff, nudgeOff: new Set(Array.isArray(o.nudgeOff) ? o.nudgeOff : []) };
|
|
44
|
+
}
|
|
45
|
+
/** Add to the marks; false when the store is blocked (the mark then lasts until the page reloads). */
|
|
46
|
+
export function markIn(storage, F, patch) {
|
|
47
|
+
try {
|
|
48
|
+
const k = buddyKey(F); const was = JSON.parse(storage.getItem(k) || 'null') || {};
|
|
49
|
+
const next = { ...was, ...patch };
|
|
50
|
+
if (patch.nudge) { next.nudgeOff = [...new Set([...(was.nudgeOff || []), patch.nudge])].slice(-20); delete next.nudge; }
|
|
51
|
+
storage.setItem(k, JSON.stringify(next)); return true;
|
|
52
|
+
} catch { return false; }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Where a Context row opens: an initiative in Home, or an https link. null when it names nothing PMOS can open. */
|
|
56
|
+
export function hrefOf(x) {
|
|
57
|
+
if (!x) return null;
|
|
58
|
+
if (x.ref && x.ref.type === 'initiative' && x.ref.id) return '/premium.html?ini=' + encodeURIComponent(x.ref.id);
|
|
59
|
+
if (typeof x.url === 'string' && /^https:\/\//i.test(x.url)) return x.url;
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The nudge: once per topic, when NUDGE_MIN minutes or fewer are left and a topic the room has not reached is still to cover. */
|
|
64
|
+
export function nudgeOf(agenda, { off } = {}) {
|
|
65
|
+
const A = agenda || null;
|
|
66
|
+
if (!A || !Array.isArray(A.topics) || A.left == null || !(A.left > 0) || A.left > NUDGE_MIN) return null;
|
|
67
|
+
const open = A.topics.filter((t) => t && !t.now && t.mark === 'notyet');
|
|
68
|
+
if (!open.length) return null;
|
|
69
|
+
const key = 'nudge:' + String(open[0].title || '').toLowerCase().replace(/\s+/g, ' ').trim();
|
|
70
|
+
if (off && typeof off.has === 'function' && off.has(key)) return null;
|
|
71
|
+
const what = clip(open[0].title, 60) + (open.length > 1 ? ' and ' + (open.length - 1) + ' more are' : ' is');
|
|
72
|
+
return { key, text: A.left + ' min left. ' + what + ' not covered yet.' };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The buddy's whole state, from the meeting focus read. Nothing is invented: a part with nothing behind it is empty. */
|
|
76
|
+
export function buddyModel(F, o = {}) {
|
|
77
|
+
const f = F && F.ok ? F : {};
|
|
78
|
+
const note = f.note || null;
|
|
79
|
+
const state = note ? note.state : null;
|
|
80
|
+
const listening = state === 'recording', paused = state === 'paused';
|
|
81
|
+
const A = f.agenda && Array.isArray(f.agenda.topics) && f.agenda.topics.length ? f.agenda : null;
|
|
82
|
+
const at = A ? A.topics.findIndex((t) => t.now) : -1;
|
|
83
|
+
const topic = at >= 0 ? { title: clip(A.topics[at].title, 80), n: at + 1, of: A.topics.length, left: A.left != null ? A.left : null } : null;
|
|
84
|
+
const cap = f.captured || {};
|
|
85
|
+
const filed = [];
|
|
86
|
+
for (const [kind, key] of [['decision', 'decisions'], ['action', 'actions'], ['question', 'questions']]) {
|
|
87
|
+
for (const x of Array.isArray(cap[key]) ? cap[key] : []) if (x && x.bid && x.text) filed.push({ kind, label: 'Filed · ' + KIND_WORD[kind], text: clip(x.text, 200), bid: String(x.bid) });
|
|
88
|
+
}
|
|
89
|
+
// newest last: a bullet id is b-<minute>-<k>, so the ids sort in meeting time
|
|
90
|
+
filed.sort((a, b) => a.bid.localeCompare(b.bid, 'en', { numeric: true }));
|
|
91
|
+
const context = [];
|
|
92
|
+
const notes = Array.isArray(f.notes) ? f.notes : [];
|
|
93
|
+
for (const n of notes.slice().reverse()) {
|
|
94
|
+
if (context.length >= CONTEXT_MAX || !n || n.cat !== 'Context' || n.ask) continue;
|
|
95
|
+
const act = (n.acts || []).find((a) => hrefOf(a));
|
|
96
|
+
context.push({ label: 'Context', text: clip(n.body, 160), href: act ? hrefOf(act) : null });
|
|
97
|
+
}
|
|
98
|
+
for (const c of Array.isArray(f.chips) ? f.chips : []) {
|
|
99
|
+
if (context.length >= CONTEXT_MAX) break;
|
|
100
|
+
const href = hrefOf(c); if (!href) continue;
|
|
101
|
+
context.push({ label: 'Context', text: clip(c.label + (c.sub ? ' · ' + c.sub : ''), 160), href });
|
|
102
|
+
}
|
|
103
|
+
const asks = Array.isArray(f.asks) ? f.asks : [];
|
|
104
|
+
const last = asks.length ? asks[asks.length - 1] : null;
|
|
105
|
+
let answer = null;
|
|
106
|
+
if (last) {
|
|
107
|
+
const a = notes.filter((x) => x && x.ask === last.id).pop() || null;
|
|
108
|
+
const from = a && Array.isArray(a.from) ? a.from.map((k) => FROM_WORDS[k]).filter(Boolean) : [];
|
|
109
|
+
answer = { id: last.id, question: clip(last.question, 300), state: a ? 'answered' : last.state === 'failed' ? 'failed' : 'working',
|
|
110
|
+
body: a ? clip(a.body, 700) : last.state === 'failed' ? (last.error || 'PMOS could not answer. Ask again.') : '', from: from.length ? 'From ' + from.join(' and ') : '' };
|
|
111
|
+
}
|
|
112
|
+
const drafts = (Array.isArray(f.raise) ? f.raise : []).filter((r) => r && r.kind === 'chat' && r.text).map((r) => ({ id: String(r.id), text: clip(r.text, 200) }));
|
|
113
|
+
const toldAt = Number.isFinite(o.toldAt) ? o.toldAt : null;
|
|
114
|
+
return {
|
|
115
|
+
eventId: f.event ? f.event.id : '', noteId: note ? note.id : '', title: f.event ? clip(f.event.title, 120) : '', call: (f.event && f.event.call) || null,
|
|
116
|
+
listening, paused, topic, gist: typeof f.gist === 'string' ? clip(f.gist, 400) : '',
|
|
117
|
+
nudge: listening ? nudgeOf(A, { off: o.nudgeOff }) : null,
|
|
118
|
+
filed: filed.slice(-FILED_MAX), filedMore: Math.max(0, filed.length - FILED_MAX), context, answer, drafts,
|
|
119
|
+
// the consent line shows while PMOS listens, until the PM copies it (or puts it away)
|
|
120
|
+
consent: { show: (listening || paused) && toldAt == null && !o.consentOff, toldAt },
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The panel's header line. */
|
|
125
|
+
export function headOf(m) {
|
|
126
|
+
if (m.paused) return { text: 'Paused', tone: 'warn' };
|
|
127
|
+
if (!m.listening) return { text: 'Not listening', tone: 'off' };
|
|
128
|
+
const sub = m.consent.show ? 'others not told yet' : m.topic ? 'Topic ' + m.topic.n + ' of ' + m.topic.of : m.consent.toldAt != null ? 'others told ' + hm(m.consent.toldAt) : '';
|
|
129
|
+
return { text: 'Listening' + (sub ? ' · ' + sub : ''), tone: m.consent.show ? 'warn' : 'ok' };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const row = (k, body, acts = '', cls = '') => `<div class="mb-r${cls ? ' ' + cls : ''}"><span class="t">${k ? `<small>${esc(k)}</small>` : ''}${body}</span>${acts}</div>`;
|
|
133
|
+
|
|
134
|
+
export const topicHtml = (m) => (m.topic ? `<div class="mb-r mb-top"><b class="t">${esc(m.topic.title)}</b>${m.topic.left != null ? `<span class="mb-sm">${esc(m.topic.left + ' min left')}</span>` : ''}</div>` : '');
|
|
135
|
+
export const nowHtml = (m) => (m.gist ? `<div class="mb-r"><span class="t"><small>Now</small>${esc(m.gist)}</span><span class="mb-spark">${svg(P.spark, 14)}</span></div>` : '');
|
|
136
|
+
export const nudgeHtml = (m) => (m.nudge ? `<div class="mb-r mb-nudge" role="status"><i class="mb-dot warn" aria-hidden="true"></i><span class="t">${esc(m.nudge.text)}</span>${ib('nudge-x', 'Dismiss', P.x, ` data-key="${esc(m.nudge.key)}"`)}</div>` : '');
|
|
137
|
+
export function filedHtml(m) {
|
|
138
|
+
if (!m.filed.length) return '';
|
|
139
|
+
return m.filed.map((x) => row(x.label, esc(x.text), ib('undo', 'Undo: take it out of the notes', P.undo, ` data-bid="${esc(x.bid)}"`))).join('')
|
|
140
|
+
+ (m.filedMore ? `<div class="mb-r mb-more"><span class="mb-sm">${esc(m.filedMore + ' more filed in the notes')}</span></div>` : '');
|
|
141
|
+
}
|
|
142
|
+
export function contextHtml(m) {
|
|
143
|
+
return m.context.map((c) => row(c.label, esc(c.text), c.href ? `<a class="mb-ib" href="${esc(c.href)}" target="_blank" rel="noopener noreferrer" aria-label="Open it" title="Open it">${svg(P.open)}</a>` : '')).join('');
|
|
144
|
+
}
|
|
145
|
+
export function draftsHtml(m) {
|
|
146
|
+
return m.drafts.map((d) => `<div class="mb-r mb-draft" data-draft="${esc(d.id)}"><span class="t"><small>Draft for the call chat</small>${esc(d.text)}</span>`
|
|
147
|
+
+ ib('copy', 'Copy the line, then paste it in the call chat', P.copy, ` data-id="${esc(d.id)}"`, 'go') + ib('chat-x', 'Not now', P.x, ` data-id="${esc(d.id)}"`) + '</div>').join('');
|
|
148
|
+
}
|
|
149
|
+
export function consentHtml(m) {
|
|
150
|
+
if (!m.consent.show) return '';
|
|
151
|
+
return `<div class="mb-r mb-consent"><span class="t"><small>PMOS proposes</small>Tell the call you are taking notes with PMOS?<q class="mb-line">${esc(CONSENT_LINE)}</q></span>`
|
|
152
|
+
+ `<span class="mb-acts">${ib('copy', 'Copy the line, then paste it in the call chat', P.copy, ' data-id="consent"', 'go')}${ib('consent-x', 'Not now', P.x)}</span></div>`;
|
|
153
|
+
}
|
|
154
|
+
export function answerHtml(m) {
|
|
155
|
+
const a = m.answer; if (!a) return '';
|
|
156
|
+
return row('You asked', esc(a.question)) + (a.state === 'working'
|
|
157
|
+
? row('PMOS', '<span class="mb-sm" role="status">PMOS is answering…</span>')
|
|
158
|
+
: row('PMOS', esc(a.body) + (a.from ? `<span class="mb-src">${esc(a.from)}</span>` : ''), '', a.state === 'failed' ? 'bad' : ''));
|
|
159
|
+
}
|
|
160
|
+
/** The Meet panel's body, in the order of board 1. */
|
|
161
|
+
export const buddyHtml = (m) => topicHtml(m) + nowHtml(m) + nudgeHtml(m) + consentHtml(m) + filedHtml(m) + contextHtml(m) + draftsHtml(m) + answerHtml(m);
|
|
162
|
+
/** The recording tab's card (its Now panel already shows the topic, the gist and the answer). */
|
|
163
|
+
export function heardHtml(m) {
|
|
164
|
+
const h = consentHtml(m) + nudgeHtml(m) + filedHtml(m) + draftsHtml(m);
|
|
165
|
+
return h ? `<div class="mb-card">${h}</div>` : '';
|
|
166
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* pm/buddy-press.js — the meeting buddy's presses (initiative meeting-buddy), shared by the Meet panel (cozy-buddy.js) and the recording
|
|
2
|
+
* tab's Now panel (cozy-rec-now.js). The rows are pm/buddy-core.js's; each press carries data-mb="…".
|
|
3
|
+
*
|
|
4
|
+
* press(btn, F, { pmPost, storage, mem }) → Promise<{ msg, undo?: bid, read: boolean } | null> null: not a buddy press
|
|
5
|
+
* undo / redo POST /api/notes/bullet { id, bullet, drop }: the filed item out of the notes, or back in
|
|
6
|
+
* copy the line on the clipboard. A chat draft is then marked raised (POST /api/meeting-focus/raise); the consent line is
|
|
7
|
+
* marked copied in this browser. Nothing is posted to the call or its chat: the PM pastes the line himself.
|
|
8
|
+
* chat-x the draft put away (POST /api/meeting-focus/raise, skip)
|
|
9
|
+
* nudge-x · consent-x kept in this browser (buddy-core.js markIn); mem keeps them when the store is blocked
|
|
10
|
+
*/
|
|
11
|
+
import { CONSENT_LINE, markIn } from './buddy-core.js';
|
|
12
|
+
|
|
13
|
+
export async function copyText(text) {
|
|
14
|
+
try { await navigator.clipboard.writeText(text); return true; } catch { /* the frame may not allow it */ }
|
|
15
|
+
try {
|
|
16
|
+
const t = document.createElement('textarea'); t.value = text; t.setAttribute('readonly', ''); t.className = 'mb-clip';
|
|
17
|
+
document.body.appendChild(t); t.select(); const ok = document.execCommand('copy'); t.remove(); return ok;
|
|
18
|
+
} catch { return false; }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The marks this view holds in memory, for a blocked store. */
|
|
22
|
+
export const newMem = () => ({ toldAt: null, consentOff: false, nudgeOff: new Set() });
|
|
23
|
+
/** The marks of the store and of memory together. */
|
|
24
|
+
export function mergeMarks(fromStore, mem) {
|
|
25
|
+
return { toldAt: fromStore.toldAt != null ? fromStore.toldAt : mem.toldAt, consentOff: fromStore.consentOff || mem.consentOff, nudgeOff: new Set([...fromStore.nudgeOff, ...mem.nudgeOff]) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function press(b, F, { pmPost, storage, mem }) {
|
|
29
|
+
const act = b && b.dataset ? b.dataset.mb : '';
|
|
30
|
+
const f = F || {};
|
|
31
|
+
const noteId = f.note ? f.note.id : '';
|
|
32
|
+
const where = noteId ? { note: noteId } : f.event ? { event: f.event.id, date: f.date } : {};
|
|
33
|
+
const mark = (patch) => {
|
|
34
|
+
if (patch.nudge) mem.nudgeOff.add(patch.nudge);
|
|
35
|
+
if (patch.toldAt) mem.toldAt = patch.toldAt;
|
|
36
|
+
if (patch.consentOff) mem.consentOff = true;
|
|
37
|
+
markIn(storage, f, patch);
|
|
38
|
+
};
|
|
39
|
+
switch (act) {
|
|
40
|
+
case 'nudge-x': mark({ nudge: b.dataset.key }); return { msg: '', read: false };
|
|
41
|
+
case 'consent-x': mark({ consentOff: true }); return { msg: '', read: false };
|
|
42
|
+
case 'copy': {
|
|
43
|
+
if (b.dataset.id === 'consent') {
|
|
44
|
+
if (!(await copyText(CONSENT_LINE))) return { msg: 'The line was not copied. Select it and copy it yourself.', read: false };
|
|
45
|
+
mark({ toldAt: Date.now() });
|
|
46
|
+
return { msg: 'Copied. Paste it in the call chat.', read: false };
|
|
47
|
+
}
|
|
48
|
+
const d = (f.raise || []).find((r) => r.id === b.dataset.id); if (!d) return null;
|
|
49
|
+
if (!(await copyText(d.text))) return { msg: 'The line was not copied.', read: false };
|
|
50
|
+
const r = await pmPost('/api/meeting-focus/raise', { ...where, id: d.id, action: 'raised' });
|
|
51
|
+
return { msg: r && r.ok ? 'Copied. Paste it in the call chat if you still want it.' : 'Copied, but not marked: ' + ((r && r.error) || 'no answer'), read: true };
|
|
52
|
+
}
|
|
53
|
+
case 'chat-x': {
|
|
54
|
+
const r = await pmPost('/api/meeting-focus/raise', { ...where, id: b.dataset.id, action: 'skip' });
|
|
55
|
+
return { msg: r && r.ok ? '' : 'Not saved: ' + ((r && r.error) || 'no answer'), read: true };
|
|
56
|
+
}
|
|
57
|
+
case 'undo': case 'redo': {
|
|
58
|
+
if (!noteId) return null;
|
|
59
|
+
const bid = b.dataset.bid;
|
|
60
|
+
const r = await pmPost('/api/notes/bullet', { id: noteId, bullet: bid, drop: act === 'undo' });
|
|
61
|
+
if (!r || !r.ok) return { msg: 'Not changed: ' + ((r && r.error) || 'no answer'), read: false };
|
|
62
|
+
return act === 'undo' ? { msg: 'Taken out of the notes.', undo: bid, read: true } : { msg: 'Back in the notes.', read: true };
|
|
63
|
+
}
|
|
64
|
+
default: return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* cozy-buddy.css — the meeting buddy (initiative meeting-buddy; pm/buddy-core.js draws it, pm/cozy-buddy.js mounts the page).
|
|
2
|
+
* The page is the PMOS panel over a Meet call (a 360 × 520 frame), and the same rows sit in the recording tab's Now panel.
|
|
3
|
+
* Colours are the cozy tokens only, so the dark theme follows cozy.css. Every class starts with mb-. */
|
|
4
|
+
|
|
5
|
+
/* the rows, shared by the Meet panel and the recording tab */
|
|
6
|
+
.mb-r { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--cz-hair); font-size: var(--fs-label); line-height: var(--lh-label); color: var(--cz-ink); }
|
|
7
|
+
.mb-r .t { flex: 1; min-width: 0; line-height: 1.4; }
|
|
8
|
+
.mb-r .t small { display: block; font-size: var(--fs-label); font-weight: var(--fw-regular); color: var(--cz-ink3); }
|
|
9
|
+
.mb-r.bad .t { color: var(--cz-late); }
|
|
10
|
+
.mb-top { font-size: var(--fs-body); align-items: center; }
|
|
11
|
+
.mb-sm { font-size: var(--fs-label); color: var(--cz-ink3); }
|
|
12
|
+
.mb-src { display: block; font-size: var(--fs-label); color: var(--cz-ink3); margin-top: 2px; }
|
|
13
|
+
.mb-spark { color: var(--cz-blueink); flex: none; padding-top: 2px; }
|
|
14
|
+
.mb-nudge { background: var(--cz-riskbg); }
|
|
15
|
+
.mb-draft, .mb-consent { background: var(--cz-well); }
|
|
16
|
+
.mb-line { display: block; margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--cz-card); color: var(--cz-ink2); quotes: none; }
|
|
17
|
+
.mb-acts { display: flex; gap: 6px; flex: none; }
|
|
18
|
+
.mb-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--cz-ink3); flex: none; opacity: .6; }
|
|
19
|
+
.mb-dot.ok { background: var(--cz-ok); opacity: 1; }
|
|
20
|
+
.mb-dot.warn { background: var(--cz-risk); opacity: 1; }
|
|
21
|
+
.mb-r .mb-dot { margin-top: 4px; }
|
|
22
|
+
.mb-ib { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; cursor: pointer; font: inherit; text-decoration: none; }
|
|
23
|
+
.mb-ib.go { background: var(--cz-solid); border-color: var(--cz-solid); color: var(--cz-onsolid); }
|
|
24
|
+
.mb-ib:disabled { opacity: .5; cursor: default; }
|
|
25
|
+
.mb-ib:focus-visible, .mb-pick:focus-visible, .mb-undo:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
26
|
+
@media (hover: hover) { .mb-ib:hover { background: var(--cz-well); } .mb-ib.go:hover { background: var(--cz-blueink); } }
|
|
27
|
+
@media (pointer: coarse) { .mb-ib { width: 44px; height: 44px; } }
|
|
28
|
+
.mb-undo { border: 0; background: none; padding: 0; font: inherit; font-weight: var(--fw-strong); color: var(--cz-blueink); cursor: pointer; }
|
|
29
|
+
|
|
30
|
+
/* the page over the call */
|
|
31
|
+
.mb-page, .cz.mb-page { margin: 0; height: 100vh; overflow: hidden; background: var(--cz-card); }
|
|
32
|
+
.mb { height: 100%; display: flex; flex-direction: column; color: var(--cz-ink); }
|
|
33
|
+
.mb-h { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; min-height: 44px; box-sizing: border-box; border-bottom: 1px solid var(--cz-hair); font-size: var(--fs-body); }
|
|
34
|
+
.mb-h .mb-sm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
35
|
+
.mb-h .mb-ib { border: 0; background: none; }
|
|
36
|
+
.mb-b { flex: 1; min-height: 0; overflow-y: auto; }
|
|
37
|
+
.mb-b > :last-child { border-bottom: 0; }
|
|
38
|
+
.mb-msg { margin: 0; padding: 8px 14px; font-size: var(--fs-label); color: var(--cz-ink2); border-top: 1px solid var(--cz-hair); }
|
|
39
|
+
.mb-msg[hidden], .mb-ask[hidden] { display: none; }
|
|
40
|
+
.mb-ask { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--cz-hair); }
|
|
41
|
+
.mb-ask input { flex: 1; min-width: 0; height: 32px; border-radius: 6px; border: 0; background: var(--cz-well); padding: 0 12px; font: inherit; font-size: var(--fs-label); color: var(--cz-ink); }
|
|
42
|
+
.mb-ask input::placeholder { color: var(--cz-ink3); }
|
|
43
|
+
.mb-pick { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--cz-hair); background: none; font: inherit; font-size: var(--fs-label); color: var(--cz-ink); text-align: left; cursor: pointer; }
|
|
44
|
+
.mb-pick b { flex: 1; min-width: 0; }
|
|
45
|
+
.mb-none { padding: 14px; margin: 0; }
|
|
46
|
+
.folded .mb-b, .folded .mb-msg { display: none; }
|
|
47
|
+
.folded .mb-h { border-bottom: 0; }
|
|
48
|
+
|
|
49
|
+
/* in the recording tab's Now panel: the rows sit in one card */
|
|
50
|
+
.mb-card { border-radius: 8px; background: var(--cz-card); box-shadow: 0 0 0 1px var(--cz-hair); overflow: hidden; }
|
|
51
|
+
.mb-card > :last-child { border-bottom: 0; }
|
|
52
|
+
.mb-clip { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* pm/cozy-buddy.js — the meeting buddy page, /premium-buddy.html (initiative meeting-buddy; Exploring 2, "Meeting buddy and one-press start").
|
|
2
|
+
*
|
|
3
|
+
* The PMOS extension frames this page over a Google Meet call (extension/panel.js): ?meet=<abc-defg-hij>&mtitle=<tab title>. The page finds
|
|
4
|
+
* the meeting on the calendar (GET /api/meeting-focus/now), then reads it every 10 s (GET /api/meeting-focus), which also lets the read-only
|
|
5
|
+
* companion run while the meeting records. With no meeting that fits, it lists today's meetings to pick from.
|
|
6
|
+
*
|
|
7
|
+
* Drawn (pm/buddy-core.js): the header (Listening · Topic n of N, Paused, Not listening), the topic and its minutes, Now, the time nudge,
|
|
8
|
+
* the consent line, Filed rows with Undo, Context, drafts for the call chat, the last answer, and a line to ask PMOS quietly.
|
|
9
|
+
* Not listening: one play icon that starts listening to this meeting in the PMOS recording tab (Chrome then asks which tab to share).
|
|
10
|
+
*
|
|
11
|
+
* Writes, each on a press: POST /api/notes/bullet (Undo: drop the filed bullet; Undo again: take it back), POST /api/meeting-focus/raise
|
|
12
|
+
* (a chat draft copied or put away), POST /api/meeting-focus/ask (a question). Copy puts a line on the clipboard; nothing here posts to the
|
|
13
|
+
* call or its chat. The consent line's copy and the nudge's dismiss are kept in this browser only (buddy-core.js marksOf, per meeting).
|
|
14
|
+
* Fold sends { pmosFocus: 'fold' | 'open' } to the panel, which shrinks to a pill. */
|
|
15
|
+
import { pmGet, pmPost } from './http.js';
|
|
16
|
+
import { buddyModel, buddyHtml, headOf, marksOf } from './buddy-core.js';
|
|
17
|
+
import { press, newMem, mergeMarks } from './buddy-press.js';
|
|
18
|
+
import { recCore } from './premium-meeting.js';
|
|
19
|
+
|
|
20
|
+
const q = new URLSearchParams(location.search);
|
|
21
|
+
const $ = (id) => document.getElementById(id);
|
|
22
|
+
const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
23
|
+
const READ_MS = 10000, ASK_MS = 3000;
|
|
24
|
+
const S = { ev: null, date: '', F: null, html: '', folded: false, timer: null, busy: false };
|
|
25
|
+
|
|
26
|
+
const ls = () => { try { return window.localStorage; } catch { return null; } };
|
|
27
|
+
const MEM = newMem(); // the PM's marks when the store is blocked: this view only
|
|
28
|
+
const local = () => mergeMarks(marksOf(ls(), S.F), MEM);
|
|
29
|
+
|
|
30
|
+
function say(text) { const m = $('mbMsg'); m.textContent = text || ''; m.hidden = !text; }
|
|
31
|
+
function draw() {
|
|
32
|
+
const L = local();
|
|
33
|
+
const m = buddyModel(S.F, L);
|
|
34
|
+
const h = headOf(m);
|
|
35
|
+
$('mbDot').className = 'mb-dot ' + h.tone;
|
|
36
|
+
$('mbHead').textContent = (S.ev ? h.text : 'Looking for the meeting');
|
|
37
|
+
let body = buddyHtml(m);
|
|
38
|
+
if (!m.listening && !m.paused && S.ev) {
|
|
39
|
+
body = `<div class="mb-r mb-start"><span class="t"><small>${esc(m.title)}</small>PMOS is not listening to this meeting.</span>`
|
|
40
|
+
+ `<button type="button" class="mb-ib go" data-mb="listen" aria-label="Start listening in PMOS" title="Start listening in PMOS"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg></button></div>` + body;
|
|
41
|
+
}
|
|
42
|
+
if (body !== S.html) { S.html = body; $('mbBody').innerHTML = body; }
|
|
43
|
+
$('mbAsk').hidden = !S.ev || S.folded;
|
|
44
|
+
const working = m.answer && m.answer.state === 'working';
|
|
45
|
+
clearTimeout(S.timer); S.timer = setTimeout(read, working ? ASK_MS : READ_MS);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function read() {
|
|
49
|
+
if (!S.ev) return;
|
|
50
|
+
const F = await pmGet('/api/meeting-focus?event=' + encodeURIComponent(S.ev.id) + '&date=' + encodeURIComponent(S.date));
|
|
51
|
+
if (F && F.ok) { S.F = F; say(''); } else if (!S.F) say((F && F.error) || 'PMOS did not answer.');
|
|
52
|
+
draw();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Which meeting this call is. With none that fits, today's meetings to pick from. */
|
|
56
|
+
async function find() {
|
|
57
|
+
if (q.get('event')) { S.ev = { id: q.get('event') }; S.date = q.get('date') || ''; return read(); }
|
|
58
|
+
const r = await pmGet('/api/meeting-focus/now?meet=' + encodeURIComponent(q.get('meet') || '') + '&title=' + encodeURIComponent(q.get('mtitle') || ''));
|
|
59
|
+
if (r && r.ok) { S.ev = r.event; S.date = r.date; return read(); }
|
|
60
|
+
const ch = (r && r.choices) || [];
|
|
61
|
+
$('mbHead').textContent = 'Which meeting is this?';
|
|
62
|
+
$('mbBody').innerHTML = ch.length
|
|
63
|
+
? ch.map((c, i) => `<button type="button" class="mb-pick" data-mb="pick" data-i="${i}"><b>${esc(c.title || 'Meeting')}</b><span class="mb-sm">${esc(String(c.at || '').slice(11, 16))}</span></button>`).join('')
|
|
64
|
+
: '<p class="mb-sm mb-none">No meeting on your PMOS calendar today.</p>';
|
|
65
|
+
S.choices = ch;
|
|
66
|
+
setTimeout(find, 30000); // a meeting added to the calendar later is found
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Start listening: the PMOS recording tab opens on this meeting's note and asks where the meeting is (Google Meet in Chrome). */
|
|
70
|
+
async function listen() {
|
|
71
|
+
const C = recCore({ pmGet, pmPost, ws: () => null });
|
|
72
|
+
const ev = (S.F && S.F.event) || S.ev;
|
|
73
|
+
const call = ev.call || null;
|
|
74
|
+
const res = await C.record({ id: ev.id, at: ev.at, end: ev.end, title: ev.title, app: call ? (call.app === 'teams' ? 'other' : call.app) : 'meet' });
|
|
75
|
+
say(res && res.ok ? 'The PMOS recording tab opened. Pick this call in Chrome\'s window and tick tab sound.' : (res && res.error) || 'Listening did not start.');
|
|
76
|
+
read();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
document.addEventListener('click', async (e) => {
|
|
80
|
+
const b = e.target.closest('[data-mb]'); if (!b || b.disabled) return;
|
|
81
|
+
const act = b.dataset.mb;
|
|
82
|
+
if (act === 'pick') { const c = S.choices[+b.dataset.i]; if (c) { S.ev = c; S.date = String(c.at || '').slice(0, 10); read(); } return; }
|
|
83
|
+
if (act === 'listen') { b.disabled = true; try { await listen(); } finally { b.disabled = false; } return; }
|
|
84
|
+
b.disabled = true;
|
|
85
|
+
let r = null;
|
|
86
|
+
try { r = await press(b, S.F, { pmPost, storage: ls(), mem: MEM }); } finally { b.disabled = false; }
|
|
87
|
+
if (!r) return;
|
|
88
|
+
if (r.undo) { const m2 = $('mbMsg'); m2.hidden = false; m2.innerHTML = esc(r.msg) + ' <button type="button" class="mb-undo" data-mb="redo" data-bid="' + esc(r.undo) + '">Undo</button>'; }
|
|
89
|
+
else say(r.msg);
|
|
90
|
+
if (r.read) read(); else draw();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
$('mbAsk').addEventListener('submit', async (e) => {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
const i = $('mbQ'), text = i.value.trim(); if (!text || !S.ev) return;
|
|
96
|
+
i.disabled = true;
|
|
97
|
+
const m = S.F || {};
|
|
98
|
+
const r = await pmPost('/api/meeting-focus/ask', { ...(m.note ? { note: m.note.id } : {}), event: S.ev.id, date: S.date, question: text });
|
|
99
|
+
i.disabled = false;
|
|
100
|
+
if (!r || !r.ok) { say('PMOS could not take the question: ' + ((r && r.error) || 'no answer')); return; }
|
|
101
|
+
i.value = ''; say(r.state === 'offered' ? 'PMOS offers to show it in the recording tab.' : '');
|
|
102
|
+
read();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
$('mbFold').addEventListener('click', () => {
|
|
106
|
+
S.folded = !S.folded;
|
|
107
|
+
document.body.classList.toggle('folded', S.folded);
|
|
108
|
+
const b = $('mbFold'); b.setAttribute('aria-expanded', String(!S.folded));
|
|
109
|
+
b.setAttribute('aria-label', S.folded ? 'Open PMOS' : 'Fold PMOS'); b.title = b.getAttribute('aria-label');
|
|
110
|
+
// the panel (extension/panel.js) passes this on to the Meet page, which shrinks the frame to a pill. It carries no data.
|
|
111
|
+
if (window.parent !== window) window.parent.postMessage({ pmosFocus: S.folded ? 'fold' : 'open' }, '*');
|
|
112
|
+
draw();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
find();
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* a press ticks or unticks and the list stays open, the last tick stays, and the pick applies when the list closes (Escape, a press outside,
|
|
16
16
|
* the chip again, or the sheet's scrim). Arrow keys move in the list. Add a product is the last row. Nothing here writes but savePick. */
|
|
17
17
|
import { pmGet, pmPost } from './http.js';
|
|
18
|
+
import { productName } from './scope-chip.js'; // one display name per product on every page ("IDPF", not "pmos-idpf"); used at draw time only
|
|
19
|
+
/** A product's name as every page prints it; the pick's own name until the names are in. */
|
|
20
|
+
const nameOf = (p) => productName(p && p.ws, (p && p.name) || '');
|
|
18
21
|
|
|
19
22
|
export const TONES = 3;
|
|
20
23
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
@@ -45,13 +48,13 @@ const isAll = (P) => !!P && P.products.length > 1 && P.products.every((p) => p.o
|
|
|
45
48
|
/** The words of the chip (its tooltip and accessible name): "Products on Home: acme-shop, acme-web", or "… all 3". */
|
|
46
49
|
export function chipWords(P, label) {
|
|
47
50
|
if (!P || !P.products.length) return label + ': none registered';
|
|
48
|
-
return label + ': ' + (isAll(P) ? 'all ' + P.products.length : P.products.filter((p) => p.on).map(
|
|
51
|
+
return label + ': ' + (isAll(P) ? 'all ' + P.products.length : P.products.filter((p) => p.on).map(nameOf).join(', '));
|
|
49
52
|
}
|
|
50
53
|
export function chipHtml(P, o = {}) {
|
|
51
54
|
const T = o.tones || tonesOf(P ? P.products : []), on = P ? P.products.filter((p) => p.on) : [];
|
|
52
55
|
// o.names (Work and Goals, slice 1): the full name of the first ticked product, "+2" for the others, "All products" when every one is ticked
|
|
53
56
|
const first = on.slice().sort((a, b) => (b.primary ? 1 : 0) - (a.primary ? 1 : 0))[0];
|
|
54
|
-
const inner = !P ? '' : o.names ? `<span class="ppk-all ppk-nmc">${isAll(P) ? 'All products' : first ? esc(first
|
|
57
|
+
const inner = !P ? '' : o.names ? `<span class="ppk-all ppk-nmc">${isAll(P) ? 'All products' : first ? esc(nameOf(first)) + (on.length > 1 ? ` <em>+${on.length - 1}</em>` : '') : 'No product'}</span>`
|
|
55
58
|
: isAll(P) ? '<span class="ppk-all">All</span>'
|
|
56
59
|
: `<span class="ppk-stk">${on.slice(0, 3).map((p) => `<i class="ppk-t t${T[p.ws] || 0}">${esc(codeOf(p))}</i>`).join('')}${on.length > 3 ? `<i class="ppk-t ppk-n">+${on.length - 3}</i>` : ''}</span>`;
|
|
57
60
|
const words = chipWords(P, o.label || 'Products'), id = o.id || 'ppChip', open = !!cur && cur.id === id; // a page that draws again keeps the open state
|
|
@@ -67,7 +70,7 @@ function itemsHtml(c) {
|
|
|
67
70
|
const box = (st) => `<i class="ppk-tk${st === 'true' ? ' on' : st === 'mixed' ? ' part' : ''}" aria-hidden="true">${st === 'true' ? svg(TICK, 13, 3.4) : st === 'mixed' ? svg(PART, 12, 3.4) : ''}</i>`;
|
|
68
71
|
const rows = P.products.map((p) => {
|
|
69
72
|
const on = c.tick.has(p.ws), line = c.o.lines ? c.o.lines(p.ws) : '';
|
|
70
|
-
return `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${on}" data-pp="${esc(p.ws)}"><span class="ppk-tl t${T[p.ws] || 0}" aria-hidden="true">${esc(codeOf(p))}</span><span class="ppk-nm"><b>${esc(p
|
|
73
|
+
return `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${on}" data-pp="${esc(p.ws)}"><span class="ppk-tl t${T[p.ws] || 0}" aria-hidden="true">${esc(codeOf(p))}</span><span class="ppk-nm"><b>${esc(nameOf(p))}</b>${line ? `<em>${esc(line)}</em>` : ''}</span>${box(String(on))}</button>`;
|
|
71
74
|
}).join('');
|
|
72
75
|
return (P.products.length > 1 ? `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${all}" data-pp="*"><span class="ppk-nm"><b>All products</b></span>${box(all)}</button><div class="ppk-sep" role="separator"></div>` : '')
|
|
73
76
|
+ rows + (`${P.products.length ? '<div class="ppk-sep" role="separator"></div>' : ''}<button type="button" class="ppk-mi" role="menuitem" data-pp-add><span class="ppk-pl" aria-hidden="true">${svg(PLUS, 18, 2.2)}</span><span class="ppk-nm"><b>Add a product</b></span></button>`)
|