create-pmos 0.712.0 → 0.714.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 (123) hide show
  1. package/package.json +99 -51
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/design-system/ui/README.md +1 -1
  4. package/payload/design-system/ui/components/State/README.md +21 -0
  5. package/payload/design-system/ui/components/State/preview.html +8 -0
  6. package/payload/design-system/ui/components/bundle.css +12 -0
  7. package/payload/design-system/ui/interactions.md +10 -0
  8. package/payload/planning/evals/eval-calibration.md +1 -1
  9. package/payload/planning/okrs/health-budgets.md +1 -1
  10. package/payload/state/discoveries.md +1 -1
  11. package/workspace/bin/back-place-health.js +70 -0
  12. package/workspace/changelog.json +98 -0
  13. package/workspace/design-system/ui/README.md +1 -1
  14. package/workspace/design-system/ui/components/State/README.md +21 -0
  15. package/workspace/design-system/ui/components/State/preview.html +8 -0
  16. package/workspace/design-system/ui/components/bundle.css +12 -0
  17. package/workspace/design-system/ui/interactions.md +10 -0
  18. package/workspace/guide/breakdown.md +20 -1
  19. package/workspace/guide/claude-proposes.md +5 -1
  20. package/workspace/guide/cli.md +10 -1
  21. package/workspace/guide/home.md +1 -0
  22. package/workspace/guide/initiatives-and-next-steps.md +13 -0
  23. package/workspace/guide/layout.md +27 -1
  24. package/workspace/guide/routine.md +10 -2
  25. package/workspace/guide/settings-and-switches.md +4 -0
  26. package/workspace/lib/briefing-premium-products.js +16 -2
  27. package/workspace/lib/changed-mark.js +34 -0
  28. package/workspace/lib/launch-cli.js +43 -5
  29. package/workspace/lib/launch-tiers.js +143 -0
  30. package/workspace/lib/moments.js +41 -3
  31. package/workspace/lib/needs-providers.js +1 -0
  32. package/workspace/lib/parked-cli.js +105 -0
  33. package/workspace/lib/parked-reasons.js +245 -0
  34. package/workspace/lib/pmos-verbs.js +4 -1
  35. package/workspace/lib/prefs-sync.js +138 -0
  36. package/workspace/lib/product-dots.js +60 -0
  37. package/workspace/lib/route-modules.js +2 -0
  38. package/workspace/lib/routes-briefing-premium.js +11 -1
  39. package/workspace/lib/routes-moments.js +1 -1
  40. package/workspace/lib/routes-prefs.js +56 -0
  41. package/workspace/lib/routes-strategy-card.js +53 -0
  42. package/workspace/lib/routes-use-log.js +24 -3
  43. package/workspace/lib/routine-sentence.js +250 -0
  44. package/workspace/lib/strategy-card.js +133 -0
  45. package/workspace/lib/unused-controls.js +178 -0
  46. package/workspace/lib/use-log.js +27 -3
  47. package/workspace/package-lock.json +2 -2
  48. package/workspace/package.json +1 -1
  49. package/workspace/premium-vw-doc-test.js +2 -0
  50. package/workspace/public/pm/action-keys.js +187 -0
  51. package/workspace/public/pm/back-place.js +87 -0
  52. package/workspace/public/pm/bd-pop-ds.css +10 -0
  53. package/workspace/public/pm/bd-pop-ds.js +27 -3
  54. package/workspace/public/pm/bd-strategy.js +85 -0
  55. package/workspace/public/pm/bd-views.js +2 -1
  56. package/workspace/public/pm/changed-mark.css +7 -0
  57. package/workspace/public/pm/changed-mark.js +117 -0
  58. package/workspace/public/pm/cozy-ev.css +7 -0
  59. package/workspace/public/pm/cozy-nav.js +2 -0
  60. package/workspace/public/pm/cozy-pick.css +12 -0
  61. package/workspace/public/pm/cozy-pop-work.css +10 -1
  62. package/workspace/public/pm/cozy-pop-work.js +201 -17
  63. package/workspace/public/pm/cozy-routine-job.js +50 -7
  64. package/workspace/public/pm/cozy-routine.css +2 -0
  65. package/workspace/public/pm/cozy-settings.js +21 -3
  66. package/workspace/public/pm/cozy-today-page.css +1 -0
  67. package/workspace/public/pm/cozy-viewer.css +1 -1
  68. package/workspace/public/pm/cozy-viewer.js +14 -2
  69. package/workspace/public/pm/cozy-vw-mtg.css +0 -2
  70. package/workspace/public/pm/cozy-vw.css +0 -1
  71. package/workspace/public/pm/home-app.js +21 -1
  72. package/workspace/public/pm/home-today.js +2 -0
  73. package/workspace/public/pm/ini-tasks.js +4 -1
  74. package/workspace/public/pm/komorebi.css +11 -0
  75. package/workspace/public/pm/page-chat.js +16 -0
  76. package/workspace/public/pm/prefs-sync.js +111 -0
  77. package/workspace/public/pm/premium-board.js +20 -2
  78. package/workspace/public/pm/premium-chart-tab.js +2 -1
  79. package/workspace/public/pm/premium-insights.js +2 -2
  80. package/workspace/public/pm/premium-mtg-replay.js +4 -3
  81. package/workspace/public/pm/premium-report-read.js +5 -4
  82. package/workspace/public/pm/premium-report-tab.js +4 -3
  83. package/workspace/public/pm/premium-vw-backlog.css +2 -1
  84. package/workspace/public/pm/premium-vw-backlog.js +4 -3
  85. package/workspace/public/pm/premium-vw-cal.css +1 -2
  86. package/workspace/public/pm/premium-vw-cal.js +14 -13
  87. package/workspace/public/pm/premium-vw-copies.js +3 -2
  88. package/workspace/public/pm/premium-vw-copy.css +0 -3
  89. package/workspace/public/pm/premium-vw-mtg.js +12 -11
  90. package/workspace/public/pm/product-switcher.js +41 -0
  91. package/workspace/public/pm/quiet-place.js +15 -2
  92. package/workspace/public/pm/report-orders-ui.js +2 -1
  93. package/workspace/public/pm/rp-parts.js +3 -2
  94. package/workspace/public/pm/state-blocks.js +67 -0
  95. package/workspace/public/pm/use-log.js +127 -1
  96. package/workspace/public/pm/work-select.js +92 -2
  97. package/workspace/public/pm/work-tree.js +70 -0
  98. package/workspace/public/premium-aud.html +1 -0
  99. package/workspace/public/premium-board.html +5 -0
  100. package/workspace/public/premium-buddy.html +1 -0
  101. package/workspace/public/premium-events.html +1 -0
  102. package/workspace/public/premium-goals.html +1 -0
  103. package/workspace/public/premium-intelligence.html +1 -0
  104. package/workspace/public/premium-library.html +1 -0
  105. package/workspace/public/premium-present.html +1 -0
  106. package/workspace/public/premium-rec.html +1 -0
  107. package/workspace/public/premium-routine.html +1 -0
  108. package/workspace/public/premium-viewer.html +1 -0
  109. package/workspace/public/premium-workflows.html +1 -0
  110. package/workspace/public/today.html +1 -0
  111. package/workspace/server.js +20 -0
  112. package/workspace/test-lists/action-keys.json +9 -0
  113. package/workspace/test-lists/back-place.json +9 -0
  114. package/workspace/test-lists/changed-mark.json +9 -0
  115. package/workspace/test-lists/launch-tiers.json +9 -0
  116. package/workspace/test-lists/parked-reasons.json +9 -0
  117. package/workspace/test-lists/prefs-follow-person.json +9 -0
  118. package/workspace/test-lists/product-switcher-dots.json +9 -0
  119. package/workspace/test-lists/routine-sentence.json +9 -0
  120. package/workspace/test-lists/shared-empty-states.json +9 -0
  121. package/workspace/test-lists/strategy-card.json +9 -0
  122. package/workspace/test-lists/unused-controls.json +9 -0
  123. package/workspace/test-lists/work-subtasks-followups.json +9 -0
@@ -23,6 +23,7 @@ import { open as vOpen, current as vCur, czSummary, setWidth, widthOf } from './
23
23
  import { pmGet } from './http.js';
24
24
  import { notesCards } from './premium-vw-notes.js';
25
25
  import './premium-vw-open.js'; // registers window.czViews
26
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
26
27
 
27
28
  export const VIEWS = [['day', 'Day'], ['week', 'Week'], ['month', 'Month']];
28
29
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -130,9 +131,9 @@ export function calHtml(M, esc, nowMin = null) {
130
131
  const seg = `<div class="vc-seg" role="group" aria-label="Calendar view">${VIEWS.map(([k, l]) => `<button type="button" data-cv="${k}" aria-pressed="${M.view === k}">${l}</button>`).join('')}</div>`;
131
132
  const step = M.view === 'day' ? 'day' : M.view === 'week' ? 'week' : 'month';
132
133
  const head = `<div class="vc-h"><button type="button" class="vc-ib" data-cn="-1" aria-label="Previous ${step}">${ic('back')}</button><button type="button" class="vc-ib" data-cn="1" aria-label="Next ${step}">${ic('next')}</button><button type="button" class="vc-tdy" data-cn="0">Today</button><b class="vc-t">${esc(M.title)}</b><small class="vc-cap">${esc(M.caption)}</small>${seg}</div>`;
133
- if (M.state !== 'ok') return `<div class="vc-w">${head}<p class="vc-empty" role="status">Calendar not read. ${esc(M.reason)}</p></div>`;
134
+ if (M.state !== 'ok') return `<div class="vc-w">${head}${SB.error('Calendar not read. ' + (M.reason || ''))}</div>`;
134
135
  const chip = (a) => a.row ? `<button type="button" class="vc-ad meet" data-ev="${esc(a.ref)}" title="${esc(a.title + ', all day')}">${esc(a.title)}</button>` : `<span class="vc-ad ${esc(a.kind)}${a.tone ? ' t-' + esc(a.tone) : ''}" title="${esc(a.title)}">${esc(a.title)}</span>`;
135
- const empty = M.empty ? `<p class="vc-empty" role="status">${esc(M.empty)}</p>` : '';
136
+ const empty = M.empty ? SB.empty(M.empty) : '';
136
137
  if (M.view === 'month') {
137
138
  const cells = M.days.map((x) => {
138
139
  const ev = [...x.allday.filter((a) => a.row), ...x.timed].sort((a, b) => (a.s || 0) - (b.s || 0));
@@ -281,8 +282,8 @@ export function calSummary(TD) {
281
282
  /** The day (XvACal): the five weekdays with their load bars, then one list, each entry at its time. A day other than today says its count. */
282
283
  export function dayHtml(strip, D, isToday = false) {
283
284
  const h = [`<div class="vzc-days" role="group" aria-label="This week">${strip.map((d) => `<button type="button" class="vzc-dy${d.today ? ' now' : ''}" aria-pressed="${d.on}" data-c="day" data-k="${d.key}" aria-label="${esc(d.dow + ' ' + d.n + (d.today ? ', today' : '') + ': ' + plural(d.count, 'meeting'))}"><span>${d.dow}</span><b>${d.n}</b><span class="vzc-lb" data-tl="${Math.round(d.bar * 100)}%"><i></i></span></button>`).join('')}</div>`];
284
- if (D.state === 'error') return h.join('') + `<p class="vz-empty" role="status">The calendar was not read. ${esc(D.reason || '')}</p>`;
285
- if (!D.rows.length) return h.join('') + '<p class="vz-empty">No meetings on this day.</p>';
285
+ if (D.state === 'error') return h.join('') + SB.error('The calendar was not read. ' + (D.reason || ''));
286
+ if (!D.rows.length) return h.join('') + SB.empty('No meetings on this day.');
286
287
  if (!isToday) { const mins = D.rows.reduce((a, r) => a + (r.mins || 0), 0), allEv = D.rows.every((r) => r.kind === 'event'); h.push(`<p class="vzc-mut">${esc(D.title)} · ${allEv ? plural(D.rows.length, 'meeting') : plural(D.rows.length, 'entry', 'entries')}${mins ? ' · ' + hrsText(mins) : ''}</p>`); }
287
288
  h.push(`<div class="vzc-list">${D.rows.map((r, i) => `<button type="button" class="vzc-de vz-hv${r.ended ? ' past' : ''}" data-c="open" data-i="${i}"${r.next ? ' data-next' : ''}><span class="vzc-t">${esc(r.time)}</span><span class="vzc-dt"><b>${esc(r.title)}</b><small>${esc(r.sub)}</small></span>${r.chip === 'Link it' ? `<span class="vz-cc vzc-link" data-c="link" data-i="${i}" role="button" tabindex="0" title="Link it to an initiative">Link it</span>` : r.chip ? chipHtml(r.chip, r.k) : r.next ? '<i class="vzc-nx" aria-label="Next"></i>' : ''}</button>`).join('')}</div>`);
288
289
  return h.join('');
@@ -306,20 +307,20 @@ export function calViewHtml(st, X) {
306
307
  if (S) h.push(czSummary(S));
307
308
  if (st.view !== 'day') h.push(`<div class="vzc-head"><h2 class="vzm-h2">${esc(rangeTitle(st.view, st.date, X.today))}</h2><button type="button" class="vzm-ib vz-hv" data-c="nav" data-k="-1" aria-label="Previous ${st.view}">${sv('prev')}</button><button type="button" class="vzm-ib vz-hv" data-c="nav" data-k="1" aria-label="Next ${st.view}">${sv('next')}</button><button type="button" class="vzm-btn vzm-soft" data-c="nav" data-k="0">Today</button><span class="vz-sp"></span><button type="button" class="vzm-btn vzm-soft" data-c="view" data-k="day">Day</button></div>`);
308
309
  const M = X.M;
309
- if (!M) h.push('<p class="vz-empty" role="status">Reading the calendar PMOS holds.</p>');
310
- else if (M.state !== 'ok' && st.view !== 'day') h.push(`<p class="vz-empty" role="status">The calendar was not read. ${esc(M.reason || '')}</p>`);
311
- else if (st.view === 'week') h.push(weekHtml(M, X.notes, X.nowMin) + (M.empty ? `<p class="vz-empty" role="status">${esc(M.empty)}</p>` : ''));
312
- else if (st.view === 'month') h.push(monthHtml(M) + (M.empty ? `<p class="vz-empty" role="status">${esc(M.empty)}</p>` : ''));
313
- else h.push(X.day ? dayHtml(X.strip, X.day, st.date === X.today) : '<p class="vz-empty" role="status">Reading the calendar PMOS holds.</p>');
310
+ if (!M) h.push(SB.loading('Reading the calendar PMOS holds.'));
311
+ else if (M.state !== 'ok' && st.view !== 'day') h.push(SB.error('The calendar was not read. ' + (M.reason || '')));
312
+ else if (st.view === 'week') h.push(weekHtml(M, X.notes, X.nowMin) + (M.empty ? SB.empty(M.empty) : ''));
313
+ else if (st.view === 'month') h.push(monthHtml(M) + (M.empty ? SB.empty(M.empty) : ''));
314
+ else h.push(X.day ? dayHtml(X.strip, X.day, st.date === X.today) : SB.loading('Reading the calendar PMOS holds.'));
314
315
  if (st.view !== 'day') h.push(`<div class="vzc-leg"><span><i class="vzc-sw"></i>Linked</span><span><i class="vzc-sw un"></i>Not linked</span><span class="vz-sp"></span><span title="${esc(CAL_FOOT)}">${esc(CAL_HINT)}</span></div>`);
315
316
  } else {
316
317
  const C = X.cards;
317
318
  h.push(`<div class="vzm-in vzc-find">${sv('find')}<input type="search" data-c="q" aria-label="${esc(SEARCH_HINT)}" placeholder="${esc(SEARCH_HINT)}" value="${esc(st.q || '')}">${st.q ? `<span class="vzc-mut">${C && C.state === 'ok' ? plural(C.count, 'note') : ''}</span><button type="button" class="vzm-ib vz-hv" data-c="clear" aria-label="Clear the search">${sv('x', 14)}</button>` : ''}</div>`);
318
319
  h.push(`<div class="vzc-chips" role="group" aria-label="Show">${NOTE_FILTERS.map(([k, l]) => `<button type="button" class="vzm-chip${(st.filter || 'all') === k ? ' on' : ''}" data-c="filter" data-k="${k}" aria-pressed="${(st.filter || 'all') === k}">${l}</button>`).join('')}</div>`);
319
- if (!C) h.push('<p class="vz-empty" role="status">Reading the notes.</p>');
320
- else if (C.state === 'error') h.push(`<p class="vz-empty" role="status">The notes could not be read. ${esc(C.error)}</p>`);
321
- else if (!C.total) h.push('<p class="vz-empty">No notes yet. Notes you record show here, grouped by initiative.</p>');
322
- else if (!C.groups.length) h.push(`<p class="vz-empty" role="status">${st.searching ? 'Searching what was said.' : st.q ? 'No note matches “' + esc(st.q) + '”.' : 'No note of this kind.'}</p>`);
320
+ if (!C) h.push(SB.loading('Reading the notes.'));
321
+ else if (C.state === 'error') h.push(SB.error('The notes could not be read. ' + (C.error || '')));
322
+ else if (!C.total) h.push(SB.empty('No notes yet. Notes you record show here, grouped by initiative.'));
323
+ else if (!C.groups.length) h.push((st.searching ? SB.loading('Searching what was said.') : SB.empty(st.q ? 'No note matches “' + st.q + '”.' : 'No note of this kind.')));
323
324
  else C.groups.forEach((g) => h.push(`<section class="vzc-grp"><p class="vzm-lbl">${esc(g.title)} <small>${esc(g.n)}</small></p>${g.entries.map((e) => entryHtml(e, st)).join('')}</section>`));
324
325
  }
325
326
  return `<div class="vz vz-cal" data-tab="${st.tab}" data-view="${st.view}">${h.join('')}</div>`;
@@ -10,6 +10,7 @@
10
10
  import { vwOpen, vwStyle } from './premium-viewer.js';
11
11
  import { pmGet, pmPost } from './http.js';
12
12
  import { mdHtml, copyKindOf } from './premium-doc-edit.js';
13
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
13
14
 
14
15
  const TOOL = { google: 'Google Docs', confluence: 'Confluence', 'google-slides': 'Google Slides', 'google-sheets': 'Google Sheets' };
15
16
  const COPY = { google: 'the Google Doc', confluence: 'the Confluence page', 'google-slides': 'the slides', 'google-sheets': 'the sheet' };
@@ -86,9 +87,9 @@ export function openCopy(o) {
86
87
  }
87
88
  const head = `<div class="cpv-bar">${ICON(kind)}<div><b>${t}</b><small>${esc(tool)}${where}</small></div><span class="chp"><i></i>${r.state === 'reading' ? 'Reading' : 'Link only'}</span></div>`;
88
89
  if (r.state === 'reading') return `<div class="cpv">${head}<p class="note">A session is reading the page with your ${esc(tool)} connector${r.since ? ' (started ' + esc(r.since) + ')' : ''}. The text shows here when it is done.</p><div class="cpv-acts">${ext(o.url, tool)}</div></div>`;
89
- return `<div class="cpv">${head}<div class="cpv-empty"><b>PMOS has only the address of this page.</b><p>It was added as a link, so PMOS holds no text to show here.</p>`
90
+ return `<div class="cpv">${head}${SB.empty('PMOS has only the address of this page. It was added as a link, so PMOS holds no text to show here.')}`
90
91
  + `<div class="cpv-acts">${r.state === 'none' ? `<button type="button" class="dmcta" data-cp="read"${S.busy ? ' disabled' : ''}>Read it now</button>` : ''}${ext(o.url, tool)}</div>`
91
- + `<p class="note">${r.state === 'error' ? esc(r.error) : r.failed ? 'The last read did not finish: ' + esc(r.failed) + '. Press Read it now to try again.' : `Read it now starts one session that reads the page with your ${esc(tool)} connector and keeps the text in PMOS. It changes nothing in ${esc(tool)}.`}</p></div></div>`;
92
+ + `<p class="note">${r.state === 'error' ? esc(r.error) : r.failed ? 'The last read did not finish: ' + esc(r.failed) + '. Press Read it now to try again.' : `Read it now starts one session that reads the page with your ${esc(tool)} connector and keeps the text in PMOS. It changes nothing in ${esc(tool)}.`}</p></div>`;
92
93
  }
93
94
  async function load() {
94
95
  S.err = '';
@@ -14,9 +14,6 @@
14
14
  .cpv-why code{font-size:var(--fs-meta);line-height:var(--lh-meta);}
15
15
  .cpv-acts{display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-8)}
16
16
  .cpv-acts .dmcta{border-radius:var(--radius-sm);text-decoration:none}
17
- .cpv-empty{display:grid;gap:var(--space-8);padding:18px 20px;border:1px dashed var(--ink-3);border-radius:8px;color:var(--ink-2)}
18
- .cpv-empty b{font-size:var(--fs-row);font-weight:var(--fw-strong);color:var(--ink);line-height:var(--lh-row);}
19
- .cpv-empty p{margin:0;font-size:var(--fs-body);line-height:var(--lh-body);}
20
17
  .cpv-page{padding:18px 22px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid)}
21
18
  .cpv-page.dim{opacity:.62}
22
19
  @media (max-width:700px){
@@ -45,6 +45,7 @@ import { replayView, phoneHtml, editHtml, mentions, phraseOf as phraseOfPage, de
45
45
  import { announce } from './rec-state.js';
46
46
  import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, Present goes to the recording tab (batch 12 item 1, rule 10)
47
47
  import { factsOf } from './meeting-share.js'; // the facts mentioned: one list for the note and a shared copy (shareable-meeting-notes)
48
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
48
49
  export { factsOf };
49
50
 
50
51
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
@@ -356,7 +357,7 @@ export function summaryHtml(m, ui = {}) {
356
357
 
357
358
  function agendaHtml(P) {
358
359
  return P.agenda.length ? `<div class="vzm-agl">${P.agenda.map((a, i) => `<div class="vz-ag"><i class="vz-num" aria-hidden="true">${a.n}</i><span>${esc(a.text)}</span><button type="button" class="vz-min vz-hv" data-a="min" data-i="${i}" title="Change the minutes for this topic" aria-label="${esc(a.text)}: ${a.min} minutes. Change">${a.min} min</button></div>`).join('')}</div>`
359
- : '<p class="vz-empty">The invite lists no topics yet.</p>';
360
+ : SB.empty('The invite lists no topics yet.');
360
361
  }
361
362
  /** Tagged rows (What matters, Since the last one, Facts). W: the word fixes, shown in the words (Facts, batch 27 item 12). */
362
363
  const tagRows = (rows, W) => rows.map((x) => `<div class="vz-tagrow"><span class="vz-tag" data-k="${x.k}">${esc(x.tag)}</span><span><span class="vz-said">${W ? wx(W, x.text) : esc(x.text)}</span> <small>${esc(x.meta || x.owner || x.src || '')}</small></span></div>`).join('');
@@ -379,19 +380,19 @@ const hlHtml = (L) => L.hl.map((x) => `<div class="vz-hl"><time>${esc(x.t)}</tim
379
380
  function caughtHtml(m) {
380
381
  const L = m.live, Fo = m.focus, h = [];
381
382
  if (Fo.gist) h.push(`<p class="vz-p">${esc('So far: ' + Fo.gist)}</p>`);
382
- else if (Fo.error) h.push(`<p class="vz-empty">${esc(Fo.error)}</p>`);
383
+ else if (Fo.error) h.push(SB.error(Fo.error));
383
384
  if (L.topics.length) h.push(weightBar('vz-stretch', L.topics.map((t) => ({ w: +t.flex || 1, attrs: ` data-k="${t.k}"` }))));
384
- return h.join('') || '<p class="vz-empty">What was said shows here while the note records.</p>';
385
+ return h.join('') || SB.empty('What was said shows here while the note records.');
385
386
  }
386
387
  /** The live Agenda: the 3 to 5 topics (pm/agenda-live.js) when the read has them. No Change topic: PMOS follows the talk, the PM says Not this one. */
387
388
  function liveAgendaHtml(m) {
388
389
  const Fo = m.focus;
389
390
  if (Fo.model) return mergedAgendaHtml(Fo.model);
390
- return (Fo.agenda.length ? Fo.agenda.map((a) => `<div class="vzm-ag" data-k="${a.k}"><span>${a.k === 'now' || a.k === 'late' ? `<b>${a.n} ${esc(a.text)}</b>` : esc(a.n + ' ' + a.text)}</span>${fillBar(a.fill, a.k)}<small>${esc(a.say)}</small></div>`).join('') : '<p class="vz-empty">The invite lists no topics yet.</p>');
391
+ return (Fo.agenda.length ? Fo.agenda.map((a) => `<div class="vzm-ag" data-k="${a.k}"><span>${a.k === 'now' || a.k === 'late' ? `<b>${a.n} ${esc(a.text)}</b>` : esc(a.n + ' ' + a.text)}</span>${fillBar(a.fill, a.k)}<small>${esc(a.say)}</small></div>`).join('') : SB.empty('The invite lists no topics yet.'));
391
392
  }
392
393
  function transcriptHtml(m, ui, lines, seek) {
393
394
  const W = m.notes && m.notes.replay ? m.notes.replay.W : null; // the word fixes (MvF) show in the transcript too
394
- return (lines.length ? lines.map((l, i) => lineHtml(l, i, ui, seek, W)).join('') : `<p class="vz-empty">${m.private ? 'This note is private: only what you type is kept.' : m.mk === 'live' ? 'Nothing has been said yet.' : 'Nothing was transcribed.'}</p>`)
395
+ return (lines.length ? lines.map((l, i) => lineHtml(l, i, ui, seek, W)).join('') : SB.empty(m.private ? 'This note is private: only what you type is kept.' : m.mk === 'live' ? 'Nothing has been said yet.' : 'Nothing was transcribed.'))
395
396
  + `<p class="vz-note vz-fine">${esc(LIVE_FOOT)}</p>`;
396
397
  }
397
398
  function stepHtml(a, ui, W) {
@@ -532,7 +533,7 @@ export function heldHtml(m, ui = {}, ctx = {}) {
532
533
  + `<button type="button" class="y" data-a="h-add" aria-label="Yes, add ${n === 1 ? 'it' : 'them'}" title="Yes, add ${n === 1 ? 'it' : 'them'}">${svg('check', 14)}</button><button type="button" data-a="h-no" aria-label="No" title="No">${svg('x', 14)}</button></div></div>`);
533
534
  }
534
535
  if (H.notes.length) h.push('<h6>Notes</h6><ul>' + H.notes.map((t) => `<li>${esc(t)}</li>`).join('') + '</ul>');
535
- if (!H.lead && !H.decisions.length && !H.tasks.length && !H.notes.length) h.push(`<p class="vz-empty">${esc(NO_NOTES)}</p>`);
536
+ if (!H.lead && !H.decisions.length && !H.tasks.length && !H.notes.length) h.push(SB.empty(NO_NOTES));
536
537
  const about = H.about ? `<button type="button" class="vzh-sel" data-a="${H.ini ? 'h-ini' : 'm-about'}" title="${esc(m.about)}"><span>${esc(H.about)}</span>${svg('next', 14)}</button>` : `<button type="button" class="vzh-sel" data-a="m-about">Link it</button>`;
537
538
  const side = ['<h6>The meeting</h6>',
538
539
  H.held ? `<div class="r"><span>Held</span><em>${esc(H.held)}</em></div>` : '',
@@ -559,8 +560,8 @@ export function matPopHtml(P) {
559
560
  }
560
561
  export function matListHtml(P) {
561
562
  const items = P.q ? P.found : P.sug;
562
- if (!items) return P.q ? '<p class="vz-empty">Looking in PMOS.</p>' : '';
563
- if (!items.length) return P.q ? '<p class="vz-empty">Nothing in PMOS matches. Paste a link instead.</p>' : '';
563
+ if (!items) return P.q ? SB.loading('Looking in PMOS.', { rows: 2 }) : '';
564
+ if (!items.length) return P.q ? SB.empty('Nothing in PMOS matches. Paste a link instead.') : '';
564
565
  return `<p class="vzm-mlbl">${P.q ? 'Found in PMOS' : 'Suggested for this meeting'}</p>` + items.map((it, i) => `<button type="button" class="vzm-mi2 vz-hv" data-a="matadd" data-i="${i}">${svg(it.kind === 'pmos-deck' ? 'deck' : it.kind === 'board' ? 'board' : 'doc', 16)}<span class="vzm-grow">${esc(clip(it.title, 80))}${it.meta ? `<br><span class="vzm-sm vzm-mut">${esc(clip(it.meta, 80))}</span>` : ''}</span><span class="vzm-k">Add</span></button>`).join('');
565
566
  }
566
567
  /** What it is about's popover (MtAfter). O = aboutOptions(), q = the find text */
@@ -571,7 +572,7 @@ export function aboutListHtml(O, q = '') {
571
572
  const words = norm(q).split(' ').filter(Boolean), hit = (x) => words.every((w) => norm(x.label).includes(w));
572
573
  const item = (x, ic, hl) => `<button type="button" class="vzm-mi2 vz-hv${hl ? ' hl' : ''}" data-a="aboutpick" data-v="${esc(x.v)}"${x.v === O.cur ? ' aria-current="true"' : ''}>${svg(ic, 16)}<span class="vzm-grow">${esc(x.label)}${x.sub ? `<br><span class="vzm-sm vzm-mut">${esc(x.sub)}</span>` : ''}</span>${x.v === O.cur ? svg('check', 14) : ''}</button>`;
573
574
  const h = [];
574
- if (words.length) { const f = O.initiatives.filter(hit).slice(0, 8); h.push(`<p class="vzm-mlbl">Initiatives</p>${f.length ? f.map((x) => item(x, 'flag')).join('') : '<p class="vz-empty">No initiative has that name.</p>'}`); }
575
+ if (words.length) { const f = O.initiatives.filter(hit).slice(0, 8); h.push(`<p class="vzm-mlbl">Initiatives</p>${f.length ? f.map((x) => item(x, 'flag')).join('') : SB.empty('No initiative has that name.')}`); }
575
576
  else if (O.suggested.length) h.push(`<p class="vzm-mlbl">Suggested from the notes</p>${O.suggested.map((x) => item(x, 'flag', true)).join('')}`);
576
577
  else if (O.initiatives.length) h.push(`<p class="vzm-mlbl">Initiatives</p>${O.initiatives.slice(0, 5).map((x) => item(x, 'flag')).join('')}`);
577
578
  h.push(`<p class="vzm-mlbl">Or</p>${O.boards.filter((x) => !words.length || hit(x)).map((x) => item(x, 'prod')).join('')}${item(O.portfolio, 'board')}${item(O.none, 'x')}`);
@@ -620,7 +621,7 @@ export async function openMeeting(ref, o = {}) {
620
621
  if (MT) { MT.alive = false; MT.timers.forEach(clearInterval); stopPlay(MT); }
621
622
  MT = me;
622
623
  const id = 'meeting:' + (R.note || R.event || R.title || 'new');
623
- const draw0 = (body) => { body.innerHTML = '<div class="vz"><p class="vz-empty" role="status">Reading the meeting.</p></div>'; };
624
+ const draw0 = (body) => { body.innerHTML = '<div class="vz">' + SB.loading('Reading the meeting.') + '</div>'; };
624
625
  me.vid = id;
625
626
  vOpen({ id, kind: 'Meeting', title: R.title || 'Meeting', icon: CLOCK_ICON, url: meetingUrl({ ...R, ws: me.ws }), render: draw0, onClose: () => closed(me) });
626
627
  widen('mtg');
@@ -834,7 +835,7 @@ function placePop(me, body) {
834
835
  const P = me.ui.pop; if (P !== 'mat' && P !== 'about') return;
835
836
  const anc = P === 'mat' ? shown(body, '[data-pop="mat"]') : body.querySelector('[data-pop="head"]'); if (!anc) return;
836
837
  if (P === 'mat') { anc.innerHTML = matPopHtml(me.mat || { row: me.row }); if (!me.matShown && anc.scrollIntoView) { me.matShown = true; anc.scrollIntoView({ block: 'nearest' }); } }
837
- else anc.innerHTML = me.about ? aboutPopHtml(me.about, me.aboutQ || '', me.row ? 'Applies to every meeting of “' + me.row.title + '”. The calendar itself is never written.' : 'Applies to this note.') : '<div class="vzm-pop"><p class="vz-empty">Reading what it can be about.</p></div>';
838
+ else anc.innerHTML = me.about ? aboutPopHtml(me.about, me.aboutQ || '', me.row ? 'Applies to every meeting of “' + me.row.title + '”. The calendar itself is never written.' : 'Applies to this note.') : '<div class="vzm-pop">' + SB.loading('Reading what it can be about.', { rows: 2 }) + '</div>';
838
839
  }
839
840
  function keydown(me, e, body) {
840
841
  const a = e.target.dataset && e.target.dataset.a;
@@ -0,0 +1,41 @@
1
+ /* pm/product-switcher.js — the product switcher row (bet A381, initiative product-switcher-dots). One quiet row of product tiles on Today
2
+ * and Work. A tile carries one blue dot when its product has rows that need the PM (GET /api/briefing-premium/products?needs=1, from
3
+ * lib/product-dots.js): no count, and no dot at zero or before the product is read (zero is silence, honest state).
4
+ *
5
+ * readDots() → the pick with `needs` on each product, or null
6
+ * switcherHtml(P, o) PURE. The row: '' for fewer than two products. o.tones: the page's tints (cozy-pick.js tonesOf), o.cls: an extra class
7
+ * pressOf(P, ws) PURE. The pick a press saves: that product alone, or every product when it is already shown alone
8
+ * press(P, ws) saves pressOf with savePick, so every page follows (pp:changed) → savePick's answer
9
+ *
10
+ * Each tile is a button with data-psw, so the local use log (pm/use-log.js, A466) counts the presses: the outcome check reads them with
11
+ * node workspace/lib/product-dots.js count. Tiles, letters and tints are the product chip's own (cozy-pick.js). */
12
+ import { pmGet } from './http.js';
13
+ import { codeOf, tonesOf, savePick } from './cozy-pick.js';
14
+ import { productName } from './scope-chip.js';
15
+
16
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
17
+ const nameOf = (p) => productName(p && p.ws, (p && p.name) || '');
18
+
19
+ export async function readDots() { const r = await pmGet('/api/briefing-premium/products?needs=1'); return r && r.ok && Array.isArray(r.products) ? r : null; }
20
+
21
+ /** The one product shown alone, or null when two or more are shown. */
22
+ const aloneOf = (P) => { const on = P.products.filter((p) => p.on); return on.length === 1 ? on[0].ws : null; };
23
+
24
+ export function switcherHtml(P, o = {}) {
25
+ if (!P || !Array.isArray(P.products) || P.products.length < 2) return '';
26
+ const T = o.tones || tonesOf(P.products), alone = aloneOf(P);
27
+ const tiles = P.products.map((p) => {
28
+ const n = Number.isInteger(p.needs) ? p.needs : 0, nm = nameOf(p);
29
+ const words = n > 0 ? nm + ', ' + n + ' need' + (n === 1 ? 's' : '') + ' you' : nm;
30
+ return `<button type="button" class="psw-b" data-psw="${esc(p.ws)}" aria-pressed="${p.ws === alone}" aria-label="${esc(words)}" title="${esc(words)}">`
31
+ + `<i class="ppk-t t${T[p.ws] || 0}" aria-hidden="true">${esc(codeOf(p))}</i>${n > 0 ? '<i class="psw-dot" aria-hidden="true"></i>' : ''}</button>`;
32
+ }).join('');
33
+ return `<div class="psw${o.cls ? ' ' + esc(o.cls) : ''}" role="group" aria-label="Switch product">${tiles}</div>`;
34
+ }
35
+
36
+ export function pressOf(P, ws) {
37
+ const all = P.products.map((p) => p.ws);
38
+ return aloneOf(P) === ws ? all : [ws];
39
+ }
40
+
41
+ export const press = (P, ws) => savePick(pressOf(P, ws));
@@ -5,8 +5,12 @@
5
5
  * quietPlace(place, stage) follows the menu's read of GET /api/moments (the event 'cz:moments' from pm/cozy-nav.js): while the place is
6
6
  * quiet, the page's panel shows only its line; the moment it opens, the page is back as it was
7
7
  * quietLine(place) the line while that place is quiet, else '' (Intelligence's reports panel uses it for its empty state)
8
+ * quietNext(place) the one next step that fills the place, as state-blocks.js next() draws it, else '' (initiative
9
+ * empty-page-next-action: Make initiatives from the Jira epics PMOS read · Draft from the strategy · Paste a list)
8
10
  * A published (read-only) copy is never quiet. Quiet only applies when every workspace on this computer is new and none has reached that
9
11
  * place, so a PMOS already in use never loses a page. */
12
+ import { next } from './state-blocks.js';
13
+
10
14
  let last = null;
11
15
  if (typeof document !== 'undefined') document.addEventListener('cz:moments', (e) => { last = e.detail || null; });
12
16
 
@@ -16,14 +20,23 @@ export const quietLine = (place) => {
16
20
  return p && p.quiet ? String(p.line || '') : '';
17
21
  };
18
22
 
23
+ export const quietNext = (place) => {
24
+ if (!quietLine(place)) return '';
25
+ const p = last.places[place];
26
+ return next(p && p.next);
27
+ };
28
+
19
29
  export function quietPlace(place, stage, doc = document) {
20
30
  if (!stage || (typeof window !== 'undefined' && window.PMOS_READONLY)) return;
21
31
  const draw = () => {
22
32
  const line = quietLine(place);
23
33
  let el = stage.querySelector(':scope > .qp-line');
24
34
  if (!line) { stage.classList.remove('qp-on'); if (el) el.remove(); return; }
25
- if (!el) { el = doc.createElement('p'); el.className = 'qp-line'; el.setAttribute('role', 'status'); stage.prepend(el); }
26
- el.textContent = line;
35
+ if (!el) { el = doc.createElement('div'); el.className = 'qp-line'; stage.prepend(el); }
36
+ const p = doc.createElement('p'); p.setAttribute('role', 'status'); p.textContent = line;
37
+ el.replaceChildren(p);
38
+ const step = quietNext(place);
39
+ if (step) el.insertAdjacentHTML('beforeend', step);
27
40
  stage.classList.add('qp-on');
28
41
  };
29
42
  doc.addEventListener('cz:moments', () => setTimeout(draw, 0));
@@ -11,6 +11,7 @@
11
11
  * Use from the next cycle on an agreed outline). Rename and Delete on Mine only.
12
12
  * S = the GET answer · G = { sel, i, ren } · o = { esc, ic, slideCard, pics(id) → [slide] | null, now: [slide], busy, hidden: Set, issued }
13
13
  */
14
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
14
15
 
15
16
  const keyOf = (S, k) => k + ':' + (S && S.slot) + ':' + ((S && S.pick && S.pick.id) || (S && S.now && S.now.id) || '');
16
17
  export const hideKey = keyOf;
@@ -79,7 +80,7 @@ function cardHtml(S, o, c) {
79
80
  }
80
81
  /** The gallery (TpD), or one order pressed open. */
81
82
  export function galHtml(S, G, o) {
82
- if (!S || !S.ok) return '<p class="vz-empty" role="status">Reading the orders.</p>';
83
+ if (!S || !S.ok) return SB.loading('Reading the orders.');
83
84
  const e = o.esc;
84
85
  const close = `<button type="button" class="rp-tl vz-hv ro-ib" data-r="ord|close" aria-label="Close the orders" title="Close">${o.ic('x', 16)}</button>`;
85
86
  if (G.sel) return detailHtml(S, G, o);
@@ -18,6 +18,7 @@
18
18
  * THE RULE (as the premium models): every number, date and chip comes from a field of a record. Where a record is silent the part says so or
19
19
  * is left out; nothing is filled with a guess. */
20
20
  import { tableStarts, readTable, tableHtml } from './md-table.js';
21
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
21
22
 
22
23
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
23
24
  const inline = (s) => esc(s).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>').replace(/`([^`]+)`/g, '<code>$1</code>');
@@ -127,7 +128,7 @@ export function briefLooksHtml(B, o = {}) {
127
128
  }
128
129
  /** The whole Brief as html, its four groups in order. o = { issued, busy, msg } */
129
130
  export function briefHtml(B, o = {}) {
130
- if (!B) return '<p class="vz-empty" role="status">Reading how this report is made.</p>';
131
+ if (!B) return SB.loading('Reading how this report is made.');
131
132
  return `<div class="rp-brief"><p class="rp-lbl">At a glance</p>${briefGlanceHtml(B)}<p class="rp-lbl">Please confirm</p>${briefConfirmHtml(B, o)}<p class="rp-lbl">Why it looks like this</p>${briefWhyHtml(B)}${briefLooksHtml(B, o)}`
132
133
  + (o.msg ? `<p class="vz-msg" role="status">${esc(o.msg)}</p>` : '') + '</div>';
133
134
  }
@@ -329,7 +330,7 @@ function chartSvg(c, hover) {
329
330
  }
330
331
  /** The live page as html. s = { name, audience, period, issued, readAgo, hover, products } */
331
332
  export function liveHtml(L, s = {}) {
332
- if (!L) return '<p class="vz-empty" role="status">Reading the numbers.</p>';
333
+ if (!L) return SB.loading('Reading the numbers.');
333
334
  const head = `<div class="rp-lvh"><div class="rp-grow"><p class="rp-lbl">${esc((s.audience ? s.audience + ' · ' : '') + 'live')}</p><h2 class="rp-h2">${esc(s.name || 'Report')}</h2></div>`
334
335
  + `<span class="rp-per" title="${s.issued ? 'An issued cycle shows its numbers as they were on its day' : 'The numbers as they are now'}">${esc(s.period || 'Now')}</span>`
335
336
  + `<button type="button" class="cz-pick" data-r="lv|prod" aria-haspopup="menu" aria-expanded="${!!s.prodOpen}">${esc((L.board && L.board.name) || 'This product')}${SV('M7 10l5 5 5-5', 14)}</button>`
@@ -0,0 +1,67 @@
1
+ /* state-blocks.js — the three states every block has, drawn once (Komorebi part State; initiative shared-empty-states).
2
+ *
3
+ * empty(line, { step }) one quiet line, and the one next step when there is one. Never "0 items".
4
+ * loading(what, { rows }) soft placeholder rows in the block's own place (3 by default). No text on screen, no spinner;
5
+ * a screen reader hears `what` ("Reading the report.").
6
+ * error(line, { retry }) one line in words that says what failed, and Retry when the page can try again.
7
+ * `retry` is the data attribute the page listens for, e.g. 'data-vc-retry'.
8
+ *
9
+ * next(step) the one next step of a page with nothing in it yet (initiative empty-page-next-action): the Komorebi
10
+ * Suggestion part, ✦ and step.say, with one icon-only primary button. step = { id, say, ask } from
11
+ * lib/moments.js nextOf; null draws nothing. A press puts step.ask in the one chat, unsent (Home's own box
12
+ * on Home, else page-chat.js ask), so the person reads it and sends it: nothing is kept without their yes.
13
+ * The button's first data attribute is data-sb-next, the name the local use log counts it under.
14
+ *
15
+ * `line` and `what` are plain text and are escaped here. `step` is trusted HTML the page built (a button or a link).
16
+ * The look lives in ui/components/bundle.css (.pm-state), so a Komorebi token change reaches every state on every page.
17
+ * An error writes one [state-block] line per distinct failure, so a responder can find it in the console. */
18
+
19
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
20
+ const ATTR = /^data-[a-z0-9-]+(="[^"<>]*")?$/; // a page's own press mark, nothing else
21
+ const RETRY = '<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>';
22
+ const SEND = '<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6"/></svg>';
23
+ const said = new Set();
24
+
25
+ export function empty(line, { step = '' } = {}) {
26
+ return `<p class="pm-state empty">${esc(line)}${step ? ' ' + step : ''}</p>`;
27
+ }
28
+
29
+ export function loading(what, { rows = 3 } = {}) {
30
+ const n = Math.max(1, Math.min(8, Math.round(Number(rows)) || 3));
31
+ return `<div class="pm-state loading" role="status" aria-label="${esc(what)}">${'<span class="ph"><i></i></span>'.repeat(n)}</div>`;
32
+ }
33
+
34
+ export function error(line, { retry = '' } = {}) {
35
+ const text = String(line == null ? '' : line);
36
+ if (!said.has(text)) {
37
+ said.add(text);
38
+ try { console.info('[state-block] error:', text); } catch { /* no console */ }
39
+ }
40
+ const mark = retry && ATTR.test(retry) ? retry : '';
41
+ const btn = mark ? `<button type="button" class="pm-btn" aria-label="Try again" title="Try again" ${mark}>${RETRY}</button>` : '';
42
+ return `<p class="pm-state error" role="alert"><span>${esc(text)}</span>${btn}</p>`;
43
+ }
44
+
45
+ export function next(step) {
46
+ if (!step || !step.say || !step.ask) return '';
47
+ const name = 'Write it in the chat for you to send';
48
+ return `<div class="pm-sug pm-state-next"><span class="pm-star" aria-hidden="true">✦</span><span class="say">${esc(step.say)}</span>`
49
+ + `<button type="button" data-sb-next="${esc(step.ask)}" class="pm-btn primary" aria-label="${name}" title="${name}">${SEND}</button></div>`;
50
+ }
51
+
52
+ /** The step's words go in the one chat, not sent: Home's own box on Home, else the chat over this page. */
53
+ async function askInChat(text) {
54
+ const box = document.getElementById('hmIn');
55
+ if (box) { box.value = text; box.dispatchEvent(new Event('input', { bubbles: true })); box.focus(); return; }
56
+ let ws; try { ws = new URLSearchParams(location.search).get('ws') || undefined; } catch { ws = undefined; }
57
+ const M = await import('./page-chat.js');
58
+ await M.ask(text, { ws });
59
+ }
60
+ if (typeof document !== 'undefined' && document.addEventListener) {
61
+ document.addEventListener('click', (e) => {
62
+ const b = e.target && e.target.closest ? e.target.closest('[data-sb-next]') : null;
63
+ if (!b) return;
64
+ e.preventDefault();
65
+ askInChat(b.getAttribute('data-sb-next') || '').catch(() => null);
66
+ });
67
+ }
@@ -5,15 +5,29 @@
5
5
  * a script drives (navigator.webdriver: a test or a crawler is not the user's own use).
6
6
  * controlOf(el) PURE: the name a pressed element is logged under, or '' to log nothing
7
7
  * deviceOf(width) PURE: phone (≤ 760 px), tablet (≤ 1100 px) or desk
8
+ * noteUse(control) note one use a page names itself (pm/action-keys.js counts its key presses as key-<action> or key-miss)
9
+ *
10
+ * HIDE THE BUTTONS NOBODY PRESSES (idea A454; the rule and the store are lib/unused-controls.js). startUseLog also:
11
+ * at load hides this page's hidden buttons (GET /api/use-log/hidden, one style rule per id, so a button drawn later is hidden too);
12
+ * after UNUSED_MS tells the server which buttons the page shows (POST /api/use-log/unused, ids only) and, when it proposes some, shows
13
+ * the Komorebi Suggestion: "Hide N buttons…", icon-only Yes and No, the buttons outlined while it shows. Yes hides them and the
14
+ * Komorebi Toast offers Undo; No folds it and PMOS does not suggest them again. Settings › General › Use log lists them with Show.
15
+ * presentControls(doc) the ids a page shows that may be proposed (PURE over the doc it is given)
16
+ * hideCss(ids) PURE: the style rule that hides them · sugHtml(n) · hidToastHtml(n) PURE: the parts' markup
8
17
  *
9
18
  * ON THIS COMPUTER ONLY. Events go to this workspace's own server (POST /api/use-log, a relative URL) in batches: every 15 s while there
10
19
  * are some, and once more when the page hides (keepalive). Nothing goes anywhere else. NOTHING PERSONAL: a control is named by its id or
11
20
  * by the NAME of its first data- attribute (data-ev-sub), never by a value, its text or its label; an element with neither is not logged. */
12
- import { pmPost } from './http.js';
21
+ import { pmPost, pmGet } from './http.js';
13
22
 
14
23
  const FLUSH_MS = 15000;
15
24
  const MAX_QUEUE = 200;
16
25
  const ID_RE = /^[A-Za-z][A-Za-z0-9_-]{0,79}$/;
26
+ const UNUSED_MS = 4000;
27
+ const TOAST_MS = 6000;
28
+ const PROPOSABLE = 'button[id], a[href][id], [role="button"][id], [role="tab"][id], [role="switch"][id], [role="menuitem"][id]';
29
+ // a button inside the menu, a dialog, a list, a table or a form is about one item or one task: never proposed
30
+ const NOT_IN = '#czNav, nav, dialog, [role="dialog"], [aria-modal="true"], ul, ol, table, [role="list"], [role="listbox"], [role="grid"], [role="table"], [role="tree"], form, [data-pm-unused-host]';
17
31
  const PRESSABLE = 'button, a[href], [role="button"], [role="tab"], [role="switch"], [role="menuitem"], input[type="checkbox"], input[type="radio"], select, summary';
18
32
  let started = false;
19
33
  const Q = [];
@@ -43,6 +57,14 @@ function note(ev) {
43
57
  Q.push({ ...ev, page: pageNow(), device: deviceNow(), t: Date.now() });
44
58
  }
45
59
 
60
+ /** Note one use the page names itself (pm/action-keys.js: `key-approve`, `key-miss`). The name must be a plain id; anything else is dropped.
61
+ * Nothing is noted before startUseLog runs, so a browser a script drives notes nothing here either. */
62
+ export function noteUse(control) {
63
+ if (!started || !ID_RE.test(String(control || ''))) return false;
64
+ note({ kind: 'use', control: String(control) });
65
+ return true;
66
+ }
67
+
46
68
  export function startUseLog(doc = typeof document !== 'undefined' ? document : null) {
47
69
  if (started || !doc) return false;
48
70
  if (botNow()) return false; // a browser driven by a script (a test, a crawler) is not the user's own use: nothing is noted
@@ -58,5 +80,109 @@ export function startUseLog(doc = typeof document !== 'undefined' ? document : n
58
80
  const hide = () => flush(true);
59
81
  try { window.addEventListener('pagehide', hide); doc.addEventListener('visibilitychange', () => { if (doc.visibilityState === 'hidden') hide(); }); } catch { /* no window */ }
60
82
  setTimeout(() => flush(false), 2000); // the open goes soon after load, so a page closed quickly still counts
83
+ try { startUnused(doc); } catch { /* the page still works without it */ }
61
84
  return true;
62
85
  }
86
+
87
+ /* ── hide the buttons nobody presses (idea A454) ── */
88
+
89
+ /** The ids this page shows that may be proposed: a pressable element with a plain id, visible, outside the menu, a dialog, a list, a
90
+ * table or a form. Never its text. */
91
+ export function presentControls(doc) {
92
+ if (!doc || !doc.querySelectorAll) return [];
93
+ const out = new Set();
94
+ for (const el of doc.querySelectorAll(PROPOSABLE)) {
95
+ const id = el.getAttribute('id') || '';
96
+ if (!ID_RE.test(id) || /^data-/i.test(id)) continue;
97
+ if (el.closest && el.closest(NOT_IN)) continue;
98
+ if (el.getClientRects && !el.getClientRects().length) continue; // not on screen: display none, or inside something closed
99
+ out.add(id);
100
+ if (out.size >= 300) break;
101
+ }
102
+ return [...out];
103
+ }
104
+
105
+ /** One style rule that hides these ids, so a button the page draws later is hidden too. Ids match ID_RE, so they need no escaping. */
106
+ export const hideCss = (ids) => (ids || []).filter((id) => ID_RE.test(id)).map((id) => `#${id}`).join(',') + ((ids || []).some((id) => ID_RE.test(id)) ? '{display:none!important}' : '');
107
+
108
+ const STAR = '<svg class="pm-ic pm-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z"/></svg>';
109
+ const icon = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
110
+ const YES = 'M5 12.5l4.5 4.5L19 7.5', NO = 'M6 6l12 12M18 6L6 18', UNDO = 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3';
111
+ const buttons = (n) => `${n} ${n === 1 ? 'button' : 'buttons'}`;
112
+
113
+ /** The Komorebi Suggestion for n buttons: the ✦, one line, icon-only Yes and No. */
114
+ export function sugHtml(n) {
115
+ return `<div class="pm-sug" role="group" aria-label="PMOS suggests"><span title="PMOS saw these on this page on many days, and you have not pressed them in 14 days. Outlined while this shows.">${STAR}</span>`
116
+ + `<span class="say">Hide ${buttons(n)} on this page you have not pressed in 14 days? They stay in Settings › Use log.</span>`
117
+ + `<button type="button" class="pm-btn primary" data-uc-yes aria-label="Yes, hide them" title="Yes, hide them">${icon(YES)}</button>`
118
+ + `<button type="button" class="pm-btn outline" data-uc-no aria-label="No, keep them" title="No, keep them">${icon(NO)}</button></div>`;
119
+ }
120
+ /** The Komorebi Toast after Yes, Undo as an icon button. */
121
+ export function hidToastHtml(n) {
122
+ return `<div class="pm-toast" role="status" aria-live="polite"><span class="in"><span>${buttons(n)} hidden. Show them again in Settings › Use log.</span>`
123
+ + `<button type="button" class="pm-btn" data-uc-undo aria-label="Undo: show them again" title="Undo">${icon(UNDO)}</button></span><span class="timer" data-uc-timer></span></div>`;
124
+ }
125
+
126
+ const UC = { css: null, host: null, ids: [], timer: 0 };
127
+ // the suggestion's place: a desk, bottom centre as the Toast part says; a phone (the menu's 760 px edge), under the top bar, so it never
128
+ // covers the chat box at the foot (as draft-keep). The outline marks the proposed buttons while the suggestion shows.
129
+ const HOST_CSS = '[data-pm-unused-host]{position:fixed;left:50%;bottom:var(--space-24);transform:translateX(-50%);z-index:2147482990;background:none;max-width:min(560px,calc(100vw - 32px))}'
130
+ + '@media (max-width:760px){[data-pm-unused-host]{bottom:auto;top:var(--space-64)}}'
131
+ + '[data-pm-unused]{outline:2px dashed var(--blue, currentColor);outline-offset:2px}';
132
+ function applyHidden(doc, ids) {
133
+ UC.ids = ids;
134
+ if (!UC.css) { UC.css = doc.createElement('style'); UC.css.id = 'pmUnusedCss'; doc.head.appendChild(UC.css); }
135
+ UC.css.innerHTML = hideCss(ids) + HOST_CSS;
136
+ }
137
+ function host(doc) {
138
+ if (UC.host && UC.host.isConnected) return UC.host;
139
+ if (!UC.css) applyHidden(doc, UC.ids); // the host's place is in the same style element (HOST_CSS)
140
+ const h = doc.createElement('div');
141
+ h.className = 'pm-ds'; h.setAttribute('data-pm-unused-host', '');
142
+ doc.body.appendChild(h);
143
+ return (UC.host = h);
144
+ }
145
+ const mark = (doc, ids, on) => { for (const id of ids) { const el = doc.getElementById(id); if (el) { if (on) el.setAttribute('data-pm-unused', ''); else el.removeAttribute('data-pm-unused'); } } };
146
+
147
+ function propose(doc, page, ids) {
148
+ const h = host(doc);
149
+ h.innerHTML = sugHtml(ids.length);
150
+ mark(doc, ids, true);
151
+ h.onclick = async (e) => {
152
+ const b = e.target.closest && e.target.closest('button'); if (!b) return;
153
+ if (b.hasAttribute('data-uc-yes')) {
154
+ mark(doc, ids, false);
155
+ const r = await pmPost('/api/use-log/hide', { page, controls: ids });
156
+ if (r && r.ok) { applyHidden(doc, [...new Set(UC.ids.concat(ids))]); hidToast(doc, page, ids); } else h.innerHTML = '';
157
+ } else if (b.hasAttribute('data-uc-no')) {
158
+ mark(doc, ids, false); h.innerHTML = '';
159
+ pmPost('/api/use-log/decline', { page, controls: ids });
160
+ }
161
+ };
162
+ }
163
+ function hidToast(doc, page, ids) {
164
+ const h = host(doc);
165
+ h.innerHTML = hidToastHtml(ids.length);
166
+ const done = () => { clearTimeout(UC.timer); h.innerHTML = ''; };
167
+ h.onclick = async (e) => {
168
+ if (!(e.target.closest && e.target.closest('[data-uc-undo]'))) return;
169
+ done();
170
+ const r = await pmPost('/api/use-log/show', { page, controls: ids });
171
+ if (r && r.ok) applyHidden(doc, UC.ids.filter((id) => !ids.includes(id)));
172
+ };
173
+ h.onmouseenter = () => clearTimeout(UC.timer);
174
+ h.onmouseleave = () => { UC.timer = setTimeout(done, TOAST_MS); };
175
+ clearTimeout(UC.timer); UC.timer = setTimeout(done, TOAST_MS);
176
+ }
177
+
178
+ function startUnused(doc) {
179
+ const page = pageNow();
180
+ Promise.resolve(pmGet('/api/use-log/hidden?page=' + encodeURIComponent(page))).then((r) => {
181
+ if (r && r.ok && Array.isArray(r.hidden) && r.hidden.length) applyHidden(doc, r.hidden.map((x) => x.control));
182
+ }).catch(() => null);
183
+ setTimeout(() => {
184
+ Promise.resolve(pmPost('/api/use-log/unused', { page, present: presentControls(doc) })).then((r) => {
185
+ if (r && r.ok && Array.isArray(r.propose) && r.propose.length) propose(doc, page, r.propose);
186
+ }).catch(() => null);
187
+ }, UNUSED_MS);
188
+ }