create-pmos 0.492.0 → 0.494.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 (102) hide show
  1. package/package.json +75 -27
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/mods/pmos-cockpit/README.md +1 -1
  4. package/payload/mods/pmos-cockpit/hooks/lib/guard.mjs +2 -2
  5. package/payload/planning/evals/eval-calibration.md +1 -1
  6. package/payload/planning/okrs/health-budgets.md +1 -1
  7. package/payload/state/discoveries.md +1 -1
  8. package/workspace/briefing-premium-initiative-test.js +2 -1
  9. package/workspace/changelog.json +74 -0
  10. package/workspace/fixtures/initiatives-api/list.json +0 -4
  11. package/workspace/fixtures/initiatives-api/roadmap.json +255 -275
  12. package/workspace/fixtures/initiatives-api/sheet.json +2 -3
  13. package/workspace/fixtures/report-api/draft.json +4 -4
  14. package/workspace/fixtures/reports-page/draft-biweekly-2026-10-16.md +4 -4
  15. package/workspace/guide/board.md +2 -2
  16. package/workspace/guide/briefing-premium.md +2 -0
  17. package/workspace/guide/claude-proposes.md +2 -2
  18. package/workspace/guide/data-freshness.md +3 -1
  19. package/workspace/guide/index.md +2 -2
  20. package/workspace/guide/initiative-boards.md +2 -2
  21. package/workspace/guide/initiatives-roadmap.md +38 -39
  22. package/workspace/guide/initiatives-screen.md +22 -20
  23. package/workspace/guide/initiatives-timeline.md +7 -9
  24. package/workspace/guide/integrated-work.md +7 -8
  25. package/workspace/guide/layout.md +2 -2
  26. package/workspace/guide/lifecycle.md +2 -2
  27. package/workspace/guide/notes.md +1 -1
  28. package/workspace/guide/pm-only-acts.md +5 -5
  29. package/workspace/guide/pm-only-lines.md +3 -3
  30. package/workspace/guide/report-slides.md +14 -1
  31. package/workspace/guide/reports.md +4 -2
  32. package/workspace/guide/today.md +2 -2
  33. package/workspace/guide/your-impact.md +6 -7
  34. package/workspace/lib/board-cli.js +1 -1
  35. package/workspace/lib/board-fold.js +6 -6
  36. package/workspace/lib/board-premium.js +3 -3
  37. package/workspace/lib/board-trail.js +30 -3
  38. package/workspace/lib/calendar-tidy.js +1 -1
  39. package/workspace/lib/core-docs.js +2 -2
  40. package/workspace/lib/engine/boards.js +11 -11
  41. package/workspace/lib/engine/signals/detectors.js +13 -13
  42. package/workspace/lib/engine/signals/facts.js +5 -3
  43. package/workspace/lib/git-shape.js +21 -0
  44. package/workspace/lib/grill-runs.js +21 -6
  45. package/workspace/lib/grill.js +1 -1
  46. package/workspace/lib/health-rules-factory.js +13 -14
  47. package/workspace/lib/health-rules-plan.js +8 -7
  48. package/workspace/lib/impact.js +29 -16
  49. package/workspace/lib/initiative-cli.js +59 -63
  50. package/workspace/lib/initiative-needs.js +6 -6
  51. package/workspace/lib/initiative-premium.js +2 -2
  52. package/workspace/lib/initiative-writer.js +2 -2
  53. package/workspace/lib/lifecycle-stage.js +39 -0
  54. package/workspace/lib/page-warm.js +68 -0
  55. package/workspace/lib/placements.js +117 -95
  56. package/workspace/lib/plan-rules.js +7 -5
  57. package/workspace/lib/pm-guard.js +1 -3
  58. package/workspace/lib/pm-lines-needs.js +1 -1
  59. package/workspace/lib/report-design.js +6 -1
  60. package/workspace/lib/report-draft.js +17 -16
  61. package/workspace/lib/report-export.js +148 -9
  62. package/workspace/lib/report-pyramid.js +434 -0
  63. package/workspace/lib/report-slides-data.js +11 -7
  64. package/workspace/lib/report-structure.js +5 -1
  65. package/workspace/lib/report-templates.js +81 -20
  66. package/workspace/lib/routes-boards.js +9 -8
  67. package/workspace/lib/routes-brief-page.js +20 -3
  68. package/workspace/lib/routes-grill.js +10 -4
  69. package/workspace/lib/routes-impact.js +12 -4
  70. package/workspace/lib/routes-initiatives.js +29 -43
  71. package/workspace/lib/routes-notes.js +24 -15
  72. package/workspace/lib/routes-programs.js +6 -4
  73. package/workspace/lib/routes-report-design.js +15 -0
  74. package/workspace/lib/routes-report-flow.js +106 -17
  75. package/workspace/lib/routes-report-setups.js +2 -1
  76. package/workspace/lib/routes-report-structure.js +3 -0
  77. package/workspace/lib/split-merge.js +2 -3
  78. package/workspace/lib/wf-bridge.js +5 -3
  79. package/workspace/package-lock.json +2 -2
  80. package/workspace/package.json +1 -1
  81. package/workspace/premium-chat-report-tab-test.js +5 -1
  82. package/workspace/public/pm/cozy-vw-rp.css +12 -0
  83. package/workspace/public/pm/fetch-share.js +38 -0
  84. package/workspace/public/pm/home-app.js +21 -3
  85. package/workspace/public/pm/home-chat.js +5 -4
  86. package/workspace/public/pm/home-impact.css +23 -13
  87. package/workspace/public/pm/home-impact.js +49 -32
  88. package/workspace/public/pm/home-ini.css +2 -0
  89. package/workspace/public/pm/http.js +1 -1
  90. package/workspace/public/pm/ini-view.css +55 -0
  91. package/workspace/public/pm/ini-view.js +5 -2
  92. package/workspace/public/pm/premium-board.js +1 -0
  93. package/workspace/public/pm/premium-insights.js +1 -0
  94. package/workspace/public/pm/premium-report-read.js +25 -6
  95. package/workspace/public/pm/premium-report-tab.js +69 -14
  96. package/workspace/public/pm/report-flow.js +93 -10
  97. package/workspace/public/pm/view-notes.js +8 -8
  98. package/workspace/replaced-tests.json +14 -0
  99. package/workspace/server.js +24 -3
  100. package/workspace/skills/report-template.skill +8 -0
  101. package/workspace/test-lists/page-open-speed.json +5 -0
  102. package/workspace/test-lists/report-pyramid.json +9 -0
@@ -1,16 +1,26 @@
1
- /* pm/home-impact.css — the weekly check of Your impact in Home's chat (feedback batch 16 item 7, canvas GmP1Ledger). pm/home-impact.js. */
2
- .im-card { clear: both; margin-top: 8px; padding: 4px 14px 8px; } /* under Claude's line, never beside it (the line floats on a desk) */
3
- .im-list { list-style: none; margin: 0; padding: 0; }
4
- .im-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--cz-hair); }
5
- .im-row:first-child { border-top: 0; }
6
- .im-row.im-off .im-t { color: var(--cz-ink3); text-decoration: line-through; }
7
- .im-k { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--cz-well); color: var(--cz-ink2); }
8
- .im-k.im-thanks { background: var(--cz-bluebg); color: var(--cz-blueink); }
1
+ /* pm/home-impact.css — the weekly check of Your impact in Home's chat (batch 16 item 7; batch 23 item 4, canvas IcA). pm/home-impact.js. */
2
+ .im-card { clear: both; margin-top: 10px; max-width: 600px; } /* under Claude's line, never beside it (the line floats on a desk) */
3
+ .im-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
4
+ .im-q { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 12px 8px 12px 16px; border-radius: 18px; background: var(--cz-bluebg); }
5
+ .im-k { flex: none; display: inline-flex; margin-top: 2px; color: var(--cz-blueink); }
9
6
  .im-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
10
- .im-t { font-size: var(--fs-4); overflow-wrap: anywhere; }
11
- .im-src { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
7
+ .im-t { font-size: var(--fs-4); font-weight: 700; line-height: 1.35; color: var(--cz-ink); overflow-wrap: anywhere; }
8
+ .im-w { font-size: var(--fs-3); color: var(--cz-ink2); overflow-wrap: anywhere; }
9
+ .im-src { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; font-size: var(--fs-2); color: var(--cz-ink3); text-decoration: none; }
12
10
  .im-src:hover { text-decoration: underline; }
13
11
  .im-src svg, .im-lock svg { flex: none; }
14
- .im-foot { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
15
- .im-lock { flex: 1; display: inline-flex; align-items: center; gap: 6px; }
16
- @media (prefers-reduced-motion: no-preference) { .im-row { transition: opacity .2s ease; } }
12
+ .im-mw { position: relative; flex: none; }
13
+ .im-more { width: 28px; height: 28px; color: var(--cz-ink2); }
14
+ .ut-ib.im-more svg { stroke-width: 3.2; }
15
+ .im-pop { position: absolute; right: 0; top: 32px; z-index: 5; padding: 4px; border-radius: 14px; background: var(--cz-card); box-shadow: 0 14px 34px -14px rgba(42, 46, 53, .4), 0 0 0 1px var(--cz-hair); }
16
+ .im-pop button { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: none; color: var(--cz-ink); font: inherit; font-size: var(--fs-3); font-weight: 600; white-space: nowrap; cursor: pointer; }
17
+ .im-pop button:hover, .im-pop button:focus-visible { background: var(--cz-well); }
18
+ .im-pop svg { width: 15px; height: 15px; }
19
+ .im-q.im-gone { align-items: center; padding: 8px 8px 8px 16px; background: var(--cz-well); color: var(--cz-ink3); font-size: var(--fs-3); }
20
+ .im-gt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
21
+ .im-undo { flex: none; height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--cz-blueink); font: inherit; font-size: var(--fs-3); font-weight: 700; cursor: pointer; }
22
+ .im-undo:hover { background: var(--cz-card); }
23
+ .im-lock { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: var(--fs-2); color: var(--cz-ink3); }
24
+ .im-msg { margin: 4px 0 0; font-size: var(--fs-2); color: var(--cz-ink3); }
25
+ .im-msg:empty { display: none; }
26
+ @media (prefers-reduced-motion: no-preference) { .im-q { transition: background-color .2s ease; } }
@@ -1,12 +1,14 @@
1
- /* pm/home-impact.js — the weekly check of "Your impact" in Home's chat (feedback batch 16 item 7, Phase 1; canvas In development GmP1Ledger).
2
- * After a week ends, Claude lists that week's items and asks whether each is real: ✕ or ✓ on each row, ✓✓ for every row not checked yet.
3
- * Only ✓ items count. Each row links to its source. No number is shown. The card is Home's own chat intro while the check is due; it goes
4
- * when every row is checked.
1
+ /* pm/home-impact.js — the weekly check of "Your impact" in Home's chat (feedback batch 16 item 7; rebuilt batch 23 item 4, canvas IcA).
2
+ * After a week ends, Claude shows that week's items as thank-you bubbles: the quote in bold, who and what, the source link. They count by
3
+ * default: nothing needs a ✓. One quiet ⋯ per row holds "Not right, drop it"; a dropped row says so with Undo. The lock line is a quiet
4
+ * footer. No number is shown. The card is Home's own chat intro for the whole week after (lib/impact.js: when it ends, rows nobody dropped
5
+ * are real); the first time it is drawn, the page says so (looked), and the row under Mentions goes.
5
6
  *
6
7
  * readCheck(pmGet) → the GET /api/impact/check body when a check is due, else null
7
- * checkIntro(c, { esc, pmPost, done }) → the intro of Home's chat: { role, text, card: { html, press } }
8
- * rowHtml(c, { esc, sel }) → the one row under Mentions while the check is due: a tap opens Home's chat on it (on a phone too). No count.
9
- * Writes: POST /api/impact/verdict { id, real }, /verdict-all { week }, /undo { id } (page presses). Nothing leaves PMOS. */
8
+ * partsOf(item) → { quote, what }: the bold line (the words in quotes, else the item's sentence) and the who/what line
9
+ * checkIntro(c, { esc, pmPost }) → the intro of Home's chat: { role, mood, text, card: { html, press } }
10
+ * rowHtml(c, { esc, sel }) → the one row under Mentions until the card is seen: a tap opens Home's chat on it (on a phone too). No count.
11
+ * Writes: POST /api/impact/verdict { id, real: false }, /undo { id }, /looked { week }. Nothing leaves PMOS. */
10
12
 
11
13
  const SV = (d, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
12
14
  const P = {
@@ -14,7 +16,7 @@ const P = {
14
16
  unblock: 'M7 11V8a5 5 0 0 1 9.6-2M5 11h14v9H5z',
15
17
  used: 'M12 3l8 9-8 9-8-9z',
16
18
  kr: 'M4 17l6-6 4 4 6-7M15 8h5v5',
17
- no: 'M6 6l12 12M18 6L6 18', yes: 'M5 12l5 5 9-10', all: 'M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16',
19
+ no: 'M6 6l12 12M18 6L6 18', yes: 'M5 12l5 5 9-10', dots: 'M5 12h.01M12 12h.01M19 12h.01',
18
20
  lock: 'M7 11V8a5 5 0 0 1 10 0v3M5 11h14v9H5z', open: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
19
21
  };
20
22
  const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -26,47 +28,62 @@ export async function readCheck(pmGet) {
26
28
  }
27
29
 
28
30
  export function rowHtml(c, { esc, sel }) {
29
- if (!c) return '';
31
+ if (!c || c.looked) return '';
30
32
  return `<div class="hv-card hr-card hr-men-card"><div class="hm-r hv-r hr-men${sel ? ' sel' : ''}" data-id="impact">`
31
33
  + `<button type="button" class="hm-rm" data-hr-impact${sel ? ' aria-current="true"' : ''} aria-label="Your impact: ${esc(c.label.toLowerCase())} is ready to check">`
32
34
  + `<span class="hv-mk hr-at" aria-hidden="true">${SV(P.yes, 16)}</span><span class="hm-rt"><b>Your impact</b><small class="hr-sub">${esc(c.label)} is ready to check</small></span>`
33
35
  + '<span class="hv-xc" aria-hidden="true"></span></button></div></div>';
34
36
  }
35
37
 
36
- export function checkIntro(c, { esc, pmPost, done }) {
37
- const st = { c, msg: '' };
38
- const left = () => st.c.items.filter((x) => x.real === null);
38
+ const QUOTE = /[“"]([^”"]{2,})[”"]/;
39
+ /** The bold line is the thanks in the person's own words when the item quotes them; the line under it says who and what. */
40
+ export function partsOf(x) {
41
+ const t = String((x && x.text) || ''), who = String((x && x.who) || ''), m = QUOTE.exec(t);
42
+ if (!m) return { quote: t, what: who };
43
+ const rest = t.replace(m[0], ' ').replace(/^[\s:—–-]+|[\s:—–-]+$/g, '').replace(/\s+/g, ' ').trim();
44
+ return { quote: `“${m[1].trim()}”`, what: rest && rest !== who ? rest : who };
45
+ }
46
+
47
+ export function checkIntro(c, { esc, pmPost }) {
48
+ const st = { c, msg: '', menu: null, told: !!c.looked };
39
49
  const row = (x) => {
40
- const mark = x.real === null
41
- ? `<button type="button" class="ut-ib lg" data-im-v="no" data-im-id="${esc(x.id)}" aria-label="Not real, drop it" title="Not real, drop it">${SV(P.no)}</button>`
42
- + `<button type="button" class="ut-ib pri" data-im-v="yes" data-im-id="${esc(x.id)}" aria-label="Real, keep it" title="Real, keep it">${SV(P.yes)}</button>`
43
- : `<button type="button" class="ut-ib lg on" data-im-undo="${esc(x.id)}" aria-pressed="true" aria-label="${x.real ? 'Kept as real. Undo' : 'Dropped. Undo'}" title="${x.real ? 'Kept as real. Undo' : 'Dropped. Undo'}">${SV(x.real ? P.yes : P.no)}</button>`;
44
- return `<li class="im-row${x.real === false ? ' im-off' : ''}"><span class="im-k im-${esc(x.kind)}" aria-hidden="true">${SV(P[x.kind] || P.used)}</span>`
45
- + `<span class="im-tx"><span class="im-t">${esc(x.text)}</span><a class="ut-small ut-mut im-src" href="${esc(x.source.url)}" target="_blank" rel="noopener noreferrer">${esc(x.source.label)} · ${esc(dayName(x.at))} ${SV(P.open, 12)}</a></span>${mark}</li>`;
50
+ const { quote, what } = partsOf(x);
51
+ const src = `<a class="im-src" href="${esc(x.source.url)}" target="_blank" rel="noopener noreferrer">${esc(x.source.label)} · ${esc(dayName(x.at))} ${SV(P.open, 11)}</a>`;
52
+ if (x.real === false) {
53
+ return `<li class="im-q im-gone"><span class="im-gt">Dropped, not counted: ${esc(quote)}</span>`
54
+ + `<button type="button" class="im-undo" data-im-undo="${esc(x.id)}">Undo</button></li>`;
55
+ }
56
+ const open = st.menu === x.id;
57
+ return `<li class="im-q"><span class="im-k im-${esc(x.kind)}" aria-hidden="true">${SV(P[x.kind] || P.used)}</span>`
58
+ + `<span class="im-tx"><span class="im-t">${esc(quote)}</span>${what ? `<span class="im-w">${esc(what)}</span>` : ''}${src}</span>`
59
+ + `<span class="im-mw"><button type="button" class="ut-ib im-more" data-im-more="${esc(x.id)}" aria-haspopup="menu" aria-expanded="${open}" aria-label="More" title="More">${SV(P.dots, 16)}</button>`
60
+ + (open ? `<span class="im-pop" role="menu"><button type="button" role="menuitem" data-im-drop="${esc(x.id)}">${SV(P.no, 15)} Not right, drop it</button></span>` : '')
61
+ + '</span></li>';
46
62
  };
47
63
  const html = () => {
48
- const open = left();
49
- return `<div class="ut-card im-card" role="group" aria-label="Your impact, ${esc(st.c.label.toLowerCase())}">`
64
+ if (!st.told) { st.told = true; st.c.looked = true; Promise.resolve(pmPost('/api/impact/looked', { week: st.c.week })).catch(() => {}); }
65
+ return `<div class="im-card" role="group" aria-label="Your impact, ${esc(st.c.label.toLowerCase())}">`
50
66
  + `<ul class="im-list">${st.c.items.map(row).join('')}</ul>`
51
- + `<div class="im-foot"><span class="ut-small ut-mut im-lock">${SV(P.lock, 14)} Only you see this. Nothing leaves PMOS.</span>`
52
- + (open.length > 1 ? `<button type="button" class="ut-ib pri" data-im-all aria-label="All real, keep them all" title="All real, keep them all">${SV(P.all)}</button>` : '')
53
- + `</div><p class="ut-small ut-mut" role="status">${esc(st.msg)}</p></div>`;
67
+ + `<p class="im-lock">${SV(P.lock, 13)} Only you see this. Nothing leaves PMOS.</p>`
68
+ + `<p class="im-msg" role="status">${esc(st.msg)}</p></div>`;
54
69
  };
55
70
  const press = async (b) => {
56
71
  const d = b.dataset;
72
+ if (d.imMore) { st.menu = st.menu === d.imMore ? null : d.imMore; return true; }
57
73
  let r = null;
58
- if (d.imV) r = await pmPost('/api/impact/verdict', { id: d.imId, real: d.imV === 'yes' });
74
+ if (d.imDrop) r = await pmPost('/api/impact/verdict', { id: d.imDrop, real: false });
59
75
  else if (d.imUndo) r = await pmPost('/api/impact/undo', { id: d.imUndo });
60
- else if ('imAll' in d) r = await pmPost('/api/impact/verdict-all', { week: st.c.week });
61
76
  else return false;
77
+ st.menu = null;
62
78
  if (!r || !r.ok) { st.msg = (r && r.error) || 'Not saved.'; return true; }
63
- if (d.imV) { const x = st.c.items.find((y) => y.id === d.imId); if (x) x.real = d.imV === 'yes'; }
64
- else if (d.imUndo) { const x = st.c.items.find((y) => y.id === d.imUndo); if (x) x.real = null; }
65
- else for (const x of st.c.items) if (x.real === null) x.real = true;
66
- st.msg = left().length ? '' : 'Thank you. This week is checked.';
67
- if (!left().length && done) done();
79
+ const x = st.c.items.find((y) => y.id === (d.imDrop || d.imUndo));
80
+ if (x) x.real = d.imDrop ? false : null;
81
+ st.msg = '';
68
82
  return true;
69
83
  };
70
- const short = c.gate === 'short' ? ' Too many of these were not real, so I keep your sprout and your log hidden for now.' : '';
71
- return { role: { key: 'claude', name: 'Claude', initial: 'C' }, text: `Here’s what I’d count as your impact ${c.label === 'Last week' ? 'last week' : c.label.replace(/^Week of/, 'the week of')}. Is each one real? I read these from your sources. I don’t post anything anywhere.${short}`, card: { html, press } };
84
+ const thanks = c.items.some((x) => x.kind === 'thanks');
85
+ const when = c.label === 'Last week' ? 'last week' : c.label.replace(/^Week of/, 'the week of');
86
+ const short = c.gate === 'short' ? ' Too many of these were not right, so I keep your sprout and your log hidden for now.' : '';
87
+ return { role: { key: 'claude', name: 'Claude', initial: 'C' }, mood: 'handled',
88
+ text: `${thanks ? 'People thanked you' : 'Your work moved things'} ${when}. I read these from your sources and counted them in your impact.${short}`, card: { html, press } };
72
89
  }
@@ -126,6 +126,8 @@ button.hi-pill { cursor: pointer; }
126
126
  /* ── the initiative's page in the Viewer (canvas HbCDesk, HbCNew, HbCPhone): the stage card, three tasks, the documents that need a look ── */
127
127
  .hi-page { display: flex; flex-direction: column; gap: 14px; }
128
128
  .hi-page .hm-pcard { margin: 0; }
129
+ /* a phone (batch 23 item 5, canvas PmA): the Viewer's own 16 px is the page's one inset */
130
+ @media (max-width: 760px) { .hi-v.hi-page { padding-left: 0; padding-right: 0; } }
129
131
  .hi-pg { display: flex; flex-direction: column; gap: 2px; }
130
132
  .hi-pgh { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 4px; }
131
133
  .hi-pgh b { font-size: var(--fs-3); font-weight: 800; color: var(--cz-ink); }
@@ -6,7 +6,7 @@
6
6
  * pressFetch(url, init) → fetch with pmHeaders; a 403 from a stale nonce is retried once with the new one
7
7
  * pageNonce() → this launch's nonce as the page holds it ('' when none)
8
8
  *
9
- * Every PM-only press (Move to Now, adopt, Issue, Release, lifecycle, Accept) goes through pmPost, so Run 2 adds the
9
+ * Every PM-only press (adopt, Issue, Release, lifecycle, Accept) goes through pmPost, so Run 2 adds the
10
10
  * per-launch nonce in pmHeaders and every press carries it at once. Relative URLs only, to this server; the browser
11
11
  * sends the page's own Origin header. Nothing here sends `by`, `via` or `at`: the writer sets them from the call path.
12
12
  * None of these throws. In FIXTURE mode none of them makes a request.
@@ -1060,6 +1060,61 @@ button.iv-mt.iv-wf { padding: 0 !important; margin: 0 !important; }
1060
1060
  .shut-mc .iv-tel { min-height: 0; }
1061
1061
  .ab-sum .nm { display: none; }
1062
1062
  }
1063
+ /* ── a phone (batch 23 item 5, canvas PmA, agreed 2026-11-02): one 16 px inset and no beige wrapper; a shorter mission; the way to finish and About
1064
+ * as one white card of 48 px rows (the next stage with its round →, which opens the Move sheet; the people and the program; About); 36 px pills in
1065
+ * the Tasks header; task rows 12 px in, and a stage's late and open counts on its dates line. A desktop is unchanged. ── */
1066
+ .iv-gx-t .tx.ph, .iv-ws .n-in { display: none; }
1067
+ @media (max-width: 760px) {
1068
+ .iv-mc { background: transparent; padding: 0; border-radius: 0; gap: 0; }
1069
+ .iv-mc-row { display: contents; }
1070
+ .iv-mc > .iv-mc-top { margin-bottom: 12px; border: 1px solid var(--cz-hair); }
1071
+ .iv-mc .iv-tel { min-height: 128px; border-radius: 22px; }
1072
+ .iv-mc:not(.shut-mc) .iv-tel { margin-bottom: 12px; }
1073
+ .iv-mc .iv-tel-ct { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0 12px; padding: 12px 56px 12px 16px; }
1074
+ .iv-mc .iv-tel-t { display: contents; }
1075
+ .iv-mc .iv-tel-ct .iv-shn { flex-basis: 100%; min-height: 36px; }
1076
+ .iv-tel .iv-dtc { min-height: 24px; font-size: var(--fs-2); }
1077
+ .iv-tel .iv-setd { min-height: 36px; }
1078
+ .iv-ro { gap: 16px; padding-top: 0; }
1079
+ .iv-ro > div { flex-direction: row; align-items: baseline; gap: 4px; }
1080
+ .iv-ro small { font-size: var(--fs-2); font-weight: 700; letter-spacing: 0; }
1081
+ .iv-ro b { font-size: var(--fs-3); }
1082
+ .iv-ro b i { font-size: var(--fs-2); }
1083
+ /* the readouts on the dates line say where today is; the art's own Today label would sit on them */
1084
+ .iv-tel .mi-tx.now { display: none; }
1085
+ /* the one card: the way to finish on top, About under it */
1086
+ .iv-gx, .iv-ab { border: 1px solid var(--cz-hair); }
1087
+ .iv-gx { border-radius: 22px 22px 0 0; border-bottom: 0; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t a" "l l" "f f"; }
1088
+ .iv-ab { border-radius: 0 0 22px 22px; }
1089
+ .iv-gx-t { padding: 4px 0 4px 10px !important; min-height: 56px; gap: 6px; }
1090
+ .iv-gx-t .chev { width: 16px; }
1091
+ .iv-gx[data-ph] .iv-gx-t .tx.dk, .iv-gx[data-ph] .iv-gx-c { display: none; }
1092
+ .iv-gx-t .tx.ph { display: flex; }
1093
+ .iv-gx-t .tx b { font-size: var(--fs-3); overflow: hidden; text-overflow: ellipsis; }
1094
+ .iv-gx-c { grid-area: a; }
1095
+ .iv-gx-a { padding: 0 8px 0 4px; }
1096
+ .iv-gx[data-ph] .iv-gx-a .iv-scgo { flex: none; width: 40px; height: 40px; padding: 0 !important; justify-content: center !important; }
1097
+ .iv-gx[data-ph] .iv-gx-a .iv-scgn { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
1098
+ .iv-gx-ft { padding: 0 8px; min-height: 48px; display: flex; align-items: center; }
1099
+ .iv-gx .iv-meta { flex: 1; }
1100
+ .iv-gx .iv-prog { margin-left: auto !important; }
1101
+ .iv-ab-h { min-height: 48px; padding: 0 14px !important; }
1102
+ /* Tasks: 36 px pills (a 44 px press under each), rows 12 px in, the counts on the dates line */
1103
+ .hi-v .iv-th button { min-height: 36px; height: 36px; position: relative; }
1104
+ .hi-v .iv-th button::after { content: ""; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; }
1105
+ .iv-ws { padding-left: 12px !important; }
1106
+ .iv-ws.in { padding-left: 12px !important; }
1107
+ .iv-ws > .n { display: none; }
1108
+ .iv-ws .n-in { display: inline; }
1109
+ .iv-ws .n-in.w { color: var(--cz-risk); font-weight: 700; }
1110
+ .iv-ws.pl > .iv-cv { margin-left: 40px; }
1111
+ .iv-wbs > .iv-ws + .iv-ws::before, .iv-wbs > .iv-wl + .iv-ws::before, .iv-wl > .iv-ws + .iv-ws::before, .iv-wl > .iv-wl + .iv-ws::before, .iv-wbs > * + :is(.iv-wsw, .ig-dz)::before, .iv-wbs > :is(.iv-wsw, .ig-dz) + .iv-ws::before { left: 12px; }
1112
+ .iv-wl { padding: 0 12px 6px 12px; }
1113
+ .iv-wl > .iv-ws.in { margin-left: -12px; width: calc(100% + 24px); }
1114
+ .iv-tr.iv-ed { margin: 0 -12px; padding: 10px 12px 12px !important; width: calc(100% + 24px); }
1115
+ .iv-addin { margin: 0 -12px; padding: 10px 12px 4px; }
1116
+ .iv-addd { margin: 0 -12px; padding: 4px 12px 12px; }
1117
+ }
1063
1118
  html.ad-still .iv-mc-top.adl, html.ad-still .iv-mc-top.adl .iv-ask .ad-svg { animation: none !important; }
1064
1119
  @media (prefers-reduced-motion: reduce) { .iv-mc-top.adl, .iv-mc-top.adl .iv-ask .ad-svg { animation: none !important; } }
1065
1120
 
@@ -165,7 +165,10 @@ function gatesHtml(v, o, pri, open) {
165
165
  const rows = G.open.length ? `<div class="iv-gx-l" role="list">${G.open.slice(0, 3).map(row).join('')}${G.open.length > 3 ? `<p class="iv-gx-dn">${G.open.length - 3} more in Tasks</p>` : ''}${G.done ? `<p class="iv-gx-dn">${plural(G.done, 'milestone', 'milestones')} done</p>` : ''}</div>`
166
166
  : G.done ? `<div class="iv-gx-l"><p class="iv-gx-dn">${plural(G.done, 'milestone', 'milestones')} done</p></div>` : '';
167
167
  const title = st.line && st.line.finished ? 'This stage is done' : 'To finish this stage';
168
- return `<section class="iv-gx" aria-label="${esc(title)}"><button type="button" class="iv-gx-t" data-iv-mc="gx" aria-expanded="${!!open}"><span class="chev" aria-hidden="true">${SVG(CHEV, 16, 2)}</span><span class="tx"><b>${title}</b>${sub ? `<span class="s">${esc(sub)}</span>` : ''}</span></button>`
168
+ // a phone (batch 23 item 5, canvas PmA) reads the row as the next stage and the count, with the round → beside it; the text above is the desktop's
169
+ const cnt = st.nTotal ? st.doneOf || st.nDone + ' of ' + st.nTotal + ' done' : '';
170
+ const ph = st.next ? `<span class="tx ph"><b>${esc('Next: ' + (st.next.ms ? '◆ ' : '') + st.next.name)}</b>${cnt ? `<span class="s">${esc(cnt)}</span>` : ''}</span>` : '';
171
+ return `<section class="iv-gx"${ph ? ' data-ph' : ''} aria-label="${esc(title)}"><button type="button" class="iv-gx-t" data-iv-mc="gx" aria-expanded="${!!open}"><span class="chev" aria-hidden="true">${SVG(CHEV, 16, 2)}</span><span class="tx dk"><b>${title}</b>${sub ? `<span class="s">${esc(sub)}</span>` : ''}</span>${ph}</button>`
169
172
  + `${st.nTotal ? `<span class="iv-gx-c">${pipsOf(st)}<small>${esc(st.doneOf || st.nDone + ' of ' + st.nTotal + ' done')}</small></span>` : ''}<div class="iv-gx-a">${nextHtml(st, o, pri)}</div>${open ? rows : ''}<div class="iv-gx-ft">${metaHtml(s, o)}</div></section>`;
170
173
  }
171
174
  function ctrlHtml(v, o = {}) {
@@ -305,7 +308,7 @@ function sectionHtml(v, sec, o, inner) {
305
308
  const name = sec.label || sec.name;
306
309
  const plus = st && op && has ? ED.plusHtml(sec, v.id || v.key || '', o) : '';
307
310
  const row = `<button type="button" class="iv-ws${sec.kind === 'past' || sec.kind === 'later' ? ' mut' : ''}${inner ? ' in' : ''}${plus ? ' pl' : ''}"${st ? ` data-iv-sec="${sk}"` : ''} ${has ? `data-iv-fold="${esc(key)}" aria-expanded="${op}"` : 'disabled'}>${markOf(sec)}`
308
- + `<span class="w"><b>${esc(name)}</b>${sec.sub ? `<small class="${sec.subWarn ? 'w' : ''}">${esc(sec.sub)}</small>` : ''}</span>${sec.epicKey ? `<span class="ig-key">${esc(sec.epicKey)}</span>` : ''}${sec.count ? `<span class="n${sec.warn ? ' w' : ''}">${esc(sec.count)}</span>` : ''}${has ? chev(op) : ''}</button>`;
311
+ + `<span class="w"><b>${esc(name)}</b>${sec.sub || sec.count ? `<small class="${sec.subWarn ? 'w' : ''}">${esc(sec.sub || '')}${sec.count ? `<span class="n-in${sec.warn ? ' w' : ''}">${sec.sub ? ' · ' : ''}${esc(sec.count)}</span>` : ''}</small>` : ''}</span>${sec.epicKey ? `<span class="ig-key">${esc(sec.epicKey)}</span>` : ''}${sec.count ? `<span class="n${sec.warn ? ' w' : ''}">${esc(sec.count)}</span>` : ''}${has ? chev(op) : ''}</button>`;
309
312
  // a group's own presses sit beside its fold: ⋯ on the PM's own group, the send icon on an epic (batch 11 item 20)
310
313
  const tools = G.toolsHtml(sec) + plus, head = tools ? `<div class="iv-wsw">${row}${tools}</div>` : row;
311
314
  // the PM's own groups and Not in a group take a dragged task
@@ -17,6 +17,7 @@
17
17
  * Workflows (D99, workflows-per-initiative: WfABoard WfABoardOne WfATrack WfAElse WfAPhone; pm/bd-wf.js): every initiative is on one workflow. The
18
18
  * chip row picks one (its own stages become the columns and the track's header) or All (the three categories, each row its own stages).
19
19
  * Where no record holds a value for an initiative, the element says so: nothing is invented. */
20
+ import './fetch-share.js'; // first: identical GETs in flight are asked once (page-open-speed)
20
21
  import { pmPost } from './http.js';
21
22
  import { followDoc } from './doc-follow.js';
22
23
  import { $, $$, esc, store, chatAbout, setPageGaps } from './premium-shell.js';
@@ -28,6 +28,7 @@
28
28
  * IsPhone the goal detail full screen with Readings, Moved by and Dashboards; a report setup as a sheet.
29
29
  * window.czViewer is feature-detected, with this page's side panel as the fallback. A report file opens in the report reader
30
30
  * (pm/premium-report-read.js), the report panel in the Viewer card. The page has no #dlg. */
31
+ import './fetch-share.js'; // first: identical GETs in flight are asked once (page-open-speed)
31
32
  import { $, $$, esc, toast, wireRail, setPageGaps } from './premium-shell.js';
32
33
  import { pmPost, pmGet } from './http.js';
33
34
  import * as GW from './grill-words.js'; // Grill and Forecast screens (canvas FcIntel): the goal that will miss, and what Claude's grill found
@@ -18,7 +18,9 @@
18
18
  * Issue a confirm with the three checks of GET /api/viewer-report/checks, Issue it and Not yet. POST /api/report/issue freezes the cycle.
19
19
  * Issued the lock line "Issued, so it stays as sent. Changes go into the next cycle." with Start the next cycle (RpStates).
20
20
  * Discard a card at the foot of the panel: "Discard the Oct 12 draft?", the cycle that stays, "This cannot be undone." (RpStates).
21
- * Slides the current slide, ‹ "Slide 1 of 5" ›, and a thumbnail of each slide.
21
+ * Slides the current slide, ‹ "Slide 1 of 5" ›, and a thumbnail of each slide. A cadence draft with no designed render shows the
22
+ * Pyramid deck (canvas RsA; GET /api/report-design/pyramid, lib/report-pyramid.js): answer first, the scorecard, the timeline,
23
+ * Needs your call and the sources. PDF prints the same slides, one to a page; the PowerPoint file draws them too.
22
24
  * Document the words as paper pages: the eyebrow, the title, "In one minute", numbered sections, tables, the sources as footnotes,
23
25
  * "Page n of N" and Download as PDF or Word (RpDoc; rp-parts.js paperModel). A designed cycle shows its designed page.
24
26
  * Live page the numbers Insights reads (GET /api/insights-premium): the goal tiles, Goals on track, Shipped and At risk, the picked goal's
@@ -54,7 +56,7 @@ import * as MP from './premium-mtg-present.js'; // the one presenter window fo
54
56
  import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, the recording tab presents it (rule 10)
55
57
  import { placeholderHtml } from './cozy-placeholder.js';
56
58
  import { vzStyle } from './premium-vw-open.js';
57
- import { reviewHtml, ICON as RF_ICON } from './report-flow.js'; // Claude's review and the template icon (batch 22 item 14, canvas RfH2, RfH6)
59
+ import { reviewHtml, chatOf as rfChatOf, ICON as RF_ICON } from './report-flow.js'; // Claude's review and the template icon (batch 22 item 14, canvas RfH2, RfH6)
58
60
  import { adler } from './cozy-adler.js'; // registers window.czViews; vzStyle adds the Viewer's sheet (cozy-vw.css)
59
61
  import { cycleGroups, cycleName, briefModel, briefGlanceHtml, briefConfirmHtml, briefWhyHtml, briefLooksHtml, paperModel, paperHtml, liveModel, liveHtml, presentHtml, dayMon, reportSummary,
60
62
  rpSumHtml, rpBarHtml, cadenceWords, goesOutWords, FORMATS, RP_ICONS } from './rp-parts.js';
@@ -170,6 +172,8 @@ const frame = (style, inner, cls, title) => `<iframe sandbox="" tabindex="-1" ti
170
172
  /* ── what is shown ── */
171
173
  function slides() {
172
174
  if (R.cyc && R.cyc.slides.length) return R.cyc.slides.map((x) => ({ k: 'frame', h: x.h, html: x.html, css: R.cyc.style }));
175
+ // a cadence draft with no designed render: the finished Pyramid deck (canvas RsA), in the report's saved look or the standard PMOS look
176
+ if (R.pyr && R.pyr.slides.length) return R.pyr.slides.map((x) => ({ k: 'frame', h: x.h, html: x.html, css: R.pyr.style }));
173
177
  const w = R.W || { title: R.name, sections: [] };
174
178
  return [titleSlide(w)]
175
179
  .concat(w.sections.map((x) => ({ k: 'text', h: x.h, html: slideHtml(x.lines) })));
@@ -493,6 +497,16 @@ async function rvAct(k, v) {
493
497
  say((r.started ? 'The report\'s session started with ' : 'Passed to the report\'s session: ') + (todo.length === 1 ? 'one change' : todo.length + ' changes') + '. They show here as it writes them. Nothing is issued.');
494
498
  }
495
499
  function openTemplate() { import('./premium-report-tab.js').then((M) => M.openReportTab({ kind: 'report', id: R.id }, { panel: 'template' })); }
500
+ /** The chat icon (Wawan, 2026-11-02): the report's own conversation beside it. Home opens it in its chat (pmos-chat-about); another page goes
501
+ * to Home with the report open, and the conversation's context waits in sessionStorage for Home to read. */
502
+ async function openChat() {
503
+ const me = R; if (!me || !me.id) return;
504
+ const st = await pmGet('/api/report-flow?' + q({ ws: me.ws, id: me.id })).catch(() => null);
505
+ const t = rfChatOf({ name: me.name, ...(st && st.ok !== false ? st : {}), latest: (st && st.latest) || { path: me.row.path } }, me.id);
506
+ if (!dispatchEvent(new CustomEvent('pmos-chat-about', { detail: t, cancelable: true }))) return; // Home took it
507
+ try { sessionStorage.setItem('pmos-chat-about', JSON.stringify(t)); } catch { /* Home opens the chat with no context */ }
508
+ location.href = '/premium.html?' + q({ about: t.key, label: t.title, open: innerWidth > 760 ? 'report:' + me.id : '' }); // a phone: the chat takes the page
509
+ }
496
510
  /** What Claude is still doing on this report, said where the PM reads it (Wawan, 2026-11-01, batch 22 item 13: "I have to wait, but there's
497
511
  * no indication of me having to wait"). Nothing running → ''. */
498
512
  export function waitWords(x, draft) {
@@ -910,6 +924,8 @@ function saveMd() {
910
924
  function printHtml() {
911
925
  const t = esc(R.name + ' ' + (R.row.slot || ''));
912
926
  if (R.cyc) return frameDoc(R.cyc.style, R.view === 'deck' && R.cyc.slides.length ? R.cyc.slides.map((x) => x.html).join('') : R.cyc.body, R.view === 'deck' && R.cyc.slides.length ? 'pmos-print pmos-print-deck' : 'pmos-print pmos-print-doc').replace('<head>', '<head><title>' + t + '</title>');
927
+ // PDF = the same Pyramid slides, one to a 1280 x 720 page (canvas RsA, RsD)
928
+ if (R.pyr && R.pyr.slides.length && R.view === 'deck') return frameDoc(R.pyr.style, R.pyr.slides.map((x) => x.html).join(''), 'pmos-print pmos-print-deck').replace('<head>', '<head><title>' + t + '</title>');
913
929
  const css = '<link rel="stylesheet" href="' + esc(href('premium-report-print.css')) + '">';
914
930
  const w = R.W || { title: R.name, sections: [] };
915
931
  const inner = R.view === 'deck'
@@ -930,7 +946,7 @@ function printIt() {
930
946
  * its saved design is HTML the presenter cannot read yet, so it, and a presenter that does not start, use the full-screen view below. */
931
947
  function presentIt() {
932
948
  const me = R;
933
- if (R.cyc || !R.W || R.err) return present(true);
949
+ if (R.cyc || (R.pyr && R.view === 'deck') || !R.W || R.err) return present(true);
934
950
  if (presentInRecording({ kind: R.view === 'deck' ? 'pmos-deck' : 'report', ref: R.row.path, title: R.name, ws: R.ws })) return;
935
951
  if (typeof MP.presentMaterial === 'function') {
936
952
  const win = typeof MP.openAudience === 'function' ? MP.openAudience() : null;
@@ -971,7 +987,9 @@ async function readCycle() {
971
987
  const c = await Promise.resolve(pmGet('/api/report-design/cycle?' + q({ ws: R.ws, path: R.row.path }))).catch(() => null);
972
988
  if (R !== me) return;
973
989
  R.cyc = null;
974
- if (c && c.ok && c.designed) { try { const x = splitRender(await textOf('/api/report-design/cycle-html?' + q({ ws: R.ws, path: R.row.path }))); if (R === me) R.cyc = x; } catch { /* the words are shown */ } }
990
+ if (c && c.ok && c.designed) { try { const x = splitRender(await textOf('/api/report-design/cycle-html?' + q({ ws: R.ws, path: R.row.path }))); if (R === me) { R.cyc = x; R.pyr = null; } } catch { /* the words are shown */ } }
991
+ // not designed: the Pyramid deck of a cadence draft (404 for any other report, which keeps the title slide and a slide per section)
992
+ else { let x = null; try { x = splitRender(await textOf('/api/report-design/pyramid?' + q({ ws: R.ws, path: R.row.path }))); } catch { x = null; } if (R === me) R.pyr = x && x.slides.length ? x : null; }
975
993
  }
976
994
  const viewUrl = (row, ws) => '/premium-viewer.html?' + q({ open: 'report', path: row.path, ws });
977
995
 
@@ -985,11 +1003,12 @@ export async function openReport(row, hand = {}) {
985
1003
  vzStyle(); rpStyle();
986
1004
  if (R) present(false);
987
1005
  const me = R = { row, ws: hand.ws || '', id: c.cadence, name: hand.name || row.name || c.cadence || 'Report', audience: hand.audience || '', issued: row.state === 'issued', archived: !!row.archived,
988
- text: '', err: '', W: null, view: 'deck', BF: null, bfRaw: null, bfMsg: '', LV: null, blank: false, i: 0, cyc: null, setup: undefined, pop: null, conf: false, checks: null, issueErr: '', busy: false, ask: '', askErr: '', edit: false, msg: null,
1006
+ text: '', err: '', W: null, view: 'deck', BF: null, bfRaw: null, bfMsg: '', LV: null, blank: false, i: 0, cyc: null, pyr: null, setup: undefined, pop: null, conf: false, checks: null, issueErr: '', busy: false, ask: '', askErr: '', edit: false, msg: null,
989
1007
  sch: schedPick(null), schErr: '', shr: null, rv: null, rvHide: new Set(), rvSent: new Set(), shares: null, more: [], hand, cuts: hand.cuts ? { on: 'team', team: null, sponsors: null, err: '' } : null, cycles: (hand.cycles || []).slice(), onIssue: hand.onIssue || null, onChange: hand.onChange || null, vid: 'report:' + row.path };
990
1008
  const head = me.head = () => ({ id: me.vid, kind: 'Report' + (me.audience ? ' · ' + me.audience : ''), title: me.name, icon: me.view === 'doc' ? 'doc' : 'report', full: true, url: viewUrl(row, me.ws), more: me.more,
991
1009
  // the template behind one icon (batch 22 item 14, canvas RfH1): format, readers, when it goes out, and its history
992
- presses: me.setup ? [{ act: 'template', label: 'Template: format, readers, look, sources', icon: RF_ICON.tune }] : [], onPress: (a) => { if (a === 'template' && R === me) openTemplate(); },
1010
+ presses: me.setup ? [{ act: 'chat', label: 'Talk to Claude about this report', icon: RF_ICON.chat }, { act: 'template', label: 'Template: format, readers, look, sources', icon: RF_ICON.tune }] : [],
1011
+ onPress: (a) => { if (R !== me) return; if (a === 'template') openTemplate(); else if (a === 'chat') openChat(); },
993
1012
  render: (b) => { syncMore(); b.innerHTML = panelHtml(); wire(b); }, onClose: () => { if (R === me && !me.reopen) { present(false); R = null; } } });
994
1013
  vOpen(head());
995
1014
  try { R.text = await textOf('/api/doc?' + q({ ws: R.ws, path: row.path })); R.W = wordsOf(R.text, R.name); if (!hand.name && R.W.title) R.name = R.W.title; } catch (x) { R.err = String((x && x.message) || x); R.W = { title: R.name, sections: [] }; }
@@ -23,7 +23,9 @@
23
23
  * A CHANGE Claude passes from the chat (block.change) goes to the report's own session (POST /api/report-flow/ask), then the report opens.
24
24
  * THE TEMPLATE (panel 'template', the header icon): the same questions on the current version, "changed" marks, Template history with Go back
25
25
  * (POST /api/report-flow/restore), Keep the current template and Make a different template (POST /api/report-flow/template). Its sections and
26
- * look, the cycles and Delete template stay one press further (panel 'manage', the view described above).
26
+ * look show as two read-only rows (canvas TplA): a sections change the PM named in the chat (block.sections) or a newer look made in Design
27
+ * is ONE ✦ "Make T<n+1>" (✕ drops it, ✓ makes it, with the settings, in one press). Editing the sections and look, the cycles and Delete
28
+ * template stay one press further (panel 'manage', the view described above).
27
29
  *
28
30
  * Every write is a press here, behind the launch nonce (http.js pmPost). Claude writes nothing: the routes refuse an agent session. A render is
29
31
  * HTML the server sanitized, shown in a frame with an empty sandbox, so nothing in it runs. Nothing is sent outward. */
@@ -79,16 +81,37 @@ export function openReportTab(block, o = {}) {
79
81
  if (!t && block.proposal) { setTimeout(() => adoptSetUp(id, block.proposal.name), 0); }
80
82
  if (!t || JSON.stringify(t.block) !== JSON.stringify(block) || (o.panel && o.panel !== t.panel)) {
81
83
  t = { id, block, nv: 'deck', sched: block.proposal ? (block.proposal.schedule || 'off') : null, open: false, view: 'structure', busy: false, msg: '', setup: null, docs: [], S: null, Z: null, sv: null, dv: null, render: new Map(), gone: false, loaded: false, i: 0, ask: null,
82
- q: block.proposal ? RF.picksOf(block.proposal) : null, panel: block.proposal ? 'new' : o.panel || 'current', chat: o.chat || (t && t.chat) || null, F: null, tq: null, passed: t ? t.passed : false };
84
+ q: block.proposal ? RF.picksOf(block.proposal) : null, panel: block.proposal ? 'new' : o.panel || (tplAsk(block) ? 'template' : 'current'), chat: o.chat || (t && t.chat) || null, F: null, tq: null, passed: t ? t.passed : false };
83
85
  T.set(id, t);
84
86
  if (block.id && t.panel === 'manage') load(t);
85
87
  } else if (o.chat) t.chat = o.chat;
86
88
  // a change passes on the PM's press of the chip only; an answer that opens the view by itself shows the report as it is
87
89
  if (block.id && block.change && !t.passed && !o.auto && !PASSED.has(JSON.stringify(block))) { PASSED.add(JSON.stringify(block)); t.passed = true; passChange(t); return show(t); }
88
90
  if (block.id && t.panel === 'current') return current(t);
89
- if (block.id && t.panel === 'template') { const v = show(t); loadFlow(t).then(() => redraw(t)); return v; }
91
+ if (block.id && t.panel === 'template') { const v = show(t); loadFlow(t).then(() => { redraw(t); if (!o.auto) makeLook(t); }); return v; }
90
92
  return show(t);
91
93
  }
94
+ /** A chat change to a set-up report's sections or look opens its template (canvas TplA), where it waits as one ✦. */
95
+ const tplAsk = (b) => !!(b && b.id && !b.change && ((Array.isArray(b.sections) && b.sections.length) || (typeof b.design === 'string' && b.design.trim())));
96
+ /** The look the PM asked for in words is made first (a design job, as Design's turn), once per chat change, on the PM's press of the chip; when
97
+ * it lands it is the newer look, and the ✦ offers it with the sections. Nothing is saved before ✓. */
98
+ async function makeLook(t) {
99
+ const words = typeof t.block.design === 'string' ? t.block.design.trim() : '';
100
+ const key = 'look:' + JSON.stringify(t.block);
101
+ if (!words || PASSED.has(key) || !t.F || !t.F.ok) return;
102
+ PASSED.add(key);
103
+ const had = t.F.look && t.F.look.newer ? t.F.look.newer.n : null;
104
+ const r = await post('/api/report-design/turn', { id: t.block.id, text: words, points: [] });
105
+ if (!r || !r.ok) { t.msg = 'The look was not started: ' + why(r, 'the page could not reach PMOS') + '.'; redraw(t); return; }
106
+ t.making = words; redraw(t);
107
+ const end = Date.now() + POLL_MAX;
108
+ while (Date.now() < end && T.get(t.id) === t) {
109
+ await new Promise((ok) => setTimeout(ok, POLL_MS * 2));
110
+ const F = await get('/api/report-flow', { id: t.block.id });
111
+ if (F && F.ok && F.look && F.look.newer && F.look.newer.n !== had) { t.F = Object.assign({}, t.F, { look: F.look }); t.making = null; t.tplDrop = false; redraw(t); return; }
112
+ }
113
+ t.making = null; t.msg = 'The look is not ready yet. It shows here when you open the template again.'; redraw(t);
114
+ }
92
115
  /** The report's state from GET /api/report-flow; for the template, the answers start from its current version. */
93
116
  async function loadFlow(t) {
94
117
  const F = await get('/api/report-flow', { id: t.block.id });
@@ -122,11 +145,19 @@ async function waitFor(t) {
122
145
  }
123
146
  t.waiting = false;
124
147
  }
125
- /** A change Claude passed from the chat: to the report's own session, then the report opens (RfH2). */
148
+ /** A change Claude passed from the chat: to the report's own session, on the latest draft by its file, then the report opens (RfH2).
149
+ * An issued latest cycle is frozen: the change is not passed, and the PM is told to change the template instead. */
126
150
  async function passChange(t) {
127
- const r = await post('/api/report-flow/ask', { id: t.block.id, text: t.block.change });
128
- const said = r && r.ok ? (r.started ? "The report's session started with your change. It shows in the report as it writes it. Nothing is issued." : "Passed to the report's session. It shows in the report as it writes it. Nothing is issued.")
129
- : 'The change was not passed on: ' + why(r, 'the page could not reach PMOS') + '.';
151
+ const F = await loadFlow(t);
152
+ const to = F && F.ok ? RF.changeTargetOf(F) : {};
153
+ let said;
154
+ if (to.frozen) said = `The ${to.frozen} report is issued, so it is frozen. The change was not passed on: change the template for the next cycle.`;
155
+ else {
156
+ const r = await post('/api/report-flow/ask', { id: t.block.id, text: t.block.change, ...(to.path ? { path: to.path } : {}) });
157
+ const which = to.slot ? `the ${to.slot} draft` : 'the draft';
158
+ said = r && r.ok ? (r.started ? `The report's session started with your change to ${which}. It shows in the report as it writes it. Nothing is issued.` : `Passed to the report's session for ${which}. It shows in the report as it writes it. Nothing is issued.`)
159
+ : 'The change was not passed on: ' + why(r, 'the page could not reach PMOS') + '.';
160
+ }
130
161
  t.block = { kind: 'report', id: t.block.id }; t.passed = false;
131
162
  return current(t, said);
132
163
  }
@@ -239,19 +270,38 @@ function currentHtml(t) {
239
270
  function templateHtml(t) {
240
271
  if (!t.F) return '<p class="vz-empty" role="status">Reading the template.</p>';
241
272
  if (t.F.err) return `<p class="vz-msg" data-tone="bad">${esc(t.F.err)}</p>`;
242
- const T0 = t.F.template || {};
243
- const tpl = { base: t.base, current: T0.current, versions: T0.versions || [], diff: RF.diffOf(t.tq, t.base) };
244
- return RF.questionsHtml(t.tq, { template: tpl, busy: t.busy, msg: t.msg })
273
+ return RF.questionsHtml(t.tq, { template: tplOf(t), name: t.F.name, making: t.making, busy: t.busy, msg: t.msg })
245
274
  + `<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>`;
246
275
  }
247
276
  const qOf = (t) => (t.block.proposal ? t.q : t.tq);
277
+ /** The sections a list of titles becomes when saved (lib/report-structure.js planFromSections): Sources last, and one named section alone gets
278
+ * "Needs your call" after it. */
279
+ export function savedTitles(L) {
280
+ const seen = new Set(), list = (L || []).map((x) => String(x || '').replace(/\s+/g, ' ').trim()).filter((x) => x && !seen.has(x.toLowerCase()) && seen.add(x.toLowerCase()));
281
+ if (!list.length) return [];
282
+ const si = list.findIndex((x) => /^sources?\b/i.test(x) || /\bsources?$/i.test(x));
283
+ const src = si >= 0 ? list.splice(si, 1)[0] : 'Sources';
284
+ if (list.length === 1) list.push('Needs your call');
285
+ return list.concat([src]);
286
+ }
287
+ /** The template as the panel draws it (canvas TplA): its versions, its sections and look, and the change waiting for ✓: the sections the PM
288
+ * named in the chat (block.sections) when they differ from the saved ones, and a newer look made in Design and not saved yet. */
289
+ function tplOf(t) {
290
+ const F = t.F || {}, T0 = F.template || {};
291
+ const S = F.sections || { saved: null, titles: [] }, L = F.look || null;
292
+ const named = Array.isArray(t.block.sections) && t.block.sections.length ? savedTitles(t.block.sections) : null;
293
+ const sNext = named && named.map((x) => x.toLowerCase()).join('\n') !== (S.titles || []).map((x) => String(x).toLowerCase()).join('\n') ? named : null;
294
+ return { base: t.base, current: T0.current, versions: T0.versions || [], diff: RF.diffOf(t.tq, t.base), dropped: !!t.tplDrop,
295
+ sections: { saved: S.saved, titles: S.titles || [], next: sNext },
296
+ look: L ? { saved: L.saved, words: L.words, follows: L.follows || [], next: L.newer || null } : null };
297
+ }
248
298
  /** Readers, typed: kept as typed; Draft it and Make a different template wait for a name. */
249
299
  function typed(t, e) {
250
300
  const k = e.target && e.target.dataset ? e.target.dataset.rt : '';
251
301
  const q = qOf(t); if (k !== 'aud' || !q) return;
252
302
  q.audience = e.target.value;
253
303
  const b = paneOf(t) && paneOf(t).querySelector(t.block.proposal ? '[data-rt="draftit"]' : '[data-rt="maketpl"]');
254
- if (b) b.disabled = t.busy || !q.audience.trim() || (!t.block.proposal && !RF.diffOf(q, t.base).length);
304
+ if (b) b.disabled = t.busy || !q.audience.trim() || (!t.block.proposal && !RF.templateChange(tplOf(t), q).length);
255
305
  }
256
306
  /** A pick in Goes out (how often, the day, the time). The template redraws, so its "changed" marks follow. */
257
307
  function picked(t, e) {
@@ -344,12 +394,17 @@ async function press(t, e) {
344
394
  if (a === 'draftit') { await setUp(t); return; }
345
395
  if (a === 'keep') { await current(t); return; }
346
396
  if (a === 'manage') { t.panel = 'manage'; t.loaded = false; show(t); await load(t); return; }
397
+ if (a === 'tpl-no') { t.tplDrop = true; t.msg = 'Dropped. Nothing is saved; the template stays T' + ((t.F && t.F.template && t.F.template.current) || 1) + '.'; redraw(t); return; }
347
398
  if (a === 'maketpl') {
399
+ const tp = tplOf(t), body = { id: t.block.id, settings: RF.settingsOfPicks(t.tq) };
400
+ if (!tp.dropped && tp.sections.next) body.sections = tp.sections.next;
401
+ if (!tp.dropped && tp.look && tp.look.next) body.design = tp.look.next.n;
348
402
  await act(t, async () => {
349
- const r = await post('/api/report-flow/template', { id: t.block.id, settings: RF.settingsOfPicks(t.tq) });
403
+ const r = await post('/api/report-flow/template', body);
350
404
  if (!r || !r.ok) return 'The template did not change: ' + why(r, 'the page could not reach PMOS') + '.';
405
+ if (body.sections) t.block = Object.assign({}, t.block, { sections: undefined, structure: undefined });
351
406
  if (r.state) t.F = r.state; await loadFlow(t);
352
- return 'T' + r.n + ' is the current template. The next draft follows it; the earlier drafts and cycles stay with their own.';
407
+ return 'T' + r.n + ' is the current template. The next cycle follows it; the open draft stays as it is, and the earlier cycles keep their look.';
353
408
  });
354
409
  return;
355
410
  }
@@ -358,7 +413,7 @@ async function press(t, e) {
358
413
  const r = await post('/api/report-flow/restore', { id: t.block.id, n: +v });
359
414
  if (!r || !r.ok) return 'It did not go back: ' + why(r, 'the page could not reach PMOS') + '.';
360
415
  await loadFlow(t);
361
- return 'Back to T' + r.n + '. It is the current template again. Nothing is deleted.';
416
+ return 'Back to T' + r.n + (r.restored ? ': ' + r.restored : '') + '. It is the current template again. Nothing is deleted.';
362
417
  });
363
418
  return;
364
419
  }