create-pmos 0.439.0 → 0.441.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/bin/create-pmos.js +5 -2
- 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/briefing-premium-adddoc-test.js +16 -13
- package/workspace/briefing-premium-insights-test.js +1 -1
- 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/core-documents.md +2 -2
- package/workspace/guide/data-freshness.md +7 -5
- package/workspace/guide/home.md +4 -1
- package/workspace/guide/horizon-scan.md +1 -1
- package/workspace/guide/settings.md +2 -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/goal-status.js +2 -1
- package/workspace/lib/headless.js +18 -1
- package/workspace/lib/kit-update.js +2 -2
- package/workspace/lib/metric-draft-runs.js +10 -4
- 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-metric-drafts.js +2 -2
- package/workspace/lib/routes-news.js +15 -1
- package/workspace/lib/routes-phone-day.js +6 -4
- 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-core-doc-issue-test.js +9 -8
- package/workspace/premium-phone-card-test.js +9 -6
- package/workspace/public/pm/bd-ini-panel.js +4 -11
- package/workspace/public/pm/cozy-ev.css +29 -0
- package/workspace/public/pm/cozy-live-pill.css +6 -0
- package/workspace/public/pm/cozy-news.js +186 -22
- package/workspace/public/pm/cozy-today.css +5 -0
- package/workspace/public/pm/cozy-viewer.js +4 -3
- package/workspace/public/pm/cozy-vw-shell.css +49 -0
- package/workspace/public/pm/home-adddoc.js +46 -26
- package/workspace/public/pm/home-app.js +137 -115
- package/workspace/public/pm/home-day.js +15 -11
- package/workspace/public/pm/home-draft.js +35 -23
- package/workspace/public/pm/home-ini.js +2 -2
- package/workspace/public/pm/home-need.js +336 -0
- package/workspace/public/pm/home-phone-card.js +4 -2
- package/workspace/public/pm/home-today.js +2 -2
- package/workspace/public/pm/home-work.js +51 -4
- package/workspace/public/pm/okr-list.js +8 -4
- package/workspace/public/pm/premium-insights.js +6 -5
- package/workspace/public/pm/small-vw.js +128 -0
- package/workspace/public/premium-intelligence.html +1 -1
- package/workspace/server.js +20 -11
- package/workspace/skills/initiative-drive.skill +4 -1
- package/workspace/test-lists/batch18-asks.json +5 -0
- package/workspace/test-lists/news-viewers.json +13 -0
- package/workspace/test-lists/small-viewers.json +5 -0
- package/workspace/test-run.js +3 -1
|
@@ -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; }
|
|
@@ -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
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
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 }) → { el, read } */
|
|
6
|
+
* mountPhoneCard({ pmGet, pmPost, toast, ws, openMeeting, skip }) → { el, read }; skip: moment kinds left to Home (say it once) */
|
|
7
7
|
import { momentOf, inText } from './phone-moment.js';
|
|
8
8
|
|
|
9
9
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
@@ -76,8 +76,10 @@ export function mountPhoneCard(o) {
|
|
|
76
76
|
let h;
|
|
77
77
|
if (!P.page) h = '<span class="label">Now</span><p class="phl">Reading your day.</p>';
|
|
78
78
|
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>`;
|
|
79
|
-
else { const mo = momentNow(); el.dataset.moment = mo.kind; h = moment(mo); }
|
|
79
|
+
else { const mo = momentNow(); el.dataset.moment = mo.kind; h = (o.skip || []).includes(mo.kind) ? '' : moment(mo); }
|
|
80
80
|
el.innerHTML = h;
|
|
81
|
+
// a moment Home already shows (batch 18 item 3: the live meeting is Home's own row) is said once: the card and its Now fold go quiet
|
|
82
|
+
el.hidden = !h; { const sec = el.closest('.czs-sec'); if (sec) { sec.hidden = !h; sec.style.display = h ? '' : 'none'; } }
|
|
81
83
|
if (focus) { const f = el.querySelector(focus); if (f) f.focus(); }
|
|
82
84
|
}
|
|
83
85
|
async function read(force) {
|
|
@@ -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 }) : '';
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Every press is the PM's and goes to the Work page's own route under /api/pm-items, /api/pm-jobs or /api/my-work (pmPost carries the launch
|
|
13
13
|
* nonce); this file adds no writer. A refused press shows the route's reason and changes nothing. Text from the list goes through esc(). */
|
|
14
14
|
import { pmGet, pmPost } from './http.js';
|
|
15
|
-
import { open as vwOpen, close as vwClose } from './cozy-viewer.js';
|
|
15
|
+
import { open as vwOpen, close as vwClose, retitle as vwRetitle, setCheck as vwSetCheck, czSummary, czSections } from './cozy-viewer.js';
|
|
16
16
|
import { mdRender } from './markdown.js';
|
|
17
17
|
import { tabsHtml } from './home-review.js';
|
|
18
18
|
|
|
@@ -55,13 +55,16 @@ const freshUi = () => ({ xp: null, ed: null, dd: '', sn: '', ask: null, body: nu
|
|
|
55
55
|
/** Open My work in the Viewer on one tab (yours | waiting | review | stale). */
|
|
56
56
|
export function openMyWork(tab = 'yours', o = {}) {
|
|
57
57
|
if (tab === 'review' && askReview()) return null;
|
|
58
|
-
const W = { solo: !!o.solo, home: o.view || null, r: null, M: null, tab: TABS.some((t) => t[0] === tab) || tab === 'review' ? tab : 'yours', msg: '', view: null, key: null, ui: freshUi(), refocus: null, want: o.item || null };
|
|
58
|
+
const W = { solo: !!o.solo, own: !!(o.solo && o.item), home: o.view || null, r: null, M: null, tab: TABS.some((t) => t[0] === tab) || tab === 'review' ? tab : 'yours', msg: '', view: null, key: null, ui: freshUi(), refocus: null, want: o.item || null };
|
|
59
59
|
if (W.home) W.view = W.home;
|
|
60
60
|
let body = null;
|
|
61
61
|
const rowOf = (key) => ((W.M && W.M.rows) || []).find((r) => r.key === key) || null;
|
|
62
62
|
const openR = () => (W.view === 'item' ? rowOf(W.key) : null);
|
|
63
63
|
const focusIds = () => new Set(((W.M && W.M.focus && W.M.focus.suggestions[0]) || {}).item_ids || []);
|
|
64
64
|
const setTitle = (t) => { const el = document.getElementById('czVwTitle'); if (el) el.textContent = t; };
|
|
65
|
+
// your own task opened alone: the header is the task's (its check, its name); it changes only when the name does
|
|
66
|
+
let ownT = '';
|
|
67
|
+
const ownHead = (r) => { if (ownT === r.title) return; ownT = r.title; vwRetitle('more:work', r.title); vwSetCheck('more:work', { state: 'todo', label: 'Mark ' + r.title + ' done', title: 'Done' }); };
|
|
65
68
|
|
|
66
69
|
/* ── the list ── */
|
|
67
70
|
function sideOf(r) {
|
|
@@ -189,7 +192,7 @@ export function openMyWork(tab = 'yours', o = {}) {
|
|
|
189
192
|
+ `<label class="mw-f"><span>Due</span><input type="date" id="xeD" class="mw-in" value="${esc(e.due)}"></label>`
|
|
190
193
|
+ `<div class="mw-f"><span>Priority</span><span class="hx-top" role="group" aria-label="Priority">${PRIS.map((p) => `<button type="button" class="hx-b" data-p="xpri" data-v="${p}" aria-pressed="${e.priority === p}">${p || 'None'}</button>`).join('')}</span></div>`
|
|
191
194
|
+ `<label class="mw-f"><span>Waiting on</span><input id="xeW" class="mw-in" maxlength="80" value="${esc(e.wo)}" placeholder="A name moves it to Waiting"></label>`
|
|
192
|
-
+ `<label class="mw-f"><span>Job</span><select id="xeJ" class="mw-in"><option value="">No job</option>${(W.M.jobs || []).map((j) => `<option value="${esc(j.id)}"${e.job === j.id ? ' selected' : ''}>${esc(j.name)}</option>`).join('')}</select></label>`
|
|
195
|
+
+ (W.solo ? '' : `<label class="mw-f"><span>Job</span><select id="xeJ" class="mw-in"><option value="">No job</option>${(W.M.jobs || []).map((j) => `<option value="${esc(j.id)}"${e.job === j.id ? ' selected' : ''}>${esc(j.name)}</option>`).join('')}</select></label>`)
|
|
193
196
|
+ '<div class="hx-top"><button type="button" class="hx-b pri" data-p="xsave">Save</button><button type="button" class="hx-b" data-p="xt" data-k="edit">Cancel</button></div></div>';
|
|
194
197
|
}
|
|
195
198
|
if (x === 'steps') {
|
|
@@ -250,6 +253,44 @@ export function openMyWork(tab = 'yours', o = {}) {
|
|
|
250
253
|
if (r.dialog.source) return h + srcHtml(r.dialog.source) + `<details class="mw-det"><summary>Details</summary>${kv}<p class="hx-n">${esc(p.file)}</p></details>`;
|
|
251
254
|
return h + `<section class="mw-rec">${kv}<p class="hx-n">The item as your list holds it · ${esc(p.file)}</p></section>`;
|
|
252
255
|
}
|
|
256
|
+
/* ── your own task, opened alone from Home (batch 18 item 2-C, canvas OvA9Docs): shell A. The header's check is Done, the title is the
|
|
257
|
+
* task's, "Your own task" under it, ⋯ holds Keep for later and Drop it (danger, last). The summary says when it is, with the agent's
|
|
258
|
+
* offer as the one primary ("Draft it") and the Not before icon; Steps, Waiting on, Priority and From are folds. No ids or file names. ── */
|
|
259
|
+
const SPARK = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/></svg>';
|
|
260
|
+
const CLOCK = 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M12 7v5l3 2';
|
|
261
|
+
function ownHtml(r) {
|
|
262
|
+
const ui = W.ui, d = r.dialog, a = d.write.actions, e = d.edit, ag = d.agent, S = d.steps || [];
|
|
263
|
+
const when = whenOf(r), late = !!e.due && e.due < W.M.today;
|
|
264
|
+
const offer = ag && ag.state === 'suggest';
|
|
265
|
+
const words = offer ? (ag.ask ? ag.ask.replace(/\s*\.$/, '') + '. ' : '') + (ag.mine ? 'I can draft it here in PMOS. Nothing leaves PMOS.' : `I can draft it here in PMOS. Nothing goes to ${ag.where || 'anyone'} until you post it.`) : '';
|
|
266
|
+
const sum = czSummary({ line: late ? 'Due ' + dayLabel(e.due) + ', still open' : when[0] + (when[1] && !/^(not placed yet|you added it|off your lists until then)$/.test(when[1]) ? ' · ' + when[1] : ''), tone: late ? 'warn' : 'you',
|
|
267
|
+
text: offer || d.say === 'This is on your list.' ? '' : d.say || '', extra: offer ? `<p class="czf-spark">${SPARK}<span>${esc(words)}</span></p>` : '',
|
|
268
|
+
primary: offer ? { label: 'Draft it', act: 'ag-brief' } : null,
|
|
269
|
+
also: [{ act: 'when', label: d.defer && d.defer > W.M.today ? 'Not before ' + dayLabel(d.defer) + '. Change it' : 'Not before…', icon: CLOCK }] });
|
|
270
|
+
const whenPan = ui.xp === 'when' || ui.xp === 'defer' ? panelHtml(r, ui.xp) : '';
|
|
271
|
+
const mine = S.filter((x) => x.who !== 'you').length;
|
|
272
|
+
const dr = ag && ag.draft && (ag.draft.body || ag.draft.summary) ? ag.draft : null;
|
|
273
|
+
const sc = d.source, from = sc ? [sc.name, sc.where].filter(Boolean).join(' · ') : ((d.facts || []).find((f) => f[0] === 'From') || [0, ''])[1];
|
|
274
|
+
const rec = (d.pane.rows || []).filter(([k]) => k !== 'From');
|
|
275
|
+
const secs = czSections([
|
|
276
|
+
dr ? { id: 'draft', title: ag.state === 'sent' ? 'Posted' : 'The draft', open: true, html: `<div class="mw-md">${mdHtml(dr.body || dr.summary)}</div><div class="hx-top"><button type="button" class="hx-b" data-pp="copy">Copy</button></div>` } : null,
|
|
277
|
+
{ id: 'steps', title: 'Steps', count: S.length ? S.length + (mine ? ' · ' + mine + ' for me' : '') : '', html: panelHtml(r, 'steps') },
|
|
278
|
+
a.includes('waiting') || e.waiting_on ? { id: 'wait', title: 'Waiting on', count: e.waiting_on || '', html: panelHtml(r, 'wait') } : null,
|
|
279
|
+
{ id: 'pri', title: 'Priority', count: [e.priority || 'None', e.due ? 'due ' + dayLabel(e.due) : ''].filter(Boolean).join(' · '), html: panelHtml(r, 'edit') },
|
|
280
|
+
{ id: 'from', title: 'From', count: from, html: sc ? srcHtml(sc) : rec.length ? `<dl class="hv-facts">${rec.map(([k, v]) => `<div><dt>${esc(k)}</dt><dd>${esc(v)}</dd></div>`).join('')}</dl>` : '' },
|
|
281
|
+
], { key: 'own-task' });
|
|
282
|
+
return `<div class="mw-it mw-own" id="card" data-esc-layer>${sum}${whenPan ? `<div class="mw-ownwhen">${whenPan}</div>` : ''}<div id="agCard">${agCardInner(r)}</div>${secs}<p class="hx-n mw-err" id="cardErr" role="alert" hidden></p></div>`;
|
|
283
|
+
}
|
|
284
|
+
function ownMore() {
|
|
285
|
+
const r = openR(); if (!r) return [];
|
|
286
|
+
const a = r.dialog.write.actions;
|
|
287
|
+
return [
|
|
288
|
+
...(a.includes('keep') ? [{ label: 'Keep for later', on: () => itemPress({ dataset: { p: 'keep' } }, r) }] : []),
|
|
289
|
+
...(a.includes('flag') ? [{ label: 'Move to Today', on: () => itemPress({ dataset: { p: 'flag' } }, r) }] : []),
|
|
290
|
+
{ sep: true },
|
|
291
|
+
{ label: 'Drop it', danger: true, icon: 'M5 7h14M9 7V4h6v3M7 7l1 13h8l1-13', on: () => itemPress({ dataset: { p: 'remove' } }, r) },
|
|
292
|
+
];
|
|
293
|
+
}
|
|
253
294
|
function itemHtml(r) {
|
|
254
295
|
const src = !!r.dialog.source;
|
|
255
296
|
return `<div class="mw-sub mw-it ut-vc" data-esc-layer><div>${backBtn()}</div>`
|
|
@@ -290,6 +331,7 @@ export function openMyWork(tab = 'yours', o = {}) {
|
|
|
290
331
|
const keep = body.scrollTop;
|
|
291
332
|
if (!W.r) body.innerHTML = '<p class="hx-n">Reading My work.</p>';
|
|
292
333
|
else if (!W.M) body.innerHTML = `<p class="hx-n">My work could not be read${W.r.error ? ': ' + esc(W.r.error) : ''}.</p>`;
|
|
334
|
+
else if (W.view === 'item' && openR() && W.own) { const r = openR(); body.innerHTML = ownHtml(r); ownHead(r); }
|
|
293
335
|
else if (W.view === 'item' && openR()) { body.innerHTML = itemHtml(openR()); setTitle(openR().title); }
|
|
294
336
|
else if (W.view === 'fjobs') { body.innerHTML = focusHtml(); setTitle('Focus and jobs'); }
|
|
295
337
|
else if (W.solo) { vwClose(); return; } // opened alone from Home (an item, or Focus and jobs): there is no list behind it
|
|
@@ -449,6 +491,10 @@ export function openMyWork(tab = 'yours', o = {}) {
|
|
|
449
491
|
if (t.dataset.pp === 'copy') { try { await navigator.clipboard.writeText(txt); toast('Draft copied.'); } catch { toast('Copy did not work here. Select the text and copy it.'); } return; }
|
|
450
492
|
const u = URL.createObjectURL(new Blob([txt], { type: 'text/plain;charset=utf-8' })); window.open(u, '_blank', 'noopener'); setTimeout(() => URL.revokeObjectURL(u), 60000); return;
|
|
451
493
|
}
|
|
494
|
+
if (t.dataset.czsAct && W.own && openR()) { // your own task's summary: Draft it, and the Not before icon opens When in place
|
|
495
|
+
if (t.dataset.czsAct === 'when') { W.ui.xp = W.ui.xp === 'when' || W.ui.xp === 'defer' ? null : 'when'; draw(W.ui.xp ? '.mw-ownwhen button' : '[data-czs-act="when"]'); return; }
|
|
496
|
+
itemPress({ dataset: { p: t.dataset.czsAct } }, openR()); return;
|
|
497
|
+
}
|
|
452
498
|
if (t.dataset.p && openR()) { itemPress(t, openR()); return; }
|
|
453
499
|
if (t.dataset.open) { openItem(t.dataset.open); return; }
|
|
454
500
|
if (t.dataset.done) {
|
|
@@ -527,7 +573,8 @@ export function openMyWork(tab = 'yours', o = {}) {
|
|
|
527
573
|
back();
|
|
528
574
|
}
|
|
529
575
|
|
|
530
|
-
body = vwOpen({ id: 'more:work', kind: W.solo ? (W.home === 'fjobs' ? 'Focus' : 'Task') : 'My work', title: W.solo ? (W.home === 'fjobs' ? 'Focus and jobs' : 'Task') : 'My work', icon: 'list',
|
|
576
|
+
body = vwOpen({ id: 'more:work', kind: W.solo ? (W.home === 'fjobs' ? 'Focus' : 'Task') : 'My work', title: W.solo ? (W.home === 'fjobs' ? 'Focus and jobs' : 'Task') : 'My work', icon: 'list',
|
|
577
|
+
...(W.own ? { sub: 'Your own task', check: { state: 'todo', label: 'Mark done', title: 'Done' }, more: () => ownMore(), onPress: (a) => { if (a === 'check' && openR()) doneP(openR()); } } : {}), render: (b) => { b.classList.add('hx'); }, onClose: () => { removeEventListener('keydown', onEsc, true); clearInterval(timer); } });
|
|
531
578
|
// delegated, as the other Home cards do: every control in the card is a real <button>; the drag repeats what the arrow keys do
|
|
532
579
|
body.onclick = onClick;
|
|
533
580
|
body.oninput = onInput;
|
|
@@ -109,7 +109,7 @@ export function budgetMeta(b, today) {
|
|
|
109
109
|
const R = b.reading || {};
|
|
110
110
|
if (R.txt) return [R.txt, ageOf(R.at, today, R.ageDays)].filter(Boolean).join(' · ');
|
|
111
111
|
if (R.share != null) return Math.round(R.share * 100) + '% of open initiatives' + (b.cap != null ? ' · cap ' + Math.round(b.cap * 100) + '%' : '');
|
|
112
|
-
return b.declared === false ? '
|
|
112
|
+
return b.declared === false ? 'No limit set yet' : 'No reading yet'; // batch 18 item 4: plain words; the Viewer says what to do
|
|
113
113
|
}
|
|
114
114
|
/** The owner on the avatar: the server's who (from Jira or the PM), else today's owner string. */
|
|
115
115
|
export function whoOf(g) {
|
|
@@ -163,10 +163,15 @@ export function draftRowHtml(r) {
|
|
|
163
163
|
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
164
164
|
/** The ✦ line: the one thing that matters this week (GsM1–M5). The server's okr.line wins. Before it: a broken limit (red, the one time); else
|
|
165
165
|
* the drafts waiting (✓✓ keeps them all); else the goal furthest behind with why; else a stale reading; else all on their line. It never says
|
|
166
|
-
* "no insight": with nothing read it says what Claude does next. o = { okr, goals, budgets, drafts, running, product } */
|
|
166
|
+
* "no insight": with nothing read it says what Claude does next. o = { okr, goals, budgets, drafts, running, failed, product } */
|
|
167
167
|
export function lineOf(o) {
|
|
168
168
|
const L = o.okr && o.okr.line;
|
|
169
169
|
const G = (o.goals || []).concat(o.budgets || []), open = (o.drafts || []).filter((r) => r.state === 'open'), name = o.product || 'this product';
|
|
170
|
+
// batch 18 item 4: what the drafting run does now wins over the server's line (it is older than the run), except a broken limit. While it
|
|
171
|
+
// runs, say so; when it failed or drafted nothing, say that plainly and offer ✦ again. o.failed: the run's error.
|
|
172
|
+
const loud = !!(L && L.tone === 'crit');
|
|
173
|
+
if (o.running && !loud) return { head: 'I am drafting the goals for ' + name + '.', sub: o.runningSay || 'I read the PRDs and the sources first, then I propose each goal with how I will read it. You can follow it in Sessions.', tone: 'drafts', keepAll: 0 };
|
|
174
|
+
if (o.failed && !open.length && !loud) return { head: 'I could not draft the goals for ' + name + '.', sub: String(o.failed).replace(/\.?$/, '.') + ' Press ✦ to try again.', tone: 'drafts', keepAll: 0, start: true, retry: true };
|
|
170
175
|
// The server's line leads (lib/goal-status.js lineOf: one status everywhere). The drafts the page just loaded are fresher than the model, so
|
|
171
176
|
// they set ✓✓ and the drafted sub; with none left, a sub about drafts is stale and goes.
|
|
172
177
|
if (L && L.head && !(L.tone === 'calm' && open.length)) {
|
|
@@ -176,10 +181,9 @@ export function lineOf(o) {
|
|
|
176
181
|
if (open.length && out.tone !== 'drafts') out.sub = open.length === 1 ? 'I drafted one fix under it.' : 'I drafted ' + open.length + ' fixes. Keep them all at once, or one by one.';
|
|
177
182
|
else if (!open.length && L.keepAll) out.sub = '';
|
|
178
183
|
}
|
|
179
|
-
if (!(o.goals || []).length && !open.length && !o.running) { out.start = true; out.sub = out.sub || '
|
|
184
|
+
if (!(o.goals || []).length && !open.length && !o.running) { out.start = true; out.sub = out.sub || 'Press ✦ and I draft the North Star from your PRDs now, with how I will read it.'; }
|
|
180
185
|
return out;
|
|
181
186
|
}
|
|
182
|
-
if (o.running) return { head: 'I am drafting the goals for ' + name + '.', sub: o.runningSay || 'I read the PRDs and the sources first, then I propose each goal with how I will read it.', tone: 'drafts', keepAll: 0 };
|
|
183
187
|
const broken = G.filter((g) => dotOf(g) === 'broken');
|
|
184
188
|
if (broken.length) {
|
|
185
189
|
const b = broken[0], fix = open.find((r) => r.goal === b.id);
|