create-pmos 0.632.0 → 0.634.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.
Files changed (62) hide show
  1. package/package.json +27 -135
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +3 -0
  7. package/workspace/briefing-premium-board-test.js +4 -2
  8. package/workspace/briefing-premium-doc-edit-test.js +3 -0
  9. package/workspace/briefing-premium-initiative-test.js +4 -0
  10. package/workspace/briefing-premium-insights-test.js +1 -1
  11. package/workspace/briefing-premium-sources-test.js +2 -2
  12. package/workspace/changelog.json +26 -0
  13. package/workspace/core-docs-workflow-test.js +3 -0
  14. package/workspace/ev-everywhere-test.js +7 -17
  15. package/workspace/guide/layout.md +12 -5
  16. package/workspace/ini-workflow-test.js +3 -0
  17. package/workspace/lib/meeting-focus.js +5 -3
  18. package/workspace/lib/repo-identity.js +99 -0
  19. package/workspace/lib/routes-meeting-focus.js +2 -2
  20. package/workspace/live-pill-round-test.js +7 -2
  21. package/workspace/package-lock.json +2 -2
  22. package/workspace/package.json +1 -1
  23. package/workspace/premium-board-actions-test.js +3 -1
  24. package/workspace/premium-vw-backlog-test.js +2 -2
  25. package/workspace/premium-vw-doc-test.js +3 -0
  26. package/workspace/premium-vw-item-test.js +1 -1
  27. package/workspace/premium-vw-jira-test.js +4 -3
  28. package/workspace/public/pm/bd-ini-panel.js +4 -1
  29. package/workspace/public/pm/bd-prog-panel.js +3 -3
  30. package/workspace/public/pm/bd-views.js +8 -2
  31. package/workspace/public/pm/buddy-core.js +2 -2
  32. package/workspace/public/pm/cozy-board.css +15 -0
  33. package/workspace/public/pm/cozy-ev.css +25 -0
  34. package/workspace/public/pm/cozy-home.css +38 -2
  35. package/workspace/public/pm/cozy-nav.js +72 -6
  36. package/workspace/public/pm/cozy-phone-rec.css +68 -0
  37. package/workspace/public/pm/cozy-phone-rec.js +105 -0
  38. package/workspace/public/pm/cozy-phone-settings.css +18 -0
  39. package/workspace/public/pm/cozy-phone-settings.js +73 -0
  40. package/workspace/public/pm/cozy-phone-swipe.js +51 -0
  41. package/workspace/public/pm/cozy-pop-work.css +56 -0
  42. package/workspace/public/pm/cozy-pop-work.js +72 -4
  43. package/workspace/public/pm/cozy-rec-tab.js +10 -0
  44. package/workspace/public/pm/cozy-today-app.js +56 -5
  45. package/workspace/public/pm/cozy-today-page.css +75 -1
  46. package/workspace/public/pm/cozy-today-view.js +87 -0
  47. package/workspace/public/pm/cozy-viewer.js +27 -7
  48. package/workspace/public/pm/home-app.js +31 -2
  49. package/workspace/public/pm/home-chat.js +8 -0
  50. package/workspace/public/pm/home-ini.js +7 -3
  51. package/workspace/public/pm/phone-ask.js +57 -0
  52. package/workspace/server.js +8 -7
  53. package/workspace/split-merge-ui-test.js +3 -1
  54. package/workspace/stage-card-tasks-test.js +6 -0
  55. package/workspace/stage-card-test.js +3 -0
  56. package/workspace/task-delete-test.js +3 -0
  57. package/workspace/task-links-test.js +3 -0
  58. package/workspace/task-plans-test.js +3 -0
  59. package/workspace/task-views-test.js +3 -0
  60. package/workspace/test-lists/phone-design-v2.json +9 -0
  61. package/workspace/test-lists/repo-identity.json +9 -0
  62. package/workspace/tk-tasks-test.js +4 -0
@@ -16,6 +16,7 @@
16
16
  * leave, with Undo for a moment. Values read from the work (Gate, Open) and Jira tasks are not edited here.
17
17
  * Reads: GET /api/library-items?ws&initiative (the Library's rows, slice 7) once per initiative; when that route is not there the core documents
18
18
  * the page already reads stand in. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
+ import { wireSwipe } from './cozy-phone-swipe.js';
19
20
  import * as M from './pop-work-model.js';
20
21
  import * as CB from './cozy-bar.js';
21
22
  import { openPop, closePop, undoToast } from './hi-pop.js';
@@ -67,7 +68,11 @@ const RO = typeof window !== 'undefined' && !!window.PMOS_READONLY;
67
68
  const ib = (attr, label, d, cls = '') => `<button type="button" class="pw-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(d)}</button>`;
68
69
 
69
70
  /** The body is in the popup, and the PM did not ask for the old page there. */
70
- export function on(body) { return !!(body && body.closest && body.closest('.cz-pop') && !body.closest('[data-pw-all]') && !(body.dataset && body.dataset.pwAll)); }
71
+ /* A phone (Ph2_init): the item's page shows the popup's content in a phone layout , not the old page. Its look is the phone block at the end of cozy-pop-work.css. */
72
+ const phone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
73
+ export function on(body) { return inPop(body) || (!!(body && body.closest && phone() && body.closest('.cz-vw')) && !body.closest('[data-pw-all]') && !(body.dataset && body.dataset.pwAll)); }
74
+ /** The body is in the popup itself (a program or a product keeps its own page on a phone: Ph2_init is an initiative's). */
75
+ export function inPop(body) { return !!(body && body.closest && body.closest('.cz-pop') && !body.closest('[data-pw-all]') && !(body.dataset && body.dataset.pwAll)); }
71
76
 
72
77
  /* ── reads ── */
73
78
  function readItems(id, ws, redraw) {
@@ -284,10 +289,58 @@ function model(r, v, o) {
284
289
  }
285
290
  export function html(r, v, o = {}) {
286
291
  const { W, S } = model(r, v, o), C = cols(), mode = store.get(SPAN, 'full');
292
+ if (phone() && !RO) return phoneHtml(W, S, keyOf(v, o), v);
287
293
  if (S.big) return `<div class="pw" data-pw-big-on>${breakdownHtml(W, C, mode, true, S)}</div>`;
288
294
  return `<div class="pw">${overviewHtml(W, S, keyOf(v, o))}${breakdownHtml(W, C, mode, false, S)}${artefactsHtml(W.artefacts, C, true, { scope: keyOf(v, o), recPath: v.prd && (v.prd.path || v.prd) })}</div>`;
289
295
  }
290
296
 
297
+ /* ── a phone (board Ph2_init; build brief nav-structure/phone/build-brief-v2.md item 8): the popup's content in a phone layout. No cards and
298
+ * no table: the stage and its days over, the gate line, ✦ Overview with the lines that are written and one proposal for the ones that are not,
299
+ * the status line and PMOS's proposals, the Work breakdown as rows with a status dot (grey done, blue in progress, an empty ring to do), the
300
+ * Backlog line, Artefacts with the merge proposal and "N documents", and the box "Ask PMOS about this work". A proposal is swiped: right
301
+ * says yes, left says no (pm/cozy-phone-swipe.js); its press opens it, as in the popup. The presses are the popup's own data-pw-* ones. */
302
+ const PH_ARTS = new Set(); // initiatives whose documents are unfolded on the phone, per page
303
+ const phSug = (id, say, keep, drop, open) => `<div class="pw-psug" role="listitem" data-sw-right="yes" data-sw-left="no">${SVG(P.spark, 13, 2)}`
304
+ + (open ? `<button type="button" class="pw-psay" ${open}>${esc(say)}</button>` : `<span class="pw-psay">${esc(say)}</span>`)
305
+ + `<span class="pw-psb" hidden><button type="button" data-sw-yes ${keep} tabindex="-1">Yes</button><button type="button" data-sw-no ${drop} tabindex="-1">No</button></span></div>`;
306
+ function phoneHtml(W, S, oid, v) {
307
+ const st = (v && v.stage) || {}, d = st.dates || {}, dr = dropped();
308
+ const head = st.name ? `<div class="pw-phd">${st.n ? `<span class="pw-pn">${esc(st.n)}</span>` : ''}<b>${esc(st.name)}</b>${d.left ? `<span class="${d.over ? 'warn' : ''}">${esc(d.left)}</span>` : ''}</div>` : '';
309
+ const miss = st.gate && (st.gate.parts || []).filter((x) => !x.ok).map((x) => x.text);
310
+ const gate = miss && miss.length ? `<p class="pw-pgate">${esc(String(st.gate.label || 'Gate'))}: <span class="warn">${esc(miss.join(' and ').replace(/^./, (c) => c.toUpperCase()))}</span></p>` : '';
311
+ // the Overview: the lines that are written; the ones that are not, as one proposal ("Draft the Problem and Done when from Research notes")
312
+ const ov = W.overview;
313
+ const lines = ov.lines.filter((L) => L.text).map((L) => `<p class="pw-pl"><b>${esc(L.k)}</b> ${L.edit ? `<span class="pw-otx" data-pw-line="${esc(L.id)}" tabindex="0" role="button" aria-label="${esc('Change the ' + L.k.toLowerCase())}">${esc(L.text)}</span>` : esc(L.text)}${L.serves ? ' ' + esc(L.serves) : ''}</p>`).join('');
314
+ const off = ov.lines.filter((L) => !L.text && L.ask && !dr.has('ov:' + oid + ':' + L.id));
315
+ const from = off.length ? (/ (from .*?)\?$/.exec(off[0].miss || '') || [])[1] || 'with you' : '';
316
+ const ovSug = off.length ? phSug('', 'Draft the ' + off.map((L) => L.k).join(' and ') + ' ' + from, `data-pw-lkeep="${esc(off.map((L) => L.id).join(','))}"`, `data-pw-ldrop="${esc(off.map((L) => 'ov:' + oid + ':' + L.id).join(','))}"`, `data-pw-lkeep="${esc(off.map((L) => L.id).join(','))}"`) : '';
317
+ // the status line without what the head and the gate line already say (said once)
318
+ const said = String(ov.status || '').split(/(?<=\.)\s+/).filter((t) => t && !/^In \S/.test(t) && !/cannot pass the gate/i.test(t)).join(' ');
319
+ const sugs = W.suggests.map((s) => phSug(s.id, s.say, `data-pw-keep="${esc(s.id)}"`, `data-pw-drop="${esc(s.id)}"`, `data-pw-sug="${esc(s.id)}"`)).join('');
320
+ const ovH = `<section class="pw-pov" aria-label="Overview"><h3>${SVG(P.spark, 14, 2)}Overview</h3>${lines}${ovSug ? `<div class="pw-psugs" role="list">${ovSug}</div>` : ''}</section>`
321
+ + (said || sugs ? `<section class="pw-pstat" aria-label="Where it stands">${said ? `<p>${esc(said)}</p>` : ''}${sugs ? `<div class="pw-psugs" role="list">${sugs}</div>` : ''}</section>` : '');
322
+ // the Work breakdown: one row per stage, the open stage's tasks under it
323
+ const dot = (x) => `<i class="pw-pdot ${x.tone === 'dn' || x.status === 'Done' ? 'dn' : x.tone === 'now' || x.status === 'In progress' ? 'now' : 'todo'}" aria-hidden="true"></i>`;
324
+ const rows = W.rows.map((x) => {
325
+ if (x.kind === 'stage' && x.loose) return '';
326
+ if (x.kind === 'stage') return `<li class="pw-pst${x.now ? ' now' : ''}">${dot(x)}<button type="button" class="pw-pstg" data-pw-fold="${esc(x.key)}" aria-expanded="${x.open}"${x.can ? '' : ' disabled'}><span class="pw-n">${esc(x.n)}</span><b>${esc(x.name)}</b></button>${x.date ? `<span class="pw-pd${x.late ? ' warn' : ''}">${esc(x.date)}</span>` : x.can ? `<span class="pw-pd">${esc(x.count || '')}</span>` : ''}</li>`;
327
+ if (x.kind === 'far') return `<li class="pw-pst">${dot({ status: 'To do' })}<button type="button" class="pw-pstg" data-pw-far aria-expanded="false"><span class="pw-n">${esc(x.n)}</span><b>${esc(x.name)}</b></button><span class="pw-pd">${esc(x.count)}</span></li>`;
328
+ if (x.kind === 'done') return `<li class="pw-ptk"><button type="button" class="pw-dn" data-pw-done="${esc(x.key)}" aria-expanded="${x.open}">${esc(x.label)}</button></li>`;
329
+ if (x.kind === 'more') return `<li class="pw-ptk"><button type="button" class="pw-dn" data-pw-more="${esc(x.key)}" aria-expanded="false">${esc(x.label)}</button></li>`;
330
+ if (x.kind === 'task') return `<li class="pw-ptk${x.done ? ' done' : ''}"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i><button type="button" class="pw-tt" data-pw-open="${esc(x.uid)}">${esc(x.title)}</button>${x.date ? `<span class="pw-pd${x.late ? ' warn' : ''}">${esc(x.date)}</span>` : ''}</li>`;
331
+ return '';
332
+ }).join('');
333
+ const loose = W.looseN ? `<p class="pw-loose"><button type="button" class="pw-lk" data-pw-backlog>${esc(W.looseN === 1 ? '1 task with no stage is in the Backlog' : W.looseN + ' tasks with no stage are in the Backlog')}${SVG(P.right, 13)}</button></p>` : '';
334
+ const wbs = `<section class="pw-psec" aria-label="Work breakdown"><h4>Work breakdown</h4>${rows ? `<ul class="pw-pwbs">${rows}</ul>` : '<p class="pw-pnone">No task yet.</p>'}${loose}</section>`;
335
+ // Artefacts: the merge proposal, then "N documents", which unfolds the list
336
+ const arts = W.artefacts.filter((a) => !a.missing), mg = mergeOf(W.artefacts), open = PH_ARTS.has(oid);
337
+ const list = open ? `<ul class="pw-parts">${W.artefacts.map((a, i) => (a.missing ? '' : `<li><button type="button" class="pw-an" data-pw-art="${i}">${esc(a.title)}</button><span class="pw-pd">${esc(a.kindName || a.kind || '')}</span></li>`)).join('')}</ul>` : '';
338
+ const artH = arts.length || mg ? `<section class="pw-psec" aria-label="Artefacts"><h4>Artefacts</h4>${mg ? `<div class="pw-psugs" role="list">${phSug(mg.id, mg.say, `data-pw-keep="${esc(mg.id)}"`, `data-pw-drop="${esc(mg.id)}"`, `data-pw-sug="${esc(mg.id)}"`)}</div>` : ''}`
339
+ + (arts.length ? `<button type="button" class="pw-lk pw-pdocs" data-pw-pdocs aria-expanded="${open}">${esc(arts.length === 1 ? '1 document' : arts.length + ' documents')}${SVG(open ? P.down : P.right, 13)}</button>${list}` : '') + '</section>' : '';
340
+ const ask = `<form class="pw-pask" data-pw-pask><input type="text" maxlength="500" placeholder="Ask PMOS about this work" aria-label="Ask PMOS about this work" autocomplete="off"><button type="submit" aria-label="Send" title="Send">${SVG('M12 19V5M6 11l6-6 6 6', 16, 2)}</button></form>`;
341
+ return `<div class="pw pw-ph">${head}${gate}${ovH}${wbs}${artH}${ask}</div>`;
342
+ }
343
+
291
344
  /* ── the suggestion as its own page (board 22) ── */
292
345
  function sugPageHtml(s, W) {
293
346
  const items = (s.items || []).slice(0, 8);
@@ -306,9 +359,15 @@ function sugPageHtml(s, W) {
306
359
  * does it in a real session; ✕ hides it on this computer */
307
360
  const DROP = 'pw-dropped';
308
361
  const dropped = () => new Set(store.get(DROP, []));
362
+ let ASK_AT = null; // the initiative shown ({ id, ws }): a phone sends the words to Ask PMOS about it
363
+ function askPage(text) {
364
+ if (!ASK_AT || !ASK_AT.id) return false;
365
+ const q = new URLSearchParams({ ask: ASK_AT.id }); if (text) q.set('q', String(text).slice(0, 500)); if (ASK_AT.ws) q.set('ws', ASK_AT.ws);
366
+ location.assign('/premium.html?' + q.toString()); return true;
367
+ }
309
368
  function sendToChat(text) {
310
369
  const ask = document.querySelector('.cz-pop [data-pop="ask"]'); if (ask && !ask.closest('[hidden]')) ask.click();
311
- const ta = document.querySelector('.cz-pop-chat textarea'); if (!ta) return false;
370
+ const ta = document.querySelector('.cz-pop-chat textarea'); if (!ta) return phone() ? askPage(text) : false;
312
371
  ta.value = text; ta.dispatchEvent(new Event('input', { bubbles: true }));
313
372
  const f = ta.closest('form'); if (f && f.requestSubmit) f.requestSubmit(); else ta.focus();
314
373
  return true;
@@ -371,6 +430,7 @@ export function wire(body, h0, x0) {
371
430
  if (!body) return;
372
431
  // the Viewer reuses its body for the next item: the presses read the item shown now from the body, so one set of listeners serves all
373
432
  body.__pwh = ED.writes(h0); body.__pwx = x0;
433
+ { const o = x0 && x0.o ? x0.o() || {} : {}; ASK_AT = o.id ? { id: String(o.id), ws: o.ws || '' } : null; }
374
434
  { const c = cur(); if (c) { readItems(c.id, (x0.o() || {}).ws, () => redraw()); if (c.S.top) body.scrollTop = c.S.top; }
375
435
  const q = OPEN_ON_DRAW;
376
436
  if (c && q && q.id === String(c.id) && Date.now() - q.at < 15000) { OPEN_ON_DRAW = null; setTimeout(() => { const c2 = cur(); if (c2) openSmall(q.uid, c2, body.__pwh, body.__pwx, body); }, 0); } }
@@ -380,6 +440,12 @@ export function wire(body, h0, x0) {
380
440
  function redraw() { if (body.__pwh && body.__pwh.redraw) body.__pwh.redraw(); }
381
441
  goalsRedraw = artRedraw = wsnRedraw = () => { if (body.isConnected && body.querySelector('.pw')) redraw(); };
382
442
  wireGrip(body);
443
+ // a phone: a proposal swiped right says yes, left says no (its own hidden Yes and No presses, so the popup's writes and Undo stay theirs)
444
+ wireSwipe(body, { on: phone, act: (row, way) => { const b = row.querySelector(way === 'right' ? '[data-sw-yes]' : '[data-sw-no]'); if (b) b.click(); } });
445
+ body.addEventListener('submit', (e) => {
446
+ const f = e.target.closest && e.target.closest('[data-pw-pask]'); if (!f) return;
447
+ e.preventDefault(); const t = f.querySelector('input'); askPage(t ? t.value.trim() : '');
448
+ });
383
449
  const live = (e) => !!body.__pwx && !!e.target.closest('.pw') && !e.target.closest('.pw-sp, [data-pw-level]');
384
450
  body.addEventListener('scroll', () => { if (!body.querySelector(':scope > .pw, .pw:not(.pw-sp)')) return; const c = cur(); if (c) c.S.top = body.scrollTop; }, { passive: true });
385
451
  body.addEventListener('click', async (e) => {
@@ -404,8 +470,10 @@ export function wire(body, h0, x0) {
404
470
  if (d.pwSug) { const s = findSug(W, d.pwSug); if (s) openSug(s, c, x, h); return; }
405
471
  if ('pwProps' in d) { if (h.props) h.props(); return; }
406
472
  if (d.pwLine) { const L = W.overview.lines.find((q) => q.id === d.pwLine); if (L && L.edit) editLine(b, L, c, x, h); return; }
407
- if (d.pwLkeep) { const L = W.overview.lines.find((q) => q.id === d.pwLkeep); if (L && L.ask && !sendToChat(L.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
408
- if (d.pwLdrop) { const dd = dropped(); dd.add(d.pwLdrop); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
473
+ // a phone asks for several lines in one proposal: "problem,done"
474
+ if (d.pwLkeep) { const asks = d.pwLkeep.split(',').map((k) => W.overview.lines.find((q) => q.id === k)).filter((L) => L && L.ask).map((L) => L.ask); if (asks.length && !sendToChat(asks.join('\n\n')) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
475
+ if (d.pwLdrop) { const dd = dropped(); for (const k of d.pwLdrop.split(',')) dd.add(k); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
476
+ if ('pwPdocs' in d) { if (PH_ARTS.has(c.id)) PH_ARTS.delete(c.id); else PH_ARTS.add(c.id); redraw(); return; }
409
477
  if (d.pwSrc) { if (h.doc) h.doc(d.pwSrc); return; }
410
478
  if (d.pwChoice) { const [sid, k] = d.pwChoice.split('|'), s = findSug(W, sid), ch = s && s.choices && s.choices[+k]; if (ch && !sendToChat(ch.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
411
479
  if (d.pwMore != null) { S.moreOpen.add(d.pwMore); redraw(); return; }
@@ -21,6 +21,7 @@
21
21
  * Slots: S2 and S3 load here if their files exist (a missing file is ignored):
22
22
  * cozy-rec-now.js mountNow({ stage, side, bar }, ctx) ctx = { ws, note(), mode(), on(evt, fn), focus(), event, rec }
23
23
  * cozy-rec-present.js mountPresent({ stage, side, bar }, ctx) ctx = { ws, note: { id, title }, event, focus() }
24
+ * cozy-phone-rec.js mountPhoneRec(slots, ctx) a phone only (Ph2_record), with the ⋯ menu (cozy-nav.js)
24
25
  * bar holds [data-slot="now"] and [data-slot="present"] for their buttons.
25
26
  * Adler (batch 17 item 4-B, AdH5): his face with headphones sits after the title while the meeting records: glasses on (listening), honest
26
27
  * while the meeting is not heard, resting with the headphones on while paused. Not recording yet, or stopped: no face (no trigger).
@@ -153,6 +154,8 @@ function drawAsk() {
153
154
  function draw() {
154
155
  const m = modeOf(S.row, held(), C.screen());
155
156
  if (m !== S.mode) { S.mode = m; fire('mode', m); }
157
+ // a phone goes back to Today, which says where the recording was filed, with Undo (Ph2_recdone)
158
+ if (S.mode === 'stopped' && !S.ask && typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches) { location.replace('/today.html' + (WS ? '?ws=' + encodeURIComponent(WS) : '')); return; }
156
159
  if (S.mode === 'stopped' && !S.ask) { location.replace('/premium-viewer.html?open=meeting&note=' + encodeURIComponent(ID) + (WS ? '&ws=' + encodeURIComponent(WS) : '')); return; }
157
160
  drawHead(); drawStage(); drawBar(); drawLine(); drawAlert();
158
161
  const say = $('rtMsg'); say.textContent = S.msg && S.mode !== 'idle' ? S.msg : ''; say.hidden = !say.textContent;
@@ -227,6 +230,13 @@ function mountSlots() {
227
230
  drawBar();
228
231
  import('./cozy-rec-now.js').then((M) => M.mountNow && M.mountNow(slots(), { ws: WS, note: () => S.one, mode: () => S.mode, on: (k, fn) => { if (S.on[k]) { S.on[k].add(fn); return () => S.on[k].delete(fn); } return () => {}; },
229
232
  focus: () => S.focus, event: eventOf(), rec: C })).catch(() => {});
233
+ // a phone (Ph2_record): one page, the stop in the header, Shared screen cut to the slide, So far, PMOS proposes; the ⋯ menu as on every phone page.
234
+ // On a phone this tab is the only tab, so its links open here and not in another tab.
235
+ if (typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches) {
236
+ const base = document.querySelector('base'); if (base) base.target = '_self';
237
+ import('./cozy-nav.js').then((M) => M.mountNav('rec', document)).catch(() => {});
238
+ import('./cozy-phone-rec.js').then((M) => M.mountPhoneRec(slots(), { note: () => S.one, focus: () => S.focus, mode: () => S.mode, on: (k, fn) => { if (S.on[k]) S.on[k].add(fn); } })).catch(() => {});
239
+ }
230
240
  import('./cozy-rec-present.js').then((M) => M.mountPresent && M.mountPresent(slots(), { ws: WS, note: { id: ID, title: title() }, event: eventOf(), focus: () => S.focus })).catch(() => {});
231
241
  }
232
242
 
@@ -18,12 +18,16 @@ import * as TM from './cozy-today-model.js';
18
18
  import { productName, whenNames } from './scope-chip.js';
19
19
  import * as TP from './cozy-today-view.js';
20
20
  import * as OM from './mention-one-model.js'; // the one mention's title and the self check's proof line (Today round 3)
21
+ import { wireSwipe } from './cozy-phone-swipe.js'; // the phone: rows and the proposal swipe (phone design, Ph2_today)
21
22
 
22
23
  const ASK_SEND = new Set(['session']);
23
24
  export function mountToday(ctx) {
24
- const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set(), type: '', open: false, hide: new Set(), sopen: new Set() };
25
+ const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set(), type: '', open: false, hide: new Set(), sopen: new Set(), unfiled: new Set() };
25
26
  const el = document.getElementById('tdPage');
26
- const on = () => !!el && !ctx.isPhone();
27
+ // a desk and a phone both draw Today here; a phone draws its own one column (TP.phonePageHtml, board Ph2_today) while no conversation is
28
+ // open over it (body.hm-plist: home-app.js's phone list state). On a phone Home's list is not drawn on today.html (cozy-today-page.css).
29
+ const on = () => !!el;
30
+ const phone = () => ctx.isPhone();
27
31
  const day = () => TM.dayKey(ctx.now());
28
32
 
29
33
  async function read() {
@@ -89,6 +93,14 @@ export function mountToday(ctx) {
89
93
  }
90
94
  if (X.type && !(L.types || {})[X.type]) X.type = '';
91
95
  const cap = document.getElementById('tdCap'), draft = cap ? cap.value : '', focus = !!cap && document.activeElement === cap;
96
+ if (phone()) {
97
+ const html = TP.phonePageHtml(L, A, O, { head: TM.headModel(ctx.now()), type: X.type, open: X.open, sopen: [...X.sopen], filed: filedLine(), now: ctx.now() });
98
+ if (html === X.html && el.firstChild) return;
99
+ X.html = html; el.classList.add('tdp');
100
+ const sy = scrollY; el.innerHTML = html; scrollTo(0, sy);
101
+ return;
102
+ }
103
+ el.classList.remove('tdp');
92
104
  const html = TP.pageHtml(L, A, { draft, overview: O, type: X.type, open: X.open || !!X.type, handled: X.type && X.type !== 'Ask' ? [] : handled(), hopen: X.hopen, sopen: [...X.sopen] });
93
105
  if (html === X.html && el.firstChild) return;
94
106
  X.html = html;
@@ -97,6 +109,19 @@ export function mountToday(ctx) {
97
109
  if (el.parentNode) el.parentNode.scrollTop = st;
98
110
  const c2 = document.getElementById('tdCap'); if (c2 && focus) { c2.focus(); c2.setSelectionRange(c2.value.length, c2.value.length); }
99
111
  }
112
+ /* After a meeting (board Ph2_recdone): "Recording filed under <work>" with what came of it, and Undo (the note leaves the work). The
113
+ * newest meeting that ended in the last 3 hours and is filed under an initiative; Undo or a later meeting takes the line away. */
114
+ const FILED_MS = 3 * 3600e3;
115
+ function filedLine() {
116
+ const N = (ctx.notes ? ctx.notes() : []).filter((n) => n && n.state === 'ended' && n.initiative && n.initiative.title && !X.unfiled.has(String(n.id)));
117
+ const at = (n) => Date.parse(n.ended_at || n.updated_at || '') || 0;
118
+ const n = N.sort((a, b) => at(b) - at(a))[0];
119
+ if (!n || ctx.now() - at(n) > FILED_MS) return null;
120
+ const ago = ctx.now() - at(n), min = Math.round((Number(n.meeting_ms) || 0) / 60000), t = n.came && n.came.tasks;
121
+ const d = new Date(at(n)), when = ago < 5 * 60000 ? 'Just now' : String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0');
122
+ const what = [n.summary ? 'summary' : '', t ? t + (t === 1 ? ' task' : ' tasks') : ''].filter(Boolean).join(' and ');
123
+ return { id: String(n.id), title: n.initiative.title, ini: n.initiative.id || null, sub: [when, min ? min + ' min' : '', what].filter(Boolean).join(' · ') };
124
+ }
100
125
  const rowOf = (key) => (X.model ? X.model.rows.flatMap((r) => [r, ...(r.members || [])]).find((r) => r.key === key) : null);
101
126
  const snap = (r) => ({ title: r.title, work: r.work, job: r.job, type: r.type });
102
127
  async function mark1(key, act, extra) {
@@ -300,10 +325,35 @@ export function mountToday(ctx) {
300
325
  if (step(e.key === 'j' ? 1 : -1)) e.preventDefault();
301
326
  });
302
327
  if (el) {
303
- el.addEventListener('click', async (e) => {
328
+ el.addEventListener('click', (e) => {
304
329
  const b = e.target.closest('[data-td]'); if (!b || b.disabled) return;
305
- const act = b.dataset.td, key = b.dataset.key || '';
330
+ run(b.dataset.td, b.dataset.key || '', b);
331
+ });
332
+ // the phone's type filter (Today's log · N All ⌄)
333
+ el.addEventListener('change', (e) => { const t = e.target.closest('[data-td-type]'); if (t) { X.type = t.value; draw(); } });
334
+ // a phone: a row or the proposal swiped; the act is the one its button had on a desk, said in the toast with Undo
335
+ wireSwipe(el, { on: phone, act: (row, way) => { const act = row.dataset[way === 'right' ? 'swRight' : 'swLeft']; if (act) run(act, row.dataset.key || '', { dataset: {}, disabled: false, isConnected: false }); } });
336
+ }
337
+ async function run(act, key, b) {
306
338
  if (act === 'cal') { ctx.openCalendar(); return; }
339
+ // the phone (Ph2_today): Record on the next event starts its recording; with no event, a recording of its own (PMOS names it after)
340
+ if (act === 'rec' || act === 'rec-ev') {
341
+ const x = act === 'rec-ev' && X.agenda && X.agenda.items.find((y) => y.key === key);
342
+ const m = x && x.ref;
343
+ const res = m ? await ctx.record({ id: m.id, at: m.start, end: m.end, title: m.title, app: x.app === 'teams' ? 'other' : x.app }) : ctx.fresh ? await ctx.fresh() : null;
344
+ if (!res || !res.ok) ctx.toast((res && res.error) || 'The recording did not start. Nothing changed.');
345
+ return;
346
+ }
347
+ // Ph2_recdone: Undo takes the recording out of the work it was filed under
348
+ if (act === 'filed-undo') {
349
+ const f = filedLine(); if (!f || f.id !== key) return;
350
+ const r = await ctx.pmPost('/api/notes/link', { id: key, initiative: null }).catch(() => null);
351
+ if (!r || !r.ok) return ctx.toast((r && r.error) || 'It is still filed. Nothing changed.');
352
+ X.unfiled.add(key); draw();
353
+ ctx.toastUndo('Taken out of ' + f.title + '.', async () => { const u = await ctx.pmPost('/api/notes/link', { id: key, initiative: f.ini }).catch(() => null); X.unfiled.delete(key); draw(); return u || { ok: false }; });
354
+ return;
355
+ }
356
+ if (act === 'ov-open') return; // the proposal's words: a swipe answers it
307
357
  if (act === 'fold') { X.open = !X.open; draw(); return; }
308
358
  if (act === 'hfold') { X.hopen = !X.hopen; draw(); return; }
309
359
  if (act === 'h-undo') {
@@ -353,7 +403,8 @@ export function mountToday(ctx) {
353
403
  else if (act === 'lk-yes' || act === 'lk-no') await looks(r, act === 'lk-yes');
354
404
  else if (act === 'same-yes' || act === 'same-no') await same(r, act === 'same-yes');
355
405
  } finally { X.busy.delete(key); if (b.isConnected) b.disabled = false; }
356
- });
406
+ }
407
+ if (el) {
357
408
  // the first line: Enter adds the row, and nothing else happens (no popup, no session)
358
409
  el.addEventListener('submit', async (e) => {
359
410
  if (e.target.id !== 'tdCapF') return;
@@ -1,7 +1,8 @@
1
1
  /* pm/cozy-today-page.css — Today, the place (slice 5 of the six-place navigation; board 1 on Exploring 2; pm/cozy-today-view.js draws it).
2
2
  * today.html on a desk: the white page panel (#hmDesk) holds Today only. Home's list and chat column are not drawn; the chat is the
3
3
  * popup's (pm/cozy-popup.js). One container: the log is one card with a thin border, the agenda one grey box on the right.
4
- * Token vars only (cozy.css :root holds every raw value, and its dark block the dark ones). Nothing animates. The phone keeps Home. */
4
+ * Token vars only (cozy.css :root holds every raw value, and its dark block the dark ones). Nothing animates. A phone draws its own one
5
+ * column (.tdp, at the end of this file) in place of Home's list. */
5
6
 
6
7
  @media (min-width: 761px) {
7
8
  body.cz-today #hmDesk > .hm-list, body.cz-today #hmDesk > .hm-chat, body.cz-today #hmDesk > .cz-pn-div, body.cz-today #hmUnfold, body.cz-today .hm-top { display: none !important; }
@@ -171,3 +172,76 @@ button.td-ev:focus-visible { outline: 2px solid var(--cz-blue); outline-offset:
171
172
  .td-r.mem .td-t { font-weight: var(--fw-regular); }
172
173
  .td-ag.quiet { align-self: start; }
173
174
  .td-quiet { margin: 6px 0 0; font-size: var(--fs-row); color: var(--cz-ink2); }
175
+
176
+ /* ── Today on a phone (phone design, boards Ph2_today, Ph2_todayzero, Ph2_recdone; pm/cozy-today-view.js phonePageHtml) ──
177
+ * One column on the white page, a 16 px gutter, no cards and no boxes: hairlines between the parts. Home's list is not drawn on today.html;
178
+ * a conversation or a page opened from a row covers Today as on Home (body:not(.hm-plist)). Rows swipe (pm/cozy-phone-swipe.js): they pan
179
+ * vertically only, and while a finger moves one its tint says the way. The ⋯ of the menu sits at the top right (cozy-ev.css). */
180
+ @media (max-width: 760px) {
181
+ body.cz-today.hm-plist { background: var(--cz-card); }
182
+ body.cz-today.hm-plist #hmDesk > .hm-list, body.cz-today .hm-plist .hm-top, body.cz-today.hm-plist .hm-top { display: none !important; }
183
+ body.cz-today:not(.hm-plist) .td-page { display: none !important; }
184
+ body.cz-today.hm-plist #hmDesk { padding: 0 16px 48px; }
185
+ .td-page.tdp { display: block; font-family: var(--cz-sans); color: var(--cz-ink); padding-top: calc(env(safe-area-inset-top, 0px) + 18px); }
186
+ .tdp h1, .tdp h2, .tdp p, .tdp ul { margin: 0; padding: 0; }
187
+ .tdp ul { list-style: none; }
188
+ .tdp button { font-family: var(--cz-sans); }
189
+ .tdp-top { padding-right: 40px; display: flex; flex-direction: column; gap: 2px; }
190
+ .tdp-top .td-when { font-size: var(--fs-label); letter-spacing: .04em; text-transform: uppercase; color: var(--cz-ink3); line-height: var(--lh-label); }
191
+ .tdp-top h1 { font-size: var(--fs-display); font-weight: var(--fw-strong); line-height: 1.25; color: var(--cz-ink); }
192
+ /* after a meeting: what was filed, with Undo (Ph2_recdone) */
193
+ .tdp-filed { display: flex; align-items: center; gap: 12px; padding: 14px 0; margin-top: 12px; border-bottom: 1px solid var(--cz-hair); }
194
+ .tdp-filed > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
195
+ .tdp-filed b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
196
+ .tdp-filed small { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
197
+ .tdp-ib { flex: none; width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink2); display: inline-grid; place-items: center; padding: 0; cursor: pointer; }
198
+ /* the Overview: PMOS's words, one ✦ proposal, the hint */
199
+ .tdp-ov { padding: 16px 0 14px; border-bottom: 1px solid var(--cz-hair); display: flex; flex-direction: column; gap: 6px; }
200
+ .tdp-ov h2 { display: flex; align-items: center; gap: 8px; font-size: var(--fs-label); font-weight: var(--fw-strong); letter-spacing: .08em; text-transform: uppercase; color: var(--cz-ink2); line-height: var(--lh-label); }
201
+ .tdp-ov h2 svg { color: var(--cz-blue); }
202
+ .tdp-ov > p { font-size: var(--fs-row); line-height: var(--lh-body); color: var(--cz-ink); }
203
+ .tdp-zero { padding: 12px 0 14px; border-bottom: 1px solid var(--cz-hair); font-size: var(--fs-row); line-height: var(--lh-body); }
204
+ .tdp-sg { touch-action: pan-y; }
205
+ .tdp-sgt { all: unset; display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; color: var(--cz-blueink); font-size: var(--fs-body); line-height: var(--lh-body); cursor: default; }
206
+ .tdp-sgt svg { flex: none; margin-top: 3px; color: var(--cz-blue); }
207
+ .tdp-ov > .tdp-hint { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
208
+ /* the next event and ● Record */
209
+ .tdp-ev { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--cz-hair); }
210
+ .tdp-evt { all: unset; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; cursor: pointer; }
211
+ .tdp-evt:disabled { cursor: default; }
212
+ .tdp-evt b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
213
+ .tdp-evt small { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
214
+ .tdp-rec { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px 0 14px; border-radius: 999px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); font-size: var(--fs-row); font-weight: var(--fw-strong); cursor: pointer; }
215
+ .tdp-rec i { width: 9px; height: 9px; border-radius: 50%; background: var(--cz-dot-red); }
216
+ /* Today's log */
217
+ .tdp-lh { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 10px; border-bottom: 1px solid var(--cz-hair); }
218
+ .tdp-lh h2 { font-size: var(--fs-label); font-weight: var(--fw-strong); letter-spacing: .08em; text-transform: uppercase; color: var(--cz-ink2); line-height: var(--lh-label); }
219
+ .tdp-f { position: relative; display: inline-flex; align-items: center; gap: 2px; color: var(--cz-ink3); }
220
+ .tdp-f select { appearance: none; -webkit-appearance: none; border: 0; background: none; font: inherit; font-size: var(--fs-row); color: var(--cz-ink3); padding: 6px 18px 6px 6px; min-height: 36px; text-align: right; }
221
+ .tdp-f svg { position: absolute; right: 0; pointer-events: none; }
222
+ .tdp-r { position: relative; display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--cz-hair); background: var(--cz-card); touch-action: pan-y; }
223
+ .tdp-r.sw-on { transition: none; }
224
+ .tdp-r.sw-r { box-shadow: inset 4px 0 0 var(--cz-dot-ok); }
225
+ .tdp-r.sw-l { box-shadow: inset -4px 0 0 var(--cz-dot-q); }
226
+ .tdp-sg.sw-r .tdp-sgt { color: var(--cz-dot-ok); }
227
+ .tdp-sg.sw-l .tdp-sgt { color: var(--cz-ink3); }
228
+ .tdp-b { flex: none; width: 14px; font-style: normal; font-size: var(--fs-panel); line-height: 26px; text-align: center; color: var(--cz-ink); }
229
+ .tdp-x { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
230
+ .tdp-t { all: unset; font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); color: var(--cz-ink); overflow-wrap: anywhere; cursor: pointer; }
231
+ span.tdp-t { cursor: default; }
232
+ .tdp-m { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
233
+ .tdp-m i { font-style: normal; }
234
+ .tdp-m em { font-style: normal; color: var(--cz-late); }
235
+ .tdp-pro { display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; font-size: var(--fs-body); color: var(--cz-ink2); line-height: var(--lh-body); }
236
+ .tdp-pro svg { flex: none; margin-top: 3px; color: var(--cz-blue); }
237
+ .tdp-r.done .tdp-t, .tdp-r.done .tdp-b { color: var(--cz-ink3); }
238
+ /* Can wait: one line; on a zero day its own short part (Ph2_todayzero) */
239
+ .tdp-cw { all: unset; display: flex; align-items: center; gap: 8px; padding: 14px 0; font-size: var(--fs-body); color: var(--cz-ink3); cursor: pointer; line-height: var(--lh-body); }
240
+ .tdp-cw b { color: var(--cz-ink); font-weight: var(--fw-strong); }
241
+ .tdp-cw[aria-expanded="true"] svg { transform: rotate(180deg); }
242
+ .tdp-cw0 h2 { padding: 22px 0 6px; font-size: var(--fs-label); font-weight: var(--fw-regular); letter-spacing: .08em; text-transform: uppercase; color: var(--cz-ink3); line-height: var(--lh-label); }
243
+ .tdp-cw0 h2 em { font-style: normal; margin-left: 6px; }
244
+ .tdp-cwl { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; justify-content: space-between; min-height: 48px; font-size: var(--fs-body); color: var(--cz-ink); cursor: pointer; }
245
+ .tdp-cwl svg { color: var(--cz-ink3); }
246
+ .tdp :focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
247
+ }
@@ -141,3 +141,90 @@ export const headHtml = (Hd) => `<header class="td-top"><span class="td-when">${
141
141
 
142
142
  /** The whole page: the Overview and the log at the left, the agenda beside them. o.overview: overviewModel(). */
143
143
  export function pageHtml(L, A, o = {}) { return `${o.head ? headHtml(o.head) : ''}<div class="td"><div class="td-main">${o.overview ? overviewHtml(o.overview, o) : ''}${logHtml(L, o)}</div>${agendaHtml(A)}</div>`; }
144
+
145
+ /* ── Today on a phone (phone design, boards Ph2_today, Ph2_todayzero, Ph2_recdone; build brief nav-structure/phone/build-brief-v2.md) ──
146
+ * One column, no cards and no boxes: the day and the greeting, "Recording filed under …" with Undo after a meeting, the ✦ Overview with at
147
+ * most one ✦ proposal and the one hint line, the next event with ● Record, Today's log (its count and an "All" filter), then Can wait folded
148
+ * to one line. A row is two lines: the title, then its type, its work and its reason; no action words. Rows and the proposal SWIPE
149
+ * (pm/cozy-phone-swipe.js): right does or accepts, left drops or puts off, and the toast says what happened with Undo. A row rests flat.
150
+ * Pure: Node imports it (today-log.test.js). */
151
+ export const SWIPE_HINT = 'Swipe any row: right to do or accept, left to drop or put off.';
152
+ const PI = { undo: 'M9 14L4 9l5-5M4 9h11a5 5 0 0 1 0 10h-3', chev: 'M9 6l6 6-6 6', down: 'M7 10l5 5 5-5', spark: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z' };
153
+ /** What a swipe does on a row: { right, left } acts of the click handler ('done', 'tomorrow', 'lab-keep', …), '' when that way does nothing. */
154
+ export function swipeActs(r) {
155
+ if (!r || r.done || r.src === 'note' || r.src === 'gone') return { right: '', left: '' };
156
+ if (r.src === 'lab') return { right: 'lab-keep', left: 'lab-drop' };
157
+ if (r.drop) return { right: 'drop', left: 'keep' }; // PMOS suggests to drop it: right accepts the suggestion, left keeps the line
158
+ if (r.looks) return { right: 'lk-yes', left: 'lk-no' };
159
+ if (r.members && r.drafts) return { right: 'same-yes', left: 'same-no' };
160
+ return { right: 'done', left: 'tomorrow' };
161
+ }
162
+ /** The next event of the day for the phone's one line: { key, title, sub, play } or the quiet line when there is none. A: agendaModel(). */
163
+ export function nextEvent(A, now = Date.now()) {
164
+ const m = (A && A.items ? A.items : []).filter((x) => (x.kind === 'meeting' || x.kind === 'own') && x.b > now).sort((p, q) => p.a - q.a)[0];
165
+ const free = A && A.free ? durPhone(A.free) + ' free' : '';
166
+ if (!m) return { key: '', title: 'No events today', sub: free, play: false, own: false };
167
+ const on = m.a <= now;
168
+ return { key: m.key, title: m.title, sub: (on ? 'Now · ' : '') + m.sub + (m.kind === 'own' ? '' : ''), play: m.kind === 'meeting', own: m.kind === 'own', ref: m };
169
+ }
170
+ const durPhone = (min) => { const h = Math.floor(min / 60), m = min % 60; return h ? (m >= 30 ? h + '.5 h' : h + ' h') : m + ' min'; };
171
+
172
+ /** One row of the phone's log: the bullet, the title, then "Task · IDPF · Ready to send"; a ✦ line under it when PMOS proposes. */
173
+ export function phoneRowHtml(r) {
174
+ const [b, bl] = r.done ? ['×', 'Done'] : BULLET[r.bullet] || BULLET.task;
175
+ const sw = swipeActs(r);
176
+ const opens = !r.done && r.src !== 'own' && r.src !== 'gone' && r.src !== 'note';
177
+ const title = opens ? `<button type="button" class="tdp-t" data-td="open" data-key="${esc(r.key)}">${esc(r.title)}</button>` : `<span class="tdp-t">${esc(r.title)}</span>`;
178
+ const meta = [r.type ? `${svg(TI[r.type] || TI.Task, 13, 1.8)}<span>${esc(r.type)}</span>` : '', r.work ? esc(r.work) : '', r.reason ? esc(r.reason) : '', r.when && r.late && !r.done ? `<em>${esc(r.when)}</em>` : '']
179
+ .filter(Boolean).join('<i aria-hidden="true">·</i>');
180
+ const pro = (t) => `<span class="tdp-pro">${svg(PI.spark, 13, 1.9)}<span>${esc(t)}</span></span>`;
181
+ const sug = r.drop ? pro('PMOS suggests: drop it from your log.')
182
+ : r.looks && !r.done ? pro('Looks answered: ' + (r.looks.who ? r.looks.who + ' replied' : 'someone replied') + ' “' + r.looks.text + '”. Close it?')
183
+ : r.members && r.drafts && !r.done ? pro('PMOS drafts them for you to read.')
184
+ : r.src === 'lab' && r.why ? pro(r.why) : '';
185
+ const say = sw.right ? ` aria-describedby="tdpHint"` : '';
186
+ return `<li class="tdp-r${r.done ? ' done' : ''}${r.first && !r.done ? ' first' : ''}" data-key="${esc(r.key)}"${sw.right ? ` data-sw-right="${sw.right}"` : ''}${sw.left ? ` data-sw-left="${sw.left}"` : ''}${say}>`
187
+ + `<i class="tdp-b" role="img" aria-label="${esc(bl)}">${b}</i><div class="tdp-x">${title}${meta ? `<small class="tdp-m">${meta}</small>` : ''}${sug}</div></li>`;
188
+ }
189
+
190
+ /** Today on a phone. L: logModel(), A: agendaModel(), O: overviewModel(); o: { head, type, open, filed: { title, sub, id } | null, now } */
191
+ export function phonePageHtml(L, A, O, o = {}) {
192
+ const H = o.head ? `<header class="tdp-top"><span class="td-when">${esc(o.head.when)}</span><h1>${esc(o.head.hello)}</h1></header>` : '';
193
+ const filed = o.filed ? `<section class="tdp-filed" aria-label="The meeting you recorded"><div><b>${esc('Recording filed under ' + o.filed.title)}</b>${o.filed.sub ? `<small>${esc(o.filed.sub)}</small>` : ''}</div>`
194
+ + `<button type="button" class="tdp-ib" data-td="filed-undo" data-key="${esc(o.filed.id)}" aria-label="${esc('Undo: take the recording out of ' + o.filed.title)}" title="Undo">${svg(PI.undo, 18, 1.8)}</button></section>` : '';
195
+ const pick = (rows) => (o.type ? (rows || []).filter((r) => r.type === o.type) : rows || []);
196
+ const shown = pick(L.first).concat(pick(L.todayRows));
197
+ const wait = pick(L.wait);
198
+ const sg = O && O.suggest && O.suggest[0];
199
+ const anySwipe = !!sg || shown.some((r) => swipeActs(r).right);
200
+ // the Overview: PMOS's words, at most one ✦ proposal, and the hint once there is something to swipe. Nothing open: one sentence.
201
+ const zero = !shown.length;
202
+ const ov = zero
203
+ ? `<p class="tdp-zero">${esc(o.quiet || 'Nothing is open for today.')}</p>`
204
+ : `<section class="tdp-ov" aria-label="Overview"><h2>${svg(PI.spark, 15, 1.9)}<span>Overview</span></h2>${O && O.said ? `<p>${esc(O.said)}</p>` : ''}`
205
+ + (sg ? `<ul class="tdp-sgl"><li class="tdp-sg" data-key="${esc(sg.key)}" data-sw-right="ov-yes" data-sw-left="ov-no" aria-describedby="tdpHint"><button type="button" class="tdp-sgt" data-td="ov-open" data-key="${esc(sg.key)}">${svg(PI.spark, 13, 1.9)}<span>${esc(sg.text)}</span></button></li></ul>` : '')
206
+ + (anySwipe ? `<p class="tdp-hint" id="tdpHint">${esc(SWIPE_HINT)}</p>` : '') + '</section>';
207
+ // the next event, with ● Record (a meeting records; with no event, Record starts a recording of its own)
208
+ const N = nextEvent(A, o.now);
209
+ const ev = `<section class="tdp-ev" aria-label="Next event"><button type="button" class="tdp-evt"${N.key && !N.own ? ` data-td="ev" data-key="${esc(N.key)}"` : ' tabindex="-1" disabled'}><b>${esc(N.title)}</b>${N.sub ? `<small>${esc(N.sub)}</small>` : ''}</button>`
210
+ + `<button type="button" class="tdp-rec" data-td="${N.play ? 'rec-ev' : 'rec'}" data-key="${esc(N.key)}" aria-label="${esc(N.play ? 'Record ' + N.title : 'Record a meeting')}"><i aria-hidden="true"></i>Record</button></section>`;
211
+ // the log: its count and the type filter, then the rows
212
+ const types = O && O.chips ? O.chips : [];
213
+ const total = types.reduce((n, c) => n + c.n, 0);
214
+ const filter = types.length > 1 ? `<label class="tdp-f"><span class="td-vh">Show</span><select data-td-type aria-label="Show one type"><option value=""${o.type ? '' : ' selected'}>All</option>`
215
+ + types.map((c) => `<option value="${esc(c.type)}"${o.type === c.type ? ' selected' : ''}>${esc((PLURAL[c.type] || c.type) + ' ' + c.n)}</option>`).join('') + `</select>${svg(PI.down, 14)}</label>` : '';
216
+ const log = zero ? '' : `<section class="tdp-log" aria-label="Today’s log"><div class="tdp-lh"><h2>Today’s log · ${esc(o.type ? shown.length : L.open || total || shown.length)}</h2>${filter}</div>`
217
+ + `<ul class="tdp-rows">${shown.map((r) => phoneRowHtml(r) + (r.members && (o.sopen || []).includes(r.key) ? r.members.map((m) => phoneRowHtml(m)).join('') : '')).join('')}</ul></section>`;
218
+ // Can wait: one line, folded; a zero day says it as its own short section (Ph2_todayzero)
219
+ let cw = '';
220
+ if (wait.length) {
221
+ const oldest = Math.max(0, ...wait.map((r) => r.carried || 0));
222
+ const old = oldest ? 'the oldest waits ' + oldest + (oldest === 1 ? ' day' : ' days') : '';
223
+ if (zero) cw = `<section class="tdp-cw0" aria-label="Can wait"><h2>Can wait <em>${esc(wait.length)}</em></h2><button type="button" class="tdp-cwl" data-td="fold" aria-expanded="${!!o.open}"><span>${esc(old ? cap(old) : plural3(wait.length))}</span>${svg(o.open ? PI.down : PI.chev, 16)}</button></section>`;
224
+ else cw = `<button type="button" class="tdp-cw" data-td="fold" aria-expanded="${!!o.open}"><b>Can wait</b><span>${esc(wait.length + ' more' + (old ? ' · ' + old : ''))}</span>${svg(PI.down, 14)}</button>`;
225
+ if (o.open) cw += `<ul class="tdp-rows tdp-waitl">${wait.map((r) => phoneRowHtml(r)).join('')}</ul>`;
226
+ }
227
+ return `${H}${filed}${ov}${ev}${log}${cw}`;
228
+ }
229
+ const cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
230
+ const plural3 = (n) => n + (n === 1 ? ' line' : ' lines');
@@ -438,18 +438,38 @@ function grip(el) {
438
438
  }
439
439
 
440
440
  /* ── the ⋯ menu ── */
441
- function moreMenu(b) {
442
- const old = V.el.querySelector('.cz-vw-menu');
443
- if (old) { old.remove(); b.setAttribute('aria-expanded', 'false'); return; }
444
- const items = ((typeof V.cur.more === 'function' ? V.cur.more() : V.cur.more) || []).filter(Boolean).slice(); // a function is asked each time ⋯ opens, so its notes are current
441
+ /** The ⋯ menu's items for one viewer: its own, the presses that left the header, Open in a new tab. b: the press that opened it. */
442
+ function itemsOf(X, b) {
443
+ const items = ((typeof X.cur.more === 'function' ? X.cur.more() : X.cur.more) || []).filter(Boolean).slice(); // a function is asked each time ⋯ opens, so its notes are current
445
444
  // on a phone the presses marked menu lead the menu (they left the header)
446
- if (V.ph || V.pop) { const mp = (V.cur.presses || []).filter((x) => x && x.act && x.label && (V.ph ? x.menu : !x.solid)); if (mp.length) items.unshift(...mp.map((x) => ({ label: x.label, icon: x.icon, on: () => { if (typeof V.cur.onPress === 'function') V.cur.onPress(x.act, b); } })), { sep: true }); }
447
- if (V.cur.url) { // the item's own address looks back, so it goes before the red stop-or-remove group, which stays last
448
- const at = items.findIndex((x) => x && x.danger), tab = { label: V.cur.full ? 'Open in full' : 'Open in a new tab', on: () => window.open(V.cur.url, '_blank', 'noopener') };
445
+ if (X.ph || X.pop) { const mp = (X.cur.presses || []).filter((x) => x && x.act && x.label && (X.ph ? x.menu : !x.solid)); if (mp.length) items.unshift(...mp.map((x) => ({ label: x.label, icon: x.icon, on: () => { if (typeof X.cur.onPress === 'function') X.cur.onPress(x.act, b); } })), { sep: true }); }
446
+ if (X.cur.url) { // the item's own address looks back, so it goes before the red stop-or-remove group, which stays last
447
+ const at = items.findIndex((x) => x && x.danger), tab = { label: X.cur.full ? 'Open in full' : 'Open in a new tab', on: () => window.open(X.cur.url, '_blank', 'noopener') };
449
448
  if (at < 0) items.push({ sep: true }, tab); else items.splice(at > 0 && items[at - 1].sep ? at - 1 : at, 0, { sep: true }, tab);
450
449
  }
451
450
  while (items.length && items[0].sep) items.shift();
452
451
  for (let i = items.length - 1; i > 0; i--) if (items[i].sep && items[i - 1].sep) items.splice(i, 1);
452
+ return items;
453
+ }
454
+ /** A phone (phone design, Ph2_init): the page has one ⋯, the menu's (pm/cozy-nav.js). The shown item's own ⋯ items lead that menu, so the
455
+ * item's header has no ⋯ of its own. → [{ label, danger, go }] or [] when no item is shown. */
456
+ /** The presses that lead an item's header (an initiative's kind of work), as ⋯ rows: a phone's item page hides them (cozy-pop-work.css). */
457
+ function leadsOf(X, anchor) {
458
+ return (X.cur.presses || []).filter((x) => x && x.lead && x.act && x.label).map((x) => ({ label: x.label.replace(/\. Tap to change\.$/, ''), on: () => { if (typeof X.cur.onPress === 'function') X.cur.onPress(x.act, anchor); } }));
459
+ }
460
+ export function phoneMoreRows(anchor) {
461
+ const X = ALL.find((x) => x.ph && shown(x)); if (!X) return [];
462
+ // the presses that lead the header (an initiative's kind of work) are hidden on a phone's item page (cozy-pop-work.css): they lead the rows
463
+ return leadsOf(X, anchor).concat(itemsOf(X, anchor)).filter((it) => it && !it.sep && !it.disabled && it.label).map((it) => ({ label: it.label, danger: !!it.danger, go: () => { try { it.on(anchor); } catch (err) { console.error(err); } } }));
464
+ }
465
+ if (typeof window !== 'undefined') window.__czVwMore = phoneMoreRows;
466
+ function moreMenu(b) {
467
+ const old = V.el.querySelector('.cz-vw-menu');
468
+ if (old) { old.remove(); b.setAttribute('aria-expanded', 'false'); return; }
469
+ // a phone (phone design, Ph2_menu): an open item's ⋯ is the screen's one ⋯, so the places follow its own rows (pm/cozy-nav.js)
470
+ const places = typeof window !== 'undefined' && typeof window.__czPhonePlaces === 'function' ? window.__czPhonePlaces() : [];
471
+ const lead = places.length && V.el.querySelector('.pw-ph') ? leadsOf(V, b) : [];
472
+ const items = lead.concat(itemsOf(V, b), places.length ? [{ sep: true }, ...places] : []);
453
473
  const m = document.createElement('div');
454
474
  m.className = 'cz-vw-menu'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'More'); m.dataset.escLayer = '1';
455
475
  m.innerHTML = items.map((it, i) => (it.sep ? '<hr>' : `<button type="button" role="menuitem" data-cz-vw-mi="${i}"${it.danger ? ' class="bad"' : ''}${it.disabled ? ' disabled' : ''}>${it.icon ? svg(path(it.icon), 16) : ''}<span>${esc(it.label)}</span>${it.note || it.hint ? `<span class="k">${esc(it.note || it.hint)}</span>` : ''}</button>`)).join('');
@@ -16,6 +16,8 @@
16
16
  * press (pmPost). Nothing here opens the old dialog or links to the console. */
17
17
  import './fetch-share.js'; // first: identical GETs in flight are asked once (page-open-speed)
18
18
  import { mountNav, openMenu } from './cozy-nav.js';
19
+ import { askGroups, askHtml } from './phone-ask.js'; // Ask PMOS on a phone (phone design, Ph2_asklist): the chats by work
20
+ import { sessionRows } from './pop-sessions.js';
19
21
  import { mountPhoneHead } from './phone-chat-head.js'; // the phone chat's top bar: the context line, its sheet and ⋯ (batch 31 item 5)
20
22
  import { mountSetupChecklist } from './setup-checklist.js';
21
23
  import { mountOnboard } from './cozy-onboard.js';
@@ -287,7 +289,7 @@ function otherProducts(D) {
287
289
  const av = (D.brief && D.brief.products && D.brief.products.available) || [];
288
290
  const own = ((D.board && D.board.board) || {}).ws || WS;
289
291
  // Today reads every product (slice 5 of the six-place navigation): the product pick is Work's and Goals', not Today's
290
- return av.filter((a) => (a.on || (TD_PAGE && !isPhone())) && a.ws && a.ws !== own).slice(0, 4);
292
+ return av.filter((a) => (a.on || TD_PAGE) && a.ws && a.ws !== own).slice(0, 4); // a phone's Today too (phone design, Ph2_today)
291
293
  }
292
294
  async function loadIni() {
293
295
  const id = S.ini;
@@ -370,7 +372,7 @@ function homeListHtml() {
370
372
  S.M = M;
371
373
  // Adler's ears over the floating button (batch 17 item 4-B, AdP6): the place menu hears how many calls are the PM's
372
374
  // on Today (a desk) the number is Today's own (pm/cozy-today-app.js: Do first and what waits today), so it is not sent here
373
- if (!(TD_PAGE && !isPhone())) { const n = (M.move || []).filter((r) => r.call).length; if (n !== S.calls) { S.calls = n; document.dispatchEvent(new CustomEvent('cz:calls', { detail: { count: n } })); } }
375
+ if (!TD_PAGE) { const n = (M.move || []).filter((r) => r.call).length; if (n !== S.calls) { S.calls = n; document.dispatchEvent(new CustomEvent('cz:calls', { detail: { count: n } })); } }
374
376
  // the ✦ chip on "Not in an initiative" is gone (UI grill delete list): Claude's clean-up is a row in Your move (rankIn extra)
375
377
  const R = L.reviewModel(S.D, NOW());
376
378
  // a group is open until the PM folds it; another product starts folded; "Not in an initiative" starts folded on a phone (HvAC, HvACDesk)
@@ -914,8 +916,33 @@ function drawList() {
914
916
  document.body.classList.toggle('hm-plist', isPhone() && !S.phoneChat); // a phone: the list is the page until a row opens its conversation (HmPhone)
915
917
  drawRailCard();
916
918
  drawRecTop();
919
+ drawAsk();
917
920
  if (TDY) TDY.draw(); // Today on a desk (today.html): the log and the agenda, from the same reads
918
921
  }
922
+ /* Ask PMOS on a phone (phone design, board Ph2_asklist): Home's page is the list of chats by work; Home's own list is not drawn there
923
+ * (cozy-home.css). A row opens its chat as Home does; the composer at the foot starts a chat with PMOS. today.html draws Today instead. */
924
+ const ASK_PAGE = new URLSearchParams(location.search).has('chats'); // the menu's Ask PMOS (cozy-nav.js); a bare /premium.html keeps Home's list
925
+ function drawAsk() {
926
+ const on = isPhone() && !TD_PAGE && ASK_PAGE;
927
+ document.body.classList.toggle('pa-on', on);
928
+ let el = document.getElementById('paList');
929
+ if (!on) { if (el) el.hidden = true; return; }
930
+ if (!el) {
931
+ el = document.createElement('section'); el.id = 'paList'; el.className = 'pa-page'; el.setAttribute('aria-label', 'Ask PMOS');
932
+ $('#hmDesk').prepend(el);
933
+ el.addEventListener('click', (e) => {
934
+ const b = e.target.closest('[data-ask-sid], [data-ask-new]'); if (!b) return;
935
+ if ('askNew' in b.dataset) { S.phoneChat = true; VW.close(); openTarget(homeTarget()); drawList(); chat.focus(); return; }
936
+ const sx = (S.D.sessions || []).find((x) => x.id === b.dataset.askSid);
937
+ if (!sx) { toast('That chat has ended. It is not on this computer any more.'); return; }
938
+ S.phoneChat = true; VW.close(); S.sel = 's:' + sx.id; openTarget(sessionTarget(sx)); followViewer(sx); drawList(); chat.focus();
939
+ });
940
+ }
941
+ el.hidden = false;
942
+ const R = sessionRows(S.D.sessions || [], { titleOf: (id) => (iniRowOf(id) ? iniTitle(id) : ''), now: NOW() });
943
+ const h = askHtml(askGroups(R.all, S.D.sessions || [], { titleOf: (id) => (iniRowOf(id) ? iniTitle(id) : ''), now: NOW() }), { ready: S.ready });
944
+ if (el.__h !== h) { el.__h = h; el.innerHTML = h; }
945
+ }
919
946
  /** The list's own fold (batch 20 item 6): kept on this computer, the one thing that folds or unfolds the list. With a Viewer open it is the rail. */
920
947
  function setFold(on) {
921
948
  S.folded = !!on; store.set('pmos.home.fold', on ? '1' : '0'); drawList(); // '0': the PM opened it, and a full Viewer keeps it open from now on
@@ -2417,6 +2444,8 @@ if (TD_PAGE) TDY = mountToday({ S, VW, POP, pmGet, pmPost, toast, toastUndo, isP
2417
2444
  const x = await startAgent({ ws: w.ws || WS || undefined, task: 'draft', initiative: w.initiative, what: w.what }); if (x.ok) started++; else failed++; }
2418
2445
  if (started) load(); return { started, failed, error: started ? '' : 'PMOS did not start them. Nothing changed.' }; },
2419
2446
  openInbox: () => MORE.openInbox(searchGo, ''), reload: () => load(), review: () => L.reviewModel(S.D, NOW()), meetings: () => H.todayOf(S.D), record: (row) => (REC ? REC.record(row) : Promise.resolve({ ok: false, error: 'PMOS is still starting. Press play again in a moment.' })),
2447
+ // the phone's Record with no event (Ph2_today): a recording of its own; the notes, for "Recording filed under …" (Ph2_recdone)
2448
+ fresh: () => (REC ? REC.fresh() : Promise.resolve({ ok: false, error: 'PMOS is still starting. Press Record again in a moment.' })), notes: () => noteRows(),
2420
2449
  news: () => (S.news && S.news.ok ? S.news.count || 0 : 0), chatNow: () => (chat.current ? chat.current() : null),
2421
2450
  openLab: (f) => import('./cozy-lab-ins.js').then((LB) => LB.openLab({ where: () => ({ ws: f.ws, board: f.board }), iniHref: (id) => '/premium-initiative.html?' + (f.ws ? 'ws=' + encodeURIComponent(f.ws) + '&' : '') + 'id=' + encodeURIComponent(id), toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) })) });
2422
2451
  PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m), skip: ['meeting'] }); drawList();
@@ -752,6 +752,14 @@ export function mountChat(el, host) {
752
752
  holdT = setTimeout(() => { unhold(); a.classList.add('held'); }, 450);
753
753
  });
754
754
  for (const ev of ['pointerup', 'pointercancel', 'pointermove']) el.addEventListener(ev, (e) => { if (ev !== 'pointermove' || Math.abs(e.movementX) + Math.abs(e.movementY) > 6) clearTimeout(holdT); });
755
+ /* The phone (phone design, Ph2_ask): the tools and the "Worked …" line show only on a touch of the message, the newest one too. A tap on a
756
+ * message shows them, a second tap or a tap on another message moves them; a press on a link or a button inside does its own job. */
757
+ el.addEventListener('click', (e) => {
758
+ if (!(typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches) || el.closest('.cz-pop-chat')) return;
759
+ const a = e.target.closest('.hm-a'); if (!a || a.classList.contains('hm-intro') || e.target.closest('button, a, input, textarea, select, summary, .hm-tools')) return;
760
+ if (String(getSelection ? getSelection() : '').trim()) return; // selecting words to copy them is not a tap
761
+ const was = a.classList.contains('held'); unhold(); if (!was) a.classList.add('held');
762
+ });
755
763
  el.addEventListener('change', (e) => { if (e.target.id === 'hmFile') { upload([...e.target.files]); e.target.value = ''; } });
756
764
  // a pasted file, or one dropped on the conversation, is attached like a picked one
757
765
  el.addEventListener('paste', (e) => { if (e.target.id !== 'hmIn' || !C.t || !C.t.key) return; const fs = e.clipboardData ? [...e.clipboardData.files] : []; if (!fs.length) return; e.preventDefault(); upload(fs); });