create-pmos 0.440.0 → 0.442.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 +25 -25
- 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/adler-seasons-art-test.js +106 -0
- package/workspace/adler-seasons-test.js +111 -0
- package/workspace/briefing-premium-adddoc-test.js +16 -13
- package/workspace/briefing-premium-board-test.js +19 -17
- package/workspace/briefing-premium-initiative-test.js +7 -4
- package/workspace/briefing-premium-products-test.js +4 -4
- package/workspace/briefing-premium-sources-test.js +2 -2
- package/workspace/briefing-premium-test.js +29 -23
- package/workspace/changelog.json +24 -0
- package/workspace/guide/adler.md +10 -0
- package/workspace/guide/core-documents.md +2 -2
- package/workspace/guide/data-freshness.md +7 -5
- package/workspace/guide/home.md +3 -1
- package/workspace/guide/horizon-scan.md +1 -1
- package/workspace/ini-workflow-test.js +6 -2
- package/workspace/lib/agent-inbox.js +20 -2
- package/workspace/lib/briefing-premium-sources.js +3 -0
- package/workspace/lib/briefing-premium.js +37 -7
- package/workspace/lib/driver-cli.js +1 -1
- package/workspace/lib/driver-run.js +15 -1
- package/workspace/lib/driver.js +31 -2
- package/workspace/lib/news-for-you.js +24 -9
- package/workspace/lib/pm-idle.js +12 -0
- package/workspace/lib/refresh.js +17 -8
- package/workspace/lib/routes-core-docs.js +1 -1
- package/workspace/lib/routes-news.js +15 -1
- package/workspace/lib/routes-phone-day.js +6 -4
- package/workspace/lib/settings-store.js +38 -0
- package/workspace/metric-drafts-ui-test.js +2 -2
- package/workspace/need-shot.js +57 -0
- package/workspace/news-viewers-test.js +183 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +2 -1
- package/workspace/premium-chat-attach-test.js +2 -0
- package/workspace/premium-core-doc-issue-test.js +9 -8
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-ini-panel.js +6 -13
- package/workspace/public/pm/c3-ini-ui.js +1 -1
- package/workspace/public/pm/cozy-adler.css +21 -0
- package/workspace/public/pm/cozy-adler.js +415 -8
- package/workspace/public/pm/cozy-ev.css +44 -0
- package/workspace/public/pm/cozy-home.css +8 -0
- package/workspace/public/pm/cozy-news.js +186 -22
- package/workspace/public/pm/cozy-seasons.js +318 -0
- package/workspace/public/pm/cozy-settings.js +88 -5
- package/workspace/public/pm/cozy-today.css +5 -0
- package/workspace/public/pm/cozy-viewer.js +12 -7
- package/workspace/public/pm/cozy-vw-shell.css +49 -0
- package/workspace/public/pm/cozy.css +65 -0
- package/workspace/public/pm/dash-view.js +4 -2
- package/workspace/public/pm/home-adddoc.js +46 -26
- package/workspace/public/pm/home-app.js +142 -114
- package/workspace/public/pm/home-chat.js +1 -1
- package/workspace/public/pm/home-day.js +17 -9
- package/workspace/public/pm/home-draft.js +35 -23
- package/workspace/public/pm/home-ini.js +4 -4
- package/workspace/public/pm/home-mentions.js +1 -1
- package/workspace/public/pm/home-need.js +336 -0
- package/workspace/public/pm/home-today.js +2 -2
- package/workspace/public/pm/home-work.js +51 -4
- package/workspace/public/pm/impact.js +1 -1
- package/workspace/public/pm/ini-groups.js +15 -10
- package/workspace/public/pm/ini-links.js +1 -1
- package/workspace/public/pm/ini-tasks.js +208 -44
- package/workspace/public/pm/ini-view-model.js +8 -2
- package/workspace/public/pm/ini-view.css +305 -1
- package/workspace/public/pm/ini-view.js +190 -80
- package/workspace/public/pm/mission.js +234 -0
- package/workspace/public/pm/premium-board.js +1 -1
- package/workspace/public/pm/premium-welcome.js +2 -2
- package/workspace/public/pm/small-vw.js +128 -0
- package/workspace/public/pm/split-merge.js +1 -1
- package/workspace/public/pm/stage-line.js +2 -2
- package/workspace/server.js +10 -6
- package/workspace/skills/initiative-drive.skill +4 -1
- package/workspace/split-merge-ui-test.js +1 -1
- package/workspace/stage-card-test.js +48 -11
- package/workspace/task-links-test.js +2 -0
- package/workspace/task-milestones-test.js +5 -1
- package/workspace/task-plans-test.js +3 -3
- package/workspace/task-views-test.js +90 -37
- package/workspace/test-lists/adler-seasons-art.json +13 -0
- package/workspace/test-lists/batch18-adler-seasons.json +13 -0
- package/workspace/test-lists/batch18-asks.json +5 -0
- package/workspace/test-lists/mission.json +5 -0
- package/workspace/test-lists/news-viewers.json +13 -0
- package/workspace/test-lists/small-viewers.json +5 -0
- package/workspace/test-lists/viewer-tasks.json +5 -0
- package/workspace/tk-tasks-test.js +25 -30
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/* home-draft.js — a core document's draft, read in Home's Viewer, with Issue it (premium-agreed-design; initiative premium-core-doc-issue
|
|
2
|
-
*
|
|
3
|
-
* Read
|
|
1
|
+
/* home-draft.js — a core document's draft, read in Home's Viewer, with Issue it (premium-agreed-design; initiative premium-core-doc-issue;
|
|
2
|
+
* batch 18 item 2-C, canvas OvA9Docs). Shell A: the title, "A draft · <initiative>" under it, ✎ Edit in the header (pressed while editing,
|
|
3
|
+
* in place of the old Read | Edit tabs), ⋯ Copy path (the path is not in the body). The summary waits for you to read, with Issue it the one
|
|
4
|
+
* primary, above the text. Edit is the document page's own editor (premium-vw-doc.js, ctx.host), so a save goes through POST /api/doc-sheet/edit as everywhere else.
|
|
4
5
|
* Issue it posts POST /api/core-docs/issue { ws, scope, key, slot } and nothing else: it marks the draft issued and sends nothing to anyone.
|
|
5
6
|
* Issue it is refused here while the editor holds typed text that is not saved.
|
|
6
7
|
*
|
|
7
|
-
* openDraftVw({ VW, pmGet, pmPost, toast, ws, scope, doc, onIssued })
|
|
8
|
+
* openDraftVw({ VW, pmGet, pmPost, toast, ws, scope, doc, iniTitle?, onIssued })
|
|
8
9
|
* doc the docs row: { key, title, path, slot, st, state }
|
|
9
10
|
* onIssued awaited after the route answers ok (the page reads again)
|
|
10
11
|
*/
|
|
@@ -12,20 +13,22 @@ import { mdHtml } from './premium-doc-edit.js';
|
|
|
12
13
|
|
|
13
14
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
14
15
|
|
|
16
|
+
const PEN = 'M4 20h4L19 9l-4-4L4 16zM14 6l4 4', COPY = 'M8 8h11v12H8zM5 16V4h11';
|
|
17
|
+
|
|
15
18
|
export function openDraftVw(o) {
|
|
16
|
-
const d = o.doc;
|
|
19
|
+
const d = o.doc, VW = o.VW;
|
|
17
20
|
const X = { tab: 'read', text: null, err: '', issued: d.st !== 'draft', dirty: false, busy: false, msg: '' };
|
|
18
21
|
const wsq = () => (o.ws ? '&ws=' + encodeURIComponent(o.ws) : '');
|
|
22
|
+
const id = 'draft:' + o.scope + ':' + d.key;
|
|
19
23
|
let body = null;
|
|
20
|
-
const
|
|
21
|
-
?
|
|
22
|
-
: `<div
|
|
24
|
+
const sum = () => (X.issued
|
|
25
|
+
? `<div data-issue-bar="done" role="status">${VW.czSummary({ line: 'Issued', tone: 'ok', text: 'Nothing was sent to anyone.' })}</div>`
|
|
26
|
+
: `<div data-issue-bar="draft">${VW.czSummary({ line: 'Waits for you to read', tone: 'you', text: 'When it reads right, issue it. Issuing marks it issued and sends nothing to anyone.', primary: { label: 'Issue it', act: 'issue', disabled: X.busy } })}</div>`);
|
|
27
|
+
const presses = () => [{ act: 'edit', label: X.tab === 'edit' ? 'Back to reading' : 'Edit the draft', icon: PEN, pressed: X.tab === 'edit' }];
|
|
23
28
|
const draw = () => {
|
|
24
29
|
if (!body) return;
|
|
25
|
-
const tabs = `<div class="hx-tabs ut-chips" role="tablist" aria-label="Draft">${[['read', 'Read'], ['edit', 'Edit']].map(([k, l]) => `<button type="button" class="cz-chip${X.tab === k ? ' on' : ' gh'}" role="tab" aria-selected="${X.tab === k}" aria-pressed="${X.tab === k}" data-ds="${k}">${l}</button>`).join('')}</div>`;
|
|
26
30
|
const text = X.text == null ? `<p class="hx-n">${esc(X.err || 'Reading the draft.')}</p>` : `<div class="dsbody hm-md">${mdHtml(X.text).html}</div>`;
|
|
27
|
-
body.innerHTML =
|
|
28
|
-
+ (X.tab === 'read' ? text : '<div class="hm-dsed" data-ds-host></div>') + '</div>';
|
|
31
|
+
body.innerHTML = sum() + `<p class="czf-err" id="dsErr" role="alert">${esc(X.msg)}</p>` + (X.tab === 'read' ? text : '<div class="hm-dsed" data-ds-host></div>');
|
|
29
32
|
if (X.tab === 'edit') mountEditor();
|
|
30
33
|
};
|
|
31
34
|
async function read() {
|
|
@@ -42,19 +45,18 @@ export function openDraftVw(o) {
|
|
|
42
45
|
host.addEventListener('input', () => { X.dirty = true; });
|
|
43
46
|
host.addEventListener('keydown', (e) => { if (e.key.length === 1 || e.key === 'Backspace' || e.key === 'Delete' || e.key === 'Enter') X.dirty = true; });
|
|
44
47
|
const M = await import('./premium-vw-doc.js');
|
|
45
|
-
M.openDocPage({ path: d.path, title: d.title }, { host, ws: () => o.ws || '', onWrite: async () => { X.dirty = false; await read(); }, onClose: () => { X.dirty = false;
|
|
48
|
+
M.openDocPage({ path: d.path, title: d.title }, { host, ws: () => o.ws || '', onWrite: async () => { X.dirty = false; await read(); }, onClose: () => { X.dirty = false; tab('read'); } });
|
|
49
|
+
}
|
|
50
|
+
const say = (m) => { X.msg = m; const e = body.querySelector('#dsErr'); if (e) e.textContent = m; };
|
|
51
|
+
/** ✎ in the header: Edit, and pressed again, back to reading (refused while the editor holds typed text that is not saved) */
|
|
52
|
+
function tab(k) {
|
|
53
|
+
if (k === X.tab) return;
|
|
54
|
+
if (k === 'read' && X.dirty) { say('You have unsaved changes in Edit. Save or cancel them there.'); return; } // leaving Edit would drop the typed text
|
|
55
|
+
X.msg = ''; X.tab = k; if (VW.setPresses) VW.setPresses(id, presses()); draw(); if (k === 'read') read();
|
|
46
56
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const k = b.dataset.ds;
|
|
51
|
-
if (k === 'read' || k === 'edit') {
|
|
52
|
-
if (k === X.tab) return;
|
|
53
|
-
if (k === 'read' && X.dirty) { X.msg = 'You have unsaved changes in Edit. Save or cancel them there.'; body.querySelector('#dsErr').textContent = X.msg; return; } // leaving Edit would drop the typed text
|
|
54
|
-
X.msg = ''; X.tab = k; draw(); if (k === 'read') read(); return;
|
|
55
|
-
}
|
|
56
|
-
if (k !== 'issue') return;
|
|
57
|
-
if (X.dirty) { X.msg = 'This draft has unsaved changes. Save or cancel them first, then issue it.'; body.querySelector('#dsErr').textContent = X.msg; return; }
|
|
57
|
+
async function issue() {
|
|
58
|
+
if (X.issued || X.busy) return;
|
|
59
|
+
if (X.dirty) { say('This draft has unsaved changes. Save or cancel them first, then issue it.'); return; }
|
|
58
60
|
X.busy = true; X.msg = ''; draw();
|
|
59
61
|
const r = await o.pmPost('/api/core-docs/issue', { ws: o.ws, scope: o.scope, key: d.key, slot: d.slot });
|
|
60
62
|
X.busy = false;
|
|
@@ -62,6 +64,16 @@ export function openDraftVw(o) {
|
|
|
62
64
|
X.issued = true; draw();
|
|
63
65
|
o.toast('Issued. Nothing was sent to anyone.');
|
|
64
66
|
if (o.onIssued) await o.onIssued();
|
|
67
|
+
}
|
|
68
|
+
body = VW.open({ id, kind: 'Draft · ' + (d.state || 'Draft'), title: d.title, sub: 'A draft' + (o.iniTitle ? ' · ' + o.iniTitle : ''), icon: 'doc',
|
|
69
|
+
presses: presses(), onPress: (a) => { if (a === 'edit') tab(X.tab === 'edit' ? 'read' : 'edit'); },
|
|
70
|
+
more: [{ label: 'Copy path', icon: COPY, on: () => copy() }],
|
|
71
|
+
render: (b) => { body = b; draw(); } });
|
|
72
|
+
async function copy() {
|
|
73
|
+
try { await navigator.clipboard.writeText(d.path); o.toast('Path copied.'); } catch { o.toast('The path was not copied: ' + d.path); }
|
|
74
|
+
}
|
|
75
|
+
body.onclick = (e) => {
|
|
76
|
+
const b = e.target.closest('[data-czs-act="issue"]'); if (b && body.contains(b)) issue();
|
|
65
77
|
};
|
|
66
78
|
read();
|
|
67
79
|
return body;
|
|
@@ -54,7 +54,7 @@ function dashFor(id) {
|
|
|
54
54
|
if (!id || id === 'product' || !X.ctx) return null;
|
|
55
55
|
if (!DASH.has(id)) {
|
|
56
56
|
const wsOf = () => { const M = curM(); return (M && M.board.ws) || (rowOf(id) || {}).ws || ''; };
|
|
57
|
-
DASH.set(id, DB.dashHost({ page: 'initiative:' + id, scope: 'initiative:' + id, ws: wsOf, board: () => { const M = curM(); return (M && M.board.id) || (rowOf(id) || {}).boardId || ''; },
|
|
57
|
+
DASH.set(id, DB.dashHost({ page: 'initiative:' + id, menu: true, scope: 'initiative:' + id, ws: wsOf, board: () => { const M = curM(); return (M && M.board.id) || (rowOf(id) || {}).boardId || ''; },
|
|
58
58
|
vid: 'ov:' + id, VW: X.ctx.VW, redraw: () => { if (BODY) BODY.__pg = null; redrawView(); }, toast: (t) => X.ctx.toast(t),
|
|
59
59
|
openReport: async (row) => { if (!row.path) return; X.ctx.VW.drill(); (await import('./premium-report-read.js')).openReportView(row.path, { ws: wsOf(), name: row.name, cuts: true }); } }));
|
|
60
60
|
}
|
|
@@ -440,7 +440,7 @@ export function iniPage() {
|
|
|
440
440
|
let rename = X.ctx.renameIni ? X.ctx.renameIni(id, '') : null;
|
|
441
441
|
if (rename) rename = { ...rename, value: X.ctx.iniTitle(id) };
|
|
442
442
|
const dh = dashFor(id);
|
|
443
|
-
BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', more: () => pageMore(id), rename,
|
|
443
|
+
BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', wrap: true, more: () => pageMore(id), rename,
|
|
444
444
|
discuss: () => X.ctx.newIn(id), discussHome: true, // the one view (OvViewers): Discuss starts a new session about it, where + New session was
|
|
445
445
|
presses: dh ? dh.presses() : null, onPress: (a) => { if (a === 'dash' && dh) dh.toggle(); },
|
|
446
446
|
render: (b) => { X.view = 'page'; BODY = b; ADDING = null; draw(b); wire(b, id); wirePage(b, id); if (dh) dh.wire(b); } });
|
|
@@ -598,7 +598,7 @@ function wire(body, id) {
|
|
|
598
598
|
if (/^(draft|open):/.test(d.czsAct || '')) {
|
|
599
599
|
const key = d.czsAct.slice(d.czsAct.indexOf(':') + 1), doc = (M.docs.rows || []).find((x) => x.key === key); if (!doc) return;
|
|
600
600
|
if (d.czsAct.startsWith('draft:')) { after(await X.ctx.pmPost('/api/core-docs/draft', { ws: M.board.ws, scope: M.docs.scope, key }), 'The draft started. It waits for you to read.'); return; }
|
|
601
|
-
if (doc.path && doc.st === 'draft' && doc.slot) { const A = await import('./home-draft.js'); A.openDraftVw({ VW: X.ctx.VW, pmGet: X.ctx.pmGet, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, doc, onIssued: () => X.ctx.load() }); return; }
|
|
601
|
+
if (doc.path && doc.st === 'draft' && doc.slot) { const A = await import('./home-draft.js'); A.openDraftVw({ VW: X.ctx.VW, pmGet: X.ctx.pmGet, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, doc, iniTitle: X.ctx.iniTitle(id), onIssued: () => X.ctx.load() }); return; }
|
|
602
602
|
X.ctx.openFile({ path: doc.path, name: doc.title }); return;
|
|
603
603
|
}
|
|
604
604
|
if ('hiDby' in d) { menu(t, Object.entries(MD.DOC_BY).map(([k, l]) => ({ label: l, radio: true, on: X.doc.by === k, go: () => { X.doc.by = k; redrawView(); } })), 'Group documents by'); return; }
|
|
@@ -618,7 +618,7 @@ function wire(body, id) {
|
|
|
618
618
|
if (d.ovDread) {
|
|
619
619
|
const doc = (M.docs.rows || []).find((x) => x.key === d.ovDread); if (!doc) return;
|
|
620
620
|
const A = await import('./home-draft.js');
|
|
621
|
-
A.openDraftVw({ VW: X.ctx.VW, pmGet: X.ctx.pmGet, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, doc, onIssued: () => X.ctx.load() });
|
|
621
|
+
A.openDraftVw({ VW: X.ctx.VW, pmGet: X.ctx.pmGet, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, doc, iniTitle: X.ctx.iniTitle(id), onIssued: () => X.ctx.load() });
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
624
|
if ('ovAdddoc' in d) { addDoc(id); return; }
|
|
@@ -37,7 +37,7 @@ const P = {
|
|
|
37
37
|
all: 'M2 12.5l4.5 4.5L15 8M9 15l2 2L22 7', spark: VW.ICONS.spark,
|
|
38
38
|
};
|
|
39
39
|
const BADGE = { slack: 'M9 4l-2 16M17 4l-2 16M4 9h16M3 15h16', mail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7', gmail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7',
|
|
40
|
-
jira: '
|
|
40
|
+
jira: 'M4 7h16v3a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4z', confluence: 'M7 3h7l4 4v14H7zM14 3v4h4', doc: 'M7 3h7l4 4v14H7zM14 3v4h4' };
|
|
41
41
|
const svg = (d, w = 16, sw = 2) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
42
42
|
const srcName = (s) => SRC[s] || (s ? String(s).charAt(0).toUpperCase() + String(s).slice(1) : 'its source');
|
|
43
43
|
const sendIn = (s) => (s === 'mail' ? 'your email' : srcName(s));
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/* pm/home-need.js — the asks in the Viewer: every row of Home that waits on the PM (batch 18 item 2-A, canvas In development OvA1Start,
|
|
2
|
+
* OvA1After, OvA2Decide, OvA3Waited, OvA4Source, OvA11Dark, OvA12Edges, OvA10Desk).
|
|
3
|
+
*
|
|
4
|
+
* One pattern for every kind (start / blocked, decision, waited, source, agent drafts):
|
|
5
|
+
* header ← · tile · the thing's name (two lines at most) · Pin (aria-pressed) · Put off (Later today / Tomorrow / Next week) · ⋯
|
|
6
|
+
* (Open the record, Open on the Board, Copy link). A source row has Pin only: the server refuses to put it off.
|
|
7
|
+
* body the summary card: the state line, ✦ Claude's offer, the amber "If it waits" line when the row has one, ONE primary verb;
|
|
8
|
+
* then one quiet owner line (whose it is, the kind of work in words, the goal it moves); then the folds.
|
|
9
|
+
* No ids, lane codes, anchors or file paths in the body: the record's path is under ⋯.
|
|
10
|
+
* after a press that starts an agent keeps the same card: what it does now, its steps, Stop and its chat; then the result.
|
|
11
|
+
* edges no next step on record → "Find the next step"; a source the brief could not read → why, and sign in again; the row left Home
|
|
12
|
+
* while it was open (someone else did it) → says so, and Done.
|
|
13
|
+
*
|
|
14
|
+
* needModel(r, ctx) → { title, sub, icon, line, tone, right, text, offer, cost, meta, primary, also, owner, sections, pin, later } PURE
|
|
15
|
+
* plainStep(next) → { say, label, doing } | null the next step on record in plain words, its verb press and its "-ing" line PURE
|
|
16
|
+
* openNeed(r, h) draws it in the Viewer. h: { VW, P, esc, svg, pinned(key), togglePin(key), putOff(key, until), menu(anchor, items),
|
|
17
|
+
* start(r) → Promise<{ ok, session?, error? }>, sessions(), stopSession(sid), openSession(sid), ask(r, text),
|
|
18
|
+
* decide(r, choice, why) → Promise<{ ok, error? }>, openReturn(item), goIni(id), boardHref(r), recordHref(r),
|
|
19
|
+
* linkOf(r), toast(m), signIn(), rowGone(key) }
|
|
20
|
+
* refresh() draws the open ask again when its phase changed (a run finished, the row left Home); called after each read. */
|
|
21
|
+
|
|
22
|
+
const STEP_WORD = { spec: 'the spec', prototype: 'the prototype', contract: 'the agreed done-criteria', anchor: 'the goal it moves', route: 'its lane', brief: 'the problem brief', prd: 'the PRD', rubric: 'the rubric' };
|
|
23
|
+
const STEP_AT = { spec: 'the spec', prototype: 'the prototype', contract: 'the contract', anchor: 'the goal', route: 'routing' };
|
|
24
|
+
export const LANE_WORD = { feature: 'New feature', discovery: 'Discovery', chore: 'Upkeep', incident: 'Incident', content: 'Content', prototype: 'Prototype' };
|
|
25
|
+
const SRC_ICON = { Mail: 'M3.5 6h17v12h-17zM4 7l8 6 8-6', Jira: 'M4 4h16v16H4zM8.5 12.5l2.5 2.5 4.5-5', Slack: 'M9 3v18M15 3v18M3 9h18M3 15h18' };
|
|
26
|
+
const ICON = { goal: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8', warn: 'M12 3l9 16H3zM12 10v4M12 17h.01', doc: 'M7 3h7l5 5v13H7zM14 3v5h5', gate: 'M12 3l7 3v6c0 4-3 7-7 9-4-2-7-5-7-9V6z' };
|
|
27
|
+
export const OUT = 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6';
|
|
28
|
+
const CHEV = 'M10 7l5 5-5 5', CHAT = 'M4 5h16v11H9l-5 4z', STOP = 'M6 6l12 12M18 6L6 18', CHECK = 'M5 12l5 5 9-10', SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z';
|
|
29
|
+
|
|
30
|
+
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
31
|
+
const cap = (s) => (s ? s[0].toUpperCase() + s.slice(1) : s);
|
|
32
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
33
|
+
/** Plain words: no file paths, no decision ids (D13), no frontmatter keys (prd_path), no parentheses that hold either. */
|
|
34
|
+
export function noPaths(s) {
|
|
35
|
+
return String(s == null ? '' : s)
|
|
36
|
+
.replace(/\s*\((?:[^()]*\/[^()]*|D\d+[^()]*|skills?[^()]*|R\d+|O\d+)\)/g, '')
|
|
37
|
+
.replace(/\bpm-decisions\.md\b/g, 'the decision journal')
|
|
38
|
+
.replace(/`[^`]*`/g, 'the record')
|
|
39
|
+
.replace(/\b[\w.-]*\/[\w./-]+/g, 'the record')
|
|
40
|
+
.replace(/\b[\w-]+\.(md|js|json|jsonl|ya?ml|skill)\b/g, 'the record')
|
|
41
|
+
.replace(/\b[a-z]+_[a-z_]+\b/g, '')
|
|
42
|
+
.replace(/\s+([,.;:])/g, '$1').replace(/,\s*,/g, ',').replace(/\s{2,}/g, ' ').trim();
|
|
43
|
+
}
|
|
44
|
+
const VERB = /^(do|review|read|author|write|create|draft|run|land|name|point|set|add|agree|anchor|route|split|move|declare|fix|correct|scope|record|pick|choose|link|open|start|state|give|put)\b/i;
|
|
45
|
+
const ING = { do: 'Doing', author: 'Drafting', write: 'Drafting', create: 'Drafting', draft: 'Drafting', run: 'Running', set: 'Setting', put: 'Putting', split: 'Splitting', scope: 'Scoping', pick: 'Picking', state: 'Stating', give: 'Giving', agree: 'Agreeing on', move: 'Moving', declare: 'Declaring', name: 'Naming', route: 'Routing', anchor: 'Anchoring', choose: 'Choosing' };
|
|
46
|
+
const ingOf = (v) => ING[v] || (/e$/.test(v) ? cap(v.slice(0, -1)) + 'ing' : cap(v) + 'ing');
|
|
47
|
+
/** The next step on record, in plain words: say ("draft the PRD with its done-criteria"), label (the press: "Draft the PRD"), doing
|
|
48
|
+
* ("Drafting the PRD"). The record's sentence is the source: nothing is added to it, its paths and ids are dropped. null when empty. */
|
|
49
|
+
export function plainStep(next) {
|
|
50
|
+
let s = String(next == null ? '' : next).split(/\s[—–]\s/)[0];
|
|
51
|
+
const parts = s.split(/(?<=[.;])\s+/).map((x) => x.trim()).filter(Boolean);
|
|
52
|
+
s = parts.find((x) => VERB.test(x)) || parts[0] || '';
|
|
53
|
+
s = s.replace(/,?\s*(then|and)\s+(set|point|correct|clear)\s+[\s\S]*$/i, '');
|
|
54
|
+
s = noPaths(s).replace(/\s+in\s+the record$/i, '').replace(/[.;:,\s]+$/, '');
|
|
55
|
+
if (!s) return null;
|
|
56
|
+
const m = /^(\w+)\s*(.*)$/.exec(s), v = m[1].toLowerCase(), rest = m[2];
|
|
57
|
+
const verb = ['author', 'write', 'create'].includes(v) ? 'draft' : v;
|
|
58
|
+
const say = verb + (rest ? ' ' + rest : '');
|
|
59
|
+
const obj = rest.split(/\s+(?:with|in|so|or|before|after|from|first|then|to|for|at)\b|[,;]/i)[0].trim().split(/\s+/).slice(0, 5).join(' ');
|
|
60
|
+
if (!VERB.test(v) || !obj) return { say, label: 'Start it', doing: 'Working on it' };
|
|
61
|
+
return { say, label: cap(verb) + ' ' + obj, doing: ingOf(v) + ' ' + obj };
|
|
62
|
+
}
|
|
63
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
64
|
+
const dayOf = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : String(iso || ''); };
|
|
65
|
+
const initials = (n) => { const t = String(n || '').replace(/^pm:/, '').trim(); return t ? t[0].toUpperCase() : ''; };
|
|
66
|
+
const isPm = (o) => !o || /^pm(:|$)/i.test(String(o));
|
|
67
|
+
const goalWords = (g) => (!g || !g.title ? '' : g.kind === 'health' ? 'keeps ' + g.title + ' healthy' : 'moves ' + g.title);
|
|
68
|
+
/** "If you skip: …" on the record becomes the amber line: "If it waits: …". */
|
|
69
|
+
const costOf = (skip) => { const m = /^If you skip:\s*(.+)$/.exec(String(skip || '')); return m ? 'If it waits: ' + m[1] : ''; };
|
|
70
|
+
/** Why a step blocks, in words, from the rule the step enforces (scripts/workflow-state.js). */
|
|
71
|
+
function whyBlocked(step, rule, lane) {
|
|
72
|
+
if (/^O[12]$/.test(rule || '')) return 'The build was committed before its spec. The spec has to come first, so the order check keeps failing until it does.';
|
|
73
|
+
if (step === 'spec') return lane === 'chore' ? 'Upkeep needs one paragraph that says what it is for before it starts.' : 'A ' + (LANE_WORD[lane] || 'piece of work').toLowerCase() + ' needs its spec before the build: what the problem is, who has it, and how we will know it worked.';
|
|
74
|
+
if (step === 'prototype') return 'This idea needs a prototype people can look at before a PRD says what to build.';
|
|
75
|
+
if (step === 'contract') return 'The run needs its done-criteria agreed before it starts, so there is something to check it against.';
|
|
76
|
+
if (step === 'anchor') return 'Every initiative names the goal it moves. Work with no goal is turned away.';
|
|
77
|
+
if (step === 'route') return 'The initiative needs its lane, so the right rules run on it.';
|
|
78
|
+
return 'The ' + step + ' step is not done yet.';
|
|
79
|
+
}
|
|
80
|
+
const lineOf = (step, rule) => (/^O[12]$/.test(rule || '') ? 'Blocked: ' + (STEP_WORD[step] || 'the ' + step) + ' came after the build'
|
|
81
|
+
: /^O3$/.test(rule || '') ? 'Blocked: the prototype has to come first' : 'Blocked: ' + (STEP_WORD[step] || 'the ' + step + ' step') + ' is missing');
|
|
82
|
+
/** A fact the PM can read: the facts a row carries, without ids, records, anchors and lanes (those are under ⋯ or said in words). */
|
|
83
|
+
const plainFacts = (rows) => (rows || []).filter((x) => x && x[1] && !/^(initiative|record|anchor|lane|source|ticket|run|confidence|reply needed|product)$/i.test(String(x[0]))).map(([k, v]) => [k, noPaths(v)]).filter((x) => x[1]);
|
|
84
|
+
const factsHtml = (rows, esc) => (rows.length ? `<dl class="nv-facts">${rows.map(([k, v]) => `<div><dt>${esc(k)}</dt><dd>${esc(v)}</dd></div>`).join('')}</dl>` : '');
|
|
85
|
+
|
|
86
|
+
/** The model of one ask. ctx: { esc, run (the agent this ask started: { label, doing, state: 'running'|'ready', done?, n? }), gone (the row
|
|
87
|
+
* left Home while it was open), choice, why, pickedRec } */
|
|
88
|
+
export function needModel(r, ctx = {}) {
|
|
89
|
+
const esc = ctx.esc || ((s) => String(s));
|
|
90
|
+
const row = r.row || {}, d = row.dialog || {}, w = d.write || {}, det = row.detail || {}, kind = row.kind;
|
|
91
|
+
const name = det.title || (kind === 'waited' ? '' : clip(String(row.subject || '').split(' · ')[0], 120)) || r.name;
|
|
92
|
+
const m = { kind, title: name, sub: '', icon: ICON.goal, line: '', tone: '', right: '', text: '', offer: '', cost: '', meta: '', primary: null, also: [], owner: null, sections: [], pin: true, later: true };
|
|
93
|
+
const owner = (pre) => {
|
|
94
|
+
const bits = [pre, LANE_WORD[det.lane] || '', goalWords(det.goal)].filter(Boolean);
|
|
95
|
+
// a face only for someone on record, or the PM's own unblock (the ask is on the PM's Home)
|
|
96
|
+
return bits.length ? { av: det.owner ? (isPm(det.owner) ? 'pm' : initials(det.owner)) : pre ? 'pm' : '', text: bits.join(' · ') } : null;
|
|
97
|
+
};
|
|
98
|
+
if (ctx.gone) {
|
|
99
|
+
m.line = kind === 'blocked' ? 'Unblocked' : kind === 'decision' ? 'Decided' : 'Done'; m.tone = 'ok';
|
|
100
|
+
m.text = (kind === 'blocked' ? 'The step was done outside this card' : kind === 'decision' ? 'A decision is on record now' : 'It was handled outside this card') + '. Nothing is left for you here.';
|
|
101
|
+
m.also = [{ act: 'done', label: 'Done', icon: CHECK }];
|
|
102
|
+
m.pin = false; m.later = false;
|
|
103
|
+
if (kind === 'waited') m.title = r.name;
|
|
104
|
+
return m;
|
|
105
|
+
}
|
|
106
|
+
if (kind === 'blocked') {
|
|
107
|
+
const step = det.step || '', st = w.kind === 'start' ? plainStep(w.what || det.next) : null;
|
|
108
|
+
m.owner = owner(isPm(det.owner) ? 'Yours to unblock' : clip(String(det.owner).replace(/^pm:/, ''), 40) + ' owns it');
|
|
109
|
+
const why = { id: 'why', title: 'Why it is blocked', open: !ctx.run, html: '<p>' + esc(whyBlocked(step, det.rule, det.lane)) + '</p>' };
|
|
110
|
+
const status = ((d.pane && d.pane.rows) || []).find((x) => x[0] === 'Status');
|
|
111
|
+
const where = status && noPaths(status[1]) ? { id: 'where', title: 'Where it stands', html: '<p>' + esc(clip(noPaths(status[1]), 280)) + '</p>' } : null;
|
|
112
|
+
if (ctx.run && ctx.run.state === 'ready') {
|
|
113
|
+
m.line = 'Ready for you to read'; m.tone = 'ok';
|
|
114
|
+
m.text = 'The agent finished ' + (ctx.run.doing ? ctx.run.doing.replace(/^\w+/, (x) => x.toLowerCase()) : 'its work') + '. Read it before anything moves.';
|
|
115
|
+
m.meta = 'When it is on record, the block lifts and the next step can start.';
|
|
116
|
+
m.primary = { act: 'read', label: 'Read it', icon: ICON.doc };
|
|
117
|
+
m.sections = [why, where]; return m;
|
|
118
|
+
}
|
|
119
|
+
if (ctx.run) {
|
|
120
|
+
m.line = ctx.run.doing || 'Working on it'; m.tone = 'you';
|
|
121
|
+
m.right = ctx.run.n ? ctx.run.done + ' of ' + plural(ctx.run.n, 'step', 'steps') : 'started';
|
|
122
|
+
m.text = 'You can close this. The work lands in its chat, and this card says when it is ready.';
|
|
123
|
+
m.also = [{ act: 'stop', label: 'Stop the agent', icon: STOP }, { act: 'talk', label: 'Open its chat', icon: CHAT }];
|
|
124
|
+
m.progress = ctx.run.n ? Math.round((ctx.run.done / ctx.run.n) * 100) : null;
|
|
125
|
+
m.sections = [why, where]; return m;
|
|
126
|
+
}
|
|
127
|
+
if (st) {
|
|
128
|
+
m.line = lineOf(step, det.rule); m.tone = 'warn';
|
|
129
|
+
m.offer = 'I can ' + st.say + '. You read it before anything moves.';
|
|
130
|
+
m.cost = costOf(row.skip);
|
|
131
|
+
m.primary = { act: 'start', label: st.label, icon: SPARK };
|
|
132
|
+
} else {
|
|
133
|
+
m.line = 'Blocked at ' + (STEP_AT[step] || 'the ' + step + ' step'); m.tone = 'warn';
|
|
134
|
+
m.offer = 'No next step is on record, so I can’t start one yet. Tell me what unblocks it, or let me look.';
|
|
135
|
+
m.primary = { act: 'find', label: 'Find the next step', icon: SPARK };
|
|
136
|
+
m.also = [{ act: 'talk', label: 'Tell Claude in the chat', icon: CHAT }];
|
|
137
|
+
}
|
|
138
|
+
m.sections = [why, where];
|
|
139
|
+
return m;
|
|
140
|
+
}
|
|
141
|
+
if (kind === 'decision') {
|
|
142
|
+
const opts = d.opts || [], rec = d.rec && opts.some((o) => o.k === d.rec.k) ? d.rec : null;
|
|
143
|
+
m.icon = ICON.goal;
|
|
144
|
+
m.line = 'Your call: ' + opts.map((o) => o.t.replace(/ it$/, '').toLowerCase()).join(', ').replace(/, ([^,]*)$/, ' or $1'); m.tone = 'you';
|
|
145
|
+
m.right = det.meeting ? 'by ' + det.meeting.at + ' ' + det.meeting.title : '';
|
|
146
|
+
if (rec) {
|
|
147
|
+
const o = opts.find((x) => x.k === rec.k);
|
|
148
|
+
m.offer = 'I’d ' + o.t.replace(/ it$/, '').toLowerCase() + (rec.why ? ': ' + rec.why : '.');
|
|
149
|
+
if (rec.sure) m.meta = 'How sure: ' + rec.sure;
|
|
150
|
+
} else {
|
|
151
|
+
m.offer = 'No pick is on record, so none is chosen for you. I can read the record and the evidence and tell you which I’d pick and how sure I am.';
|
|
152
|
+
m.primary = { act: 'weigh', label: 'Weigh it for me', icon: SPARK };
|
|
153
|
+
}
|
|
154
|
+
m.cost = costOf(row.skip);
|
|
155
|
+
m.owner = det.lane ? owner('') : null;
|
|
156
|
+
const ev = plainFacts(d.facts);
|
|
157
|
+
m.sections = [ev.length ? { id: 'evidence', title: 'The evidence', count: ev.length, html: factsHtml(ev, esc) } : null];
|
|
158
|
+
m.decide = { opts, rec: rec ? rec.k : null };
|
|
159
|
+
return m;
|
|
160
|
+
}
|
|
161
|
+
if (kind === 'waited') {
|
|
162
|
+
const items = d.items || [];
|
|
163
|
+
m.title = plural(items.length, 'failed review', 'failed reviews'); m.icon = ICON.warn;
|
|
164
|
+
m.line = clip(String(row.subject || '').split(' · ')[0], 60) || 'Waiting'; m.tone = 'warn';
|
|
165
|
+
m.text = (items.length === 1 ? 'One review failed and none has passed since.' : cap(String(d.say || '').split('. ')[0]) + '.') + ' ' + (items.length === 1 ? 'It has its findings on record.' : 'Each one has its findings on record.');
|
|
166
|
+
m.offer = 'I can send ' + (items.length === 1 ? 'it' : 'each one') + ' back to its agent with the top finding as the note. You see each note before it goes.';
|
|
167
|
+
m.primary = { act: 'notes', label: items.length === 1 ? 'Prepare the note' : 'Prepare the ' + items.length + ' notes', icon: SPARK };
|
|
168
|
+
m.cost = costOf(row.skip);
|
|
169
|
+
m.sections = [{ id: 'reviews', title: 'The reviews', count: items.length, open: true,
|
|
170
|
+
html: items.map((x, i) => `<button type="button" class="czs-it nv-rev" data-nv-rev="${i}"><span class="w">${esc(x.t)}<span>${esc([x.s, x.days != null ? plural(x.days, 'day', 'days') : '', x.lead ? clip(noPaths(x.lead), 90) : ''].filter(Boolean).join(' · '))}</span></span><span class="czs-cv" aria-hidden="true">${(ctx.svg || (() => ''))(CHEV, 15)}</span></button>`).join('') }];
|
|
171
|
+
return m;
|
|
172
|
+
}
|
|
173
|
+
if (kind === 'source') {
|
|
174
|
+
const src = d.eye || 'the source', link = /^https:\/\//.test(d.link || '') ? d.link : '';
|
|
175
|
+
m.title = r.name; m.sub = clip(row.subject || '', 90); m.icon = SRC_ICON[src] || ICON.doc; m.later = false;
|
|
176
|
+
if (row.unread) {
|
|
177
|
+
m.line = row.unread.source + ' could not be read'; m.tone = 'warn';
|
|
178
|
+
m.text = 'The morning brief could not reach ' + row.unread.source + ', so this is its copy' + (row.unread.date ? ' from ' + dayOf(row.unread.date) : '') + ', not the live ' + row.unread.source.toLowerCase() + '.';
|
|
179
|
+
m.primary = { act: 'signin', label: 'Sign in to ' + row.unread.source + ' again', icon: OUT };
|
|
180
|
+
} else {
|
|
181
|
+
const why = /^Why now:\s*/.test(row.skip || '') ? row.skip.replace(/^Why now:\s*/, '') : '';
|
|
182
|
+
m.line = why ? 'Why now: ' + clip(why.replace(/\.$/, ''), 70) : /^Due /.test(row.skip || '') ? row.skip.replace(/\.$/, '') : 'From ' + src; m.tone = 'you';
|
|
183
|
+
m.text = d.say && d.say !== why ? clip(d.say, 400) : ''; // the brief's gist; never the why now again (say it once)
|
|
184
|
+
m.meta = 'Read from ' + src + ' by the morning brief. Nothing is recorded or sent from here.';
|
|
185
|
+
if (link) m.primary = { act: 'open', label: d.linkLabel || 'Open in ' + src, href: link, icon: OUT };
|
|
186
|
+
}
|
|
187
|
+
const f = plainFacts(d.facts).filter((x) => !/^(about)$/i.test(x[0]));
|
|
188
|
+
m.sections = [f.length ? { id: 'item', title: 'The item', count: f.length, html: factsHtml(f, esc) } : null];
|
|
189
|
+
return m;
|
|
190
|
+
}
|
|
191
|
+
// the agent's drafts (lib/briefing-premium-drafts.js) and any kind to come: the state, the agent's words, the facts it stated
|
|
192
|
+
m.title = r.name; m.icon = ICON.gate;
|
|
193
|
+
m.line = clip(String(row.subject || 'Waits on you'), 60); m.tone = 'you';
|
|
194
|
+
m.text = clip(noPaths(d.say || row.prepared || ''), 400);
|
|
195
|
+
const f = plainFacts(d.facts);
|
|
196
|
+
m.sections = [f.length ? { id: 'facts', title: d.head || 'What is on record', count: f.length, html: factsHtml(f, esc) } : null];
|
|
197
|
+
return m;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The chat beside the ask asks a question instead of repeating the Viewer's summary (OvA10Desk). */
|
|
201
|
+
export function introOf(r) {
|
|
202
|
+
const row = r.row || {}, w = (row.dialog || {}).write || {};
|
|
203
|
+
if (row.kind === 'blocked') {
|
|
204
|
+
const st = w.kind === 'start' ? plainStep(w.what) : null;
|
|
205
|
+
return st ? 'Anything I should know before I ' + st.say.split(/\s+(?:with|so|or)\b/)[0] + '? Tell me here, or just press ' + st.label + '.' : 'Do you know what unblocks it? Tell me here, or press Find the next step and I’ll look.';
|
|
206
|
+
}
|
|
207
|
+
if (row.kind === 'decision') return 'Which way are you leaning? Ask me anything about it here, or let me weigh it for you.';
|
|
208
|
+
if (row.kind === 'waited') return 'Want to look at one of them first, or shall I prepare the notes?';
|
|
209
|
+
if (row.kind === 'source') return 'Want me to draft a reply, or is reading it enough?';
|
|
210
|
+
return 'Anything you want to ask about it?';
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* ── drawing ── */
|
|
214
|
+
const NV = { r: null, h: null, st: null, sig: '' };
|
|
215
|
+
const RUNS_KEY = 'pmos.home.needRuns';
|
|
216
|
+
const store = {
|
|
217
|
+
get() { try { return JSON.parse(localStorage.getItem(RUNS_KEY) || '{}') || {}; } catch { return {}; } },
|
|
218
|
+
set(o) { try { localStorage.setItem(RUNS_KEY, JSON.stringify(o)); } catch { /* a private window forgets it */ } },
|
|
219
|
+
};
|
|
220
|
+
/** The agent this ask started (kept across reads and a reload) and where it stands now, from the session list. */
|
|
221
|
+
function runOf(r, h) {
|
|
222
|
+
const k = store.get()[r.key]; if (!k || !k.sid) return null;
|
|
223
|
+
const s = (h.sessions() || []).find((x) => x.id === k.sid);
|
|
224
|
+
// a session not listed yet (the list is read every few seconds) is starting, not finished
|
|
225
|
+
const ended = s ? ['needs', 'quiet', 'exited'].includes(s.shown) : Date.now() - (k.at || 0) > 60000;
|
|
226
|
+
const pr = s && s.progress && s.progress.n > 0 ? s.progress : null;
|
|
227
|
+
return { sid: k.sid, doing: k.doing, state: ended ? 'ready' : 'running', done: pr ? pr.done : 0, n: pr ? pr.n : 0 };
|
|
228
|
+
}
|
|
229
|
+
const keepRun = (key, v) => { const o = store.get(); if (v) o[key] = v; else delete o[key]; store.set(o); };
|
|
230
|
+
|
|
231
|
+
export function openNeed(r, h, o = {}) {
|
|
232
|
+
NV.r = r; NV.h = h;
|
|
233
|
+
const d = (r.row && r.row.dialog) || {};
|
|
234
|
+
NV.st = { choice: o.choice || null, why: null, msg: '', gone: false };
|
|
235
|
+
const draw = (b) => paint(b);
|
|
236
|
+
const m0 = model();
|
|
237
|
+
const more = () => {
|
|
238
|
+
const out = [];
|
|
239
|
+
const rec = h.recordHref(r); if (rec) out.push({ label: 'Open the record', on: () => window.open(rec, '_blank', 'noopener') });
|
|
240
|
+
const bd = h.boardHref(r); if (bd) out.push({ label: 'Open on the Board', on: () => window.open(bd, '_blank', 'noopener') });
|
|
241
|
+
out.push({ label: 'Copy link', on: async () => { try { await navigator.clipboard.writeText(h.linkOf(r)); h.toast('The link is copied.'); } catch { h.toast('The link could not be copied.'); } } });
|
|
242
|
+
return out;
|
|
243
|
+
};
|
|
244
|
+
const body = h.VW.open({ id: 'need:' + r.key, kind: ({ decision: 'Decision', blocked: 'Blocked', waited: 'Waiting', source: 'Source' }[r.row.kind] || 'Needs you'), title: m0.title, sub: m0.sub, icon: m0.icon,
|
|
245
|
+
presses: pressesOf(m0, r, h), more, onPress: (act, b) => pressHead(act, b), render: draw });
|
|
246
|
+
NV.sig = sigOf(m0);
|
|
247
|
+
if (body) {
|
|
248
|
+
body.oninput = (e) => { if (e.target.id === 'nvWhy') { NV.st.why = e.target.value; const b = body.querySelector('[data-nv-rec]'); if (b) b.disabled = !canRecord(); } };
|
|
249
|
+
body.onclick = (e) => { const t = e.target.closest('button, a'); if (t) press(t, body); };
|
|
250
|
+
}
|
|
251
|
+
if (d.write && d.write.kind === 'decision' && o.choice) setTimeout(() => { const t = body && body.querySelector('#nvWhy'); if (t) t.focus(); }, 0);
|
|
252
|
+
return body;
|
|
253
|
+
}
|
|
254
|
+
function model() {
|
|
255
|
+
const { r, h, st } = NV;
|
|
256
|
+
return needModel(r, { esc: h.esc, svg: h.svg, run: r.row.kind === 'blocked' ? runOf(r, h) : null, gone: st.gone });
|
|
257
|
+
}
|
|
258
|
+
const sigOf = (m) => [m.line, m.right, m.primary && m.primary.act, m.title].join('|');
|
|
259
|
+
function pressesOf(m, r, h) {
|
|
260
|
+
const out = [];
|
|
261
|
+
if (m.pin) { const on = h.pinned(r.key); out.push({ act: 'pin', label: on ? 'Unpin' : 'Pin to the top', icon: h.P.pin, pressed: on }); }
|
|
262
|
+
if (m.later) out.push({ act: 'later', label: 'Put off', icon: h.P.clock });
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
const canRecord = () => !!NV.st.choice && String(NV.st.why == null ? whyOf() : NV.st.why).trim().length >= 3;
|
|
266
|
+
const whyOf = () => { const rec = (NV.r.row.dialog || {}).rec; return NV.st.why != null ? NV.st.why : rec && rec.why && NV.st.choice === rec.k ? rec.why : ''; };
|
|
267
|
+
function paint(b) {
|
|
268
|
+
const { r, h, st } = NV, esc = h.esc, m = model();
|
|
269
|
+
NV.sig = sigOf(m);
|
|
270
|
+
const extra = (m.offer ? `<p class="nv-offer">${h.svg(SPARK, 14)}<span>${esc(m.offer)}</span></p>` : '')
|
|
271
|
+
+ (m.progress != null ? `<div class="nv-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${m.progress}"><span style="width:${m.progress}%"></span></div>` : '')
|
|
272
|
+
+ (m.cost ? `<p class="nv-cost">${h.svg(h.P.clock, 14)}<span>${esc(m.cost)}</span></p>` : '');
|
|
273
|
+
let sum = h.VW.czSummary({ line: m.line, tone: m.tone, right: m.right, text: m.text, meta: m.meta, extra, primary: m.primary && !m.primary.href ? m.primary : null, also: m.also });
|
|
274
|
+
if (m.primary && m.primary.href) { // ↗ Open in Mail: the item's own https link, in a new tab
|
|
275
|
+
const a = `<a class="czs-pri" id="srcLink" href="${esc(m.primary.href)}" target="_blank" rel="noopener noreferrer">${h.svg(OUT, 15)}${esc(m.primary.label)}</a>`;
|
|
276
|
+
sum = sum.replace(/<\/div>$/, `<div class="czs-acts">${a}</div></div>`);
|
|
277
|
+
} else if (m.primary) sum = sum.replace(`data-czs-act="${m.primary.act}">`, `data-czs-act="${m.primary.act}">${h.svg(m.primary.icon || SPARK, 15)}`);
|
|
278
|
+
const own = m.owner ? `<p class="nv-own">${m.owner.av ? `<span class="nv-av" aria-hidden="true">${esc(m.owner.av === 'pm' ? h.me() : m.owner.av)}</span>` : ''}<span>${esc(m.owner.text)}</span></p>` : '';
|
|
279
|
+
let dec = '';
|
|
280
|
+
if (m.decide && !st.gone) {
|
|
281
|
+
if (st.choice == null && m.decide.rec) st.choice = m.decide.rec;
|
|
282
|
+
dec = `<div class="nv-dec" role="radiogroup" aria-label="Choices">${m.decide.opts.map((o) => `<button type="button" class="ut-radio" role="radio" aria-checked="${st.choice === o.k}" data-nv-opt="${esc(o.k)}"><span class="o" aria-hidden="true"></span><span><b>${esc(o.t)}</b>${m.decide.rec === o.k ? ' <span class="nv-pick">I’d do this</span>' : ''}${o.d ? `<br><span class="ut-small ut-mut">${esc(noPaths(o.d))}</span>` : ''}</span></button>`).join('')}</div>`
|
|
283
|
+
+ `<div class="ut-field"><label for="nvWhy">Why${m.decide.rec && st.choice === m.decide.rec ? ' <em>(I wrote it; change it if you like)</em>' : ' <em>· kept in the journal</em>'}</label><textarea id="nvWhy" rows="2" placeholder="Your reason goes in the journal with your choice">${esc(whyOf())}</textarea></div>`
|
|
284
|
+
+ `<div class="czs-acts"><button type="button" class="czs-pri nv-rec" data-nv-rec${canRecord() ? '' : ' disabled'}>${h.svg(CHECK, 15)}${esc(st.choice ? 'Record: ' + ((m.decide.opts.find((o) => o.k === st.choice) || {}).t || '').replace(/ it$/, '').toLowerCase() : 'Record')}</button></div>`;
|
|
285
|
+
}
|
|
286
|
+
b.innerHTML = `<div class="nv">${sum}${own}${dec}${h.VW.czSections(m.sections, { key: 'need-' + m.kind })}<p class="ut-small ut-mut" role="status" id="nvMsg">${esc(st.msg || '')}</p></div>`;
|
|
287
|
+
}
|
|
288
|
+
const say = (body, t) => { NV.st.msg = t; const el = body.querySelector('#nvMsg'); if (el) el.textContent = t; };
|
|
289
|
+
function pressHead(act, b) {
|
|
290
|
+
const { r, h } = NV;
|
|
291
|
+
if (act === 'pin') { h.togglePin(r.key); h.VW.setPresses('need:' + r.key, pressesOf(model(), r, h)); return; }
|
|
292
|
+
if (act === 'later') {
|
|
293
|
+
const at = new Date(Date.now() + 3 * 3600000), hm = String(at.getHours()).padStart(2, '0') + ':' + String(at.getMinutes()).padStart(2, '0');
|
|
294
|
+
h.menu(b, [{ label: 'Later today', k: hm, go: () => h.putOff(r.key, 'later') }, { label: 'Tomorrow', k: '09:00', go: () => h.putOff(r.key, 'tomorrow') }, { label: 'Next week', k: 'Mon', go: () => h.putOff(r.key, 'nextweek') }], 'Put off');
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
async function press(t, body) {
|
|
298
|
+
const { r, h, st } = NV, d = r.row.dialog || {};
|
|
299
|
+
if (t.dataset.nvOpt) { st.choice = t.dataset.nvOpt; if (st.why == null) st.why = whyOf(); paint(body); return; }
|
|
300
|
+
if (t.dataset.nvRev != null) { const it = (d.items || [])[+t.dataset.nvRev]; if (it) h.openReturn(it); return; }
|
|
301
|
+
if ('nvRec' in t.dataset) {
|
|
302
|
+
t.disabled = true;
|
|
303
|
+
const res = await h.decide(r, st.choice, String(st.why == null ? whyOf() : st.why).trim());
|
|
304
|
+
if (!res.ok) { t.disabled = false; say(body, res.error); }
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const act = t.dataset.czsAct; if (!act) return;
|
|
308
|
+
if (act === 'start') {
|
|
309
|
+
t.disabled = true;
|
|
310
|
+
const st0 = plainStep((d.write || {}).what);
|
|
311
|
+
const res = await h.start(r);
|
|
312
|
+
if (!res.ok) { t.disabled = false; say(body, 'Not started: ' + res.error); return; }
|
|
313
|
+
const sid = res.session && (res.session.id || res.session);
|
|
314
|
+
if (typeof sid === 'string') keepRun(r.key, { sid, doing: st0 ? st0.doing : 'Working on it', at: Date.now() });
|
|
315
|
+
st.msg = ''; paint(body); return;
|
|
316
|
+
}
|
|
317
|
+
const run = runOf(r, h);
|
|
318
|
+
if (act === 'stop' && run) { const ok = await h.stopSession(run.sid); if (ok) { keepRun(r.key, null); st.msg = ''; paint(body); } else say(body, 'The agent did not stop. Try again.'); return; }
|
|
319
|
+
if ((act === 'talk' || act === 'read') && run) { h.openSession(run.sid); return; }
|
|
320
|
+
if (act === 'talk') { h.ask(r, ''); return; }
|
|
321
|
+
if (act === 'find') { h.ask(r, 'Find the next step that unblocks ' + model().title + ': read its record and its history, then tell me what it is and whether you can start it.'); return; }
|
|
322
|
+
if (act === 'weigh') { h.ask(r, 'Weigh this for me: read the record and the evidence, then tell me which choice you would pick, how sure you are, and why.'); return; }
|
|
323
|
+
if (act === 'notes') { h.ask(r, 'For each failed review, write the note that sends it back to its agent, with its top finding. Show me each note; send nothing until I return it.'); return; }
|
|
324
|
+
if (act === 'signin') { h.signIn(); return; }
|
|
325
|
+
if (act === 'done') { if (run) keepRun(r.key, null); h.VW.close(); }
|
|
326
|
+
}
|
|
327
|
+
/** After a read: the open ask draws again when its phase changed (the agent finished, the row left Home); typing is never redrawn. */
|
|
328
|
+
export function refresh() {
|
|
329
|
+
const { r, h } = NV; if (!r || !h) return;
|
|
330
|
+
const c = h.VW.current(); if (!c || c.id !== 'need:' + r.key) { NV.r = null; return; }
|
|
331
|
+
if (!NV.st.gone && h.rowGone(r.key)) NV.st.gone = true;
|
|
332
|
+
const m = model();
|
|
333
|
+
if (sigOf(m) === NV.sig) return;
|
|
334
|
+
h.VW.setPresses('need:' + r.key, pressesOf(m, r, h));
|
|
335
|
+
const b = h.VW.body(); if (b) paint(b);
|
|
336
|
+
}
|
|
@@ -274,12 +274,12 @@ export function listHtml(M, T, o) {
|
|
|
274
274
|
const nw = o.news > 0 ? '. ' + o.news + ' new for you' : '';
|
|
275
275
|
// Your impact (batch 16 item 7, GmA1Home): with it on, the greeting's face is its own press, Adler with the week's leaves (pm/impact.js faceHtml)
|
|
276
276
|
const face = o.imFace && !o.err ? '' : AD.adler(o.err ? 'honest' : 'handled', 36, { label: false, cls: 'hv-ad' });
|
|
277
|
-
const head = `<div class="hm-hd hv-bar">${o.imFace && !o.err ? o.imFace : ''}<button type="button" class="hv-hi" data-hm-day aria-expanded="${!!o.day}" aria-label="${esc(M.word || 'Today')}${nw}. Open your day">${face}<b>${esc(M.word || 'Today')}</b>${o.news > 0 ? '<i class="hv-nd" aria-hidden="true"></i>' : ''}${svg(P.chevD, 18)}</button>`
|
|
277
|
+
const head = `<div class="hm-hd hv-bar">${o.imFace && !o.err ? o.imFace : ''}<button type="button" class="hv-hi" data-hm-day aria-expanded="${!!o.day}" aria-label="${esc(M.word || 'Today')}${nw}. Open your day">${face}<b>${esc(M.word || 'Today')}</b>${o.news > 0 ? '<i class="hv-nd" aria-hidden="true"></i>' : ''}${svg(P.chevD, 18)}</button><span class="hv-acts">`
|
|
278
278
|
// the product chip, always (it is also the way to add one): the ticked products' tiles, or All (canvas XhpA2States)
|
|
279
279
|
+ (o.pick ? chipHtml(o.pick, { id: 'hmPick', attrs: 'data-hm-pick', label: 'Products on Home', tones: o.tones }) : '')
|
|
280
280
|
+ (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Kept or Done">${svg(P.filter, 18)}</button>`)
|
|
281
281
|
+ SO.btnHtml('ut-ib hv-ib' + (SO.layout().sort !== 'mine' ? ' on' : ''))
|
|
282
|
-
+ `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button></div>`
|
|
282
|
+
+ `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button></span></div>`
|
|
283
283
|
+ (M.yours ? `<p class="hv-sub">${M.yours} ${M.yours === 1 ? 'is' : 'are'} yours</p>` : '');
|
|
284
284
|
// the Today card only while the day has a moment; the plain day (its meetings and load) is in Your day
|
|
285
285
|
const card = MOMENT.has(T.mode) ? todayHtml(T, { greet: M.greet, sub: '', phone: o.phone }) : '';
|