create-pmos 0.431.0 → 0.432.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 (58) hide show
  1. package/package.json +13 -13
  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/board-programs-test.js +10 -4
  7. package/workspace/briefing-premium-board-test.js +24 -22
  8. package/workspace/briefing-premium-initiative-test.js +10 -5
  9. package/workspace/briefing-premium-products-test.js +2 -0
  10. package/workspace/briefing-premium-sources-test.js +15 -8
  11. package/workspace/briefing-premium-work-test.js +6 -3
  12. package/workspace/changelog.json +12 -0
  13. package/workspace/ev-everywhere-test.js +40 -33
  14. package/workspace/guide/briefing-premium.md +1 -1
  15. package/workspace/guide/data-freshness.md +3 -1
  16. package/workspace/guide/home.md +25 -16
  17. package/workspace/guide/initiative-boards.md +6 -6
  18. package/workspace/guide/programs.md +2 -2
  19. package/workspace/ini-workflow-test.js +13 -8
  20. package/workspace/lib/briefing-premium.js +6 -3
  21. package/workspace/lib/engine/boards.js +13 -2
  22. package/workspace/lib/ini-deleted.js +58 -0
  23. package/workspace/lib/initiative-rows.js +4 -1
  24. package/workspace/lib/routes-boards.js +48 -0
  25. package/workspace/lib/search-index.js +3 -1
  26. package/workspace/package-lock.json +2 -2
  27. package/workspace/package.json +1 -1
  28. package/workspace/premium-board-actions-test.js +50 -32
  29. package/workspace/premium-briefing-depth-test.js +33 -34
  30. package/workspace/premium-core-doc-issue-test.js +1 -1
  31. package/workspace/premium-vw-backlog-test.js +1 -1
  32. package/workspace/premium-vw-item-test.js +1 -1
  33. package/workspace/premium-vw-jira-test.js +1 -1
  34. package/workspace/program-leave-test.js +20 -19
  35. package/workspace/public/pm/bd-acts.js +7 -5
  36. package/workspace/public/pm/bd-ini-panel.js +57 -25
  37. package/workspace/public/pm/cozy-ev.css +22 -7
  38. package/workspace/public/pm/cozy-evmodel.js +3 -3
  39. package/workspace/public/pm/cozy-nav.js +29 -32
  40. package/workspace/public/pm/cozy-news.js +11 -27
  41. package/workspace/public/pm/cozy-settings.js +68 -11
  42. package/workspace/public/pm/cozy-sources.js +5 -89
  43. package/workspace/public/pm/cozy-today.css +19 -1
  44. package/workspace/public/pm/hi-pop.css +21 -0
  45. package/workspace/public/pm/hi-pop.js +5 -5
  46. package/workspace/public/pm/home-app.js +62 -25
  47. package/workspace/public/pm/home-day.js +60 -2
  48. package/workspace/public/pm/home-ini.js +66 -27
  49. package/workspace/public/pm/home-more.js +9 -50
  50. package/workspace/public/pm/home-today.js +4 -2
  51. package/workspace/public/pm/ini-more.js +78 -42
  52. package/workspace/public/pm/ini-view-model.js +1 -1
  53. package/workspace/public/pm/ini-view.css +17 -0
  54. package/workspace/public/pm/ini-view.js +25 -7
  55. package/workspace/public/pm/premium-board.js +4 -3
  56. package/workspace/public/pm/prog-move.js +26 -0
  57. package/workspace/public/premium.html +0 -1
  58. package/workspace/stage-card-test.js +10 -1
@@ -5,7 +5,7 @@
5
5
  * questions, usual(track) the usual days in the step, rowOf(key), pageHref(r), askHref(r, q), refreshJira(), send(r) the
6
6
  * Send to Jira sheet, moreAct(r, k, btn) a stage press of ⋯ (bd-acts.js), grillOpen(r, btn), onShow(key, from) / onHide() so the page
7
7
  * marks the row the item came from, programOf(r) the program it is in or null, openProgram(id, btn), turnProgram(r)
8
- * "Turn into a program", moveItems(r) Move out of its program and Move to another (pm/prog-move.js), smItems(r) and
8
+ * "Make it a program", moveItems(r) the one Program item of ⋯ (pm/prog-move.js programItem), smItems(r) and
9
9
  * smPress(r, act, btn) Split into a new initiative and Merge into (pm/split-merge.js), openIniId(id) a row by its record id, setTask(r, uid, state) a task's state, setDates(r, uid, { start?, due? }) its days (the Tasks
10
10
  * views' quick changes, batch 9 item 5b), removeTask(r, uid) the status picker's trash (batch 11 item 16), addTask(r, title) a new task (POST /api/boards/tasks/add),
11
11
  * openTask(r, task) the task's own editor, hold(r, i, btn) a hold's menu (the stage card's ⏸, batch 11 item 21), viewDoc(path), reload() a new read of the Board and toast(text, undo?) (planned
@@ -16,9 +16,10 @@
16
16
  * openTicket(r, k) the ticket as a drill-in, in the one ticket Viewer (tk-view.js): ← goes back to the initiative; the summary says what blocks it and what that delays
17
17
  * refresh() draws the shown item again after a new read, in place · close() · shown() → the key of the initiative shown, or null
18
18
  *
19
- * What has no place on the view is under ⋯: the ONE initiative menu (pm/ini-more.js, feedback batch 14 item 5), the same words and order as
20
- * Home's initiative page. Its stage presses (Move back a stage, Move to a stage, Put on hold, Cancel) are the row menu's own (moreAct(r, k, btn),
21
- * bd-acts.js); Change workflow, Won't do and Archive are Home's (ini-wf.js). Discuss in chat takes the question to Home. */
19
+ * What has no place on the view is under ⋯: the ONE initiative menu (pm/ini-more.js, feedback batch 14 item 5; seven entries since batch 16
20
+ * item 5c), the same words and order as Home's initiative page, with Delete last (5d). The rest sits on the thing it changes: the stage chip's
21
+ * picker moves the stage with the row menu's own presses (moreAct(r, k, btn), bd-acts.js); Change workflow, Won't do and Archive are Home's
22
+ * (ini-wf.js). Discuss in chat takes the question to Home. */
22
23
  import * as VW from './cozy-viewer.js';
23
24
  import { esc } from './premium-shell.js';
24
25
  import { lr, copyText } from './cozy-xv.js';
@@ -30,7 +31,8 @@ import { pmGet, pmPost } from './http.js';
30
31
  import * as MD from './home-ini-model.js'; // the stage move's rules, as Home reads them (Moves on by itself, Move back a stage)
31
32
  import * as WF from './ini-wf.js'; // D99: Change workflow, Won't do, Back to Triage, Archive, the same popovers as Home's
32
33
  import { openPop, closePop, undoToast, ensureCss as ensurePopCss } from './hi-pop.js';
33
- import { iniMore as iniMoreOf, iniText } from './ini-more.js'; // the one initiative ⋯ menu (batch 14 item 5)
34
+ import { readyOf } from './bd-acts.js'; // how much of the step is ready, beside the next stage in the stage picker
35
+ import { iniMore as iniMoreOf, iniText, stagePick, deleteSaid, DELETE_MS } from './ini-more.js'; // the one initiative ⋯ menu and stage picker (batch 14 item 5, batch 16 item 5c)
34
36
 
35
37
  let O = null;
36
38
  let cur = null; // { key, tk } the initiative shown, and its ticket while the drill-in is shown
@@ -114,36 +116,61 @@ function addPerson(r) {
114
116
  };
115
117
  }
116
118
  function iniMore(r) {
117
- const M = O.M() || {}, a = r.acts || null, self = !!(M.board || {}).self, mv = moveOf(r), id = r.id;
118
- const live = a && !a.life && !r.ended && !a.archived;
119
+ const id = r.id;
119
120
  return iniMoreOf({
120
- wf: id && !self && !r.ended ? { name: (r.wf || {}).name, on: (b) => WF.openPicker(b, wfUi(), id) } : null,
121
- rename: O.rename && id ? () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } : null,
122
- auto: id && !mv.why ? { on: mv.auto, press: () => setAuto(r, !mv.auto) } : null,
123
- back: id && a && mv.canBack ? { prev: mv.prev, on: (b) => O.moreAct(r, 'back:' + mv.prev, b) } : null,
124
- toStage: id && live && !self && (a.stages || []).length > 1 ? (b) => O.moreAct(r, 'stage', b) : null,
125
- dates: id ? () => location.assign(O.askHref(r, 'Propose new start and end dates for ' + r.title)) : null,
126
- person: id ? () => addPerson(r) : null,
127
- // split or merge, then the program moves (batch 11 items 2 and 14; pm/split-merge.js, pm/prog-move.js)
121
+ // split or merge, then the one Program picker (batch 11 items 2 and 14; batch 16 item 5c; pm/split-merge.js, pm/prog-move.js)
128
122
  sm: id && O.smItems && !r.ended ? O.smItems(r) : [],
129
123
  pm: id && O.moveItems ? O.moveItems(r) : [],
130
- turnProgram: id && O.turnProgram && !(O.programOf && O.programOf(r)) ? () => O.turnProgram(r) : null,
131
- jira: M.jira ? () => O.refreshJira() : null,
132
- record: id ? async () => { VW.drill(); (await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: r.title, ...where(r) }); } : null,
133
124
  link: id ? () => copyText(new URL(O.pageHref(r), location.href).href, 'Link copied.') : null,
134
125
  text: () => copyText(iniText(r.title, viewOf(r), (r.track && r.track.tickets) || []), 'Copied as text.'),
135
- ended: !!r.ended,
136
- wontDo: id && !self ? (b) => WF.openWontDo(b, wfUi(), id) : null,
137
- backToTriage: id && !self ? () => WF.backToTriage(wfUi(), id) : null,
138
- archive: id && !self && !(a && a.archived) ? () => WF.archive(wfUi(), id) : null,
126
+ record: id ? async () => { VW.drill(); (await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: r.title, ...where(r) }); } : null,
127
+ del: id ? () => deleteIni(r) : null,
128
+ });
129
+ }
130
+ /** Delete (batch 16 item 5d, FmI3Deleted): no confirm; the panel closes, the row and its tasks leave the Board, and Undo in the toast for
131
+ * 8 s brings them back (POST /api/boards/ini-delete, ini-restore). Jira is never written. */
132
+ async function deleteIni(r) {
133
+ const at = where(r);
134
+ const res = await pmPost('/api/boards/ini-delete', { ...at, id: r.id }).catch(() => null);
135
+ if (!res || res.ok === false) { O.toast((res && res.error) || 'It was not deleted.'); return; }
136
+ close();
137
+ if (O.reload) await O.reload();
138
+ undoToast(deleteSaid(res.title || r.title, res.tasks || 0), async () => {
139
+ const u = await pmPost('/api/boards/ini-restore', { ...at, id: r.id }).catch(() => null);
140
+ if (!u || u.ok === false) { O.toast((u && u.error) || 'The undo did not land.'); return; }
141
+ if (O.reload) await O.reload();
142
+ if (O.openIniId) O.openIniId(r.id);
143
+ }, DELETE_MS);
144
+ }
145
+ /** The stage chip (batch 16 item 5c, FmI2Stage): the same picker as Home's. A move forward is the row's own (Undo in the toast); a move back
146
+ * asks why in a card under the chip (bd-acts.js moreAct). */
147
+ function stageChip(btn, r) {
148
+ const M = O.M() || {}, a = r.acts || {}, self = !!(M.board || {}).self, mv = moveOf(r), id = r.id;
149
+ const live = !a.life && !r.ended && !a.archived;
150
+ const own = ownWf(r) ? r.wfStages.filter((s) => s.status !== 'skipped' || s.key === r.wfStage.key) : null;
151
+ const stages = own ? own.map((s) => ({ name: s.name, ms: !!s.milestone })) : (a.stages || []).map((name) => ({ name, ms: MD.isMilestone(name) }));
152
+ const nx = stages.findIndex((x) => x.name === mv.cur) + 1;
153
+ if (nx > 0 && stages[nx]) stages[nx].note = readyOf(r);
154
+ stagePick(btn, {
155
+ title: r.title, stages, cur: mv.cur,
156
+ go: id && live && !self && O.moreAct ? (name, b) => {
157
+ const i = stages.findIndex((x) => x.name === name), at = stages.findIndex((x) => x.name === mv.cur);
158
+ O.moreAct(r, (i < at ? 'back:' : 'fwd:') + name, b);
159
+ } : null,
160
+ auto: id && !mv.why ? { on: mv.auto, press: (on) => setAuto(r, on) } : null,
139
161
  hold: id && live && O.moreAct ? (b) => O.moreAct(r, 'hold', b) : null,
140
- resume: id && a && a.life === 'hold' && !r.ended && O.moreAct ? (b) => O.moreAct(r, 'resume', b) : null,
141
- cancel: id && live && O.moreAct ? (b) => O.moreAct(r, 'cancel', b) : null,
162
+ resume: id && a.life === 'hold' && !r.ended && O.moreAct ? (b) => O.moreAct(r, 'resume', b) : null,
163
+ wontDo: id && !self && !r.ended ? (b) => WF.openWontDo(b, wfUi(), id) : null,
164
+ backToTriage: id && !self && r.ended ? () => WF.backToTriage(wfUi(), id) : null,
165
+ archive: id && !self && !a.archived ? () => WF.archive(wfUi(), id) : null,
142
166
  });
143
167
  }
144
168
  function iniBody(r) {
145
169
  const md = (v) => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+v.slice(5, 7) - 1] + ' ' + +v.slice(8, 10);
146
- return viewHtml(viewOf(r), { add: !!(r.id && O.addTask), adding: adding === r.key, addHint: adding === r.key && addDates ? md(addDates.start) + ' to ' + md(addDates.due) : '', openTask: !!O.openTask, quick: !!(O.setTask && O.setDates), hold: !!O.hold, tail: VW.czSections(boardSections(r), { key: 'board' }) });
170
+ const self = !!((O.M() || {}).board || {}).self, M = O.M() || {};
171
+ // what left the ⋯ for the thing it changes (batch 16 item 5c): the workflow chip, the dashed +, the stage chip, the dates chip, Jira's ↻
172
+ return viewHtml(viewOf(r), { add: !!(r.id && O.addTask), adding: adding === r.key, addHint: adding === r.key && addDates ? md(addDates.start) + ' to ' + md(addDates.due) : '', openTask: !!O.openTask, quick: !!(O.setTask && O.setDates), hold: !!O.hold, tail: VW.czSections(boardSections(r), { key: 'board' }),
173
+ wf: !!r.id && !self && !r.ended, person: !!r.id, stagePick: !!r.id, planDates: !!r.id, jira: !!M.jira });
147
174
  }
148
175
  /** Presses inside the shown item: the view's own (pm/ini-view.js), a ticket's drill-in, the PRD-change question. A [data-doc] goes to the page's handler. */
149
176
  function wire(body, key) {
@@ -177,6 +204,11 @@ function wire(body, key) {
177
204
  else if (act === 'page' && r.id) location.assign(O.pageHref(r));
178
205
  },
179
206
  program: (id, b) => { if (O.openProgram) O.openProgram(id, b); },
207
+ wf: (b) => { const r = O.rowOf(key); if (r && r.id) WF.openPicker(b, wfUi(), r.id); },
208
+ person: () => { const r = O.rowOf(key); if (r) addPerson(r); },
209
+ stagePick: (b) => { const r = O.rowOf(key); if (r) stageChip(b, r); },
210
+ planDates: () => { const r = O.rowOf(key); if (r) location.assign(O.askHref(r, 'Propose new start and end dates for ' + r.title)); },
211
+ jira: () => O.refreshJira(),
180
212
  // Claude's split or merge card (batch 11 item 14): ✕ Not now, ✎ Change it first, ✓ as suggested; the merged summary's link opens the one that stays
181
213
  sm: (act, b) => { const r = O.rowOf(key); if (r && O.smPress) O.smPress(r, act, b); },
182
214
  openIni: (id) => { if (O.openIniId) O.openIniId(id); },
@@ -54,17 +54,22 @@
54
54
  .cz .ev-tile svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
55
55
  .cz .ev-vh { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
56
56
 
57
- /* ── the place menu (EvMenu, EvPhone): Home, Board, Insights, then Search, New for you, Sources, Settings and Theme ── */
58
- .cz-fabm.ev-menu { width: 300px; padding: 10px; gap: 2px; border-radius: 20px; border: 0; box-shadow: 0 24px 60px -24px rgba(42,46,53,.45), 0 0 0 1px var(--cz-hair); }
57
+ /* ── the place menu (FmA1Menu, FmA4Desk): Home, Board, Intelligence, then Search and Settings as icons ── */
58
+ .cz-fabm.ev-menu { width: 250px; padding: 10px; gap: 2px; border-radius: 20px; border: 0; box-shadow: 0 24px 60px -24px rgba(42,46,53,.45), 0 0 0 1px var(--cz-hair); }
59
59
  .cz-fabm.ev-menu a, .cz-fabm.ev-menu button.ev-mi, .cz-fabm.ev-menu .ev-mi { min-height: 40px; padding: 0 12px; gap: 10px; border-radius: 12px; font-size: var(--fs-3); font-weight: 600; color: var(--cz-ink); width: 100%; box-sizing: border-box; border-top: 0; margin: 0; }
60
60
  .cz-fabm.ev-menu svg { width: 18px; height: 18px; color: var(--cz-ink2); stroke-width: 1.8; }
61
61
  .cz-fabm.ev-menu [aria-current="page"] { background: var(--cz-well); color: var(--cz-ink); font-weight: 800; }
62
62
  .cz-fabm.ev-menu a:hover, .cz-fabm.ev-menu button.ev-mi:hover { background: var(--cz-well); }
63
63
  .cz-fabm.ev-menu .ev-k { margin-left: auto; font-size: var(--fs-2); color: var(--cz-ink3); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
64
- .cz-fabm.ev-menu .ev-theme { cursor: default; }
65
- .cz-fabm.ev-menu .ev-theme .ev-seg { margin-left: auto; }
66
- .cz-fabm.ev-menu .ev-theme .ev-seg button { min-height: 0; height: 28px; padding: 0 9px; font-size: var(--fs-2); width: auto; border-radius: 999px; }
67
- .cz-fabm.ev-menu .ev-mmore { color: var(--cz-ink2); font-weight: 600; }
64
+ /* the tray under the places: Search and Settings as icons (feedback batch 16 item 5, canvas FmA1Menu); the dots sit where they lead */
65
+ .cz-fabm.ev-menu .ev-tray { display: flex; gap: 8px; border-top: 1px solid var(--cz-hair); margin-top: 6px; padding: 8px 4px 0; }
66
+ .cz-fabm.ev-menu .ev-tb { position: relative; width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--cz-well); color: var(--cz-ink); display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
67
+ .cz-fabm.ev-menu .ev-tb:hover { background: var(--cz-hair); }
68
+ .cz-fabm.ev-menu .ev-tb svg { width: 20px; height: 20px; color: var(--cz-ink); }
69
+ .cz-fabm.ev-menu .ev-md { display: block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
70
+ .cz-fabm.ev-menu a .ev-md { margin-left: auto; }
71
+ .cz-fabm.ev-menu .ev-md.you { background: var(--cz-blue); }
72
+ .cz-fabm.ev-menu .ev-md.risk { background: var(--cz-dot-risk); position: absolute; top: 9px; right: 9px; border: 2px solid var(--cz-well); box-sizing: content-box; width: 8px; height: 8px; }
68
73
  .ev-scrim { position: fixed; inset: 0; z-index: 0; background: rgba(42,46,53,.08); }
69
74
  .ev-scrim[hidden] { display: none; }
70
75
  /* the closed menu's dots: blue, something new for you (top left); amber, a source is stale (top right). They appear; they never move. */
@@ -77,7 +82,8 @@
77
82
  .ev-fd.risk { right: 2px; background: var(--cz-dot-risk); }
78
83
  @media (max-width: 760px) {
79
84
  .cz-fabm.ev-menu a, .cz-fabm.ev-menu button.ev-mi, .cz-fabm.ev-menu .ev-mi { min-height: 46px; }
80
- .cz-fabm.ev-menu .ev-theme .ev-seg button { min-height: 0; }
85
+ .cz-fabm.ev-menu .ev-tray { justify-content: space-between; padding: 8px 6px 0; }
86
+ .cz-fabm.ev-menu .ev-tb { width: 52px; height: 52px; border-radius: 16px; }
81
87
  }
82
88
 
83
89
  /* ── Search (EvSearch, EvPhone right) ── */
@@ -229,3 +235,12 @@
229
235
  .cz .ev-ad-hd { display: flex; align-items: center; gap: 12px; padding: 4px 4px 10px; }
230
236
  .cz .ev-sp-ad { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
231
237
  .cz .ev-sp-ad p { margin: 0; }
238
+ /* Settings › Connectors: each source's last read (feedback batch 16 item 5, FmA3Settings; was the Sources card), and the amber box on top */
239
+ .ev-st-main > .ev-st-warn { margin-bottom: 12px; color: var(--cz-ink); }
240
+ .ev-st-warn .ev-ib-card { background: var(--cz-card); }
241
+ .ev-st .ev-reads { margin-bottom: 12px; }
242
+ .ev-st .ev-fr { align-items: center; gap: 10px; }
243
+ .ev-st .ev-fr .ev-late { color: var(--cz-risk); font-weight: 700; }
244
+ .ev-st .ev-ib-sp { width: 32px; flex: none; }
245
+ .ev-st-nav .ev-mi .ev-dot.risk { margin-left: 6px; }
246
+ .ev-st .ev-rl { margin: 4px 0; }
@@ -6,7 +6,7 @@
6
6
  * staleOf(sources, now) → { id, name, text: 'Jira 5 days old', ago, state } | null the source furthest behind (failed, then the oldest)
7
7
  * sourceRows(sources, now) → [{ id, name, sub, when, risk, act: 'read' | 'connect' | '' }] the Sources table (EvSources)
8
8
  * partsOf(id) → what may be out of date when that source is old ('Board and the Jira-linked initiatives')
9
- * fabLabel(here, open, stale) → 'Open the menu. You are in Home. A source is stale'
9
+ * fabLabel(here, open, stale, news) → 'Open the menu. You are in Home. 3 new for you. Jira 5 days old' (the button says both dots, FmGrill 13)
10
10
  * SEARCH_KINDS · searchGroups(results, { phone }) → [{ key, label, rows }] EvSearch's groups, in its order
11
11
  * resultSub(r) · resultTag(r) → the grey line after a result's title, and the word at its right
12
12
  * wtChip(worktrees) → 'main + 3 worktrees'
@@ -54,9 +54,9 @@ export function sourceRows(sources, now = Date.now()) {
54
54
  });
55
55
  }
56
56
 
57
- export function fabLabel(here, open, stale) {
57
+ export function fabLabel(here, open, stale, news) {
58
58
  if (open) return 'Close the menu';
59
- return 'Open the menu. You are in ' + (PLACE[here] || 'PMOS') + (stale ? '. A source is stale' : '');
59
+ return 'Open the menu. You are in ' + (PLACE[here] || 'PMOS') + (news > 0 ? '. ' + news + ' new for you' : '') + (stale ? '. ' + (stale.text || 'A source is stale') : '');
60
60
  }
61
61
 
62
62
  /* ── Search ── */
@@ -1,17 +1,19 @@
1
1
  /**
2
- * cozy-nav.js — the floating menu (initiative premium-agreed-design; redrawn by premium-uncovered-features E1, canvas EvMenu and EvPhone).
2
+ * cozy-nav.js — the floating menu (initiative premium-agreed-design; redrawn by premium-uncovered-features E1, then by feedback batch 16
3
+ * item 5, canvas FmA1Menu and FmA4Desk: fewer menus).
3
4
  *
4
- * One button, bottom left on desktop and bottom right on a phone, opens the menu: Home, Board, Insights; then Search (⌘K), New for you
5
- * (its count), Sources (the source furthest behind, with an amber dot), Settings and Theme (Light, Dark, Auto). It is the one way between
6
- * places. Closed, the button shows two dots: blue when something is new for you, amber when a source is stale. Nothing moves.
5
+ * One button, bottom left on desktop and bottom right on a phone, opens the menu: the three places, Home, Board and Intelligence; then a
6
+ * tray of two icons, Search (⌘K on a desk) and Settings. It is the one way between places, and it holds nothing else: New for you is a fold
7
+ * in Your day, Sources are Settings › Connectors, Theme is Settings › General, and More is gone (feedback batch 16 item 5).
8
+ * The button keeps its two dots on every page: blue when something is new for you, amber when a source is stale. Open, the blue dot sits on
9
+ * the Home row (where Your day is) and the amber dot on the Settings icon; the button's own name says both ("Open the menu. 3 new for you.
10
+ * Jira is stale.").
7
11
  * Search pm/cozy-search.js: across the repository and every worktree; Ctrl K (Cmd K) or "/" opens it from any page
8
- * New for you pm/cozy-news.js: the FYI items (mentions, tasks given to you, finished work) in the Viewer
9
- * Sources pm/cozy-sources.js: what PMOS reads and how old each reading is, in the Viewer
10
- * Settings pm/cozy-settings.js: General, Connectors, Workspaces, Updates, What's new
11
- * A page with features the design does not draw yet passes opts.more (Home): a quiet "More" row then follows Settings.
12
+ * Settings pm/cozy-settings.js; it opens at Connectors while a source is stale, so the stale one is the first thing there
12
13
  * A page that passes opts.here() runs it when its own place is pressed, in place of a reload (Home: Menu > Home closes the page that is open).
13
- * The counts come from GET /api/news-for-you and GET /api/sources, read when the page opens and every two minutes while it is shown.
14
- * Nothing here leads to the console, and nothing here writes but the theme (this device).
14
+ * The counts come from GET /api/news-for-you and GET /api/sources, read when the page opens and every two minutes while it is shown; each
15
+ * read of New for you is passed on as the event 'cz:news-for-you' (detail: the answer), so Home's Your day and Good morning follow it.
16
+ * Nothing here leads to the console, and nothing here writes.
15
17
  */
16
18
  import { esc, svg, ICON, wsQ } from './cozy-evui.js';
17
19
  import { fabLabel, staleOf } from './cozy-evmodel.js';
@@ -24,7 +26,6 @@ export const PLACES = [
24
26
  ];
25
27
  export { fabLabel };
26
28
  const THEME_KEY = 'pmos.c3.theme';
27
- const THEMES = [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']];
28
29
  const CSS = new URL('./cozy-ev.css', import.meta.url).href;
29
30
  const N = { news: 0, stale: null, here: 'home' };
30
31
 
@@ -41,19 +42,18 @@ export function setTheme(pick, doc = document, { keep = true } = {}) {
41
42
  doc.dispatchEvent(new CustomEvent('cz:theme', { detail: { pick: p, dark } }));
42
43
  }
43
44
 
44
- /** The menu's markup; pure, so a unit test can read it. here: home | board | insights. o: { news, stale: { text } | null, more, theme } */
45
+ /** The menu's markup; pure, so a unit test can read it. here: home | board | insights. o: { news, stale: { text } | null } */
45
46
  export function menuHtml(here, o = {}) {
46
- const news = o.news > 0 ? `<span class="ev-k"><span class="ev-pill y">${o.news > 99 ? '99+' : o.news}</span></span>` : '';
47
- const stale = o.stale ? `<span class="ev-k"><i class="ev-dot risk" aria-hidden="true"></i>${esc(o.stale.text)}</span>` : '';
48
- const th = o.theme || 'auto';
49
- return PLACES.map((p) => `<a href="${p.href}"${p.key === here ? ' aria-current="page"' : ''}>${svg(p.d, 18)}${p.key === here ? `<b>${p.label}</b>` : `<span>${p.label}</span>`}</a>`).join('')
50
- + '<div class="ev-hr" role="separator"></div>'
51
- + `<button type="button" class="ev-mi" data-cz-search>${svg(ICON.search, 18)}<span>Search</span><span class="ev-k"><span class="ev-kbd">⌘K</span></span></button>`
52
- + `<button type="button" class="ev-mi" data-cz-news aria-label="New for you${o.news > 0 ? ', ' + o.news + ' new' : ''}">${svg(ICON.news, 18)}<span>New for you</span>${news}</button>`
53
- + `<button type="button" class="ev-mi" data-cz-sources aria-label="Sources${o.stale ? ', ' + esc(o.stale.text) : ''}">${svg(ICON.sources, 18)}<span>Sources</span>${stale}</button>`
54
- + `<button type="button" class="ev-mi" data-cz-settings>${svg(ICON.settings, 18)}<span>Settings</span></button>`
55
- + (o.more ? `<button type="button" class="ev-mi ev-mmore" data-cz-more>${svg(ICON.more, 18)}<span>More</span></button>` : '')
56
- + `<div class="ev-mi ev-theme">${svg(ICON.theme, 18)}<span>Theme</span><span class="ev-seg sm" role="group" aria-label="Theme">${THEMES.map(([k, w]) => `<button type="button" data-ev-theme="${k}" aria-pressed="${k === th}">${w}</button>`).join('')}</span></div>`;
47
+ const news = o.news > 0, dot = (c) => `<i class="ev-md ${c}" aria-hidden="true"></i>`;
48
+ return PLACES.map((p) => {
49
+ const you = p.key === 'home' && news;
50
+ const lab = you ? ` aria-label="${p.label}. ${o.news} new for you in Your day"` : '';
51
+ return `<a href="${p.href}"${p.key === here ? ' aria-current="page"' : ''}${lab}>${svg(p.d, 18)}${p.key === here ? `<b>${p.label}</b>` : `<span>${p.label}</span>`}${you ? dot('you') : ''}</a>`;
52
+ }).join('')
53
+ + '<div class="ev-tray">'
54
+ + `<button type="button" class="ev-tb" data-cz-search aria-label="Search (⌘K)" title="Search ⌘K">${svg(ICON.search, 20)}</button>`
55
+ + `<button type="button" class="ev-tb" data-cz-settings aria-label="Settings${o.stale ? '. ' + esc(o.stale.text) : ''}" title="Settings">${svg(ICON.settings, 20)}${o.stale ? dot('risk') : ''}</button>`
56
+ + '</div>';
57
57
  }
58
58
 
59
59
  function addCss(doc) {
@@ -80,14 +80,14 @@ export function mountNav(here, doc = document, opts = {}) {
80
80
  mountToastFaces(doc); loadPrefs();
81
81
  const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
82
82
  const draw = () => {
83
- menu.innerHTML = menuHtml(here, { news: N.news, stale: N.stale, more: !!opts.more, theme: themePick() });
83
+ menu.innerHTML = menuHtml(here, { news: N.news, stale: N.stale });
84
84
  w.querySelector('#czFdYou').hidden = !(N.news > 0) || !menu.hidden;
85
85
  w.querySelector('#czFdRisk').hidden = !N.stale || !menu.hidden;
86
- if (menu.hidden) fab.setAttribute('aria-label', fabLabel(here, false, !!N.stale) + (N.news > 0 ? '. ' + N.news + ' new for you' : ''));
86
+ if (menu.hidden) fab.setAttribute('aria-label', fabLabel(here, false, N.stale, N.news));
87
87
  };
88
88
  const set = (open) => {
89
89
  menu.hidden = !open; scrim.hidden = !open; fab.setAttribute('aria-expanded', String(open));
90
- fab.setAttribute('aria-label', fabLabel(here, open, !!N.stale)); fab.innerHTML = svg(open ? ICON.close : ICON.menu, 22);
90
+ fab.setAttribute('aria-label', fabLabel(here, open, N.stale, N.news)); fab.innerHTML = svg(open ? ICON.close : ICON.menu, 22);
91
91
  draw();
92
92
  if (open) { const f = menu.querySelector('a, button'); if (f) f.focus(); }
93
93
  };
@@ -102,13 +102,10 @@ export function mountNav(here, doc = document, opts = {}) {
102
102
  const a = e.target.closest('a[aria-current="page"]');
103
103
  if (a && opts.here && !e.metaKey && !e.ctrlKey && !e.shiftKey) { e.preventDefault(); set(false); opts.here(); return; }
104
104
  const b = e.target.closest('button'); if (!b) return;
105
- if (b.dataset.evTheme) { setTheme(b.dataset.evTheme, doc); return; }
106
105
  set(false);
107
106
  if ('czSearch' in b.dataset) import('./cozy-search.js').then((M) => M.openSearch(opts.search ? { go: opts.search() } : {}));
108
- else if ('czNews' in b.dataset) import('./cozy-news.js').then((M) => M.openNews(opts.news ? { go: opts.news() } : {}));
109
- else if ('czSources' in b.dataset) import('./cozy-sources.js').then((M) => M.openSources());
110
- else if ('czSettings' in b.dataset) import('./cozy-settings.js').then((M) => M.openSettings());
111
- else if ('czMore' in b.dataset && opts.more) opts.more()(fab);
107
+ // a stale source opens Settings at Connectors, the stale one first (FmA3Settings: open where it matters)
108
+ else if ('czSettings' in b.dataset) import('./cozy-settings.js').then((M) => M.openSettings(N.stale ? 'connectors' : undefined));
112
109
  });
113
110
  // Ctrl K (Cmd K) and "/" open Search from any page; a second press focuses it
114
111
  doc.addEventListener('keydown', (e) => {
@@ -122,7 +119,7 @@ export function mountNav(here, doc = document, opts = {}) {
122
119
  const read = async () => {
123
120
  if (doc.hidden) return;
124
121
  const [n, s] = await Promise.all([getj('/api/news-for-you' + wsQ()), getj('/api/sources' + wsQ())]);
125
- if (n && n.ok) N.news = n.count || 0;
122
+ if (n && n.ok) { N.news = n.count || 0; doc.dispatchEvent(new CustomEvent('cz:news-for-you', { detail: n })); }
126
123
  if (s && s.ok) N.stale = staleOf(s.sources);
127
124
  if (menu.hidden || !menu.contains(doc.activeElement)) draw();
128
125
  };
@@ -1,20 +1,19 @@
1
- /* pm/cozy-news.js — New for you, in the Viewer (initiative premium-uncovered-features, E2; canvas EvInbox, HmAround). It replaces the Inbox
2
- * (the bell) and Around you.
1
+ /* pm/cozy-news.js — New for you, the whole list in the Viewer (initiative premium-uncovered-features, E2; canvas EvInbox, HmAround; since
2
+ * feedback batch 16 item 5b, canvas FmA2Day, it opens from the New for you fold of Your day: "N more", or one of its rows).
3
3
  *
4
4
  * For your information only: Mentions, Given to you, Finished while you were away (GET /api/news-for-you), and today's digests from the
5
5
  * morning brief (GET /api/briefing-premium). An item leaves once it is seen: the items shown are marked seen when the card closes, and
6
6
  * Mark all seen marks them at once (POST /api/news-for-you/seen). Open on a row shows the item: a mention with Make it a task, Mark read and
7
- * Open in its source; a task with its source; finished work opens where it waits. What Around you also showed has one home each, named
8
- * under "Where the rest went", and each line opens it (home-around.js keeps those views). The prep line Around you held (the meetings left
9
- * today and how many are prepped, GET /api/brief-page) sits under the head when a meeting is still ahead.
10
- * openNews({ go? }) → the body element */
7
+ * Open in its source; a task with its source; finished work opens where it waits. The page's meetings ring, its two legend cards, "Where
8
+ * the rest went" and the "Not here" note are gone (FmAudit: Your day holds the meetings, and a page that explains itself is chrome).
9
+ * openNews({ go?, view? }) → the body element; view: an item's id opens straight on that item */
11
10
  import { pmGet, pmPost } from './http.js';
12
11
  import { open as vwOpen, current as vwCurrent } from './cozy-viewer.js';
13
12
  import { esc, svg, ICON, toast, wsParam, wsQ, skelRows, cantRead, allClear } from './cozy-evui.js';
14
13
  import { initials, ago } from './cozy-evmodel.js';
15
14
 
16
15
  const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail' };
17
- const N = { r: null, dig: null, prep: '', view: '', body: null, shown: new Set(), madd: new Set(), mread: new Set(), busy: false };
16
+ const N = { r: null, dig: null, view: '', body: null, shown: new Set(), madd: new Set(), mread: new Set(), busy: false };
18
17
  const homeUrl = (params) => { const q = new URLSearchParams(params); if (wsParam()) q.set('ws', wsParam()); return '/premium.html?' + q.toString(); };
19
18
  const https = (u) => (/^https:\/\/\S+$/i.test(String(u || '')) ? u : '');
20
19
  /** The deep link of a finished item, as the bell's was: a My work item opens its dialog; anything else opens on Home. */
@@ -31,12 +30,6 @@ function rowHtml(it) {
31
30
  return `<div class="ev-trow" data-ev-id="${esc(it.id)}"><i class="ev-dot you" aria-hidden="true"></i>${av}<div class="ev-tx"><p><b>${esc(it.title)}</b></p><p class="ev-small ev-mut">${esc(sub)}</p></div>`
32
31
  + `<button type="button" class="ev-ib" data-ev-open="${esc(it.id)}" aria-label="Open: ${esc(it.title)}" title="Open">${svg(ICON.open, 16)}</button></div>`;
33
32
  }
34
- const REST = [
35
- ['pulse', 'Portfolio pulse', 'Intelligence, at the top. Home does not repeat it.'],
36
- ['rep', 'Found in your work', 'Intelligence · Reports and dashboards, at the top.'],
37
- ['prop', 'Proposals', 'the initiative’s next step, because they need an answer.'],
38
- ['scan', 'Scan now', 'Ask in chat: “scan for billing news”.'],
39
- ];
40
33
  function digHtml() {
41
34
  const d = N.dig; if (!d || !d.length) return '';
42
35
  return `<section id="aroundDig" class="ev-dig"><p class="ev-lbl">Digests ${d.length}</p>${d.map((e) => { const x = e.dialog || {}, p = x.pane || {}, l = https(x.link);
@@ -44,17 +37,14 @@ function digHtml() {
44
37
  }
45
38
  function listHtml() {
46
39
  const r = N.r;
47
- const head = `<div class="ev-head"><h2 class="ev-h2">New since this morning</h2>${r && r.ok && r.count ? '<button type="button" class="ev-btn sm ghost" data-ev-all>Mark all seen</button>' : ''}</div>`;
48
- const two = '<div class="ev-two"><div class="ev-box"><b>Initiatives</b> (left)<br><span class="ev-mut">Each shows its next step. It stays until you act.</span></div><div class="ev-box blue"><b>New for you</b> (here)<br><span class="ev-mut">For your information. It goes once you have seen it.</span></div></div>';
40
+ const head = `<div class="ev-head"><h2 class="ev-h2">New for you</h2>${r && r.ok && r.count ? '<button type="button" class="ev-btn sm ghost" data-ev-all>Mark all seen</button>' : ''}</div>`;
49
41
  let body;
50
42
  if (!r) body = skelRows(3) + '<p class="ev-small ev-mut">Reading what is new for you</p>';
51
43
  else if (!r.ok) body = cantRead({ what: 'New for you', why: r.error || '' });
52
44
  else if (!r.count) body = allClear('Nothing new since you last looked');
53
45
  else body = r.groups.map((g) => `<p class="ev-lbl">${esc(g.label)}</p>` + g.items.map(rowHtml).join('')).join('');
54
46
  const notRead = r && r.ok && r.read ? [['mentions', 'Mentions'], ['inbox', 'The agents\' results'], ['work', 'Your tasks']].filter(([k]) => r.read[k] === false).map(([, l]) => l) : [];
55
- const rest = `<p class="ev-lbl">Where the rest went</p><div class="ev-box ev-rest">${REST.map(([k, t, w]) => `<button type="button" data-ev-rest="${k}"><b>${esc(t)}</b><span>${esc(w)}</span></button>`).join('')}</div>`;
56
- const foot = '<div class="ev-foot"><div class="ev-box ev-small"><b>Not here, so nothing shows twice</b><br>A mention that asks you something, a passed review or a proposal becomes the next step of its initiative. A task given to you shows here once, then sits under its initiative. Goal trends live in Insights.</div></div>';
57
- return head + (N.prep || '') + two + body + (notRead.length ? `<p class="ev-small ev-mut" role="status">Not read: ${esc(notRead.join(', '))}.</p>` : '') + digHtml() + rest + foot;
47
+ return head + body + (notRead.length ? `<p class="ev-small ev-mut" role="status">Not read: ${esc(notRead.join(', '))}.</p>` : '') + digHtml();
58
48
  }
59
49
  function detailHtml(it) {
60
50
  const back = '<div class="ev-head"><button type="button" class="ev-btn sm ghost" data-ev-back>' + svg(ICON.back, 16) + 'New for you</button></div>';
@@ -78,8 +68,7 @@ function draw() {
78
68
  if (!it) for (const x of items()) N.shown.add(x.id);
79
69
  }
80
70
  async function read() {
81
- const [r, d, bp] = await Promise.all([pmGet('/api/news-for-you' + wsQ()), N.dig ? Promise.resolve(null) : pmGet('/api/briefing-premium' + wsQ()), pmGet('/api/brief-page' + wsQ())]);
82
- N.prep = bp && bp.ok !== false ? await import('./home-around.js').then((M) => M.prepHtmlOf(bp)).catch(() => '') : '';
71
+ const [r, d] = await Promise.all([pmGet('/api/news-for-you' + wsQ()), N.dig ? Promise.resolve(null) : pmGet('/api/briefing-premium' + wsQ())]);
83
72
  N.r = r && r.ok ? r : { ok: false, error: (r && r.error) || 'the server did not answer' };
84
73
  if (d && d.ok && d.model) { const T = d.model.today || {}; N.dig = [].concat(T.earlier || [], T.ahead || []).filter((e) => e && e.kind === 'digest'); }
85
74
  draw();
@@ -95,7 +84,7 @@ async function seen(ids) {
95
84
  }
96
85
 
97
86
  export function openNews(o = {}) {
98
- N.view = ''; N.shown = new Set();
87
+ N.view = o.view || ''; N.shown = new Set(o.view ? [o.view] : []);
99
88
  N.body = vwOpen({ id: 'news', kind: 'For your information', title: 'New for you', icon: ICON.news, render: (b) => { b.classList.add('ev-card-b', 'ev-news'); N.body = b; draw(); wire(b, o); },
100
89
  onClose: () => { const ids = [...N.shown]; N.shown = new Set(); seen(ids); } }); // an item leaves once seen: what the card showed is seen when it closes
101
90
  read();
@@ -105,7 +94,7 @@ function wire(b, o) {
105
94
  b.onclick = async (e) => {
106
95
  const t = e.target.closest('button'); if (!t || N.busy) return;
107
96
  if ('evRetry' in t.dataset) { N.r = null; draw(); read(); return; }
108
- if ('evSources' in t.dataset) { import('./cozy-sources.js').then((M) => M.openSources()); return; }
97
+ if ('evSources' in t.dataset) { import('./cozy-settings.js').then((M) => M.openSettings('connectors')); return; }
109
98
  if ('evBack' in t.dataset) { N.view = ''; draw(); const f = b.querySelector('[data-ev-open]'); if (f) f.focus(); return; }
110
99
  if ('evAll' in t.dataset) {
111
100
  N.busy = true; const ids = items().map((x) => x.id);
@@ -113,11 +102,6 @@ function wire(b, o) {
113
102
  if (!ok) { toast('It was not marked seen. The server did not answer.'); return; }
114
103
  N.shown = new Set(); toast('Marked seen.'); N.r = null; draw(); read(); return;
115
104
  }
116
- if (t.dataset.evRest) {
117
- const k = t.dataset.evRest;
118
- // each opens its view, so every press the old Around you held (keep, dismiss, Scan now, set up) is still one press away
119
- import('./home-around.js').then((M) => M.openAround(k)); return;
120
- }
121
105
  if (t.dataset.evOpen) {
122
106
  const it = items().find((x) => x.id === t.dataset.evOpen); if (!it) return;
123
107
  N.shown.add(it.id);
@@ -1,23 +1,30 @@
1
1
  /* pm/cozy-settings.js — Settings (initiative premium-uncovered-features, E3; canvas EvSettings). A dialog over the page, its sections on the left:
2
- * General Theme (this device), Viewer opens as a column or a popup (this device), Product (which products Home reads: the Products card),
3
- * Your day (when the end-of-day card shows: time.workEnd, POST /api/settings), Agents write to Jira (fixed: only after Commit)
2
+ * General Theme (this device; the place menu's Theme row moved here, feedback batch 16 item 5), Viewer opens as a column or a popup
3
+ * (this device), Product (which products Home reads: the Products card), Your day (when the end-of-day card shows:
4
+ * time.workEnd, POST /api/settings), Agents write to Jira (fixed: only after Commit)
4
5
  * Adler how much of Claude's face shows, Motion, Celebrations, Quiet after (adler.*, POST /api/settings; canvas AdM5, batch 16 item 2)
5
- * Connectors what PMOS reads on its own, and the connectors your sessions have (GET and POST /api/proactive/settings)
6
+ * Connectors each source's last read (GET /api/sources; was the Sources card, feedback batch 16 item 5, canvas FmA3Settings): the amber dot
7
+ * and ↻ Read again on a stale or failed one (POST /api/sources/refresh), ↻ in the header reads every source
8
+ * (POST /api/sources/refresh-all); then what PMOS reads on its own, and the connectors your sessions have (GET and POST
9
+ * /api/proactive/settings)
6
10
  * Workspaces the repositories PMOS works in (GET and POST /api/workspaces, POST /api/workspaces/forget; the folder is never touched)
7
11
  * Workflows a link to its own page, /premium-workflows.html (pm/wf-page.js, D99): the stages each kind of initiative goes through
8
12
  * Updates the versions and Check now, Update, Restart to update (GET /api/kit/status, POST /api/kit/check | update | upgrade-app)
9
13
  * What's new what each published kit changed, newest first (the kit status's changelog lines)
10
- * The card at the bottom of General says when an update is ready. Every write is the PM's press (pmPost carries the launch nonce).
14
+ * The card at the bottom of General says when an update is ready. While a source is stale, an amber box at the top of every section names
15
+ * it with ↻ Read again, and the place menu opens Settings at Connectors. Every write is the PM's press (pmPost carries the launch nonce).
16
+ * PMOS reads the sources and never posts to them.
11
17
  * openSettings(section?) */
12
18
  import { pmGet, pmPost } from './http.js';
13
- import { esc, svg, ICON, toast } from './cozy-evui.js';
19
+ import { esc, svg, ICON, toast, wsParam, wsQ } from './cozy-evui.js';
20
+ import { sourceRows, staleOf, partsOf } from './cozy-evmodel.js';
14
21
  import * as AD from './cozy-adler.js';
15
22
 
16
23
  const SECTIONS = [['general', 'General'], ['adler', 'Adler'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['workflows', 'Workflows'], ['updates', 'Updates'], ['whatsnew', "What's new"]];
17
24
  const PAGE_LINKS = { workflows: '/premium-workflows.html' }; // a section that is a page of its own: the row goes there
18
25
  const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
19
26
  const VIEWER_KEY = 'pmos.cz.viewer';
20
- const T = { el: null, sec: 'general', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null };
27
+ const T = { el: null, sec: 'general', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null, fresh: null, reading: '', note: {}, lines: null };
21
28
  const cmpVer = (a, b) => { const x = String(a || '0').split('-')[0].split('.').map(Number), y = String(b || '0').split('-')[0].split('.').map(Number); for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) < (y[i] || 0) ? -1 : 1; return 0; };
22
29
  const home = () => (T.ws && T.ws[0] ? T.st[T.ws[0].id] : null);
23
30
  const latest = () => { const s = home(); return (s && (s.latest || (s.lastCheck && s.lastCheck.latest))) || null; };
@@ -63,11 +70,36 @@ function adlerSec() {
63
70
  + trow('Quiet after', 'After this time, opening PMOS shows Adler asleep and nothing urgent.', seg('Quiet after', 'adler.quiet', P['adler.quiet'], [['22', '22:00'], ['never', 'Never']]));
64
71
  }
65
72
  const firstLine = () => { const c = changes().find((e) => e.v === latest()); const p = c && c.prs && c.prs[0]; return p ? (p.t || p.s || '') : ''; };
73
+ /* each source's last read (FmA3Settings): the name, "read 09:41", the amber dot and ↻ on a stale or failed one */
74
+ const RD = 'M20 12a8 8 0 1 1-2.3-5.7M20 4v5h-5';
75
+ const readBtn = (id, label, cls = 'ev-ib') => `<button type="button" class="${cls}" data-ev-read="${esc(id)}" aria-label="${esc(label)}" title="${esc(label)}"${T.reading ? ' disabled' : ''}>${svg(RD, 18)}</button>`;
76
+ function readsHtml() {
77
+ const s = T.fresh;
78
+ if (!s) return '<p class="ev-small ev-mut">Reading when each source was last read.</p>';
79
+ if (!s.ok) return `<p class="ev-small ev-mut">When each source was last read could not be read${s.error ? ': ' + esc(s.error) : ''}.</p>`;
80
+ const rows = sourceRows(s.sources).map((x) => `<div class="ev-trow ev-fr" data-src="${esc(x.id)}"><div class="ev-tx"><b>${esc(x.name)}</b>${T.note[x.id] ? `<p class="ev-small" role="status">${esc(T.note[x.id])}</p>` : ''}</div>`
81
+ + `${x.risk ? '<i class="ev-dot risk" aria-hidden="true"></i>' : ''}<span class="ev-small ${x.risk ? 'ev-late' : 'ev-mut'}">${esc(/^(Watching|Never read|Not connected|Reading now|Could not be read)$/.test(x.when) ? x.when : 'read ' + x.when)}</span>`
82
+ + `${x.act === 'read' ? readBtn(x.id, 'Read ' + x.name + ' again') : '<span class="ev-ib-sp" aria-hidden="true"></span>'}</div>`).join('');
83
+ // the background line (harness-health): quiet when all is well, a box when something needs a look
84
+ const hl = s.health && s.health.level;
85
+ const health = !s.health ? '' : hl === 'warn' || hl === 'bad'
86
+ ? `<div class="ev-box ev-small ev-line" id="srcHealth" data-level="${esc(hl)}" role="status"><i class="ev-dot risk" aria-hidden="true"></i><p class="ev-grow"><b>${esc(s.health.line)}</b>${(s.health.issues || []).slice(1, 4).map((i) => `<br>${esc(i.text)}`).join('')}</p></div>`
87
+ : `<p class="ev-small ev-mut ev-line" id="srcHealth" data-level="ok"><i class="ev-dot ok" aria-hidden="true"></i>${esc(s.health.line || '')}</p>`;
88
+ // which reads each part of Home shows (briefing-source-flow slice 5), in home-more.js readLine words
89
+ const L = T.lines ? [['Today', T.lines.readLine(s, ['calendar'])], ['Needs you', T.lines.readLine(s, ['initiatives', 'my-work', 'd:brief'])]].filter((x) => x[1]) : [];
90
+ return `${health}<div class="ev-reads">${rows}</div>${L.map(([k, v]) => `<p class="ev-small ev-mut ev-rl" data-reads="${esc(k)}"><b>${esc(k)}:</b> ${esc(v)}</p>`).join('')}`;
91
+ }
92
+ /** The amber box at the top of Settings while a source is stale (FmA3Settings): what is old, what it makes old, and ↻ Read again. */
93
+ function staleHtml() {
94
+ const st = T.fresh && T.fresh.ok ? staleOf(T.fresh.sources) : null;
95
+ if (!st) return '';
96
+ return `<div class="ev-warn ev-line ev-st-warn" id="srcWarn"><i class="ev-dot risk" aria-hidden="true"></i><p class="ev-grow"><b>${esc(st.state === 'stale' ? st.name + ' was last read ' + st.ago + '.' : st.text + '.')}</b> ${esc(partsOf(st.id))} may be out of date.</p>${readBtn(st.id, 'Read ' + st.name + ' again', 'ev-ib ev-ib-card')}</div>`;
97
+ }
66
98
  function connectors() {
67
- if (T.src === null) return '<p class="ev-small ev-mut">Reading the connectors.</p>';
99
+ if (T.src === null) return readsHtml() + '<p class="ev-small ev-mut">Reading the connectors.</p>';
68
100
  const brief = Object.keys(SRC).filter((k) => k in T.src).map((k) => trow(SRC[k], T.src[k] ? 'PMOS reads it on its own' : 'PMOS does not read it on its own', sw(T.src[k], `data-ev-src="${k}"`, SRC[k])));
69
101
  const more = T.conn.filter((c) => !c.source).map((c) => trow(c.label, T.con[c.name] ? 'On. Your sessions can use it' : 'Your sessions can use it', sw(T.con[c.name], `data-ev-conn="${esc(c.name)}"`, c.label)));
70
- return '<p class="ev-small ev-mut">Every connector your Claude session has. A switch chooses only what PMOS reads on its own. PMOS reads and never posts.</p>' + brief.join('') + more.join('');
102
+ return readsHtml() + '<p class="ev-small ev-mut">Every connector your Claude session has. A switch chooses only what PMOS reads on its own. PMOS reads and never posts.</p>' + brief.join('') + more.join('');
71
103
  }
72
104
  function workspaces() {
73
105
  if (T.ws === null) return '<p class="ev-small ev-mut">Reading the repositories.</p>';
@@ -100,9 +132,11 @@ function draw() {
100
132
  // a redraw replaces the nodes: keep focus on the same control (by its data-ev-* key), else on the open section, never on the body
101
133
  const ae = document.activeElement, had = ae && el.contains(ae), key = had ? [...ae.attributes].find((a) => a.name.startsWith('data-ev-')) : null;
102
134
  const n = { connectors: T.src === null ? '' : Object.keys(SRC).filter((k) => T.src[k]).length + T.conn.filter((c) => !c.source && T.con[c.name]).length, workspaces: T.ws ? T.ws.length : '', updates: ready() ? '<span class="ev-pill y">1</span>' : '' };
103
- el.querySelector('.ev-st-nav').innerHTML = '<h2 class="ev-h2">Settings</h2>' + SECTIONS.map(([k, l]) => PAGE_LINKS[k] ? `<a href="${PAGE_LINKS[k]}" class="ev-mi">${esc(l)}</a>` : `<a href="#${k}" class="ev-mi" data-ev-sec="${k}"${T.sec === k ? ' aria-current="page"' : ''}>${esc(l)}${n[k] !== undefined && n[k] !== '' ? `<span class="ev-k">${typeof n[k] === 'number' ? n[k] : n[k]}</span>` : ''}</a>`).join('');
135
+ const stale = T.fresh && T.fresh.ok ? staleOf(T.fresh.sources) : null;
136
+ el.querySelector('.ev-st-nav').innerHTML = '<h2 class="ev-h2">Settings</h2>' + SECTIONS.map(([k, l]) => PAGE_LINKS[k] ? `<a href="${PAGE_LINKS[k]}" class="ev-mi">${esc(l)}</a>` : `<a href="#${k}" class="ev-mi" data-ev-sec="${k}"${T.sec === k ? ' aria-current="page"' : ''}>${esc(l)}${k === 'connectors' && stale ? '<i class="ev-dot risk" aria-label="A source is stale" role="img"></i>' : ''}${n[k] !== undefined && n[k] !== '' ? `<span class="ev-k">${typeof n[k] === 'number' ? n[k] : n[k]}</span>` : ''}</a>`).join('');
104
137
  const label = (SECTIONS.find((x) => x[0] === T.sec) || SECTIONS[0])[1];
105
- el.querySelector('.ev-st-main').innerHTML = `<div class="ev-top"><h3 class="ev-h2" id="evStTitle">${esc(label)}</h3><button type="button" class="ev-ib" data-ev-close aria-label="Close settings" title="Close settings">${svg(ICON.close, 18)}</button></div>`
138
+ const all = T.sec === 'connectors' ? `<button type="button" class="ev-ib" data-ev-readall aria-label="Read every source again" title="Read all again"${T.reading ? ' disabled' : ''}>${svg(RD, 18)}</button>` : '';
139
+ el.querySelector('.ev-st-main').innerHTML = staleHtml() + `<div class="ev-top"><h3 class="ev-h2" id="evStTitle">${esc(label)}</h3>${all}<button type="button" class="ev-ib" data-ev-close aria-label="Close settings" title="Close settings">${svg(ICON.close, 18)}</button></div>`
106
140
  + BODY[T.sec]() + `<p role="status">${esc(T.msg)}</p>`;
107
141
  if (had && !ae.isConnected) { const f = (key && el.querySelector(`[${key.name}="${CSS.escape(key.value)}"]`)) || el.querySelector('[aria-current="page"]'); if (f) f.focus(); }
108
142
  }
@@ -141,6 +175,7 @@ async function press(e) {
141
175
  PP.openPicker(t, { P, label: 'Products', onApply: async (on) => { const r = await PP.savePick(on); if (!r.ok) { T.msg = r.error; draw(); return; } T.prods = r.products; draw(); } });
142
176
  return;
143
177
  }
178
+ if (t.dataset.evRead || 'evReadall' in t.dataset) { readAgain(t.dataset.evRead || ''); return; }
144
179
  if (T.busy) return;
145
180
  T.busy = true; T.msg = '';
146
181
  try {
@@ -189,7 +224,29 @@ async function waitRestart(from, log) {
189
224
  }
190
225
  T.phase = ''; T.msg = 'PMOS did not come back on this address. Type pmos in a terminal to open it. The update log is ' + log + '.'; draw();
191
226
  }
227
+ /** GET /api/sources: when each source was last read. The place menu's amber dot follows (the event pm:sources). */
228
+ async function readFresh() {
229
+ if (!T.lines) T.lines = await import('./home-more.js').catch(() => null);
230
+ const r = await pmGet('/api/sources' + wsQ());
231
+ T.fresh = r && r.ok !== false ? r : { ok: false, error: (r && r.error) || 'the server did not answer' };
232
+ if (T.fresh.ok) window.dispatchEvent(new CustomEvent('pm:sources', { detail: T.fresh }));
233
+ draw();
234
+ }
235
+ /** ↻ on a source reads it again (POST /api/sources/refresh); ↻ in the Connectors header reads every source (POST /api/sources/refresh-all). */
236
+ async function readAgain(id) {
237
+ if (T.reading) return;
238
+ const ws = (T.fresh && T.fresh.ws) || wsParam() || '';
239
+ T.reading = id || 'all'; draw();
240
+ const r = await pmPost(id ? '/api/sources/refresh' : '/api/sources/refresh-all', id ? { ws, source: id } : { ws });
241
+ T.reading = '';
242
+ if (id) {
243
+ T.note[id] = r && r.ok ? (r.started === 'session' ? 'An agent session started to read it, with your own connection.' : 'Reading it again on this machine.') : 'It did not start: ' + ((r && r.error) || 'the server did not answer') + '.';
244
+ toast(r && r.ok ? 'Reading again.' : T.note[id]);
245
+ } else toast(r && r.ok ? (r.joined ? 'Every source is already being read.' : 'Reading every source, then Home\'s list.') : 'Read all again did not start: ' + ((r && r.error) || 'the server did not answer') + '.');
246
+ await readFresh(); setTimeout(readFresh, 4000);
247
+ }
192
248
  async function load() {
249
+ readFresh();
193
250
  const [w, p, s, b] = await Promise.all([pmGet('/api/workspaces'), pmGet('/api/proactive/settings'), pmGet('/api/settings'), pmGet('/api/briefing-premium')]);
194
251
  T.ws = w && Array.isArray(w.workspaces) ? w.workspaces : [];
195
252
  T.src = p && p.ok && p.settings ? { ...p.settings.briefSources } : {}; T.con = p && p.ok && p.settings ? { ...p.settings.connectors } : {};
@@ -205,7 +262,7 @@ async function load() {
205
262
  export function openSettings(section) {
206
263
  const el = mount();
207
264
  if (section && BODY[section]) T.sec = section;
208
- if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; }
265
+ if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.fresh = null; T.note = {}; }
209
266
  el.hidden = false; document.getElementById('evStScrim').hidden = false; el.setAttribute('data-esc-layer', '');
210
267
  draw();
211
268
  const f = el.querySelector('[aria-current="page"]'); if (f) f.focus();