create-pmos 0.784.0 → 0.786.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 (78) hide show
  1. package/package.json +90 -59
  2. package/payload/AGENTS.md +160 -0
  3. package/payload/KIT-VERSION +1 -1
  4. package/payload/design-system/ui/components/Badge/README.md +2 -2
  5. package/payload/design-system/ui/components/Glyph/README.md +28 -0
  6. package/payload/design-system/ui/components/bundle.css +3 -0
  7. package/payload/planning/evals/eval-calibration.md +1 -1
  8. package/payload/planning/okrs/health-budgets.md +1 -1
  9. package/payload/state/discoveries.md +1 -1
  10. package/workspace/bin/card-catalog-gen.js +22 -0
  11. package/workspace/board-columns-test.js +2 -2
  12. package/workspace/briefing-premium-insights-test.js +5 -4
  13. package/workspace/calm-timeline-test.js +4 -3
  14. package/workspace/changelog.json +89 -0
  15. package/workspace/design-system/ui/components/Badge/README.md +2 -2
  16. package/workspace/design-system/ui/components/Glyph/README.md +28 -0
  17. package/workspace/design-system/ui/components/bundle.css +3 -0
  18. package/workspace/guide/cli.md +19 -0
  19. package/workspace/guide/home.md +5 -3
  20. package/workspace/guide/index.md +2 -2
  21. package/workspace/guide/jira.md +8 -0
  22. package/workspace/guide/layout.md +16 -2
  23. package/workspace/lib/briefing-premium-agent.js +3 -0
  24. package/workspace/lib/card-catalog-gen.js +123 -0
  25. package/workspace/lib/cos-chat.js +1 -0
  26. package/workspace/lib/declined-asks.js +177 -0
  27. package/workspace/lib/declined-cli.js +87 -0
  28. package/workspace/lib/goal-chat.js +1 -0
  29. package/workspace/lib/initiative-chat.js +1 -0
  30. package/workspace/lib/jira-status.js +11 -2
  31. package/workspace/lib/live-events.js +99 -0
  32. package/workspace/lib/pmos-verbs.js +6 -0
  33. package/workspace/lib/program-chat.js +1 -0
  34. package/workspace/lib/quiet-cli.js +81 -0
  35. package/workspace/lib/quiet-sweep.js +228 -0
  36. package/workspace/lib/report-chat.js +1 -0
  37. package/workspace/lib/route-modules.js +1 -0
  38. package/workspace/lib/routes-backlog.js +21 -1
  39. package/workspace/lib/routes-live-rows.js +30 -0
  40. package/workspace/lib/routes-slash.js +142 -2
  41. package/workspace/lib/routes-your-move.js +39 -3
  42. package/workspace/lib/task-cli.js +5 -3
  43. package/workspace/lib/workflow-chat.js +1 -0
  44. package/workspace/okr-goals-ui-test.js +3 -2
  45. package/workspace/package-lock.json +2 -2
  46. package/workspace/package.json +1 -1
  47. package/workspace/public/pm/bd-cols.js +3 -1
  48. package/workspace/public/pm/bd-span.js +13 -7
  49. package/workspace/public/pm/bd-sprint.js +29 -1
  50. package/workspace/public/pm/bd-views.js +6 -3
  51. package/workspace/public/pm/bd-work-ds.css +1 -0
  52. package/workspace/public/pm/bd-work.js +15 -2
  53. package/workspace/public/pm/cozy-board.css +3 -0
  54. package/workspace/public/pm/cozy-insights.css +3 -4
  55. package/workspace/public/pm/ds-bridge.css +12 -0
  56. package/workspace/public/pm/goal-forecast.js +7 -4
  57. package/workspace/public/pm/home-app.js +14 -4
  58. package/workspace/public/pm/komorebi.css +1 -0
  59. package/workspace/public/pm/live-edit.js +34 -3
  60. package/workspace/public/pm/live-feed.js +43 -0
  61. package/workspace/public/pm/okr-list.js +5 -2
  62. package/workspace/public/pm/premium-board.js +2 -0
  63. package/workspace/public/pm/premium-insights.js +10 -4
  64. package/workspace/public/pm/premium-vw-doc.css +5 -0
  65. package/workspace/public/pm/premium-vw-doc.js +11 -31
  66. package/workspace/public/pm/premium-vw-file.js +13 -8
  67. package/workspace/public/pm/premium-vw-guide.css +9 -0
  68. package/workspace/public/pm/premium-vw-guide.js +20 -17
  69. package/workspace/public/pm/quiet-view.js +107 -0
  70. package/workspace/public/pm/reading-view.js +44 -0
  71. package/workspace/public/pm/state-glyph.js +135 -0
  72. package/workspace/skills/jira-sync.skill +4 -3
  73. package/workspace/task-milestones-test.js +2 -2
  74. package/workspace/test-lists/a2ui-chat-rules.json +9 -0
  75. package/workspace/test-lists/a2ui-live-rows.json +9 -0
  76. package/workspace/test-lists/declined-asks.json +9 -0
  77. package/workspace/test-lists/quiet-sweep.json +9 -0
  78. package/workspace/test-lists/state-glyph.json +5 -0
@@ -0,0 +1,43 @@
1
+ /* pm/live-feed.js — a change the chat makes shows on the open page at once, on that one row (bet A458, path-level live updates; job #1750).
2
+ *
3
+ * `pmos task add|set|state|remove` (lib/task-cli.js) writes one event per changed field; the server streams them (GET /api/live-rows,
4
+ * lib/routes-live-rows.js). Each event is put on the rows the page already holds (live-edit.js remote()), so Today, Work and an open
5
+ * popup move the row with no list read again. The window event 'pmos:action' { kind, id, field, value, undo, remote: true } follows
6
+ * each one, the same event the card buttons send (pm/action-run.js), so a card that listens follows a chat change too.
7
+ *
8
+ * opOf(ev) the live-edit op of one event, or null: { kind: 'patch', id, fields } | { kind: 'remove', id } | { kind: 'add', ini, row }
9
+ * start(g) open the stream once per page; the browser opens it again by itself after a drop
10
+ *
11
+ * The chat's turn-end read (cz:chat-turn) is unchanged: it still catches every write this stream does not carry. */
12
+ import { remote, FIELDS } from './live-edit.js';
13
+
14
+ export function opOf(ev) {
15
+ if (!ev || typeof ev !== 'object' || ev.kind !== 'task' || typeof ev.id !== 'string' || !ev.id) return null;
16
+ if (ev.field === 'removed') return { kind: 'remove', id: ev.id };
17
+ if (ev.field === 'added') {
18
+ const v = ev.value && typeof ev.value === 'object' ? ev.value : null;
19
+ if (!v || typeof v.initiative !== 'string' || !v.initiative || typeof v.title !== 'string') return null;
20
+ const { initiative, ...rest } = v;
21
+ return { kind: 'add', ini: initiative, row: { uid: ev.id, ...rest } };
22
+ }
23
+ if (!Object.prototype.hasOwnProperty.call(FIELDS, ev.field) || ev.field === 'title') return null;
24
+ return { kind: 'patch', id: ev.id, fields: { [ev.field]: ev.field === 'state' ? String(ev.value) : ev.value === null ? '' : ev.value } };
25
+ }
26
+
27
+ let started = false;
28
+ export function start(g = globalThis) {
29
+ if (started || !g || typeof g.EventSource !== 'function') return false;
30
+ if (g.PMOS_READONLY) return false; // a published, read-only board (pm/readonly-boot.js) reads nothing from the server
31
+ started = true;
32
+ let es;
33
+ try { es = new g.EventSource('/api/live-rows'); } catch { started = false; return false; }
34
+ es.onmessage = (m) => {
35
+ let ev = null;
36
+ try { ev = JSON.parse(m.data); } catch { return; }
37
+ const op = opOf(ev);
38
+ if (!op) return;
39
+ remote(op);
40
+ try { g.dispatchEvent(new g.CustomEvent('pmos:action', { detail: { kind: ev.kind, id: ev.id, field: ev.field, value: ev.value, undo: !!ev.undo, remote: true } })); } catch { /* no listener needs it */ }
41
+ };
42
+ return true;
43
+ }
@@ -15,6 +15,7 @@
15
15
  * THE RULE (as the other premium models): a number, a dot or an age is made only from a field of a record. A goal with no reading has a hollow dot
16
16
  * and no status. Initiative delivery status never sets a dot. */
17
17
 
18
+ import { stateGlyph } from './state-glyph.js';
18
19
  export const DAY = 864e5;
19
20
  const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
20
21
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -61,7 +62,9 @@ function budgetDot(b) {
61
62
  /** The dot's class on .cz-dot (cozy.css): a broken limit pulses (m-crit), the one time a dot moves. */
62
63
  export const DOT_CLS = { on: 'ok', behind: 'risk', close: 'risk', broken: 'red m-crit', none: 'hollow', q: 'q' };
63
64
  export const DOT_SAY = { on: 'On its line', behind: 'Behind its line', close: 'Close to its limit', broken: 'Over its limit', none: 'No reading yet', q: 'No line to judge it by' };
64
- export const dotHtml = (d, cls = '') => `<span class="cz-dot okr-dot ${DOT_CLS[d] || 'hollow'}${cls ? ' ' + cls : ''}" role="img" aria-label="${esc(DOT_SAY[d] || '')}"></span>`;
65
+ /** A goal's state as the shared glyph (state-glyphs): the shape says the state, the words above are its why. */
66
+ export const DOT_STATE = { on: 'on', behind: 'risk', close: 'risk', broken: 'late', none: 'none', q: 'none' };
67
+ export const dotHtml = (d, cls = '', size = 14) => stateGlyph(DOT_STATE[d] || 'none', { why: DOT_SAY[d] || '', size, progress: 1, cls: 'okr-dot' + (cls ? ' ' + cls : '') });
65
68
 
66
69
  /* ── the row's second line ─────────────────────────────────────────────────────────────────────────────────────────────────────── */
67
70
  /** How old the latest reading is: "today", "yesterday", the weekday within the week, else "12 days old". A reading past its cadence is stale. */
@@ -250,4 +253,4 @@ export function productLine(S) {
250
253
  const text = S.line || [S.on ? S.on + ' on ' + (S.on === 1 ? 'its' : 'their') + ' line' : '', bad[0] || '', bad.length > 1 ? (bad.length - 1) + ' more need' + (bad.length === 2 ? 's' : '') + ' you' : '', none ? none + ' not read yet' : ''].filter(Boolean).join(' · ');
251
254
  return { text, dots: S.dots.map((d) => d.dot) };
252
255
  }
253
- export const productLineHtml = (L) => `<span class="okr-pl"><span class="okr-plt">${esc(L.text)}</span><span class="okr-pld" aria-hidden="true">${L.dots.map((d) => dotHtml(d)).join('')}</span></span>`;
256
+ export const productLineHtml = (L) => `<span class="okr-pl"><span class="okr-plt">${esc(L.text)}</span><span class="okr-pld" aria-hidden="true">${L.dots.map((d) => dotHtml(d, '', 10)).join('')}</span></span>`;
@@ -73,6 +73,8 @@ import * as LS from './load-shapes.js'; // the skeleton and the slow-case line
73
73
  import * as STRAT from './bd-strategy.js'; // the product's strategy in five lines above the initiatives (bet A458)
74
74
  import * as PRIN from './bd-principles.js'; // the product's principles drafted from its decisions, below the strategy (bet A352)
75
75
  import * as SWN from './cozy-status-when.js'; // the day a status move really happened, in the toast (round 3 point 18)
76
+ import { pressHold } from './state-glyph.js'; // a state is a shape, not a word (state-glyphs)
77
+ pressHold(typeof document !== 'undefined' ? document.body : null); // on a phone, press and hold a state glyph for its word and why (state-glyphs)
76
78
 
77
79
  const VIEW_KEY = 'pmos.board.view', PVIEW_KEY = 'pmos.board.pview', SPAN_KEY = 'pmos.board.span', GROUPING_KEY = 'pmos.board.grouping';
78
80
  let M = null; // the model
@@ -48,9 +48,11 @@ import * as IP2 from './ins-pane.js'; // Intelligence as the first panel (pane
48
48
  import * as KO from './komorebi.js'; // the design system's Chart behaviour: hover tip, keys, press a point (North Star, intelligence-ds-page)
49
49
  import * as GC from './goals-clear.js';
50
50
  import * as LAB from './cozy-lab-ins.js'; // Intelligence › Lab (idle lab B+C, canvas I1 IlBC): what fits no initiative, the week's background record, next time
51
+ import { stateGlyph, pressHold } from './state-glyph.js'; // a state is a shape, not a word (state-glyphs)
51
52
  import * as FCV from './goal-forecast.js'; // a goal's forecast in its Viewer (FcViewer, FcPhone): the state line, the range band, the baseline ✓ // goals made clear (batch 18 item 11, 11-B): the drafts table, the check panel, first readings, failed and held
52
53
  import { provenStatus } from './status-proof.js'; // T3: an initiative's status word renders only with its source and read time
53
54
  import * as POP from './cozy-popup.js'; // the one popup (slice 2 of the six-place navigation): an initiative opens in it with Ask PMOS beside it
55
+ pressHold(typeof document !== 'undefined' ? document.body : null); // on a phone, press and hold a state glyph for its word and why (state-glyphs)
54
56
  /* An initiative's link (a goal's "Moved by", the outcomes table, a step) opens the initiative in the one popup on a desk, read the way the
55
57
  * Viewer reads it (premium-vw-item.js), with Ask PMOS about it on the right. ⌘/Ctrl-click, a middle click and a phone keep the link. */
56
58
  document.addEventListener('click', (e) => {
@@ -902,7 +904,10 @@ function movePill(r) {
902
904
  if (d !== null && d >= 0 && d <= 14) return ['q', 'Ships in ' + d + ' days'];
903
905
  return { late: ['late', 'Late'], 'at risk': ['risk', 'At risk'], 'on hold': ['q', 'On hold'], 'on track': ['q', 'On track'] }[ps] || null;
904
906
  }
905
- const initRow = (r, pill = true) => { const p = pill ? movePill(r) : null; return `<a class="ins-ini" href="${iniHref(r.id)}">${trackHtml(r)}<span class="n">${esc(r.title)}</span>${p ? `<span class="pm-badge ${p[0]}">${esc(p[1])}</span>` : ''}</a>`; };
907
+ // the pill's state words become the glyph (state-glyphs); a fact ("3 days over", "No owner", "Ships in 4 days") stays as text
908
+ const PILL_STATE = { Late: 'late', 'At risk': 'risk', 'On hold': 'wait', 'On track': 'on', Done: 'done', Stopped: 'none' };
909
+ const pillGlyph = (p) => { const st = PILL_STATE[p[1]] || (p[0] === 'late' ? 'late' : p[0] === 'risk' ? 'risk' : ''); return { g: st ? stateGlyph(st, { why: PILL_STATE[p[1]] ? '' : p[1], progress: 1 }) : '', fact: PILL_STATE[p[1]] ? '' : p[1] }; };
910
+ const initRow = (r, pill = true) => { const p = pill ? movePill(r) : null, x = p ? pillGlyph(p) : { g: '', fact: '' }; return `<a class="ins-ini" href="${iniHref(r.id)}">${trackHtml(r)}${x.g}<span class="n">${esc(r.title)}</span>${x.fact ? `<span class="pm-badge ${p[0]}">${esc(x.fact)}</span>` : ''}</a>`; };
906
911
  const TONE_BAR = { ok: 'var(--cz-dot-ok)', late: 'var(--cz-dot-late)', red: 'var(--cz-dot-red)', q: 'var(--cz-dot-q)', risk: 'var(--cz-dot-risk)' };
907
912
  /** Done or not: its steps as a checklist; Stay within: the readings over a green band that marks the budget, with no forecast. */
908
913
  const stepsHtml = (g) => `<div class="ins-steps">${(g.steps || []).map((s) => `<span class="${s.done ? 'on' : ''}"><i class="ins-cb${s.done ? ' on' : ''}">${s.done ? SV(I.chk, 3) : ''}</i>${esc(s.text)}</span>`).join('')}</div>`;
@@ -969,7 +974,7 @@ function paceHtml(g) {
969
974
  * g.forecast comes from lib/forecast.js through /api/insights-premium; without it the row keeps the pace above. Too early draws no bar (zero is
970
975
  * silence); held dims the bar and never extends it. */
971
976
  const FC_WORD = { 'on-track': ['ok', 'On track'], 'at-risk': ['risk', 'At risk'], 'will-miss': ['red', 'Will miss'], 'too-early': ['q', 'Too early'], held: ['q', 'Held'] };
972
- const FC_C = { ok: 'var(--cz-ok)', risk: 'var(--cz-risk)', red: 'var(--cz-red)', q: 'var(--cz-ink3)' };
977
+ const FC_STATE = { 'on-track': 'on', 'at-risk': 'risk', 'will-miss': 'late', 'too-early': 'none', held: 'none' }; // the forecast's state as a glyph (state-glyphs)
973
978
  const fcV = (g, v) => unitV(g, Math.round(v * 10) / 10);
974
979
  function forecastHtml(g) {
975
980
  const F = g.forecast, w = F && FC_WORD[F.state];
@@ -990,7 +995,7 @@ function forecastHtml(g) {
990
995
  const note = F.state === 'too-early' ? 'Needs 3 weeks of readings' + (wk ? ', ' + wk + ' so far' : '')
991
996
  : F.state === 'held' ? (F.asOf ? src + 'last read ' + md(Date.parse(F.asOf)) : 'Not read lately') + '. Range held'
992
997
  : fcV(g, F.low) + ' to ' + fcV(g, F.high) + (F.driftFrom ? '. Was on track on ' + md(Date.parse(F.driftFrom)) : '');
993
- return `<div class="pace" role="cell"><b style="color:${FC_C[w[0]]}">${esc(w[1])}</b>${bar}<div class="note">${esc(note)}</div></div>`;
998
+ return `<div class="pace" role="cell">${stateGlyph(FC_STATE[F.state] || 'none', { why: w[1], progress: 1 })}${bar}<div class="note">${esc(note)}</div></div>`;
994
999
  }
995
1000
  /** What happened to a goal's last reading, said once under its number: "not read Mon 16 Nov", "1 reading held". */
996
1001
  const gcSay = (g) => (g.failed ? 'not read ' + GC.dayTxt(g.failed.at) : (g.held || []).length ? ((g.held.length === 1 ? '1 reading' : g.held.length + ' readings') + ' held') : '');
@@ -1199,6 +1204,7 @@ function budgetsHtml(D) {
1199
1204
  return '<div class="ins-grp" role="row"><span role="cell">Health budgets</span> <span class="q">always on, judged every week</span></div>' + B.map(budgetRow).join('');
1200
1205
  }
1201
1206
  /* the phone (Iq8Phone): one card per goal, its status at the top right, its value, its so-far, its bar and the first initiative that moves it */
1207
+ const CARD_STATE = { 'Not read': 'none', Held: 'none', Behind: 'late', Ahead: 'on', 'On track': 'on' }; // the phone card's state, as a glyph before its title (state-glyphs)
1202
1208
  function cardPill(g) {
1203
1209
  if (g.failed) return ['risk', 'Not read'];
1204
1210
  if ((g.held || []).length) return ['risk', 'Held'];
@@ -1219,7 +1225,7 @@ function drawCards(G, okr = false) {
1219
1225
  function cardOf(g) {
1220
1226
  const p = cardPill(g), tg = g.targetTxt ? (g.type === 'Count' ? 'of ' : 'target ') + g.targetTxt + (g.byAt ? ' by ' + md(day(g.byAt)) : '') : 'no target', first = GC.firstOf(g);
1221
1227
  const gr = first ? `<span class="note">${esc(GC.firstMeta(g).split(' · ').slice(1).join(' · '))}</span>` : isBlocks(g) ? blocksHtml(g, 190, false) : g.type === 'Stay within' && g.series.length && g.target !== null ? bandSvg(g.series, g.target, g.limit !== 'floor', g.tone, g.title, 190, 30) : g.key ? sparkHtml(g, 190, 30) : '';
1222
- return `<div class="ins-card" role="listitem" data-goal="${esc(g.id)}" tabindex="0" aria-label="${esc(g.title)}"><div class="ins-ch"><b>${g.krTok ? `<span class="ins-krt">${esc(g.krTok)}</span>` : ''}${esc(g.title)}</b>${p ? `<span class="pm-badge ${p[0]}">${p[1]}</span>` : ''}</div>`
1228
+ return `<div class="ins-card" role="listitem" data-goal="${esc(g.id)}" tabindex="0" aria-label="${esc(g.title)}"><div class="ins-ch">${p ? stateGlyph(CARD_STATE[p[1]] || 'none', { why: p[1], progress: 1 }) : ''}<b>${g.krTok ? `<span class="ins-krt">${esc(g.krTok)}</span>` : ''}${esc(g.title)}</b></div>`
1223
1229
  + `<div class="ins-cs"><span class="pm-badge q ins-type">${esc(g.type)}</span><span class="note">${esc(tg)}</span></div>`
1224
1230
  + `<div class="ins-cv"><b>${esc(nowOf(g))}</b><span class="ins-cg">${gr}</span></div>${first || gcSay(g) ? '' : barHtml(g, ' ins-wide')}`
1225
1231
  + (g.moves[0] ? `<div class="ins-c1">${initRow(g.moves[0], false)}</div>` : '') + '</div>' + (PF ? '' : draftsFor(g.id).map(drHtml).join(''));
@@ -318,3 +318,8 @@ iframe.vwprint{position:fixed;right:0;bottom:0;width:1px;height:1px;border:0;opa
318
318
  .rd-cm p{margin:0}
319
319
  .rd-q{color:var(--muted)}
320
320
  @media (max-width: 720px){ .rd-sb{padding-left:0} .rd-short{padding:var(--space-12) var(--space-16)} }
321
+ /* A page with no Contents (one section or none) gives its column back: the column stays at the reading measure, centred. */
322
+ @media (min-width: 1101px){
323
+ .pm-ds .pm-layout-reading.rd:not(:has(>.pm-contents)){grid-template:"head head" auto "main margin" 1fr/minmax(0,var(--doc-measure)) var(--width-margin)}
324
+ .pm-ds .pm-layout-reading.rd:not(:has(>.pm-contents)):not(:has(>.pm-margin)){grid-template:"head" auto "main" 1fr/minmax(0,var(--doc-measure))}
325
+ }
@@ -13,8 +13,8 @@ import { vwOpen, vwStyle, vwConfirm } from './premium-viewer.js';
13
13
  import { $, $$, esc, toast, AI, CHECK } from './premium-shell.js';
14
14
  import { editBody, acceptBody, rejectBody, askBody, askLine, relationsOf, copyKindOf, copyView, proposalsModel } from './premium-doc-edit.js';
15
15
  import { bodyHtml, pageHead, propHtml, splitDoc, overlay, overlayLine, mergeEdit, readMinutes, dayOf, PANELS, signOffOf } from './premium-vw-doc-model.js';
16
- import { adler } from './cozy-adler.js';
17
- import { readingOf, foldKey, foldsOf, foldsWith } from './reading-model.js'; // the Reading layout (reading-layouts, A334) // the sign-off under a page the agent drafted (batch 17 item 4-A, canvas AdH4)
16
+ import { adler } from './cozy-adler.js'; // the sign-off under a page the agent drafted (batch 17 item 4-A, canvas AdH4)
17
+ import { readingPageHtml, wireReading } from './reading-view.js'; // the Reading layout (reading-layouts, A334)
18
18
 
19
19
  const I = (d) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${d}</svg>`;
20
20
  const IC = {
@@ -275,7 +275,6 @@ function makePage(d, ctx) {
275
275
  /* ── the Reading layout (reading-layouts, A334; board ReadingDS): read mode with no agent edit open. Contents at left follows the scroll; the
276
276
  * title and meta strip (who drafted ✦, who checked, for whom); In short; one section per heading, each folds and the open state is kept per
277
277
  * document; comments in the margin beside their section, and no margin when there are none. Edit, Markdown and an agent's edit keep their page. */
278
- const store = { get: (k) => { try { return localStorage.getItem(k); } catch { return null; } }, set: (k, val) => { try { localStorage.setItem(k, val); } catch { /* a private window */ } } };
279
278
  function metaHtml(R) {
280
279
  const revs = (P.log && P.log.revisions) || [], last = revs[revs.length - 1], m = R.meta, bits = [];
281
280
  if (m.drafted) bits.push(`${m.drafted.by === 'PMOS' ? `<span class="rd-ai" aria-hidden="true">${AI}</span>PMOS drafted it` : `${esc(m.drafted.by)} wrote it`}${m.drafted.at ? ' ' + esc(dayOf(m.drafted.at)) : ''}`);
@@ -286,34 +285,15 @@ function makePage(d, ctx) {
286
285
  return `<p class="rd-meta cfby">${bits.join(' · ')}</p>`;
287
286
  }
288
287
  function readingHtml(h, p) {
289
- const R = readingOf(P.text, { title: h.title || String(d.path).split('/').pop(), revisions: (P.log && P.log.revisions) || [], comments: ctx.comments ? ctx.comments() : [] });
290
- const folds = foldsOf(store.get(foldKey(d.path)));
291
288
  const unsaved = P.work != null && P.work !== P.text ? `<p class="vwmut vwline" role="status">You have changes that are not saved yet. Edit shows them again.${P.stale ? ' The chat changed the file since. Cancel there shows the new text.' : ''}</p>` : '';
292
- let start = 0;
293
- const md = (src) => { const r = bodyHtml(src, { start }); start += r.heads.length; return r.html; };
294
- const secs = R.sections.map((sx) => `<details class="rd-sec" id="${esc(sx.id)}" data-rd="${esc(sx.id)}"${folds[sx.id] === false ? '' : ' open'}><summary><h2>${esc(sx.name)}</h2>${sx.comments ? `<span class="rd-cn" title="${sx.comments} comments">${sx.comments}</span>` : ''}</summary><div class="rd-sb">${md(sx.md)}</div></details>`).join('');
295
- const contents = R.contents.length > 1 ? `<nav class="pm-contents" aria-label="Contents"><p class="rd-lab">Contents</p>${R.contents.map((c, i) => `<a href="#${esc(c.id)}" data-rdto="${esc(c.id)}" aria-current="${i === 0}">${esc(c.name)}</a>`).join('')}</nav>` : '';
296
- const margin = R.margin.length ? `<aside class="pm-margin" aria-label="Comments">${R.margin.map((c) => `<div class="rd-cm" data-for="${esc(c.id)}">${c.quote ? `<p class="rd-q">on “${esc(c.quote)}”</p>` : ''}<p><b>${esc(c.who || '')}</b>${c.at ? ' · ' + esc(dayOf(c.at) || c.at) : ''}</p><p>${esc(c.text)}</p></div>`).join('')}</aside>` : '';
297
- return `<div class="pm-layout-reading rd"><div class="pm-head">${toolsHtml(p)}</div>${contents}<div class="pm-main">${moreBar()}${unsaved}`
298
- + `<header class="rd-hd"><h1 class="rd-t cft">${esc(R.title)}</h1>${metaHtml(R)}`
299
- + (h.labels.length ? `<div class="cflb">${h.labels.map((l) => `<span>${esc(l)}</span>`).join('')}</div>` : '')
300
- + (h.props.length ? `<details class="rd-props"><summary>Properties · ${h.props.length}</summary><table class="cfpr" aria-label="Properties">${h.props.map(([k, val]) => `<tr><th scope="row">${esc(k)}</th><td>${propHtml(k, val)}</td></tr>`).join('')}</table></details>` : '') + '</header>'
301
- + `<article class="cf rd-doc"><div class="cfb">`
302
- + (R.inShort ? `<section class="rd-short" id="rd-in-short" aria-label="In short"><p class="rd-lab">In short</p>${md(R.inShort)}</section>` : '')
303
- + `${R.lead ? md(R.lead) : ''}${secs || (R.lead ? '' : '<p class="vwmut">The file has no text yet.</p>')}</div>`
304
- + `<footer class="cff"><span>${v() ? 'v' + v() : ''}</span><span class="gap"></span><code>${esc(d.path)}</code></footer></article>`
305
- + signHtml() + sideHtml() + `</div>${margin}</div>`;
306
- }
307
- /** Wire the Reading layout: a fold is kept per document; Contents jumps to a section (opening it) and follows the scroll. */
308
- function wireReading() {
309
- const box = $('.rd', el); if (!box) return;
310
- $$('.rd-sec', box).forEach((x) => x.addEventListener('toggle', () => store.set(foldKey(d.path), foldsWith(store.get(foldKey(d.path)), x.dataset.rd, x.open))));
311
- const nav = $('.pm-contents', box); if (!nav) return;
312
- const mark = (id) => $$('[data-rdto]', nav).forEach((a) => a.setAttribute('aria-current', String(a.dataset.rdto === id)));
313
- nav.onclick = (e) => { const a = e.target.closest('[data-rdto]'); if (!a) return; e.preventDefault(); const t = box.querySelector('#' + CSS.escape(a.dataset.rdto)); if (!t) return; if (t.tagName === 'DETAILS') t.open = true; t.scrollIntoView({ block: 'start', behavior: 'smooth' }); mark(a.dataset.rdto); };
314
- if (typeof IntersectionObserver !== 'function') return;
315
- const io = new IntersectionObserver((es) => { const top = es.filter((x) => x.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top)[0]; if (top) mark(top.target.id); }, { root: el, rootMargin: '0px 0px -70% 0px' });
316
- $$('#rd-in-short, .rd-sec', box).forEach((x) => io.observe(x));
289
+ return readingPageHtml(P.text, {
290
+ path: d.path, title: h.title || String(d.path).split('/').pop(), revisions: (P.log && P.log.revisions) || [], comments: ctx.comments ? ctx.comments() : [],
291
+ head: toolsHtml(p), above: moreBar() + unsaved, meta: metaHtml,
292
+ extraHead: (h.labels.length ? `<div class="cflb">${h.labels.map((l) => `<span>${esc(l)}</span>`).join('')}</div>` : '')
293
+ + (h.props.length ? `<details class="rd-props"><summary>Properties · ${h.props.length}</summary><table class="cfpr" aria-label="Properties">${h.props.map(([k, val]) => `<tr><th scope="row">${esc(k)}</th><td>${propHtml(k, val)}</td></tr>`).join('')}</table></details>` : ''),
294
+ foot: `<footer class="cff"><span>${v() ? 'v' + v() : ''}</span><span class="gap"></span><code>${esc(d.path)}</code></footer>`,
295
+ below: signHtml() + sideHtml(),
296
+ });
317
297
  }
318
298
  function pageHtml() {
319
299
  if (P.err) return `<p class="vwempty">${esc(P.err)}</p>`;
@@ -349,7 +329,7 @@ function makePage(d, ctx) {
349
329
  const reading = P.mode === 'read' && !ctx.host && P.text != null && !P.err && !openProp();
350
330
  el.innerHTML = `<div class="vwdoc${reading ? ' rdw' : ''}">${pageHtml()}</div>`;
351
331
  el.scrollTop = keepScroll;
352
- if (reading) wireReading(); else if (P.mode === 'read') tocOf();
332
+ if (reading) wireReading(el, el, d.path); else if (P.mode === 'read') tocOf();
353
333
  if (P.mode === 'edit') startEdit();
354
334
  }
355
335
 
@@ -10,6 +10,7 @@
10
10
  import { vwOpen, vwStyle } from './premium-viewer.js';
11
11
  import { bodyHtml, pageHead, splitDoc, readMinutes } from './premium-vw-doc-model.js';
12
12
  import { needsReader, drawPdf } from './premium-vw-pdf.js';
13
+ import { readingPageHtml, wireReading } from './reading-view.js'; // a markdown file reads in the Reading layout (reading-layouts)
13
14
 
14
15
  const CHECK_MS = 2500;
15
16
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -45,12 +46,12 @@ export function downloadsOf(f) {
45
46
  const DL_ICON = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v11M7 10l5 5 5-5M5 20h14"/></svg>';
46
47
  const SH_ICON = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 15V4M8 8l4-4 4 4M6 12v7h12v-7"/></svg>';
47
48
  /** The title row: the name, and the download icon when the file was read. */
48
- function headHtml(f, title) {
49
+ function actsHtml(f) {
49
50
  const n = downloadsOf(f).length;
50
- const dl = n ? `<div class="vwacts"><button type="button" class="vwib" data-fdl aria-label="Download${n > 1 ? '…' : ''}" title="Download"${n > 1 ? ' aria-haspopup="menu" aria-expanded="false"' : ''}>${DL_ICON}</button>`
51
+ return n ? `<div class="vwacts"><button type="button" class="vwib" data-fdl aria-label="Download${n > 1 ? '…' : ''}" title="Download"${n > 1 ? ' aria-haspopup="menu" aria-expanded="false"' : ''}>${DL_ICON}</button>`
51
52
  + `<button type="button" class="vwib" data-fsh aria-label="Share…" title="Share" aria-haspopup="dialog" aria-expanded="false">${SH_ICON}</button></div>` : '';
52
- return `<header class="cfh vwfh"><h1 class="cft">${esc(title)}</h1>${dl}</header>`;
53
53
  }
54
+ function headHtml(f, title) { return `<header class="cfh vwfh"><h1 class="cft">${esc(title)}</h1>${actsHtml(f)}</header>`; }
54
55
  /** The MIME type the original is saved with. */
55
56
  export function mimeOf(f) { return isHtml(f) ? 'text/html' : f.kind === 'markdown' ? 'text/markdown' : 'text/plain'; }
56
57
  /** A file as one standalone page, for the print frame and for a share link's copy (premium-viewer-share D3, S2): an .html file as it is, markdown as a
@@ -108,11 +109,14 @@ export function fileHtml(f, view = 'page') {
108
109
  + `<footer class="cff"><span>Read-only · PDF</span><span class="gap"></span><code>${esc(f.abs || f.rel)}</code></footer></article></div>`;
109
110
  const foot = `<footer class="cff"><span>Read-only · ${readMinutes(f.text)} min read</span><span class="gap"></span><code>${esc(f.abs || f.rel)}</code></footer>`;
110
111
  if (f.kind === 'markdown') {
111
- const h = pageHead(f.text), sd = splitDoc(f.text);
112
- const body = bodyHtml([sd.pre, ...sd.sections.map((s, n) => (n === 0 && h.h1 ? s.body : s.head + '\n' + s.body))].join('\n')).html;
113
- return `<div class="vwdoc"><article class="cf vwfile">${headHtml(f, h.title || f.name).replace('</header>', '')}`
114
- + (h.labels.length ? `<div class="cflb">${h.labels.map((l) => `<span>${esc(l)}</span>`).join('')}</div>` : '')
115
- + `</header><div class="cfb">${body || '<p class="vwmut">The file has no text yet.</p>'}</div>${foot}</article></div>`;
112
+ // the Reading layout (reading-layouts, A334): a text file reads like every document; Download and Share sit in the head row
113
+ const h = pageHead(f.text);
114
+ return `<div class="vwdoc rdw">` + readingPageHtml(f.text, {
115
+ path: 'file:' + (f.abs || f.rel || f.path), title: h.title || f.name, head: `<span class="gap"></span>${actsHtml(f)}`,
116
+ meta: () => `<p class="rd-meta cfby">Read-only · ${readMinutes(f.text)} min read</p>`,
117
+ extraHead: h.labels.length ? `<div class="cflb">${h.labels.map((l) => `<span>${esc(l)}</span>`).join('')}</div>` : '',
118
+ foot: `<footer class="cff"><span>Read-only</span><span class="gap"></span><code>${esc(f.abs || f.rel)}</code></footer>`,
119
+ }) + '</div>';
116
120
  }
117
121
  const ext = (/\.([A-Za-z0-9]+)$/.exec(f.name || '') || [])[1] || 'text';
118
122
  if (isHtml(f)) {
@@ -142,6 +146,7 @@ export function openChatFile(p, ctx = {}) {
142
146
  // the download icon: one format saves at once; more open a menu under the icon (Escape or a press elsewhere closes it)
143
147
  const wire = (el) => {
144
148
  const r = el.querySelector('.vwpdfr[data-pdf-src]'); if (r) drawPdf(r, r.dataset.pdfSrc);
149
+ wireReading(el, el, 'file:' + (st.f.abs || st.f.rel || st.f.path));
145
150
  el.onclick = (e) => {
146
151
  const d = e.target.closest('[data-fdl]');
147
152
  if (d) { const opts = downloadsOf(st.f); if (opts.length === 1) download(st.f, opts[0].fmt); else dlMenu(d, opts); return; }
@@ -38,3 +38,12 @@
38
38
  .gd-tog{display:flex}
39
39
  .gd-railon .gd-rail{display:flex;position:absolute;z-index:3;top:64px;left:0;right:0;width:auto;max-height:70vh;padding:var(--space-12);border:1px solid var(--hair);border-radius:14px;background:var(--card-solid);box-shadow:var(--card-shadow)}
40
40
  }
41
+ /* The Reading layout (reading-layouts, A334): the page reads like every document; the page rail opens over it from the list icon at every
42
+ width, and the section chips stand in for Contents where Contents is hidden (under 1100 px). */
43
+ .gd-railable{display:block}
44
+ .gd-railable .gd-tog{display:flex}
45
+ .gd-railable>.gd-rail{display:none}
46
+ .gd-railable.gd-railon>.gd-rail{display:flex;position:absolute;z-index:3;top:var(--space-48);left:0;width:var(--width-margin);max-height:70vh;padding:var(--space-12);border:1px solid var(--line);border-radius:var(--radius-card);background:var(--card);box-shadow:var(--lift)}
47
+ .gd .gd-secs{display:none}
48
+ @media (max-width: 1100px){ .gd .gd-secs{display:flex} }
49
+ @media (max-width: 720px){ .gd-railable.gd-railon>.gd-rail{right:0;width:auto} }
@@ -14,7 +14,9 @@
14
14
  * contentsOf(indexMd) -> [{ group, pages: [{ page, title }] }] from Start here's headings and links (pure) */
15
15
  import { vwOpen, vwStyle } from './premium-viewer.js';
16
16
  import { drill, wide, widthOf } from './cozy-viewer.js';
17
- import { bodyHtml, pageHead, splitDoc, readMinutes } from './premium-vw-doc-model.js';
17
+ import { pageHead, readMinutes } from './premium-vw-doc-model.js';
18
+ import { readingOf } from './reading-model.js';
19
+ import { readingPageHtml, wireReading } from './reading-view.js'; // a guide page reads in the Reading layout (reading-layouts, A334)
18
20
 
19
21
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
20
22
  const NAME = /^[a-z0-9][a-z0-9-]*$/;
@@ -55,22 +57,23 @@ export function railHtml(name, groups, folded = []) {
55
57
  /** Each markdown link to a guide page (`[x](layout.md)`, `[x](layout.md#keys)`) becomes `[x](#guide:layout)`, which the page model keeps as a link. */
56
58
  export const guideLinks = (md) => String(md || '').replace(/\]\(([a-z0-9][a-z0-9-]*)\.md(?:#[^)\s]*)?\)/g, '](#guide:$1)');
57
59
 
58
- /** One guide page: the rail, then the page with its title, its section chips, the text and a quiet footer. */
60
+ /** One guide page in the Reading layout (reading-layouts, A334): the title and "Guide · N min read", then one section per heading that folds,
61
+ * with Contents at the left following the scroll. The page rail (every guide page, Find a page) opens from the list icon in the head row, over
62
+ * the page, at every width. Where Contents is hidden (under 1100 px) the section chips take its place, so a section is one press away. */
59
63
  export function guideHtml(name, text, groups = TOC, folded = []) {
60
- const t = guideLinks(text), h = pageHead(t), sd = splitDoc(t);
61
- const b = bodyHtml([sd.pre, ...sd.sections.map((s, n) => (n === 0 && h.h1 ? s.body : s.head + '\n' + s.body))].join('\n'));
62
- const secs = b.heads.filter((x) => x[0] === 2);
64
+ const t = guideLinks(text), h = pageHead(t), R = readingOf(t, { title: h.title || name });
63
65
  // At most 6 chips show; the rest wait behind "N more", so a long page does not open on a wall of chips.
64
- const chip = ([, s, id], n) => `<a href="#${esc(id)}" class="gd-chip" data-gd-jump="${esc(id)}"${n >= CHIPS ? ' hidden' : ''}>${esc(s)}</a>`;
65
- const more = secs.length > CHIPS ? `<button type="button" class="gd-chip gd-more" data-gd-more>${secs.length - CHIPS} more</button>` : '';
66
- const chips = secs.length > 1 ? `<div class="gd-secs" role="group" aria-label="On this page">${secs.map(chip).join('')}${more}</div>` : '';
66
+ const chip = (x, n) => `<a href="#${esc(x.id)}" class="gd-chip" data-gd-jump="${esc(x.id)}"${n >= CHIPS ? ' hidden' : ''}>${esc(x.name)}</a>`;
67
+ const more = R.contents.length > CHIPS ? `<button type="button" class="gd-chip gd-more" data-gd-more>${R.contents.length - CHIPS} more</button>` : '';
68
+ const chips = R.contents.length > 1 ? `<div class="gd-secs" role="group" aria-label="On this page">${R.contents.map(chip).join('')}${more}</div>` : '';
67
69
  const home = name === 'index' ? '' : '<span class="gap"></span><a href="#guide:index">Start here</a>';
68
- return `<div class="vwdoc gd"><div class="gd-wrap">${railHtml(name, groups || [], folded)}`
69
- + `<article class="cf vwfile gd-read"><header class="cfh vwfh"><h1 class="cft">${esc(h.title || name)}</h1>`
70
- + `<div class="vwacts gd-tog"><button type="button" class="vwib" data-gd-toc aria-label="Guide pages" title="Guide pages" aria-expanded="false">${TOC_ICON}</button></div></header>`
71
- + chips
72
- + `<div class="cfb">${b.html || '<p class="vwmut">This page has no text yet.</p>'}</div>`
73
- + `<footer class="cff"><span>Guide · ${readMinutes(text)} min read</span>${home}</footer></article></div></div>`;
70
+ return `<div class="vwdoc gd rdw"><div class="gd-wrap gd-railable">${railHtml(name, groups || [], folded)}`
71
+ + readingPageHtml(t, {
72
+ path: 'guide:' + name, title: h.title || name, empty: 'This page has no text yet.',
73
+ head: `<div class="vwacts gd-tog"><button type="button" class="vwib" data-gd-toc aria-label="Guide pages" title="Guide pages" aria-expanded="false">${TOC_ICON}</button></div><span class="gap"></span>`,
74
+ meta: () => `<p class="rd-meta cfby">Guide · ${readMinutes(text)} min read</p>`, extraHead: chips,
75
+ foot: `<footer class="cff"><span>Guide</span>${home}</footer>`,
76
+ }) + '</div></div>';
74
77
  }
75
78
 
76
79
  const failHtml = (why) => `<div class="vwdoc"><div class="vwfnone" role="status"><b>The guide page could not be shown</b><p class="vwmut">${esc(why)}</p></div></div>`;
@@ -106,7 +109,7 @@ function wire(el) {
106
109
  const m = e.target.closest('[data-gd-more]');
107
110
  if (m) { m.parentElement.querySelectorAll('.gd-chip[hidden]').forEach((c) => { c.hidden = false; }); m.remove(); return; }
108
111
  const j = e.target.closest('[data-gd-jump]');
109
- if (j) { e.preventDefault(); const h = el.querySelector('#' + CSS.escape(j.dataset.gdJump)); if (h) h.scrollIntoView({ block: 'start', behavior: 'smooth' }); return; }
112
+ if (j) { e.preventDefault(); const h = el.querySelector('#' + CSS.escape(j.dataset.gdJump)); if (h) { if (h.tagName === 'DETAILS') h.open = true; h.scrollIntoView({ block: 'start', behavior: 'smooth' }); } return; }
110
113
  const a = e.target.closest('a'); if (!a) return;
111
114
  const href = a.getAttribute('href') || '';
112
115
  const g = /^#guide:([a-z0-9-]+)$/.exec(href);
@@ -122,14 +125,14 @@ export function openGuide(page = 'index') {
122
125
  const id = 'guide:' + name;
123
126
  let pane = null, done = null;
124
127
  pane = vwOpen({ id, kind: 'Guide', title: 'Guide', icon: 'doc', url: '/premium-viewer.html?open=guide&page=' + name,
125
- render: (el) => { el.innerHTML = done || '<div class="vwdoc"><p class="vwmut" role="status">Opening the guide.</p></div>'; wire(el); } });
128
+ render: (el) => { el.innerHTML = done || '<div class="vwdoc"><p class="vwmut" role="status">Opening the guide.</p></div>'; wire(el); wireReading(el, el, 'guide:' + name); } });
126
129
  try { if (!widthOf('Guide')) wide(true); } catch { /* a page with no cozy Viewer */ }
127
130
  const toc = TOC ? Promise.resolve() : read('index').then((r) => { if (r.ok) TOC = contentsOf(r.text); });
128
131
  Promise.all([read(name), toc]).then(([r]) => {
129
132
  done = r.ok ? guideHtml(name, r.text, TOC, store.get()) : failHtml(r.why);
130
133
  const el = document.querySelector(`.obody.vw[data-vw="${CSS.escape(id)}"]`) || pane;
131
134
  if (el && el.isConnected) {
132
- el.innerHTML = done; el.scrollTop = 0;
135
+ el.innerHTML = done; el.scrollTop = 0; wireReading(el, el, 'guide:' + name);
133
136
  const cur = el.querySelector('.gd-rail [aria-current="page"]'); if (cur) cur.scrollIntoView({ block: 'nearest' });
134
137
  }
135
138
  });
@@ -0,0 +1,107 @@
1
+ /* pm/quiet-view.js — the weekly sweep of quiet work (initiative quiet-work-sweep, bet A503; lib/quiet-sweep.js, GET /api/quiet).
2
+ * Pure apart from openQuiet: Node imports it (quiet-sweep.test.js Q7).
3
+ *
4
+ * rowOf(lists, { looked }) → Today's Your move row ({ key, go: 'quiet', week, title, sub }) or null: null when nothing is quiet
5
+ * (zero is silence) and once the PM opened this week's list. lists: each product's GET /api/quiet answer.
6
+ * listHtml(lists, { esc }) → one row per quiet initiative, most quiet first, grouped by product: how long it was quiet, what PMOS
7
+ * suggests (✦), and three icon presses: Keep, Park, Close
8
+ * openQuiet(lists, H) the list in the Viewer, with its presses. H: { pmPost, toast, toastUndo, onChange }
9
+ * lookedWeek() · markLooked(week) which week the PM opened (this browser only; a missing store reads as not looked)
10
+ * Keep is POST /api/quiet/keep; Park and Close are POST /api/lifecycle (the PM's press), each with Undo. Nothing is sent. */
11
+
12
+ const KEY = 'pmos.quiet.looked';
13
+ const escDefault = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
14
+ const ICON = 'M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z';
15
+ const svg = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="${d}"/></svg>`;
16
+ const ACTS = [
17
+ { act: 'keep', label: 'Keep: still on', icon: 'M20 6 9 17l-5-5' },
18
+ { act: 'park', label: 'Park it', icon: 'M10 4H6v16h4zM18 4h-4v16h4z' },
19
+ { act: 'close', label: 'Close it', icon: 'M18 6 6 18M6 6l12 12' },
20
+ ];
21
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
22
+ const ok = (l) => l && l.ok && Array.isArray(l.items);
23
+ const UNDO_REASON = 'undo'; // the decision journal takes a park's decision out again on this word (lib/decision-journal.js)
24
+
25
+ export function lookedWeek() { try { return localStorage.getItem(KEY) || ''; } catch { return ''; } }
26
+ export function markLooked(week) { try { if (week) localStorage.setItem(KEY, week); } catch { /* this browser keeps no store */ } }
27
+
28
+ /** Today's Your move row for this week's quiet work, or null. */
29
+ export function rowOf(lists, { looked = '' } = {}) {
30
+ const L = (lists || []).filter(ok);
31
+ const total = L.reduce((s, l) => s + (l.total || 0), 0);
32
+ if (!total) return null;
33
+ const week = (L.find((l) => l.week) || {}).week || '';
34
+ if (week && looked === week) return null;
35
+ return { key: 'quiet:' + week, go: 'quiet', week,
36
+ title: plural(total, 'initiative', 'initiatives') + ' quiet 30 days or more',
37
+ sub: 'Keep, park or close each one. Undo stays open.' };
38
+ }
39
+
40
+ function itemHtml(it, ws, esc) {
41
+ const where = [it.station ? 'on ' + it.station : '', it.workflow ? '(' + it.workflow + ')' : ''].filter(Boolean).join(' ');
42
+ const btns = ACTS.map((a) => {
43
+ const sug = it.suggest === a.act;
44
+ const label = (sug ? '✦ ' : '') + a.label;
45
+ return `<button type="button" class="ev-btn sm${sug ? ' pri' : ''}" data-qs-act="${a.act}" data-qs-id="${esc(it.id)}" data-qs-ws="${esc(ws)}" aria-label="${esc(label)}" title="${esc(label)}">${svg(a.icon)}</button>`;
46
+ }).join('');
47
+ return `<li class="mv-row" data-qs-row="${esc(it.id)}"><span class="mv-say">${esc(it.title)}</span>`
48
+ + `<br><span class="yd-exp">Quiet ${esc(String(it.quietDays))} days${where ? ' ' + esc(where) : ''} · ✦ ${esc(it.suggest === 'close' ? 'Close' : 'Park')}: ${esc(it.why)}</span>`
49
+ + `<span class="try-acts">${btns}</span></li>`;
50
+ }
51
+
52
+ /** The list, one section per product; a product with nothing quiet is left out. */
53
+ export function listHtml(lists, { esc = escDefault } = {}) {
54
+ const L = (lists || []).filter(ok).filter((l) => l.items.length);
55
+ if (!L.length) return '<p class="yd-exp">Nothing is quiet 30 days or more.</p>';
56
+ const many = L.length > 1;
57
+ return L.map((l) => {
58
+ const head = many ? `<h3>${esc(l.name || l.ws)}</h3>` : '';
59
+ const more = l.total > l.items.length ? ` The ${esc(String(l.items.length))} most quiet show here; answer them and the next ones come.` : '';
60
+ const sum = `<p class="yd-exp">${esc(plural(l.total, 'initiative', 'initiatives'))} with no change in 30 days or more.${more} Keep leaves one alone for 30 days.</p>`;
61
+ return `<section class="mv-prod">${head}${sum}<ul class="mv-list">${l.items.map((it) => itemHtml(it, l.ws || '', esc)).join('')}</ul></section>`;
62
+ }).join('');
63
+ }
64
+
65
+ const SAID = { keep: 'Kept. The sweep leaves it alone for 30 days.', park: 'Parked.', close: 'Closed.' };
66
+
67
+ /** The list in the Viewer; opening it marks the week as looked. */
68
+ export function openQuiet(lists, H = {}) {
69
+ const VW = window.czViewer;
70
+ const toast = H.toast || (() => {});
71
+ const row = rowOf(lists);
72
+ if (row) markLooked(row.week);
73
+ if (!VW) { toast('The list could not open here.'); return; }
74
+ let L = (lists || []).filter(ok).map((l) => ({ ...l, items: l.items.slice() }));
75
+ const send = async (path, body) => {
76
+ const r = await H.pmPost(path, body).catch((e) => ({ ok: false, error: String((e && e.message) || e) }));
77
+ if (!r || !r.ok) { toast('Not saved: ' + ((r && r.error) || 'the workspace did not answer') + '.'); return false; }
78
+ return true;
79
+ };
80
+ const answer = (act, ws, it) => (act === 'keep' ? send('/api/quiet/keep', { ws: ws || undefined, id: it.id })
81
+ : send('/api/lifecycle', { ws: ws || undefined, initiative_id: it.id, state: act === 'park' ? 'on-hold' : 'closed',
82
+ reason: act === 'park' ? 'Quiet ' + it.quietDays + ' days; parked in the weekly sweep' : 'Closed in the weekly sweep of quiet work' }));
83
+ const takeBack = (act, ws, it) => (act === 'keep' ? send('/api/quiet/keep', { ws: ws || undefined, id: it.id, undo: true })
84
+ : send('/api/lifecycle', { ws: ws || undefined, initiative_id: it.id, state: 'active', reason: UNDO_REASON }));
85
+ VW.open({ id: 'quiet:' + ((row && row.week) || ''), kind: 'Quiet work', title: 'Quiet 30 days or more', icon: ICON, presses: [],
86
+ render: (b) => {
87
+ const draw = () => { b.innerHTML = listHtml(L); };
88
+ draw();
89
+ // the presses are real <button>s in b; one listener on the document reads them (a re-render drops its old one), as pm/try-view.js does
90
+ if (b._qsOff) b._qsOff();
91
+ const onPress = async (ev) => {
92
+ const t = ev.target && ev.target.closest && ev.target.closest('[data-qs-act]'); if (!t || t.disabled || !b.contains(t)) return;
93
+ const act = t.dataset.qsAct, ws = t.dataset.qsWs || '', id = t.dataset.qsId;
94
+ const l = L.find((x) => (x.ws || '') === ws); const it = l && l.items.find((x) => x.id === id); if (!it) return;
95
+ t.disabled = true;
96
+ if (!(await answer(act, ws, it))) { t.disabled = false; return; }
97
+ const at = l.items.indexOf(it);
98
+ l.items.splice(at, 1); l.total = Math.max(0, l.total - 1);
99
+ draw();
100
+ if (H.onChange) H.onChange(L);
101
+ const undo = async () => { if (await takeBack(act, ws, it)) { l.items.splice(Math.min(at, l.items.length), 0, it); l.total += 1; draw(); if (H.onChange) H.onChange(L); } };
102
+ if (H.toastUndo) H.toastUndo(SAID[act], undo); else toast(SAID[act]);
103
+ };
104
+ b.ownerDocument.addEventListener('click', onPress);
105
+ b._qsOff = () => b.ownerDocument.removeEventListener('click', onPress);
106
+ } });
107
+ }
@@ -0,0 +1,44 @@
1
+ /* pm/reading-view.js — the Reading layout as one page every reader draws (initiative reading-layouts, A334; board ReadingDS).
2
+ * The pure cut is reading-model.js; this draws it into pm-layout-reading and wires it. A reader passes its own head (tools), meta strip,
3
+ * the parts above and below the article (bars, Edit log), and its footer, so each kind keeps every feature it had.
4
+ *
5
+ * readingPageHtml(text, o) → html. o: { path, title, revisions, comments, head, above, meta(R) → html, extraHead, foot, below, empty }
6
+ * wireReading(root, scroller, path) a fold is kept per document; Contents jumps to a section (opening it) and follows the scroll
7
+ * readStore localStorage, wrapped: a private window keeps nothing and breaks nothing */
8
+ import { readingOf, foldKey, foldsOf, foldsWith } from './reading-model.js';
9
+ import { bodyHtml, dayOf } from './premium-vw-doc-model.js';
10
+
11
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
12
+ export const readStore = {
13
+ get: (k) => { try { return localStorage.getItem(k); } catch { return null; } },
14
+ set: (k, val) => { try { localStorage.setItem(k, val); } catch { /* a private window */ } },
15
+ };
16
+
17
+ /** The page in the Reading layout. Contents shows only with two entries or more; the margin only with a comment. */
18
+ export function readingPageHtml(text, o = {}) {
19
+ const R = readingOf(text, { title: o.title, revisions: o.revisions || [], comments: o.comments || [] });
20
+ const folds = foldsOf(readStore.get(foldKey(o.path)));
21
+ let start = 0;
22
+ const md = (src) => { const r = bodyHtml(src, { start }); start += r.heads.length; return r.html; };
23
+ const secs = R.sections.map((sx) => `<details class="rd-sec" id="${esc(sx.id)}" data-rd="${esc(sx.id)}"${folds[sx.id] === false ? '' : ' open'}><summary><h2>${esc(sx.name)}</h2>${sx.comments ? `<span class="rd-cn" title="${sx.comments} comments">${sx.comments}</span>` : ''}</summary><div class="rd-sb">${md(sx.md)}</div></details>`).join('');
24
+ const contents = R.contents.length > 1 ? `<nav class="pm-contents" aria-label="Contents"><p class="rd-lab">Contents</p>${R.contents.map((c, i) => `<a href="#${esc(c.id)}" data-rdto="${esc(c.id)}" aria-current="${i === 0}">${esc(c.name)}</a>`).join('')}</nav>` : '';
25
+ const margin = R.margin.length ? `<aside class="pm-margin" aria-label="Comments">${R.margin.map((c) => `<div class="rd-cm" data-for="${esc(c.id)}">${c.quote ? `<p class="rd-q">on “${esc(c.quote)}”</p>` : ''}<p><b>${esc(c.who || '')}</b>${c.at ? ' · ' + esc(dayOf(c.at) || c.at) : ''}</p><p>${esc(c.text)}</p></div>`).join('')}</aside>` : '';
26
+ return `<div class="pm-layout-reading rd">${o.head != null ? `<div class="pm-head">${o.head}</div>` : ''}${contents}<div class="pm-main">${o.above || ''}`
27
+ + `<header class="rd-hd"><h1 class="rd-t cft">${esc(R.title)}</h1>${o.meta ? o.meta(R) : ''}${o.extraHead || ''}</header>`
28
+ + `<article class="cf rd-doc"><div class="cfb">`
29
+ + (R.inShort ? `<section class="rd-short" id="rd-in-short" aria-label="In short"><p class="rd-lab">In short</p>${md(R.inShort)}</section>` : '')
30
+ + `${R.lead ? md(R.lead) : ''}${secs || (R.lead ? '' : `<p class="vwmut">${esc(o.empty || 'The file has no text yet.')}</p>`)}</div>`
31
+ + `${o.foot || ''}</article>${o.below || ''}</div>${margin}</div>`;
32
+ }
33
+
34
+ /** Wire a drawn Reading page inside root; scroller is the element that scrolls (the Viewer tab's body). */
35
+ export function wireReading(root, scroller, path) {
36
+ const box = root && root.querySelector('.rd'); if (!box) return;
37
+ box.querySelectorAll('.rd-sec').forEach((x) => x.addEventListener('toggle', () => readStore.set(foldKey(path), foldsWith(readStore.get(foldKey(path)), x.dataset.rd, x.open))));
38
+ const nav = box.querySelector('.pm-contents'); if (!nav) return;
39
+ const mark = (id) => nav.querySelectorAll('[data-rdto]').forEach((a) => a.setAttribute('aria-current', String(a.dataset.rdto === id)));
40
+ nav.onclick = (e) => { const a = e.target.closest('[data-rdto]'); if (!a) return; e.preventDefault(); const t = box.querySelector('#' + CSS.escape(a.dataset.rdto)); if (!t) return; if (t.tagName === 'DETAILS') t.open = true; t.scrollIntoView({ block: 'start', behavior: 'smooth' }); mark(a.dataset.rdto); };
41
+ if (typeof IntersectionObserver !== 'function') return;
42
+ const io = new IntersectionObserver((es) => { const top = es.filter((x) => x.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top)[0]; if (top) mark(top.target.id); }, { root: scroller || null, rootMargin: '0px 0px -70% 0px' });
43
+ box.querySelectorAll('#rd-in-short, .rd-sec').forEach((x) => io.observe(x));
44
+ }