create-pmos 0.711.0 → 0.713.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 (118) hide show
  1. package/package.json +88 -40
  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 +2 -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 +87 -2
  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 +2 -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 +10 -3
  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/needs-providers.js +1 -0
  31. package/workspace/lib/parked-cli.js +105 -0
  32. package/workspace/lib/parked-reasons.js +245 -0
  33. package/workspace/lib/pmos-verbs.js +4 -1
  34. package/workspace/lib/prefs-sync.js +138 -0
  35. package/workspace/lib/product-dots.js +60 -0
  36. package/workspace/lib/route-modules.js +2 -0
  37. package/workspace/lib/routes-briefing-premium.js +11 -1
  38. package/workspace/lib/routes-prefs.js +56 -0
  39. package/workspace/lib/routes-strategy-card.js +53 -0
  40. package/workspace/lib/routes-use-log.js +24 -3
  41. package/workspace/lib/routine-sentence.js +250 -0
  42. package/workspace/lib/strategy-card.js +133 -0
  43. package/workspace/lib/unused-controls.js +178 -0
  44. package/workspace/package-lock.json +2 -2
  45. package/workspace/package.json +1 -1
  46. package/workspace/public/pm/back-place.js +87 -0
  47. package/workspace/public/pm/bd-backlog.css +1 -1
  48. package/workspace/public/pm/bd-backlog.js +9 -3
  49. package/workspace/public/pm/bd-pop-ds.css +10 -0
  50. package/workspace/public/pm/bd-pop-ds.js +27 -3
  51. package/workspace/public/pm/bd-strategy.js +85 -0
  52. package/workspace/public/pm/bd-views.js +2 -1
  53. package/workspace/public/pm/changed-mark.css +7 -0
  54. package/workspace/public/pm/changed-mark.js +117 -0
  55. package/workspace/public/pm/cozy-home.css +7 -0
  56. package/workspace/public/pm/cozy-pick.css +12 -0
  57. package/workspace/public/pm/cozy-pop-work.css +10 -1
  58. package/workspace/public/pm/cozy-pop-work.js +201 -17
  59. package/workspace/public/pm/cozy-routine-job.js +50 -7
  60. package/workspace/public/pm/cozy-routine.css +2 -0
  61. package/workspace/public/pm/cozy-settings.js +21 -3
  62. package/workspace/public/pm/cozy-task-pop.css +7 -0
  63. package/workspace/public/pm/cozy-today-page.css +1 -0
  64. package/workspace/public/pm/cozy-viewer.css +1 -1
  65. package/workspace/public/pm/cozy-viewer.js +14 -2
  66. package/workspace/public/pm/cozy-vw-mtg.css +0 -2
  67. package/workspace/public/pm/cozy-vw.css +0 -1
  68. package/workspace/public/pm/home-app.js +21 -1
  69. package/workspace/public/pm/home-ask.js +19 -1
  70. package/workspace/public/pm/home-chat.js +16 -3
  71. package/workspace/public/pm/home-today.js +2 -0
  72. package/workspace/public/pm/ini-tasks.js +4 -1
  73. package/workspace/public/pm/komorebi.css +11 -0
  74. package/workspace/public/pm/prefs-sync.js +111 -0
  75. package/workspace/public/pm/premium-board.js +20 -2
  76. package/workspace/public/pm/premium-chart-tab.js +2 -1
  77. package/workspace/public/pm/premium-mtg-replay.js +4 -3
  78. package/workspace/public/pm/premium-report-read.js +5 -4
  79. package/workspace/public/pm/premium-report-tab.js +4 -3
  80. package/workspace/public/pm/premium-vw-backlog.css +2 -1
  81. package/workspace/public/pm/premium-vw-backlog.js +4 -3
  82. package/workspace/public/pm/premium-vw-cal.css +1 -2
  83. package/workspace/public/pm/premium-vw-cal.js +14 -13
  84. package/workspace/public/pm/premium-vw-copies.js +3 -2
  85. package/workspace/public/pm/premium-vw-copy.css +0 -3
  86. package/workspace/public/pm/premium-vw-mtg.js +12 -11
  87. package/workspace/public/pm/product-switcher.js +41 -0
  88. package/workspace/public/pm/report-orders-ui.js +2 -1
  89. package/workspace/public/pm/rp-parts.js +3 -2
  90. package/workspace/public/pm/state-blocks.js +36 -0
  91. package/workspace/public/pm/use-log.js +118 -1
  92. package/workspace/public/pm/work-select.js +92 -2
  93. package/workspace/public/pm/work-tree.js +70 -0
  94. package/workspace/public/premium-aud.html +1 -0
  95. package/workspace/public/premium-board.html +5 -0
  96. package/workspace/public/premium-buddy.html +1 -0
  97. package/workspace/public/premium-events.html +1 -0
  98. package/workspace/public/premium-goals.html +1 -0
  99. package/workspace/public/premium-intelligence.html +1 -0
  100. package/workspace/public/premium-library.html +1 -0
  101. package/workspace/public/premium-present.html +1 -0
  102. package/workspace/public/premium-rec.html +1 -0
  103. package/workspace/public/premium-routine.html +1 -0
  104. package/workspace/public/premium-viewer.html +1 -0
  105. package/workspace/public/premium-workflows.html +1 -0
  106. package/workspace/public/today.html +1 -0
  107. package/workspace/server.js +20 -0
  108. package/workspace/test-lists/back-place.json +9 -0
  109. package/workspace/test-lists/changed-mark.json +9 -0
  110. package/workspace/test-lists/launch-tiers.json +9 -0
  111. package/workspace/test-lists/parked-reasons.json +9 -0
  112. package/workspace/test-lists/prefs-follow-person.json +9 -0
  113. package/workspace/test-lists/product-switcher-dots.json +9 -0
  114. package/workspace/test-lists/routine-sentence.json +9 -0
  115. package/workspace/test-lists/shared-empty-states.json +9 -0
  116. package/workspace/test-lists/strategy-card.json +9 -0
  117. package/workspace/test-lists/unused-controls.json +9 -0
  118. package/workspace/test-lists/work-subtasks-followups.json +9 -0
@@ -126,8 +126,9 @@ const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file
126
126
  * key or the last open() went to, so the exported API always speaks of the Viewer used last. G is what the page has once: its list's rail,
127
127
  * the listeners, the rail's card. Only the first instance (#czViewer) writes the browser history; another keeps its own ← → trail.
128
128
  * Without cozy-panels.js (Board, Intelligence) the limit stays 1 and there is one Viewer, as before. */
129
+ import { capture as capturePlace, restore as restorePlace } from './back-place.js'; // Back restores your place (A430)
129
130
  const G = { chat: null, subs: [], railKey: null, rail: false, lw: 0, tick: 0, limit: 1, beside: null, place: null, managed: null, popH: null, popNext: null };
130
- const mk = (i) => ({ i, el: null, cur: null, back: null, stack: [], fwd: [], wide: false, w: 0, drill: false, over: false, used: 0, ph: false, via: '', pop: false });
131
+ const mk = (i) => ({ i, el: null, cur: null, back: null, stack: [], fwd: [], unplace: null, wide: false, w: 0, drill: false, over: false, used: 0, ph: false, via: '', pop: false });
131
132
  let V = mk(0);
132
133
  const ALL = [V];
133
134
  const shown = (x) => !!(x && x.el && !x.el.hidden && x.cur);
@@ -641,7 +642,7 @@ export function open(it) {
641
642
  if (!V.cur) { const ae = document.activeElement; V.back = ae && ae !== document.body && !el.contains(ae) ? ae : null; }
642
643
  const was = isOpen(), pos = V.stack.length, how = stepOf(o);
643
644
  if (how === 'nav') { V.stack = o._trail.stack; V.fwd = o._trail.fwd; }
644
- else if (how === 'drill') { V.stack.push(V.cur.args); V.fwd = []; hq({ push: 1, s: H.s, i: V.stack.length }); }
645
+ else if (how === 'drill') { keepPlace(); V.stack.push(V.cur.args); V.fwd = []; hq({ push: 1, s: H.s, i: V.stack.length }); }
645
646
  else if (how === 'new' && V.i) { V.stack = []; V.fwd = []; } // a second Viewer keeps its trail without the browser history
646
647
  else if (how === 'new') {
647
648
  // a press starts a trail on its own entry; an open no press led to (the page drew it, or Back from another page restored it) takes the
@@ -659,12 +660,15 @@ export function open(it) {
659
660
  redraw();
660
661
  el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
661
662
  const body = el.querySelector('.cz-vw-body');
663
+ if (V.unplace) { V.unplace(); V.unplace = null; }
662
664
  body.innerHTML = ''; body.scrollTop = 0;
663
665
  body.className = 'cz-vw-body'; body.onclick = null; body.oninput = null; body.onchange = null; body.onkeydown = null; // what one item's render added to the body does not reach the next
664
666
  const wasHidden = el.hidden;
665
667
  el.hidden = false;
666
668
  if (!(sameKind && !wasHidden && (V.wide || G.rail))) { const k = widthOf(o.kind); V.wide = false; apply(k || room().def); redraw(); }
667
669
  if (typeof o.render === 'function') o.render(body); else if (o.html) body.innerHTML = o.html;
670
+ // a step back or forward comes back to the item's place (its scroll, its open sections), now and while its content arrives
671
+ if (how === 'nav' && o._place) V.unplace = restorePlace(body, o._place);
668
672
  emit();
669
673
  if (isPhone()) el.focus();
670
674
  return body;
@@ -694,6 +698,7 @@ export function close(o = {}) {
694
698
  V.via = o.quiet ? 'history' : '';
695
699
  V.stack = []; V.fwd = []; V.wide = false; V.drill = false;
696
700
  if (V.over) { V.over = false; document.body.classList.remove('cz-vw-over'); }
701
+ if (V.unplace) { V.unplace(); V.unplace = null; }
697
702
  V.el.hidden = true;
698
703
  V.el.querySelector('.cz-vw-body').innerHTML = '';
699
704
  V.el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
@@ -751,6 +756,7 @@ export function replaceUrl(url) { if (canHist()) hq({ url: String(url) }); }
751
756
  /** n steps along the trail (← is -1, → is 1, the trail list jumps). Past its start the Viewer closes. o.quiet: the browser already moved. */
752
757
  function step(n, o = {}) {
753
758
  if (!V.cur || !n) return null;
759
+ keepPlace();
754
760
  const seq = [...V.stack, V.cur.args, ...V.fwd.slice().reverse()], at = V.stack.length + n;
755
761
  if (at < 0) { close(o); return null; }
756
762
  if (at >= seq.length) return null;
@@ -758,6 +764,12 @@ function step(n, o = {}) {
758
764
  if (!o.quiet) hq({ go: n });
759
765
  return open({ ...to, back: false, keep: false, _asked: true, _nav: true, _inst: V, _trail: { stack: seq.slice(0, at), fwd: seq.slice(at + 1).reverse() } });
760
766
  }
767
+ /** The item shown now keeps its place (scroll, open sections) in its trail entry, so a step back to it restores it (back-place.js). */
768
+ function keepPlace() {
769
+ if (!V.cur || !V.cur.args || !V.el) return;
770
+ const p = capturePlace(V.el.querySelector('.cz-vw-body'));
771
+ if (p) V.cur.args = { ...V.cur.args, _place: p };
772
+ }
761
773
  /** The browser moved (Back, Forward, a swipe, a long press on its own ←). An item with unsaved changes asks first: the browser goes back to
762
774
  * where it was, and the move runs on Save or Discard. */
763
775
  function popped(e) { use(ALL[0]); popped0(e); }
@@ -71,7 +71,6 @@
71
71
  .vzm-pop { position: absolute; right: 0; top: 4px; z-index: 30; width: min(380px, 100%); display: flex; flex-direction: column; gap: 6px; padding: var(--space-12); border-radius: var(--radius-card, 18px); background: var(--cz-card); border: 1px solid var(--cz-hair); box-shadow: var(--cz-lift); }
72
72
  .vzm-anc[data-pop="mat"] { height: auto; }
73
73
  .vzm-anc[data-pop="mat"] .vzm-pop { position: relative; top: 0; width: 100%; }
74
- .vzm-pop .vz-empty { font-size: var(--fs-meta); line-height: var(--lh-meta); }
75
74
  .vzm-mi2 { display: flex !important; width: 100%; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px !important; border-radius: var(--radius-md, 10px); font-size: var(--fs-body); color: var(--cz-ink); line-height: var(--lh-body); }
76
75
  .vzm-mi2.hl, .vzm-mi2[aria-current="true"] { background: var(--cz-well); }
77
76
  .vzm-mi2 .vzm-k { color: var(--cz-ink3); font-size: var(--fs-meta); line-height: var(--lh-meta); }
@@ -191,7 +190,6 @@
191
190
  .vzp-lr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; padding: var(--space-8) 6px var(--space-8) 28px; font-size: var(--fs-meta); color: var(--cz-ink2); border-top: 1px solid var(--cz-hair); line-height: var(--lh-meta); }
192
191
  .vzp-lr small { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
193
192
  .vzp-link { color: var(--cz-blueink); font-weight: var(--fw-strong); font-size: var(--fs-label); line-height: var(--lh-label); }
194
- .vzp-empty { margin: 0; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
195
193
  .vzp-phh { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
196
194
  .vzp-dark { min-height: 32px; padding: 0 14px !important; border-radius: var(--radius-pill, 999px); background: var(--vzd) !important; color: var(--vzd-on) !important; font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
197
195
  .vzp-h3 { margin: var(--space-8) 0 0 !important; font-size: var(--fs-section); font-weight: var(--fw-strong); line-height: var(--lh-section); }
@@ -73,7 +73,6 @@
73
73
  .vz-ph svg { color: var(--cz-ink3); transition: transform .15s; }
74
74
  .vz-part[data-open="true"] .vz-ph svg { transform: rotate(180deg); }
75
75
  .vz-pb { padding: 2px 14px var(--space-16); display: flex; flex-direction: column; gap: 14px; }
76
- .vz-empty { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
77
76
 
78
77
  /* rows shared by the parts */
79
78
  .vz-ready { display: flex; align-items: flex-start; gap: 10px; font-size: var(--fs-body); line-height: var(--lh-body); }
@@ -36,6 +36,7 @@ import * as H from './home-data.js';
36
36
  import { mountChat, avHtml } from './home-chat.js';
37
37
  import * as MORE from './home-more.js';
38
38
  import * as PP from './cozy-pick.js'; // the one product picker Home, Board and Insights share (batch 12 item 5)
39
+ import * as SW from './product-switcher.js'; // the product switcher row with its dots (bet A381)
39
40
  import { headModel, STEPS, gateOf } from './premium-initiative-head.js';
40
41
  import * as SC from './home-stage-card.js'; // the initiative's stage card D
41
42
  import * as WFM from './ini-wf-model.js'; // D99: the workflow an initiative runs (kind line, usual days)
@@ -245,6 +246,7 @@ async function load() {
245
246
  loadMoment();
246
247
  readImpact();
247
248
  loadGrillNews();
249
+ loadDots();
248
250
  // the top of Home (A′): the ranked list's own reads and Waiting on others, after the first draw so they never hold the list up
249
251
  document.body.dataset.hmTop = '0';
250
252
  // the top of Home is off until a new design is agreed (Wawan 2026-11-17: the list stays navigation). GET /api/waiting is not read, so no
@@ -387,7 +389,7 @@ function homeListHtml() {
387
389
  const sel = S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null);
388
390
  return TD.listHtml(M, todayModel(), {
389
391
  sel, selHead: S.head, ses: S.ses, pOpen, here: isPhone() ? null : TD.groupOfOpen(M, sel) || S.head, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
390
- pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, news: S.news && S.news.ok ? S.news.count : 0, top: S.ready ? revealLeft(S.reveal) + RECROW.html() + (S.drift ? DRIFT.rowHtml(S.drift.c, { esc, sel: S.sel === 'drift' }) : '') + (T ? '<i data-hm-topslot hidden></i>' : '') : '', held: T ? T.held : null, // chief-of-staff C3: the Mentions and Your impact cards are gone; their asks land in Your move
392
+ pick: S.D.pick, tones: pickTones(), psw: S.ready ? SW.switcherHtml(dotsPick(), { tones: pickTones(), cls: 'hv-psw' }) : '', review: R, mic: canDictate(), phone: isPhone(), day: S.day, news: S.news && S.news.ok ? S.news.count : 0, top: S.ready ? revealLeft(S.reveal) + RECROW.html() + (S.drift ? DRIFT.rowHtml(S.drift.c, { esc, sel: S.sel === 'drift' }) : '') + (T ? '<i data-hm-topslot hidden></i>' : '') : '', held: T ? T.held : null, // chief-of-staff C3: the Mentions and Your impact cards are gone; their asks land in Your move
391
393
  last: S.ready ? '' : LS.last(LAST_KEY), keep: S.ready && S.filter === 'today' && !S.ini ? (b) => LS.keepLast(LAST_KEY, b) : null,
392
394
  imFace: IM.faceHtml(S.im, { joy: S.imJoy }), grill: S.ready ? grillNews() : null,
393
395
  });
@@ -1680,6 +1682,23 @@ function pickTones() {
1680
1682
  const own = ((S.D.board && S.D.board.board) || {}).ws || '';
1681
1683
  return PP.tonesOf(P.products.map((p) => ({ ...p, primary: own ? p.ws === own : p.primary })));
1682
1684
  }
1685
+ /** The pick with each product's needs (S.dots, GET /api/briefing-premium/products?needs=1), for the switcher row; the saved pick decides
1686
+ * which product is shown alone, so a read that came before a save does not draw the old one */
1687
+ function dotsPick() {
1688
+ const P = S.D.pick; if (!P) return null;
1689
+ const N = new Map(((S.dots && S.dots.products) || []).map((p) => [p.ws, p.needs]));
1690
+ return { ...P, products: P.products.map((p) => ({ ...p, needs: N.has(p.ws) ? N.get(p.ws) : null })) };
1691
+ }
1692
+ // a product not read yet comes back null and its read starts on the server: ask again a little later, a few times, then on each load
1693
+ let dotsTry = 0;
1694
+ function loadDots() {
1695
+ SW.readDots().then((r) => {
1696
+ if (!r) return;
1697
+ const was = JSON.stringify(S.dots && S.dots.products.map((p) => p.needs)); S.dots = r;
1698
+ if (JSON.stringify(r.products.map((p) => p.needs)) !== was) drawList();
1699
+ if (r.products.some((p) => p.needs === null) && dotsTry++ < 3) setTimeout(loadDots, 15000);
1700
+ }).catch(() => null);
1701
+ }
1683
1702
  function pickLine(ws) {
1684
1703
  const M = S.M; if (!M) return '';
1685
1704
  const p = M.products.find((x) => x.ws === ws); if (!p) return '';
@@ -2207,6 +2226,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
2207
2226
  if (d.hmCheck) { checkRow(d.hmCheck); return; }
2208
2227
  if ('hmReview' in d) { if (S.day) day(false); openReviewVw(); return; }
2209
2228
  if ('hmPick' in d) { pickProduct(b); return; }
2229
+ if (d.psw) { const P = dotsPick(); if (P) SW.press(P, d.psw).then((r) => { if (!r.ok) toast(r.error); }); return; }
2210
2230
  if ('hmCapmic' in d) { const i = $('#hmCap'); if (i) capMic(i, b); return; }
2211
2231
  if (d.hmTc) { if (S.day && d.hmTc === 'cal') day(false); todayPress(d.hmTc, b); return; }
2212
2232
  if (d.hmEnd) { endRow(d.hmEnd); return; }
@@ -57,7 +57,11 @@ export function permissionAsk(conv) {
57
57
  const more = opts.filter((o) => o !== allow && o !== deny);
58
58
  const send = !!ch && OUTSIDE.test(ch.system || '') && WRITE.test(ch.tool || '');
59
59
  const verb = ch && ch.tool && !/^mcp__/.test(ch.tool) ? ch.tool + ' ' : '';
60
+ // tap for why (PhoneTodayDS, job 1540): PMOS's own words just before it asked, so the PM need not scroll up to see the reason
61
+ const said = (Array.isArray(c.messages) ? c.messages : []).filter((m) => m.role === 'assistant').pop();
62
+ const why = said ? clip(splitAsk(said.text).text, 300) : '';
60
63
  return {
64
+ why,
61
65
  kind: send ? 'send' : 'file',
62
66
  label: send ? 'Asks before it sends to ' + ch.system : 'Asks before it goes on',
63
67
  title: ch ? (send ? ch.what : verb + ch.what) : c.ask.question,
@@ -118,7 +122,8 @@ export function askCardHtml(a, { live = true, role = 'PMOS' } = {}) {
118
122
  const yes = a.answers.find((x) => x.icon === 'yes'), no = a.answers.find((x) => x.icon === 'no');
119
123
  const sw = live && yes && no ? ` data-sw-right="yes" data-sw-left="no"` : '';
120
124
  const hint = sw ? `<p class="hm-swh">${esc('Swipe right: ' + yes.label + ' · left: ' + no.label)}</p>` : '';
121
- return `<div class="hm-askw" role="group" aria-label="${esc(role)} asks before it goes on"><div class="hm-askk" data-ask-kind="${a.kind}"${sw}><p class="k">${esc(a.label)}</p><b class="q">${esc(a.title)}</b>${ft}${hint}`
125
+ const why = live && a.why && a.why !== a.title ? `<details class="hm-why"><summary>Why</summary><p>${esc(a.why)}</p></details>` : '';
126
+ return `<div class="hm-askw" role="group" aria-label="${esc(role)} asks before it goes on"><div class="hm-askk" data-ask-kind="${a.kind}"${sw}><p class="k">${esc(a.label)}</p><b class="q">${esc(a.title)}</b>${ft}${hint}${why}`
122
127
  + `<div class="acts">${a.answers.map((x) => iconBtn({ ...x, off: !live, sw: x === yes ? 'yes' : x === no ? 'no' : '' })).join('')}${more}</div></div></div>`;
123
128
  }
124
129
 
@@ -137,3 +142,16 @@ export function openAsk(conv) {
137
142
  }
138
143
  return false;
139
144
  }
145
+
146
+ /** What a change PMOS was allowed to make says after it, with one Undo (PhoneTodayDS, job 1540: "Done: COM-412 is due 27 Nov. Undo").
147
+ * a = the card the PM answered (permissionAsk). Undo asks PMOS in words to put it back; a send to another system cannot be taken back
148
+ * by PMOS alone, so its Undo asks PMOS to undo it there and say what it could not. null when the card held no change. */
149
+ export function doneLine(a) {
150
+ if (!a || !a.title || (a.kind !== 'file' && a.kind !== 'send')) return null;
151
+ const what = clip(a.title, 160);
152
+ const undo = a.from || a.to
153
+ ? `Undo that change: put back "${clip(a.from, 200)}" in place of "${clip(a.to, 200)}" (${what}).`
154
+ : `Undo that change: ${what}.`;
155
+ return { text: what, undo };
156
+ }
157
+ export const doneLineHtml = (d) => d ? `<p class="hm-done" role="status">Done: ${esc(d.text)}. <button type="button" class="hm-undo" data-chat-say="${esc(d.undo)}">Undo</button></p>` : '';
@@ -31,7 +31,7 @@ import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
31
31
  import { turnsOf } from './chat-context.js';
32
32
  import { askCardHtml, answerText } from './chat-ask.js';
33
33
  import { wireSwipe } from './cozy-phone-swipe.js'; // a phone: the ask card swipes (PhoneTodayDS, job #1540)
34
- import { permissionAsk, splitAsk, blockAsk, iconBtn, openAsk, askCardHtml as kindCardHtml } from './home-ask.js';
34
+ import { permissionAsk, splitAsk, blockAsk, iconBtn, openAsk, askCardHtml as kindCardHtml, doneLine, doneLineHtml } from './home-ask.js';
35
35
  import { splitChase, runStop, sweepLine, stopText } from './home-sweep.js';
36
36
  import { splitSrc, srcHtml } from './chat-src.js'; // chief-of-staff C1: where each answer came from
37
37
  import { splitFiles, filesHtml, sizeText, MAX_BYTES, MAX_FILES, setAttachSink } from './premium-attach.js';
@@ -215,6 +215,15 @@ export function mountChat(el, host) {
215
215
  const a = permissionAsk(C.conv);
216
216
  return a ? kindCardHtml(a, { role: R.role.name }) : '';
217
217
  }
218
+ /** The last allowed change: "Done: … Undo", kept until the PM writes again (a new PM turn, or the next ask, takes its place). */
219
+ function doneHtml() {
220
+ if (!C.done) return '';
221
+ const users = ((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').length;
222
+ const ask = C.conv && C.conv.ask;
223
+ if (users > C.done.n || (ask && ask.question !== C.done.q)) { C.done = null; return ''; }
224
+ if (ask) return ''; // the answered prompt is still on screen until the next read
225
+ return doneLineHtml(C.done);
226
+ }
218
227
  function queuedHtml() {
219
228
  const q = host.queued ? host.queued(sid()) : [];
220
229
  // as typed: PMOS wraps a report ask or a /goal in its rule, adds the files line, and a live session joins the lines (batch 22 item 10:
@@ -290,7 +299,7 @@ export function mountChat(el, host) {
290
299
  const goal = C.th && C.th.goal;
291
300
  const parts = items.map((it, i) => msgHtml(it, i, R));
292
301
  placeDivider(parts, items, goal);
293
- let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro, !items.length) : '') + parts.join('') + askHtml(R) + (R.stop && R.lastAgent < 0 ? dividerHtml(R.stop) : '') + pendHtml() + queuedHtml();
302
+ let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro, !items.length) : '') + parts.join('') + askHtml(R) + doneHtml() + (R.stop && R.lastAgent < 0 ? dividerHtml(R.stop) : '') + pendHtml() + queuedHtml();
294
303
  html += GU.choiceHtml(); // /goal while a goal works here: In a new chat, or Here instead
295
304
  for (const n of C.notes || []) if (t.ini && n.ini === t.ini) html += `<p class="hm-note hm-you">${esc(n.text)}</p>`;
296
305
  if (C.th && C.th.working) html += `<p class="hm-note" role="status">The agent is answering. You can write again when it has.</p>`;
@@ -627,7 +636,11 @@ export function mountChat(el, host) {
627
636
  if ('hmRetry' in d) { const u = ((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').pop(); if (u) send(u.text); return; }
628
637
  if (d.hmWi) { const it = C.items[+d.hmWi]; if (it) host.workItem(it.text, C.t); return; }
629
638
  if (d.hmPill) { const p = C.t.intro.pills[+d.hmPill]; if (p && p.go) { b.disabled = true; await p.go(b); b.disabled = false; } return; }
630
- if (d.hmPress) { b.disabled = true; press(d.hmPress); return; }
639
+ if (d.hmPress) {
640
+ // an allowed change says Done with one Undo under the chat until the PM writes again (PhoneTodayDS, job 1540)
641
+ if ('swYes' in d) { const dl = doneLine(permissionAsk(C.conv)); C.done = dl ? { ...dl, q: C.conv && C.conv.ask ? C.conv.ask.question : '', n: ((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').length } : null; }
642
+ b.disabled = true; press(d.hmPress); return;
643
+ }
631
644
  if ('hmPmore' in d) { const m = b.nextElementSibling; m.hidden = !m.hidden; return; }
632
645
  if ('hmTerm' in d) { host.openTerminal(sid()); return; }
633
646
  if ('hmCopyterm' in d) { const cmd = C.th && C.th.resume; try { await navigator.clipboard.writeText(cmd); host.toast('Copied. Paste it in Terminal on the computer PMOS runs on.'); } catch { host.toast('Copy did not work here. The command: ' + cmd); } return; }
@@ -334,6 +334,8 @@ export function listHtml(M, T, o) {
334
334
  + SO.btnHtml('ut-ib hv-ib' + (SO.layout().sort !== 'mine' ? ' on' : ''))
335
335
  + `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button>`
336
336
  + '</span></div>'
337
+ // the product switcher row (bet A381, pm/product-switcher.js): one press shows one product; a blue dot is a product that needs the PM
338
+ + (o.psw || '')
337
339
  // Claude grilled something by itself this week and left findings (canvas FcPhone, Home): one quiet line with ✦, else nothing
338
340
  + (o.grill ? `<p class="hv-sub hv-gn"><span>${esc(o.grill.text)}</span><button type="button" class="ut-ib hv-ib" data-hm-gn="${esc(o.grill.id)}" aria-label="${esc('Open the ' + o.grill.n + (o.grill.n === 1 ? ' finding' : ' findings') + ' on ' + o.grill.title)}" title="Open the findings">${svg('M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', 18)}</button></p>` : '');
339
341
  // the Today card only while the day has a moment; the plain day (its meetings and load) is in Your day
@@ -145,7 +145,10 @@ function openSheet(anchor, H) {
145
145
  if (d.ivsCol) { const on = timelineCols(); setTimelineCols(on.includes(d.ivsCol) ? on.filter((k) => k !== d.ivsCol) : on.concat(d.ivsCol)); if (H.redraw) H.redraw(); draw(); return; }
146
146
  if (d.ivsZoom) { ZOOM = d.ivsZoom; store.set('pmos.tasks.zoom', ZOOM); if (H.redraw) H.redraw(); draw(); return; }
147
147
  if (d.ivsBy && H.__g) { const r = H.__g.set(d.ivsBy); if (r && r.then) r.then(draw); else draw(); return; }
148
- if ('ivsMore' in d && H.__g) { const a = POP && POP.anchor; closePop(); if (a && a.isConnected) H.__g.more(a); }
148
+ if ('ivsMore' in d && H.__g) {
149
+ // the Tasks header can draw again while the sheet is open (a read of the page): the menu then opens under the view button drawn now
150
+ const a0 = POP && POP.anchor, a = a0 && a0.isConnected ? a0 : document.querySelector('[data-iv-vbtn]'); closePop(); if (a) H.__g.more(a);
151
+ }
149
152
  }, { sheet: PHONE(), right: true });
150
153
  return el;
151
154
  }
@@ -144,6 +144,17 @@
144
144
  .pm-ds .pm-rail .pm-count{position:absolute;top:3px;right:5px}
145
145
  .pm-ds .pm-path{display:flex;align-items:center;gap:6px;font-size:var(--type-small)}
146
146
  .pm-ds .pm-path a{color:var(--blue)}
147
+ .pm-ds .pm-state{margin:0;padding:var(--space-8) 0;font-size:var(--type-small);line-height:var(--leading-small);color:var(--muted)}
148
+ .pm-ds .pm-state.empty{max-width:62ch}
149
+ .pm-ds .pm-state.loading{display:flex;flex-direction:column;gap:var(--space-4)}
150
+ .pm-ds .pm-state.loading .ph{display:flex;align-items:center;gap:var(--space-12);min-height:var(--space-32)}
151
+ .pm-ds .pm-state.loading .ph::before{content:"";flex:none;width:var(--space-12);height:var(--space-12);border-radius:var(--radius-sm);background:var(--line)}
152
+ .pm-ds .pm-state.loading .ph i{display:block;flex:none;width:62%;height:var(--space-8);border-radius:var(--radius-sm);background:var(--line)}
153
+ .pm-ds .pm-state.loading .ph:nth-child(3n+2) i{width:78%}
154
+ .pm-ds .pm-state.loading .ph:nth-child(3n) i{width:48%}
155
+ .pm-ds .pm-state.error{display:flex;align-items:center;gap:var(--space-8);color:var(--ink)}
156
+ .pm-ds .pm-state.error::before{content:"";flex:none;width:var(--space-8);height:var(--space-8);border-radius:var(--radius-pill);background:var(--alert)}
157
+ .pm-ds .pm-state.error .pm-btn{margin-left:auto}
147
158
  .pm-ds .pm-motion-enter{animation:pmEnter var(--duration-enter) var(--ease-out) both}
148
159
  @keyframes pmEnter{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
149
160
  @media (prefers-reduced-motion: reduce) {
@@ -0,0 +1,111 @@
1
+ /* pm/prefs-sync.js — the page side of view preferences that follow the person (bet A461; the store is lib/prefs-sync.js, the routes
2
+ * lib/routes-prefs.js). A CLASSIC script, not a module: GET /api/view-prefs/boot.js serves it with the person's values in front, and every
3
+ * page loads that first, right after the nonce meta, so this runs before any page code reads localStorage. No page code changes.
4
+ *
5
+ * start(win) → { flush(keepalive), took, pending() } | null
6
+ * 1. TAKE: each kept value whose time is later than this browser's copy is written into this browser's storage (`took` counts them).
7
+ * A browser value with no time yet (kept before this change) gives way to the person's value.
8
+ * 2. SEED: an allowed value this browser holds that the store lacks, or holds newer, is sent.
9
+ * 3. WATCH: a later write or remove of an allowed key, by any page code, is sent in a batch (1.5 s after the last write, and when the
10
+ * page hides). Every other key (a draft, a cache, a seen marker, a panel size) is never sent.
11
+ * allowedBy(keys) → (key) → boolean · deviceOf(width) PURE
12
+ *
13
+ * ON THIS COMPUTER ONLY: one relative URL, POST /api/view-prefs, to this workspace's own server, with the page's nonce. A browser a script
14
+ * drives (navigator.webdriver: a test, a crawler) takes nothing and sends nothing, so one test's view never reaches the next. */
15
+ (function (root) {
16
+ 'use strict';
17
+ var STAMP = 'pmos.viewPrefs.at'; // this browser's time per key: { <key>: <ms> }
18
+ var FLUSH_MS = 1500;
19
+
20
+ function allowedBy(keys) {
21
+ var exact = {}; var pre = (keys && keys.prefix) || [];
22
+ ((keys && keys.exact) || []).forEach(function (k) { exact[k] = true; });
23
+ return function (k) {
24
+ if (typeof k !== 'string' || !k || k.length > 120) return false;
25
+ if (exact[k]) return true;
26
+ for (var i = 0; i < pre.length; i++) if (k.length > pre[i].length && k.indexOf(pre[i]) === 0) return true;
27
+ return false;
28
+ };
29
+ }
30
+ function deviceOf(w) { return w <= 760 ? 'phone' : w <= 1100 ? 'tablet' : 'desk'; }
31
+
32
+ function start(win) {
33
+ if (!win || win.__pmosViewPrefsStarted) return null;
34
+ try { if (win.navigator && win.navigator.webdriver) return null; } catch (e) { /* no navigator */ }
35
+ if (win.__pmosViewPrefsOn === false) return null;
36
+ var ls; try { ls = win.localStorage; } catch (e) { ls = null; }
37
+ if (!ls) return null;
38
+ win.__pmosViewPrefsStarted = true;
39
+ var SP = (win.Storage && win.Storage.prototype) || Object.getPrototypeOf(ls);
40
+ var oSet = SP.setItem, oGet = SP.getItem, oDel = SP.removeItem;
41
+ var get = function (k) { try { return oGet.call(ls, k); } catch (e) { return null; } };
42
+ var put = function (k, v) { try { oSet.call(ls, k, v); } catch (e) { /* storage full or blocked */ } };
43
+ var del = function (k) { try { oDel.call(ls, k); } catch (e) { /* blocked */ } };
44
+ var now = function () { return Date.now(); };
45
+ var allowed = allowedBy(win.__pmosViewPrefsKeys);
46
+ var kept = win.__pmosViewPrefs && typeof win.__pmosViewPrefs === 'object' ? win.__pmosViewPrefs : {};
47
+ var stamps; try { stamps = JSON.parse(get(STAMP) || '{}') || {}; } catch (e) { stamps = {}; }
48
+ if (typeof stamps !== 'object' || Array.isArray(stamps)) stamps = {};
49
+ var dirty = {}; var took = 0; var timer = null;
50
+
51
+ // 1. TAKE
52
+ Object.keys(kept).forEach(function (k) {
53
+ var e = kept[k];
54
+ if (!allowed(k) || !e || typeof e.at !== 'number') return;
55
+ var mine = stamps[k];
56
+ if (typeof mine === 'number' && mine >= e.at) return;
57
+ var cur = get(k);
58
+ if (e.v === null) { if (cur !== null) { del(k); took++; } } else if (typeof e.v === 'string' && cur !== e.v) { put(k, e.v); took++; }
59
+ stamps[k] = e.at;
60
+ });
61
+ // 2. SEED
62
+ var n = 0; try { n = ls.length; } catch (e) { n = 0; }
63
+ var names = []; for (var i = 0; i < n; i++) { var key = null; try { key = ls.key(i); } catch (e) { key = null; } if (key) names.push(key); }
64
+ names.forEach(function (k) {
65
+ if (!allowed(k)) return;
66
+ var e = kept[k];
67
+ if (typeof stamps[k] !== 'number') stamps[k] = now();
68
+ if (!e || stamps[k] > e.at) dirty[k] = { v: get(k), at: stamps[k] };
69
+ });
70
+ put(STAMP, JSON.stringify(stamps));
71
+
72
+ function nonce() {
73
+ try { var m = win.document && win.document.querySelector('meta[name="pmos-nonce"]'); return (m && m.getAttribute('content')) || ''; } catch (e) { return ''; }
74
+ }
75
+ function pending() { return Object.keys(dirty).length; }
76
+ function flush(keepalive) {
77
+ if (timer) { win.clearTimeout(timer); timer = null; }
78
+ if (!pending() && !took) return false;
79
+ var set = dirty; dirty = {};
80
+ var body = { set: set, followed: took, device: deviceOf(win.innerWidth || 1280) };
81
+ took = 0;
82
+ var h = { 'Content-Type': 'application/json' }; var nn = nonce(); if (nn) h['x-pmos-nonce'] = nn;
83
+ var back = function () { Object.keys(set).forEach(function (k) { if (!dirty[k] || dirty[k].at < set[k].at) dirty[k] = set[k]; }); };
84
+ try {
85
+ var p = win.fetch('/api/view-prefs', { method: 'POST', headers: h, body: JSON.stringify(body), keepalive: !!keepalive, credentials: 'same-origin' });
86
+ if (p && p.then) p.then(function (r) { if (!r || !r.ok) back(); }, back);
87
+ } catch (e) { back(); }
88
+ return true;
89
+ }
90
+ function later() { if (timer) win.clearTimeout(timer); timer = win.setTimeout(function () { flush(false); }, FLUSH_MS); }
91
+ function note(store, k) {
92
+ if (store !== ls || k === STAMP || !allowed(k)) return;
93
+ var at = now();
94
+ stamps[k] = at; put(STAMP, JSON.stringify(stamps));
95
+ dirty[k] = { v: get(k), at: at };
96
+ later();
97
+ }
98
+ // 3. WATCH: every write of every page script goes through the Storage prototype
99
+ SP.setItem = function (k, v) { var r = oSet.apply(this, arguments); note(this, String(k)); return r; };
100
+ SP.removeItem = function (k) { var r = oDel.apply(this, arguments); note(this, String(k)); return r; };
101
+ if (pending() || took) win.setTimeout(function () { flush(false); }, 3000);
102
+ try {
103
+ win.addEventListener('pagehide', function () { flush(true); });
104
+ if (win.document) win.document.addEventListener('visibilitychange', function () { if (win.document.visibilityState === 'hidden') flush(true); });
105
+ } catch (e) { /* no events */ }
106
+ return { flush: flush, get took() { return took; }, pending: pending };
107
+ }
108
+
109
+ if (typeof module !== 'undefined' && module.exports) module.exports = { start: start, allowedBy: allowedBy, deviceOf: deviceOf, STAMP: STAMP };
110
+ else if (root && root.window === root) root.__pmosViewPrefsSync = start(root);
111
+ })(typeof window !== 'undefined' ? window : this);
@@ -23,6 +23,7 @@ import { pmPost } from './http.js';
23
23
  import { followDoc } from './doc-follow.js';
24
24
  import { $, $$, esc, store, chatAbout, setPageGaps } from './premium-shell.js';
25
25
  import * as PK from './cozy-pick.js';
26
+ import * as SW from './product-switcher.js'; // the product switcher row beside the chip, on a desktop (bet A381)
26
27
  import { productName, whenNames } from './scope-chip.js'; // the products' display names ("IDPF", not "pmos-idpf") // the one product picker Home, Board and Insights share (batch 12 item 5)
27
28
  import { mountNav } from './cozy-nav.js';
28
29
  import { quietPlace } from './quiet-place.js'; // onboarding B3: before three initiatives or a date, the Board shows one line
@@ -58,6 +59,7 @@ import { nextHtml } from './bd-next.js';
58
59
  import * as GL from './bd-goal.js'; // board AwH: the Track grouped By goal
59
60
  import { statusOf as ivStatus } from './ini-view-model.js';
60
61
  import { initiativeRename, taskRename } from './rename-press.js';
62
+ import * as CM from './changed-mark.js'; // bet A456: the ✦ and Undo on a row PMOS changed by itself in the last 24 h
61
63
  import { setSay } from './cozy-xv.js';
62
64
  import { narrowForm } from './pn-narrow.js';
63
65
  import * as BP2 from './bd-pane.js';
@@ -65,6 +67,7 @@ import * as WV from './bd-work.js'; // Work, one view on a desk (slice 4 of th
65
67
  import * as BK from './bd-backlog.js';
66
68
  import * as ST from './bd-stands.js'; // Where it stands, its Suggestion and the Next milestones line (initiative work-design-system-blocks, WorkDS) // the Backlog beside Initiatives in Work: every task in one list (initiative work-backlog)
67
69
  import * as LS from './load-shapes.js'; // the skeleton and the slow-case line while the board is read (page-open-speed, SpD) // the Board as the first panel: fit(), the rows that open beside, the open row's mark
70
+ import * as STRAT from './bd-strategy.js'; // the product's strategy in five lines above the initiatives (bet A458)
68
71
  import * as SWN from './cozy-status-when.js'; // the day a status move really happened, in the toast (round 3 point 18)
69
72
 
70
73
  const VIEW_KEY = 'pmos.board.view', PVIEW_KEY = 'pmos.board.pview', SPAN_KEY = 'pmos.board.span', GROUPING_KEY = 'pmos.board.grouping';
@@ -229,9 +232,15 @@ function shownPick() {
229
232
  const ws = new Set(M.board.all ? (M.board.products || []).map((p) => p.ws) : [M.board.ws]);
230
233
  return { ...PKP, products: PKP.products.map((p) => ({ ...p, on: ws.has(p.ws) })) };
231
234
  }
235
+ /* the switcher row's dots (bet A381): each product's needs, read once per page (GET /api/briefing-premium/products?needs=1) */
236
+ let DOTS = null;
237
+ const dotsPick = (P) => (P ? { ...P, products: P.products.map((p) => ({ ...p, needs: DOTS && p.ws in DOTS ? DOTS[p.ws] : null })) } : null);
232
238
  function drawPick() {
233
239
  const P = shownPick(), host = $('#crumbHost'); if (!host) return;
234
- host.innerHTML = P ? PK.chipHtml(P, { id: 'bdPick', label: 'Products', names: !matchMedia('(max-width: 760px)').matches }) : `<span class="crpg">${esc(M.board.name || 'Board')}</span>`;
240
+ const desk = !matchMedia('(max-width: 760px)').matches;
241
+ host.innerHTML = P ? PK.chipHtml(P, { id: 'bdPick', label: 'Products', names: desk }) + (desk ? SW.switcherHtml(dotsPick(P)) : '') : `<span class="crpg">${esc(M.board.name || 'Board')}</span>`;
242
+ host.onclick = (e) => { const b = e.target.closest('[data-psw]'); if (!b) return; e.stopPropagation(); SW.press(dotsPick(shownPick()), b.dataset.psw).then((r) => { if (!r.ok) say(r.error); }); };
243
+ if (P && desk && !DOTS) { DOTS = {}; SW.readDots().then((r) => { if (r) { DOTS = Object.fromEntries(r.products.map((p) => [p.ws, p.needs])); drawPick(); } }).catch(() => null); }
235
244
  const chip = $('#bdPick'); if (!chip) return;
236
245
  // a product's line: its open initiatives on this page (zero is silence)
237
246
  const lines = (ws) => { const rows = (M.initiatives.list.rows || []).filter((r) => (M.board.all ? r.ws === ws : M.board.ws === ws)); return rows.length ? rows.length + (rows.length === 1 ? ' initiative' : ' initiatives') : ''; };
@@ -525,7 +534,7 @@ function trackRow(r, cls = '', po = false) {
525
534
  return `<div class="bt-r bt-l${cls}${peek && peek.key === r.key && peek.kind !== 'acts' ? ' sel' : ''}${r.acts && r.acts.life === 'hold' ? ' held' : ''}" role="row" data-row="${esc(r.key)}"${po ? ` data-po-id="${esc(r.id)}"` : ''}>${po ? PO.gripHtml(r.title) : ''}`
526
535
  + `<button type="button" class="ini2 bt-nm" data-key="${esc(r.key)}" role="rowheader" aria-haspopup="dialog"><b>${r.inProgram ? PG.memberIcon(PGS, r.inProgram) : ''}${many ? WF.wfIcon(WF.wfOf(r), 18) : ''}${WK.iconHtml(r.kind)}${SM.nameHtml(r)}</b><span class="cs s-${s.tone}"${s.from ? ` title="${esc(s.from)}"` : ''}><i class="cz-dot ${s.tone}"></i>${esc(s.text)}</span><span class="bt-pst">${t.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(t.label)} · ${DAYS(t)}</span></button>`
527
536
  + `<div class="${cellsCls()}" role="presentation"${cellsStyle()}>${cells}</div>`
528
- + `<div class="bt-dl" role="cell">${nextHtml(r, { self: M.board.self, factory: M.board.factory, icon: !small() })}</div></div>`; // the Next cell (XocA): what finishes the step next
537
+ + `<div class="bt-dl" role="cell">${nextHtml(r, { self: M.board.self, factory: M.board.factory, icon: !small() })}${CM.markFor(r.ws || M.board.ws || '', r.id)}</div></div>`; // the Next cell (XocA): what finishes the step next
529
538
  }
530
539
  const cellsCls = () => 'bt-cells' + (TK.mode === 'cats' ? ' bands' : TK.mode === 'wf' ? ' wfn' : '');
531
540
  const cellsStyle = () => (TK.mode === 'wf' ? ` style="--n:${Math.max(1, TK.steps.length)}"` : '');
@@ -1387,10 +1396,19 @@ async function load() {
1387
1396
  return;
1388
1397
  }
1389
1398
  M = r.model; readTries = 0; jiraReading = false; holdNames(); draw();
1399
+ readChanges();
1400
+ STRAT.refresh($('#cStrat'), { ws: M.board.ws || null, board: M.board.id || null, single: !ALL, say });
1390
1401
  focusOnce(); programOnce(); newOnce(); loadOthers(); loadWorkflows();
1391
1402
  if (r.stale) setTimeout(load, 2000); // a press is still being derived: ask again
1392
1403
  else { loadTrail(); loadGrill(); }
1393
1404
  }
1405
+ /** What PMOS changed by itself in the last 24 h, per product on this Board (pm/changed-mark.js, bet A456): read after each read of the board,
1406
+ * at most once a minute per product; a press of a row's Undo reads the board again. */
1407
+ function readChanges() {
1408
+ const ws = M.board.all ? (M.board.products || []).map((p) => p.ws) : [M.board.ws || ''];
1409
+ CM.read(ws, () => drawInit()).catch(() => null);
1410
+ }
1411
+ CM.bind({ onUndone: (r) => { if (r.ok) load(); else drawInit(); } });
1394
1412
  /** The workflows' own stage lists (GET /api/workflows), once, when a row here is on another workflow than Product feature: a picked workflow
1395
1413
  * draws every one of its stages, the empty ones too (WfABoardOne). Not read: the stages come from the rows (pm/bd-wf.js stagesOfWf). */
1396
1414
  let wfRead = false;
@@ -16,6 +16,7 @@ import { pmGet, pmPost } from './http.js';
16
16
  import { open as vOpen, current as vCur, body as vBody } from './cozy-viewer.js';
17
17
  import { vzStyle } from './premium-vw-open.js';
18
18
  import { deriveChart, unitTxt } from './premium-chart-draw.js';
19
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
19
20
 
20
21
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
21
22
  const FORMS = [['line', 'Line'], ['bars', 'Bars'], ['number', 'Number'], ['meter', 'Meter']];
@@ -149,7 +150,7 @@ function dashHtml(t) {
149
150
  }
150
151
  function bodyHtml(t) {
151
152
  const noun = t.block.kind;
152
- if (!t.loaded) return `<p class="vz-empty" role="status">Reading the ${noun}.</p>`;
153
+ if (!t.loaded) return SB.loading(`Reading the ${noun}.`);
153
154
  if (!t.M) return `<p class="vz-msg">The Intelligence records could not be read, so the ${noun} cannot be drawn. Try again in a moment.</p>`;
154
155
  if (t.removed) return '<p class="vz-msg">Deleted. Ask in the chat for a new one.</p>';
155
156
  if (t.gone) return `<p class="vz-msg">This ${noun} (${esc(t.block.id)}) is deleted, or it is not saved on this board.</p>`;
@@ -27,6 +27,7 @@
27
27
  * due and state); n = the note (GET /api/notes/one) for the remarks of the live transcript; points, edits, lessons, terms = GET /api/meeting-points.
28
28
  * replayView(rep, { n, points, edits, lessons, terms, now }) → the view model
29
29
  * replayHtml(V, ui) → the desk and the phone. ui = { pos, playing, speed, pt (the selected point), strip, caps, chaps, allShots, edit, draft } */
30
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
30
31
 
31
32
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
32
33
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
@@ -241,7 +242,7 @@ function rowHtml(V, p, ui, sel) {
241
242
  export function pointsCardHtml(V, ui = {}) {
242
243
  const sel = selOf(V, ui), cnt = ['decision', 'action', 'question'].map((k) => { const c = V.points.filter((p) => p.kind === k).length; return c ? `<span class="vzr-cnt">${kindIcon(k)}${c}</span>` : ''; }).join('');
243
244
  const head = `<div class="vzr-ph"><h3>${V.points.length} kept</h3>${cnt}<span class="vzp-sp"></span>${V.toConfirm ? `<button type="button" class="vzp-dark vzr-cfall" data-a="confirmall">${ic('chk', 14)}Confirm ${V.toConfirm}</button>` : ''}</div>`;
244
- const rows = V.rows.length ? V.rows.map((p) => rowHtml(V, p, ui, !!sel && sel.id === p.id)).join('') : `<p class="vzp-empty vzr-pad">Nothing was agreed, owned or left open in this meeting.</p>`;
245
+ const rows = V.rows.length ? V.rows.map((p) => rowHtml(V, p, ui, !!sel && sel.id === p.id)).join('') : '<div class="vzr-pad">' + SB.empty('Nothing was agreed, owned or left open in this meeting.') + '</div>';
245
246
  return `<section class="vzr-pts" aria-label="Kept points">${head}<div class="vzp-kl">${rows}</div></section>`;
246
247
  }
247
248
  /** Left out (a panel of the strip): each remark and why it was left out; a point marked not right can be put back. */
@@ -358,11 +359,11 @@ export function phoneHtml(V, ui = {}) {
358
359
  const sel = selOf(V, ui);
359
360
  const rows = V.rows.map((p) => rowHtml(V, p, ui, !!sel && sel.id === p.id)).join('');
360
361
  return playerHtml(V, ui, true) + `<div class="vzr-phk"><div class="vzr-ph"><h3>${V.points.length} kept</h3><span class="vzp-sp"></span>${V.toConfirm ? `<button type="button" class="vzp-dark vzr-cfall" data-a="confirmall">${ic('chk', 14)}Confirm ${V.toConfirm}</button>` : ''}</div>`
361
- + (rows ? `<div class="vzp-kl">${rows}</div>` : '<p class="vzp-empty">Nothing was agreed, owned or left open in this meeting.</p>') + '</div>';
362
+ + (rows ? `<div class="vzp-kl">${rows}</div>` : SB.empty('Nothing was agreed, owned or left open in this meeting.')) + '</div>';
362
363
  }
363
364
 
364
365
  /** The whole of it: the desk and the phone; the stylesheet shows one (cozy-vw-mtg.css). o: deskHtml's (the summary and the strip). */
365
366
  export function replayHtml(V, ui = {}, o = {}) {
366
- if (!V) return '<p class="vzp-empty">This meeting has no recording to replay.</p>';
367
+ if (!V) return SB.empty('This meeting has no recording to replay.');
367
368
  return `${deskHtml(V, ui, o)}<div class="vzp vzp-mb">${phoneHtml(V, ui)}</div>`;
368
369
  }
@@ -60,6 +60,7 @@ import * as OU from './report-orders-ui.js'; // batch 27 item 16: the orders o
60
60
  import { adler } from './cozy-adler.js'; // registers window.czViews; vzStyle adds the Viewer's sheet (cozy-vw.css)
61
61
  import { cycleGroups, cycleName, briefModel, briefGlanceHtml, briefConfirmHtml, briefWhyHtml, briefLooksHtml, paperModel, paperHtml, liveModel, liveHtml, presentHtml, dayMon, reportSummary,
62
62
  rpSumHtml, rpBarHtml, cadenceWords, goesOutWords, FORMATS, RP_ICONS } from './rp-parts.js';
63
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
63
64
 
64
65
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
65
66
  const svg = (p, n = 18) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true">${p}</svg>`;
@@ -433,7 +434,7 @@ function foldsHtml() {
433
434
  }
434
435
  function deckHtml() {
435
436
  const L = slides();
436
- if (!L.length) return '<p class="vz-empty">This cycle has no slides. Read it as a page.</p>';
437
+ if (!L.length) return SB.empty('This cycle has no slides. Read it as a page.');
437
438
  const i = R.i = Math.max(0, Math.min(R.i, L.length - 1));
438
439
  return `<div class="vz-slide" tabindex="0" role="group" aria-roledescription="slide" aria-label="Slide ${i + 1} of ${L.length}: ${esc(L[i].h)}. Use the arrow keys to change slide." data-r="slide">${slideCard(L[i])}</div>`
439
440
  + `<div class="rp-nav">${ib('prev', ic('prev', 15), 'Previous slide', { off: i === 0 })}<span class="rp-count" aria-live="polite">Slide ${i + 1} of ${L.length}</span>${ib('next', ic('next', 15), 'Next slide', { off: i === L.length - 1 })}${R.pyr && !R.cyc && R.ord && R.ord.engine && !R.edit ? ib('ord|slide', ic('mark', 15), 'Save this slide\'s layout to My slides', { cls: ' ro-slmark', off: R.busy }) : ''}</div>`
@@ -471,7 +472,7 @@ function rfhHtml() {
471
472
  R.issued ? null : { act: 'edit', label: 'Edit', icon: 'pen' }, { act: 'present', label: 'Present', icon: 'present' },
472
473
  R.archived ? null : { act: 'share', label: 'Share', icon: 'share', exp: R.pop === 'share', pop: 'dialog' },
473
474
  { act: 'dlm', label: 'Download', icon: 'dl', exp: R.pop === 'dl' }] });
474
- const view = R.err ? `<p class="vz-msg" data-tone="bad" role="alert">The document could not be read: ${esc(R.err)}</p>` : !R.W ? '<p class="vz-empty" role="status">Reading the report.</p>'
475
+ const view = R.err ? SB.error('The document could not be read: ' + R.err) : !R.W ? SB.loading('Reading the report.')
475
476
  : R.gal ? galView() : (R.view === 'doc' ? pageHtml() : deckHtml()) + ordAssHtml();
476
477
  const conf = confirm && R.BF ? czSections([{ id: 'confirm', title: 'Please confirm', count: confirm, open: true, render: () => briefConfirmHtml(R.BF, { issued: R.issued, busy: R.busy }) + (R.bfMsg ? `<p class="vz-msg" role="status">${esc(R.bfMsg)}</p>` : '') }], { key: 'report' }) : '';
477
478
  const pri = R.archived ? { act: 'unarch|' + R.row.path, label: 'Bring back', icon: 'back' } : R.issued ? null : { act: 'issue', label: 'Issue it', icon: 'send' };
@@ -486,7 +487,7 @@ function bodyHtml() {
486
487
  + (R.view === 'deck' && !R.noTip ? `<p class="vz-tip"><span>${tipText(at, n)}</span>${ib('notip', ic('x', 14), 'Hide this tip', { cls: ' vz-small' })}</p>` : '')
487
488
  + '<div class="vz-ed" data-vz-ed></div></div>';
488
489
  }
489
- const view = R.err ? `<p class="vz-msg" data-tone="bad" role="alert">The document could not be read: ${esc(R.err)}</p>` : !R.W ? '<p class="vz-empty" role="status">Reading the report.</p>'
490
+ const view = R.err ? SB.error('The document could not be read: ' + R.err) : !R.W ? SB.loading('Reading the report.')
490
491
  : R.gal ? galView() : (R.view === 'deck' ? deckHtml() : R.view === 'live' ? liveView() : pageHtml()) + ordAssHtml();
491
492
  return `<div class="vz-rpb">${R.conf ? confHtml() : R.W ? sumHtml() + ordRowHtml() : ''}${R.W && !R.err ? cutsHtml() : ''}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}${R.edit ? '' : waitHtml()}${R.W && !R.err ? barHtml() : ''}${view}${R.W && !R.err && !R.issued ? rvHtml() : ''}${R.W && !R.err ? foldsHtml() : ''}${askHtml()}</div>`;
492
493
  }
@@ -824,7 +825,7 @@ async function lifeIt(k, at) {
824
825
  if (R.onChange) R.onChange();
825
826
  const rest = R.cycles.filter((x) => x.path !== R.row.path);
826
827
  if (rest.length) return openReport(rest[0], { ...R.hand, cycles: rest });
827
- const b = bodyEl(); if (b) b.innerHTML = '<div class="vz"><p class="vz-empty" role="status">The draft is discarded.</p></div>';
828
+ const b = bodyEl(); if (b) b.innerHTML = '<div class="vz">' + SB.empty('The draft is discarded.') + '</div>';
828
829
  return;
829
830
  }
830
831
  R.cycles = R.cycles.map((x) => (x.path === rel ? { ...x, archived } : x));
@@ -35,6 +35,7 @@ import { FORMATS } from './rp-parts.js';
35
35
  import { vzStyle } from './premium-vw-open.js';
36
36
  import * as RF from './report-flow.js';
37
37
  import { adler } from './cozy-adler.js';
38
+ import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
38
39
 
39
40
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
40
41
  const OUT = FORMATS;
@@ -300,13 +301,13 @@ export function deckOf(p, sections) {
300
301
  export const frameOf = (sections) => (Array.isArray(sections) && sections.length ? sections.map((h) => [h, '']) : FRAME);
301
302
  /** The report's current state while no cycle is written yet (RfH1). */
302
303
  function currentHtml(t) {
303
- if (!t.F) return '<p class="vz-empty" role="status">Reading the report.</p>';
304
+ if (!t.F) return SB.loading('Reading the report.');
304
305
  if (t.F.err) return `<p class="vz-msg" data-tone="bad">${esc(t.F.err)}</p>`;
305
306
  return RF.waitHtml(t.F, adler(t.F.drafting && t.F.drafting.state === 'ended' ? 'honest' : 'thinking', 36));
306
307
  }
307
308
  /** The template (RfH3): the questions on its current version, what changed, its history, Keep the current template | Make a different template. */
308
309
  function templateHtml(t) {
309
- if (!t.F) return '<p class="vz-empty" role="status">Reading the template.</p>';
310
+ if (!t.F) return SB.loading('Reading the template.');
310
311
  if (t.F.err) return `<p class="vz-msg" data-tone="bad">${esc(t.F.err)}</p>`;
311
312
  return RF.questionsHtml(t.tq, { template: tplOf(t), name: t.F.name, making: t.making, busy: t.busy, msg: t.msg })
312
313
  + `<p class="vz-note">Its sections and look, and its cycles: <button type="button" class="rp-linkbtn vz-hv" data-rt="manage">Sections, look and cycles</button></p>`;
@@ -351,7 +352,7 @@ function picked(t, e) {
351
352
  }
352
353
  function setupHtml(t) {
353
354
  const s = t.setup;
354
- if (!t.loaded) return '<p class="vz-empty" role="status">Reading the report.</p>';
355
+ if (!t.loaded) return SB.loading('Reading the report.');
355
356
  if (t.gone) return `<p class="vz-msg">This template (${esc(t.block.id)}) is deleted, or it is not set up in this workspace. Its issued reports are kept.</p>${cyclesHtml(t)}`;
356
357
  const cur = s.status === 'paused' ? 'off' : s.schedule;
357
358
  const want = t.block.schedule && !sameSched(t.block.schedule, cur) ? `<div class="vz-ask"><p>PMOS proposes: <b>${esc(schedWords(t.block.schedule))}</b></p><div>${btn('sched-use', 'Change the schedule', { off: t.busy })}</div></div>` : '';