create-pmos 0.398.0 → 0.399.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.
- package/package.json +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +18 -14
- package/workspace/briefing-premium-board-test.js +80 -48
- package/workspace/briefing-premium-calendar-2-test.js +36 -36
- package/workspace/briefing-premium-calendar-3-test.js +39 -39
- package/workspace/briefing-premium-calendar-test.js +23 -24
- package/workspace/briefing-premium-doc-edit-test.js +6 -2
- package/workspace/briefing-premium-initiative-test.js +38 -16
- package/workspace/briefing-premium-insights-test.js +114 -37
- package/workspace/briefing-premium-metrics-test.js +6 -4
- package/workspace/briefing-premium-products-test.js +10 -7
- package/workspace/briefing-premium-sources-test.js +25 -22
- package/workspace/briefing-premium-test.js +46 -42
- package/workspace/briefing-premium-work-test.js +9 -9
- package/workspace/changelog.json +12 -0
- package/workspace/ev-everywhere-test.js +210 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
- package/workspace/guide/home.md +39 -18
- package/workspace/guide/index.md +1 -1
- package/workspace/lib/board-grill.js +63 -0
- package/workspace/lib/board-premium.js +36 -5
- package/workspace/lib/initiative-layout.js +77 -0
- package/workspace/lib/insights-premium.js +3 -2
- package/workspace/lib/insights-records.js +21 -7
- package/workspace/lib/meeting-points.js +52 -0
- package/workspace/lib/news-for-you.js +88 -0
- package/workspace/lib/notes-series.js +29 -6
- package/workspace/lib/report-confirm.js +48 -0
- package/workspace/lib/route-modules.js +8 -0
- package/workspace/lib/routes-board-docs.js +46 -0
- package/workspace/lib/routes-board-grill.js +90 -0
- package/workspace/lib/routes-home-review.js +108 -0
- package/workspace/lib/routes-initiative-layout.js +57 -0
- package/workspace/lib/routes-insights-premium.js +4 -1
- package/workspace/lib/routes-insights-records.js +8 -4
- package/workspace/lib/routes-meeting-points.js +37 -0
- package/workspace/lib/routes-news.js +57 -0
- package/workspace/lib/routes-notes.js +2 -1
- package/workspace/lib/routes-report-confirm.js +31 -0
- package/workspace/lib/routes-search.js +38 -0
- package/workspace/lib/search-index.js +176 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +86 -50
- package/workspace/premium-briefing-depth-test.js +55 -54
- package/workspace/premium-chat-chart-tab-test.js +4 -2
- package/workspace/premium-chat-report-tab-test.js +16 -2
- package/workspace/premium-core-doc-issue-test.js +15 -13
- package/workspace/premium-phone-card-test.js +5 -3
- package/workspace/premium-report-read-test.js +55 -18
- package/workspace/premium-vw-backlog-test.js +2 -2
- package/workspace/premium-vw-cal-test.js +50 -35
- package/workspace/premium-vw-doc-test.js +9 -3
- package/workspace/premium-vw-item-test.js +1 -1
- package/workspace/premium-vw-jira-test.js +2 -2
- package/workspace/premium-vw-meet-test.js +37 -40
- package/workspace/premium-vw-notes-test.js +21 -19
- package/workspace/premium-vw-rec-test.js +11 -12
- package/workspace/premium-welcome-test.js +3 -3
- package/workspace/premium-work-depth-test.js +3 -3
- package/workspace/public/pm/bd-acts.js +303 -225
- package/workspace/public/pm/bd-asks.js +261 -0
- package/workspace/public/pm/bd-pop.js +59 -0
- package/workspace/public/pm/bd-span.js +49 -13
- package/workspace/public/pm/bd-views.js +169 -0
- package/workspace/public/pm/cozy-board.css +301 -0
- package/workspace/public/pm/cozy-ev.css +228 -0
- package/workspace/public/pm/cozy-evmodel.js +106 -0
- package/workspace/public/pm/cozy-evui.js +47 -0
- package/workspace/public/pm/cozy-insights.css +148 -10
- package/workspace/public/pm/cozy-nav.js +103 -39
- package/workspace/public/pm/cozy-news.js +140 -0
- package/workspace/public/pm/cozy-search.js +203 -0
- package/workspace/public/pm/cozy-settings.js +198 -0
- package/workspace/public/pm/cozy-sources.js +89 -0
- package/workspace/public/pm/cozy-today.css +217 -0
- package/workspace/public/pm/cozy-viewer.js +1 -0
- package/workspace/public/pm/cozy-vw-mtg.css +350 -0
- package/workspace/public/pm/cozy-vw-rp.css +152 -0
- package/workspace/public/pm/home-adddoc.js +5 -5
- package/workspace/public/pm/home-app.js +329 -55
- package/workspace/public/pm/home-around.js +24 -126
- package/workspace/public/pm/home-chat.js +67 -14
- package/workspace/public/pm/home-data.js +6 -6
- package/workspace/public/pm/home-dictate.js +54 -0
- package/workspace/public/pm/home-draft.js +6 -6
- package/workspace/public/pm/home-ini-model.js +190 -0
- package/workspace/public/pm/home-ini.css +171 -0
- package/workspace/public/pm/home-ini.js +456 -0
- package/workspace/public/pm/home-list.js +276 -0
- package/workspace/public/pm/home-more.js +17 -134
- package/workspace/public/pm/home-phone-card.js +4 -4
- package/workspace/public/pm/home-review.js +104 -0
- package/workspace/public/pm/home-task.js +67 -0
- package/workspace/public/pm/home-today.js +144 -0
- package/workspace/public/pm/home-work.js +54 -26
- package/workspace/public/pm/premium-board.js +163 -39
- package/workspace/public/pm/premium-chart-tab.js +4 -5
- package/workspace/public/pm/premium-first.js +5 -7
- package/workspace/public/pm/premium-insights.js +499 -202
- package/workspace/public/pm/premium-mtg-present.js +138 -0
- package/workspace/public/pm/premium-mtg-replay.js +142 -0
- package/workspace/public/pm/premium-report-read.js +216 -52
- package/workspace/public/pm/premium-report-tab.js +44 -19
- package/workspace/public/pm/premium-shell.js +7 -7
- package/workspace/public/pm/premium-vw-cal.js +150 -60
- package/workspace/public/pm/premium-vw-mtg.js +488 -261
- package/workspace/public/pm/premium-vw-notes.js +61 -0
- package/workspace/public/pm/rp-parts.js +269 -0
- package/workspace/public/premium-board.html +4 -3
- package/workspace/public/premium-insights.html +10 -10
- package/workspace/public/premium.html +3 -1
- package/workspace/r/m1.png +0 -0
- package/workspace/r/m2.png +0 -0
- package/workspace/r/m3.png +0 -0
- package/workspace/r/nl.png +0 -0
- package/workspace/test-lists/initiative-layout.json +9 -0
- package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
- package/workspace/test-lists/premium-uncovered-reports.json +9 -0
- package/workspace/test-lists/uf-everywhere.json +15 -0
- package/workspace/test-lists/uf-home.json +9 -0
- package/workspace/test-lists/uncovered-board.json +9 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/* pm/home-list.js — Home's one list, pure (initiative premium-uncovered-features, H1 and H2; canvas HmMyWork, HmReview, HmProducts, HmDay,
|
|
2
|
+
* HmDecide, HmMic, HmPhone, HmPhone2).
|
|
3
|
+
*
|
|
4
|
+
* There is no Needs you group and no Your list (PM, canvas review 2026-10-22/23): every next step sits under its initiative, and the list is
|
|
5
|
+
* grouped by product. This file turns what the routes answer into what the list draws, and touches no page, so a node test imports it:
|
|
6
|
+
* productsOf(D) the products the list shows: the board's own first, then every product Home reads (GET /api/briefing-premium products)
|
|
7
|
+
* and every product a next step names; each with its goals line ("2 of 4 goals on track")
|
|
8
|
+
* homeList(D, o) { greet, yours, filters, groups, untouched, filter } for the list column
|
|
9
|
+
* todayCard(D, o) the Today card through the day: day (greeting and the day's load), soon (a meeting in 15 minutes or less), live
|
|
10
|
+
* (a meeting on now), rec (a recording that is no calendar meeting), eod (the end of a day with something open), clear
|
|
11
|
+
* staleInis(D, now, days) open initiatives with no change for `days` days or more, the longest first
|
|
12
|
+
* reviewModel(D, now) the weekly review's four steps, from the My work model, the stale initiatives and the review log (GET /api/home-review)
|
|
13
|
+
* fileUnder(text, inis) the initiative a typed task names (its title or id in the text), or null: the task then goes on the PM's own list
|
|
14
|
+
* D is home-data.js's D plus { work (GET /api/my-work-premium model), items (GET /api/boards/items), others ([{ ws, name, model }], the boards of
|
|
15
|
+
* the other products), phoneDay (GET /api/phone-day), review (GET /api/home-review) }. A part that did not answer is left out, never guessed. */
|
|
16
|
+
import { needsOf, boardRows, productCard, productName, sessionRow, iniOfSession, todayOf, live, OPEN, hm } from './home-data.js';
|
|
17
|
+
|
|
18
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
|
+
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
20
|
+
const RANK = { needs: 4, blocked: 3, working: 2, quiet: 1 };
|
|
21
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
22
|
+
const cap1 = (s) => (s ? String(s).charAt(0).toUpperCase() + String(s).slice(1) : '');
|
|
23
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
24
|
+
const isoDay = (ms) => { const d = new Date(ms); return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()); };
|
|
25
|
+
const dayDiff = (iso, now) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return null; const a = new Date(+m[1], +m[2] - 1, +m[3]); const t = new Date(now); t.setHours(0, 0, 0, 0); return Math.round((a - t) / 86400000); };
|
|
26
|
+
const shortDay = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
27
|
+
export const REVIEW_DAY = 5; // Friday
|
|
28
|
+
export const STALE_DAYS = 14;
|
|
29
|
+
|
|
30
|
+
/* ── the greeting ── */
|
|
31
|
+
export function greetWord(now = Date.now()) { const h = new Date(now).getHours(); return h < 12 ? 'Good morning' : h < 18 ? 'Good afternoon' : 'Good evening'; }
|
|
32
|
+
/** "Good morning. 2 next steps are yours today." */
|
|
33
|
+
export function greeting(n, now = Date.now()) {
|
|
34
|
+
return greetWord(now) + '. ' + (n ? plural(n, 'next step is', 'next steps are') + ' yours today.' : 'No next step is yours today.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* ── products ── */
|
|
38
|
+
const initialsOf = (name) => { const w = String(name || '').trim().split(/[\s_-]+/).filter(Boolean); return (w.length > 1 ? w[0][0] + w[1][0] : String(name || '?').slice(0, 2)).toUpperCase(); };
|
|
39
|
+
function goalsOf(model) {
|
|
40
|
+
const C = productCard({ board: model });
|
|
41
|
+
const n = C.items.length, ok = C.items.filter((x) => x.kind === 'ok').length;
|
|
42
|
+
return { ok, n, text: n ? ok + ' of ' + n + ' goals on track' : 'No goal anchored yet' };
|
|
43
|
+
}
|
|
44
|
+
/* A row the brief tags "Across products" names no product: it is not a group of its own, it sits with the rows that name none. */
|
|
45
|
+
const ACROSS = 'Across products';
|
|
46
|
+
const prodOf = (x) => (x && x.product && x.product !== ACROSS ? x.product : '');
|
|
47
|
+
/** The products the list shows, the board's own product first. Each: { key, ws, name, initials, primary, model, goals, on }. */
|
|
48
|
+
export function productsOf(D) {
|
|
49
|
+
const out = [];
|
|
50
|
+
const add = (p) => { const k = p.ws || 'n:' + String(p.name).toLowerCase(); if (out.some((x) => x.key === k || x.name.toLowerCase() === String(p.name).toLowerCase())) return; out.push({ ...p, key: k, initials: initialsOf(p.name) }); };
|
|
51
|
+
const b = D.board && D.board.board;
|
|
52
|
+
const av = (D.brief && D.brief.products && D.brief.products.available) || [];
|
|
53
|
+
const named = (ws) => ((ws && av.find((a) => a.ws === ws)) || {}).name || '';
|
|
54
|
+
if (D.board) add({ ws: (b && b.ws) || '', name: (b && b.product) || named(b && b.ws) || productName(D), primary: true, model: D.board, goals: goalsOf(D.board) });
|
|
55
|
+
for (const o of D.others || []) if (o && o.model) add({ ws: o.ws, name: o.name || productName({ board: o.model }), primary: false, model: o.model, goals: goalsOf(o.model) });
|
|
56
|
+
for (const a of av) if (a.on) add({ ws: a.ws, name: a.name, primary: false, model: null, goals: null });
|
|
57
|
+
for (const r of needsOf(D)) if (prodOf(r)) add({ ws: '', name: r.product, primary: false, model: null, goals: null });
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ── rows ── */
|
|
62
|
+
function taskHint(t, now, mine) {
|
|
63
|
+
const d = t.end ? dayDiff(t.end, now) : null;
|
|
64
|
+
const when = d == null ? '' : d === 0 ? 'due today' : d === 1 ? 'due tomorrow' : d < 0 ? plural(-d, 'day', 'days') + ' late' : 'due ' + shortDay(t.end);
|
|
65
|
+
if (!mine) return ['Waiting on ' + (/^agent:/.test(String(t.owner)) ? 'an agent' : t.owner), when].filter(Boolean).join(' · ');
|
|
66
|
+
return ['Task', t.status && t.status !== 'To do' ? t.status : '', when].filter(Boolean).join(' · ');
|
|
67
|
+
}
|
|
68
|
+
/** The PMOS tasks of an initiative that are not done: the PM's first, then the ones that wait on someone else. */
|
|
69
|
+
export function tasksOf(D, ini, now = Date.now()) {
|
|
70
|
+
const me = String((D.today && D.today.me) || '').toLowerCase();
|
|
71
|
+
const items = ((D.items && D.items.items) || []).filter((t) => t && t.src === 'pmos' && t.kind !== 'Epic' && t.ini === ini && t.status !== 'Done');
|
|
72
|
+
return items.map((t) => {
|
|
73
|
+
const ow = String(t.owner || '').toLowerCase();
|
|
74
|
+
const mine = !ow || /^(pm|you)(:|$)/.test(ow) || (!!me && (ow === me || ow.startsWith(me + ' ')));
|
|
75
|
+
return { id: 't:' + t.uid, kind: 'task', ini, name: t.title, hint: taskHint(t, now, mine), state: mine ? 'quiet' : 'wait', mine, due: t.end || '', late: !!(t.end && dayDiff(t.end, now) < 0), task: t };
|
|
76
|
+
}).sort((a, b) => (b.mine - a.mine) || String(a.due).localeCompare(String(b.due)));
|
|
77
|
+
}
|
|
78
|
+
function meetRow(m, ini) {
|
|
79
|
+
return { id: 'm:' + (m.id || m.title), kind: 'meeting', ini: ini || null, name: m.title, hint: (m.state === 'now' ? 'Now' : hm(m.start)) + (ini ? ' meeting' : ' · not linked'), state: m.state === 'now' ? 'working' : 'quiet', icon: 'clock', meeting: m };
|
|
80
|
+
}
|
|
81
|
+
/** Today's unread mentions of the PM (GET /api/brief-page mentions). One that names an initiative is that initiative's next step. */
|
|
82
|
+
const mentionsOf = (D) => (D.today && Array.isArray(D.today.mentions) ? D.today.mentions : []).filter((m) => m && !m.read && !m.done);
|
|
83
|
+
function mentionRow(m, ini) {
|
|
84
|
+
return { id: 'men:' + (m.id || m.at), kind: 'mention', ini: ini || null, name: (m.who ? m.who + ' ' : '') + (m.text ? 'asks: ' + m.text : 'named you'),
|
|
85
|
+
hint: (ini ? 'Next step · ' : '') + 'Mention' + (m.where ? ' · ' + m.where : m.source ? ' · ' + cap1(m.source) : ''), state: 'needs', mention: m, link: m.link || '', step: !!ini };
|
|
86
|
+
}
|
|
87
|
+
const meetIni = (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null;
|
|
88
|
+
/** A next step's hint without its product's name: the product is the group's header. */
|
|
89
|
+
const bareHint = (x) => { const h = String(x.hint || ''), p = prodOf(x); return p && h.startsWith(p + ' · ') ? h.slice(p.length + 3) : p && h === p ? '' : h; }; // the group names the product; "Across products" stays
|
|
90
|
+
function iniRowOf(D, r, needs, now) {
|
|
91
|
+
const steps = needs.filter((x) => x.ini === r.id && !x.needSession).map((x) => ({ ...x, step: true, hint: 'Next step' + (bareHint(x) ? ' · ' + bareHint(x) : '') }))
|
|
92
|
+
.concat(mentionsOf(D).filter((m) => m.initiative === r.id).map((m) => mentionRow(m, r.id)));
|
|
93
|
+
const ses = (D.sessions || []).filter((s) => live(s) && iniOfSession(s) === r.id).map((s) => sessionRow(s, D.desk && D.desk.roles));
|
|
94
|
+
const tasks = tasksOf(D, r.id, now);
|
|
95
|
+
const meet = todayOf(D).filter((m) => meetIni(m) === r.id && m.state !== 'past').map((m) => meetRow(m, r.id));
|
|
96
|
+
const turn = steps.length > 0 || ses.some((s) => s.state === 'needs' || s.state === 'blocked');
|
|
97
|
+
const mine = tasks.filter((t) => t.mine).length;
|
|
98
|
+
const run = ses.filter((s) => s.state === 'working').length;
|
|
99
|
+
const right = turn ? 'your turn' + (mine ? ' · ' + plural(mine, 'task', 'tasks') : '') : mine ? plural(mine, 'task', 'tasks') : run ? run + ' running' : 'Nothing today';
|
|
100
|
+
const kids = [...steps, ...ses.sort((a, b) => (RANK[b.state] || 0) - (RANK[a.state] || 0)), ...tasks, ...meet];
|
|
101
|
+
const hint = r.made ? [cap1(r.lane), r.stage].filter(Boolean).join(' · ') : [cap1(r.lane || 'feature'), r.stage].filter(Boolean).join(' · ');
|
|
102
|
+
return { id: 'i:' + r.id, kind: 'ini', ini: r.id, name: r.title, hint, right, turn, busy: kids.length > 0, state: turn ? 'needs' : run ? 'working' : 'quiet', kids, board: r, updated: r.updated || '' };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* ── the list ── */
|
|
106
|
+
const sameName = (a, b) => String(a || '').toLowerCase() === String(b || '').toLowerCase();
|
|
107
|
+
/** o: { filter ('today' | 'waiting' | 'kept' | 'done'), product (a product key, or null for all), now } */
|
|
108
|
+
export function homeList(D, o = {}) {
|
|
109
|
+
const now = o.now || D.now || Date.now();
|
|
110
|
+
const needs = needsOf(D);
|
|
111
|
+
const products = productsOf(D);
|
|
112
|
+
const primary = products.find((p) => p.primary) || null;
|
|
113
|
+
const used = new Set();
|
|
114
|
+
const W = D.work || null;
|
|
115
|
+
const tab = (k) => ((W && W.queue && W.queue.tabs) || []).find((t) => t.key === k) || null;
|
|
116
|
+
const tabRows = (k) => { const t = tab(k); return t ? t.groups.flatMap((g) => g.rows || []) : []; };
|
|
117
|
+
const filters = [
|
|
118
|
+
{ key: 'today', label: 'Today' },
|
|
119
|
+
{ key: 'waiting', label: 'Waiting', n: W && W.waiting ? W.waiting.rows.length : 0 },
|
|
120
|
+
{ key: 'kept', label: 'Kept', n: (tab('kept') || {}).n || 0 },
|
|
121
|
+
{ key: 'done', label: 'Done' },
|
|
122
|
+
];
|
|
123
|
+
const groups = [];
|
|
124
|
+
for (const p of products) {
|
|
125
|
+
if (o.product && o.product !== p.key) continue;
|
|
126
|
+
const rows = (p.model && p.model.initiatives && p.model.initiatives.list && p.model.initiatives.list.rows) || (p.primary ? boardRows(D) : []);
|
|
127
|
+
const open = rows.filter(OPEN);
|
|
128
|
+
const ids = new Set(open.map((r) => r.id));
|
|
129
|
+
const mineNeeds = needs.filter((x) => (x.ini && ids.has(x.ini)) || (p.primary ? x.ini === 'product' || (!x.ini && !prodOf(x) && !x.needSession) || (prodOf(x) && sameName(prodOf(x), p.name)) : prodOf(x) && sameName(prodOf(x), p.name)));
|
|
130
|
+
mineNeeds.forEach((x) => used.add(x.id));
|
|
131
|
+
// a next step whose initiative is not an open row of the board (a prototype, a record the board does not list) still sits under that
|
|
132
|
+
// initiative, never loose under the product (canvas HmMyWork): the initiative's row is made from the step's own subject
|
|
133
|
+
const extra = new Map();
|
|
134
|
+
for (const x of mineNeeds) if (x.ini && x.ini !== 'product' && !ids.has(x.ini) && !x.needSession && !extra.has(x.ini)) extra.set(x.ini, { id: x.ini, title: (x.row && x.row.subject) || x.ini, lane: (x.row && x.row.lane) || '', stage: (x.row && x.row.stage) || '', made: true });
|
|
135
|
+
for (const id of extra.keys()) ids.add(id);
|
|
136
|
+
const inis = open.concat([...extra.values()]).map((r) => iniRowOf(D, r, mineNeeds, now));
|
|
137
|
+
inis.sort((a, b) => (b.turn - a.turn) || (b.busy - a.busy) || (RANK[b.state] || 0) - (RANK[a.state] || 0));
|
|
138
|
+
// the product's own next steps (its weekly update, a decision with no initiative) sit under its header, before the initiatives
|
|
139
|
+
const flat = mineNeeds.filter((x) => !x.ini || !ids.has(x.ini)).filter((x) => !x.needSession).map((x) => ({ ...x, flat: true, hint: bareHint(x) }));
|
|
140
|
+
const turnN = inis.filter((x) => x.turn).length + flat.length;
|
|
141
|
+
const shown = inis.filter((x) => x.turn || x.busy);
|
|
142
|
+
groups.push({ key: 'p:' + p.key, kind: 'product', product: p, name: p.name, primary: !!p.primary, goals: p.goals, flat, inis: shown, rest: inis.filter((x) => !shown.includes(x)),
|
|
143
|
+
count: inis.length, turnN, closedLine: [inis.length ? plural(inis.length, 'initiative', 'initiatives') : '', turnN ? turnN + ' your turn' : ''].filter(Boolean).join(' · ') || 'Nothing open' });
|
|
144
|
+
}
|
|
145
|
+
// sessions that wait on the PM and belong to no initiative of a product: they are next steps too, under "Not in an initiative"
|
|
146
|
+
const looseNeeds = needs.filter((x) => !used.has(x.id) && !(x.ini && groups.some((g) => g.inis.concat(g.rest).some((i) => i.ini === x.ini))));
|
|
147
|
+
const loose = [];
|
|
148
|
+
for (const x of looseNeeds) loose.push({ ...x, flat: true });
|
|
149
|
+
for (const r of tabRows('today')) loose.push({ id: 'w:' + r.key, kind: 'item', key: r.key, name: r.title, hint: [r.overdue ? 'late' : '', r.sub ? r.sub.replace(/^Yours\b/, 'your own note') : 'your own note'].filter(Boolean).join(' · '), check: true, item: r });
|
|
150
|
+
const inIni = new Set(groups.flatMap((g) => g.inis.concat(g.rest)).map((i) => i.ini));
|
|
151
|
+
for (const m of mentionsOf(D).filter((x) => !(x.initiative && inIni.has(x.initiative)))) loose.push(mentionRow(m, null));
|
|
152
|
+
for (const m of todayOf(D).filter((x) => !meetIni(x) && x.state !== 'past')) loose.push(meetRow(m, null));
|
|
153
|
+
for (const s of (D.sessions || []).filter((s) => live(s) && !iniOfSession(s) && s.shown !== 'needs' && s.shown !== 'blocked')) loose.push({ ...sessionRow(s, D.desk && D.desk.roles), loose: true });
|
|
154
|
+
if (!o.product || o.product === 'loose') groups.push({ key: 'loose', kind: 'loose', name: 'Not in an initiative', rows: loose, n: loose.length });
|
|
155
|
+
const stale = staleInis(D, now);
|
|
156
|
+
const untouched = { n: stale.length + ((W && W.review && W.review.n) || 0), inis: stale.length, items: (W && W.review && W.review.n) || 0, day: new Date(now).getDay() === REVIEW_DAY ? 'today' : 'Fri' };
|
|
157
|
+
// a filter other than Today shows one plain list from the PM's own list (the items carry no initiative)
|
|
158
|
+
let list = null;
|
|
159
|
+
if (o.filter === 'waiting') list = { title: 'Waiting on others', rows: (W && W.waiting ? W.waiting.rows : []).map((r) => ({ id: 'w:' + r.key, kind: 'item', key: r.key, name: r.title, hint: r.sub || '', state: 'wait', item: r })), empty: 'Nobody owes you anything.' };
|
|
160
|
+
if (o.filter === 'kept') list = { title: 'Kept for later', rows: tabRows('kept').map((r) => ({ id: 'w:' + r.key, kind: 'item', key: r.key, name: r.title, hint: r.sub || '', check: true, item: r })), empty: 'Nothing is kept for later.' };
|
|
161
|
+
if (o.filter === 'done') {
|
|
162
|
+
const done = tabRows('done').map((r) => ({ id: 'w:' + r.key, kind: 'item', key: r.key, name: r.title, hint: r.sub || 'Done', done: true, item: r }));
|
|
163
|
+
const fin = (D.phoneDay && D.phoneDay.finished) || [];
|
|
164
|
+
for (const f of fin) done.push({ id: 'fin:' + (f.id || f.title), kind: 'finished', name: f.title, hint: f.status === 'review' ? 'Finished · waits for your review' : 'Finished', done: true, finished: f });
|
|
165
|
+
list = { title: 'Done today', rows: done, empty: 'Nothing is done yet today.' };
|
|
166
|
+
}
|
|
167
|
+
const yours = needs.length + mentionsOf(D).filter((m) => m.initiative && groups.some((g) => g.inis.concat(g.rest || []).some((i) => i.ini === m.initiative))).length;
|
|
168
|
+
const nIni = groups.filter((g) => g.kind === 'product').reduce((n, g) => n + g.count, 0);
|
|
169
|
+
return { yours, greet: greeting(yours, now), products, primary, filters, filter: o.filter || 'today', groups, list, untouched,
|
|
170
|
+
counts: { products: products.length, initiatives: nIni } };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* ── the Today card through the day ── */
|
|
174
|
+
const DAY_FROM = 9, DAY_TO = 18;
|
|
175
|
+
/** The day's load bar from 09 to 18: free and meeting stretches, the meeting on now marked. { segs: [{ flex, m, now }], sub } */
|
|
176
|
+
export function dayLoad(today, now = Date.now()) {
|
|
177
|
+
const L = (Array.isArray(today) ? today : []).filter((m) => m && m.start).map((m) => ({ m, a: Date.parse(m.start), b: m.end ? Date.parse(m.end) : Date.parse(m.start) + (m.minutes || 30) * 60000 })).filter((x) => !Number.isNaN(x.a)).sort((x, y) => x.a - y.a);
|
|
178
|
+
const d0 = new Date(now); d0.setHours(DAY_FROM, 0, 0, 0); const d1 = new Date(now); d1.setHours(DAY_TO, 0, 0, 0);
|
|
179
|
+
const segs = []; let at = d0.getTime();
|
|
180
|
+
for (const x of L) {
|
|
181
|
+
const a = Math.max(x.a, at), b = Math.min(x.b, d1.getTime());
|
|
182
|
+
if (b <= a) continue;
|
|
183
|
+
if (a > at) segs.push({ flex: Math.round((a - at) / 60000), m: false });
|
|
184
|
+
segs.push({ flex: Math.round((b - a) / 60000), m: true, now: x.m.state === 'now' });
|
|
185
|
+
at = b;
|
|
186
|
+
}
|
|
187
|
+
if (at < d1.getTime()) segs.push({ flex: Math.round((d1.getTime() - at) / 60000), m: false });
|
|
188
|
+
const mins = L.reduce((n, x) => n + Math.max(0, Math.round((x.b - x.a) / 60000)), 0);
|
|
189
|
+
const dur = mins >= 60 ? (Math.round(mins / 30) / 2).toString().replace(/\.0$/, '') + ' h' : mins + ' min';
|
|
190
|
+
const sub = L.length ? plural(L.length, 'meeting', 'meetings') + ' · ' + dur + ' · first at ' + hm(L[0].m.start) : 'No meeting today';
|
|
191
|
+
return { segs: L.length ? segs : [], sub, n: L.length };
|
|
192
|
+
}
|
|
193
|
+
const listWords = (a) => (a.length <= 1 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
|
|
194
|
+
/** The card's mode and words. o: { now, rec: { id, title, at, paused, meeting } | null, hidden (the end-of-day card was closed today), titleOf(ini) } */
|
|
195
|
+
export function todayCard(D, o = {}) {
|
|
196
|
+
const now = o.now || D.now || Date.now();
|
|
197
|
+
const t = todayOf(D);
|
|
198
|
+
const needs = needsOf(D);
|
|
199
|
+
const titleOf = o.titleOf || ((id) => id);
|
|
200
|
+
if (o.rec && !o.rec.meeting) {
|
|
201
|
+
const s = o.rec.at ? Math.max(0, Math.round((now - Date.parse(o.rec.at)) / 1000)) : null;
|
|
202
|
+
return { mode: 'rec', id: o.rec.id, paused: !!o.rec.paused, clock: s == null ? '' : Math.floor(s / 60) + ':' + pad(s % 60), title: o.rec.title || 'A recording', sub: (o.rec.title ? o.rec.title : 'A recording') + ' · not on the calendar' };
|
|
203
|
+
}
|
|
204
|
+
const nowM = t.find((m) => m.state === 'now');
|
|
205
|
+
if (nowM) {
|
|
206
|
+
const mins = Math.max(0, Math.round((now - Date.parse(nowM.start)) / 60000));
|
|
207
|
+
const done = (nowM.before || []).filter((x) => x && x.done).length, all = (nowM.before || []).length;
|
|
208
|
+
return { mode: 'live', meeting: nowM, title: nowM.title, rec: !!(o.rec && o.rec.meeting), mins: mins + ' min', sub: all ? 'To do before: ' + done + ' of ' + all + ' done' : nowM.people && nowM.people.length ? 'With ' + listWords(nowM.people.slice(0, 3)) : 'On now' };
|
|
209
|
+
}
|
|
210
|
+
const soon = t.find((m) => m.state !== 'past' && Date.parse(m.start) > now && Date.parse(m.start) - now <= 15 * 60000);
|
|
211
|
+
if (soon) {
|
|
212
|
+
const inMin = Math.max(1, Math.round((Date.parse(soon.start) - now) / 60000));
|
|
213
|
+
const ini = meetIni(soon);
|
|
214
|
+
const todo = (soon.before || []).filter((x) => x && !x.done).length;
|
|
215
|
+
const parts = [soon.people && soon.people.length ? 'With ' + listWords(soon.people.slice(0, 3)) : '', ini ? titleOf(ini) : '', todo ? plural(todo, 'thing', 'things') + ' to do before' : '', soon.minutes ? soon.minutes + ' min' : ''].filter(Boolean);
|
|
216
|
+
const link = [soon.join, soon.link, soon.url].find((u) => /^https:\/\//.test(String(u || ''))) || '';
|
|
217
|
+
return { mode: 'soon', meeting: soon, time: hm(soon.start), title: soon.title, in: 'in ' + inMin + ' min', sub: parts.join(' · '), link, prep: (soon.prepared || []).length > 0 || todo > 0 };
|
|
218
|
+
}
|
|
219
|
+
const h = new Date(now).getHours();
|
|
220
|
+
if (h >= 17 && !o.hidden) {
|
|
221
|
+
const P = D.phoneDay && D.phoneDay.ok !== false ? D.phoneDay : null;
|
|
222
|
+
const block = needs.find((x) => x.row && /decision|blocked/.test(x.row.kind)) || needs[0] || null;
|
|
223
|
+
const rec = P && P.recap ? P.recap : null;
|
|
224
|
+
const moved = rec && (rec.moved || []).length ? rec.moved.slice(0, 2).map((m) => m.text).join(' · ') : '';
|
|
225
|
+
const doneLine = moved || (rec ? [rec.decided ? plural(rec.decided, 'decision', 'decisions') : '', rec.done ? plural(rec.done, 'task', 'tasks') + ' done' : '', rec.finished ? rec.finished + ' finished' : ''].filter(Boolean).join(' · ') : '');
|
|
226
|
+
const runs = (D.sessions || []).filter((s) => s.shown === 'working');
|
|
227
|
+
const over = runs.length ? (runs.length === 1 ? ((runs[0].hx && runs[0].hx.title) || runs[0].name) + ' runs.' : runs.length + ' sessions run.') + ' Results are in New for you by morning.' : '';
|
|
228
|
+
const tm = P && P.tomorrow ? P.tomorrow : null;
|
|
229
|
+
const first = tm && (tm.meetings || []).length ? tm.meetings.slice().sort((a, b) => Date.parse(a.start) - Date.parse(b.start))[0] : null;
|
|
230
|
+
const tomorrow = tm ? (first ? 'First meeting ' + hm(first.start) : 'No meeting') + (needs.length ? ' · ' + needs.length + ' on your list' : '') : '';
|
|
231
|
+
if (!block) return { mode: 'clear', time: hm(new Date(now).toISOString()), line: 'All clear.' + (tomorrow ? ' Tomorrow: ' + tomorrow.charAt(0).toLowerCase() + tomorrow.slice(1) + '.' : '') };
|
|
232
|
+
const waits = block.ini && block.ini !== 'product' ? titleOf(block.ini) : '';
|
|
233
|
+
return { mode: 'eod', time: hm(new Date(now).toISOString()), block, blockLine: block.name + ' still waits on you.', why: waits && waits !== block.name ? waits + ' cannot move on without it.' : block.hint || '', later: !!(block.row && block.row.kind !== 'source'),
|
|
234
|
+
lines: [['Done', doneLine], ['Overnight', over], ['Tomorrow', tomorrow]].filter((x) => x[1]) };
|
|
235
|
+
}
|
|
236
|
+
const load = dayLoad(t, now);
|
|
237
|
+
return { mode: 'day', load };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* ── the weekly review ── */
|
|
241
|
+
/** Open initiatives with no change for `days` days or more, the longest first: { id, title, stage, days, owner }. */
|
|
242
|
+
export function staleInis(D, now = Date.now(), days = STALE_DAYS) {
|
|
243
|
+
return boardRows(D).filter(OPEN).filter((r) => !/^(Deliver|Monitor|Evaluate)$/.test(String(r.stage || '')) && r.updated && !Number.isNaN(Date.parse(r.updated)))
|
|
244
|
+
.map((r) => ({ id: r.id, title: r.title, stage: r.stage || '', days: Math.floor((now - Date.parse(r.updated)) / 86400000), owner: r.owner || null, life: (r.acts && r.acts.life) || null }))
|
|
245
|
+
.filter((r) => r.days >= days && r.life !== 'on-hold').sort((a, b) => b.days - a.days);
|
|
246
|
+
}
|
|
247
|
+
export const REVIEW_STEPS = [['sort', 'Sort what came in'], ['wait', 'Check what you wait on'], ['untouched', 'Look at untouched work'], ['pick', "Pick next week's three"]];
|
|
248
|
+
/** The review of this week: { week, label, steps: [{ key, label, done, now, note, n }], at (the step on now), last, kept } */
|
|
249
|
+
export function reviewModel(D, now = Date.now()) {
|
|
250
|
+
const R = (D.review && D.review.ok) ? D.review : { steps: {}, kept: {}, last: null };
|
|
251
|
+
const W = D.work || null;
|
|
252
|
+
const tab = (k) => ((W && W.queue && W.queue.tabs) || []).find((t) => t.key === k) || { n: 0, groups: [] };
|
|
253
|
+
const n = { sort: tab('inbox').n || 0, wait: W && W.waiting ? W.waiting.rows.length : 0, untouched: staleInis(D, now).length + ((W && W.review && W.review.n) || 0), pick: 3 };
|
|
254
|
+
const steps = REVIEW_STEPS.map(([key, label]) => ({ key, label, done: !!(R.steps && R.steps[key]), note: (R.steps && R.steps[key] && R.steps[key].note) || '', n: n[key] }));
|
|
255
|
+
const at = steps.findIndex((s) => !s.done);
|
|
256
|
+
steps.forEach((s, i) => { s.now = i === at; });
|
|
257
|
+
const d = new Date(now);
|
|
258
|
+
return { week: R.week || '', label: d.getDate() + ' ' + MON[d.getMonth()], steps, at, done: at < 0, last: R.last || null, kept: R.kept || {}, open: d.getDay() === REVIEW_DAY && at >= 0, started: steps.some((s) => s.done) };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* ── filing a typed task ── */
|
|
262
|
+
const words = (s) => String(s || '').toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').split(/\s+/).filter((w) => w.length > 2);
|
|
263
|
+
/** The open initiative a typed line names: its id, or every word of its title (the longest title that matches), else null. */
|
|
264
|
+
export function fileUnder(text, inis) {
|
|
265
|
+
const t = String(text || '').toLowerCase(), tw = new Set(words(t));
|
|
266
|
+
let best = null, bestN = 0;
|
|
267
|
+
for (const r of inis || []) {
|
|
268
|
+
if (!r || !r.id) continue;
|
|
269
|
+
if (t.includes(String(r.id).toLowerCase())) return r.id;
|
|
270
|
+
const w = words(r.title);
|
|
271
|
+
if (w.length && w.length <= 6 && w.every((x) => tw.has(x)) && w.length > bestN) { best = r.id; bestN = w.length; }
|
|
272
|
+
}
|
|
273
|
+
return best;
|
|
274
|
+
}
|
|
275
|
+
export const dayOf = (now = Date.now()) => isoDay(now);
|
|
276
|
+
export const dowOf = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? DOW[new Date(+m[1], +m[2] - 1, +m[3]).getDay()] : ''; };
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
* (initiative premium-agreed-design, Home: "keep every uncovered feature usable, in the cozy style, with a small Waiting for design marker").
|
|
3
3
|
*
|
|
4
4
|
* Each opens in the Viewer card (cozy-viewer.js), never the old dialog, and reads and writes through the routes the old pages used:
|
|
5
|
-
* openSettings()
|
|
6
|
-
*
|
|
7
|
-
* openSources() GET /api/sources, POST /api/sources/refresh and /refresh-all
|
|
5
|
+
* openSettings() the designed Settings (pm/cozy-settings.js, premium-uncovered-features E3)
|
|
6
|
+
* openSources() the designed Sources (pm/cozy-sources.js, E3); readLine below gives its read lines
|
|
8
7
|
* openMyWork(tab) home-work.js: Your list, Waiting on others, Weekly review, Untouched; an item's fields and agent; Focus and jobs;
|
|
9
8
|
* keys and swipe on the rows (GET /api/my-work-premium; the /api/pm-items, /api/pm-jobs and /api/my-work presses)
|
|
10
|
-
* openAround(key?) home-around.js:
|
|
11
|
-
* line and today's digests (the old Briefing card's reads and presses)
|
|
9
|
+
* openAround(key?) home-around.js: Around you is gone (premium-uncovered-features, HmAround); its views stay, opened from New for you
|
|
12
10
|
* openEndOfDay() GET /api/phone-day: what finished today, the recap and tomorrow's meetings
|
|
13
11
|
* openProducts() which products Home reads (GET /api/briefing-premium products, POST /api/settings ws.briefing.include)
|
|
14
|
-
* openSearch()
|
|
15
|
-
* openInbox()
|
|
12
|
+
* openSearch(go) the designed Search (pm/cozy-search.js, E1): the repository and every worktree
|
|
13
|
+
* openInbox(go) New for you (pm/cozy-news.js, E2), which replaces the agents' results
|
|
16
14
|
* openRecorder() a note recorded now with no calendar event (the Viewer's newNote, else POST /api/notes/new)
|
|
17
|
-
* moreItems the ⋯ menu's rows, [key, label, icon]
|
|
15
|
+
* moreItems the ⋯ menu's rows, [key, label, icon]: the features the place menu does not hold (Search, New for you, Sources and
|
|
16
|
+
* Settings are in the place menu, cozy-nav.js)
|
|
18
17
|
* Every write is the PM's press (pmPost carries the launch nonce). Nothing here sends anything outside PMOS. */
|
|
19
18
|
import { pmGet, pmPost } from './http.js';
|
|
20
19
|
import { open as vwOpen } from './cozy-viewer.js';
|
|
@@ -33,9 +32,7 @@ function card(o, draw) {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export const moreItems = [
|
|
36
|
-
['work', 'My work', 'list'], ['
|
|
37
|
-
['cal', 'Calendar', 'cal'], ['rec', 'Record a note', 'mic'], ['search', 'Search', 'doc'], ['products', 'Products', 'chart'],
|
|
38
|
-
['sources', 'Sources', 'source'], ['settings', 'Settings', 'gear'],
|
|
35
|
+
['work', 'My work', 'list'], ['eod', 'End of the day', 'cal'], ['cal', 'Calendar', 'cal'], ['rec', 'Record a note', 'mic'], ['products', 'Products', 'chart'],
|
|
39
36
|
];
|
|
40
37
|
|
|
41
38
|
/** The ⋯ list itself in the Viewer, for a page with no menu of its own: items are [label, open]. */
|
|
@@ -46,56 +43,8 @@ export function listCard(items) {
|
|
|
46
43
|
});
|
|
47
44
|
}
|
|
48
45
|
|
|
49
|
-
/* ── Settings ── */
|
|
50
|
-
|
|
51
|
-
export function openSettings() {
|
|
52
|
-
const M = { ws: null, st: {}, src: null, con: {}, conn: [], msg: '', busy: false };
|
|
53
|
-
const draw = (b) => {
|
|
54
|
-
const home = M.ws && M.ws[0] ? M.st[M.ws[0].id] : null;
|
|
55
|
-
const latest = home && (home.latest || (home.lastCheck && home.lastCheck.latest));
|
|
56
|
-
const behind = M.ws ? M.ws.filter((w) => M.st[w.id] && M.st[w.id].kitBehind) : [];
|
|
57
|
-
const appBehind = !!(home && home.appBehind && !(home.app && home.app.fromCheckout));
|
|
58
|
-
const upd = !home ? '<p class="hx-n">Reading the versions.</p>'
|
|
59
|
-
: row('PMOS ' + ((home.app && home.app.version) || '?'), latest ? (appBehind || behind.length ? latest + ' is ready' : 'Up to date · the newest kit is ' + latest) : 'Press Check now to ask for the latest version',
|
|
60
|
-
btn('Check now', 'data-x="check"') + (appBehind || behind.length ? btn('Update', 'data-x="update"', true) : ''));
|
|
61
|
-
const ws = M.ws === null ? '<p class="hx-n">Reading the repositories.</p>' : M.ws.map((x) => row(x.label || x.name || x.id, (x.root || '') + (x.home ? ' · home' : ''), x.home ? '' : btn('Remove', `data-rm="${esc(x.id)}"`))).join('')
|
|
62
|
-
+ '<div class="hx-add"><input id="hxRoot" placeholder="Folder path of a repository" aria-label="Folder path of a repository"><button type="button" class="hx-b pri" data-x="add">Add</button></div>';
|
|
63
|
-
const con = M.src === null ? '<p class="hx-n">Reading the connectors.</p>' : Object.keys(SRC).filter((k) => k in M.src).map((k) => row(SRC[k], M.src[k] ? 'Home reads it' : 'Home does not read it', `<button type="button" class="hx-sw" role="switch" aria-checked="${!!M.src[k]}" data-src="${k}">${M.src[k] ? 'On' : 'Off'}</button>`)).join('')
|
|
64
|
-
+ M.conn.filter((c) => !c.source).map((c) => row(c.label, M.con[c.name] ? 'On' : 'Your sessions can use it', `<button type="button" class="hx-sw" role="switch" aria-checked="${!!M.con[c.name]}" data-conn="${esc(c.name)}">${M.con[c.name] ? 'On' : 'Off'}</button>`)).join('');
|
|
65
|
-
b.innerHTML = WAIT + sec('Updates', upd) + sec('Workspaces', ws) + sec('Connectors', con) + `<p class="hx-n" role="status">${esc(M.msg)}</p>`;
|
|
66
|
-
};
|
|
67
|
-
const body = card({ id: 'settings', kind: 'Settings', title: 'Settings', icon: 'gear' }, draw);
|
|
68
|
-
const load = async () => {
|
|
69
|
-
const [w, p] = await Promise.all([pmGet('/api/workspaces'), pmGet('/api/proactive/settings')]);
|
|
70
|
-
M.ws = w && Array.isArray(w.workspaces) ? w.workspaces : [];
|
|
71
|
-
await Promise.all(M.ws.map(async (x) => { const r = await pmGet('/api/kit/status?ws=' + encodeURIComponent(x.id)); if (r && r.ok) M.st[x.id] = r; }));
|
|
72
|
-
M.src = p && p.ok && p.settings ? { ...p.settings.briefSources } : {}; M.con = p && p.ok && p.settings ? { ...p.settings.connectors } : {};
|
|
73
|
-
M.conn = p && p.connectors && Array.isArray(p.connectors.list) ? p.connectors.list : [];
|
|
74
|
-
if (body.isConnected) draw(body);
|
|
75
|
-
};
|
|
76
|
-
body.onclick = async (e) => {
|
|
77
|
-
const t = e.target.closest('button'); if (!t || M.busy) return;
|
|
78
|
-
M.busy = true; M.msg = '';
|
|
79
|
-
try {
|
|
80
|
-
if (t.dataset.x === 'check') { for (const w of M.ws) { const r = await pmPost('/api/kit/check', { ws: w.id }); if (r && r.ok) M.st[w.id] = { ...M.st[w.id], ...r }; else M.msg = (r && r.error) || 'The check failed.'; } }
|
|
81
|
-
else if (t.dataset.x === 'update') {
|
|
82
|
-
const home = M.st[M.ws[0].id], v = home.latest || (home.lastCheck && home.lastCheck.latest);
|
|
83
|
-
for (const w of M.ws.filter((x) => M.st[x.id] && M.st[x.id].kitBehind)) { const r = await pmPost('/api/kit/update', { ws: w.id, version: v }); if (!(r && r.ok)) { M.msg = (r && r.error) || 'The kit was not updated.'; break; } M.st[w.id].kitBehind = false; }
|
|
84
|
-
if (!M.msg && home.appBehind) { const r = await pmPost('/api/kit/upgrade-app', { ws: M.ws[0].id, version: v }); M.msg = r && r.ok !== false ? 'Installing PMOS ' + v + '. Reload this page when it starts again.' : (r && r.error) || 'The update did not start.'; }
|
|
85
|
-
else if (!M.msg) M.msg = 'Updated the kits to ' + v + '.';
|
|
86
|
-
} else if (t.dataset.x === 'add') {
|
|
87
|
-
const root = (body.querySelector('#hxRoot').value || '').trim();
|
|
88
|
-
if (!root) M.msg = 'Paste the folder path of a repository.';
|
|
89
|
-
else { const r = await pmPost('/api/workspaces', { root, focus: false }); if (r && r.ok) M.ws = [...M.ws.filter((y) => y.id !== r.workspace.id), r.workspace]; else M.msg = (r && r.error) || 'Not added.'; }
|
|
90
|
-
} else if (t.dataset.rm) { const r = await pmPost('/api/workspaces/forget', { id: t.dataset.rm }); if (r && r.ok) { M.ws = M.ws.filter((y) => y.id !== t.dataset.rm); toast('Removed. The folder is untouched.'); } else M.msg = (r && (r.error || r.reason)) || 'Not removed.'; }
|
|
91
|
-
else if (t.dataset.src) { const k = t.dataset.src, on = !M.src[k]; const r = await pmPost('/api/proactive/settings', { briefSources: { [k]: on } }); if (r && r.ok) M.src[k] = on; else M.msg = (r && r.error) || 'Not saved.'; }
|
|
92
|
-
else if (t.dataset.conn) { const k = t.dataset.conn, on = !M.con[k]; const r = await pmPost('/api/proactive/settings', { connectors: { [k]: on } }); if (r && r.ok) M.con[k] = on; else M.msg = (r && r.error) || 'Not saved.'; }
|
|
93
|
-
} finally { M.busy = false; }
|
|
94
|
-
draw(body);
|
|
95
|
-
};
|
|
96
|
-
load();
|
|
97
|
-
return body;
|
|
98
|
-
}
|
|
46
|
+
/* ── Settings ── the designed dialog (pm/cozy-settings.js) */
|
|
47
|
+
export function openSettings(section) { return import('./cozy-settings.js').then((M) => M.openSettings(section)); }
|
|
99
48
|
|
|
100
49
|
/* ── Sources ── */
|
|
101
50
|
/** A read line: "<source> read HH:MM" for each id, from one GET /api/sources answer. ids name freshness rows ('initiatives', 'calendar', …)
|
|
@@ -110,39 +59,14 @@ export function readLine(s, ids) {
|
|
|
110
59
|
return (der ? ({ brief: 'Brief' })[x.id] || x.label : x.label) + ' ' + w;
|
|
111
60
|
}).filter(Boolean).join(' · ');
|
|
112
61
|
}
|
|
113
|
-
|
|
114
|
-
export function openSources() {
|
|
115
|
-
const M = { r: null, msg: '', busy: false };
|
|
116
|
-
const draw = (b) => {
|
|
117
|
-
const s = M.r;
|
|
118
|
-
const rows = !s ? '<p class="hx-n">Reading the sources.</p>' : !s.ok ? '<p class="hx-n">The sources could not be read.</p>'
|
|
119
|
-
: s.sources.map((x) => row(x.label, (SST[x.state] || x.state) + (x.as_of ? ' · read ' + when(x.as_of) : ''), x.id === 'repository' ? '' : btn('Refresh', `data-sref="${esc(x.id)}"${x.state === 'off' || x.state === 'building' || M.busy ? ' disabled' : ''}`))).join('');
|
|
120
|
-
const h = s && s.ok && s.health ? s.health : null, lv = h ? (h.level === 'bad' ? 'bad' : h.level === 'warn' ? 'warn' : 'ok') : '';
|
|
121
|
-
const health = h ? `<div id="srcHealth" class="hx-h ${esc(h.level)}" role="status"><p class="hx-n"><i class="sdot ${lv}" aria-hidden="true"></i>${esc(h.line)}</p>${(h.issues || []).slice(1, 4).map((i) => `<p class="hx-n">${esc(i.text)}</p>`).join('')}</div>` : '';
|
|
122
|
-
// which reads each part of Home shows, and when they were read (briefing-source-flow slice 5), from this same read
|
|
123
|
-
const shows = s && s.ok ? [['Today', readLine(s, ['calendar'])], ['Needs you', readLine(s, ['initiatives', 'my-work', 'd:brief'])]].filter((x) => x[1]) : [];
|
|
124
|
-
b.innerHTML = WAIT + health + (shows.length ? sec('What Home shows', shows.map(([k, v]) => `<p class="hx-n hx-reads" data-reads="${esc(k)}"><b>${esc(k)}:</b> ${esc(v)}</p>`).join('')) : '') + `<div class="hx-top"><p class="hx-n">Each source is read on its own schedule, not live. Refresh all reads every source, then writes Home's list from those reads.</p>${btn(s && s.all && !s.all.done ? 'Refreshing' : 'Refresh all', 'data-x="all"' + (M.busy ? ' disabled' : ''), true)}</div>`
|
|
125
|
-
+ sec('Sources', rows) + `<p class="hx-n" role="status">${esc(M.msg)}</p>`;
|
|
126
|
-
};
|
|
127
|
-
const body = card({ id: 'sources', kind: 'Sources', title: 'Sources', icon: 'source' }, draw);
|
|
128
|
-
const read = async () => { M.r = await pmGet('/api/sources' + wsQ()); if (body.isConnected) draw(body); };
|
|
129
|
-
body.onclick = async (e) => {
|
|
130
|
-
const t = e.target.closest('button'); if (!t || M.busy || !M.r || !M.r.ok) return;
|
|
131
|
-
M.busy = true; draw(body);
|
|
132
|
-
const r = t.dataset.x === 'all' ? await pmPost('/api/sources/refresh-all', { ws: M.r.ws || '' }) : t.dataset.sref ? await pmPost('/api/sources/refresh', { ws: M.r.ws || '', source: t.dataset.sref }) : null;
|
|
133
|
-
M.busy = false; M.msg = r && r.ok ? 'Reading again.' : (r && r.error) || 'It did not start.';
|
|
134
|
-
await read(); setTimeout(read, 4000);
|
|
135
|
-
};
|
|
136
|
-
read();
|
|
137
|
-
return body;
|
|
138
|
-
}
|
|
62
|
+
/** Sources: the designed card in the Viewer (pm/cozy-sources.js). */
|
|
63
|
+
export function openSources() { return import('./cozy-sources.js').then((M) => M.openSources()); }
|
|
139
64
|
|
|
140
65
|
/* ── My work ── */
|
|
141
66
|
/* ── My work ── the four tabs, the item with its fields and its agent, Focus and jobs, and the keys and swipe on the rows, in home-work.js */
|
|
142
67
|
export function openMyWork(tab = 'yours') { return import('./home-work.js').then((M) => M.openMyWork(tab)); }
|
|
143
68
|
|
|
144
|
-
/* ── Around you ──
|
|
145
|
-
* the prep line and today's digests, in home-around.js. key opens one row's view at once. */
|
|
69
|
+
/* ── Around you ── gone (HmAround): its parts have one home each, and New for you names them. key opens one of its views (home-around.js). */
|
|
146
70
|
export function openAround(key) { return import('./home-around.js').then((M) => M.openAround(key)); }
|
|
147
71
|
|
|
148
72
|
/* ── End of the day ── */
|
|
@@ -192,52 +116,11 @@ export function openProducts() {
|
|
|
192
116
|
return body;
|
|
193
117
|
}
|
|
194
118
|
|
|
195
|
-
/* ── Search ── */
|
|
196
|
-
export function openSearch(go) {
|
|
197
|
-
const M = { q: '', inis: [], docs: [], ses: [] };
|
|
198
|
-
const hit = (s) => String(s || '').toLowerCase().includes(M.q.toLowerCase());
|
|
199
|
-
const drawList = (b) => {
|
|
200
|
-
const L = b.querySelector('#hxRes'); if (!L) return;
|
|
201
|
-
if (M.q.length < 2) { L.innerHTML = '<p class="hx-n">Type two letters or more.</p>'; return; }
|
|
202
|
-
const a = M.inis.filter((r) => hit(r.title) || hit(r.id)).slice(0, 8).map((r) => `<button type="button" class="hx-hit" data-ini="${esc(r.id)}"><b>${esc(r.title)}</b><em>Initiative · ${esc(r.stage || '')}</em></button>`);
|
|
203
|
-
const d = M.docs.filter((x) => hit(x.title) || hit(x.path)).slice(0, 8).map((x) => `<button type="button" class="hx-hit" data-doc="${esc(x.path)}"><b>${esc(x.title)}</b><em>Document · ${esc(x.path)}</em></button>`);
|
|
204
|
-
const s = M.ses.filter((x) => hit(x.name) || hit(x.hx && x.hx.title)).slice(0, 8).map((x) => `<button type="button" class="hx-hit" data-ses="${esc(x.id)}"><b>${esc((x.hx && x.hx.title) || x.name)}</b><em>Session · ${esc(x.label || '')}</em></button>`);
|
|
205
|
-
L.innerHTML = [...a, ...d, ...s].join('') || '<p class="hx-n">Nothing matches.</p>';
|
|
206
|
-
};
|
|
207
|
-
const draw = (b) => { b.innerHTML = WAIT + '<label class="hx-q"><input type="search" id="hxQ" placeholder="Search initiatives, documents and sessions" aria-label="Search" autocomplete="off"></label><div id="hxRes"></div>'; drawList(b); const q = b.querySelector('#hxQ'); q.value = M.q; setTimeout(() => q.focus(), 0); };
|
|
208
|
-
const body = card({ id: 'search', kind: 'Search', title: 'Find anything', icon: 'doc' }, draw);
|
|
209
|
-
body.oninput = (e) => { if (e.target.id === 'hxQ') { M.q = e.target.value.trim(); drawList(body); } };
|
|
210
|
-
body.onclick = (e) => { const t = e.target.closest('.hx-hit'); if (!t || !go) return; go(t.dataset); };
|
|
211
|
-
Promise.all([pmGet('/api/board-premium' + wsQ()), pmGet('/api/core-docs?level=product' + wsQ('&')), pmGet('/api/sessions')]).then(([b, d, s]) => {
|
|
212
|
-
M.inis = b && b.ok && b.model ? ((b.model.initiatives && b.model.initiatives.list && b.model.initiatives.list.rows) || []) : [];
|
|
213
|
-
M.docs = d && d.ok ? (d.rows || d.docs || []).filter((x) => x.path) : [];
|
|
214
|
-
M.ses = s && Array.isArray(s.sessions) ? s.sessions.filter((x) => x.shown !== 'exited') : [];
|
|
215
|
-
if (body.isConnected) drawList(body);
|
|
216
|
-
});
|
|
217
|
-
return body;
|
|
218
|
-
}
|
|
119
|
+
/* ── Search ── the designed palette (pm/cozy-search.js); go is the page's own opener for an initiative ({ ini }), a session ({ ses }) or a file ({ doc }) */
|
|
120
|
+
export function openSearch(go) { return import('./cozy-search.js').then((M) => M.openSearch({ go })); }
|
|
219
121
|
|
|
220
|
-
/* ── the agents' results (the bell)
|
|
221
|
-
export function openInbox(go) {
|
|
222
|
-
const M = { r: null };
|
|
223
|
-
const draw = (b) => {
|
|
224
|
-
const r = M.r;
|
|
225
|
-
b.innerHTML = WAIT + (!r ? '<p class="hx-n">Reading the agents\' results.</p>' : !r.ok ? '<p class="hx-n">The results could not be read.</p>'
|
|
226
|
-
: (r.items || []).length ? sec(r.count + ' wait on you', r.items.map((x) => row(x.title || x.text, [x.who, x.where, x.at ? when(x.at) : ''].filter(Boolean).join(' · '), (x.link ? btn('Open', `data-open="${esc(x.link)}"`) : '') + btn('Seen', `data-seen="${esc(x.id)}"`))).join('')) + btn('Mark all seen', 'data-all="1"')
|
|
227
|
-
: '<p class="hx-n">Nothing from the agents waits on you.</p>');
|
|
228
|
-
};
|
|
229
|
-
const body = card({ id: 'inbox', kind: 'Agent results', title: 'What the agents finished', icon: 'list' }, draw);
|
|
230
|
-
const read = async () => { M.r = await pmGet('/api/inbox'); if (body.isConnected) draw(body); };
|
|
231
|
-
body.onclick = async (e) => {
|
|
232
|
-
const t = e.target.closest('button'); if (!t) return;
|
|
233
|
-
if (t.dataset.open) { if (go) go({ link: t.dataset.open }); return; }
|
|
234
|
-
if (t.dataset.seen) await pmPost('/api/inbox/seen', { ids: [t.dataset.seen] });
|
|
235
|
-
if (t.dataset.all) await pmPost('/api/inbox/seen', { all: true });
|
|
236
|
-
read();
|
|
237
|
-
};
|
|
238
|
-
read();
|
|
239
|
-
return body;
|
|
240
|
-
}
|
|
122
|
+
/* ── New for you ── it replaces the agents' results (the bell) and Around you (pm/cozy-news.js) */
|
|
123
|
+
export function openInbox(go) { return import('./cozy-news.js').then((M) => M.openNews({ go })); }
|
|
241
124
|
|
|
242
125
|
/* ── record a note now ── */
|
|
243
126
|
export async function openRecorder() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* pm/home-phone-card.js — the phone moment card, moved onto Home (initiative premium-agreed-design; the card itself is premium-phone-card,
|
|
2
|
-
* planning/prd/premium-phone-card-prd.md R1 to R5).
|
|
3
|
-
*
|
|
2
|
+
* planning/prd/premium-phone-card-prd.md R1 to R5). On a phone it is the Today card at the top of the list (canvas HmPhone and HmPhone2):
|
|
3
|
+
* the moment of the day, in the card's shape. At 640 px and narrower only; a desktop never reads /api/phone-day.
|
|
4
4
|
* The moment comes from momentOf (c3-phone-model.js) over the /api/brief-page day and the clock; every line comes from /api/brief-page or
|
|
5
5
|
* /api/phone-day. Done and Undo press /api/pm-items/done and /reopen on the PM's own item; nothing is written on load.
|
|
6
|
-
* mountPhoneCard({ pmGet, pmPost, toast, ws, openMeeting
|
|
6
|
+
* mountPhoneCard({ pmGet, pmPost, toast, ws, openMeeting }) → { el, read } */
|
|
7
7
|
import { momentOf, inText } from './phone-moment.js';
|
|
8
8
|
|
|
9
9
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
@@ -69,7 +69,7 @@ export function mountPhoneCard(o) {
|
|
|
69
69
|
if (!P.page) h = '<span class="label">Now</span><p class="phl">Reading your day.</p>';
|
|
70
70
|
else if (!P.page.ok) h = `<span class="label">Now</span><p class="pherr" role="alert">Your day could not be read: ${esc(P.page.error || 'the workspace server did not answer')}.</p>`;
|
|
71
71
|
else { const mo = momentNow(); el.dataset.moment = mo.kind; h = moment(mo); }
|
|
72
|
-
el.innerHTML =
|
|
72
|
+
el.innerHTML = h;
|
|
73
73
|
if (focus) { const f = el.querySelector(focus); if (f) f.focus(); }
|
|
74
74
|
}
|
|
75
75
|
async function read(force) {
|