create-pmos 0.261.0 → 0.263.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 +1 -1
- 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-insights-test.js +76 -7
- package/workspace/briefing-premium-test.js +17 -0
- package/workspace/fixtures/insights-premium-facts.js +19 -3
- package/workspace/guide/briefing-premium.md +10 -4
- package/workspace/lib/insights-premium.js +56 -3
- package/workspace/lib/premium-dashboards.js +127 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-insights-premium.js +14 -2
- package/workspace/lib/routes-premium-dashboards.js +62 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/premium-insights.css +23 -0
- package/workspace/public/pm/premium-insights.js +207 -11
- package/workspace/public/pm/premium-shell.js +51 -1
- package/workspace/public/pm/premium.css +7 -0
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-initiative.html +1 -0
- package/workspace/public/premium-insights.html +3 -1
- package/workspace/public/premium-work.html +1 -0
- package/workspace/public/premium.html +1 -0
- package/workspace/server.js +2 -0
- package/workspace/test-files.json +2 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-premium-dashboards.js — the dashboards the PM makes on the premium Insights page (initiative briefing-premium-reports, PRD D2).
|
|
3
|
+
*
|
|
4
|
+
* POST /api/premium-dashboards/save { ws, board, id?, name, purpose, charts, main, remove? } → { ok, dashboard, dashboards }
|
|
5
|
+
* one `save` or `remove` line in <state>/premium-dashboards.jsonl (lib/premium-dashboards.js, the one writer)
|
|
6
|
+
*
|
|
7
|
+
* The page reads the dashboards through GET /api/insights-premium, so this module has no GET.
|
|
8
|
+
*
|
|
9
|
+
* WHO WRITES. The POST refuses a request that carries an agent session header (403), as routes-custom-docs.js does, and passes pm-guard
|
|
10
|
+
* requirePagePress: the launch nonce and the page's origin. The board must be one of the workspace's boards (routes-boards.js frameFor), and every chart
|
|
11
|
+
* must be a KR metric record of that workspace (its `rid`, the id the Insights model gives a chart). The route stores what the PM chose and nothing else: no chart, report or console layout changes. */
|
|
12
|
+
const guard = require('./pm-guard.js');
|
|
13
|
+
const PD = require('./premium-dashboards.js');
|
|
14
|
+
const boards = require('./routes-boards.js');
|
|
15
|
+
const { repoScript } = require('./repo-script.js');
|
|
16
|
+
const { recordsDirFor } = require('./records-dir.js');
|
|
17
|
+
|
|
18
|
+
const text = (v) => (typeof v === 'string' ? v : '');
|
|
19
|
+
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
20
|
+
|
|
21
|
+
function wsOf(ctx, id) {
|
|
22
|
+
const w = ctx.getWs(id || null);
|
|
23
|
+
return w && (!id || w.id === id) ? w : null;
|
|
24
|
+
}
|
|
25
|
+
/** The board ids of a workspace (lib/routes-boards.js frameFor). null when they cannot be read. */
|
|
26
|
+
function boardIds(ctx, w) {
|
|
27
|
+
try { return new Set(boards.frameFor(ctx, w).boards.map((b) => b.id)); } catch { return null; }
|
|
28
|
+
}
|
|
29
|
+
/** The KR metric ids of a workspace. null when the records cannot be read. */
|
|
30
|
+
function krIds(ctx, ws) {
|
|
31
|
+
try { return new Set(require(repoScript('records/index.js')).list(recordsDirFor(ctx, ws), 'kr-metrics').map((k) => k.rid).filter(Boolean)); } catch { return null; }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function handle(req, res, url, ctx) {
|
|
35
|
+
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
36
|
+
if (url.pathname !== '/api/premium-dashboards/save') return send(bad(404, 'no such premium-dashboards route'));
|
|
37
|
+
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
38
|
+
const read = await ctx.readJson(req);
|
|
39
|
+
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
40
|
+
const body = read.body || {};
|
|
41
|
+
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a dashboard. Only a press on the page does'));
|
|
42
|
+
const g = guard.requirePagePress(req, body);
|
|
43
|
+
if (!g.ok) return send(bad(g.status, g.error));
|
|
44
|
+
const w = wsOf(ctx, text(body.ws));
|
|
45
|
+
if (!w) return send(bad(404, 'no such workspace'));
|
|
46
|
+
const c = PD.check(body);
|
|
47
|
+
if (!c.ok) return send(bad(c.status, c.error));
|
|
48
|
+
const ids = boardIds(ctx, w);
|
|
49
|
+
if (!ids) return send(bad(503, 'The boards could not be read. Try again in a moment.'));
|
|
50
|
+
if (!ids.has(c.value.board)) return send(bad(404, 'no such board in this workspace'));
|
|
51
|
+
let known = null;
|
|
52
|
+
if (!c.value.remove) {
|
|
53
|
+
const ks = krIds(ctx, w.id);
|
|
54
|
+
if (!ks) return send(bad(503, 'The KR metric records could not be read, so the charts cannot be checked.'));
|
|
55
|
+
known = { charts: ks };
|
|
56
|
+
}
|
|
57
|
+
const r = PD.save(w.root, body, g.actor, { now: Date.now(), known });
|
|
58
|
+
if (!r.ok) return send(bad(r.status, r.error));
|
|
59
|
+
return send({ status: 200, body: { ok: true, dashboard: r.dashboard, dashboards: r.dashboards } });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { prefixes: ['/api/premium-dashboards'], handle };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.263.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.263.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -141,3 +141,26 @@ button.nfr:hover,button.nfr:focus-visible{background:color-mix(in oklab,var(--in
|
|
|
141
141
|
.ndm small{color:var(--ink-3)}
|
|
142
142
|
.ntf .lk,.nsch .lk{min-height:44px;display:inline-flex;align-items:center}
|
|
143
143
|
.ntf{min-height:44px}
|
|
144
|
+
/* briefing-premium-reports: a saved dashboard's bar and edit dialog, the report Ask box and the report dialogs */
|
|
145
|
+
.pdbar{margin:12px 0 4px}
|
|
146
|
+
.pdbar .pdp{flex:1 1 240px;margin:0;color:var(--ink-2)}
|
|
147
|
+
.pdbar .dmcta,.nask .dmcta{min-height:44px}
|
|
148
|
+
.pdck:empty{display:none}
|
|
149
|
+
.pdck{margin:10px 0 0;color:var(--ember)}
|
|
150
|
+
.pdlist{display:grid;gap:6px}
|
|
151
|
+
.pdrow{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 8px 8px 14px;border-radius:14px;background:var(--well)}
|
|
152
|
+
.pdrow>span:first-child{min-width:0;display:grid;gap:2px}
|
|
153
|
+
.pdrow b{font-size:15px;font-weight:600;overflow-wrap:anywhere}
|
|
154
|
+
.pdrow small{color:var(--ink-3);font-size:12.5px}
|
|
155
|
+
.pdmv{display:flex;gap:4px;flex:none}
|
|
156
|
+
.pdmv .round{width:44px;height:44px;color:var(--ink-2)}
|
|
157
|
+
.pdmv .round:disabled{opacity:.35}
|
|
158
|
+
.addf label.pdchk{display:flex;align-items:center;gap:10px;min-height:44px;font-size:15px;font-weight:550;color:var(--ink)}
|
|
159
|
+
.addf .pdchk input{width:22px;height:22px;flex:none;accent-color:var(--ember)}
|
|
160
|
+
.nask{display:flex;gap:8px;margin:4px 0 0}
|
|
161
|
+
.nask input{flex:1;min-width:0;height:44px;border-radius:14px;border:1px solid var(--hair);background:var(--card-solid);padding:0 12px;font:inherit;font-size:15px;color:var(--ink)}
|
|
162
|
+
.nask input:focus-visible{outline:2px solid var(--ember);outline-offset:1px}
|
|
163
|
+
.nask-n{margin:6px 0 0 4px;font-size:12.5px}
|
|
164
|
+
.pdev{margin:0 0 12px;padding-left:18px;display:grid;gap:4px}
|
|
165
|
+
.pdev small{color:var(--ink-3)}
|
|
166
|
+
.dplist button[role="switch"]{min-height:44px;width:100%}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/* pm/premium-insights.js — the premium Insights page (initiative briefing-premium-insights, slice 9). Reads GET /api/insights-premium and draws the model
|
|
2
2
|
* lib/insights-premium.js builds from the KR metric records and the report files the console's Reports tab reads: the Dashboards card (charts with a target
|
|
3
|
-
* line, what stands out), the Reports card, the dock and the standard dialog.
|
|
4
|
-
|
|
3
|
+
* line, what stands out), the Reports card, the dock and the standard dialog.
|
|
4
|
+
* briefing-premium-reports adds the PM's presses, each through pmPost and so behind the launch nonce: a saved dashboard (POST /api/premium-dashboards/save,
|
|
5
|
+
* PRD D2 to D6) and the report presses of the console's Reports workspace (POST /api/report-setups/ask | change | cancel | setup | dismiss | pause | resume |
|
|
6
|
+
* draft, PRD R2 to R4). Nothing else posts, and nothing is sent outward. */
|
|
7
|
+
import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb, kv } from './premium-shell.js';
|
|
8
|
+
import { pmPost } from './http.js';
|
|
5
9
|
|
|
6
10
|
let M = null; // the model
|
|
7
11
|
let dash = 'all'; // the dashboard on screen
|
|
@@ -9,7 +13,9 @@ wireRail('rep');
|
|
|
9
13
|
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
10
14
|
const DOCI = '<path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 13h6M9 17h4"/>';
|
|
11
15
|
const CHV2 = '<svg class="i" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></svg>';
|
|
16
|
+
const AIC = '<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"/>';
|
|
12
17
|
const byKey = (k) => (M && M.charts || []).find((c) => c.key === k) || null;
|
|
18
|
+
const savedDash = () => (M.dashboards || []).filter((d) => d.saved);
|
|
13
19
|
|
|
14
20
|
/* ── header ───────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
15
21
|
let crumbed = false;
|
|
@@ -63,7 +69,9 @@ function drawDash() {
|
|
|
63
69
|
const D = curDash(), L = D.keys.map(byKey).filter(Boolean);
|
|
64
70
|
$('#dashCap').textContent = M.counts.total ? M.counts.charts + ' drawn · ' + M.counts.noSeries + ' without a series' : '';
|
|
65
71
|
const tabs = $('#dashTabs'); tabs.hidden = M.dashboards.length < 2;
|
|
66
|
-
if (!tabs.hidden) { tabs.innerHTML = '<i class="pill"></i>' + M.dashboards.map((d) => `<button data-d="${esc(d.id)}" aria-pressed="${d.id === D.id}">${esc(d.name)}</button>`).join(''); pillOf(tabs); }
|
|
72
|
+
if (!tabs.hidden) { tabs.innerHTML = '<i class="pill"></i>' + M.dashboards.map((d) => `<button data-d="${esc(d.id)}" aria-pressed="${d.id === D.id}"${d.main ? ' title="The main dashboard"' : ''}>${esc(d.name)}${d.main ? ' · Main' : ''}</button>`).join(''); pillOf(tabs); }
|
|
73
|
+
drawDashBar(D);
|
|
74
|
+
if (D.saved) { drawSaved(D, L); return; }
|
|
67
75
|
if (!M.charts.length) {
|
|
68
76
|
$('#dashBody').innerHTML = `<div class="nempty" style="margin-top:14px"><p><b>${esc(M.counts.total ? 'No KR metric holds two readings yet.' : 'No KR metric is recorded for this workspace.')}</b> ${esc(M.counts.total ? 'A chart needs a series, so nothing is drawn.' : 'There is nothing to chart. Add one where the KR metrics are kept.')}</p></div>` + noSeriesHtml();
|
|
69
77
|
return;
|
|
@@ -74,11 +82,75 @@ function drawDash() {
|
|
|
74
82
|
+ `<p class="mhint" style="margin-top:6px"><b>${tot - off} of ${tot}</b> on their line${off ? `. <b class="mflag">${off} ${off === 1 ? 'is' : 'are'} behind it.</b>` : '.'} Each chart is one KR metric, drawn at the dates of its readings. A gap between readings is left as a gap. The dashed line is the target.</p>`
|
|
75
83
|
+ `<div class="ngrid">${L.map((c) => `<div class="ntw">${tileHtml(c)}<div class="ntf"><button class="lk" data-open="${esc(c.key)}">Details</button></div></div>`).join('')}</div>` + noSeriesHtml();
|
|
76
84
|
}
|
|
85
|
+
/* The bar under the switch: a saved dashboard's purpose and Edit, and New dashboard (PRD D3/D4). Hidden when the page has no board to save on. */
|
|
86
|
+
function drawDashBar(D) {
|
|
87
|
+
const bar = $('#dashBar'); bar.hidden = !M.board.id;
|
|
88
|
+
if (bar.hidden) return;
|
|
89
|
+
bar.innerHTML = (D.saved ? `<p class="note pdp">${D.main ? '<b>Main dashboard.</b> ' : ''}${esc(D.purpose)}</p><button class="dmcta alt" id="pdEdit" aria-haspopup="dialog">Edit</button>` : '')
|
|
90
|
+
+ '<button class="dmcta alt" id="pdNew" aria-haspopup="dialog">New dashboard</button>';
|
|
91
|
+
}
|
|
92
|
+
function drawSaved(D, L) {
|
|
93
|
+
const off = D.off, tot = L.length;
|
|
94
|
+
const gone = D.gone.length ? `<p class="label ngl">Not drawn · ${D.gone.length}</p><div class="dplist" role="list">${D.gone.map((g) => `<div class="nempty" role="listitem" style="margin-bottom:6px"><p><b>${esc(g.title)}</b><br>${esc(g.why)}</p></div>`).join('')}</div>` : '';
|
|
95
|
+
const checks = D.checks.length ? `<p class="note pdck">${D.checks.map(esc).join(' ')}</p>` : '';
|
|
96
|
+
$('#dashBody').innerHTML = (tot ? `<div class="mprog" role="progressbar" aria-label="Measures on their line" aria-valuemin="0" aria-valuemax="${tot}" aria-valuenow="${tot - off}"><b style="width:${(tot - off) / tot * 100}%"></b></div>`
|
|
97
|
+
+ `<p class="mhint" style="margin-top:6px"><b>${tot - off} of ${tot}</b> on their line${off ? `. <b class="mflag">${off} ${off === 1 ? 'is' : 'are'} behind it.</b>` : '.'} The charts are drawn in the order you saved. The dashed line is the target.</p>`
|
|
98
|
+
+ `<div class="ngrid">${L.map((c) => `<div class="ntw">${tileHtml(c)}<div class="ntf"><button class="lk" data-open="${esc(c.key)}">Details</button></div></div>`).join('')}</div>`
|
|
99
|
+
: `<div class="nempty" style="margin-top:14px"><p><b>This dashboard draws no chart yet.</b> Press Edit to add a measure with a series.</p></div>`) + checks + gone;
|
|
100
|
+
}
|
|
77
101
|
function noSeriesHtml() {
|
|
78
102
|
const N = M.noSeries; if (!N.length) return '';
|
|
79
103
|
return `<p class="label ngl">No series recorded · ${N.length}</p><div class="dplist" role="list">${N.map((n) => `<div class="nempty" role="listitem" style="margin-bottom:6px"><p><b>${esc(n.title)}</b>${n.pillar ? ' · ' + esc(n.pillar) : ''}<br>${esc(n.why)} It is not drawn.</p></div>`).join('')}</div>`;
|
|
80
104
|
}
|
|
81
105
|
$('#dashTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-d]'); if (!b) return; dash = b.dataset.d; drawDash(); });
|
|
106
|
+
$('#dashBar').addEventListener('click', (e) => { if (e.target.closest('#pdEdit')) openDashEdit(curDash()); else if (e.target.closest('#pdNew')) openDashEdit(null); });
|
|
107
|
+
|
|
108
|
+
/* ── a saved dashboard: the edit dialog (PRD D4/D5). The one press posts POST /api/premium-dashboards/save. ─────────────────────────────── */
|
|
109
|
+
async function saveDash(body) { return pmPost('/api/premium-dashboards/save', Object.assign({ ws: M.board.ws, board: M.board.id }, body)); }
|
|
110
|
+
function openDashEdit(D) {
|
|
111
|
+
const fresh = !D, ids = D ? D.charts.slice() : [];
|
|
112
|
+
const title = (id) => { const m = (M.measures || []).find((x) => x.id === id); return m ? m.title : id; };
|
|
113
|
+
const why = (id) => { const m = (M.measures || []).find((x) => x.id === id); return !m ? 'No record any more' : m.charted ? '' : 'No series yet'; };
|
|
114
|
+
const listHtml = () => ids.length ? ids.map((id, i) => `<div class="pdrow" role="listitem"><span><b>${esc(title(id))}</b>${why(id) ? `<small>${esc(why(id))}</small>` : ''}</span><span class="pdmv"><button type="button" class="round" data-mv="${i}:-1" aria-label="Move ${esc(title(id))} up" ${i ? '' : 'disabled'}>${ICO('<path d="M12 19V5M6 11l6-6 6 6"/>')}</button><button type="button" class="round" data-mv="${i}:1" aria-label="Move ${esc(title(id))} down" ${i < ids.length - 1 ? '' : 'disabled'}>${ICO('<path d="M12 5v14M6 13l6 6 6-6"/>')}</button><button type="button" class="round" data-rm="${i}" aria-label="Take ${esc(title(id))} off">${ICO('<path d="M6 6l12 12M18 6 6 18"/>')}</button></span></div>`).join('') : '<p class="note" style="margin:0">No measure yet. Add one below.</p>';
|
|
115
|
+
const addHtml = () => { const L = (M.measures || []).filter((m) => !ids.includes(m.id)); return L.length ? `<label>Add a measure<select id="pdAdd"><option value="">Choose a KR metric</option>${L.map((m) => `<option value="${esc(m.id)}">${esc(m.title)}${m.charted ? '' : ' (no series yet)'}</option>`).join('')}</select></label>` : '<p class="note" style="margin:0">Every KR metric of this workspace is on this dashboard.</p>'; };
|
|
116
|
+
const checksTxt = () => [ids.length > 6 ? 'This dashboard holds ' + ids.length + ' charts. A dashboard that serves one routine usually holds six or fewer.' : '', new Set(ids).size !== ids.length ? 'The same measure is on this dashboard twice.' : ''].filter(Boolean).join(' ');
|
|
117
|
+
const form = `<div class="addf"><p class="note" style="margin:0">A dashboard is a named list of this board's measures. It is saved in the workspace's state folder and changes nothing else: no record, no report and no console layout.</p>
|
|
118
|
+
<label>Name<input id="pdN" maxlength="60" value="${esc(D ? D.name : '')}" placeholder="For example: Weekly partner review"></label>
|
|
119
|
+
<label>What it is for<input id="pdP" maxlength="200" value="${esc(D ? D.purpose : '')}" placeholder="The routine it serves, in one line"></label>
|
|
120
|
+
<label class="pdchk"><input type="checkbox" id="pdMain" ${D && D.main ? 'checked' : ''}>Make it the main dashboard of this board</label>
|
|
121
|
+
<div><span class="label">Charts, in order</span><div class="pdlist" id="pdList" role="list">${listHtml()}</div></div>
|
|
122
|
+
<div id="pdAddW">${addHtml()}</div>
|
|
123
|
+
<p class="note pdck" id="pdCk" role="status">${esc(checksTxt())}</p>
|
|
124
|
+
<p class="note" id="pdM" role="status" style="margin:0;min-height:1.2em"></p>
|
|
125
|
+
<div class="cact"><button class="cta" id="pdGo">Save</button><button class="cta alt" id="pdNo">Cancel</button>${fresh ? '' : '<button class="cta alt" id="pdDel">Remove the dashboard</button>'}</div></div>`;
|
|
126
|
+
openDlg({ eye: (fresh ? 'New dashboard' : 'Dashboard') + ' · real data', title: fresh ? 'New dashboard' : D.name, sub: M.board.name, say: 'Name the dashboard, say what it is for and choose its measures.', stream: turnA(ptx('Name the dashboard, say what it is for and choose its measures in the order you read them. I save it in the workspace\'s state folder and change nothing else.')), noteKey: null, pane: `<article class="paper doc">${form}</article>`, label: 'Dashboard' });
|
|
127
|
+
$('#askF').hidden = true;
|
|
128
|
+
const redraw = () => { $('#pdList').innerHTML = listHtml(); $('#pdAddW').innerHTML = addHtml(); $('#pdCk').textContent = checksTxt(); };
|
|
129
|
+
let armed = false;
|
|
130
|
+
$('#oMain').onchange = (e) => { if (e.target.id === 'pdAdd' && e.target.value) { ids.push(e.target.value); redraw(); const s = $('#pdAdd'); if (s) s.focus(); } };
|
|
131
|
+
$('#oMain').onclick = async (e) => {
|
|
132
|
+
const mv = e.target.closest('[data-mv]'), rm = e.target.closest('[data-rm]');
|
|
133
|
+
if (mv) { const [i, d] = mv.dataset.mv.split(':').map(Number), j = i + d; [ids[i], ids[j]] = [ids[j], ids[i]]; redraw(); const b = $(`#pdList [data-mv="${j}:${d}"]`) || $(`#pdList [data-mv="${j}:${-d}"]`); if (b) b.focus(); return; }
|
|
134
|
+
if (rm) { ids.splice(+rm.dataset.rm, 1); redraw(); return; }
|
|
135
|
+
if (e.target.closest('#pdNo')) { closeDlg(); return; }
|
|
136
|
+
const m = $('#pdM');
|
|
137
|
+
if (e.target.closest('#pdDel')) {
|
|
138
|
+
if (!armed) { armed = true; e.target.closest('#pdDel').textContent = 'Press again to remove it'; m.textContent = 'Removing takes the dashboard off this board. The measures and their records stay.'; return; }
|
|
139
|
+
const b = e.target.closest('#pdDel'); b.disabled = true;
|
|
140
|
+
const res = await saveDash({ id: D.id, remove: true });
|
|
141
|
+
if (!res || res.ok !== true) { b.disabled = false; m.textContent = (res && res.error) || 'The dashboard could not be removed.'; return; }
|
|
142
|
+
toast('Dashboard removed. The line is saved in the workspace\'s state folder.'); dash = 'all'; closeDlg(); await load(); return;
|
|
143
|
+
}
|
|
144
|
+
if (!e.target.closest('#pdGo')) return;
|
|
145
|
+
const name = $('#pdN').value.trim(), purpose = $('#pdP').value.trim();
|
|
146
|
+
if (!name) { m.textContent = 'Give the dashboard a name.'; $('#pdN').focus(); return; }
|
|
147
|
+
if (!purpose) { m.textContent = 'Say what the dashboard is for, in one line.'; $('#pdP').focus(); return; }
|
|
148
|
+
const go = $('#pdGo'); go.disabled = true; m.textContent = 'Saving.';
|
|
149
|
+
const res = await saveDash({ id: D ? D.id : undefined, name, purpose, charts: ids, main: $('#pdMain').checked });
|
|
150
|
+
if (!res || res.ok !== true) { go.disabled = false; m.textContent = (res && res.error) || 'The dashboard could not be saved.'; return; }
|
|
151
|
+
toast('Dashboard saved in the workspace\'s state folder.'); if (res.dashboard) dash = res.dashboard.id; closeDlg(); await load();
|
|
152
|
+
};
|
|
153
|
+
}
|
|
82
154
|
$('#dashBody').addEventListener('click', (e) => { const o = e.target.closest('[data-open]'); if (o) openChart(byKey(o.dataset.open)); });
|
|
83
155
|
$('#dashBody').addEventListener('keydown', (e) => {
|
|
84
156
|
const t = e.target.closest && e.target.closest('.mch'); if (!t || !/^Arrow(Left|Right)$/.test(e.key)) return;
|
|
@@ -93,33 +165,157 @@ $('#dashBody').addEventListener('pointermove', (e) => {
|
|
|
93
165
|
$('#dashBody').addEventListener('pointerleave', () => $$('#dashBody .mch.hv').forEach((x) => chartAt(x)));
|
|
94
166
|
|
|
95
167
|
/* ── reports ──────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
168
|
+
let askTimer = 0;
|
|
169
|
+
const dismissing = new Map(); // finding id → timer: "Not a report" waits 5 s for an Undo before it is sent
|
|
170
|
+
const ASKST = { running: ['Working', 'draft'], ready: ['Ready to review', 'issued'], failed: ['Failed', 'none'] };
|
|
96
171
|
function repRow(r) {
|
|
97
|
-
return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="1"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(r.cadence)} · ${esc(r.date || r.slot)}</b><small>${esc(r.path)}</small><span class="dmm"><span class="s ${esc(r.state === 'issued' ? 'issued' : 'draft')}">${esc(r.stateLabel)}</span></span></span></button></div>`;
|
|
172
|
+
return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="1" title="Opens in the console's Reports tab"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(r.cadence)} · ${esc(r.date || r.slot)}</b><small>${esc(r.path)}</small><span class="dmm"><span class="s ${esc(r.state === 'issued' ? 'issued' : 'draft')}">${esc(r.stateLabel)}</span><span>Opens in the console</span></span></span></button></div>`;
|
|
98
173
|
}
|
|
174
|
+
const foundRow = (f) => `<div class="dmr" role="listitem"><button class="dmo" data-found="${esc(f.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(AIC)}</span><span class="dmn"><b>${esc(f.name)}</b><small>${esc(f.why)}</small><span class="dmm">${f.confidence ? `<span>${esc(f.confidence)}</span>` : ''}<span>${f.evidence.length} ${f.evidence.length === 1 ? 'sign' : 'signs'} in your work</span></span></span></button></div>`;
|
|
175
|
+
const askRow = (a) => `<div class="dmr" role="listitem"><button class="dmo" data-ask="${esc(a.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(AIC)}</span><span class="dmn"><b>${esc(a.proposal && a.proposal.name ? a.proposal.name : a.text)}</b><small>You asked: ${esc(a.text)}</small><span class="dmm"><span class="s ${ASKST[a.state][1]}">${ASKST[a.state][0]}</span>${a.changed ? '<span>Changed once</span>' : ''}</span></span></button></div>`;
|
|
176
|
+
const setupRow = (s) => `<div class="dmr" role="listitem"><button class="dmo" data-setup="${esc(s.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(s.name)}</b><small>${esc([s.label, s.audience ? 'for ' + s.audience : ''].filter(Boolean).join(' · '))}</small><span class="dmm"><span class="s ${s.paused ? 'none' : 'issued'}">${s.paused ? 'Paused' : s.drafting ? 'Drafting' : 'Set up'}</span>${s.next && !s.paused ? `<span>Next draft ${esc(s.next)}</span>` : ''}</span></span></button></div>`;
|
|
99
177
|
function drawReps() {
|
|
100
|
-
const R = M.reports;
|
|
178
|
+
const R = M.reports, found = (R.found || []).filter((f) => !dismissing.has(f.id)), asks = R.asks || [], setups = R.setups || [];
|
|
101
179
|
$('#repCap').textContent = R.rows.length ? String(R.rows.length) : '';
|
|
180
|
+
const group = (id, label, L, row) => L.length ? `<div class="dmg ngrp" id="${id}" role="list"><p class="label">${esc(label)} · ${L.length}</p>${L.map(row).join('')}</div>` : '';
|
|
102
181
|
$('#repBody').innerHTML = `<p class="mhint">A report is a file in the repository. PMOS drafts it, you read it. <b>Nothing is sent from here.</b></p>`
|
|
182
|
+
+ `<form class="nask" id="repAsk"><input id="repAskIn" maxlength="500" autocomplete="off" placeholder="Ask PMOS to set up a report" aria-label="Ask PMOS to set up a report"><button class="dmcta" id="repAskGo" type="submit">Ask</button></form>`
|
|
183
|
+
+ '<p class="note nask-n">This starts a background run that only proposes a report. Nothing is set up until you press Set it up.</p>'
|
|
184
|
+
+ (R.setupsOk === false ? '<div class="nempty"><p><b>The report setups could not be read</b>, so what PMOS found and what you set up are not listed.</p></div>'
|
|
185
|
+
: group('repAsks', 'Your requests', asks, askRow) + group('repFound', 'Found in your work', found, foundRow) + group('repSetups', 'Set up', setups, setupRow))
|
|
103
186
|
+ (R.missing ? '<div class="nempty"><p><b>The report files could not be read</b>, so none is listed.</p></div>'
|
|
104
|
-
: R.rows.length ? `<
|
|
105
|
-
: '<div class="nempty"><p><b>No report file is on record.</b>
|
|
106
|
-
+ `<p class="nsch"><button class="lk" id="repOpen">Open the Reports tab</button> to read, edit or issue
|
|
187
|
+
: R.rows.length ? `<div class="dmg ngrp" id="repDocs" role="list"><p class="label">Documents · <b>${R.counts.draft}</b> ${R.counts.draft === 1 ? 'draft' : 'drafts'} · <b>${R.counts.issued}</b> issued</p>${R.rows.map(repRow).join('')}</div>`
|
|
188
|
+
: '<div class="nempty"><p><b>No report file is on record.</b> Set one up above, or ask PMOS for one.</p></div>')
|
|
189
|
+
+ `<p class="nsch"><button class="lk" id="repOpen">Open the Reports tab</button> to read, edit or issue a document.</p>`;
|
|
190
|
+
clearTimeout(askTimer);
|
|
191
|
+
if (asks.some((a) => a.state === 'running')) askTimer = setTimeout(load, 5000);
|
|
192
|
+
}
|
|
193
|
+
$('#repBody').addEventListener('click', (e) => {
|
|
194
|
+
if (e.target.closest('[data-rep]') || e.target.closest('#repOpen')) { location.assign('/c3.html?tab=rep'); return; }
|
|
195
|
+
const f = e.target.closest('[data-found]'), a = e.target.closest('[data-ask]'), s = e.target.closest('[data-setup]');
|
|
196
|
+
if (f) openFound((M.reports.found || []).find((x) => x.id === f.dataset.found));
|
|
197
|
+
else if (a) openAsk((M.reports.asks || []).find((x) => x.id === a.dataset.ask));
|
|
198
|
+
else if (s) openSetup((M.reports.setups || []).find((x) => x.id === s.dataset.setup));
|
|
199
|
+
});
|
|
200
|
+
$('#repBody').addEventListener('submit', async (e) => {
|
|
201
|
+
if (e.target.id !== 'repAsk') return;
|
|
202
|
+
e.preventDefault();
|
|
203
|
+
const inp = $('#repAskIn'), text = inp.value.trim(), go = $('#repAskGo');
|
|
204
|
+
if (!text) { toast('Say what the report is for, then press Ask.'); inp.focus(); return; }
|
|
205
|
+
go.disabled = true;
|
|
206
|
+
const res = await repPost('ask', { text });
|
|
207
|
+
go.disabled = false;
|
|
208
|
+
if (!res || res.ok !== true) { toast((res && res.error) || 'The request could not start.'); return; }
|
|
209
|
+
inp.value = ''; toast('Asked. A background run is working on a proposal. Nothing is set up yet.'); await load();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
/* ── the report dialogs: each press is one existing /api/report-setups/* route (PRD R2 to R4) ─────────────────────────────────────────────── */
|
|
213
|
+
const repPost = (sub, body) => pmPost('/api/report-setups/' + sub, Object.assign({ ws: M.board.ws }, body));
|
|
214
|
+
function repDlg(o) {
|
|
215
|
+
openDlg({ eye: o.eye + ' · real data', title: o.title, sub: o.sub || M.board.name, say: o.say, stream: turnA(ptx(o.say)), noteKey: null, label: 'Report',
|
|
216
|
+
pane: `<article class="paper doc">${o.html}<p class="note" id="rxM" role="status" style="margin:12px 0 0;min-height:1.2em"></p><div class="cact">${o.acts.map(([id, t, alt]) => `<button class="cta${alt ? ' alt' : ''}" data-rx="${id}">${esc(t)}</button>`).join('')}</div></article>` });
|
|
217
|
+
$('#askF').hidden = true;
|
|
218
|
+
$('#oMain').onchange = null;
|
|
219
|
+
$('#oMain').onclick = async (e) => {
|
|
220
|
+
const b = e.target.closest('[data-rx]'); if (!b) return;
|
|
221
|
+
const m = $('#rxM'), fn = o.on[b.dataset.rx]; if (!fn) return;
|
|
222
|
+
$$('#oMain [data-rx]').forEach((x) => { x.disabled = true; });
|
|
223
|
+
const after = await fn(m, b);
|
|
224
|
+
if (after === 'keep') { $$('#oMain [data-rx]').forEach((x) => { x.disabled = false; }); return; }
|
|
225
|
+
if (after === 'keep-off') return;
|
|
226
|
+
closeDlg(); await load();
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/* A press: post, then say the result in words, or keep the dialog open with the server's refusal. */
|
|
230
|
+
const press = (sub, body, said) => async (m) => {
|
|
231
|
+
m.textContent = 'Recording.';
|
|
232
|
+
const res = await repPost(sub, body);
|
|
233
|
+
if (!res || res.ok !== true) { m.textContent = (res && res.error) || 'That did not go through.'; return 'keep'; }
|
|
234
|
+
toast(typeof said === 'function' ? said(res) : said); return null;
|
|
235
|
+
};
|
|
236
|
+
const setupSaid = (res) => { const d = res.drafted || {}; return 'Set up. ' + (d.path ? 'The first draft is ' + d.path + '.' : 'The first draft was not written' + (d.error ? ': ' + d.error : '') + '. Draft it now on the report tries again.'); };
|
|
237
|
+
const propHtml = (p) => p && p.rows.length ? kv(p.rows) : '<p class="note" style="margin:0">The proposal holds no fields yet.</p>';
|
|
238
|
+
function openFound(f) {
|
|
239
|
+
if (!f) return;
|
|
240
|
+
repDlg({ eye: 'Found in your work', title: f.name, say: f.why + ' Set it up, or say it is not a report.',
|
|
241
|
+
html: `<p class="lede" style="margin:0 0 12px">${esc(f.why)}</p>${propHtml(f.proposal)}<h3 class="h2">What PMOS saw · ${f.evidence.length}</h3><ul class="pdev">${f.evidence.map((x) => `<li>${esc(x.text)}${x.kind ? ` <small>${esc(x.kind)}</small>` : ''}</li>`).join('')}</ul><p class="note">Set it up records the report in the report ledger and drafts its first cycle as a file. Not a report hides it; you can undo for 5 seconds.</p>`,
|
|
242
|
+
acts: [['set', 'Set it up'], ['no', 'Not a report', 1]],
|
|
243
|
+
on: {
|
|
244
|
+
set: press('setup', { finding: f.id }, setupSaid),
|
|
245
|
+
no: (m) => {
|
|
246
|
+
const t = setTimeout(async () => { dismissing.delete(f.id); const res = await repPost('dismiss', { finding: f.id }); if (!res || res.ok !== true) toast((res && res.error) || 'Not a report did not go through.'); await load(); }, 5000);
|
|
247
|
+
dismissing.set(f.id, t); drawReps();
|
|
248
|
+
m.innerHTML = 'Hidden. It is recorded as not a report in 5 seconds. <button class="lk" id="rxUndo">Undo</button>';
|
|
249
|
+
$('#rxUndo').onclick = () => { clearTimeout(dismissing.get(f.id)); dismissing.delete(f.id); drawReps(); m.textContent = 'Undone. Nothing was recorded.'; $$('#oMain [data-rx]').forEach((x) => { x.disabled = false; }); };
|
|
250
|
+
return 'keep-off';
|
|
251
|
+
},
|
|
252
|
+
} });
|
|
253
|
+
}
|
|
254
|
+
function openAsk(a) {
|
|
255
|
+
if (!a) return;
|
|
256
|
+
if (a.state === 'running') {
|
|
257
|
+
repDlg({ eye: 'Your request', title: a.text, say: 'A background run is working on a proposal. It proposes only; nothing is set up until you press Set it up.', html: `<p class="lede" style="margin:0">A background run is working on this request. This page checks again every 5 seconds.</p>`, acts: [['cancel', 'Cancel the request', 1]], on: { cancel: press('cancel', { id: a.id }, 'Request cancelled.') } });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (a.state === 'failed') {
|
|
261
|
+
repDlg({ eye: 'Your request', title: a.text, say: 'The run ended without a proposal.', html: `<p class="lede" style="margin:0">${esc(a.error || 'The run ended without a proposal.')}</p>`, acts: [['cancel', 'Remove the request', 1]], on: { cancel: press('cancel', { id: a.id }, 'Request removed.') } });
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
repDlg({ eye: 'Your request', title: (a.proposal && a.proposal.name) || a.text, say: 'Here is the proposal. Set it up, ask for a change, or cancel.',
|
|
265
|
+
html: `<p class="note" style="margin:0 0 10px">You asked: ${esc(a.text)}</p>${propHtml(a.proposal)}<div class="addf" style="margin-top:14px"><label>A change to ask for<input id="rxChg" maxlength="500" placeholder="For example: monthly, not weekly"></label></div><p class="note">Change it starts the run again with your words. Set it up records the report and drafts its first cycle as a file.</p>`,
|
|
266
|
+
acts: [['set', 'Set it up'], ['chg', 'Change it', 1], ['cancel', 'Cancel', 1]],
|
|
267
|
+
on: {
|
|
268
|
+
set: press('setup', { ask: a.id }, setupSaid),
|
|
269
|
+
chg: (m) => { const t = $('#rxChg').value.trim(); if (!t) { m.textContent = 'Say what to change.'; $('#rxChg').focus(); return 'keep'; } return press('change', { id: a.id, text: t }, 'Asked for the change. The run is revising the proposal.')(m); },
|
|
270
|
+
cancel: press('cancel', { id: a.id }, 'Request cancelled.'),
|
|
271
|
+
} });
|
|
272
|
+
}
|
|
273
|
+
function openSetup(s) {
|
|
274
|
+
if (!s) return;
|
|
275
|
+
const rows = [['Schedule', s.label], ['Status', s.paused ? 'Paused' : 'Active'], ['Next draft', s.paused ? '' : s.next], ['Last issued', s.lastIssued], ['Audience', s.audience], ['Output', s.output], ['Documents', String(s.cycles)], ['Purpose', s.purpose]];
|
|
276
|
+
const acts = [s.paused ? ['resume', 'Resume'] : ['pause', 'Pause', 1]];
|
|
277
|
+
if (s.fromWork && !s.paused) acts.unshift(['draft', 'Draft it now']);
|
|
278
|
+
repDlg({ eye: 'Set-up report', title: s.name, say: s.paused ? 'This report is paused. Resume it to draft it on its schedule again.' : 'This report is drafted on its schedule. You can draft the next cycle now or pause it.',
|
|
279
|
+
html: kv(rows) + `<p class="note">${s.fromWork ? (s.structured ? 'Draft it now starts a background run that follows the saved structure.' : 'Draft it now writes the next cycle as a file at once.') : 'This report is drafted from its dashboard on its day.'} Pause and Resume record a line in the report ledger. Nothing is sent.</p>`,
|
|
280
|
+
acts, on: {
|
|
281
|
+
draft: press('draft', { id: s.id }, (res) => res.drafting ? 'Drafting started. The draft follows the saved structure.' : 'Drafted: ' + ((res.drafted && res.drafted.path) || 'the next cycle') + '.'),
|
|
282
|
+
pause: press('pause', { id: s.id }, 'Paused. It is not drafted until you resume it.'),
|
|
283
|
+
resume: press('resume', { id: s.id }, 'Resumed. It is drafted on its schedule again.'),
|
|
284
|
+
} });
|
|
107
285
|
}
|
|
108
|
-
$('#repBody').addEventListener('click', (e) => { if (e.target.closest('[data-rep]') || e.target.closest('#repOpen')) location.assign('/c3.html?tab=rep'); });
|
|
109
286
|
|
|
110
287
|
/* ── dock ─────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
111
288
|
function drawDock() { $('#dN').textContent = M.dock.needs; $('#dLab').textContent = M.dock.label; $('#dNext').innerHTML = M.dock.next ? `<i></i>First <b>${esc(M.dock.next)}</b>` : 'No measure is behind its line'; }
|
|
112
289
|
|
|
113
290
|
/* ── the dialog: the measure's record, no press, the read-only agent beside it ───────────────────────────────── */
|
|
114
|
-
function cardHtml(c) { return `<div class="acard" id="card"><p class="ct">What this page can do</p><p class="nodef" id="holdWhy">${esc(c.dialog.hold)}
|
|
291
|
+
function cardHtml(c) { return `<div class="acard" id="card"><p class="ct">What this page can do</p><p class="nodef" id="holdWhy">${esc(c.dialog.hold)} The switches under On your dashboards save a dashboard and change no record.</p></div>`; }
|
|
115
292
|
function paneHtml(c) {
|
|
116
293
|
const p = c.dialog.pane;
|
|
117
|
-
return `<article class="paper doc"><p class="dpath">${esc(p.file)}</p
|
|
294
|
+
return `<article class="paper doc"><p class="dpath">${esc(p.file)}</p>${onDashHtml(c)}<div class="kv2">${c.dialog.facts.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div><h3 class="h2">All ${c.pts.length} readings</h3><div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div><p class="xn">Read from the KR metric record. The line status is the record's own: the straight line from its baseline to its target. Nothing here is a forecast.</p></article>`;
|
|
295
|
+
}
|
|
296
|
+
/* Add to a dashboard (PRD D6): one switch per saved dashboard of the board. A press saves that dashboard with the chart added or taken off. */
|
|
297
|
+
function onDashHtml(c) {
|
|
298
|
+
if (!M.board.id) return '';
|
|
299
|
+
const L = savedDash();
|
|
300
|
+
return `<h3 class="h2">On your dashboards</h3>${L.length ? `<div class="dplist" role="group" aria-label="Add to a dashboard">${L.map((d) => { const on = d.charts.includes(c.id); return `<button role="switch" aria-checked="${on}" aria-pressed="${on}" data-pdsw="${esc(d.id)}"><span><b>${esc(d.name)}</b><small>${d.charts.length} ${d.charts.length === 1 ? 'chart' : 'charts'}</small></span><i>${on ? 'On it' : 'Add'}</i></button>`; }).join('')}</div>` : '<p class="note" style="margin:0 0 12px">No saved dashboard on this board yet. Make one with New dashboard.</p>'}<p class="note" id="pdSwM" role="status" style="min-height:1.2em"></p>`;
|
|
118
301
|
}
|
|
119
302
|
function openChart(c) {
|
|
120
303
|
if (!c) return;
|
|
121
304
|
const d = c.dialog;
|
|
122
305
|
openDlg({ eye: d.eye + ' · real data', title: c.title, sub: c.sub + ' · ' + c.chip, say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(c), noteKey: c.key, pane: paneHtml(c), label: 'KR metric record' });
|
|
306
|
+
$('#oMain').onchange = null;
|
|
307
|
+
$('#oMain').onclick = async (e) => {
|
|
308
|
+
const b = e.target.closest('[data-pdsw]'); if (!b || b.disabled) return;
|
|
309
|
+
const D = savedDash().find((x) => x.id === b.dataset.pdsw); if (!D) return;
|
|
310
|
+
const on = D.charts.includes(c.id), charts = on ? D.charts.filter((x) => x !== c.id) : D.charts.concat(c.id);
|
|
311
|
+
b.disabled = true; $('#pdSwM').textContent = 'Saving.';
|
|
312
|
+
const res = await saveDash({ id: D.id, name: D.name, purpose: D.purpose, charts, main: D.main });
|
|
313
|
+
b.disabled = false;
|
|
314
|
+
if (!res || res.ok !== true) { $('#pdSwM').textContent = (res && res.error) || 'The dashboard could not be saved.'; return; }
|
|
315
|
+
D.charts = charts; b.setAttribute('aria-checked', !on); b.setAttribute('aria-pressed', !on); $('i', b).textContent = on ? 'Add' : 'On it'; $('small', b).textContent = charts.length + ' ' + (charts.length === 1 ? 'chart' : 'charts');
|
|
316
|
+
$('#pdSwM').textContent = on ? 'Taken off ' + D.name + '.' : 'Added to ' + D.name + '.';
|
|
317
|
+
load();
|
|
318
|
+
};
|
|
123
319
|
loadThread(c.key);
|
|
124
320
|
setTimeout(() => { const b = $('#dBody'); b.scrollTop = b.scrollHeight; }, 120);
|
|
125
321
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* pm/premium-shell.js — what the premium Briefing and My work pages share: the theme, the toast, the standard dialog and the read-only agent's conversation (initiatives briefing-premium and my-work-premium). */
|
|
2
|
-
import { pmPost } from './http.js';
|
|
2
|
+
import { pmGet, pmPost } from './http.js';
|
|
3
3
|
export const $ = (s, r = document) => r.querySelector(s);
|
|
4
4
|
export const $$ = (s, r = document) => [...r.querySelectorAll(s)];
|
|
5
5
|
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
@@ -20,6 +20,7 @@ export function flip() {
|
|
|
20
20
|
}
|
|
21
21
|
{ const t = new URLSearchParams(location.search).get('theme') || store.get(THEME_KEY); theme(t); }
|
|
22
22
|
$('#theme').onclick = flip; $('#theme2').onclick = flip;
|
|
23
|
+
{ const b = $('#settingsBtn'); if (b) b.onclick = () => openSettings(); } // hoisted: the function below is declared, not assigned
|
|
23
24
|
|
|
24
25
|
/* ── toast ──────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
25
26
|
let tt = null;
|
|
@@ -211,3 +212,52 @@ export function openAddDoc(o) {
|
|
|
211
212
|
toast('Document added. It is saved on the record.'); closeDlg(); if (o.onAdded) await o.onAdded();
|
|
212
213
|
};
|
|
213
214
|
}
|
|
215
|
+
|
|
216
|
+
/* ── Settings: the two things that cannot be defaulted (initiative premium-settings) ────────────────────────────────────────────────────
|
|
217
|
+
* Workspaces: GET /api/workspaces · POST /api/workspaces, /api/workspaces/forget. Connectors: GET and POST /api/proactive/settings {briefSources}.
|
|
218
|
+
* Each press saves what the console's section saves, and nothing else. Every other setting runs on a default and stays in the console. */
|
|
219
|
+
const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
|
|
220
|
+
export async function openSettings() {
|
|
221
|
+
const M = { ws: null, src: null, err: '', busy: false };
|
|
222
|
+
const draw = () => {
|
|
223
|
+
const w = M.ws, s = M.src;
|
|
224
|
+
const wsRows = w === null ? '<p class="note">Reading the repositories.</p>' : w.length ? w.map((x) => `<div class="sr"><span class="sn"><b>${esc(x.label || x.name || x.id)}</b><em>${esc(x.root || '')}${x.home ? ' · home' : ''}</em></span>${x.home ? '' : `<button type="button" class="cta alt" data-rm="${esc(x.id)}">Remove</button>`}</div>`).join('') : '<p class="note">No repository is registered yet.</p>';
|
|
225
|
+
const srcRows = s === null ? '<p class="note">Reading the sources.</p>' : Object.keys(SRC).filter((k) => k in s).map((k) => `<div class="sr"><span class="sn"><b>${esc(SRC[k])}</b><em>${s[k] ? 'The Briefing reads it' : 'The Briefing does not read it'}</em></span><button type="button" class="fchip" role="switch" aria-checked="${s[k]}" aria-label="${esc(SRC[k])}: the Briefing reads it" data-src="${esc(k)}">${s[k] ? 'On' : 'Off'}</button></div>`).join('');
|
|
226
|
+
$('#oMain').innerHTML = `<article class="paper doc"><div class="addf">
|
|
227
|
+
<div><span class="label">Workspaces</span><p class="note" style="margin:0 0 8px">A workspace is one repository PMOS works in. Removing one forgets the address only; the folder is not deleted.</p>${wsRows}
|
|
228
|
+
<div class="two" style="margin-top:10px"><label><input id="stP" maxlength="500" placeholder="Folder path of a repository" aria-label="Folder path of a repository"></label><button type="button" class="cta" id="stAdd">Add repository</button></div></div>
|
|
229
|
+
<div><span class="label">Connectors</span><p class="note" style="margin:0 0 8px">Which sources the Briefing reads. PMOS keeps no passwords or keys; your Claude session reaches each tool through its own connectors.</p>${srcRows}</div>
|
|
230
|
+
<p class="note" id="stM" role="status" style="margin:0;min-height:1.2em">${esc(M.err)}</p>
|
|
231
|
+
<p class="note" style="margin:0">Everything else runs on a default. <a href="/c3.html?tab=settings">More settings in the console</a>.</p></div></article>`;
|
|
232
|
+
};
|
|
233
|
+
openDlg({ eye: 'Settings · real data', title: 'Settings', say: 'Two choices only: which repositories PMOS works in, and which sources the Briefing reads.', stream: turnA(ptx('Two choices only: which repositories PMOS works in, and which sources the Briefing reads. Each press saves that one record and changes nothing else.')), noteKey: null, pane: '<article class="paper doc"></article>', label: 'Settings' });
|
|
234
|
+
$('#askF').hidden = true; setMode('detail'); draw();
|
|
235
|
+
const load = async () => {
|
|
236
|
+
const [w, p] = await Promise.all([pmGet('/api/workspaces'), pmGet('/api/proactive/settings')]);
|
|
237
|
+
M.ws = w && Array.isArray(w.workspaces) ? w.workspaces : []; M.src = p && p.ok && p.settings ? { ...p.settings.briefSources } : {};
|
|
238
|
+
if (!w || !Array.isArray(w.workspaces)) M.err = 'The repositories could not be read.'; else if (!p || !p.ok) M.err = 'The sources could not be read.';
|
|
239
|
+
draw();
|
|
240
|
+
};
|
|
241
|
+
$('#oMain').onclick = async (e) => {
|
|
242
|
+
if (M.busy) return;
|
|
243
|
+
const rm = e.target.closest('[data-rm]'), sw = e.target.closest('[data-src]');
|
|
244
|
+
M.err = '';
|
|
245
|
+
if (rm) {
|
|
246
|
+
const x = M.ws.find((y) => y.id === rm.dataset.rm); if (!x) return;
|
|
247
|
+
M.busy = true; const r = await pmPost('/api/workspaces/forget', { id: x.id }); M.busy = false;
|
|
248
|
+
if (r && r.ok) { M.ws = M.ws.filter((y) => y.id !== x.id); toast('Removed ' + (x.label || x.name || x.id) + '. The folder is untouched.'); } else M.err = (r && (r.error || r.reason)) || 'Not removed.';
|
|
249
|
+
draw();
|
|
250
|
+
} else if (sw) {
|
|
251
|
+
const k = sw.dataset.src, on = !M.src[k];
|
|
252
|
+
M.busy = true; const r = await pmPost('/api/proactive/settings', { briefSources: { [k]: on } }); M.busy = false;
|
|
253
|
+
if (r && r.ok) { M.src[k] = on; toast((on ? 'The Briefing now reads ' : 'The Briefing no longer reads ') + SRC[k] + '.'); } else M.err = (r && r.error) || 'Not saved.';
|
|
254
|
+
draw();
|
|
255
|
+
} else if (e.target.closest('#stAdd')) {
|
|
256
|
+
const root = ($('#stP').value || '').trim(); if (!root) { M.err = 'Paste the folder path of a repository.'; draw(); return; }
|
|
257
|
+
M.busy = true; const r = await pmPost('/api/workspaces', { root, focus: false }); M.busy = false;
|
|
258
|
+
if (r && r.ok) { M.ws = [...M.ws.filter((y) => y.id !== r.workspace.id), r.workspace]; toast('Added ' + (r.workspace.name || root) + '.'); } else M.err = (r && r.error) || 'Not added.';
|
|
259
|
+
draw();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
await load();
|
|
263
|
+
}
|
|
@@ -1280,3 +1280,10 @@ button.dsn:hover{box-shadow:inset 0 0 0 1.5px rgb(79,109,245)}
|
|
|
1280
1280
|
/* initiative page: the pill and the theme button sit under the crumb as the mockup draws them; long file names in the check evidence wrap */
|
|
1281
1281
|
.top:has(#iH1) .tools-top{flex-basis:100%;justify-content:flex-start}
|
|
1282
1282
|
#cIniChk .ckr small{overflow-wrap:anywhere}
|
|
1283
|
+
|
|
1284
|
+
/* Settings dialog rows (initiative premium-settings) */
|
|
1285
|
+
.sr{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:44px;padding:8px 0;border-bottom:1px solid var(--hair)}
|
|
1286
|
+
.sr .sn{display:grid;gap:2px;min-width:0}.sr .sn b{font-size:15px}.sr .sn em{font-style:normal;font-size:12.5px;color:var(--ink-3);overflow-wrap:anywhere}
|
|
1287
|
+
.sr button{min-height:44px;min-width:64px;flex:none}
|
|
1288
|
+
.sr .fchip[aria-checked="true"]{background:var(--solid);color:var(--on-solid)}
|
|
1289
|
+
@media (max-width:600px){.pkmenu{left:0;right:auto}} /* three round header buttons leave the picker too far left for a right-aligned menu (initiative premium-settings) */
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
<div class="tools tools-top"><span class="snap" id="snap">Reading the board</span>
|
|
37
37
|
<span class="seg modeseg" id="modeSeg" role="group" aria-label="How an initiative opens"><i class="pill"></i><button data-m="page" aria-pressed="true">Page</button><button data-m="popup" aria-pressed="false">Popup</button></span>
|
|
38
38
|
<a class="glass round" id="toConsole" href="/c3.html" aria-label="Open the console" title="Open the console"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3M13 15h4"/></svg></a>
|
|
39
|
+
<button class="glass round" id="settingsBtn" aria-label="Settings" title="Settings"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/></svg></button>
|
|
39
40
|
<button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
|
|
40
41
|
</header>
|
|
41
42
|
<section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
<h1 class="vh" id="iH1">Initiative</h1><div id="crumbHost"></div>
|
|
36
36
|
<div class="tools tools-top"><span class="snap" id="snap">Reading the initiative</span>
|
|
37
37
|
<a class="glass round" id="toConsole" href="/c3.html" aria-label="Open the console" title="Open the console"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3M13 15h4"/></svg></a>
|
|
38
|
+
<button class="glass round" id="settingsBtn" aria-label="Settings" title="Settings"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/></svg></button>
|
|
38
39
|
<button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
|
|
39
40
|
</header>
|
|
40
41
|
<section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
<h1 class="vh">Insights</h1><div id="crumbHost"></div>
|
|
37
37
|
<div class="tools tools-top"><span class="snap" id="snap">Reading the records</span>
|
|
38
38
|
<a class="glass round" id="toConsole" href="/c3.html" aria-label="Open the console" title="Open the console"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3M13 15h4"/></svg></a>
|
|
39
|
+
<button class="glass round" id="settingsBtn" aria-label="Settings" title="Settings"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/></svg></button>
|
|
39
40
|
<button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
|
|
40
41
|
</header>
|
|
41
42
|
<section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
<section class="card rise" style="--d:5" id="cDash" aria-labelledby="hDash">
|
|
45
46
|
<div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg></span><h2 id="hDash">Dashboards</h2><small id="dashCap"></small></div>
|
|
46
47
|
<div class="seg" id="dashTabs" role="group" aria-label="Dashboard" hidden><i class="pill"></i></div>
|
|
48
|
+
<div class="nact pdbar" id="dashBar" hidden></div>
|
|
47
49
|
<div id="dashBody"></div>
|
|
48
50
|
</section>
|
|
49
51
|
</div>
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
</section>
|
|
55
57
|
</aside>
|
|
56
58
|
</div>
|
|
57
|
-
<p class="foot" id="foot">Charts read the KR metric records of this workspace and never invent a number. Left out: the Insight Studio (making
|
|
59
|
+
<p class="foot" id="foot">Charts read the KR metric records of this workspace and never invent a number. A press here records only what it says: a dashboard in the workspace's state folder, a report setup, request or dismissal in the report ledger. Left out: the Insight Studio (making a chart or a report by conversation), the report deck, present and print, run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. Nothing is sent from this page.</p>
|
|
58
60
|
</main>
|
|
59
61
|
<noscript>This page needs JavaScript.</noscript>
|
|
60
62
|
<script type="module" src="/pm/premium-insights.js"></script>
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
<h1 class="vh">My work</h1><span class="glass name" aria-hidden="true">My work</span>
|
|
36
36
|
<div class="tools tools-top"><span class="snap" id="snap">Reading your list</span>
|
|
37
37
|
<a class="glass round" id="toConsole" href="/c3.html" aria-label="Open the console" title="Open the console"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3M13 15h4"/></svg></a>
|
|
38
|
+
<button class="glass round" id="settingsBtn" aria-label="Settings" title="Settings"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/></svg></button>
|
|
38
39
|
<button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
|
|
39
40
|
</header>
|
|
40
41
|
<section class="hero">
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
<div class="tools tools-top"><span class="snap" id="snap">Reading the repository</span>
|
|
38
38
|
<span class="pkw" id="pkw" hidden><button class="fchip" id="pick" aria-haspopup="menu" aria-expanded="false" aria-controls="pickMenu">Products<em id="pickN"></em></button><div class="crmenu pkmenu" id="pickMenu" role="menu" hidden></div></span>
|
|
39
39
|
<a class="glass round" id="toConsole" href="/c3.html" aria-label="Open the console" title="Open the console"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3M13 15h4"/></svg></a>
|
|
40
|
+
<button class="glass round" id="settingsBtn" aria-label="Settings" title="Settings"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/></svg></button>
|
|
40
41
|
<button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
|
|
41
42
|
</header>
|
|
42
43
|
<section class="hero">
|
package/workspace/server.js
CHANGED
|
@@ -6255,6 +6255,8 @@ async function handleRequest(req, res) {
|
|
|
6255
6255
|
// one row, as before. A refusal names its cause — unknown / home / sessions (R3.3).
|
|
6256
6256
|
let body = {};
|
|
6257
6257
|
try { body = JSON.parse((await readBody(req)) || '{}'); } catch {}
|
|
6258
|
+
const g = pmGuard.requirePagePress(req, body); // premium-settings: Remove is a page press, so an agent session gets 403
|
|
6259
|
+
if (!g.ok) return json(res, { ok: false, error: g.error }, g.status);
|
|
6258
6260
|
if (body.repository) {
|
|
6259
6261
|
const out = forgetRepository(body.id);
|
|
6260
6262
|
return json(res, out, out.ok ? 200 : 409);
|