create-pmos 0.841.0 → 0.843.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 +59 -54
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +58 -0
- package/workspace/guide/cli.md +24 -0
- package/workspace/guide/layout.md +3 -0
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/build-engine.js +4 -1
- package/workspace/lib/copy-tests.js +281 -0
- package/workspace/lib/events-place.js +38 -2
- package/workspace/lib/factory-traces.js +2 -1
- package/workspace/lib/features.json +2 -0
- package/workspace/lib/initiative-cost.js +259 -0
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/routes-artefacts.js +31 -1
- package/workspace/lib/routes-factory-metrics.js +54 -1
- package/workspace/lib/routes-proposals.js +7 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog.css +3 -0
- package/workspace/public/pm/bd-backlog.js +36 -7
- package/workspace/public/pm/bd-pop-ds.js +8 -4
- package/workspace/public/pm/copy-tests.js +95 -0
- package/workspace/public/pm/cozy-events-view.js +16 -2
- package/workspace/public/pm/cozy-events.css +5 -1
- package/workspace/public/pm/cozy-events.js +6 -1
- package/workspace/public/pm/cozy-pop-work.js +14 -1
- package/workspace/public/pm/initiative-cost.js +103 -0
- package/workspace/public/pm/pop-work-model.js +2 -1
- package/workspace/test-lists/copy-tests.json +9 -0
- package/workspace/test-lists/events-bring.json +9 -0
- package/workspace/test-lists/initiative-cost.json +9 -0
|
@@ -26,6 +26,7 @@ import * as TWV from './team-waits.js'; // team-waits (A364): Work › Depende
|
|
|
26
26
|
import * as TSV from './team-slips.js'; // team-slips (A15): Upstream on Work › Dependencies, other teams' slips (GET /api/team-slips)
|
|
27
27
|
import * as LV from './line-view.js'; // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
|
|
28
28
|
import * as FV from './factory.js'; // Work › Factory (factory-page-ui): the stations and the work they make, from GET /api/factory
|
|
29
|
+
import * as IC from './initiative-cost.js'; // Work › Cost (initiative-cost, A17): what the factory spent per initiative, from GET /api/initiative-cost
|
|
29
30
|
import * as LB from './list-balance.js'; // the balance meter under the Backlog header (bet A448, board BalanceDS) // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
|
|
30
31
|
import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
|
|
31
32
|
|
|
@@ -73,10 +74,11 @@ export function tabOf() {
|
|
|
73
74
|
if (q === 'sprint') return 'sp';
|
|
74
75
|
if (q === 'line') return 'ln';
|
|
75
76
|
if (q === 'factory') return 'fx';
|
|
77
|
+
if (q === 'cost') return 'co';
|
|
76
78
|
if (q === 'deps') return 'dp';
|
|
77
79
|
if (q === 'initiatives') return 'ini';
|
|
78
80
|
const v = (get(KEY, {}) || {})[scopeKey()];
|
|
79
|
-
return v === 'bk' || v === 'sp' || v === 'ln' || v === 'fx' || v === 'dp' ? v : 'ini';
|
|
81
|
+
return v === 'bk' || v === 'sp' || v === 'ln' || v === 'fx' || v === 'dp' || v === 'co' ? v : 'ini';
|
|
80
82
|
}
|
|
81
83
|
/** Is a task tab (Backlog or This sprint) the view now? */
|
|
82
84
|
export const on = () => tabOf() === 'bk' || tabOf() === 'sp';
|
|
@@ -86,6 +88,8 @@ export const lineOn = () => tabOf() === 'ln';
|
|
|
86
88
|
export const factoryOn = () => tabOf() === 'fx';
|
|
87
89
|
/** Is the Dependencies tab the view now? (team-waits) */
|
|
88
90
|
export const depsOn = () => tabOf() === 'dp';
|
|
91
|
+
/** Is the Cost tab the view now? (initiative-cost) */
|
|
92
|
+
export const costOn = () => tabOf() === 'co';
|
|
89
93
|
function setOn(v) {
|
|
90
94
|
v = v === true ? 'bk' : v === false ? 'ini' : v;
|
|
91
95
|
const m = get(KEY, {}) || {}; m[scopeKey()] = v; put(KEY, m);
|
|
@@ -137,7 +141,8 @@ export async function load() {
|
|
|
137
141
|
// the Line (quiet-rows-line) is a five-column table for a desk; a phone keeps its three tabs (Today's dashed line is desk-only too)
|
|
138
142
|
// the Factory (factory-page-ui) sits beside Line, a desk's too: its tiles are a row of five
|
|
139
143
|
// Dependencies (team-waits) is a desk tab as well: a phone keeps its three
|
|
140
|
-
|
|
144
|
+
// the Cost tab (initiative-cost) shows on a desk only while some factory spent on the pick (zero is silence)
|
|
145
|
+
export const tabNames = (phone, n, cost = false) => [['ini', 'Initiatives'], ...(phone ? [] : [['ln', 'Line'], ['fx', 'Factory']]), ['bk', 'Backlog' + (phone && n > 0 ? ` <span class="bk-swn">${Number(n)}</span>` : '')], ['sp', phone ? 'Sprint' : 'This sprint'], ...(phone ? [] : [['dp', 'Dependencies']]), ...(!phone && cost ? [['co', 'Cost']] : [])];
|
|
141
146
|
const phoneNow = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
|
|
142
147
|
function drawSwitch() {
|
|
143
148
|
if (!sw) return;
|
|
@@ -145,22 +150,45 @@ function drawSwitch() {
|
|
|
145
150
|
// one Tabs part for the three (WorkDS); no count on a desk tab: Where it stands says what matters (say it once).
|
|
146
151
|
// A phone (PhoneWorkDS, job 1540) has no Where it stands over the Backlog, so its tab carries the count, and the short name "Sprint"
|
|
147
152
|
const ph = phoneNow();
|
|
148
|
-
sw.innerHTML = tabNames(ph, ph && DATA ? backlogOf().length : 0).map(([k, n]) => tb(k, n)).join('');
|
|
153
|
+
sw.innerHTML = tabNames(ph, ph && DATA ? backlogOf().length : 0, IC.hasSpend(costScoped()) || t === 'co').map(([k, n]) => tb(k, n)).join('');
|
|
149
154
|
}
|
|
150
155
|
function apply() {
|
|
151
|
-
const bk = on(), ln = lineOn(), fx = factoryOn(), dp = depsOn();
|
|
156
|
+
const bk = on(), ln = lineOn(), fx = factoryOn(), dp = depsOn(), co = costOn();
|
|
152
157
|
if (tabOf() === 'sp') CHIPS.add('sprint');
|
|
153
158
|
document.body.classList.toggle('sp-on', tabOf() === 'sp');
|
|
154
|
-
document.body.classList.toggle('bk-on', bk || ln || fx || dp);
|
|
155
|
-
if (host) host.hidden = !(bk || ln || fx || dp);
|
|
159
|
+
document.body.classList.toggle('bk-on', bk || ln || fx || dp || co);
|
|
160
|
+
if (host) host.hidden = !(bk || ln || fx || dp || co);
|
|
156
161
|
drawSwitch();
|
|
157
162
|
if (ln) { closeAll(); drawLine(); return; }
|
|
158
163
|
if (fx) { closeAll(); drawFactory(); return; }
|
|
159
164
|
if (dp) { closeAll(); drawDeps(); return; }
|
|
165
|
+
if (co) { closeAll(); drawCost(); return; }
|
|
160
166
|
if (bk) { if (!DATA || scopeKey() !== lastScope) { lastScope = scopeKey(); host.innerHTML = '<p class="bk-wait">Reading the tasks…</p>'; load(); } else draw(); }
|
|
161
167
|
else closeAll();
|
|
162
168
|
}
|
|
163
169
|
|
|
170
|
+
/* ── the Cost tab (initiative-cost, board BatchReleaseDS panel 21) ── what the factory spent per initiative, from GET /api/initiative-cost ── */
|
|
171
|
+
const CO = { used: false, undone: new Set() };
|
|
172
|
+
/** The products of the pick, as the Cost read has them. */
|
|
173
|
+
function costScoped() {
|
|
174
|
+
const got = IC.cached() || [];
|
|
175
|
+
if (!A) return got;
|
|
176
|
+
const ws = new Set(A.scope().map((x) => x.ws || ''));
|
|
177
|
+
return ws.has('') ? got : got.filter((p) => ws.has(p.ws));
|
|
178
|
+
}
|
|
179
|
+
function drawCost() {
|
|
180
|
+
if (!host) return;
|
|
181
|
+
if (!CO.used) { CO.used = true; noteUse('costOpen'); console.info('[initiative-cost] cost tab opened'); }
|
|
182
|
+
if (!IC.cached()) { host.innerHTML = '<p class="bk-wait">Reading the cost…</p>'; IC.load().then(() => { if (costOn()) drawCost(); }); return; }
|
|
183
|
+
host.innerHTML = IC.tabHtml(costScoped(), { undone: CO.undone });
|
|
184
|
+
IC.load().then(() => { if (costOn()) host.innerHTML = IC.tabHtml(costScoped(), { undone: CO.undone }); }); // a read older than a minute comes again
|
|
185
|
+
}
|
|
186
|
+
/** A press in the Cost tab: Pause (with Undo), Keep going, Resume, or a name (opens the initiative). true when it was one. */
|
|
187
|
+
function costPress(e) {
|
|
188
|
+
if (!costOn()) return false;
|
|
189
|
+
return IC.press(e, { post: (u, b) => AP().post(u, b).catch(() => null), say: (m, undo) => (A.say ? A.say(m, undo) : null), redraw: () => { if (costOn()) drawCost(); }, open: (id, ws) => (A.openIni ? A.openIni(id, ws) : null), undone: CO.undone });
|
|
190
|
+
}
|
|
191
|
+
|
|
164
192
|
/* ── the Line tab (quiet-rows slice B, board QuietLine) ── every live initiative of the pick by station, from GET /api/line ── */
|
|
165
193
|
const LN = { tab: '', got: null, key: '', used: false };
|
|
166
194
|
async function readLine() {
|
|
@@ -914,7 +942,8 @@ export function sync(api) {
|
|
|
914
942
|
sw.addEventListener('click', (e) => { const b = e.target.closest('[data-bksw]'); if (b) setOn(b.dataset.bksw); });
|
|
915
943
|
host = document.createElement('div'); host.id = 'bkBody'; host.className = 'bk-host'; host.hidden = true;
|
|
916
944
|
ib.insertAdjacentElement('afterend', host);
|
|
917
|
-
host.addEventListener('click', (e) => { if (linePress(e) || factoryPress(e) || depsPress(e)) return; press(e); });
|
|
945
|
+
host.addEventListener('click', (e) => { if (linePress(e) || factoryPress(e) || depsPress(e) || costPress(e)) return; press(e); });
|
|
946
|
+
IC.load().then(() => drawSwitch()); // the Cost tab shows only when some factory spent (initiative-cost)
|
|
918
947
|
host.addEventListener('change', (e) => { if (e.target.closest('[data-bkck]')) press(e); });
|
|
919
948
|
host.addEventListener('keydown', (e) => { const c = e.target.closest('[data-bkcap]'); if (c && e.key === 'Enter') { e.preventDefault(); capture(c); } });
|
|
920
949
|
dragWire();
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* listHtml(rows, W, o) → the Work breakdown's List: one capture Input, one group per stage with tasks, empty stages folded into one line
|
|
10
10
|
* wbsHead(view) → the Work breakdown's head: its name and the List / Gantt tabs
|
|
11
11
|
* caseHtml(W, o) → The case: its lines (each editable), the facts; no line written: one Suggestion to draft them all
|
|
12
|
-
* overviewHtml(W, r, o) → Overview: Where it stands, The case and its facts in one block that folds; folded, the one-line summary
|
|
12
|
+
* overviewHtml(W, r, o) → Overview: Where it stands, The case and its facts in one block that folds; folded, the one-line summary;
|
|
13
|
+
* then the Copy test block when the initiative has one (pm/copy-tests.js)
|
|
13
14
|
* artsHtml(arts) → Artefacts: a List with Add in the head
|
|
14
15
|
* artMenu(arts, o) → the ⋯ menu's Artefacts section (the desk popup has no side card)
|
|
15
16
|
* stageKeyOf(text, st) → { key, name, title } the stage a captured line names ("… in Plan"), else the stage in progress
|
|
@@ -28,6 +29,7 @@ export const I = {
|
|
|
28
29
|
};
|
|
29
30
|
import * as WT from './work-tree.js'; // subtasks and the epic check (initiative work-subtasks)
|
|
30
31
|
import { barHtml as selBar } from './work-select.js'; // the bulk bar (WorkBulkDS)
|
|
32
|
+
import { blockHtml as copyTestsHtml } from './copy-tests.js'; // the Copy test block under the Overview (initiative copy-tests, A351)
|
|
31
33
|
import { runStateLine } from './grill-words.js'; // a grill run the PM was told about: running, or failed and why (lib/grill.js runStateOf)
|
|
32
34
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
33
35
|
const DAY = 864e5;
|
|
@@ -296,19 +298,21 @@ export function caseHtml(W, o = {}) {
|
|
|
296
298
|
* that opens it when PMOS has a suggestion waiting. The block's head is the fold press (data-pw-ov). Nothing to show: ''. */
|
|
297
299
|
export function overviewHtml(W, r, o = {}) {
|
|
298
300
|
const s = standsParts(W, r, o), c = caseParts(W, o), open = o.open !== false;
|
|
299
|
-
|
|
301
|
+
// the initiative's copy tests (copy-tests, A351): their own block under the Overview, folded or open; none: nothing (zero is silence)
|
|
302
|
+
const ct = copyTestsHtml(W.copyTests, { ro: o.ro, ws: W.ws, offer: W.copyTestOffer });
|
|
303
|
+
if (!s.say && !s.next && !s.sug && !s.grill && !c.top && !c.lines && !c.status && !c.facts) return ct;
|
|
300
304
|
const head = `<h2 class="pm-h-sm"><button type="button" class="pwd-ovt" data-pw-ov aria-expanded="${open}">${SV(open ? I.down : I.right, 16)}${SV(I.star).replace('pm-ic', 'pm-ic pm-star')}Overview</button></h2>`;
|
|
301
305
|
if (!open) {
|
|
302
306
|
const line = s.say || (W.overview && W.overview.status) || '';
|
|
303
307
|
const one = line ? `<p class="pwd-say pwd-ov1">${esc(line)}</p>` : s.next;
|
|
304
308
|
const sg = s.n ? `<button type="button" class="pw-lk" data-pw-ov>${esc(plural(s.n, 'suggestion', 'suggestions'))}</button>` : '';
|
|
305
|
-
return `<section class="pm-block pwd-blk pwd-ov shut" aria-label="Overview">${head}${one || sg ? `<div class="pm-row pwd-ovs">${one}${sg}</div>` : ''}${s.grill}</section
|
|
309
|
+
return `<section class="pm-block pwd-blk pwd-ov shut" aria-label="Overview">${head}${one || sg ? `<div class="pm-row pwd-ovs">${one}${sg}</div>` : ''}${s.grill}</section>${ct}`;
|
|
306
310
|
}
|
|
307
311
|
const part = (cls, lbl, h) => (h ? `<div class="pwd-ovp ${cls}"><h3 class="pm-meta">${lbl}</h3>${h}</div>` : '');
|
|
308
312
|
const stands = part('pwd-ovw', 'Where it stands', (s.say ? `<p class="pwd-say">${esc(s.say)}</p>` : '') + s.grill + s.next + s.sug);
|
|
309
313
|
const kase = part('pwd-ovc', 'The case', c.top + c.lines + c.status);
|
|
310
314
|
const facts = part('pwd-ovf', 'Details', c.facts);
|
|
311
|
-
return `<section class="pm-block pwd-blk pwd-ov" aria-label="Overview">${head}<div class="pwd-ovg">${stands}${kase}${facts}</div></section
|
|
315
|
+
return `<section class="pm-block pwd-blk pwd-ov" aria-label="Overview">${head}<div class="pwd-ovg">${stands}${kase}${facts}</div></section>${ct}`;
|
|
312
316
|
}
|
|
313
317
|
const iconOf = (a) => (a.link || /^link/i.test(a.kind || '') ? I.link : /slide|deck/i.test(a.kind || '') ? I.deck : /proto|design/i.test((a.kindName || '') + ' ' + (a.kind || '') + ' ' + (a.akind || '')) ? I.proto : I.doc);
|
|
314
318
|
/** arts: the model's artefacts, in its order (each row's press is its index, as the popup's handler reads it). o: { ro, merge (the ✦ line) } */
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* copy-tests.js — the Copy test block in the work popup (initiative copy-tests, job #1905, idea A351; board BatchDesignDS panel 20).
|
|
2
|
+
*
|
|
3
|
+
* GET /api/artefacts?scope=experiment:<id> carries the initiative's tests on the Experiment artefact (`copyTests`, lib/copy-tests.js foldOf).
|
|
4
|
+
* With no test yet, a record that names its rollout_flag carries `copyTestOffer` { initiative, flag }: the block shows by itself (LINE Rule 12)
|
|
5
|
+
* as one ✦ line, a field for the new words and an icon-only ✦ that drafts A (as it is now) against B. It never starts the test.
|
|
6
|
+
* Each test is one table (Variant, Copy or Layout, the metric, Sure) and one ✦ line, from the system's parts: pm-block, pm-table, pm-said
|
|
7
|
+
* and icon-only pm-btn with a label for screen readers. A draft with a flag offers ▶ (start); a test PMOS is at least 80 % sure of offers ✓
|
|
8
|
+
* (keep the winner). The press is POST /api/artefacts/copy-test; the toast carries Undo. No test: nothing is drawn (zero is silence).
|
|
9
|
+
* pm/pop-work-model.js puts the tests on the model (W.copyTests) and pm/bd-pop-ds.js draws the block under the Overview. This module wires its
|
|
10
|
+
* own presses (one listener on the document, data-ct-op), so the popup's handler is unchanged; after a press it sends cz:chat-turn, which
|
|
11
|
+
* makes the popup read its artefacts again.
|
|
12
|
+
*
|
|
13
|
+
* testsOf(art) → [test] the Experiment artefact's copyTests, or []
|
|
14
|
+
* offerOf(art) → { initiative, flag } | null the Experiment artefact's copyTestOffer
|
|
15
|
+
* blockHtml(tests, { ro, ws, offer }) → HTML | '' ro (a shared copy): the tables and lines, no buttons and no offer
|
|
16
|
+
* press(btn, { pmPost, undoToast, toast, done }) → true when btn is a copy test button (data-ct-op, data-ct-id, data-ct-ws)
|
|
17
|
+
* The copy says PMOS, never Claude. */
|
|
18
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
19
|
+
const SV = (d, w = 16) => `<svg class="pm-ic" aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
20
|
+
const STAR = 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', OK = 'M5 12.5l4.5 4.5L19 7.5', PLAY = 'M8 5l11 7-11 7z';
|
|
21
|
+
const pct = (x) => (Math.round(x * 1000) / 10).toFixed(1).replace(/\.0$/, '') + ' %';
|
|
22
|
+
|
|
23
|
+
export function testsOf(art) {
|
|
24
|
+
const ex = (art || []).find((a) => a && a.key === 'experiment');
|
|
25
|
+
return ex && Array.isArray(ex.copyTests) ? ex.copyTests : [];
|
|
26
|
+
}
|
|
27
|
+
export function offerOf(art) {
|
|
28
|
+
const ex = (art || []).find((a) => a && a.key === 'experiment');
|
|
29
|
+
const o = ex && ex.copyTestOffer;
|
|
30
|
+
return o && o.initiative && o.flag ? o : null;
|
|
31
|
+
}
|
|
32
|
+
const btn = (op, id, ws, label, d) => `<button type="button" class="pm-btn" data-ct-op="${op}" data-ct-id="${esc(id)}" data-ct-ws="${esc(ws)}" aria-label="${esc(label)}" title="${esc(label)}">${SV(d)}</button>`;
|
|
33
|
+
function oneHtml(t, ro, ws) {
|
|
34
|
+
const r = t.result, lead = r && r.leader ? r.leader : '';
|
|
35
|
+
const rows = (t.variants || []).map((v) => {
|
|
36
|
+
const win = lead === v.v && t.status !== 'draft';
|
|
37
|
+
const rate = v.rate == null ? '' : pct(v.rate);
|
|
38
|
+
return `<tr><td>${esc(v.v)}</td><td>${esc(v.text)}</td><td>${win && rate ? `<b>${rate}</b>` : rate}</td><td>${win ? Math.round(r.sure * 100) + ' %' : ''}</td></tr>`;
|
|
39
|
+
}).join('');
|
|
40
|
+
const table = `<table class="pm-table"><thead><tr><th>Variant</th><th>${t.kind === 'layout' ? 'Layout' : 'Copy'}</th><th>${esc(t.metric || 'Converted')}</th><th>Sure</th></tr></thead><tbody>${rows}</tbody></table>`;
|
|
41
|
+
const said = `<p class="pm-said">${SV(STAR, 16).replace('pm-ic', 'pm-ic pm-star')}<span>${esc(t.line)}</span></p>`;
|
|
42
|
+
let acts = '';
|
|
43
|
+
if (!ro && t.status === 'draft' && t.flag) acts = btn('start', t.id, ws, 'Start the test behind ' + t.flag, PLAY);
|
|
44
|
+
else if (!ro && t.canKeep && lead) acts = btn('keep', t.id, ws, 'Keep ' + lead, OK);
|
|
45
|
+
return `<div class="ct-one">${table}${said}${acts ? `<div class="pm-row">${acts}</div>` : ''}</div>`;
|
|
46
|
+
}
|
|
47
|
+
export function blockHtml(tests, o = {}) {
|
|
48
|
+
const T = (tests || []).filter((t) => t && Array.isArray(t.variants) && t.variants.length);
|
|
49
|
+
const of = o.offer;
|
|
50
|
+
if (!T.length && of && of.initiative && of.flag && !o.ro) {
|
|
51
|
+
const said = `<p class="pm-said">${SV(STAR, 16).replace('pm-ic', 'pm-ic pm-star')}<span>${esc(of.flag)} can carry a test. Write the new words and PMOS drafts A, as it is now, against B. Starting it waits for you.</span></p>`;
|
|
52
|
+
const field = `<input class="pm-input ct-ask" type="text" data-ct-ask maxlength="200" autocomplete="off" placeholder="New words to try, for example "Pay now"" aria-label="New words to try">`;
|
|
53
|
+
const go = `<button type="button" class="pm-btn" data-ct-op="draft" data-ct-id="${esc(of.initiative)}" data-ct-ini="${esc(of.initiative)}" data-ct-ws="${esc(o.ws || '')}" aria-label="Draft the test" title="Draft the test">${SV(STAR)}</button>`;
|
|
54
|
+
return `<section class="pm-block pwd-blk ct-blk" aria-label="Copy test"><h2 class="pm-h-sm">Copy test</h2><div class="ct-one">${said}<div class="pm-row">${field}${go}</div></div></section>`;
|
|
55
|
+
}
|
|
56
|
+
if (!T.length) return '';
|
|
57
|
+
return `<section class="pm-block pwd-blk ct-blk" aria-label="Copy test"><h2 class="pm-h-sm">${T.length === 1 ? 'Copy test' : 'Copy tests'}</h2>${T.map((t) => oneHtml(t, !!o.ro, o.ws || '')).join('')}</section>`;
|
|
58
|
+
}
|
|
59
|
+
/** A press on ▶ or ✓. h: { pmPost, undoToast, toast, done } — done() makes the popup read the artefacts again and draw itself. */
|
|
60
|
+
export async function press(b, h) {
|
|
61
|
+
const d = b && b.dataset;
|
|
62
|
+
if (!d || !d.ctOp || !d.ctId) return false;
|
|
63
|
+
const ws = d.ctWs || undefined;
|
|
64
|
+
let body = { ws, id: d.ctId, op: d.ctOp };
|
|
65
|
+
if (d.ctOp === 'draft') {
|
|
66
|
+
const row = b.closest ? b.closest('.pm-row') : null, f = row && row.querySelector('[data-ct-ask]');
|
|
67
|
+
const ask = f ? String(f.value || '').trim() : '';
|
|
68
|
+
if (!ask) { if (f && f.focus) f.focus(); return true; }
|
|
69
|
+
body = { ws, op: 'draft', initiative: d.ctIni, ask };
|
|
70
|
+
}
|
|
71
|
+
b.disabled = true;
|
|
72
|
+
const r = await h.pmPost('/api/artefacts/copy-test', body).catch(() => null);
|
|
73
|
+
if (!r || r.ok === false) { if (h.toast) h.toast((r && r.error) || 'Nothing was changed. Try again.'); b.disabled = false; return true; }
|
|
74
|
+
if (h.done) h.done();
|
|
75
|
+
h.undoToast(r.said || 'Done.', async () => {
|
|
76
|
+
const id = d.ctOp === 'draft' ? (r.test && r.test.id) : d.ctId;
|
|
77
|
+
const u = await h.pmPost('/api/artefacts/copy-test', { ws, id, op: 'undo' }).catch(() => null);
|
|
78
|
+
if ((!u || u.ok === false) && h.toast) h.toast((u && u.error) || 'The undo did not land.');
|
|
79
|
+
if (h.done) h.done();
|
|
80
|
+
});
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// one listener for every popup: the press is the button's own; nothing else on the page carries data-ct-op
|
|
85
|
+
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
86
|
+
document.addEventListener('click', (e) => {
|
|
87
|
+
const b = e.target && e.target.closest ? e.target.closest('button[data-ct-op]') : null;
|
|
88
|
+
if (!b || b.disabled) return;
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
Promise.all([import('./http.js'), import('./hi-pop.js')]).then(([H, P]) => press(b, {
|
|
91
|
+
pmPost: H.pmPost, undoToast: P.undoToast, toast: (t) => P.undoToast(t, () => b.click(), 12000, 'Try again'),
|
|
92
|
+
done: () => document.dispatchEvent(new CustomEvent('cz:chat-turn')),
|
|
93
|
+
})).catch(() => { b.disabled = false; });
|
|
94
|
+
});
|
|
95
|
+
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* showHtml(show, { counts, unread }) Show, a flat block: the six types (TYPES) with their counts as the filter, which is also the key to the
|
|
19
19
|
* marks; a type whose source is not read says so and opens Connectors. countsOf(items, o) · hiddenHtml(items,
|
|
20
20
|
* o): the "Showing … only · N more hidden · Show all" line. visible(items, o): the types on and the chip
|
|
21
|
+
* A meeting tied to work or a product shows what to bring under it (x.bring, board TbEvents): ✦ and the calls, or a grey "Nothing new".
|
|
21
22
|
* Each row's grey line starts with its type word (lineOf); a coming day with BUSY meetings or more is one line that opens them; a date
|
|
22
23
|
* stated in a source opens the line that states it under the row (o.open has 'src:<key>').
|
|
23
24
|
* KINDS · KIND_LABEL · LATE_SHOWN · shiftMonth(ym, n) · weekOf(day)
|
|
@@ -139,6 +140,19 @@ function actsHtml(x, o, fixLine) {
|
|
|
139
140
|
+ (x.canFix ? `<button type="button" class="evp-ib evp-fx pm-btn" data-evp-fix aria-pressed="${x.fixed ? 'true' : 'false'}" aria-label="${x.fixed ? 'Fixed date. Press to let PMOS suggest a new date' : 'Mark as a fixed date'}" title="${x.fixed ? 'Fixed date' : 'Fixed date: never move it'}">${svg(ICON.lock, 15)}</button>` : '');
|
|
140
141
|
return (a ? `<span class="evp-a">${a}</span>` : '') + (tools ? `<span class="evp-tl acts">${tools}</span>` : '');
|
|
141
142
|
}
|
|
143
|
+
/** What to bring, under a meeting (board TbEvents): ✦ and PMOS's calls from the meeting's own work or product; "Nothing new for this one
|
|
144
|
+
* yet." in grey with no ✦. Read-only: no button. */
|
|
145
|
+
function bringHtml(x) {
|
|
146
|
+
const b = x.bring;
|
|
147
|
+
if (!b || !b.text) return '';
|
|
148
|
+
return `<div class="evp-bring pm-meta${b.calls && b.calls.length ? '' : ' none'}" data-key="${esc(x.key)}" role="note" aria-label="What to bring">`
|
|
149
|
+
+ `${b.calls && b.calls.length ? STAR(14) : ''}<span>${esc(b.text)}</span></div>`;
|
|
150
|
+
}
|
|
151
|
+
/** How many meetings the page shows with calls to bring, and how many calls (the use log and the [events-bring] line). PURE. */
|
|
152
|
+
export function bringShown(model) {
|
|
153
|
+
const ms = ((model && model.items) || []).filter((x) => x.kind === 'meeting' && (x.group === 'today' || x.group === 'coming') && x.bring && x.bring.calls && x.bring.calls.length);
|
|
154
|
+
return { meetings: ms.length, calls: ms.reduce((n, x) => n + x.bring.calls.length, 0) };
|
|
155
|
+
}
|
|
142
156
|
/** The line a date stated in a source opens, under the row: who said it, when, and a link to the source. The sentence only when it says
|
|
143
157
|
* more than the title (say it once). */
|
|
144
158
|
function srcHtml(x, o) {
|
|
@@ -161,7 +175,7 @@ export function rowHtml(x, o = {}) {
|
|
|
161
175
|
const kindWord = TYPE_WORD[typeOf(x)];
|
|
162
176
|
return `<div class="evp-r${o.child ? ' evp-kid' : ''}${x.fixed ? ' fixed' : ''}${o.busy && o.busy.has(x.key) ? ' busy' : ''} pm-li" data-key="${esc(x.key)}" data-kind="${esc(x.kind)}" data-type="${esc(typeOf(x))}"${askOf(x)} aria-label="${esc(kindWord)}">`
|
|
163
177
|
+ `<span class="evp-d ${x.tone || ''}"><b>${esc(d.b)}</b>${d.s || x.fixed ? `<small>${esc(d.s)}${x.fixed ? (d.s ? ' · ' : '') + 'fixed' : ''}</small>` : ''}</span>${markHtml(x)}${whatHtml(x, o, fixLine)}`
|
|
164
|
-
+ `${badge}${actsHtml(x, o, fixLine)}</div>${srcHtml(x, o)}${x.suggest && !fixLine ? sugLine(x) : ''}`;
|
|
178
|
+
+ `${badge}${actsHtml(x, o, fixLine)}</div>${srcHtml(x, o)}${bringHtml(x)}${x.suggest && !fixLine ? sugLine(x) : ''}`;
|
|
165
179
|
}
|
|
166
180
|
|
|
167
181
|
/** A List block: its heading and count, then the rows. Zero is silence. */
|
|
@@ -200,7 +214,7 @@ export function todayHtml(rows, o = {}) {
|
|
|
200
214
|
const over = now && (x.until || x.time) < now;
|
|
201
215
|
const fixLine = !!x.suggest;
|
|
202
216
|
return `<div class="evp-tr${o.busy && o.busy.has(x.key) ? ' busy' : ''}" data-key="${esc(x.key)}" data-kind="${esc(x.kind)}" data-type="${esc(typeOf(x))}"${askOf(x)}><span class="evp-tm pm-meta">${esc(x.time || (x.kind === 'meeting' ? 'All day' : 'Due'))}</span>`
|
|
203
|
-
+ `<div class="evp-ev pm-ev${over ? ' over' : ''}${x.fixed ? ' fixed' : ''}">${markHtml(x)}${whatHtml(x, o, fixLine)}${actsHtml(x, o, fixLine)}</div></div>${srcHtml(x, o)}`;
|
|
217
|
+
+ `<div class="evp-ev pm-ev${over ? ' over' : ''}${x.fixed ? ' fixed' : ''}">${markHtml(x)}${whatHtml(x, o, fixLine)}${actsHtml(x, o, fixLine)}</div></div>${srcHtml(x, o)}${bringHtml(x)}`;
|
|
204
218
|
};
|
|
205
219
|
const line = '<div class="evp-tr evp-nowl" aria-label="Now"><span class="evp-tm pm-meta">now</span><span class="evp-nl" aria-hidden="true"></span></div>';
|
|
206
220
|
let body = untimed.map(ev).join(''), placed = !now;
|
|
@@ -49,6 +49,10 @@ button.evp-t { cursor: pointer; }
|
|
|
49
49
|
.evp-all { margin: 0 var(--space-16) 6px; }
|
|
50
50
|
.evp-sug { margin: 2px var(--space-16) var(--space-8) 104px; }
|
|
51
51
|
.evp-sug .pm-star, .evp-all .pm-star { flex: none; }
|
|
52
|
+
/* what to bring under a meeting (board TbEvents): ✦ and the calls, in the title's column; read-only, so no buttons */
|
|
53
|
+
.evp-bring { display: flex; align-items: flex-start; gap: var(--space-8); margin: 0 var(--space-16) var(--space-8) 104px; }
|
|
54
|
+
.evp-bring .pm-star { flex: none; margin-top: 2px; }
|
|
55
|
+
.evp-tl-list .evp-bring { margin: calc(-1 * var(--space-4)) 0 0 66px; }
|
|
52
56
|
|
|
53
57
|
/* Today: a Timeline block. Each line is the time, then an Event; the now line runs across the Events' column */
|
|
54
58
|
.evp-tl-list { display: flex; flex-direction: column; gap: 10px; }
|
|
@@ -169,7 +173,7 @@ button.evp-t { cursor: pointer; }
|
|
|
169
173
|
.pm-ds .evp-grid.pm-layout-side { grid-template-columns: minmax(0, 1fr); }
|
|
170
174
|
.evp .evp-r { flex-wrap: wrap; row-gap: var(--space-4); padding: var(--space-8) var(--space-12); }
|
|
171
175
|
.evp .evp-r .txt { flex: 1 1 calc(100% - 100px); }
|
|
172
|
-
.evp-sug, .evp-src { margin-left: var(--space-16); padding-left: var(--space-16); }
|
|
176
|
+
.evp-sug, .evp-src, .evp-bring { margin-left: var(--space-16); padding-left: var(--space-16); }
|
|
173
177
|
.evp-sug { flex-wrap: wrap; }
|
|
174
178
|
.evp-new { grid-template-columns: minmax(0, 1fr) auto; }
|
|
175
179
|
.evp-new input[type="date"] { grid-column: 1; }
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
import { mountNav } from './cozy-nav.js';
|
|
21
21
|
import * as POP from './cozy-popup.js';
|
|
22
22
|
import { pmGet, pmPost } from './http.js';
|
|
23
|
-
import { TYPES, listHtml, calHtml, monthHtml, showHtml, hiddenHtml, countsOf, shiftMonth, esc, lateInView } from './cozy-events-view.js';
|
|
23
|
+
import { TYPES, listHtml, calHtml, monthHtml, showHtml, hiddenHtml, countsOf, shiftMonth, esc, lateInView, bringShown } from './cozy-events-view.js';
|
|
24
|
+
import { noteUse } from './use-log.js'; // what to bring (tb-events-bring): one line per page load that shows calls, on this computer only
|
|
24
25
|
import { readPick } from './cozy-pick.js';
|
|
25
26
|
import { scopeChipHtml, openScope, matches, narrowed, scopeWords, whenNames } from './scope-chip.js';
|
|
26
27
|
|
|
@@ -71,6 +72,10 @@ async function load() {
|
|
|
71
72
|
S.model = r;
|
|
72
73
|
if (!S.ym) S.ym = String(r.today).slice(0, 7);
|
|
73
74
|
draw();
|
|
75
|
+
if (!S.bringNoted) {
|
|
76
|
+
const b = bringShown(r);
|
|
77
|
+
if (b.meetings) { S.bringNoted = true; noteUse('events-bring-shown'); console.info('[events-bring] shown meetings=' + b.meetings + ' calls=' + b.calls); }
|
|
78
|
+
}
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
/* ── drawing ── */
|
|
@@ -38,6 +38,7 @@ import * as IF from './inline-fields.js'; // a task's sprint and priority, set
|
|
|
38
38
|
import * as SD from './star-draft.js'; // a ✦ draft runs as a PMOS background job and lands on its line (star-buttons-act-directly A7)
|
|
39
39
|
import * as CAP from './pop-cap.js'; // five actions at most: Ask PMOS and the toolbar's four, the rest under ⋯ (popup-cap, idea A498)
|
|
40
40
|
import { noteUse } from './use-log.js';
|
|
41
|
+
import * as IC from './initiative-cost.js'; // ⋯ › Cost (initiative-cost, A17): the factory's spend per merged pull request, in a sheet
|
|
41
42
|
import * as BVD from './built-vs-design.js'; // the built screen beside its design, its circles, Accept and Send back (built-vs-design, A380)
|
|
42
43
|
import * as STMAP from './story-map.js'; // a new bet's story map with the Release 1 line (initiative story-map, A419)
|
|
43
44
|
import * as TLY from './three-layouts.js'; // three layouts for a new screen, pick one (initiative three-layouts, A317)
|
|
@@ -1762,12 +1763,24 @@ async function addArt(x, h) {
|
|
|
1762
1763
|
* every part of the old page, as a drill-in, and every suggestion. body: the popup body the host drew into (it carries the wired handlers). */
|
|
1763
1764
|
export function moreItems(x, h, body) {
|
|
1764
1765
|
// under the popup cap (PopupCapDS) Plan, View and Jira come first; View holds Every part
|
|
1765
|
-
const cap = capItems(body, h), out = cap.concat(artItems(body));
|
|
1766
|
+
const cap = capItems(body, h), out = cap.concat(artItems(body), costItems(body));
|
|
1766
1767
|
if (h.allParts && !cap.some((it) => it.label === 'Every part')) out.push({ label: 'Every part', on: () => h.allParts() });
|
|
1767
1768
|
if (h.props) out.push({ label: 'Everything PMOS suggests', on: () => h.props() });
|
|
1768
1769
|
return out.length ? out.concat({ sep: true }) : out;
|
|
1769
1770
|
}
|
|
1770
1771
|
|
|
1772
|
+
/** ⋯ › Cost (initiative-cost, A17): what the factory spent on this initiative, one row per merged pull request. Only when a factory ran on it
|
|
1773
|
+
* (zero is silence); the read is Work's (pm/initiative-cost.js load), so the first ⋯ may come before it and the next one has it. Money
|
|
1774
|
+
* shows in the sheet only, never on the popup itself. */
|
|
1775
|
+
function costItems(body) {
|
|
1776
|
+
if (RO || !body || !body.__pwx || !body.querySelector || !body.querySelector('.pw.pwd')) return [];
|
|
1777
|
+
const r = body.__pwx.r(); if (!r || !r.id) return [];
|
|
1778
|
+
IC.load();
|
|
1779
|
+
const row = IC.rowOf(r.ws || '', r.id);
|
|
1780
|
+
if (!row) return [];
|
|
1781
|
+
return [{ label: 'Cost', on: () => import('./primitives.js').then((P) => { const el = document.createElement('div'); el.innerHTML = IC.iniHtml(row); P.sheet({ title: 'Cost', sub: r.title || r.id, body: [el], attrs: { 'data-ic-sheet': r.id } }); }) }];
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1771
1784
|
/** The Artefacts section of ⋯ (artefacts-in-more-menu): read when ⋯ opens, so an artefact just added is there. The presses are the ones the
|
|
1772
1785
|
* side card had: open full screen with Back, add, and the ✦ merge goes to the chat. */
|
|
1773
1786
|
function artItems(body) {
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* pm/initiative-cost.js — Work › Cost and the initiative's ⋯ › Cost (initiative initiative-cost, job #1906, idea A17; board BatchReleaseDS
|
|
2
|
+
* panel 21 on the main canvas, agreed 2026-11-25). What the factory spent per initiative and per merged pull request, from
|
|
3
|
+
* GET /api/initiative-cost (lib/initiative-cost.js, the same store as `pmos cost`).
|
|
4
|
+
* Pure parts first, so Node imports them (initiative-cost.test.js); the page parts touch the DOM only when called.
|
|
5
|
+
*
|
|
6
|
+
* hasSpend(products) → true when some factory spent: Work shows the Cost tab only then (zero is silence)
|
|
7
|
+
* rowsOf(products) → [row] every product's rows, each with its ws and product name, most spend first
|
|
8
|
+
* tabHtml(products, { undone }) → the Cost tab: the table (Initiative, Agent hours, Spend, Result) and one ✦ line per stalled initiative
|
|
9
|
+
* with icon-only Pause and Keep going; a paused one has a Resume button
|
|
10
|
+
* iniHtml(row) → the ⋯ › Cost sheet: one row per merged pull request, with its own cost
|
|
11
|
+
* money(n) · hoursText(h) · resultText(row)
|
|
12
|
+
* load({ force }) → Promise<products> · rowOf(ws, ini) → row | null the page's one read, kept a minute
|
|
13
|
+
* press(e, { post, say, redraw }) → true when the press was a Cost button
|
|
14
|
+
*
|
|
15
|
+
* Money shows here only (Totals only on the Cost tab; no money on other pages). The words say PMOS. Every button is an icon with its
|
|
16
|
+
* aria-label. Text from records goes through esc(). */
|
|
17
|
+
import { pmGet } from './http.js';
|
|
18
|
+
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
19
|
+
const SV = (d, cls = '') => `<svg class="pm-ic${cls ? ' ' + cls : ''}" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="${d}"/></svg>`;
|
|
20
|
+
const IC = {
|
|
21
|
+
star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z',
|
|
22
|
+
pause: 'M8 5v14M16 5v14',
|
|
23
|
+
keep: 'M6 6l12 12M18 6L6 18',
|
|
24
|
+
play: 'M7 5l12 7-12 7z',
|
|
25
|
+
link: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
|
|
26
|
+
};
|
|
27
|
+
const STALL_DAYS = 7;
|
|
28
|
+
|
|
29
|
+
export function money(n) { const v = Number(n) || 0; return '$' + (v >= 100 ? Math.round(v) : v >= 10 ? Math.round(v) : v.toFixed(2)); }
|
|
30
|
+
export function hoursText(h) { const v = Number(h) || 0; return v > 0 ? (v >= 10 ? Math.round(v) : v) + ' h' : '—'; }
|
|
31
|
+
export function resultText(r) {
|
|
32
|
+
if (r.stall) return `0 merged in ${STALL_DAYS} days`;
|
|
33
|
+
if (r.merged) return r.merged + (r.merged === 1 ? ' PR merged' : ' PRs merged');
|
|
34
|
+
return 'Nothing merged yet';
|
|
35
|
+
}
|
|
36
|
+
export function rowsOf(products) {
|
|
37
|
+
const out = [];
|
|
38
|
+
for (const p of Array.isArray(products) ? products : []) for (const r of (p && p.rows) || []) out.push({ ...r, ws: p.ws || '', product: p.name || p.ws || '' });
|
|
39
|
+
return out.sort((a, b) => b.costUsd - a.costUsd || a.ini.localeCompare(b.ini));
|
|
40
|
+
}
|
|
41
|
+
export const hasSpend = (products) => rowsOf(products).some((r) => r.runs > 0);
|
|
42
|
+
|
|
43
|
+
const btn = (attrs, label, d) => `<button type="button" class="pm-btn" ${attrs} aria-label="${esc(label)}" title="${esc(label)}">${SV(d)}</button>`;
|
|
44
|
+
const keyOf = (r) => esc((r.ws || '') + '|' + r.ini);
|
|
45
|
+
const dataOf = (r) => `data-ic-ws="${esc(r.ws || '')}" data-ic-ini="${esc(r.ini)}"`;
|
|
46
|
+
|
|
47
|
+
/** The Cost tab. o.undone: keys (ws|ini) the PM answered on this page, so their ✦ line goes at once. */
|
|
48
|
+
export function tabHtml(products, o = {}) {
|
|
49
|
+
const rows = rowsOf(products), many = new Set(rows.map((r) => r.ws)).size > 1, gone = o.undone || new Set();
|
|
50
|
+
if (!rows.length) return '<section class="pm-block ic-cost" aria-label="Cost"><p class="pm-meta">No factory has run on an initiative here yet.</p></section>';
|
|
51
|
+
const th = (t) => `<th scope="col">${esc(t)}</th>`;
|
|
52
|
+
const body = rows.map((r) => {
|
|
53
|
+
const res = r.paused ? `<span class="pm-badge">Paused</span>` : r.stall ? `<span class="ic-alert">${esc(resultText(r))}</span>` : esc(resultText(r));
|
|
54
|
+
const name = `<button type="button" class="pw-lk" data-ic-open ${dataOf(r)}>${esc(r.ini)}</button>${many ? ` <span class="pm-meta">${esc(r.product)}</span>` : ''}`;
|
|
55
|
+
const resume = r.paused ? ' ' + btn(`data-ic-resume ${dataOf(r)}`, `Resume ${r.ini}'s jobs`, IC.play) : '';
|
|
56
|
+
return `<tr data-ic-row="${keyOf(r)}"><td>${name}</td><td>${esc(hoursText(r.hours))}</td><td>${esc(money(r.costUsd))}</td><td>${res}${resume}</td></tr>`;
|
|
57
|
+
}).join('');
|
|
58
|
+
const table = `<table class="pm-table ic-table"><thead><tr>${th('Initiative')}${th('Agent hours')}${th('Spend')}${th('Result')}</tr></thead><tbody>${body}</tbody></table>`;
|
|
59
|
+
const asks = rows.filter((r) => r.stall && !r.paused && !gone.has((r.ws || '') + '|' + r.ini)).map((r) => `<div class="ic-ask" data-ic-ask="${keyOf(r)}"><p class="pm-said">${SV(IC.star, 'pm-star')}<span>${esc(r.ini)} has spent ${esc(money(r.sinceUsd || r.recentUsd))} with no merge in ${STALL_DAYS} days. Pause its jobs?</span></p>`
|
|
60
|
+
+ `<div class="pm-row">${btn(`data-ic-pause ${dataOf(r)}`, `Pause ${r.ini}'s new jobs`, IC.pause)}${btn(`data-ic-keep ${dataOf(r)}`, 'Keep going', IC.keep)}</div></div>`).join('');
|
|
61
|
+
const total = rows.reduce((s, r) => s + (Number(r.costUsd) || 0), 0);
|
|
62
|
+
return `<section class="pm-block ic-cost" aria-label="Cost"><div class="pm-row ic-head"><h2 class="pm-h-sm">Cost</h2><span class="pm-meta">${esc(money(total))} in all</span></div>${table}${asks}</section>`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The initiative's ⋯ › Cost sheet: one row per merged pull request. */
|
|
66
|
+
export function iniHtml(r) {
|
|
67
|
+
if (!r) return '<p class="pm-meta">No factory has run on this initiative yet.</p>';
|
|
68
|
+
const th = (t) => `<th scope="col">${esc(t)}</th>`;
|
|
69
|
+
const head = `<p class="pm-meta">${esc(hoursText(r.hours))} · ${esc(money(r.costUsd))} · ${esc(String(r.tokens || 0))} tokens · ${esc(resultText(r))}${r.paused ? ' · Paused' : ''}</p>`;
|
|
70
|
+
if (!r.prs || !r.prs.length) return head + '<p class="pm-meta">No pull request merged yet.</p>';
|
|
71
|
+
const body = r.prs.map((p) => `<tr><td>${esc(p.title || p.item)}${p.url ? ' ' + `<a class="pm-btn" href="${esc(p.url)}" target="_blank" rel="noopener" aria-label="Open the pull request" title="Open the pull request">${SV(IC.link)}</a>` : ''}</td><td>${esc(hoursText(p.hours))}</td><td>${esc(money(p.costUsd))}</td><td>${esc(String(p.tokens || 0))}</td></tr>`).join('');
|
|
72
|
+
return head + `<table class="pm-table ic-table"><thead><tr>${th('Pull request')}${th('Agent hours')}${th('Spend')}${th('Tokens')}</tr></thead><tbody>${body}</tbody></table>`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* ── the page: one read, kept a minute ── */
|
|
76
|
+
const S = { got: null, at: 0, inflight: null };
|
|
77
|
+
export function load({ force = false } = {}) {
|
|
78
|
+
if (!force && S.got && Date.now() - S.at < 60000) return Promise.resolve(S.got);
|
|
79
|
+
if (S.inflight) return S.inflight;
|
|
80
|
+
S.inflight = pmGet('/api/initiative-cost').catch(() => null)
|
|
81
|
+
.then((j) => { S.got = j && j.ok ? j.products || [] : (S.got || []); S.at = Date.now(); S.inflight = null; return S.got; });
|
|
82
|
+
return S.inflight;
|
|
83
|
+
}
|
|
84
|
+
export const cached = () => S.got;
|
|
85
|
+
export function rowOf(ws, ini) { return rowsOf(S.got || []).find((r) => r.ini === ini && (!ws || !r.ws || r.ws === ws)) || null; }
|
|
86
|
+
|
|
87
|
+
/** A press on the Cost tab. post(path, body) → Promise<{ ok }>; say(msg, undo?) the page's toast; redraw() after a change. */
|
|
88
|
+
export function press(e, { post, say, redraw, open, undone } = {}) {
|
|
89
|
+
const b = e.target.closest('[data-ic-pause],[data-ic-keep],[data-ic-resume],[data-ic-open]');
|
|
90
|
+
if (!b || b.disabled) return false;
|
|
91
|
+
const d = b.dataset, body = { ws: d.icWs || undefined, ini: d.icIni };
|
|
92
|
+
if ('icOpen' in d) { if (open) open(d.icIni, d.icWs); return true; }
|
|
93
|
+
const act = 'icPause' in d ? 'pause' : 'icKeep' in d ? 'keep' : 'resume';
|
|
94
|
+
b.disabled = true;
|
|
95
|
+
post('/api/initiative-cost/' + act, body).then((r) => {
|
|
96
|
+
if (!r || !r.ok) { b.disabled = false; if (say) say((r && r.error) || 'That did not save. Try again in a moment.'); return; }
|
|
97
|
+
if (undone && act !== 'resume') undone.add((d.icWs || '') + '|' + d.icIni);
|
|
98
|
+
const again = () => post('/api/initiative-cost/resume', body).then(() => load({ force: true }).then(() => redraw && redraw()));
|
|
99
|
+
if (say) say(act === 'pause' ? `Paused ${d.icIni}'s new jobs. Running work finishes.` : act === 'keep' ? `${d.icIni} keeps going.` : `${d.icIni}'s jobs run again.`, act === 'pause' ? again : undefined);
|
|
100
|
+
return load({ force: true }).then(() => redraw && redraw());
|
|
101
|
+
});
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
@@ -32,6 +32,7 @@ import { gapsOf } from './cozy-bar.js';
|
|
|
32
32
|
import { withTime } from './day-time.js'; // a task's optional time on its start and due (task-time-optional)
|
|
33
33
|
import { provenStatus, NO_SIGNAL } from './status-proof.js';
|
|
34
34
|
import * as WT from './work-tree.js'; // subtasks: nesting and the roll-up (initiative work-subtasks)
|
|
35
|
+
import { testsOf, offerOf as copyTestOfferOf } from './copy-tests.js'; // the initiative's copy tests, on the Experiment (initiative copy-tests, A351)
|
|
35
36
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
36
37
|
const DAY = 864e5;
|
|
37
38
|
const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
@@ -576,7 +577,7 @@ export function workOf(r, v, o = {}) {
|
|
|
576
577
|
const dates = [r.start, r.end].concat(bd.rows.flatMap((x) => [x.start, x.end])).filter(Boolean);
|
|
577
578
|
const tk = trackOf(dates, o.mode || 'full', t), span = tk.span;
|
|
578
579
|
return { view: tk.view, zoom: tk.zoom, at: tk.at, title: v.title || r.title || '', summary: sum, overview: overviewOf(r, v, o), suggests: all.slice(0, MAX_SUGGEST), more: sug.more + Math.max(0, all.length - MAX_SUGGEST), rowSuggests: rowS, facts: factsOf(r, v, o),
|
|
579
|
-
rows: bd.rows, many: bd.many, looseN: bd.looseN || 0, span, today: iso(t), artefacts: arts };
|
|
580
|
+
rows: bd.rows, many: bd.many, looseN: bd.looseN || 0, span, today: iso(t), artefacts: arts, copyTests: testsOf(o.art), copyTestOffer: copyTestOfferOf(o.art), ws: o.ws || '' };
|
|
580
581
|
}
|
|
581
582
|
|
|
582
583
|
/* ── one level up: a program or a product (boards 26, 27) ── */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Copy and layout tests (initiative copy-tests, job #1905, idea A351, done test planning/done-tests/copy-tests.md T1-T5, N1-N3): the plain-words draft, how sure, keep and undo, the route's copyTests and press, the popup block, the verb. No server, network, model or browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"copy-tests.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"copy-tests.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "What to bring on each meeting (tb-events-bring, board TbEvents): the bring rule in lib/events-place.js and its line in the pure markup public/pm/cozy-events-view.js. No browser, no network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"events-bring.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"events-bring.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "What each initiative and merged pull request cost (initiative initiative-cost, done test C1-C7, N1-N3): the pure fold, the stall ✦, the pause in build-engine next and claim, pmos cost, the route in process and the Cost tab's HTML, on a scratch product with the vendored work-item ledger. No server, browser, model or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"initiative-cost.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"initiative-cost.test.js": 2
|
|
8
|
+
}
|
|
9
|
+
}
|