create-pmos 0.612.0 → 0.614.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 +33 -27
- 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/changelog.json +32 -0
- package/workspace/guide/cli.md +2 -1
- package/workspace/guide/layout.md +23 -9
- package/workspace/guide/programs.md +1 -1
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/events-place.js +2 -2
- package/workspace/lib/mention-cli.js +6 -3
- package/workspace/lib/mention-store.js +49 -10
- package/workspace/lib/routes-events-place.js +2 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-span.js +2 -1
- package/workspace/public/pm/cozy-home-rows.css +55 -0
- package/workspace/public/pm/cozy-nav.js +15 -2
- package/workspace/public/pm/cozy-pop-work.css +3 -0
- package/workspace/public/pm/cozy-pop-work.js +5 -3
- package/workspace/public/pm/cozy-routine.js +2 -2
- package/workspace/public/pm/cozy-today-app.js +119 -12
- package/workspace/public/pm/cozy-today-model.js +278 -21
- package/workspace/public/pm/cozy-today-page.css +74 -15
- package/workspace/public/pm/cozy-today-view.js +89 -31
- package/workspace/public/pm/home-app.js +14 -6
- package/workspace/public/pm/home-data.js +1 -1
- package/workspace/public/pm/home-ini.js +17 -1
- package/workspace/public/pm/home-mentions.js +121 -6
- package/workspace/public/pm/ini-edit.js +2 -0
- package/workspace/public/pm/ini-view.css +2 -0
- package/workspace/public/pm/mention-one-model.js +115 -0
- package/workspace/public/pm/pop-work-model.js +17 -11
- package/workspace/public/pm/scope-chip.js +4 -1
- package/workspace/run-tests.js +11 -4
- package/workspace/server.js +8 -0
- package/workspace/skills/morning-brief.skill +1 -1
- package/workspace/test-run.js +2 -0
|
@@ -222,3 +222,6 @@ button.pw-fv .grey { color: var(--cz-ink3); }
|
|
|
222
222
|
@media (hover: hover) { button.pw-fv:hover > span:first-child { text-decoration: underline; text-underline-offset: 2px; } }
|
|
223
223
|
/* When did this happen? under the status list (round 3 point 18) */
|
|
224
224
|
.hi-pop .pw-when { padding: 0 6px 4px; }
|
|
225
|
+
/* round 3 item 11b: the task a Today row opened, lit until another task is opened */
|
|
226
|
+
.pw-kr.lit { background: var(--cz-bluebg); box-shadow: inset 3px 0 0 var(--cz-blue); }
|
|
227
|
+
.pw-kr.lit .pw-tt { font-weight: var(--fw-strong); }
|
|
@@ -50,10 +50,12 @@ const cols = () => ({ status: true, date: true, tl: true, kind: true, when: true
|
|
|
50
50
|
const ST = new Map(); // initiative id → { open, shut, doneOpen, farOpen, details, top }
|
|
51
51
|
const LOOSE = 'pw-loose'; // the initiatives whose Not in a stage row the PM opened (round 3 point 21), remembered on this computer
|
|
52
52
|
const stOf = (id) => {
|
|
53
|
-
if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), doneOpen: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false });
|
|
53
|
+
if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), doneOpen: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false, focus: '' });
|
|
54
54
|
return ST.get(id);
|
|
55
55
|
};
|
|
56
56
|
const looseKeep = (id, on) => { const L = (store.get(LOOSE, []) || []).filter((x) => x !== id); if (on) L.push(id); store.set(LOOSE, L.slice(-200)); };
|
|
57
|
+
/** The task a Today row opened (round 3 item 11b): its stage opens and its row is lit until another task is focused. '' clears it. */
|
|
58
|
+
export function focus(id, uid) { stOf(String(id)).focus = uid ? String(uid) : ''; }
|
|
57
59
|
const ITEMS = new Map(); // initiative id → the Library's rows | null while reading | false when the route is not there
|
|
58
60
|
const ib = (attr, label, d, cls = '') => `<button type="button" class="pw-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(d)}</button>`;
|
|
59
61
|
|
|
@@ -200,7 +202,7 @@ function rowHtml(x, W, C, sugRows) {
|
|
|
200
202
|
if (x.kind === 'done') return `<div class="pw-tr pw-dr" role="row"><span class="pw-it"><button type="button" class="pw-dn" data-pw-done="${esc(x.key)}" aria-expanded="${x.open}">${esc(x.label)}${SVG(x.open ? P.down : P.right, 14)}</button></span>${C.status ? '<span></span>' : ''}${C.date ? '<span></span>' : ''}${tl}</div>`;
|
|
201
203
|
const s = sugRows.get(x.uid);
|
|
202
204
|
const title = x.jira ? `<span class="pw-tt">${esc(x.title)}</span>` : `<button type="button" class="pw-tt" data-pw-name="${esc(x.uid)}" aria-label="${esc('Rename ' + x.title)}">${esc(x.title)}</button>`;
|
|
203
|
-
return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"><span class="pw-it"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov')}${ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
|
|
205
|
+
return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"><span class="pw-it"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov')}${ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
|
|
204
206
|
+ (s ? `<div class="pw-tr pw-sugrow" role="row"><span class="pw-it">${sugLine(s, true)}</span></div>` : '');
|
|
205
207
|
}
|
|
206
208
|
function breakdownHtml(W, C, mode, full, S) {
|
|
@@ -252,7 +254,7 @@ const keyOf = (v, o) => String((o && o.id) || (v && (v.id || v.key)) || '');
|
|
|
252
254
|
function model(r, v, o) {
|
|
253
255
|
const id = keyOf(v, o), S = stOf(id), it = ITEMS.get(id);
|
|
254
256
|
const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
|
|
255
|
-
const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, doneOpen: S.doneOpen, moreOpen: S.moreOpen, farOpen: S.farOpen, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
|
|
257
|
+
const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, doneOpen: S.doneOpen, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
|
|
256
258
|
const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
|
|
257
259
|
return { W, S, id };
|
|
258
260
|
}
|
|
@@ -18,7 +18,7 @@ import * as VW from './cozy-viewer.js';
|
|
|
18
18
|
import * as POP from './cozy-popup.js';
|
|
19
19
|
import { KINDS, routineRows, routineGroups, didLine, kindCounts, productsOf, productName } from './cozy-routine-model.js';
|
|
20
20
|
import * as PK from './cozy-pick.js'; // the saved product pick of Work, Today and Goals
|
|
21
|
-
import { scopeChipHtml, openScope, scopeWords, whenNames } from './scope-chip.js'; // one chip for products, programs and projects (shared with Events)
|
|
21
|
+
import { scopeChipHtml, openScope, scopeWords, whenNames, displayName } from './scope-chip.js'; // one chip for products, programs and projects (shared with Events)
|
|
22
22
|
import { atOf } from './cozy-evmodel.js';
|
|
23
23
|
import { openReport } from './cozy-routine-pop.js';
|
|
24
24
|
import { openJob, openNew } from './cozy-routine-job.js'; // reads, jobs, services and your tasks: manage them in the popup (round 3 item 3)
|
|
@@ -58,7 +58,7 @@ async function load() {
|
|
|
58
58
|
const up = (n !== (x.name || x.id) && raw.find((y) => y.name === n)) || (x.linked && x.repo_key && raw.find((y) => y !== x && !y.linked && y.repo_key === x.repo_key));
|
|
59
59
|
return up && up !== x ? up : null;
|
|
60
60
|
};
|
|
61
|
-
const own =
|
|
61
|
+
const own = displayName; // the chip's rule (pm/scope-chip.js), so the column and the chip agree
|
|
62
62
|
S.ws = raw.map((x) => { const m = mainOf(x); return { id: x.id, name: m ? own(m) : own(x), slug: x.name || x.id, main: m ? m.id : null }; });
|
|
63
63
|
const home = (raw.find((x) => x.home) || raw[0] || {}).id; // Horizon scan and Report finder are settings of the home product
|
|
64
64
|
const per = await Promise.all(S.ws.map((x) => Promise.all([pmGet('/api/report-setups/routine?ws=' + enc(x.id)).catch(() => null), pmGet('/api/autonomy?ws=' + enc(x.id)).catch(() => null)])));
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
* Viewer no longer floats over a chat on a laptop. A row's press opens its work in the one popup (cozy-popup.js) with Home's chat beside it.
|
|
12
12
|
* The capture line adds a row and does nothing else: no popup, no session. Every write is a press: today-log marks and own entries
|
|
13
13
|
* (POST /api/today-log/*), a task's state or due day (the Board's own routes), an item's done, defer, due or remove (POST /api/pm-items/*),
|
|
14
|
-
* a Lab finding kept or dropped (POST /api/lab/*). Each says what it did in the toast, with Undo. Reads: GET /api/today-log
|
|
14
|
+
* a Lab finding kept or dropped (POST /api/lab/*). Each says what it did in the toast, with Undo. Reads: GET /api/today-log, and GET
|
|
15
|
+
* /api/events-place for the reports that go out today (placed at their time on the agenda). */
|
|
15
16
|
import * as TM from './cozy-today-model.js';
|
|
16
17
|
import * as TP from './cozy-today-view.js';
|
|
18
|
+
import * as OM from './mention-one-model.js'; // the one mention's title and the self check's proof line (Today round 3)
|
|
17
19
|
|
|
18
20
|
const ASK_SEND = new Set(['session']);
|
|
19
21
|
export function mountToday(ctx) {
|
|
20
|
-
const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set() };
|
|
22
|
+
const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set(), type: '', open: false, hide: new Set() };
|
|
21
23
|
const el = document.getElementById('tdPage');
|
|
22
24
|
const on = () => !!el && !ctx.isPhone();
|
|
23
25
|
const day = () => TM.dayKey(ctx.now());
|
|
@@ -27,7 +29,19 @@ export function mountToday(ctx) {
|
|
|
27
29
|
if (r && r.ok) X.log = { entries: r.entries || [], marks: r.marks || {} };
|
|
28
30
|
X.read = true;
|
|
29
31
|
draw();
|
|
32
|
+
readReports();
|
|
30
33
|
}
|
|
34
|
+
// the reports that go out today, at their time (GET /api/events-place; 202 while a Board is read: ask again in a moment, three times)
|
|
35
|
+
async function readReports(n = 0) {
|
|
36
|
+
const r = await ctx.pmGet('/api/events-place').catch(() => null);
|
|
37
|
+
if (r && r.state === 'reading' && n < 3) { setTimeout(() => readReports(n + 1), 4000); return; }
|
|
38
|
+
if (!r || !r.ok) return;
|
|
39
|
+
const today = day();
|
|
40
|
+
X.reports = (r.items || []).filter((x) => x && x.kind === 'report' && x.date === today && x.time).map((x) => ({ key: x.key, title: x.title, time: x.time }));
|
|
41
|
+
draw();
|
|
42
|
+
}
|
|
43
|
+
// the head's clock: the time on it moves each minute, and only its words change
|
|
44
|
+
setInterval(() => { const w = el && el.querySelector('.td-when'); if (w) w.textContent = TM.headModel(ctx.now()).when; }, 30000);
|
|
31
45
|
const tdItems = () => {
|
|
32
46
|
const tabs = (ctx.S.D.work && ctx.S.D.work.queue && ctx.S.D.work.queue.tabs) || [];
|
|
33
47
|
return ((tabs.find((t) => t.key === 'today') || { groups: [] }).groups || []).flatMap((g) => g.rows || []);
|
|
@@ -42,9 +56,12 @@ export function mountToday(ctx) {
|
|
|
42
56
|
const lab = (S.lab || []).flatMap((l) => (l.items || []).map((f) => ({ ...f, ws: l.ws, board: l.board })));
|
|
43
57
|
const L = TM.logModel({ rank: ctx.rank(), move, items: tdItems(), drafts, review: R && R.open && !R.done ? { title: 'Your weekly review' } : null,
|
|
44
58
|
own: X.log.entries, marks: X.log.marks, lab, titleOf: ctx.titleOf, now });
|
|
45
|
-
const
|
|
59
|
+
const lead = L.rows.find((r) => !r.done && r.src !== 'note' && r.src !== 'own' && r.src !== 'lab');
|
|
60
|
+
const A = TM.agendaModel({ meetings: ctx.meetings(), own: X.log.entries, reports: X.reports || [], focus: lead ? { key: lead.key, title: lead.title } : null, now,
|
|
46
61
|
iniOf: (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null });
|
|
47
|
-
|
|
62
|
+
const O = TM.overviewModel(L, A);
|
|
63
|
+
O.suggest = O.suggest.filter((x) => !X.hide.has(x.key));
|
|
64
|
+
return { L, A, O };
|
|
48
65
|
}
|
|
49
66
|
function draw() {
|
|
50
67
|
document.body.classList.toggle('cz-today', on());
|
|
@@ -52,37 +69,72 @@ export function mountToday(ctx) {
|
|
|
52
69
|
if (!on()) { el.hidden = true; return; }
|
|
53
70
|
el.hidden = false;
|
|
54
71
|
if (!ctx.S.ready) { if (!el.firstChild) el.innerHTML = '<p class="td-none">Reading your day.</p>'; return; }
|
|
55
|
-
const { L, A } = models();
|
|
56
|
-
X.model = L; X.agenda = A;
|
|
72
|
+
const { L, A, O } = models();
|
|
73
|
+
X.model = L; X.agenda = A; X.overview = O;
|
|
74
|
+
autoClosed();
|
|
75
|
+
// the rail's number on every place: the lines for today (Do first and what waits today), the number the Overview says; kept for the
|
|
76
|
+
// other places with its day (pm/cozy-nav.js reads it there)
|
|
77
|
+
if (O.today !== X.calls) {
|
|
78
|
+
X.calls = O.today;
|
|
79
|
+
document.dispatchEvent(new CustomEvent('cz:calls', { detail: { count: O.today } }));
|
|
80
|
+
try { localStorage.setItem('pmos.today.count', JSON.stringify({ day: L.today, n: O.today })); } catch { /* a private window */ }
|
|
81
|
+
}
|
|
82
|
+
if (X.type && !(L.types || {})[X.type]) X.type = '';
|
|
57
83
|
const cap = document.getElementById('tdCap'), draft = cap ? cap.value : '', focus = !!cap && document.activeElement === cap;
|
|
58
|
-
const html = TP.pageHtml(L, A, {
|
|
84
|
+
const html = TP.pageHtml(L, A, { draft, overview: O, type: X.type, open: X.open || !!X.type, handled: X.type && X.type !== 'Ask' ? [] : handled(), hopen: X.hopen });
|
|
59
85
|
if (html === X.html && el.firstChild) return;
|
|
60
86
|
X.html = html;
|
|
61
87
|
const st = el.parentNode ? el.parentNode.scrollTop : 0;
|
|
62
|
-
el.innerHTML = html;
|
|
88
|
+
el.innerHTML = TP.headHtml(TM.headModel(ctx.now())) + html;
|
|
63
89
|
if (el.parentNode) el.parentNode.scrollTop = st;
|
|
64
90
|
const c2 = document.getElementById('tdCap'); if (c2 && focus) { c2.focus(); c2.setSelectionRange(c2.value.length, c2.value.length); }
|
|
65
91
|
}
|
|
66
92
|
const rowOf = (key) => (X.model ? X.model.rows.find((r) => r.key === key) : null);
|
|
67
|
-
const snap = (r) => ({ title: r.title, work: r.work, job: r.job });
|
|
68
|
-
async function
|
|
93
|
+
const snap = (r) => ({ title: r.title, work: r.work, job: r.job, type: r.type });
|
|
94
|
+
async function mark1(key, act, extra) {
|
|
69
95
|
const r = await ctx.pmPost('/api/today-log/mark', { key, act, day: day(), ...extra }).catch(() => null);
|
|
70
96
|
return r && r.ok ? r : { ok: false, error: (r && r.error) || 'the server did not answer' };
|
|
71
97
|
}
|
|
98
|
+
/** A mark goes to every key behind a line (the same ask from two people is one line with two keys). */
|
|
99
|
+
async function mark(key, act, extra = {}) {
|
|
100
|
+
const r = rowOf(key), keys = r && r.keys && r.keys.length ? r.keys : [key];
|
|
101
|
+
let res = null;
|
|
102
|
+
for (const k of keys) { res = await mark1(k, act, k === key ? extra : {}); if (!res.ok) return res; }
|
|
103
|
+
return res;
|
|
104
|
+
}
|
|
72
105
|
/** After a write: read the log again, and Home's own lists when the source changed. */
|
|
73
106
|
const after = async (src) => { if (src) await ctx.reload(); await read(); };
|
|
74
107
|
const pop = (r) => ctx.VW.popNext({ keep: true, id: r.ini || r.key, kind: r.ini ? 'initiative' : 'item', title: r.ini ? ctx.titleOf(r.ini) : r.title });
|
|
75
108
|
/** A chat-only press (a session that asks): the popup with that chat and the sessions on its left. */
|
|
76
109
|
const chatPop = () => setTimeout(() => { if (!ctx.VW.popOpen()) { ctx.VW.popNext(null); const t = ctx.chatNow(); if (t) ctx.POP.openCos(t); } }, 120);
|
|
77
110
|
|
|
111
|
+
/** The popup's chat hidden for this open (round 3 point 7), until the popup's own per-item rule does it. */
|
|
112
|
+
const chatOff = () => setTimeout(() => { const h = document.querySelector('.cz-pop:not([hidden]) [data-pop="hide"]'); if (h && !h.closest('.chat-off')) h.click(); }, 60);
|
|
113
|
+
/** The rows in the order Today shows them, the ones that open something. */
|
|
114
|
+
const order = () => { const L = X.model; if (!L) return []; return [...(L.first || []), ...(L.todayRows || []), ...(X.open || X.type ? L.wait || [] : [])].filter((r) => r && !r.done && r.src !== 'note' && r.src !== 'own'); };
|
|
115
|
+
/** ↑ ↓ (j k) in the popup: the previous or next Today row opens in its place. true when it stepped. */
|
|
116
|
+
function step(d) {
|
|
117
|
+
const list = order(), i = list.findIndex((r) => r.key === X.last);
|
|
118
|
+
const next = list[i < 0 ? 0 : i + d]; if (!next) return false;
|
|
119
|
+
open(next); return true;
|
|
120
|
+
}
|
|
78
121
|
function open(r) {
|
|
79
122
|
if (!r) return;
|
|
80
123
|
const ref = r.ref || {};
|
|
124
|
+
X.last = r.key; // ↑ ↓ (j k) step from here (round 3 point 6)
|
|
81
125
|
if (r.src === 'ask') {
|
|
126
|
+
// a mention opens that one mention in the popup, about it, with the chat hidden (round 3 points 1 to 7); never the Mentions list
|
|
127
|
+
if (ref.kind === 'mention' && ref.mention && ctx.openMention) {
|
|
128
|
+
const m = ref.mention;
|
|
129
|
+
ctx.VW.popNext({ id: 'mention:' + m.id, kind: 'mention', title: OM.askTitle(m) });
|
|
130
|
+
if (ctx.openMention(m.id, { step, m })) { chatOff(); return; } // m: the row's own copy when a fresh read no longer lists it
|
|
131
|
+
}
|
|
132
|
+
// a Check (did it work?) opens its initiative, where the verdict is asked, not the Intelligence list (round 3 point 8)
|
|
133
|
+
if (ref.kind === 'verdict') { const ini = ref.ini || (ref.verdict && ref.verdict.ini); if (ini && ctx.hasIni(ini)) { ctx.goIni(ini); return; } }
|
|
82
134
|
if (ref.kind === 'call') { const c = ref.call || {}; if (c.ini && ctx.hasIni(c.ini) && !ASK_SEND.has(c.kind)) { ctx.goIni(c.ini); return; } pop(r); ctx.select(c.id); if (ASK_SEND.has(c.kind)) chatPop(); return; }
|
|
83
135
|
pop(r); ctx.movePress({ dataset: { yd: 'mv-open', key: ref.key }, disabled: false }); return;
|
|
84
136
|
}
|
|
85
|
-
if (r.src === 'move') { if (ref.kind === 'task' && r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini); return; } pop(r); ctx.select(r.key); if (ref.kind === 'session') chatPop(); return; }
|
|
137
|
+
if (r.src === 'move') { if (ref.kind === 'task' && r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini, { task: (ref.task && ref.task.uid) || null }); return; } pop(r); ctx.select(r.key); if (ref.kind === 'session') chatPop(); return; }
|
|
86
138
|
if (r.src === 'item') { if (r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini); return; } pop(r); import('./home-work.js').then((M) => M.openWorkItem(ref.key)).catch(() => {}); return; }
|
|
87
139
|
if (r.src === 'draft') { pop(r); ctx.openFinished(ref.fin); return; }
|
|
88
140
|
if (r.src === 'review') { pop(r); ctx.openReviewVw(); return; }
|
|
@@ -172,6 +224,36 @@ export function mountToday(ctx) {
|
|
|
172
224
|
if (undo) ctx.toastUndo(said, undo); else ctx.toast(said);
|
|
173
225
|
return after(true);
|
|
174
226
|
}
|
|
227
|
+
/** ✦ Looks answered on an ask: ✓ closes it (answered, with Undo), ✕ keeps it waiting and PMOS does not ask again until the thread moves. */
|
|
228
|
+
async function looks(r, yes) {
|
|
229
|
+
const ids = (r.keys || [r.key]).filter((k) => /^mn:/.test(k)).map((k) => k.slice(3));
|
|
230
|
+
let ok = 0; for (const id of ids) { const m = await ctx.mentionAct(id, yes ? 'answered' : 'keep').catch(() => null); if (m && m.ok) ok++; }
|
|
231
|
+
if (!ok) return ctx.toast('It did not go through. Nothing changed.');
|
|
232
|
+
await ctx.reloadMentions();
|
|
233
|
+
if (!yes) return ctx.toast('Kept waiting. PMOS will not ask again unless the thread moves.');
|
|
234
|
+
ctx.toastUndo('Closed: ' + r.title + '.', async () => { let u = { ok: true }; for (const id of ids) u = await ctx.mentionAct(id, 'undo').catch(() => ({ ok: false })); await ctx.reloadMentions(); return u; });
|
|
235
|
+
}
|
|
236
|
+
/** The self check closed an ask he had answered already (his reply, a closed ticket, the ask taken back): it left Today by itself; the
|
|
237
|
+
* toast says how, once, with Undo (round 3 point 10c). The asks Today showed as waiting are kept on this computer to tell which left. */
|
|
238
|
+
/** PMOS handled · N: the asks the self check cleared today (design check of round 3, point 6). */
|
|
239
|
+
function handled() {
|
|
240
|
+
const M = ctx.mentions ? ctx.mentions() : null; if (!M || !M.loaded || M.failed) return [];
|
|
241
|
+
let c = null; try { c = JSON.parse(localStorage.getItem('pmos.today.cleared') || 'null'); } catch { c = null; }
|
|
242
|
+
return TM.handledModel(M.answered, { today: day(), now: ctx.now(), cleared: c && c.day === day() ? c.ids : [] });
|
|
243
|
+
}
|
|
244
|
+
function autoClosed() {
|
|
245
|
+
const L = ctx.mentions ? ctx.mentions() : null; if (!L || !L.loaded || L.failed) return;
|
|
246
|
+
let was = null; try { was = JSON.parse(localStorage.getItem('pmos.today.waits') || 'null'); } catch { was = null; }
|
|
247
|
+
try { localStorage.setItem('pmos.today.waits', JSON.stringify(L.waiting.map((m) => m.id))); } catch { /* a private window */ }
|
|
248
|
+
if (!Array.isArray(was)) return;
|
|
249
|
+
const gone = L.answered.filter((m) => m.auto && m.proof && was.includes(m.id)); if (!gone.length) return;
|
|
250
|
+
try { const c = JSON.parse(localStorage.getItem('pmos.today.cleared') || 'null'); const ids = c && c.day === day() ? c.ids : [];
|
|
251
|
+
localStorage.setItem('pmos.today.cleared', JSON.stringify({ day: day(), ids: [...new Set([...ids, ...gone.map((m) => m.id)])] })); } catch { /* a private window */ }
|
|
252
|
+
const nm = (m) => String((m.people && m.people[0]) || m.who || 'Someone').trim().split(/\s+/)[0];
|
|
253
|
+
const said = gone.length === 1 ? 'Answered already, so it left Today: ' + nm(gone[0]) + '. ' + OM.proofText(gone[0].proof, ctx.now()) + '.'
|
|
254
|
+
: gone.length + ' asks were answered already, so they left Today: ' + gone.map(nm).join(', ') + '.';
|
|
255
|
+
ctx.toastUndo(said, async () => { let u = { ok: true }; for (const m of gone) u = await ctx.mentionAct(m.id, 'reopen').catch(() => ({ ok: false })); await ctx.reloadMentions(); return u; });
|
|
256
|
+
}
|
|
175
257
|
/** The date chooser beside a row: one date field; Enter or a change sets it, Escape or a press outside closes it. */
|
|
176
258
|
function chooseDate(r, btn) {
|
|
177
259
|
document.querySelectorAll('.td-dp').forEach((x) => x.remove());
|
|
@@ -193,12 +275,36 @@ export function mountToday(ctx) {
|
|
|
193
275
|
try { i.showPicker(); } catch { /* the field itself is the chooser */ }
|
|
194
276
|
}
|
|
195
277
|
|
|
278
|
+
// j k with any Today row's item open in the popup: the next or previous row opens in its place (↑ ↓ too in the one-mention popup)
|
|
279
|
+
document.addEventListener('keydown', (e) => {
|
|
280
|
+
if (!on() || !X.last || e.metaKey || e.ctrlKey || e.altKey || (e.key !== 'j' && e.key !== 'k')) return;
|
|
281
|
+
if (!(ctx.VW.popOpen && ctx.VW.popOpen()) || (e.target && e.target.closest && e.target.closest('input,textarea,select,[contenteditable],.cz-pop-chat,[role="textbox"]'))) return;
|
|
282
|
+
if (step(e.key === 'j' ? 1 : -1)) e.preventDefault();
|
|
283
|
+
});
|
|
196
284
|
if (el) {
|
|
197
285
|
el.addEventListener('click', async (e) => {
|
|
198
286
|
const b = e.target.closest('[data-td]'); if (!b || b.disabled) return;
|
|
199
287
|
const act = b.dataset.td, key = b.dataset.key || '';
|
|
200
288
|
if (act === 'cal') { ctx.openCalendar(); return; }
|
|
201
|
-
if (act === '
|
|
289
|
+
if (act === 'fold') { X.open = !X.open; draw(); return; }
|
|
290
|
+
if (act === 'hfold') { X.hopen = !X.hopen; draw(); return; }
|
|
291
|
+
if (act === 'h-undo') {
|
|
292
|
+
b.disabled = true; const m = await ctx.mentionAct(key, 'reopen').catch(() => null);
|
|
293
|
+
if (!m || !m.ok) { b.disabled = false; return ctx.toast('It did not go through. Nothing changed.'); }
|
|
294
|
+
await ctx.reloadMentions(); ctx.toast('Back on Today: it still waits on you.'); return;
|
|
295
|
+
}
|
|
296
|
+
if (act === 'type') { X.type = X.type === key ? '' : key; draw(); return; }
|
|
297
|
+
if (act === 'ov-yes' || act === 'ov-no') {
|
|
298
|
+
const sg = X.overview && X.overview.suggest.find((x) => x.key === key); if (!sg || X.busy.has(key)) return;
|
|
299
|
+
X.busy.add(key); b.disabled = true;
|
|
300
|
+
try {
|
|
301
|
+
if (act === 'ov-no') { for (const k of sg.keys) await mark1(k, 'keep', {}); X.hide.add(key); ctx.toast('Kept. PMOS will not suggest it again for a month.'); return after(false); }
|
|
302
|
+
const done = []; for (const k of sg.keys) { const m = await mark1(k, 'drop', {}); if (m.ok) done.push(k); }
|
|
303
|
+
if (!done.length) return ctx.toast('Nothing was dropped. Nothing changed.');
|
|
304
|
+
ctx.toastUndo('Dropped ' + done.length + (done.length === 1 ? ' line' : ' lines') + ' from your log.', async () => { let u = { ok: true }; for (const k of done) u = await mark1(k, 'undrop', {}); after(false); return u; });
|
|
305
|
+
return after(false);
|
|
306
|
+
} finally { X.busy.delete(key); if (b.isConnected) b.disabled = false; }
|
|
307
|
+
}
|
|
202
308
|
if (act === 'ev') {
|
|
203
309
|
const x = X.agenda && X.agenda.items.find((y) => y.key === key); if (!x) return;
|
|
204
310
|
if (x.ini && ctx.hasIni(x.ini)) { ctx.goIni(x.ini); return; }
|
|
@@ -215,6 +321,7 @@ export function mountToday(ctx) {
|
|
|
215
321
|
else if (act === 'drop') await drop(r);
|
|
216
322
|
else if (act === 'keep') await keep(r);
|
|
217
323
|
else if (act === 'lab-keep' || act === 'lab-drop') await lab(r, act === 'lab-keep');
|
|
324
|
+
else if (act === 'lk-yes' || act === 'lk-no') await looks(r, act === 'lk-yes');
|
|
218
325
|
} finally { X.busy.delete(key); if (b.isConnected) b.disabled = false; }
|
|
219
326
|
});
|
|
220
327
|
// the first line: Enter adds the row, and nothing else happens (no popup, no session)
|