create-pmos 0.441.0 → 0.443.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 (87) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/adler-seasons-art-test.js +106 -0
  7. package/workspace/adler-seasons-test.js +111 -0
  8. package/workspace/briefing-premium-board-test.js +19 -17
  9. package/workspace/briefing-premium-initiative-test.js +7 -4
  10. package/workspace/changelog.json +24 -0
  11. package/workspace/goals-clear-ui-test.js +249 -0
  12. package/workspace/guide/adler.md +10 -0
  13. package/workspace/guide/home.md +8 -1
  14. package/workspace/guide/metric-drafts.md +8 -2
  15. package/workspace/home-railcard-test.js +193 -0
  16. package/workspace/ini-workflow-test.js +6 -2
  17. package/workspace/intelligence-gaps-ui-test.js +16 -14
  18. package/workspace/lib/engine/records/index.js +9 -2
  19. package/workspace/lib/initiative-layout.js +3 -1
  20. package/workspace/lib/insights-premium.js +22 -1
  21. package/workspace/lib/metric-drafts.js +37 -10
  22. package/workspace/lib/metric-read-runs.js +20 -13
  23. package/workspace/lib/metric-reads.js +208 -23
  24. package/workspace/lib/metrics-cli.js +62 -5
  25. package/workspace/lib/routes-goal-status.js +89 -6
  26. package/workspace/lib/routes-insights-premium.js +1 -1
  27. package/workspace/lib/routes-metric-drafts.js +26 -3
  28. package/workspace/lib/settings-store.js +38 -0
  29. package/workspace/metric-drafts-ui-test.js +7 -4
  30. package/workspace/okr-goals-ui-test.js +7 -5
  31. package/workspace/package-lock.json +2 -2
  32. package/workspace/package.json +1 -1
  33. package/workspace/premium-board-actions-test.js +2 -1
  34. package/workspace/premium-chat-attach-test.js +2 -0
  35. package/workspace/program-panel-test.js +1 -1
  36. package/workspace/public/pm/bd-ini-panel.js +2 -2
  37. package/workspace/public/pm/c3-ini-ui.js +1 -1
  38. package/workspace/public/pm/cozy-adler.css +21 -0
  39. package/workspace/public/pm/cozy-adler.js +415 -8
  40. package/workspace/public/pm/cozy-ev.css +16 -1
  41. package/workspace/public/pm/cozy-home.css +8 -0
  42. package/workspace/public/pm/cozy-insights.css +82 -0
  43. package/workspace/public/pm/cozy-live-pill.css +5 -0
  44. package/workspace/public/pm/cozy-news.js +1 -1
  45. package/workspace/public/pm/cozy-seasons.js +318 -0
  46. package/workspace/public/pm/cozy-settings.js +88 -5
  47. package/workspace/public/pm/cozy-today.css +15 -0
  48. package/workspace/public/pm/cozy-viewer.js +50 -18
  49. package/workspace/public/pm/cozy-vw-shell.css +4 -0
  50. package/workspace/public/pm/cozy.css +65 -0
  51. package/workspace/public/pm/dash-view.js +4 -2
  52. package/workspace/public/pm/goals-clear.js +258 -0
  53. package/workspace/public/pm/home-app.js +59 -5
  54. package/workspace/public/pm/home-chat.js +1 -1
  55. package/workspace/public/pm/home-day.js +7 -4
  56. package/workspace/public/pm/home-ini.js +2 -2
  57. package/workspace/public/pm/home-mentions.js +1 -1
  58. package/workspace/public/pm/home-today.js +51 -10
  59. package/workspace/public/pm/impact.js +1 -1
  60. package/workspace/public/pm/ini-groups.js +28 -17
  61. package/workspace/public/pm/ini-links.js +1 -1
  62. package/workspace/public/pm/ini-tasks.js +246 -48
  63. package/workspace/public/pm/ini-view-model.js +45 -16
  64. package/workspace/public/pm/ini-view.css +330 -1
  65. package/workspace/public/pm/ini-view.js +196 -83
  66. package/workspace/public/pm/metric-drafts.js +4 -1
  67. package/workspace/public/pm/mission.js +238 -0
  68. package/workspace/public/pm/premium-board.js +1 -1
  69. package/workspace/public/pm/premium-insights.js +178 -24
  70. package/workspace/public/pm/premium-welcome.js +2 -2
  71. package/workspace/public/pm/split-merge.js +1 -1
  72. package/workspace/public/pm/stage-line.js +2 -2
  73. package/workspace/server.js +6 -2
  74. package/workspace/skills/metric-read.skill +7 -5
  75. package/workspace/split-merge-ui-test.js +1 -1
  76. package/workspace/stage-card-test.js +56 -11
  77. package/workspace/task-links-test.js +2 -0
  78. package/workspace/task-milestones-test.js +5 -1
  79. package/workspace/task-plans-test.js +3 -3
  80. package/workspace/task-views-test.js +279 -37
  81. package/workspace/test-lists/adler-seasons-art.json +13 -0
  82. package/workspace/test-lists/batch18-adler-seasons.json +13 -0
  83. package/workspace/test-lists/goals-clear.json +15 -0
  84. package/workspace/test-lists/home-railcard.json +9 -0
  85. package/workspace/test-lists/mission.json +5 -0
  86. package/workspace/test-lists/viewer-tasks.json +5 -0
  87. package/workspace/tk-tasks-test.js +27 -32
@@ -0,0 +1,258 @@
1
+ /* pm/goals-clear.js — goals made clear on Intelligence (feedback batch 18 item 11, build 11-B; main canvas In development, frames Gc*). PURE: each
2
+ * function takes a drafted row (GET /api/metric-drafts, through okr-list.js draftsOf) or a goal of the Intelligence model (GET /api/insights-premium,
3
+ * with the fields lib/goal-status.js and the goals reading engine add) and returns words or markup. No read, no write, no clock of its own.
4
+ *
5
+ * rhythmOf(x) { short: "Every Monday", long: "every Monday 07:00" } | null the server's rhythm, else said from the recipe
6
+ * keptSay(rows) the "Kept" toast: "Kept. I read it every Monday 07:00." with the goal's own rhythm (never "every morning")
7
+ * tableHtml(rows, o) GcJ1aTable: the drafts table. Proposed metric · How it is counted · Now (read hh:mm) · Target · From, how often · ✕ ✓
8
+ * checkHtml(r, st) GcJ1Drafts: the check panel of one drafted metric; GcS3Differs once the PM typed a number that differs
9
+ * firstOf(g) { n, first, next } while a goal has fewer than 3 readings (GcJ2FirstMonday): no pace, no trend yet
10
+ * firstMeta(g) the row's second line then: "39.4k · Looker, Mon 2 Nov 07:02 · pace known after 3 readings"
11
+ * firstChart(g) the dashed box where the chart will be: "The line starts with the 2nd reading, Mon 9 Nov"
12
+ * krHtml(g, o) GcR3Goal, GcR4Failed, GcR5Held: the failed or held box, How it is counted, From … (said once), the checks, the query
13
+ * lineOf(goals, product) the ✦ line for a held reading, a failed read or the first readings; null when none of them is the news
14
+ *
15
+ * The rules of the frames: summary first; how often and the last read are said once, in "From, how often"; a held or failed reading never shows as
16
+ * progress (the row and the dot keep the last good reading); icon-only presses, with words in aria-label and title; Adler stays out of the table,
17
+ * the counts and the charts. Every field is optional: what the server did not send is not drawn (zero is silence). */
18
+
19
+ import { esc, SV, P, dotHtml } from './okr-list.js';
20
+
21
+ const WD = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
22
+ const WD3 = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
23
+ const DAYKEY = { sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6 };
24
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
25
+ const fin = (v) => typeof v === 'number' && Number.isFinite(v);
26
+ const when = (iso) => { const t = Date.parse(String(iso || '')); return Number.isFinite(t) ? new Date(t) : null; };
27
+ const pad = (n) => String(n).padStart(2, '0');
28
+ /** "07:02" in the PM's own time. A day with no time ("2026-11-02") has none. */
29
+ export const hm = (iso) => { const d = /T\d/.test(String(iso || '')) ? when(iso) : null; return d ? pad(d.getHours()) + ':' + pad(d.getMinutes()) : ''; };
30
+ /** "Mon 2 Nov" (a date) and "Mon 2 Nov, 07:02" (a date with its time). */
31
+ export const dayTxt = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return ''; const d = /T\d/.test(iso) ? when(iso) : new Date(+m[1], +m[2] - 1, +m[3]); return d ? WD3[d.getDay()] + ' ' + d.getDate() + ' ' + MON[d.getMonth()] : ''; };
32
+ export const atTxt = (iso) => [dayTxt(iso), hm(iso)].filter(Boolean).join(', ');
33
+ const big = (v) => (fin(v) ? (Math.abs(v) >= 1000 ? v.toLocaleString('en-US', { maximumFractionDigits: 0 }) : String(Math.round(v * 100) / 100)) : '');
34
+ const icon = (d, s = 16) => SV(d, s);
35
+ const I = Object.assign({}, P, { open: 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5', redo: 'M20 12a8 8 0 1 1-2.3-5.6M20 4v5h-5', warn: 'M12 4l9 16H3zM12 10v4M12 17v.5' });
36
+ const ib = (o) => `<button type="button" class="cz-ib sm${o.solid ? ' solid' : ''}" data-gc="${esc(o.act)}"${o.row ? ` data-row="${esc(o.row)}"` : ''} aria-label="${esc(o.label)}" title="${esc(o.title || o.label)}"${o.busy ? ' disabled' : ''}>${icon(o.icon, o.solid ? 18 : 16)}</button>`;
37
+
38
+ /* ── the rhythm ────────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
39
+ /** How often a goal is read, in two lengths: the table's short one and the long one the panel and the toast say. The server's rhythm wins
40
+ * ({ txt, short }); else it is said from the recipe's cadence, at and day. null when the goal has no way to be read. */
41
+ export function rhythmOf(x) {
42
+ const R = (x && x.rhythm) || (x && x.raw && x.raw.rhythm), rc = (x && x.recipe) || (x && x.raw && x.raw.recipe) || null;
43
+ const rat = R && typeof R === 'object' ? (/^\d{1,2}:\d{2}$/.test(String(R.at || '')) ? String(R.at) : (/(\d{1,2}:\d{2})$/.exec(String(R.txt || '')) || [])[1] || '') : '';
44
+ if (R && typeof R === 'object' && R.cadence === 'daily' && rat) return { short: 'Every day, ' + rat.padStart(5, '0'), long: String(R.txt || 'every day ' + rat).replace(/^./, (c) => c.toLowerCase()) };
45
+ if (R && typeof R === 'object' && (R.txt || R.short)) { const long = String(R.txt || R.short); return { short: String(R.short || long.replace(/^./, (c) => c.toUpperCase()).replace(/ \d{2}:\d{2}$/, '')), long: long.replace(/^./, (c) => c.toLowerCase()) }; }
46
+ if (typeof R === 'string' && R) return { short: R.replace(/^./, (c) => c.toUpperCase()), long: R.replace(/^./, (c) => c.toLowerCase()) };
47
+ const c = rc && rc.cadence; if (!c) return null;
48
+ const at = /^\d{1,2}:\d{2}$/.test(String(rc.at || '')) ? String(rc.at).padStart(5, '0') : '';
49
+ if (c === 'hourly') return { short: 'Every hour', long: 'every hour' + (rc.hours ? ', ' + rc.hours : '') };
50
+ if (c === 'daily') return { short: 'Every day' + (at ? ', ' + at : ''), long: 'every day' + (at ? ' ' + at : '') };
51
+ if (c === 'weekly') { const d = DAYKEY[String(rc.day || 'mon').slice(0, 3).toLowerCase()]; const w = WD[d === undefined ? 1 : d]; return { short: 'Every ' + w, long: 'every ' + w + (at ? ' ' + at : '') }; }
52
+ if (c === 'monthly') return { short: 'Every month', long: 'every month, the 1st' + (at ? ' ' + at : '') };
53
+ return { short: String(c), long: String(c) };
54
+ }
55
+ /** The "Kept" toast (AdM3Intel, now with the goal's own rhythm). rows: the drafts kept by this press. One rhythm for all: it says it; several:
56
+ * "each on its own rhythm". A server's said line (r.said) wins. */
57
+ export function keptSay(rows, said) {
58
+ if (said) return said;
59
+ const R = (rows || []).map(rhythmOf).filter(Boolean), longs = [...new Set(R.map((x) => x.long))];
60
+ if (!R.length) return 'Kept. I read it from now on.';
61
+ if (longs.length === 1) return 'Kept. I read ' + ((rows || []).length > 1 ? 'them ' : 'it ') + longs[0] + '.';
62
+ return 'Kept. I read each one on its own rhythm: the first reading within the hour.';
63
+ }
64
+
65
+ /* ── the drafts table (GcJ1aTable) ─────────────────────────────────────────────────────────────────────────────────────────────── */
66
+ const GROUP_SAY = { 'North Star': 'the moment people get value', Inputs: 'what moves the North Star', Guardrails: 'must not get worse', 'Key results': 'this quarter' };
67
+ const TYPE_SAY = { 'Stay within': 'Stay within', Percentage: 'Percentage', Count: 'Count', Amount: 'Amount', Duration: 'Duration', 'Done or not': 'Done or not' };
68
+ const liveOf = (r) => { const L = r && r.raw && r.raw.live; return L && typeof L === 'object' ? L : null; };
69
+ const countsOf = (x) => { const c = (x && x.counts) || (x && x.raw && x.raw.counts); return c && typeof c === 'object' ? c : null; };
70
+ /** What the row says in "How it is counted": the plain sentence, else the two counts as "a ÷ b", else nothing. */
71
+ export function countedOf(x) {
72
+ const c = countsOf(x); if (!c) return '';
73
+ if (c.what) return String(c.what);
74
+ return [c.num_label, c.den_label].filter(Boolean).join(' ÷ ');
75
+ }
76
+ /** The source and the rhythm as the table says them: the source with its dot (green: it read; amber: it could not), then the short rhythm. */
77
+ function fromHtml(r) {
78
+ const rc = (r.raw && r.raw.recipe) || null, L = liveOf(r), src = (rc && rc.connector) || r.source || '';
79
+ const R = rhythmOf(r);
80
+ if (!src && !R) return '<span class="note">Not set yet</span>';
81
+ const dot = L ? (L.ok === false ? 'risk' : 'ok') : 'q';
82
+ return `<span class="gc-src"><i class="cz-dot ${dot}" aria-hidden="true"></i><b>${esc(src || 'You type it in')}</b></span>${R ? `<span class="note">${esc(R.short)}</span>` : ''}`;
83
+ }
84
+ const nowOf = (r) => { const L = liveOf(r); if (L && L.ok !== false) return L.txt || big(L.value) || r.nowTxt || '—'; if (L && L.ok === false) return '—'; return r.nowTxt || '—'; };
85
+ /** rows: the open metric drafts (okr-list.js draftsOf, kind metric) in the product's groups. o: { busy: Set of row ids, sel: row id }.
86
+ * The header's "read hh:mm" is the time of the newest live read; with none it is "Now". */
87
+ export function tableHtml(rows, o = {}) {
88
+ const R = (rows || []).filter((r) => r && r.kind === 'metric' && r.state === 'open'); if (!R.length) return '';
89
+ const lives = R.map(liveOf).filter((L) => L && L.ok !== false && L.at).map((L) => L.at).sort();
90
+ const t = lives.length ? hm(lives[lives.length - 1]) : '';
91
+ const groups = ['North Star', 'Inputs', 'Guardrails', 'Key results'];
92
+ const by = groups.map((g) => [g, R.filter((r) => r.group === g)]).concat([['', R.filter((r) => !groups.includes(r.group))]]).filter(([, L]) => L.length);
93
+ const busy = o.busy || new Set();
94
+ const row = (r) => {
95
+ const type = (r.raw && TYPE_SAY[r.raw.type]) || '';
96
+ return `<div class="gc-tr${o.sel === r.id ? ' sel' : ''}" role="row" data-gc-row="${esc(r.id)}" tabindex="0" aria-label="${esc('Check ' + r.name)}">`
97
+ + `<span class="gc-nm" role="cell"><b>${esc(r.name)}</b>${type ? `<span class="gc-type">${esc(type)}</span>` : ''}</span>`
98
+ + `<span class="gc-hw" role="cell">${esc(countedOf(r)) || '<span class="note">Not written yet</span>'}</span>`
99
+ + `<span class="gc-now" role="cell"><b>${esc(nowOf(r))}</b></span>`
100
+ + `<span class="gc-tg" role="cell"><b>${esc(r.targetTxt || '—')}</b></span>`
101
+ + `<span class="gc-from" role="cell">${fromHtml(r)}</span>`
102
+ + `<span class="gc-acts" role="cell">${ib({ act: 'drop', row: r.id, icon: I.x, label: 'Not now: ' + r.name, title: 'Not now', busy: busy.has(r.id) })}${ib({ act: 'keep', row: r.id, icon: I.chk, label: 'Keep: ' + r.name, title: 'Keep', solid: false, busy: busy.has(r.id) })}</span></div>`;
103
+ };
104
+ return `<div class="gc-tbl" role="table" aria-label="Proposed metrics"><div class="gc-th" role="row"><span role="columnheader">Proposed metric</span><span role="columnheader">How it is counted</span>`
105
+ + `<span role="columnheader">Now${t ? ` <span class="note">read ${esc(t)}</span>` : ''}</span><span role="columnheader">Target</span><span role="columnheader">From, how often</span><span role="columnheader"><span class="vh">Not now or keep</span></span></div>`
106
+ + by.map(([g, L]) => (g ? `<div class="gc-grp" role="row"><span role="cell"><b>${esc(g)}</b> <span class="note">${esc(GROUP_SAY[g] || '')}</span></span></div>` : '') + L.map(row).join('')).join('') + '</div>';
107
+ }
108
+
109
+ /* ── the check panel (GcJ1Drafts, GcS3Differs) ─────────────────────────────────────────────────────────────────────────────────── */
110
+ const checkRow = (c) => `<li class="${c.ok ? 'ok' : 'warn'}">${icon(c.ok ? I.chk : I.warn, 14)}<span>${esc(c.text)}</span></li>`;
111
+ const queryHtml = (rc, open) => (rc && rc.query ? `<details class="gc-q"${open ? ' open' : ''}><summary><b>The query</b> <span class="note">${esc([rc.connector, rc.where].filter(Boolean).join(' · '))}</span></summary><pre>${esc(rc.query)}</pre></details>` : '');
112
+ /** The counts as a fraction (GcR3Goal): "1,212 checkouts stopped at login" over "6,000 checkouts reached login", then "= 20.2%, week of 9 Nov".
113
+ * With a reading that failed, the counts are "?" and the result is "not known for this week". */
114
+ function fractionHtml(c, L, unknown) {
115
+ if (!c || !(c.num_label || c.den_label)) return '';
116
+ const n = unknown ? '?' : big(L && L.num), d = unknown ? '?' : big(L && L.den);
117
+ if (!unknown && !(n || d)) return '';
118
+ const res = unknown ? '= not known for this ' + (L && L.period && /^month/.test(L.period) ? 'month' : 'week') : '= ' + (L.txt || big(L.value)) + (L.period ? ', ' + L.period : '');
119
+ return `<div class="gc-frac">${c.num_label ? `<div class="n"><b>${esc(n)}</b><span>${esc(c.num_label)}</span></div>` : ''}${c.den_label ? `<div class="d"><b>${esc(d)}</b><span>${esc(c.den_label)}</span></div>` : ''}<div class="r">${esc(res)}</div></div>`;
120
+ }
121
+ /** st: { compare: the PM's number as typed, busy, msg }. The compare answer lives on the row (raw.compare) once the server has it. */
122
+ export function checkHtml(r, st = {}) {
123
+ const raw = r.raw || {}, L = liveOf(r), c = countsOf(r), rc = raw.recipe || null, R = rhythmOf(r), cmp = raw.compare && fin(raw.compare.value) ? raw.compare : null;
124
+ if (cmp && cmp.state !== 'picked' && !st.back) {
125
+ // GcS3Differs: mine beside yours, how far apart and why, then Claude's suggestion with ✕ / ✓
126
+ const sg = cmp.suggest || null, mine = cmp.oursTxt || (fin(cmp.ours) ? big(cmp.ours) : '') || (L && L.ok !== false ? (L.txt || big(L.value)) : r.nowTxt || '—');
127
+ const close = cmp.state === 'same' || (cmp.differs === false) || (cmp.differs === undefined && fin(cmp.pct) && Math.abs(cmp.pct) <= 2);
128
+ return `<div class="gc-two"><div class="gc-card"><span class="note">Mine</span><b>${esc(mine)}</b><span class="note">${esc(cmp.oursLabel || 'as I count it')}</span></div>`
129
+ + `<div class="gc-card"><span class="note">${esc(cmp.label || 'Yours')}</span><b>${esc(cmp.txt || big(cmp.value))}</b><span class="note">you typed it</span></div></div>`
130
+ + (close ? `<p class="gc-say"><b>Within 2%.</b> Your number and mine agree, so I keep counting it this way.</p>`
131
+ : `<p class="gc-say">${cmp.apart ? `<b>${esc(cmp.apart)} apart.</b> ` : ''}${cmp.why ? `<b>I found why:</b> ${esc(cmp.why)}` : 'I am looking for why. It shows here when I know.'}</p>`)
132
+ + (sg && sg.text && !close ? `<div class="gc-sg"><span class="sp" aria-hidden="true">${icon(I.spark, 16)}</span><p>${esc(sg.text)} I write your pick into “How it is counted”.</p><span class="acts">${ib({ act: 'pick-other', row: r.id, icon: I.x, label: 'No, count it the other way', title: 'No', busy: st.busy })}${ib({ act: 'pick', row: r.id, icon: I.chk, label: 'Yes, count it as you suggest', title: 'Yes', solid: true, busy: st.busy })}</span></div>` : '')
133
+ + `<p class="note gc-msg" role="status">${esc(st.msg || '')}</p>`;
134
+ }
135
+ const value = L && L.ok !== false ? (L.txt || big(L.value)) : '';
136
+ const head = L && L.ok === false
137
+ ? `<div class="gc-warnbox"><b>${esc(atTxt(L.at) + ' · not read')}</b><p>${esc(L.error || 'The source did not answer.')} I did not guess a number.</p></div>`
138
+ : '';
139
+ const box = `<div class="gc-box"><span class="gc-k">How it is counted</span>${c && c.what ? `<p class="gc-what">${esc(c.what)}</p>` : '<p class="note">Not written yet. ✎ says it in your words.</p>'}`
140
+ + (L && L.ok !== false && (L.num != null || L.den != null) ? fractionHtml(c, L) : '')
141
+ + (value ? `<p class="gc-big"><b>${esc(value)}</b><span class="note">read ${esc(L.at && Date.now() - Date.parse(L.at) < 15 * 6e4 ? 'just now' : atTxt(L.at))}${L.period ? ', ' + esc(L.period) : ''}</span></p>`
142
+ : !L ? `<p class="note">Not read yet. ↻ reads it now, and nothing is kept until you keep it.</p>` : '') + '</div>';
143
+ const checks = (Array.isArray(raw.checks) ? raw.checks : []).filter((x) => x && x.text);
144
+ const cmpLine = { ok: false, text: 'No other number to compare yet: type yours' };
145
+ const list = checks.concat(cmp ? [] : [cmpLine]);
146
+ return head + box
147
+ + `<div class="gc-sec"><b class="gc-k">My checks</b><ul class="gc-checks">${list.map(checkRow).join('')}</ul></div>`
148
+ + `<form class="gc-cmp" data-gc-cmp><input name="v" inputmode="decimal" maxlength="24" autocomplete="off" placeholder="${esc('Your number for ' + (L && L.period ? L.period.replace(/^week of .*/, 'last week') : 'last week') + (value ? ', e.g. ' + value : ''))}" aria-label="Your number, to compare with mine" value="${esc(st.compare || '')}">`
149
+ + `<button type="submit" class="cz-ib sm solid" aria-label="Compare with my number" title="Compare"${st.busy ? ' disabled' : ''}>${icon(I.chk, 18)}</button></form>`
150
+ + (R ? `<p class="gc-line"><b>How often</b> ${esc(R.long)}</p>` : '')
151
+ + queryHtml(rc, false)
152
+ + `<div class="gc-foot">${rc && rc.url ? `<a class="cz-ib sm" href="${esc(rc.url)}" target="_blank" rel="noopener noreferrer" aria-label="Open in ${esc(rc.connector || 'the source')}" title="Open in ${esc(rc.connector || 'the source')}">${icon(I.open)}</a>` : ''}`
153
+ + ib({ act: 'edit', row: r.id, icon: I.pen, label: 'Edit how it is counted, the target or the source', title: 'Edit', busy: st.busy })
154
+ + ib({ act: 'test', row: r.id, icon: I.redo, label: 'Read it now', title: 'Read now', busy: st.busy })
155
+ + `<span class="gc-sp"></span>${ib({ act: 'keep', row: r.id, icon: I.chk, label: 'Keep', title: 'Keep', solid: true, busy: st.busy })}</div>`
156
+ + `<p class="note gc-msg" role="status">${esc(st.msg || '')}</p>`;
157
+ }
158
+
159
+ /* ── first readings (GcJ2FirstMonday) ──────────────────────────────────────────────────────────────────────────────────────────── */
160
+ const SEEN_UNTIL = 3;
161
+ /** While a goal has fewer than 3 readings: how many, the first one (with its source and time) and when the next one comes. null from the 3rd. */
162
+ export function firstOf(g) {
163
+ const S = (g && g.series) || [], n = S.length;
164
+ // Only goals Claude reads on a rhythm; a goal read by hand keeps its line from the first reading.
165
+ if (!g || !n || n >= SEEN_UNTIL || !g.recipe) return null;
166
+ const last = g.lastRead || null, z = S[n - 1];
167
+ return { n, txt: (last && last.txt) || g.nowTxt || big(z.v), source: (last && last.source) || (g.recipe && g.recipe.connector) || '', at: (last && last.at) || z.at, next: g.nextRead || null };
168
+ }
169
+ /** The row's second line while the line is not drawn yet. */
170
+ export function firstMeta(g) {
171
+ const F = firstOf(g); if (!F) return '';
172
+ return [F.txt, [F.source, atTxt(F.at)].filter(Boolean).join(', '), 'pace known after 3 readings'].filter(Boolean).join(' · ');
173
+ }
174
+ /** Where the chart goes: "The line starts with the 2nd reading, Mon 9 Nov". */
175
+ export function firstChart(g) {
176
+ const F = firstOf(g); if (!F || F.n >= 2) return '';
177
+ return `<div class="gc-wait" role="note">The line starts with the 2nd reading${F.next ? ', ' + esc(dayTxt(F.next)) : ''}</div>`;
178
+ }
179
+
180
+ /* ── a key result's panel (GcR3Goal), and its failed (GcR4Failed) and held (GcR5Held) states ───────────────────────────────────────── */
181
+ /** "From Looker, chart “Checkout funnel”, every Monday 07:00. Last Mon 16 Nov, next Mon 23 Nov." The last read and the next one, said once. */
182
+ export function fromLine(g) {
183
+ const rc = g.recipe || null, R = rhythmOf(g), L = g.lastRead || null, F = g.failed || null, H = (g.held || [])[0] || null;
184
+ if (!rc || !rc.connector) return '';
185
+ const lastAt = [L && L.at, F && F.at, H && H.at].filter(Boolean).sort().pop() || (rc.last && rc.last.at) || null;
186
+ const last = lastAt ? 'Last ' + dayTxt(lastAt) + (H && H.at === lastAt ? ' (held)' : '') : '';
187
+ const next = g.nextRead ? 'next ' + dayTxt(g.nextRead) : '';
188
+ return `<p class="gc-fl">From <b>${esc(rc.connector)}</b>${rc.where ? ', ' + esc(rc.where) : ''}${R ? ', ' + esc(R.long) : ''}.${last || next ? ' ' + esc([last, next].filter(Boolean).join(', ')) + '.' : ''}</p>`;
189
+ }
190
+ /** The amber box of a read that failed: the time, the reason, and its one fix (reconnect the source, then Claude reads it at once). */
191
+ function failedHtml(g) {
192
+ const F = g.failed; if (!F) return '';
193
+ const fx = F.fix || {}, src = fx.connector || (g.recipe && g.recipe.connector) || 'the source';
194
+ return `<div class="gc-warnbox" data-gc-failed><b>${esc(atTxt(F.at) + ' · not read')}</b><p>${esc(F.why || 'The source did not answer.')} I did not guess a number.</p>`
195
+ + `<div class="gc-fix"><b>Reconnect ${esc(src)}, then I read it at once</b>${ib({ act: 'reconnect', row: fx.row || '', icon: I.plug, label: 'Reconnect ' + src, title: 'Reconnect', solid: true })}</div></div>`;
196
+ }
197
+ /** The amber box of a held reading: the time, the value it read, why it was held, its checks, the drafted Jira ticket (✎, ✓ send it) and ✓✓ file it
198
+ * anyway. ticket: the drafted ticket row (okr-list.js draftsOf) when the goal's held reading names one. */
199
+ function heldHtml(g, ticket) {
200
+ const H = (g.held || [])[0]; if (!H) return '';
201
+ // say it once: a check whose words are already the why is not listed again
202
+ const checks = (H.checks || []).filter((c) => c && c.text && !String(H.why || '').includes(c.text));
203
+ const tk = ticket && ticket.state === 'open' ? `<div class="gc-fix"><b>I drafted a Jira ticket: “${esc((ticket.raw && ticket.raw.ticket && ticket.raw.ticket.title) || ticket.text)}”</b><span class="acts"><button type="button" class="cz-ib sm" data-okd="edit" data-row="${esc(ticket.id)}" aria-label="Edit the ticket" title="Edit">${icon(I.pen)}</button><button type="button" class="cz-ib sm solid" data-okd="keep" data-row="${esc(ticket.id)}" aria-label="Send the ticket to Jira" title="Send to Jira">${icon(I.chk, 18)}</button></span></div>` : '';
204
+ return `<div class="gc-warnbox" data-gc-held><b>${esc(dayTxt(H.at) + (H.txt || fin(H.value) ? ' · read ' + (H.txt || big(H.value)) : '') + ' · held')}</b>${H.why ? `<p>${esc(H.why)}</p>` : ''}`
205
+ + (checks.length ? `<ul class="gc-checks">${checks.map(checkRow).join('')}</ul>` : '') + tk
206
+ + `<div class="gc-file">${ib({ act: 'file-held', row: H.at, icon: I.checks, label: 'It is right: file it as a reading', title: 'File it' })}</div></div>`;
207
+ }
208
+ /** The key result's panel body above its chart: the failed or held box, How it is counted with its counts, From … (said once), Last read with its
209
+ * checks, and the query. o: { ticket: the held reading's drafted ticket row }. '' when the goal has none of these fields. */
210
+ export function krHtml(g, o = {}) {
211
+ const c = countsOf(g), L = g.lastRead || null, failed = !!g.failed;
212
+ const frac = fractionHtml(c, L || {}, failed);
213
+ const box = c && (c.what || frac) ? `<div class="gc-box"><span class="gc-k">How it is counted</span>${frac || `<p class="gc-what">${esc(c.what)}</p>`}${frac && c.what ? `<p class="note">${esc(c.what)}</p>` : ''}</div>` : '';
214
+ const checks = (g.checks || []).filter((x) => x && x.text);
215
+ // a goal read by hand says when in its head line already; the last read is said here only for a goal Claude reads
216
+ const last = L && g.recipe && !failed && !(g.held || []).length ? `<div class="gc-sec"><p class="gc-line"><b>Last read</b> ${esc(atTxt(L.at))}</p>${checks.length ? `<ul class="gc-checks">${checks.map(checkRow).join('')}</ul>` : ''}</div>` : '';
217
+ const out = failedHtml(g) + heldHtml(g, o.ticket) + box + fromLine(g) + last + (failed ? '' : queryHtml(g.recipe, true));
218
+ return out ? `<div class="gc-kr">${out}</div>` : '';
219
+ }
220
+ /** The big number of a goal whose last reading was not good: the last good one, and from when (GcR4Failed, GcR5Held). */
221
+ export function lastGoodSay(g) {
222
+ if (!(g.failed || (g.held || []).length)) return '';
223
+ const L = g.lastRead; return L && L.at ? (g.failed ? 'from ' + dayTxt(L.at) + ', the last good reading' : 'the last good reading, ' + dayTxt(L.at)) : '';
224
+ }
225
+
226
+ /* ── the ✦ line ────────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
227
+ /** The news a reading brings, before the ordinary line: a held reading, then a failed read, then the first readings. null when none applies. */
228
+ export function lineOf(goals, product) {
229
+ const G = (goals || []).filter(Boolean);
230
+ const held = G.filter((g) => (g.held || []).length);
231
+ if (held.length) {
232
+ const g = held[0], H = g.held[0], role = g.role === 'north-star' ? 'the North Star' : g.title;
233
+ return { head: 'I held back one reading of ' + role + '.', sub: (H.short || (H.why ? String(H.why).split('. ')[0] : 'It did not pass my checks')).replace(/\.?$/, '.') + ' Check it in the side panel.', tone: 'behind', goal: g.id };
234
+ }
235
+ const failed = G.filter((g) => g.failed);
236
+ if (failed.length) {
237
+ const g = failed[0], F = g.failed, src = (F.fix && F.fix.connector) || (g.recipe && g.recipe.connector) || 'The source';
238
+ const d = when(F.at);
239
+ return { head: 'I couldn’t read ' + g.title + (d ? ' on ' + WD[d.getDay()] : '') + '.', sub: String(F.short || F.why || src + ' did not answer').replace(/\.?$/, '.') + ' Reconnect it and I read it straight away.', tone: 'behind', goal: g.id };
240
+ }
241
+ const read = G.filter((g) => (g.series || []).length);
242
+ if (read.length && read.every((g) => g.series.length === 1)) {
243
+ const hourly = read.filter((g) => { const r = g.recipe; return r && r.cadence === 'hourly'; });
244
+ const next = read.map((g) => g.nextRead).filter(Boolean).sort().pop();
245
+ return { head: 'The first readings are in' + (read.length === G.length ? ', all ' + G.length + ' goals.' : ', ' + read.length + ' of ' + G.length + ' goals.'),
246
+ sub: 'One reading is a starting point, not a trend.' + (hourly.length ? ' ' + hourly[0].title + ' reads every hour, so its line starts today' + (next ? '; the others from ' + dayTxt(next) : '') + '.' : next ? ' The lines start with the 2nd reading, ' + dayTxt(next) + '.' : ''), tone: 'calm' };
247
+ }
248
+ return null;
249
+ }
250
+ /** A drafted-metrics ✦ line (GcJ1aTable): "I drafted a North Star, 3 inputs and 2 guardrails for pmos-idpf." */
251
+ export function draftsLine(rows, product) {
252
+ const R = (rows || []).filter((r) => r && r.kind === 'metric' && r.state === 'open'); if (!R.length) return null;
253
+ const n = (g) => R.filter((r) => r.group === g).length;
254
+ const parts = [n('North Star') ? 'a North Star' : '', n('Inputs') ? n('Inputs') + (n('Inputs') === 1 ? ' input' : ' inputs') : '', n('Guardrails') ? n('Guardrails') + (n('Guardrails') === 1 ? ' guardrail' : ' guardrails') : '', n('Key results') ? n('Key results') + (n('Key results') === 1 ? ' key result' : ' key results') : ''].filter(Boolean);
255
+ const list = parts.length > 1 ? parts.slice(0, -1).join(', ') + ' and ' + parts[parts.length - 1] : parts[0] || R.length + ' metrics';
256
+ return { head: 'I drafted ' + list + (product ? ' for ' + product : '') + '.', sub: 'Keep them and I read each one on its own rhythm, first reading within the hour. Tap a row to check it.', tone: 'drafts', keepAll: R.length > 1 ? R.length : 0 };
257
+ }
258
+ export { dotHtml };
@@ -304,8 +304,10 @@ function homeListHtml() {
304
304
  const R = L.reviewModel(S.D, NOW());
305
305
  // a group is open until the PM folds it; another product starts folded; "Not in an initiative" starts folded on a phone (HvAC, HvACDesk)
306
306
  const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.kind === 'loose' ? !isPhone() : g.kind === 'program' || g.primary || M.products.length === 1);
307
+ const sel = S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null);
308
+ S.lo = { sel, ses: S.ses, restOpen: (k) => S.rest.has(k), pin: S.pin, phone: false }; // the folded rail's card draws Home's rows with these
307
309
  return TD.listHtml(M, todayModel(), {
308
- sel: S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null), selHead: S.head, ses: S.ses, pOpen, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
310
+ sel, selHead: S.head, ses: S.ses, pOpen, here: isPhone() ? null : TD.groupOfOpen(M, sel) || S.head, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
309
311
  pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, news: S.news && S.news.ok ? S.news.count : 0, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) + (S.impact ? IMP.rowHtml(S.impact.c, { esc, sel: S.sel === 'impact' }) : '') : '',
310
312
  imFace: IM.faceHtml(S.im, { joy: S.imJoy }),
311
313
  });
@@ -317,7 +319,7 @@ function homeListHtml() {
317
319
  * marks all seen. An item leaves once it is opened or marked seen. */
318
320
  function dayHtml() { return ''; }
319
321
  function dayParts() {
320
- const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW(), { delightOk: !!S.joyOk, news: S.news, sources: S.src && S.src.sources, ask: MEN.dayAskOf(S.D) });
322
+ const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW(), { delightOk: !!S.joyOk, news: S.news, sources: S.src && S.src.sources, ask: MEN.dayAskOf(S.D), dress: AD.dress() });
321
323
  return { Y, P: YD.dayParts(Y, { moment: !!(isPhone() && PHC), now: NOW(), first: !!S.first }) };
322
324
  }
323
325
  function drawDayBody(body, P) {
@@ -360,6 +362,8 @@ function day(on) {
360
362
  // ← back from a row's Viewer draws the day as it is now (a draft the PM is done with has left Drafted for you, batch 18 item 2)
361
363
  if (body.dataset.ydDrawn) { const f = dayParts(); S.Y = f.Y; drawDayBody(body, f.P); } else { body.dataset.ydDrawn = '1'; drawDayBody(body, P); }
362
364
  if (isPhone()) mountPull(body, { read: rereadDay, label: 'Reading your day again' });
365
+ // dressed for the season (batch 18 item 8-B, AsSet2Tap): a press on the dressed scene says why; no toast says he dressed up
366
+ AD.mountDressTip(body, { post: pmPost, say: toast, openSettings: (sec) => import('./cozy-settings.js').then((M) => M.openSettings(sec)) });
363
367
  body.onclick = (e) => { // the rows are the list's own rows: the same presses open them
364
368
  const b = e.target.closest('button'); if (!b) return;
365
369
  if (b.dataset.hmSel) { if (b.dataset.hmSel === 'n:update' && !rowById('n:update')) openUpdateViewer(); else select(b.dataset.hmSel); return; }
@@ -416,6 +420,7 @@ function newsIn(r) {
416
420
  if (r.count !== was) { drawList(); redrawDay(); }
417
421
  }
418
422
  document.addEventListener('cz:news-for-you', (e) => { if (e.detail && e.detail.ok) newsIn(e.detail); });
423
+ document.addEventListener('adler:dressed', () => { if (S.day) redrawDay(); }); // he dresses (or undresses: "Not this one") while Your day is open
419
424
  /** ✓✓ in the New for you fold: every item is marked seen (POST /api/news-for-you/seen), so the fold goes. */
420
425
  async function daySeen(b) {
421
426
  const ids = YD.newsOf(S.news).map((x) => x.id); if (!ids.length || b.disabled) return;
@@ -464,7 +469,10 @@ function iniViewOf(id) {
464
469
  const need = H.needsOf(S.D).find((r) => r.ini === id);
465
470
  const p = programOf(S.D.programs || [], row.ws || (B.board || {}).ws || '', id);
466
471
  return iniView(rowFor({ ...row, trail: t || row.trail || null }), { steps: B.steps || STEPS, today: B.today, usual: WFM.usualOf(S.D.trail, row),
467
- ask: need ? { title: need.name } : null, program: p ? { id: p.id, title: p.title } : null });
472
+ ask: need ? { title: need.name, n: H.needsOf(S.D).filter((r) => r.ini === id).length } : null, program: p ? { id: p.id, title: p.title } : null,
473
+ // the card (batch 18 item 1): Claude's line while a session works on it, the stakeholders
474
+ claude: (() => { const w = S.D.sessions.find((s) => H.iniOfSession(s) === id && s.shown === 'working'); return w ? 'I’m working on “' + H.nameOf(w) + '”. I’ll say here when it is ready.' : ''; })(),
475
+ people: (((S.D.desk && S.D.desk.stakeholders) || {})[id] || []) });
468
476
  }
469
477
  /** An initiative no board Home reads holds (its own read only, GET /api/initiative-premium): the row the one view needs, from that read. */
470
478
  function imRowOf(id) {
@@ -582,8 +590,41 @@ function drawList() {
582
590
  if (PHC && PHC.el.parentNode === sc) PHC.el.remove();
583
591
  document.body.classList.toggle('hm-folded', S.folded && !isPhone());
584
592
  document.body.classList.toggle('hm-plist', isPhone() && !S.phoneChat); // a phone: the list is the page until a row opens its conversation (HmPhone)
593
+ drawRailCard();
585
594
  drawRecTop();
586
595
  }
596
+ /* ── the folded rail's card (batch 18 item 14, FlA1–FlA5) ──
597
+ * With the Viewer wide, Home's list folds to a rail of group tiles (cozy-viewer.js). A tile's press opens a card beside it with that group's
598
+ * rows, Home's own (iniHtml): a row opens as on Home and the card closes, the rail and the Viewer's width stay; the pill lists the sessions
599
+ * in place. A second press on the tile, ×, Escape or a press outside closes it. The card sits in the rail, inside #hmList, so the list's
600
+ * own presses work in it. S.rc: the group whose card is open. */
601
+ function drawRailCard() {
602
+ const bar = $('#hmList > .cz-vw-railbar');
603
+ if (!bar || isPhone() || !VW.railOn() || !S.M || !S.M.groups.some((g) => g.key === S.rc)) S.rc = null;
604
+ let card = bar && bar.querySelector(':scope > .hv-rc');
605
+ if (!S.rc) { if (card) card.remove(); VW.railSync(null); return; }
606
+ if (!card) { card = document.createElement('div'); card.className = 'hv-rc'; card.setAttribute('role', 'dialog'); card.setAttribute('data-esc-layer', ''); bar.append(card); }
607
+ const g = S.M.groups.find((x) => x.key === S.rc);
608
+ card.setAttribute('aria-label', g.name);
609
+ const html = TD.railCardHtml(S.M, S.rc, S.lo);
610
+ if (card.__h !== html) { card.__h = html; card.innerHTML = html; }
611
+ VW.railSync(S.rc);
612
+ // beside the tile, its top with the tile's, kept inside the window
613
+ const t = bar.querySelector(`[data-cz-vw-rail="${CSS.escape(S.rc)}"]`);
614
+ if (!t) return;
615
+ const r = t.getBoundingClientRect();
616
+ card.style.left = Math.round(r.right + 12) + 'px';
617
+ card.style.top = Math.round(Math.max(12, Math.min(r.top - 10, innerHeight - card.offsetHeight - 12))) + 'px';
618
+ }
619
+ function railCard(key, o = {}) {
620
+ const was = S.rc;
621
+ S.rc = key || null; S.ses = null;
622
+ drawList();
623
+ if (S.rc) { const f = $('#hmList .hv-rc .hv-rcb .hm-rm, #hmList .hv-rc .hv-rcb .hv-fold'); if (f && o.focus !== false) f.focus({ preventScroll: true }); return; }
624
+ const t = was && o.back && $(`#hmList [data-cz-vw-rail="${CSS.escape(was)}"]`); if (t) t.focus();
625
+ }
626
+ VW.railCard((key) => railCard(S.rc === key ? null : key, { back: true }));
627
+ document.addEventListener('cz:vw-rail', (e) => { if (!e.detail.on && S.rc) S.rc = null; });
587
628
  /* A phone chat has no floating menu, so while a meeting records its pill sits in the top bar (XcbOptions B, case 7): a red dot and the
588
629
  * clock (home-rec-row.js ticks every [data-hr-clock]); a press opens the live meeting in place. No recording: no pill. */
589
630
  function drawRecTop() {
@@ -1677,11 +1718,14 @@ $('#hmDesk').onclick = (e) => { if (S.sheet && e.target === $('#hmDesk')) sheet(
1677
1718
  $('#hmList').onclick = (e) => { // delegated: every press on the list is a <button>
1678
1719
  const b = e.target.closest('button'); if (!b) return;
1679
1720
  const d = b.dataset;
1721
+ if ('hmRcx' in d) { railCard(null, { back: true }); return; } // × on the folded rail's card
1722
+ // a pick in the rail's card: the card closes, the rail stays folded and the Viewer as wide (FlA4After)
1723
+ if (S.rc && b.closest('.hv-rc') && (d.hmSel || d.hmProg || d.hmProdopen || d.hmSesnew)) { S.rc = null; S.ses = null; VW.keepWide(); }
1680
1724
  if (d.hmSes) { sesPill(d.hmSes === S.ses ? null : d.hmSes); return; } // an initiative's pill: what sits in it, under it (a sheet on a phone)
1681
1725
  if ('hmSesx' in d) { sesPill(null); return; }
1682
1726
  if (d.hmSesnew) { sesPill(null, false); newIn(d.hmSesnew); return; }
1683
1727
  if (d.hmCompact) { compact(d.hmCompact); return; } // ✓ on Claude's ✦ Compact (batch 13 item 8): the pill's list stays open
1684
- if (S.ses && !b.closest('.hv-spp, .hv-sps')) sesPill(null, false); // a press anywhere else in the list closes it
1728
+ if (S.ses && !b.closest('.hv-spp, .hv-sps, .hv-rcs')) sesPill(null, false); // a press anywhere else in the list closes it
1685
1729
  if (d.hmSel) { if (S.ses) sesPill(null, false); if (S.day) S.day = false; select(d.hmSel); return; }
1686
1730
  if ('hrImpact' in d) { if (S.day) S.day = false; S.sel = 'impact'; if (isPhone()) S.phoneChat = true; openTarget(homeTarget()); drawList(); return; } // Your impact: Home's own chat, on the weekly check
1687
1731
  if ('hrMentions' in d) { if (S.day) S.day = false; S.sel = 'mentions'; drawList(); MEN.openMentions(menCtx()); return; }
@@ -1731,13 +1775,23 @@ function sesPill(id, back = true) {
1731
1775
  const was = S.ses;
1732
1776
  S.ses = id || null;
1733
1777
  drawList();
1734
- const f = id ? $('#hmList .hv-spp .hm-rm, #hmList .hv-sps .hm-rm') : back && was ? $(`#hmList [data-hm-ses="${CSS.escape(was)}"]`) : null;
1778
+ const f = id ? $('#hmList .hv-spp .hm-rm, #hmList .hv-sps .hm-rm, #hmList .hv-rcs .hm-rm') : back && was ? $(`#hmList [data-hm-ses="${CSS.escape(was)}"]`) : null;
1735
1779
  if (f) f.focus();
1736
1780
  }
1737
1781
  // Escape closes it wherever the focus is (a redraw of the list can drop the focus to the page); a press outside the list closes it too
1738
1782
  window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && S.ses && menuEl.hidden) { e.preventDefault(); e.stopPropagation(); sesPill(null); } }, true); // before the Viewer's own Escape
1739
1783
  // a press outside the list (the chat, the Viewer) closes an open pill list too
1740
1784
  document.addEventListener('pointerdown', (e) => { if (S.ses && !e.target.closest('#hmList')) sesPill(null, false); });
1785
+ // the rail's card: Escape closes it (after an open pill list) and gives the focus back to its tile; a press outside it closes it
1786
+ window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && S.rc && !e.defaultPrevented && menuEl.hidden) { e.preventDefault(); e.stopPropagation(); railCard(null, { back: true }); } }, true);
1787
+ document.addEventListener('pointerdown', (e) => { if (S.rc && !e.target.closest('.hv-rc, .cz-vw-railtile')) railCard(null); });
1788
+ // arrows move between the card's rows
1789
+ $('#hmList').addEventListener('keydown', (e) => {
1790
+ if ((e.key !== 'ArrowDown' && e.key !== 'ArrowUp') || !e.target.closest('.hv-rc')) return;
1791
+ const all = [...document.querySelectorAll('#hmList .hv-rc .hv-rcb .hm-rm, #hmList .hv-rc .hv-rcb .hv-fold, #hmList .hv-rc .hv-rcb [data-hm-sesnew]')];
1792
+ const i = all.indexOf(e.target.closest('button')); if (!all.length) return;
1793
+ e.preventDefault(); all[Math.max(0, Math.min(all.length - 1, i < 0 ? 0 : i + (e.key === 'ArrowDown' ? 1 : -1)))].focus();
1794
+ });
1741
1795
  $('#hmList').addEventListener('submit', async (e) => { // the capture box: Enter adds the task
1742
1796
  if (e.target.id !== 'hmCapF') return;
1743
1797
  e.preventDefault();
@@ -54,7 +54,7 @@ export function avHtml(role, size = 28, cls = '') {
54
54
  /** Adler is Claude's avatar once, on the latest reply, in that reply's mood (batch 16 item 2, canvas AdU1): needs you while it asks,
55
55
  * honest when the run stopped, thinking while it runs, handled otherwise. Another role keeps its letter. */
56
56
  const isClaude = (r) => !r || !r.key || r.key === 'claude';
57
- export const adlerAvHtml = (mood) => `<span class="hm-av hm-adler" aria-hidden="true">${adler(mood, 36, { label: false, id: 'chat' })}</span>`;
57
+ export const adlerAvHtml = (mood) => `<span class="hm-av hm-adler" aria-hidden="true">${adler(mood, 36, { label: false, id: 'chat', dress: true })}</span>`;
58
58
 
59
59
  export function mountChat(el, host) {
60
60
  const esc = host.esc;
@@ -30,7 +30,7 @@
30
30
  * never happier than the data. When Claude's own miss or a stuck call already leads the card, the failed source is one card under it. */
31
31
 
32
32
  import { todayOf, hm } from './home-data.js';
33
- import { adler, adlerScene, asleep, firstOpenToday } from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2): AdB1-3, AdP1, AdP4
33
+ import { adler, adlerScene, asleep, firstOpenToday, dress, dressDay } from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2): AdB1-3, AdP1, AdP4; dressed for the season (batch 18 item 8-B)
34
34
  import { initials, ago } from './cozy-evmodel.js';
35
35
 
36
36
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -124,7 +124,9 @@ export function dayModel(M, D, R, now = Date.now(), o = {}) {
124
124
  const thanks = thanksOf(D, now);
125
125
 
126
126
  const h = new Date(now).getHours(), name = D.today && D.today.me ? String(D.today.me) : '';
127
- const hi = (h < 12 ? 'Morning' : h < 17 ? 'Afternoon' : 'Evening') + (name ? ', ' + name : '') + '.';
127
+ // on a festival's own day the greeting wishes it once (AsPlaces); a day with bad news says the news instead (the concerned line replaces it)
128
+ const wish = o.dress && dressDay(o.dress, now) ? 'Happy ' + o.dress.name : '';
129
+ const hi = (wish || (h < 12 ? 'Morning' : h < 17 ? 'Afternoon' : 'Evening')) + (name ? ', ' + name : '') + '.';
128
130
  const gaps = gapsOf(t, now);
129
131
  let mood = 'calm', line = hi, sub = meetText, offer = null;
130
132
  if (misses.length || blocked.length) {
@@ -175,7 +177,8 @@ export function openHtml(Y, o = {}) {
175
177
  // AdP5: a failed source that leads the card draws the small rain cloud in place of the morning scene (Face only: the honest face)
176
178
  const rain = Y.fail && Y.failLead ? adlerScene('rain', 'honest', { label: 'Adler, honest, under a small rain cloud', h: 170 }) : '';
177
179
  if (rain) o = { ...o, scene: true };
178
- const head = rain ? `<div class="yd-scene">${rain}</div>` : o.scene ? `<div class="yd-scene">${adlerScene('morning', 'handled', { label: false })}</div>` : o.big ? '' : faceHtml(Y.face || Y.mood);
180
+ // a dressed day's scene is wider (460 x 170), so the card's 150 px shows its garland or lights, not only the ground (AsPlaces)
181
+ const head = rain ? `<div class="yd-scene">${rain}</div>` : o.scene ? `<div class="yd-scene"${dress() ? ' data-ad-dress role="button" tabindex="0" aria-label="Why Adler is dressed"' : ''}>${adlerScene('morning', 'handled', { label: false, dress: true, ...(dress() ? { w: 460, h: 170 } : {}) })}</div>` : o.big ? '' : faceHtml(Y.face || Y.mood);
179
182
  const chips = Y.chips.length ? `<div class="yd-chips">${Y.chips.map((c) => `<span class="yd-chip">${svg(CHECK, 14, 2.6)}${esc(c)}</span>`).join('')}</div>` : '';
180
183
  const miss = Y.misses.map((m) => `<div class="yd-miss" data-id="${esc(m.id)}"><div class="yd-mt"><b>My miss: ${esc(m.title)}</b>${m.why ? `<em>${esc(m.why)}</em>` : ''}</div>${ok('retry', 'Run it again', m.id)}</div>`).join('');
181
184
  // the failed source under Claude's own miss: one card, no second Adler; its icon reads the source again (Settings › Connectors' ↻)
@@ -213,7 +216,7 @@ const bigHtml = (kind) => (kind === 'win'
213
216
  /** After 22:00 (Settings > Adler > Quiet after), unless something is wrong: Adler asleep, and the day one press away (AdP4). */
214
217
  export function nightHtml(Y) {
215
218
  const sub = Y.calls.length ? (Y.calls.length === 1 ? 'One call waits for you in the morning.' : Y.calls.length + ' calls wait for you in the morning.') : 'Nothing needs you tonight.';
216
- return `<div class="yd-night">${adlerScene('night', 'resting')}<b>It’ll keep till morning.</b><em>${esc(sub)}</em><button type="button" class="yd-awake" data-yd="awake">Open anyway</button></div>`;
219
+ return `<div class="yd-night">${adlerScene('night', 'resting', { dress: true })}<b>It’ll keep till morning.</b><em>${esc(sub)}</em><button type="button" class="yd-awake" data-yd="awake">Open anyway</button></div>`;
217
220
  }
218
221
 
219
222
  /* one New for you item (FmA2Day): the blue dot, who, the words and where it came from; a press opens it in the Viewer (cozy-news.js) */
@@ -54,7 +54,7 @@ function dashFor(id) {
54
54
  if (!id || id === 'product' || !X.ctx) return null;
55
55
  if (!DASH.has(id)) {
56
56
  const wsOf = () => { const M = curM(); return (M && M.board.ws) || (rowOf(id) || {}).ws || ''; };
57
- DASH.set(id, DB.dashHost({ page: 'initiative:' + id, scope: 'initiative:' + id, ws: wsOf, board: () => { const M = curM(); return (M && M.board.id) || (rowOf(id) || {}).boardId || ''; },
57
+ DASH.set(id, DB.dashHost({ page: 'initiative:' + id, menu: true, scope: 'initiative:' + id, ws: wsOf, board: () => { const M = curM(); return (M && M.board.id) || (rowOf(id) || {}).boardId || ''; },
58
58
  vid: 'ov:' + id, VW: X.ctx.VW, redraw: () => { if (BODY) BODY.__pg = null; redrawView(); }, toast: (t) => X.ctx.toast(t),
59
59
  openReport: async (row) => { if (!row.path) return; X.ctx.VW.drill(); (await import('./premium-report-read.js')).openReportView(row.path, { ws: wsOf(), name: row.name, cuts: true }); } }));
60
60
  }
@@ -440,7 +440,7 @@ export function iniPage() {
440
440
  let rename = X.ctx.renameIni ? X.ctx.renameIni(id, '') : null;
441
441
  if (rename) rename = { ...rename, value: X.ctx.iniTitle(id) };
442
442
  const dh = dashFor(id);
443
- BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', more: () => pageMore(id), rename,
443
+ BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', wrap: true, more: () => pageMore(id), rename,
444
444
  discuss: () => X.ctx.newIn(id), discussHome: true, // the one view (OvViewers): Discuss starts a new session about it, where + New session was
445
445
  presses: dh ? dh.presses() : null, onPress: (a) => { if (a === 'dash' && dh) dh.toggle(); },
446
446
  render: (b) => { X.view = 'page'; BODY = b; ADDING = null; draw(b); wire(b, id); wirePage(b, id); if (dh) dh.wire(b); } });
@@ -37,7 +37,7 @@ const P = {
37
37
  all: 'M2 12.5l4.5 4.5L15 8M9 15l2 2L22 7', spark: VW.ICONS.spark,
38
38
  };
39
39
  const BADGE = { slack: 'M9 4l-2 16M17 4l-2 16M4 9h16M3 15h16', mail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7', gmail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7',
40
- jira: 'M12 3l9 9-9 9-9-9z', confluence: 'M7 3h7l4 4v14H7zM14 3v4h4', doc: 'M7 3h7l4 4v14H7zM14 3v4h4' };
40
+ jira: 'M4 7h16v3a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4z', confluence: 'M7 3h7l4 4v14H7zM14 3v4h4', doc: 'M7 3h7l4 4v14H7zM14 3v4h4' };
41
41
  const svg = (d, w = 16, sw = 2) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
42
42
  const srcName = (s) => SRC[s] || (s ? String(s).charAt(0).toUpperCase() + String(s).slice(1) : 'its source');
43
43
  const sendIn = (s) => (s === 'mail' ? 'your email' : srcName(s));