create-pmos 0.613.0 → 0.615.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 (38) hide show
  1. package/package.json +27 -39
  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/changelog.json +26 -0
  7. package/workspace/guide/cli.md +2 -1
  8. package/workspace/guide/layout.md +24 -10
  9. package/workspace/guide/settings-and-switches.md +1 -0
  10. package/workspace/lib/events-place.js +46 -10
  11. package/workspace/lib/mention-cli.js +6 -3
  12. package/workspace/lib/mention-store.js +49 -10
  13. package/workspace/lib/routes-events-place.js +2 -1
  14. package/workspace/package-lock.json +2 -2
  15. package/workspace/package.json +1 -1
  16. package/workspace/public/pm/cozy-events-view.js +23 -4
  17. package/workspace/public/pm/cozy-events.js +8 -2
  18. package/workspace/public/pm/cozy-home-rows.css +55 -0
  19. package/workspace/public/pm/cozy-nav.js +15 -2
  20. package/workspace/public/pm/cozy-pop-work.css +3 -0
  21. package/workspace/public/pm/cozy-pop-work.js +5 -3
  22. package/workspace/public/pm/cozy-today-app.js +119 -12
  23. package/workspace/public/pm/cozy-today-model.js +278 -21
  24. package/workspace/public/pm/cozy-today-page.css +74 -15
  25. package/workspace/public/pm/cozy-today-view.js +89 -31
  26. package/workspace/public/pm/home-app.js +14 -6
  27. package/workspace/public/pm/home-data.js +1 -1
  28. package/workspace/public/pm/home-ini.js +17 -1
  29. package/workspace/public/pm/home-mentions.js +121 -6
  30. package/workspace/public/pm/ini-edit.js +2 -0
  31. package/workspace/public/pm/ini-view.css +2 -0
  32. package/workspace/public/pm/mention-one-model.js +115 -0
  33. package/workspace/public/pm/pop-work-model.js +17 -11
  34. package/workspace/public/pm/scope-chip.js +5 -2
  35. package/workspace/run-tests.js +11 -4
  36. package/workspace/server.js +8 -0
  37. package/workspace/skills/morning-brief.skill +1 -1
  38. package/workspace/test-run.js +2 -0
@@ -16,6 +16,8 @@
16
16
  * KINDS · KIND_LABEL · LATE_SHOWN · shiftMonth(ym, n) · weekOf(day)
17
17
  * Text from records goes through esc(). Every icon-only button has an aria-label. The words say PMOS. */
18
18
 
19
+ import { productName } from './scope-chip.js'; // the one product-name function (audit round 2: names, not ids)
20
+
19
21
  export const TYPES = ['meeting', 'focus', 'milestone', 'task', 'report', 'deadline'];
20
22
  export const KINDS = TYPES; // the filter is by type since round 2
21
23
  export const LATE_SHOWN = 5;
@@ -24,8 +26,16 @@ export const TYPE_WORD = { meeting: 'Meeting', focus: 'Focus time', milestone: '
24
26
  export const TYPE_LABEL = { meeting: 'Meetings', focus: 'Focus time', milestone: 'Milestones', task: 'Tasks', report: 'Reports', deadline: 'Deadlines' };
25
27
  export const KIND_LABEL = TYPE_LABEL;
26
28
  const typeOf = (x) => x.type || x.kind;
29
+ /** The model's line with the product by its display name ("Planned finish · IDPF", not "· pmos-idpf"). */
30
+ export const lineText = (x) => {
31
+ const l = String(x.line || '');
32
+ if (!l || !x.product) return l;
33
+ const ws = (x.work && x.work.ws) || ((x.scope || []).find((t) => /^p:/.test(t)) || '').slice(2);
34
+ const n = ws ? productName(ws, x.product) : x.product;
35
+ return n === x.product ? l : l.split(x.product).join(n);
36
+ };
27
37
  /** The grey line: the type word first, then what the model says. */
28
- export const lineOf = (x) => TYPE_WORD[typeOf(x)] + (x.line ? ' · ' + x.line : '');
38
+ export const lineOf = (x) => TYPE_WORD[typeOf(x)] + (x.line ? ' · ' + lineText(x) : '');
29
39
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
30
40
  const MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
31
41
  const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -79,7 +89,10 @@ export function rowHtml(x, o = {}) {
79
89
  // a meeting under an opened busy day: only its time, the day row above names the day
80
90
  const d = o.child ? { b: x.time || 'All day', s: x.until ? 'to ' + x.until : '' } : dayCell(x, today);
81
91
  const kindWord = TYPE_WORD[typeOf(x)];
82
- const what = `<b>${esc(x.title)}</b><small><em class="evp-ty">${esc(kindWord)}</em>${x.line ? ' · ' + esc(x.line) : ''}</small>`;
92
+ // a row whose name is its type ("Focus time") does not say the type again
93
+ const same = String(x.title || '').trim().toLowerCase() === String(kindWord || '').toLowerCase();
94
+ const small = same ? (x.line ? `<small>${esc(lineText(x))}</small>` : '') : `<small><em class="evp-ty">${esc(kindWord)}</em>${x.line ? ' · ' + esc(lineText(x)) : ''}</small>`;
95
+ const what = `<b>${esc(x.title)}</b>${small}`;
83
96
  const srcOpen = x.source && o.open && o.open.has('src:' + x.key);
84
97
  const t = x.source ? `<button type="button" class="evp-t" data-evp-src aria-expanded="${srcOpen ? 'true' : 'false'}" aria-label="${esc(x.title)}. ${esc(lineOf(x))}. Show what was said">${what}</button>`
85
98
  : x.work || x.task || x.own || x.link ? `<button type="button" class="evp-t" data-evp-open aria-label="${esc(x.title)}. ${esc(lineOf(x))}. Open it">${what}</button>` : `<span class="evp-t">${what}</span>`;
@@ -153,13 +166,19 @@ export function hiddenHtml(items, o = {}) {
153
166
  }
154
167
  const fold = (key, open, text) => `<button type="button" class="evp-fold" data-evp-fold="${key}" aria-expanded="${open ? 'true' : 'false'}"><i aria-hidden="true">${svg(ICON.go, 14)}</i><span>${text}</span></button>`;
155
168
 
169
+ /** The late rows in view: the newest LATE_SHOWN while the rest are folded, else all. Yes to all takes these. */
170
+ export function lateInView(model, o = {}) {
171
+ const late = groupsOf(model.items, o).late;
172
+ return !o.day && late.length > LATE_SHOWN + 1 && !(o.open && o.open.has('late')) ? late.slice(0, LATE_SHOWN) : late;
173
+ }
156
174
  /** The left side. model: { today, items, later }; o: { show, day, busy } */
157
175
  export function listHtml(model, o = {}) {
158
176
  const today = model.today;
159
177
  const G = groupsOf(model.items, o);
160
- const yes = G.late.filter((x) => x.suggest).length;
161
- const all = yes > 1 ? `<button type="button" class="evp-all" data-evp-all>Yes to all ${yes}</button>` : '';
162
178
  const open = o.open || new Set();
179
+ // Yes to all says yes only to what is in view: "Yes to these 5" while the older late rows are folded (as the Backlog does)
180
+ const seen = lateInView(model, o), yes = seen.filter((x) => x.suggest).length, folded = seen.length < G.late.length;
181
+ const all = yes > 1 ? `<button type="button" class="evp-all" data-evp-all>${folded ? 'Yes to these' : 'Yes to all'} ${yes}</button>` : '';
163
182
  const ro = { today, busy: o.busy, open };
164
183
  let later = '';
165
184
  const on = new Set(o.show || TYPES);
@@ -19,7 +19,7 @@
19
19
  import { mountNav } from './cozy-nav.js';
20
20
  import * as POP from './cozy-popup.js';
21
21
  import { pmGet, pmPost } from './http.js';
22
- import { TYPES, listHtml, calHtml, monthHtml, showHtml, hiddenHtml, countsOf, shiftMonth, esc } from './cozy-events-view.js';
22
+ import { TYPES, listHtml, calHtml, monthHtml, showHtml, hiddenHtml, countsOf, shiftMonth, esc, lateInView } from './cozy-events-view.js';
23
23
  import { readPick } from './cozy-pick.js';
24
24
  import { scopeChipHtml, openScope, matches, narrowed, scopeWords, whenNames } from './scope-chip.js';
25
25
 
@@ -123,6 +123,11 @@ async function apply(x, s) {
123
123
  if (x.own) { const r = await pmPost('/api/pm-items/remove', { id: x.own }); return { ok: r && r.ok !== false, error: r && r.error, undo: () => pmPost('/api/pm-items/undo', { id: x.own }) }; }
124
124
  const r = await setState(x, "Won't do"); return { ok: r && r.ok !== false, error: r && r.error, undo: () => setState(x, was) };
125
125
  }
126
+ if (s.op === 'gone' && Array.isArray(s.keys)) { // the old report drafts: each one marked dropped; the files stay
127
+ const done = [];
128
+ for (const key of s.keys) { const r = await pmPost('/api/events-place/mark', { key, gone: 'dropped' }); if (r && r.ok !== false) done.push(key); else return { ok: false, error: (r && r.error) || 'Nothing was changed.', undo: null }; }
129
+ return { ok: true, undo: async () => { for (const key of done) await pmPost('/api/events-place/mark', { key, gone: false }); } };
130
+ }
126
131
  if (s.op === 'met' || s.op === 'gone') {
127
132
  const r = await pmPost('/api/events-place/mark', { key: x.key, gone: s.op === 'met' ? 'met' : 'dropped' });
128
133
  return { ok: r && r.ok !== false, error: r && r.error, undo: () => pmPost('/api/events-place/mark', { key: x.key, gone: false }) };
@@ -150,7 +155,8 @@ async function yes(x) {
150
155
  }
151
156
  async function yesAll() {
152
157
  const ok = scopeOk();
153
- const list = S.model.items.filter((x) => x.group === 'late' && x.suggest && S.show.includes(x.type || x.kind) && (!ok || ok(x)) && (!S.day || x.date === S.day));
158
+ // only the late rows in view (the list's own rule): while the older ones are folded, the button says "Yes to these N"
159
+ const list = lateInView(S.model, { show: S.show, scopeOk: ok || undefined, day: S.day, open: S.open }).filter((x) => x.suggest);
154
160
  if (!list.length) return;
155
161
  list.forEach((x) => S.busy.add(x.key)); draw();
156
162
  const undos = [];
@@ -124,3 +124,58 @@
124
124
  .mn-cht { flex: 1; min-width: 0; display: flex; flex-direction: column; }
125
125
  .mn-cht b { font-size: var(--fs-body); line-height: var(--lh-body); }
126
126
  .mn-cht small { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
127
+
128
+ /* ── one mention, as Today opens it (Today round 3): a centred column, nothing about other mentions ── */
129
+ .mn1 { max-width: 760px; margin: 0 auto; padding: 8px 4px 32px; display: flex; flex-direction: column; gap: 16px; color: var(--cz-ink); }
130
+ .mn1-h { display: flex; align-items: flex-start; gap: 12px; }
131
+ .mn1-ht { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
132
+ .mn1-who { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: var(--fs-row); line-height: var(--lh-row); }
133
+ .mn1-who b { font-weight: var(--fw-strong); }
134
+ .mn1-src { font-size: var(--fs-meta); color: var(--cz-ink2); background: var(--cz-well); border-radius: 999px; padding: 1px 9px; }
135
+ .mn1-sub { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--cz-ink2); }
136
+ .mn1-sub .late { color: var(--cz-risk); }
137
+ .mn1-kind { font-size: var(--fs-badge); font-weight: var(--fw-strong); color: var(--cz-blueink); background: var(--cz-bluebg); border-radius: 6px; padding: 0 7px; }
138
+ .mn1-ck { color: var(--cz-ink3); }
139
+ .mn1-ck.answered { color: var(--cz-ink2); }
140
+ .mn1-ck.unknown { color: var(--cz-risk); }
141
+ .mn1-all { flex: none; border: 0; background: none; padding: 4px 2px; font: inherit; font-size: var(--fs-meta); color: var(--cz-ink3); cursor: pointer; }
142
+ .mn1-all:hover, .mn1-all:focus-visible { color: var(--cz-blueink); text-decoration: underline; }
143
+ .mn1-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0; border: 1px solid var(--cz-hair); border-radius: 16px; overflow: hidden; }
144
+ .mn1-did, .mn1-left { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
145
+ .mn1-did { background: var(--cz-well); }
146
+ .mn1-did ul { margin: 0; padding-left: 18px; font-size: var(--fs-body); line-height: 1.5; color: var(--cz-ink2); }
147
+ .mn1-k { margin: 0; display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-label); font-weight: var(--fw-strong); line-height: var(--lh-label); color: var(--cz-ink2); }
148
+ .mn1-did .mn1-k { color: var(--cz-blueink); }
149
+ .mn1-lt { margin: 0; font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
150
+ .mn1-ask { display: flex; flex-direction: column; gap: 6px; }
151
+ .mn1-aq { margin: 0; font-size: var(--fs-panel); line-height: var(--lh-panel); overflow-wrap: anywhere; }
152
+ .mn1-go, .mn1-about { align-self: flex-start; border: 0; background: none; padding: 2px 0; font: inherit; font-size: var(--fs-meta); color: var(--cz-blueink); cursor: pointer; }
153
+ .mn1-go:hover, .mn1-about:hover { text-decoration: underline; }
154
+ .mn1-about { padding: 8px 12px; border: 1px solid var(--cz-hair); border-radius: 12px; color: var(--cz-ink); }
155
+ .mn1-reply { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; border-radius: 16px; background: var(--cz-bluebg); }
156
+ .mn1-reply.no { background: var(--cz-well); }
157
+ .mn1-reply > p { margin: 0; font-size: var(--fs-body); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
158
+ .mn1-reply .mn1-k { color: var(--cz-blueink); }
159
+ .mn1-blank { font: inherit; font-size: var(--fs-body); border: 0; border-bottom: 2px solid var(--cz-blue); background: var(--cz-card); border-radius: 6px 6px 0 0; padding: 0 6px; color: var(--cz-ink); }
160
+ .mn1-blank:focus { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
161
+ .mn1-ra, .mn1-acts { display: flex; justify-content: flex-end; gap: 8px; }
162
+ .mn1-acts { justify-content: flex-start; }
163
+ .mn1-proof, .mn1-looks { margin: 0; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; background: var(--cz-well); font-size: var(--fs-body); line-height: 1.5; }
164
+ .mn1-looks p { margin: 0; flex: 1; }
165
+ /* no draft: one ✦ line, one icon that opens an empty reply field (design check of round 3) */
166
+ .mn1-nod { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--cz-blueink); }
167
+ .mn1-nod p { margin: 0; flex: 1; font-size: var(--fs-body); line-height: 1.5; color: var(--cz-ink2); }
168
+ .mn1-free { font: inherit; font-size: var(--fs-body); line-height: 1.6; border: 1px solid var(--cz-hair); border-radius: 12px; padding: 10px 12px; background: var(--cz-card); color: var(--cz-ink); resize: vertical; }
169
+ .mn1-free:focus { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
170
+ .mn1-left { position: relative; }
171
+ .mn1-clr { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
172
+ .mn1-undo { margin-left: auto; border: 0; background: none; font: inherit; font-size: var(--fs-meta); color: var(--cz-blueink); cursor: pointer; }
173
+ .mn1-sec h3 { margin: 0 0 8px; font-size: var(--fs-section); font-weight: var(--fw-section); line-height: var(--lh-section); }
174
+ .mn1-thr, .mn1-thr ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
175
+ .mn1-m { padding: 8px 12px; border-radius: 12px; background: var(--cz-card); border: 1px solid var(--cz-hair); }
176
+ .mn1-m.me { background: var(--cz-bluebg); border-color: transparent; }
177
+ .mn1-m p { margin: 0; font-size: var(--fs-body); line-height: 1.5; overflow-wrap: anywhere; }
178
+ .mn1-m .mn1-mh { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-meta); color: var(--cz-ink3); }
179
+ .mn1-m .mn1-mh b { color: var(--cz-ink); font-weight: var(--fw-strong); }
180
+ .mn1-m .mn1-mh em { font-style: normal; color: var(--cz-ink2); background: var(--cz-well); border-radius: 6px; padding: 0 6px; }
181
+ .mn1-early summary { cursor: pointer; font-size: var(--fs-meta); color: var(--cz-ink3); padding: 2px 0 8px; }
@@ -17,7 +17,8 @@
17
17
  * Nothing here leads to the console, and nothing here writes.
18
18
  * ONE DOT (chief-of-staff C3 and the UI grill's delete list, 2026-11-08). The button carries one dot: amber while a source needs the PM,
19
19
  * else blue while a call in Your move is the PM's (the event 'cz:calls', detail { count }: Home sends it from Your move) or a place has
20
- * something new to show. The "N new for you" count is gone from the button and its name (New for you stays a fold of Your day), and so
20
+ * something new to show (on a desk the rail's Today number is Today's lines for today on every place: pm/cozy-today-app.js keeps it in
21
+ * localStorage 'pmos.today.count' with its day, and a page that sends no 'cz:calls' of its own shows it). The "N new for you" count is gone from the button and its name (New for you stays a fold of Your day), and so
21
22
  * are Adler's ears over the phone button (AdP6): Your move is the one place that says what is yours.
22
23
  * THE CHAT (C5, board CsB): the tray's chat icon opens the one chat over the page you are on (pm/page-chat.js openCos), with a soft
23
24
  * "You are on …" chip. A page that has its own chat column (Home) passes opts.chat() and the icon focuses that chat instead.
@@ -227,6 +228,7 @@ export function mountNav(here, doc = document, opts = {}) {
227
228
  N.fresh = freshRows(mo.places);
228
229
  doc.dispatchEvent(new CustomEvent('cz:moments', { detail: mo }));
229
230
  }
231
+ storedCalls();
230
232
  if (n && n.ok) { N.news = n.count || 0; doc.dispatchEvent(new CustomEvent('cz:news-for-you', { detail: n })); }
231
233
  if (s && s.ok) { N.stale = bannerOf(s.sources); doc.dispatchEvent(new CustomEvent('cz:sources', { detail: s })); } // Your day's failed source (AdP5)
232
234
  if (menu.hidden || !menu.contains(doc.activeElement)) draw();
@@ -235,7 +237,18 @@ export function mountNav(here, doc = document, opts = {}) {
235
237
  setInterval(read, 120000);
236
238
  doc.addEventListener('visibilitychange', () => { if (!doc.hidden) read(); });
237
239
  doc.addEventListener('cz:news', (e) => { if (e.detail && Number.isFinite(e.detail.count)) { N.news = e.detail.count; draw(); } else read(); });
238
- doc.addEventListener('cz:calls', (e) => { const n = e.detail && Number(e.detail.count); N.calls = Number.isFinite(n) && n > 0 ? n : 0; draw(); });
240
+ doc.addEventListener('cz:calls', (e) => { const n = e.detail && Number(e.detail.count); N.calls = Number.isFinite(n) && n > 0 ? n : 0; N.callsHere = true; draw(); });
241
+ // Today's number on every place (round 2 of Today): Today keeps its lines for today with the day (pm/cozy-today-app.js); a page that
242
+ // sends no number of its own shows that one while it is from today
243
+ const storedCalls = () => {
244
+ if (N.callsHere) return;
245
+ let v = null; try { v = JSON.parse(localStorage.getItem('pmos.today.count') || 'null'); } catch { v = null; }
246
+ const d = new Date(), today = d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
247
+ const n = v && v.day === today && Number(v.n) > 0 ? Number(v.n) : 0;
248
+ if (n !== N.calls) { N.calls = n; draw(); }
249
+ };
250
+ storedCalls();
251
+ addEventListener('storage', (e) => { if (e.key === 'pmos.today.count') storedCalls(); });
239
252
  doc.addEventListener('adler:prefs', () => draw());
240
253
  // the chat icon's number: the sessions that wait for you (cozy-live-pill.js counts them)
241
254
  doc.addEventListener('cz:live-n', (e) => { const a = e.detail && Number(e.detail.asks); const v = Number.isFinite(a) && a > 0 ? a : 0; if (v !== N.waiting) { N.waiting = v; draw(); } });
@@ -222,3 +222,6 @@ button.pw-fv .grey { color: var(--cz-ink3); }
222
222
  @media (hover: hover) { button.pw-fv:hover > span:first-child { text-decoration: underline; text-underline-offset: 2px; } }
223
223
  /* When did this happen? under the status list (round 3 point 18) */
224
224
  .hi-pop .pw-when { padding: 0 6px 4px; }
225
+ /* round 3 item 11b: the task a Today row opened, lit until another task is opened */
226
+ .pw-kr.lit { background: var(--cz-bluebg); box-shadow: inset 3px 0 0 var(--cz-blue); }
227
+ .pw-kr.lit .pw-tt { font-weight: var(--fw-strong); }
@@ -50,10 +50,12 @@ const cols = () => ({ status: true, date: true, tl: true, kind: true, when: true
50
50
  const ST = new Map(); // initiative id → { open, shut, doneOpen, farOpen, details, top }
51
51
  const LOOSE = 'pw-loose'; // the initiatives whose Not in a stage row the PM opened (round 3 point 21), remembered on this computer
52
52
  const stOf = (id) => {
53
- if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), doneOpen: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false });
53
+ if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), doneOpen: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false, focus: '' });
54
54
  return ST.get(id);
55
55
  };
56
56
  const looseKeep = (id, on) => { const L = (store.get(LOOSE, []) || []).filter((x) => x !== id); if (on) L.push(id); store.set(LOOSE, L.slice(-200)); };
57
+ /** The task a Today row opened (round 3 item 11b): its stage opens and its row is lit until another task is focused. '' clears it. */
58
+ export function focus(id, uid) { stOf(String(id)).focus = uid ? String(uid) : ''; }
57
59
  const ITEMS = new Map(); // initiative id → the Library's rows | null while reading | false when the route is not there
58
60
  const ib = (attr, label, d, cls = '') => `<button type="button" class="pw-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(d)}</button>`;
59
61
 
@@ -200,7 +202,7 @@ function rowHtml(x, W, C, sugRows) {
200
202
  if (x.kind === 'done') return `<div class="pw-tr pw-dr" role="row"><span class="pw-it"><button type="button" class="pw-dn" data-pw-done="${esc(x.key)}" aria-expanded="${x.open}">${esc(x.label)}${SVG(x.open ? P.down : P.right, 14)}</button></span>${C.status ? '<span></span>' : ''}${C.date ? '<span></span>' : ''}${tl}</div>`;
201
203
  const s = sugRows.get(x.uid);
202
204
  const title = x.jira ? `<span class="pw-tt">${esc(x.title)}</span>` : `<button type="button" class="pw-tt" data-pw-name="${esc(x.uid)}" aria-label="${esc('Rename ' + x.title)}">${esc(x.title)}</button>`;
203
- return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"><span class="pw-it"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov')}${ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
205
+ return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"><span class="pw-it"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov')}${ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
204
206
  + (s ? `<div class="pw-tr pw-sugrow" role="row"><span class="pw-it">${sugLine(s, true)}</span></div>` : '');
205
207
  }
206
208
  function breakdownHtml(W, C, mode, full, S) {
@@ -252,7 +254,7 @@ const keyOf = (v, o) => String((o && o.id) || (v && (v.id || v.key)) || '');
252
254
  function model(r, v, o) {
253
255
  const id = keyOf(v, o), S = stOf(id), it = ITEMS.get(id);
254
256
  const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
255
- const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, doneOpen: S.doneOpen, moreOpen: S.moreOpen, farOpen: S.farOpen, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
257
+ const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, doneOpen: S.doneOpen, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
256
258
  const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
257
259
  return { W, S, id };
258
260
  }
@@ -11,13 +11,15 @@
11
11
  * Viewer no longer floats over a chat on a laptop. A row's press opens its work in the one popup (cozy-popup.js) with Home's chat beside it.
12
12
  * The capture line adds a row and does nothing else: no popup, no session. Every write is a press: today-log marks and own entries
13
13
  * (POST /api/today-log/*), a task's state or due day (the Board's own routes), an item's done, defer, due or remove (POST /api/pm-items/*),
14
- * a Lab finding kept or dropped (POST /api/lab/*). Each says what it did in the toast, with Undo. Reads: GET /api/today-log. */
14
+ * a Lab finding kept or dropped (POST /api/lab/*). Each says what it did in the toast, with Undo. Reads: GET /api/today-log, and GET
15
+ * /api/events-place for the reports that go out today (placed at their time on the agenda). */
15
16
  import * as TM from './cozy-today-model.js';
16
17
  import * as TP from './cozy-today-view.js';
18
+ import * as OM from './mention-one-model.js'; // the one mention's title and the self check's proof line (Today round 3)
17
19
 
18
20
  const ASK_SEND = new Set(['session']);
19
21
  export function mountToday(ctx) {
20
- const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set() };
22
+ const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set(), type: '', open: false, hide: new Set() };
21
23
  const el = document.getElementById('tdPage');
22
24
  const on = () => !!el && !ctx.isPhone();
23
25
  const day = () => TM.dayKey(ctx.now());
@@ -27,7 +29,19 @@ export function mountToday(ctx) {
27
29
  if (r && r.ok) X.log = { entries: r.entries || [], marks: r.marks || {} };
28
30
  X.read = true;
29
31
  draw();
32
+ readReports();
30
33
  }
34
+ // the reports that go out today, at their time (GET /api/events-place; 202 while a Board is read: ask again in a moment, three times)
35
+ async function readReports(n = 0) {
36
+ const r = await ctx.pmGet('/api/events-place').catch(() => null);
37
+ if (r && r.state === 'reading' && n < 3) { setTimeout(() => readReports(n + 1), 4000); return; }
38
+ if (!r || !r.ok) return;
39
+ const today = day();
40
+ X.reports = (r.items || []).filter((x) => x && x.kind === 'report' && x.date === today && x.time).map((x) => ({ key: x.key, title: x.title, time: x.time }));
41
+ draw();
42
+ }
43
+ // the head's clock: the time on it moves each minute, and only its words change
44
+ setInterval(() => { const w = el && el.querySelector('.td-when'); if (w) w.textContent = TM.headModel(ctx.now()).when; }, 30000);
31
45
  const tdItems = () => {
32
46
  const tabs = (ctx.S.D.work && ctx.S.D.work.queue && ctx.S.D.work.queue.tabs) || [];
33
47
  return ((tabs.find((t) => t.key === 'today') || { groups: [] }).groups || []).flatMap((g) => g.rows || []);
@@ -42,9 +56,12 @@ export function mountToday(ctx) {
42
56
  const lab = (S.lab || []).flatMap((l) => (l.items || []).map((f) => ({ ...f, ws: l.ws, board: l.board })));
43
57
  const L = TM.logModel({ rank: ctx.rank(), move, items: tdItems(), drafts, review: R && R.open && !R.done ? { title: 'Your weekly review' } : null,
44
58
  own: X.log.entries, marks: X.log.marks, lab, titleOf: ctx.titleOf, now });
45
- const A = TM.agendaModel({ meetings: ctx.meetings(), own: X.log.entries, now,
59
+ const lead = L.rows.find((r) => !r.done && r.src !== 'note' && r.src !== 'own' && r.src !== 'lab');
60
+ const A = TM.agendaModel({ meetings: ctx.meetings(), own: X.log.entries, reports: X.reports || [], focus: lead ? { key: lead.key, title: lead.title } : null, now,
46
61
  iniOf: (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null });
47
- return { L, A };
62
+ const O = TM.overviewModel(L, A);
63
+ O.suggest = O.suggest.filter((x) => !X.hide.has(x.key));
64
+ return { L, A, O };
48
65
  }
49
66
  function draw() {
50
67
  document.body.classList.toggle('cz-today', on());
@@ -52,37 +69,72 @@ export function mountToday(ctx) {
52
69
  if (!on()) { el.hidden = true; return; }
53
70
  el.hidden = false;
54
71
  if (!ctx.S.ready) { if (!el.firstChild) el.innerHTML = '<p class="td-none">Reading your day.</p>'; return; }
55
- const { L, A } = models();
56
- X.model = L; X.agenda = A;
72
+ const { L, A, O } = models();
73
+ X.model = L; X.agenda = A; X.overview = O;
74
+ autoClosed();
75
+ // the rail's number on every place: the lines for today (Do first and what waits today), the number the Overview says; kept for the
76
+ // other places with its day (pm/cozy-nav.js reads it there)
77
+ if (O.today !== X.calls) {
78
+ X.calls = O.today;
79
+ document.dispatchEvent(new CustomEvent('cz:calls', { detail: { count: O.today } }));
80
+ try { localStorage.setItem('pmos.today.count', JSON.stringify({ day: L.today, n: O.today })); } catch { /* a private window */ }
81
+ }
82
+ if (X.type && !(L.types || {})[X.type]) X.type = '';
57
83
  const cap = document.getElementById('tdCap'), draft = cap ? cap.value : '', focus = !!cap && document.activeElement === cap;
58
- const html = TP.pageHtml(L, A, { news: ctx.news(), draft });
84
+ const html = TP.pageHtml(L, A, { draft, overview: O, type: X.type, open: X.open || !!X.type, handled: X.type && X.type !== 'Ask' ? [] : handled(), hopen: X.hopen });
59
85
  if (html === X.html && el.firstChild) return;
60
86
  X.html = html;
61
87
  const st = el.parentNode ? el.parentNode.scrollTop : 0;
62
- el.innerHTML = html;
88
+ el.innerHTML = TP.headHtml(TM.headModel(ctx.now())) + html;
63
89
  if (el.parentNode) el.parentNode.scrollTop = st;
64
90
  const c2 = document.getElementById('tdCap'); if (c2 && focus) { c2.focus(); c2.setSelectionRange(c2.value.length, c2.value.length); }
65
91
  }
66
92
  const rowOf = (key) => (X.model ? X.model.rows.find((r) => r.key === key) : null);
67
- const snap = (r) => ({ title: r.title, work: r.work, job: r.job });
68
- async function mark(key, act, extra = {}) {
93
+ const snap = (r) => ({ title: r.title, work: r.work, job: r.job, type: r.type });
94
+ async function mark1(key, act, extra) {
69
95
  const r = await ctx.pmPost('/api/today-log/mark', { key, act, day: day(), ...extra }).catch(() => null);
70
96
  return r && r.ok ? r : { ok: false, error: (r && r.error) || 'the server did not answer' };
71
97
  }
98
+ /** A mark goes to every key behind a line (the same ask from two people is one line with two keys). */
99
+ async function mark(key, act, extra = {}) {
100
+ const r = rowOf(key), keys = r && r.keys && r.keys.length ? r.keys : [key];
101
+ let res = null;
102
+ for (const k of keys) { res = await mark1(k, act, k === key ? extra : {}); if (!res.ok) return res; }
103
+ return res;
104
+ }
72
105
  /** After a write: read the log again, and Home's own lists when the source changed. */
73
106
  const after = async (src) => { if (src) await ctx.reload(); await read(); };
74
107
  const pop = (r) => ctx.VW.popNext({ keep: true, id: r.ini || r.key, kind: r.ini ? 'initiative' : 'item', title: r.ini ? ctx.titleOf(r.ini) : r.title });
75
108
  /** A chat-only press (a session that asks): the popup with that chat and the sessions on its left. */
76
109
  const chatPop = () => setTimeout(() => { if (!ctx.VW.popOpen()) { ctx.VW.popNext(null); const t = ctx.chatNow(); if (t) ctx.POP.openCos(t); } }, 120);
77
110
 
111
+ /** The popup's chat hidden for this open (round 3 point 7), until the popup's own per-item rule does it. */
112
+ const chatOff = () => setTimeout(() => { const h = document.querySelector('.cz-pop:not([hidden]) [data-pop="hide"]'); if (h && !h.closest('.chat-off')) h.click(); }, 60);
113
+ /** The rows in the order Today shows them, the ones that open something. */
114
+ const order = () => { const L = X.model; if (!L) return []; return [...(L.first || []), ...(L.todayRows || []), ...(X.open || X.type ? L.wait || [] : [])].filter((r) => r && !r.done && r.src !== 'note' && r.src !== 'own'); };
115
+ /** ↑ ↓ (j k) in the popup: the previous or next Today row opens in its place. true when it stepped. */
116
+ function step(d) {
117
+ const list = order(), i = list.findIndex((r) => r.key === X.last);
118
+ const next = list[i < 0 ? 0 : i + d]; if (!next) return false;
119
+ open(next); return true;
120
+ }
78
121
  function open(r) {
79
122
  if (!r) return;
80
123
  const ref = r.ref || {};
124
+ X.last = r.key; // ↑ ↓ (j k) step from here (round 3 point 6)
81
125
  if (r.src === 'ask') {
126
+ // a mention opens that one mention in the popup, about it, with the chat hidden (round 3 points 1 to 7); never the Mentions list
127
+ if (ref.kind === 'mention' && ref.mention && ctx.openMention) {
128
+ const m = ref.mention;
129
+ ctx.VW.popNext({ id: 'mention:' + m.id, kind: 'mention', title: OM.askTitle(m) });
130
+ if (ctx.openMention(m.id, { step, m })) { chatOff(); return; } // m: the row's own copy when a fresh read no longer lists it
131
+ }
132
+ // a Check (did it work?) opens its initiative, where the verdict is asked, not the Intelligence list (round 3 point 8)
133
+ if (ref.kind === 'verdict') { const ini = ref.ini || (ref.verdict && ref.verdict.ini); if (ini && ctx.hasIni(ini)) { ctx.goIni(ini); return; } }
82
134
  if (ref.kind === 'call') { const c = ref.call || {}; if (c.ini && ctx.hasIni(c.ini) && !ASK_SEND.has(c.kind)) { ctx.goIni(c.ini); return; } pop(r); ctx.select(c.id); if (ASK_SEND.has(c.kind)) chatPop(); return; }
83
135
  pop(r); ctx.movePress({ dataset: { yd: 'mv-open', key: ref.key }, disabled: false }); return;
84
136
  }
85
- if (r.src === 'move') { if (ref.kind === 'task' && r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini); return; } pop(r); ctx.select(r.key); if (ref.kind === 'session') chatPop(); return; }
137
+ if (r.src === 'move') { if (ref.kind === 'task' && r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini, { task: (ref.task && ref.task.uid) || null }); return; } pop(r); ctx.select(r.key); if (ref.kind === 'session') chatPop(); return; }
86
138
  if (r.src === 'item') { if (r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini); return; } pop(r); import('./home-work.js').then((M) => M.openWorkItem(ref.key)).catch(() => {}); return; }
87
139
  if (r.src === 'draft') { pop(r); ctx.openFinished(ref.fin); return; }
88
140
  if (r.src === 'review') { pop(r); ctx.openReviewVw(); return; }
@@ -172,6 +224,36 @@ export function mountToday(ctx) {
172
224
  if (undo) ctx.toastUndo(said, undo); else ctx.toast(said);
173
225
  return after(true);
174
226
  }
227
+ /** ✦ Looks answered on an ask: ✓ closes it (answered, with Undo), ✕ keeps it waiting and PMOS does not ask again until the thread moves. */
228
+ async function looks(r, yes) {
229
+ const ids = (r.keys || [r.key]).filter((k) => /^mn:/.test(k)).map((k) => k.slice(3));
230
+ let ok = 0; for (const id of ids) { const m = await ctx.mentionAct(id, yes ? 'answered' : 'keep').catch(() => null); if (m && m.ok) ok++; }
231
+ if (!ok) return ctx.toast('It did not go through. Nothing changed.');
232
+ await ctx.reloadMentions();
233
+ if (!yes) return ctx.toast('Kept waiting. PMOS will not ask again unless the thread moves.');
234
+ ctx.toastUndo('Closed: ' + r.title + '.', async () => { let u = { ok: true }; for (const id of ids) u = await ctx.mentionAct(id, 'undo').catch(() => ({ ok: false })); await ctx.reloadMentions(); return u; });
235
+ }
236
+ /** The self check closed an ask he had answered already (his reply, a closed ticket, the ask taken back): it left Today by itself; the
237
+ * toast says how, once, with Undo (round 3 point 10c). The asks Today showed as waiting are kept on this computer to tell which left. */
238
+ /** PMOS handled · N: the asks the self check cleared today (design check of round 3, point 6). */
239
+ function handled() {
240
+ const M = ctx.mentions ? ctx.mentions() : null; if (!M || !M.loaded || M.failed) return [];
241
+ let c = null; try { c = JSON.parse(localStorage.getItem('pmos.today.cleared') || 'null'); } catch { c = null; }
242
+ return TM.handledModel(M.answered, { today: day(), now: ctx.now(), cleared: c && c.day === day() ? c.ids : [] });
243
+ }
244
+ function autoClosed() {
245
+ const L = ctx.mentions ? ctx.mentions() : null; if (!L || !L.loaded || L.failed) return;
246
+ let was = null; try { was = JSON.parse(localStorage.getItem('pmos.today.waits') || 'null'); } catch { was = null; }
247
+ try { localStorage.setItem('pmos.today.waits', JSON.stringify(L.waiting.map((m) => m.id))); } catch { /* a private window */ }
248
+ if (!Array.isArray(was)) return;
249
+ const gone = L.answered.filter((m) => m.auto && m.proof && was.includes(m.id)); if (!gone.length) return;
250
+ try { const c = JSON.parse(localStorage.getItem('pmos.today.cleared') || 'null'); const ids = c && c.day === day() ? c.ids : [];
251
+ localStorage.setItem('pmos.today.cleared', JSON.stringify({ day: day(), ids: [...new Set([...ids, ...gone.map((m) => m.id)])] })); } catch { /* a private window */ }
252
+ const nm = (m) => String((m.people && m.people[0]) || m.who || 'Someone').trim().split(/\s+/)[0];
253
+ const said = gone.length === 1 ? 'Answered already, so it left Today: ' + nm(gone[0]) + '. ' + OM.proofText(gone[0].proof, ctx.now()) + '.'
254
+ : gone.length + ' asks were answered already, so they left Today: ' + gone.map(nm).join(', ') + '.';
255
+ ctx.toastUndo(said, async () => { let u = { ok: true }; for (const m of gone) u = await ctx.mentionAct(m.id, 'reopen').catch(() => ({ ok: false })); await ctx.reloadMentions(); return u; });
256
+ }
175
257
  /** The date chooser beside a row: one date field; Enter or a change sets it, Escape or a press outside closes it. */
176
258
  function chooseDate(r, btn) {
177
259
  document.querySelectorAll('.td-dp').forEach((x) => x.remove());
@@ -193,12 +275,36 @@ export function mountToday(ctx) {
193
275
  try { i.showPicker(); } catch { /* the field itself is the chooser */ }
194
276
  }
195
277
 
278
+ // j k with any Today row's item open in the popup: the next or previous row opens in its place (↑ ↓ too in the one-mention popup)
279
+ document.addEventListener('keydown', (e) => {
280
+ if (!on() || !X.last || e.metaKey || e.ctrlKey || e.altKey || (e.key !== 'j' && e.key !== 'k')) return;
281
+ if (!(ctx.VW.popOpen && ctx.VW.popOpen()) || (e.target && e.target.closest && e.target.closest('input,textarea,select,[contenteditable],.cz-pop-chat,[role="textbox"]'))) return;
282
+ if (step(e.key === 'j' ? 1 : -1)) e.preventDefault();
283
+ });
196
284
  if (el) {
197
285
  el.addEventListener('click', async (e) => {
198
286
  const b = e.target.closest('[data-td]'); if (!b || b.disabled) return;
199
287
  const act = b.dataset.td, key = b.dataset.key || '';
200
288
  if (act === 'cal') { ctx.openCalendar(); return; }
201
- if (act === 'news') { ctx.VW.popNext({ keep: true, id: 'news', kind: 'item', title: 'New for you' }); ctx.openInbox(); return; }
289
+ if (act === 'fold') { X.open = !X.open; draw(); return; }
290
+ if (act === 'hfold') { X.hopen = !X.hopen; draw(); return; }
291
+ if (act === 'h-undo') {
292
+ b.disabled = true; const m = await ctx.mentionAct(key, 'reopen').catch(() => null);
293
+ if (!m || !m.ok) { b.disabled = false; return ctx.toast('It did not go through. Nothing changed.'); }
294
+ await ctx.reloadMentions(); ctx.toast('Back on Today: it still waits on you.'); return;
295
+ }
296
+ if (act === 'type') { X.type = X.type === key ? '' : key; draw(); return; }
297
+ if (act === 'ov-yes' || act === 'ov-no') {
298
+ const sg = X.overview && X.overview.suggest.find((x) => x.key === key); if (!sg || X.busy.has(key)) return;
299
+ X.busy.add(key); b.disabled = true;
300
+ try {
301
+ if (act === 'ov-no') { for (const k of sg.keys) await mark1(k, 'keep', {}); X.hide.add(key); ctx.toast('Kept. PMOS will not suggest it again for a month.'); return after(false); }
302
+ const done = []; for (const k of sg.keys) { const m = await mark1(k, 'drop', {}); if (m.ok) done.push(k); }
303
+ if (!done.length) return ctx.toast('Nothing was dropped. Nothing changed.');
304
+ ctx.toastUndo('Dropped ' + done.length + (done.length === 1 ? ' line' : ' lines') + ' from your log.', async () => { let u = { ok: true }; for (const k of done) u = await mark1(k, 'undrop', {}); after(false); return u; });
305
+ return after(false);
306
+ } finally { X.busy.delete(key); if (b.isConnected) b.disabled = false; }
307
+ }
202
308
  if (act === 'ev') {
203
309
  const x = X.agenda && X.agenda.items.find((y) => y.key === key); if (!x) return;
204
310
  if (x.ini && ctx.hasIni(x.ini)) { ctx.goIni(x.ini); return; }
@@ -215,6 +321,7 @@ export function mountToday(ctx) {
215
321
  else if (act === 'drop') await drop(r);
216
322
  else if (act === 'keep') await keep(r);
217
323
  else if (act === 'lab-keep' || act === 'lab-drop') await lab(r, act === 'lab-keep');
324
+ else if (act === 'lk-yes' || act === 'lk-no') await looks(r, act === 'lk-yes');
218
325
  } finally { X.busy.delete(key); if (b.isConnected) b.disabled = false; }
219
326
  });
220
327
  // the first line: Enter adds the row, and nothing else happens (no popup, no session)