create-pmos 0.266.0 → 0.267.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.266.0",
3
+ "version": "0.267.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@f9ca693
1
+ kernel-source: pmos@277fdcb
2
2
  assembled: 2026-10-18
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-18T10:48:48Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T11:30:29Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-18T10:48:48Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T11:30:29Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-18T10:48:48Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T11:30:29Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -0,0 +1,231 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* briefing-premium-calendar-2-test.js — Add and Remove material and Make task in the premium meeting dialog (initiative briefing-premium-calendar, slice 2;
4
+ * planning/prd/briefing-premium-calendar-2-prd.md M1 to M7). Serves the real page from the real server. The Briefing model, the calendar answer, the replay and the material
5
+ * are answered by stand-ins, so each press can be read off the request the page sent; the routes' own behaviour is in their own suites.
6
+ * M1 add material · M2 remove · M3 what each press records · M4 make task · M5 honest states · M6 only the named writes · M7 floors and fidelity
7
+ * Every wait polls the page; no fixed sleep stands in for a state. */
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { spawn } = require('child_process');
11
+ const { findBrowser } = require('./lib/find-browser');
12
+ const T = require('./test-run').configure({ name: 'briefing-premium-calendar-2' });
13
+ const B = require('./lib/briefing-premium.js');
14
+ const F = require('./fixtures/briefing-premium-facts.js');
15
+
16
+ const BASE = T.BASE;
17
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
18
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
19
+ const results = [];
20
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
21
+ let srv = null; let browser = null;
22
+ const finish = async (code) => {
23
+ if (browser) await browser.close().catch(() => {});
24
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
25
+ T.killTmux();
26
+ const bad = results.filter((x) => !x.cond).length;
27
+ console.log(`\n${results.length - bad}/${results.length} briefing-premium-calendar-2 assertions passed`);
28
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
29
+ };
30
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
31
+
32
+ const pad = (n) => String(n).padStart(2, '0');
33
+ const dayKey = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
34
+ const iso = (d) => { const off = -d.getTimezoneOffset(), a = Math.abs(off); return `${dayKey(d)}T${pad(d.getHours())}:${pad(d.getMinutes())}:00${off >= 0 ? '+' : '-'}${pad(Math.floor(a / 60))}:${pad(a % 60)}`; };
35
+ const NOW = new Date();
36
+ const at = (h, m, plus = 0) => { const d = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate() + plus, h, m, 0, 0); return d; };
37
+ const monday = () => { const d = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate()); d.setDate(d.getDate() - ((d.getDay() + 6) % 7)); return d; };
38
+ const weekAnswer = () => {
39
+ const m = monday(), cells = [];
40
+ for (let i = 0; i < 7; i++) { const d = new Date(m.getFullYear(), m.getMonth(), m.getDate() + i); cells.push({ key: dayKey(d), start: dayKey(d), end: dayKey(d), events: [] }); }
41
+ const put = (d, e) => cells.find((c) => c.key === dayKey(d)).events.push(e);
42
+ put(at(9, 30), { id: 'ev-checkout', at: iso(at(9, 30)), end: iso(at(10, 15)), title: 'Checkout sync', attendees: ['Priya', 'Dara'] });
43
+ put(at(14, 0), { id: 'ev-sprint', at: iso(at(14, 0)), end: iso(at(15, 0)), title: 'Sprint planning', attendees: ['Dara', 'Priya', 'Sam'], series: 'sprint-planning' });
44
+ const other = at(9, 30, NOW.getDay() === 0 ? -1 : 1); // a day other than today, still in the week unless it runs off the end
45
+ if (cells.some((c) => c.key === dayKey(other))) put(other, { id: 'ev-standup', at: iso(other), end: iso(new Date(other.getTime() + 30 * 60000)), title: 'Standup', attendees: [] });
46
+ return { ok: true, view: 'week', range: { start: cells[0].key, end: cells[6].key }, cells, events_source: 'calendar-memory', today: dayKey(NOW),
47
+ context: { 'ev-sprint': { phase: 'upcoming', level: { kind: 'board', ws: 'w1', id: 'idpf', name: 'IDPF', why: 'you linked it to the board', by: 'pm' } } },
48
+ link_boards: [{ ws: 'w1', id: 'idpf', name: 'IDPF' }, { ws: 'w1', id: 'pay', name: 'Payments' }], gantt: [{ id: 'premium-ux', title: 'Premium UX' }] };
49
+ };
50
+ const REPLAY0 = { ok: true, note: { id: 'n1', title: 'Sprint planning notes' }, meeting: { title: 'Sprint planning', attendees: ['Dara', 'Priya', 'Sam'] }, audio: { url: '/x', ms: 1500000 }, length_ms: 1500000, lines: [{}],
51
+ keys: [{ k: 'decision', text: 'Plan the sprint with eight people', state: 'draft' }, { k: 'action', text: 'Sam confirms the data fix owner', owner: 'Sam', due: 'Tue', state: 'owner' }, { k: 'question', text: 'Does a release eat the capacity?', state: 'open' }] };
52
+ const MATERIAL = { ok: true, key: 'k', items: [{ id: 'm1', kind: 'doc', ref: 'r', title: 'Capacity sheet', scope: 'series' }, { id: 'm2', kind: 'link', url: 'https://x.example', title: 'Roadmap', scope: 'meeting' }] };
53
+ const MOCKUP = fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'briefing-artifact.html'), 'utf8');
54
+
55
+
56
+ const REPLAY = Object.assign({}, REPLAY0, { note: { id: 'n1', title: 'Sprint planning notes', ws: 'w1', initiative: { id: 'premium-ux', title: 'Premium UX', ws: 'w1' } } });
57
+ const REPLAY_NOINI = Object.assign({}, REPLAY0, { note: { id: 'n1', title: 'Sprint planning notes' } });
58
+ const SUGGEST = { ok: true, suggested: [{ kind: 'pmos-doc', ref: 'planning/prd/premium-ux-prd.md', title: 'Premium UX PRD', meta: 'document', ws: 'w1' }], found: [{ kind: 'report', ref: 'planning/reports/q3.md', title: 'Q3 report', meta: 'report', ws: 'w1' }] };
59
+
60
+ (async () => {
61
+ const exe = findBrowser();
62
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
63
+ let chromium;
64
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
65
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
66
+ await T.waitForServer(BASE);
67
+ browser = await chromium.launch({ executablePath: exe });
68
+
69
+ const facts = () => { const f = F.facts(); f.meetings = [{ start: at(14, 0).getTime(), end: at(15, 0).getTime(), title: 'Sprint planning', with: 'Dara, Priya, Sam', initiative: null }]; return f; };
70
+ const open = async ({ w = 1280, h = 900, theme = 'light', replay = REPLAY, items = [{ id: 'm1', kind: 'link', url: 'https://x.example/road', title: 'Roadmap', scope: 'meeting', from: 'you' }], writeStatus = 200, planStatus = 200, stages = [{ id: 'st1', label: 'Intake' }] } = {}) => {
71
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
72
+ const page = await ctx.newPage();
73
+ const S = { errors: [], reqs: [], matPosts: [], planPosts: [], suggestGets: [], items: items.slice() };
74
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
75
+ page.on('request', (r) => { if (r.url().startsWith(BASE)) S.reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
76
+ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
77
+ await page.route('**/api/briefing-premium*', (r) => json(r, { ok: true, state: 'ready', model: B.build(facts()), as_of: Date.now() }));
78
+ await page.route('**/api/calendar-views*', (r) => json(r, weekAnswer()));
79
+ await page.route('**/api/meeting-replay*', (r) => json(r, replay));
80
+ await page.route('**/api/meeting-material/suggest*', (r) => { S.suggestGets.push(new URL(r.request().url()).search); json(r, SUGGEST); });
81
+ await page.route('**/api/meeting-material?*', (r) => {
82
+ const req = r.request();
83
+ if (req.method() === 'POST') {
84
+ const b = JSON.parse(req.postData() || '{}'); S.matPosts.push(b);
85
+ if (writeStatus !== 200) return json(r, { ok: false, error: 'a page press is required' }, writeStatus);
86
+ if (b.op === 'add') S.items.push(Object.assign({ id: 'n' + S.items.length, from: 'you', scope: b.scope }, b.item));
87
+ else S.items = S.items.filter((i) => (i.ref || i.url) !== (b.item.ref || b.item.url));
88
+ return json(r, { ok: true, items: S.items });
89
+ }
90
+ return json(r, { ok: true, key: 'k', items: S.items });
91
+ });
92
+ await page.route('**/api/meeting-material', (r) => {
93
+ const req = r.request(); const b = JSON.parse(req.postData() || '{}'); S.matPosts.push(b);
94
+ if (writeStatus !== 200) return json(r, { ok: false, error: 'a page press is required' }, writeStatus);
95
+ if (b.op === 'add') S.items.push(Object.assign({ id: 'n' + S.items.length, from: 'you', scope: b.scope }, b.item));
96
+ else S.items = S.items.filter((i) => (i.ref || i.url) !== (b.item.ref || b.item.url));
97
+ return json(r, { ok: true, items: S.items });
98
+ });
99
+ await page.route('**/api/plan-items*', (r) => {
100
+ const req = r.request();
101
+ if (req.method() === 'POST') { const b = JSON.parse(req.postData() || '{}'); S.planPosts.push(b); return planStatus === 200 ? json(r, { ok: true, written: [{ item: 'item-9' }] }) : json(r, { ok: false, error: 'a page press is required' }, planStatus); }
102
+ return json(r, { ok: true, stages });
103
+ });
104
+ await page.route('**/api/calendar-links', (r) => json(r, { ok: true }));
105
+ await page.goto(BASE + '/premium.html?theme=' + theme);
106
+ S.up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 && document.querySelectorAll('#tl .ev').length > 0), 20000);
107
+ await page.click('#rng [data-r=week]');
108
+ await until(() => page.evaluate(() => !document.querySelector('#tl').hasAttribute('aria-busy') && !!document.querySelector('#tl .wkd')));
109
+ await page.evaluate(() => { const r = [...document.querySelectorAll('#tl .ev')].find((e) => e.querySelector('b').textContent === 'Sprint planning'); r.id = 'rowSprint'; r.click(); });
110
+ S.dlg = await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#mmAdd') && /Roadmap|No material/.test(document.querySelector('#oMain').textContent)));
111
+ return Object.assign(S, { ctx, page });
112
+ };
113
+ const text = (p) => p.evaluate(() => document.querySelector('#oMain').textContent);
114
+
115
+ const A = await open();
116
+ ok('0 the dialog opens on a week row with Add material', A.up && A.dlg);
117
+ if (!A.up || !A.dlg) return finish(1);
118
+ const p = A.page;
119
+
120
+ /* M1 the sheet */
121
+ ok('M2 each removable row has Remove, and the row says its scope', await p.evaluate(() => { const b = document.querySelector('.mtg-rm'); return !!b && /Roadmap/.test(b.getAttribute('aria-label')) && /document itself is not changed/.test(b.title) && /for this meeting/.test(b.closest('li').textContent); }));
122
+ await p.click('#mmAdd');
123
+ const sheet = await until(() => p.evaluate(() => { const s = document.querySelector('.mtg-sheet'); return s && /Premium UX PRD/.test(s.textContent) ? s.textContent : null; }));
124
+ ok('M1 the sheet opens in the dialog with Suggested, Find in PMOS and Or paste a link', sheet && /Suggested for this meeting/.test(sheet) && /Find in PMOS/.test(sheet) && /Or paste a link/.test(sheet), String(sheet).slice(0, 200));
125
+ ok('M1 the sheet says the invite is not changed, and focus is on Back', sheet && /invite in your calendar is not changed/.test(sheet) && await p.evaluate(() => document.activeElement && document.activeElement.id === 'mmBack'));
126
+ ok('M1 Suggested asked for the workspace-free level query of this meeting', A.suggestGets.length >= 1 && !/q=/.test(A.suggestGets[0]), JSON.stringify(A.suggestGets));
127
+ await p.fill('#mmFind', 'q3');
128
+ const found = await until(() => p.evaluate(() => /Q3 report/.test(document.querySelector('#mmFound').textContent)));
129
+ ok('M1 Find in PMOS shows what the search returned, and nothing for one letter', found && A.suggestGets.some((q) => /q=q3/.test(q)));
130
+ await p.fill('#mmFind', 'q');
131
+ ok('M1 a one-letter search shows nothing', await until(() => p.evaluate(() => document.querySelector('#mmFound').textContent === '')));
132
+ await p.fill('#mmLinkIn', 'not a link');
133
+ ok('M1 an address that is not https says so and cannot be picked', await p.evaluate(() => /Paste an https address/.test(document.querySelector('#mmPaste').textContent) && !document.querySelector('#mmPaste [data-pick]')));
134
+ ok('M1 no Add button shows before something is picked', await p.evaluate(() => !document.querySelector('#mmDo')));
135
+ await p.click('#mmSug [data-pick]');
136
+ const opt = await p.evaluate(() => ({ line: document.querySelector('#mmLine').textContent, pressed: [...document.querySelectorAll('[data-scope]')].map((b) => b.dataset.scope + ':' + b.getAttribute('aria-pressed')).join(), picked: document.querySelector('#mmSug .mtg-on') && document.querySelector('#mmSug .mtg-on').textContent }));
137
+ ok('M3 picking says what Add records, before the press', /Adds “Premium UX PRD” to this meeting\. The calendar is not written\./.test(opt.line) && opt.picked === 'Picked' && /meeting:true,series:false/.test(opt.pressed), JSON.stringify(opt));
138
+ await p.click('[data-scope=series]');
139
+ ok('M3 the line follows the scope', await p.evaluate(() => /to every meeting in the series\./.test(document.querySelector('#mmLine').textContent)));
140
+ await p.click('#mmCancel');
141
+ ok('M1 Cancel returns to the meeting and focus returns to Add material', await p.evaluate(() => !document.querySelector('.mtg-sheet') && document.activeElement && document.activeElement.id === 'mmAdd') && A.matPosts.length === 0);
142
+
143
+ /* M1 add */
144
+ await p.click('#mmAdd'); await until(() => p.evaluate(() => /Premium UX PRD/.test(document.querySelector('#mmSug').textContent)));
145
+ await p.click('#mmSug [data-pick]'); await p.click('[data-scope=series]'); await p.click('#mmDo');
146
+ await until(() => A.matPosts.length === 1);
147
+ ok('M1 Add posts one line to /api/meeting-material for the series', A.matPosts.length === 1 && A.matPosts[0].op === 'add' && A.matPosts[0].scope === 'series' && A.matPosts[0].item.ref === 'planning/prd/premium-ux-prd.md' && A.matPosts[0].event.series === 'sprint-planning' && A.matPosts[0].event.id === 'ev-sprint', JSON.stringify(A.matPosts));
148
+ const after = await until(() => p.evaluate(() => /Premium UX PRD/.test(document.querySelector('#oMain').textContent) && !document.querySelector('.mtg-sheet') ? { text: document.querySelector('#oMain').textContent, focus: document.activeElement && document.activeElement.id } : null));
149
+ ok('M3 the list is read again from the route and shows the new row, and the status says what was added', after && /Premium UX PRD/.test(after.text) && /for every meeting of this series/.test(after.text) && /Added “Premium UX PRD” to every meeting in the series\./.test(after.text) && after.focus === 'mmAdd', JSON.stringify(after));
150
+
151
+ /* M2 remove and undo */
152
+ const nRm = A.matPosts.length;
153
+ await p.click('.mtg-rm[aria-label="Remove Roadmap"]');
154
+ await until(() => A.matPosts.length === nRm + 1);
155
+ const rm = A.matPosts[nRm];
156
+ ok('M2 Remove posts the url at the scope the row was added', rm.op === 'remove' && rm.scope === 'meeting' && rm.item.url === 'https://x.example/road', JSON.stringify(rm));
157
+ const gone = await until(() => p.evaluate(() => /Removed “Roadmap” from this meeting\. The document itself is not changed\./.test(document.querySelector('#mtgStatus').textContent) && !/for this meeting.*Roadmap/.test(document.querySelector('#oMain').textContent) && !!document.querySelector('#mtgUndo')));
158
+ ok('M2 the row leaves after the list is read again, and the status offers Undo', gone);
159
+ await p.click('#mtgUndo');
160
+ await until(() => A.matPosts.length === nRm + 2);
161
+ ok('M2 Undo adds the same item back at the same scope', A.matPosts[nRm + 1].op === 'add' && A.matPosts[nRm + 1].scope === 'meeting' && A.matPosts[nRm + 1].item.url === 'https://x.example/road', JSON.stringify(A.matPosts[nRm + 1]));
162
+ ok('M2 the row is back and the status says so', await until(() => p.evaluate(() => /Put back\./.test(document.querySelector('#mtgStatus').textContent) && /Roadmap/.test(document.querySelector('#oMain').textContent))));
163
+ ok('M6 nothing else was written by the material work', A.planPosts.length === 0 && ![...A.reqs].some((r) => /\/api\/(notes|meeting-focus|calendar-links)/.test(r)));
164
+ ok('M6 no page error so far', A.errors.length === 0, JSON.stringify(A.errors));
165
+
166
+ /* M5 refusals */
167
+ const D = await open({ writeStatus: 403 });
168
+ await D.page.click('.mtg-rm');
169
+ const refused = await until(() => D.page.evaluate(() => /The material was not removed: a page press is required/.test(document.querySelector('#mtgStatus').textContent) && /Roadmap/.test(document.querySelector('#oMain').textContent)));
170
+ ok('M5 a refused Remove shows the reason and the row stays', refused && D.items.length === 1);
171
+ await D.page.click('#mmAdd'); await until(() => D.page.evaluate(() => /Premium UX PRD/.test(document.querySelector('#mmSug').textContent)));
172
+ await D.page.fill('#mmLinkIn', 'https://typed.example/page');
173
+ await D.page.click('#mmDo');
174
+ const refAdd = await until(() => D.page.evaluate(() => /The material was not saved: a page press is required/.test(document.querySelector('#mmLine').textContent) ? { still: !!document.querySelector('.mtg-sheet'), typed: document.querySelector('#mmLinkIn').value, again: !document.querySelector('#mmDo').disabled } : null));
175
+ ok('M5 a refused Add shows the reason, keeps the sheet and what was typed, and can be pressed again', refAdd && refAdd.still && refAdd.typed === 'https://typed.example/page' && refAdd.again, JSON.stringify(refAdd));
176
+ ok('M5 the refused writes changed nothing in the list', D.items.length === 1);
177
+
178
+ /* M4 make task */
179
+ const N = await open();
180
+ const steps = await text(N.page);
181
+ ok('M4 the next step has Make task, and decisions and questions have none', /Make task/.test(steps) && await N.page.evaluate(() => document.querySelectorAll('.mtg-task').length === 1));
182
+ await N.page.click('.mtg-task');
183
+ await until(() => N.planPosts.length === 1);
184
+ const pp = N.planPosts[0];
185
+ ok('M4 Make task posts one planned event in the first stage with the owner and due', pp.ws === 'w1' && pp.events.length === 1 && pp.events[0].ev === 'planned' && pp.events[0].initiative === 'premium-ux' && pp.events[0].stage === 'st1' && pp.events[0].title === 'Sam confirms the data fix owner' && pp.events[0].owner === 'person:Sam', JSON.stringify(pp));
186
+ const made = await until(() => N.page.evaluate(() => /Added to Premium UX, under Intake\./.test(document.querySelector('#mtgStatus').textContent) && document.querySelector('.mtg-task').textContent === 'Task made' && document.querySelector('.mtg-task').disabled ? true : null));
187
+ ok('M4 the step says Task made and the status says where it went', made);
188
+ await N.page.click('#mtgUndo');
189
+ await until(() => N.planPosts.length === 2);
190
+ ok('M4 Undo withdraws the item', N.planPosts[1].events[0].ev === 'withdrawn' && N.planPosts[1].events[0].item === 'item-9' && N.planPosts[1].events[0].initiative === 'premium-ux', JSON.stringify(N.planPosts[1]));
191
+ ok('M4 after Undo the step can be made a task again', await until(() => N.page.evaluate(() => document.querySelector('.mtg-task').textContent === 'Make task' && !document.querySelector('.mtg-task').disabled)));
192
+ const NI = await open({ replay: REPLAY_NOINI });
193
+ await NI.page.click('.mtg-task');
194
+ ok('M4 with no initiative the button says to link one and writes nothing', await until(() => NI.page.evaluate(() => /Link the note to an initiative first/.test(document.querySelector('#mtgStatus').textContent))) && NI.planPosts.length === 0);
195
+ const NS = await open({ stages: [] });
196
+ await NS.page.click('.mtg-task');
197
+ ok('M4 an initiative with no stage says so and writes nothing', await until(() => NS.page.evaluate(() => /The task was not made: The initiative has no stage/.test(document.querySelector('#mtgStatus').textContent))) && NS.planPosts.length === 0);
198
+ const NR = await open({ planStatus: 403 });
199
+ await NR.page.click('.mtg-task');
200
+ ok('M5 a refused Make task shows the reason and the step stays open', await until(() => NR.page.evaluate(() => /The task was not made: a page press is required/.test(document.querySelector('#mtgStatus').textContent) && document.querySelector('.mtg-task').textContent === 'Make task' && !document.querySelector('.mtg-task').disabled)));
201
+
202
+ /* M6 the allow-list */
203
+ const all = [].concat(A.reqs, D.reqs, N.reqs, NI.reqs, NS.reqs, NR.reqs);
204
+ const posts = [...new Set(all.filter((r) => /^POST /.test(r)))].sort();
205
+ ok('M6 the only writes the page sent are the material and the plan items', posts.join() === 'POST /api/meeting-material,POST /api/plan-items', posts.join());
206
+ ok('M6 no recording, Focus, note or calendar write was sent', !all.some((r) => /\/api\/(notes|meeting-focus)|POST \/api\/calendar/.test(r)));
207
+ ok('M6 no page error', [A, D, N, NI, NS, NR].every((x) => x.errors.length === 0), JSON.stringify([A, D, N, NI, NS, NR].map((x) => x.errors)));
208
+
209
+ /* M7 floors and fidelity */
210
+ for (const th of ['light', 'dark']) {
211
+ const P = await open({ w: 390, h: 844, theme: th });
212
+ const f1 = await P.page.evaluate(() => ({ scroll: document.documentElement.scrollWidth <= innerWidth + 1, btn: [...document.querySelectorAll('#mmAdd,.mtg-rm,.mtg-task')].map((b) => Math.min(b.getBoundingClientRect().width, b.getBoundingClientRect().height)) }));
213
+ await P.page.click('#mmAdd'); await until(() => P.page.evaluate(() => /Premium UX PRD/.test(document.querySelector('#mmSug').textContent)));
214
+ await P.page.click('#mmSug [data-pick]');
215
+ const f2 = await P.page.evaluate(() => ({ scroll: document.documentElement.scrollWidth <= innerWidth + 1 && document.querySelector('#oMain').scrollWidth <= document.querySelector('#oMain').clientWidth + 1, btn: [...document.querySelectorAll('#mmBack,#mmDo,#mmCancel,[data-scope],[data-pick],.mtg-in')].map((b) => Math.min(b.getBoundingClientRect().width, b.getBoundingClientRect().height)) }));
216
+ ok(`M7 at 390 px (${th}) the dialog and the sheet have no sideways scroll and every press is at least 44 px`, f1.scroll && f2.scroll && f1.btn.every((n) => n >= 44) && f2.btn.every((n) => n >= 44), JSON.stringify([f1, f2]));
217
+ await P.ctx.close();
218
+ }
219
+ const css = (page, sel) => page.evaluate((s) => { const e = document.querySelector(s); if (!e) return null; const c = getComputedStyle(e); return ['fontWeight', 'borderRadius'].map((k) => c[k]).join('|'); }, sel);
220
+ const mk = await browser.newContext({ viewport: { width: 1280, height: 900 } }); const mp = await mk.newPage();
221
+ await mp.setContent(MOCKUP); await mp.waitForTimeout(500);
222
+ const ctaM = await mp.evaluate(() => { const b = document.createElement('button'); b.className = 'cta'; document.body.appendChild(b); const c = getComputedStyle(b); return c.fontWeight + '|' + c.borderRadius; }), F1 = await open(), addB = await css(F1.page, '#mmAdd');
223
+ await F1.page.click('#mmAdd'); await until(() => F1.page.evaluate(() => /Premium UX PRD/.test(document.querySelector('#mmSug').textContent))); await F1.page.click('#mmSug [data-pick]');
224
+ const doB = await css(F1.page, '#mmDo');
225
+ ok('M7 fidelity: the buttons keep the mockup\'s pill radius and weight', ctaM && addB && addB === ctaM && doB === ctaM, ctaM + ' vs ' + addB + ' / ' + doB);
226
+ const labM = await mp.evaluate(() => { const e = document.querySelector('.label'); return e ? getComputedStyle(e).fontSize + '|' + getComputedStyle(e).textTransform : null; });
227
+ const labP = await F1.page.evaluate(() => { const e = document.querySelector('.mtg-sec .label'); return e ? getComputedStyle(e).fontSize + '|' + getComputedStyle(e).textTransform : null; });
228
+ ok('M7 fidelity: a sheet section label uses the mockup\'s label type', labM && labP && labM === labP, labM + ' vs ' + labP);
229
+ await mk.close();
230
+ return finish();
231
+ })().catch((e) => { console.error(e); finish(1); });
@@ -90,7 +90,11 @@ The Today card has a **Today / This week** switch. **This week** lists the meeti
90
90
 
91
91
  Press a meeting, from Today or from the week, to open the meeting dialog. It shows the time, the people, and what the meeting is about. It also shows the notes (decisions, next steps and open questions), the material, and, when a recording was kept, its length and the key points. Each part appears only when a record holds it.
92
92
 
93
- When the meeting is not linked, the dialog has a **Link it** press. You choose the portfolio, a board, an initiative or none. The press writes one calendar link, through a check that only a real press from this page can pass, so an agent session is refused. After the write, the page reads the week again. Adding or removing material, routing next steps, recording and Focus stay in the console for now.
93
+ When the meeting is not linked, the dialog has a **Link it** press. You choose the portfolio, a board, an initiative or none. The press writes one calendar link, through a check that only a real press from this page can pass, so an agent session is refused. After the write, the page reads the week again. The **Material** part has **Add material** and a **Remove** on each row. Add material opens a sheet in the dialog with three ways to pick: **Suggested** (the documents of the meeting's initiative and the newest report cycles), **Find in PMOS** (type two letters or more) and **Paste a link** (an https address). A **For** choice says whether the material belongs to this meeting or to every meeting in the series. Before you press Add, the sheet says what it records: one line in PMOS's own record of the meeting. The calendar invite is never changed. After a write, the list is read again from the record. Remove names its scope and says the document itself is not changed. A few seconds of **Undo** put a removed item back.
94
+
95
+ In **Notes**, each next step has **Make task** when the note is linked to an initiative. It adds the step to the first stage of that initiative's breakdown, with its owner and due day when the step names them, and the status says where it went. **Undo** withdraws the task. A note with no initiative explains that it must be linked first, and writes nothing. Both writes need the page's launch nonce, so an agent session is refused. A refused write shows its reason and changes nothing on screen.
96
+
97
+ Recording and Focus stay in the console for now.
94
98
 
95
99
  ## The dock
96
100
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.266.0",
3
+ "version": "0.267.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.266.0",
9
+ "version": "0.267.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.266.0",
3
+ "version": "0.267.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -1,7 +1,8 @@
1
- /* pm/premium-meeting.js — Calendar in the premium Briefing's Today card (initiative briefing-premium-calendar, slice 1).
2
- * The Today / This week switch, the week list and the meeting dialog. Reads GET /api/calendar-views?view=week, GET /api/meeting-replay and GET /api/meeting-material.
3
- * The one write is "Link it", through POST /api/calendar-links. Every word is a field of a record: the pure half (weekView, meetingView) takes the routes' answers and
4
- * returns what the page draws, so a test reads it without a DOM. Recording, Focus and material changes are later slices. */
1
+ /* pm/premium-meeting.js — Calendar in the premium Briefing's Today card (initiative briefing-premium-calendar, slices 1 and 2).
2
+ * The Today / This week switch, the week list and the meeting dialog. Reads GET /api/calendar-views?view=week, GET /api/meeting-replay, GET /api/meeting-material and
3
+ * GET /api/meeting-material/suggest. The writes are "Link it" (POST /api/calendar-links), Add and Remove material (POST /api/meeting-material) and Make task
4
+ * (POST /api/plan-items). Every word is a field of a record: the pure half (weekView, meetingView, the body builders) takes the routes' answers and returns what the page
5
+ * draws or sends, so a test reads it without a DOM. Recording and Focus are slice 3. */
5
6
 
6
7
  const pad = (n) => String(n).padStart(2, '0');
7
8
  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; };
@@ -46,15 +47,16 @@ export function meetingView(row, replay, material) {
46
47
  const rep = replay && replay.state === 'ok' ? replay.body : null;
47
48
  const people = row.who && row.who.length ? row.who : (rep && rep.meeting && Array.isArray(rep.meeting.attendees) ? rep.meeting.attendees : []);
48
49
  const keys = rep && Array.isArray(rep.keys) ? rep.keys : [];
49
- const pick = (k) => keys.filter((x) => x.k === k).map((x) => ({ text: clip(x.text, 240), owner: x.owner || '', due: x.due || '', open: x.state === 'open' || x.state === 'owner' }));
50
- const notes = rep ? { title: clip((rep.note && rep.note.title) || '', 120), decisions: pick('decision'), actions: pick('action'), questions: pick('question') } : null;
50
+ const pick = (k) => keys.filter((x) => x.k === k).map((x) => ({ id: x.id == null ? '' : String(x.id), text: clip(x.text, 240), owner: x.owner || '', due: x.due || '', open: x.state === 'open' || x.state === 'owner' }));
51
+ const ini = rep && rep.note && rep.note.initiative && rep.note.initiative.id ? rep.note.initiative : null, nws = rep && rep.note ? (ini && ini.ws) || rep.note.ws || '' : '';
52
+ const notes = rep ? { title: clip((rep.note && rep.note.title) || '', 120), id: (rep.note && rep.note.id) || '', initiative: ini ? { id: ini.id, name: clip(ini.title || ini.name || ini.id, 70), ws: nws } : null, decisions: pick('decision'), actions: pick('action'), questions: pick('question') } : null;
51
53
  const heard = rep && Number(rep.length_ms) > 0 ? Math.round(rep.length_ms / 60000) : 0;
52
54
  return {
53
55
  people,
54
56
  notes, notesState: replay ? replay.state : 'none',
55
57
  notesLine: !replay ? 'Reading the notes.' : replay.state === 'error' ? 'The notes could not be read: ' + clip(replay.error, 120) : replay.state === 'none' ? 'No notes for this meeting.' : '',
56
58
  replay: rep && (rep.audio || heard) ? { minutes: heard, keyPoints: keys.length, lines: Array.isArray(rep.lines) ? rep.lines.length : 0 } : null,
57
- material: material && material.state === 'ok' ? (material.items || []).map((i) => ({ title: clip(i.title || i.ref || i.url, 120), kind: i.kind || '', scope: i.scope === 'series' ? 'every meeting of this series' : 'this meeting' })) : null,
59
+ material: material && material.state === 'ok' ? (material.items || []).map((i, n) => ({ n, title: clip(i.title || i.ref || i.url, 120), kind: i.kind || '', scope: i.scope === 'series' ? 'every meeting of this series' : 'this meeting', removable: i.from === 'you' && (i.scope === 'series' || i.scope === 'meeting'), line: removeLine(i) })) : null,
58
60
  materialLine: !material ? 'Reading the material.' : material.state === 'error' ? 'The material could not be read: ' + clip(material.error, 120) : (material.items || []).length ? '' : 'No material is linked to this meeting.',
59
61
  row,
60
62
  };
@@ -70,6 +72,53 @@ export function linkBody(row, choice, boards) {
70
72
  return null;
71
73
  }
72
74
 
75
+ /** The event the material routes key on: id, title and the series, as the calendar answer holds them. */
76
+ const eventOf = (row) => ({ id: row.id || undefined, title: row.title, ...(row.series ? { series: row.series } : {}) });
77
+ const isPmos = (k) => k === 'pmos-deck' || k === 'pmos-doc' || k === 'report';
78
+ const scopeText = (scope) => (scope === 'series' ? 'every meeting in the series' : 'this meeting');
79
+
80
+ /** A pasted address as the sheet shows it: an https address with a dot in its host. The server decides what kind it is when it saves. null for anything else. */
81
+ export function pasteOf(raw) {
82
+ const t = String(raw || '').trim();
83
+ if (!t || /\s/.test(t)) return null;
84
+ let u; try { u = new URL(/^[a-z][a-z0-9+.-]*:/i.test(t) ? t : 'https://' + t); } catch { return null; }
85
+ if (u.protocol !== 'https:' || !u.hostname.includes('.')) return null;
86
+ return { kind: 'link', url: u.href, title: u.hostname, meta: 'opens in a new tab · PMOS does not read it' };
87
+ }
88
+ /** The initiative whose documents the sheet suggests: the meeting's own level, when that is an initiative. */
89
+ export const levelInitiative = (row) => (row && row.level && row.level.kind === 'initiative' && row.level.id ? String(row.level.id) : '');
90
+ /** The query of GET /api/meeting-material/suggest. Suggested uses the level; Find in PMOS uses q (two letters or more). */
91
+ export function suggestQuery(row, { q, ws } = {}) {
92
+ const p = new URLSearchParams();
93
+ if (ws) p.set('ws', ws);
94
+ if (q) p.set('q', q); else if (levelInitiative(row)) p.set('initiative', levelInitiative(row));
95
+ return p.toString();
96
+ }
97
+ /** The body of POST /api/meeting-material for a pick made in the sheet. */
98
+ export function addBody(row, pick, scope) {
99
+ if (!pick || !(pick.url || pick.ref)) return null;
100
+ const item = isPmos(pick.kind) ? { kind: pick.kind, ref: pick.ref, title: pick.title, ...(pick.ws ? { ws: pick.ws } : {}) } : { url: pick.url, title: pick.title };
101
+ return { op: 'add', event: eventOf(row), scope: scope === 'series' ? 'series' : 'meeting', item };
102
+ }
103
+ /** The body of POST /api/meeting-material for a row of the list (a row the route returned). */
104
+ export function removeBody(row, item) {
105
+ if (!item || item.from !== 'you' || !['meeting', 'series'].includes(item.scope)) return null;
106
+ return { op: 'remove', event: eventOf(row), scope: item.scope, item: isPmos(item.kind) ? { kind: item.kind, ref: item.ref, ...(item.ws ? { ws: item.ws } : {}) } : { url: item.url } };
107
+ }
108
+ /** What a press records, said before the press (and after it, as the toast). */
109
+ export const addLine = (pick, scope) => `Adds “${clip(pick && pick.title, 80)}” to ${scopeText(scope)}. The calendar is not written.`;
110
+ export const removeLine = (item) => `Removes “${clip(item && item.title, 80)}” from ${scopeText(item && item.scope)}. The document itself is not changed.`;
111
+
112
+ /** Make task for a next step of the meeting's note: the planned event of the note's initiative, or the reason there is none. `stage` is the first stage of its breakdown. */
113
+ export function taskEvent(note, step, stage) {
114
+ if (!note || !note.initiative || !note.initiative.id || !note.initiative.ws) return { ok: false, reason: 'Link the note to an initiative first. Make task adds the step to its breakdown.' };
115
+ if (!stage || !stage.id) return { ok: false, reason: 'The initiative has no stage to put the step in.' };
116
+ const ev = { ev: 'planned', initiative: note.initiative.id, title: String(step.text || '').slice(0, 200), stage: stage.id, note: 'From the meeting note "' + (note.title || 'Untitled note') + '"' };
117
+ if (step.owner) ev.owner = /^(you|me)$/i.test(step.owner) ? 'you' : 'person:' + String(step.owner).slice(0, 60);
118
+ if (step.due && /^\d{4}-\d{2}-\d{2}$/.test(step.due)) ev.due = step.due;
119
+ return { ok: true, ws: note.initiative.ws, event: ev };
120
+ }
121
+
73
122
  /* ── the page half ─────────────────────────────────────────────────────────────────────────────────────── */
74
123
 
75
124
  /** deps: { $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, wsq(), ws() }. Returns { mode, draw, openToday }. */
@@ -110,8 +159,10 @@ export function mountMeeting(d) {
110
159
 
111
160
  /* the dialog */
112
161
  const sec = (label, body) => `<div class="mtg-sec"><span class="label">${esc(label)}</span>${body}</div>`;
113
- const items = (L) => `<ul class="mtg-l">${L.map((x) => `<li>${esc(x.text)}${x.owner || x.due ? `<em>${esc([x.owner, x.due].filter(Boolean).join(' · '))}</em>` : ''}</li>`).join('')}</ul>`;
114
- function paneHtml(v, boards, inis, saved) {
162
+ const items = (L, task) => `<ul class="mtg-l">${L.map((x, i) => `<li>${esc(x.text)}${x.owner || x.due ? `<em>${esc([x.owner, x.due].filter(Boolean).join(' · '))}</em>` : ''}${task ? `<button class="mtg-b mtg-task" data-task="${i}"${task.done.has(i) ? ' disabled' : ''}>${task.done.has(i) ? 'Task made' : 'Make task'}</button>` : ''}</li>`).join('')}</ul>`;
163
+ const pickLi = (it, key, on) => `<li class="mtg-pick"><span>${esc(clip(it.title, 120))}<em>${esc([it.kind, it.meta].filter(Boolean).join(' · '))}</em></span>${on ? '<span class="mtg-on">Picked</span>' : `<button class="mtg-b" data-pick="${esc(key)}">Pick</button>`}</li>`;
164
+
165
+ function detailHtml(v, boards, inis, saved, ui) {
115
166
  const r = v.row, lv = r.level;
116
167
  const aboutNow = lv ? aboutOf(lv) : saved || '';
117
168
  const opts = [['', aboutNow ? 'Change what it is about' : 'Choose what it is about'], ['portfolio', 'Portfolio']].concat(boards.map((b) => ['board|' + b.ws + '|' + b.id, 'Board: ' + b.name]), inis.map((i) => ['initiative|' + i.id, 'Initiative: ' + i.name]), [['none', 'Remove the link']]);
@@ -119,38 +170,125 @@ export function mountMeeting(d) {
119
170
  <div class="mtg-link"><select id="mtgSel" aria-label="What this meeting is about">${opts.map(([val, t]) => `<option value="${esc(val)}">${esc(t)}</option>`).join('')}</select><button class="cta" id="mtgLink" disabled>Link it</button></div>
120
171
  <p class="note" id="mtgMsg" role="status">The link applies to every occurrence of “${esc(r.title)}”. The calendar itself is never written.</p>`;
121
172
  const n = v.notes;
173
+ const task = n && n.actions.length ? { done: ui.tasked } : null;
122
174
  const notes = v.notesLine ? `<p class="note">${esc(v.notesLine)}</p>` : [n.title ? `<p><b>${esc(n.title)}</b></p>` : '',
123
- n.decisions.length ? `<h4 class="mtg-h">Decisions ${n.decisions.length}</h4>${items(n.decisions)}` : '', n.actions.length ? `<h4 class="mtg-h">Next steps ${n.actions.length}</h4>${items(n.actions)}` : '',
175
+ n.decisions.length ? `<h4 class="mtg-h">Decisions ${n.decisions.length}</h4>${items(n.decisions)}` : '', n.actions.length ? `<h4 class="mtg-h">Next steps ${n.actions.length}</h4>${items(n.actions, task)}` : '',
124
176
  n.questions.length ? `<h4 class="mtg-h">Open questions ${n.questions.length}</h4>${items(n.questions)}` : '', (n.decisions.length + n.actions.length + n.questions.length) ? '' : '<p class="note">The note holds no decisions, next steps or questions yet.</p>'].join('');
125
- const mat = v.materialLine ? `<p class="note">${esc(v.materialLine)}</p>` : `<ul class="mtg-l">${v.material.map((m) => `<li>${esc(m.title)}<em>${esc([m.kind, 'for ' + m.scope].filter(Boolean).join(' · '))}</em></li>`).join('')}</ul>`;
177
+ const mat = (v.materialLine ? `<p class="note">${esc(v.materialLine)}</p>` : `<ul class="mtg-l">${v.material.map((m) => `<li>${esc(m.title)}<em>${esc([m.kind, 'for ' + m.scope].filter(Boolean).join(' · '))}</em>${m.removable ? `<button class="mtg-b mtg-rm" data-rm="${m.n}" aria-label="Remove ${esc(m.title)}" title="${esc(m.line)}">Remove</button>` : ''}</li>`).join('')}</ul>`)
178
+ + `<div class="mtg-foot"><button class="mtg-b" id="mmAdd">Add material</button><span class="note">Your calendar invite is not changed.</span></div>`;
126
179
  const rep = v.replay ? `<p>A recording is kept: ${v.replay.minutes ? v.replay.minutes + ' min, ' : ''}${v.replay.keyPoints} key ${v.replay.keyPoints === 1 ? 'point' : 'points'}.</p><p class="note">Replay opens in the console for now.</p>` : '';
127
- return `<article class="paper doc mtg">${d.kv([['When', r.day + ' · ' + r.time + (r.len ? ' · ' + r.len : '')], ['People', v.people.join(', ') || 'The calendar lists no other people.']])}${sec('What it is about', about)}${sec('Notes', notes)}${sec('Material', mat)}${rep ? sec('Replay', rep) : ''}</article>`;
180
+ const status = ui.status ? `<p class="note mtg-status" id="mtgStatus" role="status">${esc(ui.status.text)}${ui.status.undo ? ' <button class="mtg-b" id="mtgUndo">Undo</button>' : ''}</p>` : '<p class="note mtg-status" id="mtgStatus" role="status" hidden></p>';
181
+ return `<article class="paper doc mtg">${status}${d.kv([['When', r.day + ' · ' + r.time + (r.len ? ' · ' + r.len : '')], ['People', v.people.join(', ') || 'The calendar lists no other people.']])}${sec('What it is about', about)}${sec('Notes', notes)}${sec('Material', mat)}${rep ? sec('Replay', rep) : ''}</article>`;
182
+ }
183
+ function sheetHtml(row) {
184
+ return `<article class="paper doc mtg mtg-sheet"><button class="mtg-b" id="mmBack">Back to the meeting</button>
185
+ <p class="note">${esc(row.title)} · ${esc(row.day)} ${esc(row.time)}. PMOS keeps the link on its record of this meeting. The invite in your calendar is not changed.</p>
186
+ ${sec('Suggested for this meeting', '<div id="mmSug"></div>')}${sec('Find in PMOS', '<input class="mtg-in" id="mmFind" type="search" placeholder="A document, report or deck" aria-label="Find a document, report or deck in PMOS" autocomplete="off"><div id="mmFound"></div>')}
187
+ ${sec('Or paste a link', '<input class="mtg-in" id="mmLinkIn" type="url" placeholder="Any https address" aria-label="Paste a link" autocomplete="off"><div id="mmPaste"></div>')}<div id="mmOpts"></div></article>`;
128
188
  }
129
189
 
130
190
  async function openRow(row, via) {
131
191
  let replay = null, material = null, boards = W ? W.boards : [], inis = W ? W.initiatives : [], saved = '';
132
- const paint = () => { $('#oMain').innerHTML = paneHtml(meetingView(row, replay, material), boards, inis, saved); };
192
+ const ui = { view: 'detail', status: null, tasked: new Set() }, SH = { sug: null, found: [], pick: null, scope: 'meeting', q: '', link: '', token: 0 };
193
+ let stT = null, findT = null, undoFn = null;
194
+ const view = () => meetingView(row, replay, material);
195
+ const say = (text, undo) => { clearTimeout(stT); undoFn = undo || null; ui.status = { text, undo: undo || null }; if (ui.view === 'detail') { paint(); stT = setTimeout(() => { ui.status = null; if (ui.view === 'detail') paint(); }, 9000); } else d.toast(text); };
196
+ const paint = () => { $('#oMain').innerHTML = ui.view === 'add' ? sheetHtml(row) : detailHtml(view(), boards, inis, saved, ui); if (ui.view === 'add') paintSheet(); };
197
+ function paintSheet() {
198
+ const list = (L, k) => (L.length ? `<ul class="mtg-l">${L.map((it, i) => pickLi(it, k + ':' + i, SH.pick && (SH.pick.ref || SH.pick.url) === (it.ref || it.url) && SH.pick.kind === it.kind)).join('')}</ul>` : '');
199
+ const q = $('#mmSug'); if (!q) return;
200
+ q.innerHTML = SH.sug == null ? '<p class="note">Looking in PMOS.</p>' : SH.sug.length ? list(SH.sug, 'sug') : '<p class="note">Nothing to suggest yet. Search below, or paste a link.</p>';
201
+ $('#mmFound').innerHTML = SH.q.length >= 2 ? (SH.foundBusy ? '<p class="note">Searching.</p>' : SH.found.length ? list(SH.found, 'found') : '<p class="note">Nothing in PMOS matches that.</p>') : '';
202
+ const pst = pasteOf(SH.link);
203
+ $('#mmPaste').innerHTML = pst ? list([pst], 'paste') : `<p class="note">${SH.link ? 'Paste an https address.' : 'A web page opens in a new tab and PMOS does not read it.'}</p>`;
204
+ const k = SH.pick;
205
+ $('#mmOpts').innerHTML = k ? `<div class="mtg-sec"><span class="label">For</span><div class="seg2" role="group" aria-label="For"><button class="mtg-b" data-scope="meeting" aria-pressed="${SH.scope === 'meeting'}">This meeting</button><button class="mtg-b" data-scope="series" aria-pressed="${SH.scope === 'series'}">${row.series ? 'Every meeting in the series' : 'Every meeting with this title'}</button></div>
206
+ <p class="note" id="mmLine">${esc(addLine(k, SH.scope))}</p><div class="mtg-foot"><button class="cta" id="mmDo">Add to the meeting</button><button class="mtg-b" id="mmCancel">Cancel</button></div></div>` : '';
207
+ }
208
+ async function reload() {
209
+ const mt = await d.pmGet(matPath());
210
+ material = mt && mt.ok === true ? { state: 'ok', items: mt.items || [] } : { state: 'error', error: (mt && mt.error) || 'no answer' };
211
+ }
212
+ const matPath = () => '/api/meeting-material?event=' + encodeURIComponent(row.id) + '&title=' + encodeURIComponent(row.title) + (row.series ? '&series=' + encodeURIComponent(row.series) : '') + '&date=' + row.day;
133
213
  d.openDlg({ eye: 'Calendar · real data', title: row.title, sub: [row.day, row.time, row.len].filter(Boolean).join(' · '), noteKey: via === 'today' ? 'ev:meeting:' + Date.parse(row.at) : null,
134
- stream: d.turnA(d.ptx('This meeting is in the calendar PMOS holds. Its notes, material and recording appear here only if PMOS holds them.')), pane: paneHtml(meetingView(row, null, null), boards, inis, ''), label: 'Meeting' });
214
+ stream: d.turnA(d.ptx('This meeting is in the calendar PMOS holds. Its notes, material and recording appear here only if PMOS holds them.')), pane: detailHtml(meetingView(row, null, null), boards, inis, '', ui), label: 'Meeting' });
135
215
  if (via !== 'today') $('#askF').hidden = true;
136
- const [rp, mt] = await Promise.all([d.pmGet('/api/meeting-replay?event=' + encodeURIComponent(row.id) + '&date=' + row.day), d.pmGet('/api/meeting-material?event=' + encodeURIComponent(row.id) + '&title=' + encodeURIComponent(row.title) + (row.series ? '&series=' + encodeURIComponent(row.series) : '') + '&date=' + row.day)]);
216
+ const [rp, mt] = await Promise.all([d.pmGet('/api/meeting-replay?event=' + encodeURIComponent(row.id) + '&date=' + row.day), d.pmGet(matPath())]);
137
217
  if ($('#dTitle').textContent !== row.title) return;
138
218
  replay = rp && rp.ok === true ? { state: 'ok', body: rp } : rp && rp.status === 404 ? { state: 'none' } : { state: 'error', error: (rp && rp.error) || 'no answer' };
139
219
  material = mt && mt.ok === true ? { state: 'ok', items: mt.items || [] } : { state: 'error', error: (mt && mt.error) || 'no answer' };
140
220
  paint();
141
- const sel = () => $('#mtgSel');
221
+
222
+ const write = async (body) => { const res = await d.pmPost('/api/meeting-material', body); return res && res.ok === true ? res : { ok: false, error: (res && res.error) || 'The material was not saved.' }; };
223
+ async function removeItem(item) {
224
+ const body = removeBody(row, item); if (!body) return;
225
+ const res = await write(body);
226
+ if (!res.ok) return say('The material was not removed: ' + res.error);
227
+ await reload();
228
+ say('Removed “' + clip(item.title, 80) + '” from ' + scopeText(item.scope) + '. The document itself is not changed.', async () => { const back = await write({ ...addBody(row, item, item.scope), ...(item.topic ? { topic: item.topic } : {}), present: !!item.present }); await reload(); say(back.ok ? 'Put back.' : 'It was not put back: ' + back.error); });
229
+ }
230
+ async function makeTask(i) {
231
+ const n = view().notes, step = n && n.actions[i]; if (!step) return;
232
+ if (!n.initiative) return say(taskEvent(n, step, null).reason);
233
+ const lay = await d.pmGet('/api/plan-items?ladder=0&ws=' + encodeURIComponent(n.initiative.ws) + '&id=' + encodeURIComponent(n.initiative.id));
234
+ const plan = taskEvent(n, step, lay && lay.ok && (lay.stages || [])[0]);
235
+ if (!plan.ok) return say('The task was not made: ' + plan.reason);
236
+ const res = await d.pmPost('/api/plan-items', { ws: plan.ws, events: [plan.event] });
237
+ if (!res || res.ok !== true) return say('The task was not made' + (res && res.error ? ': ' + res.error : '.'));
238
+ ui.tasked.add(i);
239
+ const item = res.written && res.written[0] && res.written[0].item;
240
+ say(`Added to ${n.initiative.name}, under ${(lay.stages[0].label || lay.stages[0].id)}.`, item ? async () => {
241
+ const u = await d.pmPost('/api/plan-items', { ws: plan.ws, events: [{ ev: 'withdrawn', item, initiative: n.initiative.id }] });
242
+ if (u && u.ok === true) { ui.tasked.delete(i); say('The task is withdrawn.'); } else say('The task was not withdrawn' + (u && u.error ? ': ' + u.error : '.'));
243
+ } : null);
244
+ }
245
+ async function openSheet() {
246
+ ui.view = 'add'; SH.sug = null; SH.found = []; SH.pick = null; SH.q = ''; SH.link = ''; paint();
247
+ $('#mmBack').focus();
248
+ const r = await d.pmGet('/api/meeting-material/suggest?' + suggestQuery(row, { ws: d.ws() }));
249
+ SH.sug = r && r.ok && Array.isArray(r.suggested) ? r.suggested : []; if (ui.view === 'add') paintSheet();
250
+ }
251
+ const closeSheet = (focusAdd) => { ui.view = 'detail'; paint(); if (focusAdd && $('#mmAdd')) $('#mmAdd').focus(); };
252
+ const pickOf = (key) => { const [k, i] = key.split(':'); return (k === 'sug' ? SH.sug : k === 'found' ? SH.found : [pasteOf(SH.link)])[+i] || null; };
253
+
254
+ $('#oMain').oninput = (e) => {
255
+ if (e.target.id === 'mmLinkIn') { SH.link = e.target.value.trim(); const p = pasteOf(SH.link); if (p) SH.pick = p; else if (SH.pick && !SH.pick.ref) SH.pick = null; paintSheet(); }
256
+ if (e.target.id === 'mmFind') {
257
+ SH.q = e.target.value.trim(); SH.found = []; SH.foundBusy = SH.q.length >= 2; paintSheet(); clearTimeout(findT);
258
+ if (!SH.foundBusy) return;
259
+ const my = ++SH.token;
260
+ findT = setTimeout(async () => { const r = await d.pmGet('/api/meeting-material/suggest?' + suggestQuery(row, { q: SH.q, ws: d.ws() })); if (my !== SH.token || ui.view !== 'add') return; SH.foundBusy = false; SH.found = r && r.ok && Array.isArray(r.found) ? r.found : []; paintSheet(); }, 220);
261
+ }
262
+ };
142
263
  $('#oMain').onchange = (e) => { if (e.target.id === 'mtgSel') $('#mtgLink').disabled = !e.target.value; };
143
264
  $('#oMain').onclick = async (e) => {
144
- if (!e.target.closest('#mtgLink')) return;
145
- const body = linkBody(row, sel().value, boards);
265
+ const t = e.target.closest('button'); if (!t) return;
266
+ if (t.id === 'mmAdd') return openSheet();
267
+ if (t.id === 'mmBack' || t.id === 'mmCancel') return closeSheet(true);
268
+ if (t.dataset.pick) { SH.pick = pickOf(t.dataset.pick); paintSheet(); return; }
269
+ if (t.dataset.scope) { SH.scope = t.dataset.scope; paintSheet(); return; }
270
+ if (t.id === 'mmDo') {
271
+ const body = addBody(row, SH.pick, SH.scope); if (!body) return;
272
+ t.disabled = true;
273
+ const res = await write(body);
274
+ if (!res.ok) { t.disabled = false; $('#mmLine').textContent = 'The material was not saved: ' + res.error; return; }
275
+ await reload(); ui.view = 'detail';
276
+ say('Added “' + clip(SH.pick.title, 80) + '” to ' + scopeText(SH.scope) + '.');
277
+ if ($('#mmAdd')) $('#mmAdd').focus();
278
+ return;
279
+ }
280
+ if (t.dataset.rm !== undefined) { const it = ((material && material.items) || [])[+t.dataset.rm]; if (it) await removeItem(it); return; }
281
+ if (t.dataset.task !== undefined) { t.disabled = true; await makeTask(+t.dataset.task); if (!ui.tasked.has(+t.dataset.task)) paint(); return; }
282
+ if (t.id === 'mtgUndo') { const fn = undoFn; undoFn = null; if (fn) await fn(); return; }
283
+ if (t.id !== 'mtgLink') return;
284
+ const body = linkBody(row, $('#mtgSel').value, boards);
146
285
  if (!body) return;
147
- const go = $('#mtgLink'); go.disabled = true;
286
+ t.disabled = true;
148
287
  const res = await d.pmPost('/api/calendar-links', body);
149
- if (!res || res.ok !== true) { go.disabled = false; $('#mtgMsg').textContent = (res && res.error) || 'The link could not be saved.'; return; }
150
- saved = body.kind === 'none' ? '' : sel().selectedOptions[0].textContent;
288
+ if (!res || res.ok !== true) { t.disabled = false; $('#mtgMsg').textContent = (res && res.error) || 'The link could not be saved.'; return; }
289
+ saved = body.kind === 'none' ? '' : $('#mtgSel').selectedOptions[0].textContent;
151
290
  d.toast(body.kind === 'none' ? 'The link is removed for every occurrence of this meeting.' : 'Linked. It applies to every occurrence of this meeting.');
152
291
  await readWeek(); paint(); if (mode === 'week') draw();
153
- $('#oMain').onchange = (ev) => { if (ev.target.id === 'mtgSel') $('#mtgLink').disabled = !ev.target.value; };
154
292
  };
155
293
  }
156
294
 
@@ -1329,6 +1329,16 @@ button.dsn:hover{box-shadow:inset 0 0 0 1.5px rgb(79,109,245)}
1329
1329
  .mtg-link{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:10px 0 8px}
1330
1330
  .mtg-link select{flex:1 1 220px;min-width:0;min-height:44px;border-radius:18px;border:1px solid var(--hair);background:var(--well);padding:0 14px;font:inherit;color:inherit}
1331
1331
  @media (max-width:700px){#todayCard .ch{flex-wrap:wrap;row-gap:8px}}
1332
+ .mtg-b{min-height:44px;padding:0 16px;border-radius:var(--r-chip);background:var(--well);color:var(--ink);font-weight:650;font-size:var(--t-small);display:inline-flex;align-items:center;transition:transform .35s var(--spring)}
1333
+ .mtg-b:disabled{opacity:.55}
1334
+ .mtg-l li:has(>.mtg-b){display:grid;grid-template-columns:1fr auto;column-gap:12px;align-items:center}.mtg-l li>.mtg-b{grid-row:1 / span 2;grid-column:2}
1335
+ .mtg-foot{display:flex;gap:12px;flex-wrap:wrap;align-items:center;margin-top:12px}.mtg-foot .note{margin:0}
1336
+ .mtg-in{width:100%;min-height:44px;border-radius:18px;border:1px solid var(--hair);background:var(--well);padding:0 14px;font:inherit;color:inherit;margin-bottom:8px}
1337
+ .mtg-pick{display:grid;grid-template-columns:1fr auto;column-gap:12px;align-items:center}.mtg-on{font-size:var(--t-small);color:var(--ember-ink);font-weight:600}
1338
+ .mtg-status{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:0 0 12px;padding:10px 14px;border-radius:18px;background:var(--well);color:var(--ink-2)}.mtg-status[hidden]{display:none}
1339
+ .mtg-sheet>.mtg-b{margin-bottom:10px}
1340
+ .mtg-sheet .seg2 button{min-height:44px}
1341
+
1332
1342
 
1333
1343
  /* Agent sessions dialog and its header button (initiative premium-sessions) */
1334
1344
  .sbtn{position:relative}
@@ -46,6 +46,7 @@
46
46
  "briefing-premium-reports.test.js",
47
47
  "briefing-premium-doc-edit.test.js",
48
48
  "briefing-premium-calendar.test.js",
49
+ "briefing-premium-calendar-2.test.js",
49
50
  "briefing-premium-products.test.js",
50
51
  "briefing-premium-sources.test.js",
51
52
  "briefing-premium-metrics.test.js",
@@ -213,6 +214,7 @@
213
214
  "briefing-premium-reports.test.js": 1,
214
215
  "briefing-premium-doc-edit.test.js": 1,
215
216
  "briefing-premium-calendar.test.js": 1,
217
+ "briefing-premium-calendar-2.test.js": 1,
216
218
  "briefing-premium-products.test.js": 1,
217
219
  "briefing-premium-sources.test.js": 1,
218
220
  "briefing-premium-metrics.test.js": 1,
@@ -9,6 +9,7 @@
9
9
  "briefing-premium-adddoc-test.js",
10
10
  "briefing-premium-doc-edit-test.js",
11
11
  "briefing-premium-calendar-test.js",
12
+ "briefing-premium-calendar-2-test.js",
12
13
  "briefing-premium-products-test.js",
13
14
  "briefing-premium-sources-test.js",
14
15
  "briefing-premium-metrics-test.js",
@@ -23,6 +24,7 @@
23
24
  "briefing-premium-adddoc-test.js": 120,
24
25
  "briefing-premium-doc-edit-test.js": 90,
25
26
  "briefing-premium-calendar-test.js": 90,
27
+ "briefing-premium-calendar-2-test.js": 90,
26
28
  "briefing-premium-products-test.js": 90,
27
29
  "briefing-premium-sources-test.js": 90,
28
30
  "briefing-premium-metrics-test.js": 120,