create-pmos 0.271.0 → 0.272.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 +1 -1
- package/workspace/guide/briefing-premium.md +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-studio-report-test.js +203 -0
- package/workspace/public/pm/premium-insights.js +16 -4
- package/workspace/public/pm/premium-studio-report.js +264 -0
- package/workspace/public/pm/premium-studio.js +56 -23
- package/workspace/public/pm/premium.css +7 -0
- package/workspace/test-lists/premium-studio-report.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.272.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-18T13:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T13:41:52Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-18T13:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T13:41:52Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-18T13:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T13:41:52Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -200,7 +200,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
200
200
|
await shut();
|
|
201
201
|
await q.click('#repSetups .dmo'); await dlgOn();
|
|
202
202
|
const su = await q.evaluate(() => ({ kv: document.querySelector('#oMain .kv2').textContent, acts: [...document.querySelectorAll('#oMain [data-rx]')].map((b) => b.dataset.rx).join() }));
|
|
203
|
-
ok('R4 a set-up report shows its schedule and next draft, with Draft it now and
|
|
203
|
+
ok('R4 a set-up report shows its schedule and next draft, with Draft it now, Pause and Shape it in the Studio', /ScheduleEvery other Monday at 09:00/.test(su.kv) && /Next draft26 Oct/.test(su.kv) && su.acts === 'draft,pause,studio', JSON.stringify(su));
|
|
204
204
|
await q.click('#oMain [data-rx="pause"]'); await sleep(300);
|
|
205
205
|
ok('R4 Pause posts that report', last()[0] === '/api/report-setups/pause' && last()[1].id === 'partner-update', JSON.stringify(last()));
|
|
206
206
|
ok('R7 every press went to the dashboard save route or an existing report-setups route', R.posts.every((x) => /^POST \/api\/(premium-dashboards\/save|report-setups\/(ask|change|cancel|setup|dismiss|pause|resume|draft))$/.test(x)), R.posts.join());
|
|
@@ -204,6 +204,8 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
204
204
|
- **Dashboards.** The switch lists All measures first, then your saved dashboards (the main one first, marked Main), then the pillars the metrics name. A saved dashboard draws its charts in the order you saved them. A chart whose record is gone, or that has fewer than two readings, is listed in its place with the reason and is not drawn.
|
|
205
205
|
- **Make or edit a dashboard.** **New dashboard**, or **Edit** on a saved one, opens the **Insight Studio**, a wide dialog. On the right, the brief shows the Name, Purpose, Charts and Main dashboard; press a chip to change it. **Library** lists the board's measures and saved dashboards to add. The preview draws the dashboard as the page will, and lists a measure with no series as not drawn. The checks (a name, a purpose, a chart, six or fewer, no repeat, a main dashboard on the board) say what fails, with a one-press fix. On the left you can say it instead: "add Partner activation", "remove …", "move … first", "call it …", "it is for …", "make it the main dashboard", "undo" or "start a new one". A turn changes the draft only. **Undo** steps back one change. **Save the dashboard** records it; **Remove the dashboard** asks once more and then removes it. In a chart's dialog, **On your dashboards** has a switch for each saved dashboard, which adds the chart to it or takes it off.
|
|
206
206
|
- **Make your own chart.** **New chart**, or **Edit** on one of your charts, opens the Insight Studio in **Chart** mode; the switch at the top moves between Chart and Dashboard, and each keeps its own draft. The brief shows the Question, Measure, Form (line, bars, number or meter), Range (all readings or the last few) and Target; **More** adds the Title, Better when, Note and Add to (a dashboard). The Studio suggests a form from the question and says why. The checks (a question, a target, enough readings, a form that fits the question, one scale) say what fails, with a one-press fix. You can say it instead: "show it as bars", "last 4 readings", "target 35", "lower is better", "call it …", "note: …", "add it to Weekly", or a question. A pie is declined, with the reason. **Save the chart** records it in the workspace's state folder, and adds it to the dashboard you named. Your charts are listed under **All measures**, and a dashboard can hold them beside the measures. **Remove the chart** asks once more; a dashboard that held it then says it was removed.
|
|
207
|
+
- **Set up a report in the Studio.** **New report** on the Reports card opens the Insight Studio in **Report** mode. The brief shows the Title, What it answers, Audience, Format, Schedule, Draw from (your work, or the board's dashboard) and the Sections. A new report always has the same sections, in the same order, so they are listed, not edited. The checks (what it answers, an audience, a format that fits the audience, a new title, the answer first) say what fails, with a one-press fix. You can say it instead: "it answers: …", "for leadership", "slides", "monthly", "every two weeks on Thursday", "call it …". **Set it up** records the report and writes its first draft as a file.
|
|
208
|
+
- **Shape a report's sections.** On a report drawn from your work, **Shape it in the Studio** opens Report mode on it. Tell PMOS how to shape the sections in your own words; PMOS proposes the next version and says what it changed. **Leave out** on a section makes the next version without it; the headline, Needs your call and Sources are always in. **Undo** goes back one version. **Use this structure** saves the version shown, and the next cycle follows it.
|
|
207
209
|
- **What stands out.** Up to three plain sentences taken from the series: behind its line for three readings in a row, behind and still moving away from the target, closing in, slipped, reached its target, or a large one-step move. There is no forecast and no cause.
|
|
208
210
|
- **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
|
|
209
211
|
- **Ask PMOS to set up a report.** Type what the report is for and press **Ask**. A background run proposes a report and does nothing else. The request is listed as Working, then Ready to review. A ready request opens with its proposal: **Set it up**, **Change it** (say what to change; the run revises it), or **Cancel**.
|
|
@@ -211,4 +213,4 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
211
213
|
- **Set up.** Your recurring reports, with their schedule and next draft. A report opens with **Draft it now** (for a report drawn from your work) and **Pause** or **Resume**.
|
|
212
214
|
- **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens the console's Reports tab, where it is read, edited or issued. Nothing is sent from this page.
|
|
213
215
|
|
|
214
|
-
Not built: the
|
|
216
|
+
Not built: report samples and the report's look in the Studio, a second measure next to a chart, bar highlights, the report deck, present and print, changing a set-up report's audience, format or schedule, tile sizes and free layout, the finder's settings, run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.272.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.272.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-studio-report-test.js — the Insight Studio's Report mode on the premium Insights page (initiative premium-studio-report;
|
|
4
|
+
* planning/prd/premium-studio-report-prd.md R1 to R13). A real server on a scratch git repository with KR metric records, and a stub `claude` on the PATH that
|
|
5
|
+
* plays the report-structure job (as c3-report-structure-real-test.js does). The real page presses the real routes:
|
|
6
|
+
* O opening · K the checks · C the conversation · U Undo · B the brief · S set it up · H shaping a set-up report · L the library · P the POST allow-list · F floors
|
|
7
|
+
* Set STUDIO_SHOTS=<dir> to save screenshots of a new report and a set-up report, at 1280 and 390 wide. */
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { spawn, execFileSync } = require('child_process');
|
|
12
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
13
|
+
const T = require('./test-run').configure({ name: 'premium-studio-report' });
|
|
14
|
+
const RS = require('./lib/report-setups.js');
|
|
15
|
+
const S = require('./lib/report-structure.js');
|
|
16
|
+
|
|
17
|
+
const BASE = T.BASE;
|
|
18
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
19
|
+
const until = async (fn, ms = 20000, step = 150) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
20
|
+
const results = [];
|
|
21
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
|
|
22
|
+
let srv = null, browser = null;
|
|
23
|
+
const base = fs.mkdtempSync(path.join(os.tmpdir(), 'studio-report-'));
|
|
24
|
+
const finish = async (code) => {
|
|
25
|
+
if (browser) await browser.close().catch(() => {});
|
|
26
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
27
|
+
T.killTmux();
|
|
28
|
+
try { fs.rmSync(base, { recursive: true, force: true }); } catch { /* left for the OS */ }
|
|
29
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
30
|
+
console.log(`\n${results.length - bad}/${results.length} premium-studio-report assertions passed`);
|
|
31
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
32
|
+
};
|
|
33
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
34
|
+
|
|
35
|
+
/* the scratch repository: one measure with a series, so the page draws; a git repository, so a report draft can be written */
|
|
36
|
+
const dir = path.join(base, 'repo'), stateDir = path.join(base, 'state'), fakeBin = path.join(base, 'bin'), fakeHome = path.join(base, 'home');
|
|
37
|
+
for (const d of [path.join(dir, 'planning', 'records'), stateDir, fakeBin, path.join(fakeHome, '.claude')]) fs.mkdirSync(d, { recursive: true });
|
|
38
|
+
const rd = (id, rid, at, value) => ({ id, kind: 'reading', rid, fields: { at, value } });
|
|
39
|
+
fs.writeFileSync(path.join(dir, 'planning', 'records', 'kr-metrics.jsonl'), [
|
|
40
|
+
{ id: '1', kind: 'add', rid: 'krm-a', fields: { metric: 'Partner activation', baseline: 20, target: 50, by: '2026-12-31', pillar: 'Growth', unit: '%' } },
|
|
41
|
+
rd('2', 'krm-a', '2026-08-01', 24), rd('3', 'krm-a', '2026-09-01', 30), rd('4', 'krm-a', '2026-10-01', 33),
|
|
42
|
+
].map((x) => JSON.stringify(x)).join('\n') + '\n');
|
|
43
|
+
fs.mkdirSync(path.join(dir, 'planning', 'initiatives'), { recursive: true });
|
|
44
|
+
fs.writeFileSync(path.join(dir, 'planning', 'initiatives', 'partner-activation.md'), '---\ntype: Initiative\ntitle: "Partner activation"\nid: partner-activation\nlane: feature\nparent_kr: q4:o1:kr1\n---\n\n# Partner activation\n');
|
|
45
|
+
const git = (...a) => execFileSync('git', a, { cwd: dir, stdio: 'ignore' });
|
|
46
|
+
git('init', '-q'); git('-c', 'user.name=t', '-c', 'user.email=t@t', 'add', '-A'); git('-c', 'user.name=t', '-c', 'user.email=t@t', 'commit', '-q', '-m', 'records');
|
|
47
|
+
/* The stub plays the structure job: the first turn builds a plan with five sections; a later turn builds on the previous version. Any other run is a no-op. */
|
|
48
|
+
fs.writeFileSync(path.join(fakeBin, 'claude'), `#!/usr/bin/env node
|
|
49
|
+
const fs = require('fs');
|
|
50
|
+
let input = ''; process.stdin.on('data', (d) => { input += d; }); process.stdin.on('end', () => {
|
|
51
|
+
const line = (k) => { const m = new RegExp('^- ' + k + ': (.*)$', 'm').exec(input); return m ? m[1].trim() : null; };
|
|
52
|
+
const mode = line('Mode'); const out = line('Output path');
|
|
53
|
+
const done = (o) => { process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', is_error: false, result: typeof o === 'string' ? o : JSON.stringify(o), num_turns: 2, duration_ms: 500, permission_denials: [] })); process.exit(0); };
|
|
54
|
+
if (!mode || !out || mode === 'dry') return done('Done.');
|
|
55
|
+
const prev = line('Previous version');
|
|
56
|
+
const plan = prev && prev.startsWith('/') ? JSON.parse(fs.readFileSync(prev, 'utf8')) : {
|
|
57
|
+
purpose: { readers: 'Leadership', decision: 'Whether partners activate fast enough', scope: 'Partners', cadence: 'monthly', questions: ['Are partners activating?'] },
|
|
58
|
+
sources: [{ id: 'board', kind: 'pmos-level', name: 'Board', ref: 'board', use: 'The KR metric records', state: 'reached' }],
|
|
59
|
+
charts: [{ id: 'act', chart: null, name: 'Partner activation', source: 'board', from: 'KR metric record', how: 'Latest reading', compare: 'Previous reading', flag: 'Below the line', question: 'Are partners activating?', query: '', why: 'The KR' }],
|
|
60
|
+
outline: [{ id: 'headline', title: 'Headline', fixed: true, charts: [], notes: '', show: 'Text' }, { id: 'funnel', title: 'Activation', charts: ['act'], notes: 'The KR against its line', show: 'Chart' },
|
|
61
|
+
{ id: 'changes', title: 'What changed', charts: [], notes: '', show: 'List' }, { id: 'needs', title: 'Needs your call', fixed: true, charts: [], notes: '', show: 'List' }, { id: 'sources', title: 'Sources', fixed: true, charts: [], notes: '', show: 'List' }],
|
|
62
|
+
options: [],
|
|
63
|
+
};
|
|
64
|
+
fs.writeFileSync(out, JSON.stringify(plan));
|
|
65
|
+
setTimeout(() => done({ answer: prev && prev.startsWith('/') ? 'Kept the sections as they are.' : 'Built the first version: the headline, activation, what changed, needs your call and sources.' }), 600);
|
|
66
|
+
});
|
|
67
|
+
`, { mode: 0o755 });
|
|
68
|
+
const model = async () => (await (await fetch(BASE + '/api/insights-premium')).json()).model;
|
|
69
|
+
|
|
70
|
+
(async () => {
|
|
71
|
+
const exe = findBrowser();
|
|
72
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
73
|
+
let chromium;
|
|
74
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
75
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore',
|
|
76
|
+
env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: dir, PMOS_STATE_DIR: stateDir, PMOS_NO_OPEN: '1', PMOS_REPORT_FIND: 'off', PMOS_CORE_DOCS: 'off', HOME: fakeHome, PATH: fakeBin + path.delimiter + process.env.PATH }) });
|
|
77
|
+
await T.waitForServer(BASE);
|
|
78
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
79
|
+
|
|
80
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p = await ctx.newPage(), errs = [], posts = [];
|
|
81
|
+
p.on('pageerror', (e) => errs.push(String(e)));
|
|
82
|
+
p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
|
|
83
|
+
await p.goto(BASE + '/premium-insights.html');
|
|
84
|
+
await until(() => p.evaluate(() => !!document.querySelector('#repNew')));
|
|
85
|
+
const M0 = await model(), bname = M0.board.name;
|
|
86
|
+
const say = async (t, ms = 150) => { await p.fill('#stIn', t); await p.press('#stIn', 'Enter'); await sleep(ms); return p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; }); };
|
|
87
|
+
const lastA = () => p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; });
|
|
88
|
+
const chipv = (k) => p.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
|
|
89
|
+
const checksTxt = () => p.evaluate(() => (document.querySelector('#stCk .suckb b') || {}).textContent || '');
|
|
90
|
+
const secs = () => p.evaluate(() => [...document.querySelectorAll('#stPv .stsec h4')].map((h) => h.firstChild.textContent));
|
|
91
|
+
const tap = (sel) => p.$eval(sel, (b) => b.click());
|
|
92
|
+
const mode = () => p.evaluate(() => (document.querySelector('#oMain .stmd [aria-pressed="true"]') || {}).textContent || '');
|
|
93
|
+
const shot = async (n) => { if (process.env.STUDIO_SHOTS) await p.screenshot({ path: path.join(process.env.STUDIO_SHOTS, n + '.png') }); };
|
|
94
|
+
const cta = () => p.evaluate(() => { const b = document.querySelector('#stFt [data-st="save"]'); return b ? b.textContent + (b.disabled ? ':off' : ':on') : ''; });
|
|
95
|
+
|
|
96
|
+
/* O: New report opens the Studio in Report mode */
|
|
97
|
+
await p.click('#repNew');
|
|
98
|
+
await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu')));
|
|
99
|
+
ok('O1 New report opens the Studio in Report mode, with the brief of the mockup', await mode() === 'Report' && await chipv('title') === bname + ' weekly report' && await chipv('purpose') === 'Not set'
|
|
100
|
+
&& await chipv('aud') === 'The team' && await chipv('out') === 'Google Doc' && await chipv('sched') === 'Weekly, Mondays at 09:00' && await chipv('from') === 'Your work' && await chipv('secs') === '7', [await mode(), await chipv('title'), await chipv('sched')].join());
|
|
101
|
+
ok('O2 the preview lists the frozen frame, headline first and sources last', (await secs()).join() === 'Headline,Timeline,Initiatives,New since last report,Decided this cycle,Needs your call,Sources', (await secs()).join());
|
|
102
|
+
|
|
103
|
+
/* K and C: the checks and the conversation */
|
|
104
|
+
ok('K1 without what it answers, 4 of 5 checks pass', await checksTxt() === '4 of 5 checks pass', await checksTxt());
|
|
105
|
+
let a = await say('It answers: Are partners activating fast enough?');
|
|
106
|
+
ok('C1 "it answers" sets What it answers, and 5 of 5 checks pass', await chipv('purpose') === 'Are partners activating fast enough?' && await checksTxt() === '5 of 5 checks pass', a);
|
|
107
|
+
a = await say('for leadership, monthly');
|
|
108
|
+
ok('C2 one turn sets the audience and the schedule', await chipv('aud') === 'Leadership' && await chipv('sched') === 'Monthly on the 1st at 09:00', a);
|
|
109
|
+
ok('K2 leadership with a document fails "The format fits the audience"', await checksTxt() === '4 of 5 checks pass', await checksTxt());
|
|
110
|
+
await tap('#oMain [data-st="ck"]'); await sleep(100);
|
|
111
|
+
const fix = await p.evaluate(() => [...document.querySelectorAll('#stCk .sucl li.bad button')].map((b) => b.textContent));
|
|
112
|
+
ok('K3 the failing check offers its fix', fix.join() === 'Make it slides', fix.join());
|
|
113
|
+
await tap('#stCk .sucl li.bad button'); await sleep(150);
|
|
114
|
+
ok('K4 the fix makes it slides, and the checks pass', await chipv('out') === 'Google Slides' && await checksTxt() === '5 of 5 checks pass');
|
|
115
|
+
a = await say('leave out the timeline');
|
|
116
|
+
ok('C3 a request to change a section of a new report changes nothing and says why', /^I changed nothing: a new report always has the same sections/.test(a) && (await secs()).length === 7, a);
|
|
117
|
+
a = await say('call it Partner review, every two weeks on Thursday');
|
|
118
|
+
ok('C4 one turn names it and sets every other Thursday', await chipv('title') === 'Partner review' && await chipv('sched') === 'Every other Thursday at 09:00', a);
|
|
119
|
+
await tap('#oMain [data-st="undo"]'); await sleep(150);
|
|
120
|
+
ok('U1 Undo steps back one turn', await chipv('title') === bname + ' weekly report' && await chipv('sched') === 'Monthly on the 1st at 09:00', await chipv('title'));
|
|
121
|
+
await say('call it Partner review');
|
|
122
|
+
await shot('report-new-1280');
|
|
123
|
+
ok('C5 no turn on a new report posted anything', posts.length === 0, posts.join());
|
|
124
|
+
|
|
125
|
+
/* B: the brief and its tray */
|
|
126
|
+
await tap('#oMain [data-st="chip|from"]'); await sleep(100);
|
|
127
|
+
const from = await p.evaluate(() => [...document.querySelectorAll('#stTr .sto b')].map((b) => b.textContent));
|
|
128
|
+
ok('B1 Draw from offers your work and the board\'s dashboard', from.join() === 'Your work,The board\'s dashboard', from.join());
|
|
129
|
+
await tap('#stTr [data-st="set|from|dash"]'); await sleep(100);
|
|
130
|
+
ok('B2 the board\'s dashboard has no fixed frame to list, and says what it draws', await chipv('from') === 'The board\'s dashboard' && (await secs()).length === 0 && /dashboard: each of its charts/.test(await p.evaluate(() => document.querySelector('#stPv').textContent)));
|
|
131
|
+
await tap('#oMain [data-st="chip|from"]'); await sleep(100); await tap('#stTr [data-st="set|from|work"]'); await sleep(100);
|
|
132
|
+
await tap('#oMain [data-st="chip|sched"]'); await sleep(100);
|
|
133
|
+
await tap('#stTr [data-st="set|cadence|weekly"]'); await sleep(100);
|
|
134
|
+
await tap('#oMain [data-st="chip|sched"]'); await sleep(100);
|
|
135
|
+
await tap('#stTr [data-st="set|day|Tue"]'); await sleep(100);
|
|
136
|
+
ok('B3 the Schedule tray sets weekly on a Tuesday', await chipv('sched') === 'Weekly, Tuesdays at 09:00', await chipv('sched'));
|
|
137
|
+
await tap('#oMain [data-st="chip|aud"]'); await sleep(100);
|
|
138
|
+
await p.fill('#stI', 'Leadership team'); await sleep(150);
|
|
139
|
+
ok('B4 the Audience field sets the audience as it is typed', await chipv('aud') === 'Leadership team');
|
|
140
|
+
await p.press('#stI', 'Enter'); await sleep(100);
|
|
141
|
+
|
|
142
|
+
/* S: set it up */
|
|
143
|
+
await tap('#oMain [data-st="save"]');
|
|
144
|
+
await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
|
|
145
|
+
const st0 = [...RS.fold(RS.readLines(RS.ledgerFile(dir))).setups.values()];
|
|
146
|
+
const su = st0[0] || {};
|
|
147
|
+
ok('S1 Set it up writes one setup with what the brief shows', st0.length === 1 && su.name === 'Partner review' && su.audience === 'Leadership team' && su.output === 'google-slides' && su.source === 'work'
|
|
148
|
+
&& su.schedule.cadence === 'weekly' && su.schedule.day === 'Tue' && su.purpose === 'Are partners activating fast enough?', JSON.stringify(su));
|
|
149
|
+
const toastT = await p.evaluate(() => (document.querySelector('#toast') || {}).textContent || '');
|
|
150
|
+
const draftRel = (/first draft is (\S+\.md)/.exec(toastT) || [])[1];
|
|
151
|
+
ok('S2 the answer says where the first draft is, and the file is there', !!draftRel && fs.existsSync(path.join(dir, draftRel)), toastT);
|
|
152
|
+
ok('S3 Set it up posted the setup route only', posts.join() === '/api/report-setups/setup', posts.join());
|
|
153
|
+
|
|
154
|
+
/* H: shape the set-up report */
|
|
155
|
+
await until(() => p.evaluate((id) => !!document.querySelector(`#repBody [data-setup="${id}"]`), su.id));
|
|
156
|
+
await p.click(`#repBody [data-setup="${su.id}"]`);
|
|
157
|
+
await until(() => p.evaluate(() => !!document.querySelector('#oMain [data-rx="studio"]')));
|
|
158
|
+
await tap('#oMain [data-rx="studio"]');
|
|
159
|
+
await until(() => p.evaluate(() => !!document.querySelector('#oMain .stu')) && chipv('ver').then((v) => v === 'None yet'));
|
|
160
|
+
ok('H1 Shape it in the Studio opens Report mode on the report, with no structure yet', await mode() === 'Report' && await chipv('facts') === 'Partner review' && await chipv('ver') === 'None yet' && (await secs()).length === 7, [await mode(), await chipv('facts'), (await secs()).join()].join(' | '));
|
|
161
|
+
await tap('#oMain [data-st="chip|secs"]'); await sleep(100);
|
|
162
|
+
ok('H2 with no structure, the sections cannot be left out by press, and the fixed ones say Always in', await p.evaluate(() => document.querySelectorAll('#stTr [data-st^="rsec|"]').length === 0 && [...document.querySelectorAll('#stTr .stlc small')].length === 3));
|
|
163
|
+
ok('K5 with no structure, "The version shown is saved" fails, and seven sections are long for a leadership audience', await checksTxt() === '3 of 5 checks pass' && await cta() === 'Use this structure:off', await checksTxt() + ' ' + await cta());
|
|
164
|
+
await p.fill('#stIn', 'Shape it for the partner review'); await p.press('#stIn', 'Enter');
|
|
165
|
+
ok('H3 a turn shows PMOS working', await until(() => lastA().then((x) => x === 'PMOS is working on it.'), 3000));
|
|
166
|
+
await until(() => chipv('ver').then((v) => v === 'S1, not saved'), 30000);
|
|
167
|
+
a = await lastA();
|
|
168
|
+
ok('H4 the job\'s answer replaces the working line, and S1 is shown', /^Built the first version/.test(a) && /Shown: S1, not saved yet\./.test(a) && (await secs()).join() === 'Headline,Activation,What changed,Needs your call,Sources', a + ' ' + (await secs()).join());
|
|
169
|
+
ok('H5 the turn posted report-structure/turn', posts.includes('/api/report-structure/turn'), posts.join());
|
|
170
|
+
await until(() => p.evaluate(() => !!document.querySelector('#stTr [data-st="rsec|changes"]')), 3000);
|
|
171
|
+
await tap('#stTr [data-st="rsec|changes"]');
|
|
172
|
+
await until(() => chipv('ver').then((v) => v === 'S2, not saved'));
|
|
173
|
+
ok('H6 Leave out makes the next version without the section', (await secs()).join() === 'Headline,Activation,Needs your call,Sources' && posts.includes('/api/report-structure/remove'), (await secs()).join());
|
|
174
|
+
await tap('#oMain [data-st="undo"]');
|
|
175
|
+
await until(() => chipv('ver').then((v) => v === 'S1, not saved'));
|
|
176
|
+
ok('U2 Undo on a set-up report goes back one version', (await secs()).length === 5 && posts.includes('/api/report-structure/revert'));
|
|
177
|
+
ok('K6 Leadership with five sections passes the length check; the unsaved version fails', await checksTxt() === '4 of 5 checks pass', await checksTxt());
|
|
178
|
+
await tap('#oMain [data-st="save"]');
|
|
179
|
+
await until(() => chipv('ver').then((v) => v === 'S1, saved'));
|
|
180
|
+
const sv = S.stateOf(dir, su.id).saved;
|
|
181
|
+
ok('H7 Use this structure saves the version shown, and is then not offered', sv && sv.n === 1 && await cta() === 'Use this structure:off' && await checksTxt() === '5 of 5 checks pass', JSON.stringify(sv) + ' ' + await cta());
|
|
182
|
+
|
|
183
|
+
await tap('#oMain [data-st="chip|secs"]'); await sleep(150); await shot('report-shape-1280'); await tap('#oMain [data-st="chip|secs"]');
|
|
184
|
+
/* L: the library */
|
|
185
|
+
await tap('#oMain [data-st="lib"]'); await sleep(100);
|
|
186
|
+
const lib = await p.evaluate(() => [...document.querySelectorAll('#stLb .stli')].map((b) => b.querySelector('b').textContent + ':' + b.querySelector('em').textContent));
|
|
187
|
+
ok('L1 the library lists the set-up reports', lib.join() === 'Partner review:Open', lib.join());
|
|
188
|
+
await tap('#oMain [data-st="lib"]');
|
|
189
|
+
|
|
190
|
+
/* P: the writes */
|
|
191
|
+
const allowed = new Set(['/api/report-setups/setup', '/api/report-setups/from-dashboard', '/api/report-structure/turn', '/api/report-structure/remove', '/api/report-structure/revert', '/api/report-structure/accept']);
|
|
192
|
+
ok('P1 every POST is one of the existing report routes', posts.length > 0 && posts.every((x) => allowed.has(x)), posts.join());
|
|
193
|
+
|
|
194
|
+
/* F: floors */
|
|
195
|
+
await p.setViewportSize({ width: 390, height: 844 }); await sleep(300);
|
|
196
|
+
const wide = await p.evaluate(() => { const d = document.querySelector('#oMain'); return [document.documentElement.scrollWidth - innerWidth, d ? d.scrollWidth - d.clientWidth : 0]; });
|
|
197
|
+
await shot('report-shape-390');
|
|
198
|
+
ok('F1 at 390 wide, Report mode does not scroll sideways', wide[0] <= 0 && wide[1] <= 1, wide.join());
|
|
199
|
+
const small = await p.evaluate(() => [...document.querySelectorAll('#oMain .stmd button, #oMain .suc, #stFt button')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent));
|
|
200
|
+
ok('F2 the mode switch, the chips and the footer are 44 px tall', small.length === 0, small.join());
|
|
201
|
+
ok('F3 no script error', errs.length === 0, errs.join(' | '));
|
|
202
|
+
return finish();
|
|
203
|
+
})().catch((e) => { console.error(e); finish(1); });
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* line, what stands out), the Reports card, the dock and the standard dialog.
|
|
4
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
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). premium-studio-chart adds a saved chart (POST /api/premium-charts/save, PRD C1, C10) and its four forms (C3).
|
|
7
|
-
*
|
|
6
|
+
* draft, PRD R2 to R4). premium-studio-chart adds a saved chart (POST /api/premium-charts/save, PRD C1, C10) and its four forms (C3). premium-studio-report
|
|
7
|
+
* adds New report and Shape it in the Studio, whose presses are POST /api/report-setups/setup | from-dashboard and POST /api/report-structure/turn | remove |
|
|
8
|
+
* revert | accept (PRD R5 to R8). Nothing else posts, and nothing is sent outward. */
|
|
8
9
|
import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb, kv } from './premium-shell.js';
|
|
9
|
-
import { pmPost } from './http.js';
|
|
10
|
+
import { pmPost, pmGet } from './http.js';
|
|
10
11
|
import { openStudio } from './premium-studio.js';
|
|
11
12
|
|
|
12
13
|
let M = null; // the model
|
|
@@ -164,10 +165,17 @@ $('#dashBar').addEventListener('click', (e) => { if (e.target.closest('#pdEdit')
|
|
|
164
165
|
/* ── a dashboard is made and edited in the Insight Studio (initiative premium-studio-dashboard). Its one press posts POST /api/premium-dashboards/save. ── */
|
|
165
166
|
async function saveDash(body) { return pmPost('/api/premium-dashboards/save', Object.assign({ ws: M.board.ws, board: M.board.id }, body)); }
|
|
166
167
|
async function saveChart(body) { return pmPost('/api/premium-charts/save', Object.assign({ ws: M.board.ws, board: M.board.id }, body)); }
|
|
167
|
-
const
|
|
168
|
+
const structure = {
|
|
169
|
+
get: (id) => pmGet('/api/report-structure?ws=' + encodeURIComponent(M.board.ws || '') + '&id=' + encodeURIComponent(id)),
|
|
170
|
+
post: (sub, id, body) => pmPost('/api/report-structure/' + sub, Object.assign({ ws: M.board.ws, id }, body)),
|
|
171
|
+
};
|
|
172
|
+
const studioOf = (o) => openStudio(Object.assign({ M, tile: tileHtml, derive: deriveChart, save: saveDash, saveChart, setup: (sub, body) => repPost(sub, body), structure, reportsChanged: () => load(),
|
|
173
|
+
done: async (id) => { dash = id || dash; if (!M.dashboards.some((d) => d.id === dash)) dash = 'all'; await load(); } }, o));
|
|
168
174
|
function openDashEdit(D) { studioOf({ mode: 'dash', D, done: async (id) => { dash = id || 'all'; await load(); } }); }
|
|
169
175
|
/* A chart is made and edited in the Studio's Chart mode (initiative premium-studio-chart). Save posts POST /api/premium-charts/save. */
|
|
170
176
|
function openChartEdit(id) { studioOf({ mode: 'chart', C: id ? (M.mineSaved || []).find((x) => x.id === id) || null : null }); }
|
|
177
|
+
/* A report is set up and shaped in the Studio's Report mode (initiative premium-studio-report). */
|
|
178
|
+
function openReportEdit(s) { studioOf({ mode: 'rep', R: s || null }); }
|
|
171
179
|
$('#dashBody').addEventListener('click', (e) => { const o = e.target.closest('[data-open]'); if (o) { openChart(byKey(o.dataset.open)); return; } const ed = e.target.closest('[data-ced]'); if (ed) openChartEdit(ed.dataset.ced); });
|
|
172
180
|
$('#dashBody').addEventListener('keydown', (e) => {
|
|
173
181
|
const t = e.target.closest && e.target.closest('.mch'); if (!t || !/^Arrow(Left|Right)$/.test(e.key)) return;
|
|
@@ -196,6 +204,7 @@ function drawReps() {
|
|
|
196
204
|
$('#repCap').textContent = R.rows.length ? String(R.rows.length) : '';
|
|
197
205
|
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>` : '';
|
|
198
206
|
$('#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>`
|
|
207
|
+
+ '<div class="nact"><button class="dmcta" id="repNew" aria-haspopup="dialog">New report</button></div>'
|
|
199
208
|
+ `<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>`
|
|
200
209
|
+ '<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>'
|
|
201
210
|
+ (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>'
|
|
@@ -209,6 +218,7 @@ function drawReps() {
|
|
|
209
218
|
}
|
|
210
219
|
$('#repBody').addEventListener('click', (e) => {
|
|
211
220
|
if (e.target.closest('[data-rep]') || e.target.closest('#repOpen')) { location.assign('/c3.html?tab=rep'); return; }
|
|
221
|
+
if (e.target.closest('#repNew')) { openReportEdit(null); return; }
|
|
212
222
|
const f = e.target.closest('[data-found]'), a = e.target.closest('[data-ask]'), s = e.target.closest('[data-setup]');
|
|
213
223
|
if (f) openFound((M.reports.found || []).find((x) => x.id === f.dataset.found));
|
|
214
224
|
else if (a) openAsk((M.reports.asks || []).find((x) => x.id === a.dataset.ask));
|
|
@@ -292,12 +302,14 @@ function openSetup(s) {
|
|
|
292
302
|
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]];
|
|
293
303
|
const acts = [s.paused ? ['resume', 'Resume'] : ['pause', 'Pause', 1]];
|
|
294
304
|
if (s.fromWork && !s.paused) acts.unshift(['draft', 'Draft it now']);
|
|
305
|
+
if (s.fromWork) acts.push(['studio', 'Shape it in the Studio', 1]);
|
|
295
306
|
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.',
|
|
296
307
|
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>`,
|
|
297
308
|
acts, on: {
|
|
298
309
|
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') + '.'),
|
|
299
310
|
pause: press('pause', { id: s.id }, 'Paused. It is not drafted until you resume it.'),
|
|
300
311
|
resume: press('resume', { id: s.id }, 'Resumed. It is drafted on its schedule again.'),
|
|
312
|
+
studio: () => { openReportEdit(s); return 'keep-off'; },
|
|
301
313
|
} });
|
|
302
314
|
}
|
|
303
315
|
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/* pm/premium-studio-report.js — the Insight Studio's Report mode on the premium Insights page (initiative premium-studio-report). premium-studio.js hands
|
|
2
|
+
* Report mode to this module: the brief, its tray, the library rows, the preview, the checks, the footer and the conversation.
|
|
3
|
+
*
|
|
4
|
+
* Two drafts. A NEW report is a brief in the page (title, what it answers, audience, format, schedule, draw from). A turn changes it and writes nothing.
|
|
5
|
+
* Set it up posts POST /api/report-setups/setup with the proposal, or POST /api/report-setups/from-dashboard for the board's dashboard.
|
|
6
|
+
* A SET-UP report is read from GET /api/report-structure. Its sections change through its structure: Leave out posts POST /api/report-structure/remove,
|
|
7
|
+
* a turn posts POST /api/report-structure/turn (one headless job that proposes the next version), Undo posts .../revert to the version before, and
|
|
8
|
+
* Use this structure posts .../accept. Every POST goes through the page's hand (P.setup, P.structure), behind the launch nonce. The frame of a new report
|
|
9
|
+
* is frozen (D78 as amended by D86), so its sections are shown, not edited. Nothing is sent outward. */
|
|
10
|
+
import { $, esc } from './premium-shell.js';
|
|
11
|
+
|
|
12
|
+
const OUT = { 'google-slides': ['Google Slides', 'A deck. Leadership usually reads one.'], 'google-doc': ['Google Doc', 'A document to read through.'], 'google-sheets': ['Google Sheets', 'A spreadsheet of the numbers.'], confluence: ['Confluence page', 'A page in your wiki.'], pdf: ['PDF', 'A file to keep or attach.'] };
|
|
13
|
+
const CAD = { daily: 'Daily', weekly: 'Weekly', 'bi-weekly': 'Every two weeks', monthly: 'Monthly' };
|
|
14
|
+
const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
|
|
15
|
+
const DAYN = { Mon: 'Monday', Tue: 'Tuesday', Wed: 'Wednesday', Thu: 'Thursday', Fri: 'Friday', Sat: 'Saturday', Sun: 'Sunday' };
|
|
16
|
+
/* The frame every instant draft writes, in its frozen order (lib/report-draft.js FRAME), and what each section holds (lib/report-setups.js SECTION_NOTES). */
|
|
17
|
+
const FRAME = [['headline', 'Headline', 'The one thing the readers must know this cycle.'], ['timeline', 'Timeline', 'The dated items, written in full.'],
|
|
18
|
+
['initiatives', 'Initiatives', 'One block for each initiative: done, in progress, next and the key open item.'], ['new', 'New since last report', 'What is new in the window, each with its date.'],
|
|
19
|
+
['decided', 'Decided this cycle', 'The decisions, marked Decided or Acknowledged.'], ['needs', 'Needs your call', 'The asks to the readers: what, who, by when.'], ['sources', 'Sources', 'The sources reached and not reached.']];
|
|
20
|
+
const FIXED = { headline: 'Every report leads with its answer.', needs: 'Every report names what it needs from its readers.', sources: 'Every report lists its sources, so each number can be checked.' };
|
|
21
|
+
const DOCI = '<svg class="i" viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 13h6M9 17h4"/></svg>';
|
|
22
|
+
const SECW = /\b(sections?|headline|timeline|initiatives|decided|decisions?|needs your call|sources|new since)\b/;
|
|
23
|
+
const LEAD = /\b(lead(ership)?|exec(utive)?s?|the board|directors?|vps?|heads? of|c-?level|cxo|ceo|cto|cpo)\b/i;
|
|
24
|
+
const HELP = 'I understand: call it something, it answers something (or a question), for an audience, a format (slides, a doc, sheets, Confluence, a PDF), daily, weekly on a day, every two weeks, monthly, from my work or from the dashboard, undo, and start a new one.';
|
|
25
|
+
const HELPS = 'Tell me how to shape the sections in your own words, for example: leave out the timeline, or put the decisions first. PMOS proposes the next version; nothing is saved until you press Use this structure. Undo goes back one version.';
|
|
26
|
+
|
|
27
|
+
let X = null; // the Studio's hand: { st, P, chip, opt, field, draw, plural }
|
|
28
|
+
export function useStudio(x) { X = x; }
|
|
29
|
+
const st = () => X.st;
|
|
30
|
+
const r = () => X.st.r;
|
|
31
|
+
const board = () => X.P.M.board || {};
|
|
32
|
+
const setups = () => ((X.P.M.reports || {}).setups || []);
|
|
33
|
+
const clean = (s) => s.trim().replace(/^["'“]|["'”]$/g, '').replace(/[.\s]+$/, '').trim();
|
|
34
|
+
const outName = (o) => (OUT[o] ? OUT[o][0] : o || 'Not set');
|
|
35
|
+
const lead = (aud) => LEAD.test(aud || '');
|
|
36
|
+
function schedLabel(d) {
|
|
37
|
+
if (d.cadence === 'daily') return 'Daily at 09:00';
|
|
38
|
+
if (d.cadence === 'monthly') return 'Monthly on the 1st at 09:00';
|
|
39
|
+
return (d.cadence === 'weekly' ? 'Weekly, ' : 'Every other ') + DAYN[d.day] + (d.cadence === 'weekly' ? 's' : '') + ' at 09:00';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* ── the drafts ── */
|
|
43
|
+
export function blankReport() {
|
|
44
|
+
return { kind: 'new', title: ((board().name || 'Board') + ' weekly report').slice(0, 80), purpose: '', audience: 'The team', output: 'google-doc', cadence: 'weekly', day: 'Mon', from: 'work' };
|
|
45
|
+
}
|
|
46
|
+
export function setupReport(s) {
|
|
47
|
+
const d = { kind: 'setup', id: s.id, name: s.name, audience: s.audience, output: s.output, label: s.label, S: null, loading: true, working: false, err: '' };
|
|
48
|
+
load(d);
|
|
49
|
+
return d;
|
|
50
|
+
}
|
|
51
|
+
async function load(d) {
|
|
52
|
+
const res = await X.P.structure.get(d.id);
|
|
53
|
+
if (r() !== d) return;
|
|
54
|
+
d.loading = false;
|
|
55
|
+
if (!res || res.ok !== true) { d.err = (res && res.error) || 'The structure of this report could not be read.'; X.draw(); return; }
|
|
56
|
+
d.S = res.structure; d.err = ''; X.draw();
|
|
57
|
+
}
|
|
58
|
+
const plan = (d) => (d.S && d.S.plan) || null;
|
|
59
|
+
const shownN = (d) => (d.S ? d.S.current : null);
|
|
60
|
+
const savedN = (d) => (d.S ? d.S.saved : null);
|
|
61
|
+
const outline = (d) => (plan(d) ? plan(d).outline : FRAME.map(([id, title]) => ({ id, title, fixed: !!FIXED[id], charts: [], notes: '', show: '' })));
|
|
62
|
+
|
|
63
|
+
/* ── the brief ── */
|
|
64
|
+
export function brief() {
|
|
65
|
+
const d = r(), c = X.chip;
|
|
66
|
+
if (d.kind === 'new') {
|
|
67
|
+
return `<div class="stbr" role="group" aria-label="Brief">${c('title', 'Title', d.title || 'Not set')}${c('purpose', 'What it answers', d.purpose || 'Not set')}${c('aud', 'Audience', d.audience || 'Not set')}${c('out', 'Format', outName(d.output))}${c('sched', 'Schedule', schedLabel(d))}${c('from', 'Draw from', d.from === 'dash' ? 'The board\'s dashboard' : 'Your work')}${d.from === 'work' ? c('secs', 'Sections', String(FRAME.length)) : ''}</div>`;
|
|
68
|
+
}
|
|
69
|
+
const n = shownN(d), s = savedN(d);
|
|
70
|
+
return `<div class="stbr" role="group" aria-label="Brief">${c('facts', 'Report', d.name)}${c('secs', 'Sections', d.loading ? 'Reading' : String(outline(d).length))}${c('ver', 'Version', d.loading ? 'Reading' : n == null ? 'None yet' : 'S' + n + (s === n ? ', saved' : s != null ? ', saved is S' + s : ', not saved'))}</div>`;
|
|
71
|
+
}
|
|
72
|
+
export function tray(p) {
|
|
73
|
+
const d = r(), o = X.opt, f = X.field;
|
|
74
|
+
if (d.kind === 'new') {
|
|
75
|
+
if (p === 'title') return f('title', d.title, 'The name of the report', 80);
|
|
76
|
+
if (p === 'purpose') return f('purpose', d.purpose, 'For example: Are partners activating, and what do we decide?', 400) + '<p class="note">One line: what the report answers for its readers. The headline leads with it.</p>';
|
|
77
|
+
if (p === 'aud') return f('audience', d.audience, 'Who reads it', 120) + `<div class="sor"><button type="button" class="dmcta alt" data-st="set|audience|The team">The team</button><button type="button" class="dmcta alt" data-st="set|audience|Leadership">Leadership</button></div>`;
|
|
78
|
+
if (p === 'out') return `<div class="sol">${Object.keys(OUT).map((k) => o('set|output|' + k, OUT[k][0], OUT[k][1], d.output === k)).join('')}</div><p class="note">PMOS drafts the report as a file in the repository. The format names the copy you keep in step with it. Nothing is sent from here.</p>`;
|
|
79
|
+
if (p === 'sched') {
|
|
80
|
+
return `<div class="sol">${Object.keys(CAD).map((k) => o('set|cadence|' + k, CAD[k], k === 'monthly' ? 'On the 1st' : k === 'daily' ? 'Every day' : 'On ' + DAYN[d.day], d.cadence === k)).join('')}</div>`
|
|
81
|
+
+ (d.cadence === 'weekly' || d.cadence === 'bi-weekly' ? `<div class="sor">${DAYS.map((k) => `<button type="button" class="dmcta${d.day === k ? '' : ' alt'}" data-st="set|day|${k}" aria-pressed="${d.day === k}">${DAYN[k]}</button>`).join('')}</div>` : '') + '<p class="note">PMOS drafts it at 09:00 on its day. A draft is only a draft until you issue it.</p>';
|
|
82
|
+
}
|
|
83
|
+
if (p === 'from') return `<div class="sol">${o('set|from|work', 'Your work', 'The records of this workspace: initiatives, decisions, releases and asks.', d.from === 'work')}${board().id ? o('set|from|dash', 'The board\'s dashboard', 'The charts of ' + (board().name || 'this board') + '\'s dashboard, in its order, drafted on its day.', d.from === 'dash') : ''}</div>`;
|
|
84
|
+
if (p === 'secs') return `<ul class="sul">${FRAME.map(([, t, w]) => `<li><span>${esc(t)}<small>${esc(w)}</small></span></li>`).join('')}</ul><p class="note">A new report always has these sections, in this order. Once it is set up, you can shape them here in words.</p>`;
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
if (p === 'facts') return `<ul class="sul"><li><span>Audience<small>${esc(d.audience || 'Not named')}</small></span></li><li><span>Format<small>${esc(outName(d.output))}</small></span></li><li><span>Schedule<small>${esc(d.label || 'Not set')}</small></span></li></ul><p class="note">These are set when the report is set up. This page does not change them.</p>`;
|
|
88
|
+
if (p === 'secs') {
|
|
89
|
+
if (d.loading) return '<p class="note">Reading the structure.</p>';
|
|
90
|
+
const L = outline(d);
|
|
91
|
+
return `<ul class="sul">${L.map((x) => `<li><span>${esc(x.title)}${FIXED[x.id] ? `<small>${esc(FIXED[x.id])}</small>` : x.notes ? `<small>${esc(x.notes)}</small>` : ''}</span><span class="stlc">${FIXED[x.id] ? '<small>Always in</small>' : plan(d) ? `<button type="button" data-st="rsec|${esc(x.id)}" aria-label="Leave out ${esc(x.title)}"${d.working ? ' disabled' : ''}>Leave out</button>` : ''}</span></li>`).join('')}</ul>`
|
|
92
|
+
+ (plan(d) ? '<p class="note">Leave out makes the next version without that section. To add or move one, say it.</p>' : '<p class="note">This report has no structure yet, so each cycle uses this frame. Say how to shape it, and PMOS proposes the first version.</p>');
|
|
93
|
+
}
|
|
94
|
+
if (p === 'ver') {
|
|
95
|
+
const V = (d.S && d.S.versions) || [];
|
|
96
|
+
return V.length ? `<ul class="sul">${V.slice().reverse().map((v) => `<li><span>S${v.n}${v.n === savedN(d) ? ' · saved' : ''}${v.n === shownN(d) ? ' · shown' : ''}<small>${esc(v.turn || '')}</small></span></li>`).join('')}</ul><p class="note">Undo goes back one version. Use this structure saves the version shown.</p>` : '<p class="note">No version yet. Say how to shape the report.</p>';
|
|
97
|
+
}
|
|
98
|
+
return '';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* ── the library: the board's set-up reports ── */
|
|
102
|
+
export function libRows() {
|
|
103
|
+
const L = setups(), d = r();
|
|
104
|
+
const rows = L.map((s) => `<button type="button" class="stli" data-st="libr|${esc(s.id)}"${!s.fromWork || (d.kind === 'setup' && d.id === s.id) ? ' disabled' : ''}><span class="stlic" aria-hidden="true">${DOCI}</span><span><b>${esc(s.name)}</b><small>${esc([s.label, s.audience ? 'for ' + s.audience : ''].filter(Boolean).join(' · '))}</small></span><em>${!s.fromWork ? 'Follows its dashboard' : d.kind === 'setup' && d.id === s.id ? 'Open' : 'Shape it'}</em></button>`).join('');
|
|
105
|
+
return `<p class="label">Set-up reports · ${L.length}</p>${L.length ? `<div class="stlg">${rows}</div>` : '<p class="note">No report is set up yet. Fill the brief and press Set it up.</p>'}`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* ── the preview ── */
|
|
109
|
+
export function preview() {
|
|
110
|
+
const d = r();
|
|
111
|
+
if (d.kind === 'new') {
|
|
112
|
+
const secs = d.from === 'work' ? FRAME.map(([, t, w]) => `<section class="stsec"><h4>${esc(t)}</h4><p class="mut">${esc(w)}</p></section>`).join('')
|
|
113
|
+
: `<p class="note">Drawn from ${esc(board().name || 'the board')}'s dashboard: each of its charts, in its order, as the dashboard reads them on the report's day.</p>`;
|
|
114
|
+
return `<div class="stpvw"><h3 class="ndt">${esc(d.title || 'Untitled report')}</h3><p class="mut stuse">${esc(d.purpose || 'It does not say what it answers yet.')}</p><p class="stsrc">For ${esc(d.audience || 'no one yet')} · ${esc(outName(d.output))} · ${esc(schedLabel(d))}</p>${secs}<p class="note">Nothing is drafted until you press Set it up. The first draft is written then, as a file.</p></div>`;
|
|
115
|
+
}
|
|
116
|
+
if (d.loading) return '<div class="stpvw"><p class="note">Reading the structure of this report.</p></div>';
|
|
117
|
+
if (d.err) return `<div class="stpvw"><p class="note">${esc(d.err)}</p></div>`;
|
|
118
|
+
const P = plan(d), names = new Map((P ? P.charts : []).map((c) => [c.id, c.name || c.id]));
|
|
119
|
+
const secs = outline(d).map((x) => `<section class="stsec"><h4>${esc(x.title)}${FIXED[x.id] ? '<span class="npin2">Always in</span>' : ''}</h4>${x.charts && x.charts.length ? `<p class="mut">Charts: ${esc(x.charts.map((c) => names.get(c) || c).join(', '))}</p>` : ''}${x.notes ? `<p class="mut">${esc(x.notes)}</p>` : ''}${!P ? `<p class="mut">${esc((FRAME.find((f) => f[0] === x.id) || ['', '', ''])[2])}</p>` : ''}</section>`).join('');
|
|
120
|
+
const pu = P && P.purpose;
|
|
121
|
+
return `<div class="stpvw"><h3 class="ndt">${esc(d.name)}${d.S && d.S.current != null ? `<span class="npin2">S${d.S.current}</span>` : ''}</h3>${pu && pu.decision ? `<p class="mut stuse">${esc(pu.decision)}</p>` : ''}<p class="stsrc">For ${esc(d.audience || 'no one named')} · ${esc(outName(d.output))} · ${esc(d.label || '')}</p>${secs}${d.working ? '<p class="note" role="status">PMOS is working on the next version.</p>' : ''}</div>`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ── the checks ── */
|
|
125
|
+
export function checks() {
|
|
126
|
+
const d = r();
|
|
127
|
+
if (d.kind === 'new') {
|
|
128
|
+
const dup = setups().some((s) => s.name.toLowerCase() === d.title.trim().toLowerCase());
|
|
129
|
+
return [
|
|
130
|
+
{ ok: !!d.purpose.trim(), l: 'It says what it answers', d: d.purpose.trim() ? '"' + d.purpose.trim() + '"' : 'There is nothing for the headline to answer.', fix: ['Say what it answers', 'chip|purpose'] },
|
|
131
|
+
{ ok: !!d.audience.trim(), l: 'It names its audience', d: d.audience.trim() ? 'For ' + d.audience.trim() + '.' : 'Without an audience, Needs your call stays empty.', fix: ['Name the audience', 'chip|aud'] },
|
|
132
|
+
{ ok: !(lead(d.audience) && d.output !== 'google-slides'), l: 'The format fits the audience', d: lead(d.audience) && d.output !== 'google-slides' ? 'Leadership usually reads a deck.' : 'The format suits the audience.', fix: ['Make it slides', 'set|output|google-slides'] },
|
|
133
|
+
{ ok: !!d.title.trim() && !dup, l: 'The title is new', d: !d.title.trim() ? 'Give it a title.' : dup ? 'A report called "' + d.title.trim() + '" is set up already.' : 'No set-up report has this title.', fix: ['Change the title', 'chip|title'] },
|
|
134
|
+
{ ok: true, l: 'It leads with the answer', d: d.from === 'work' ? 'The frame starts with the headline.' : 'It follows the dashboard. Put the chart that answers first on the dashboard.' },
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
const L = outline(d), n = shownN(d), s = savedN(d);
|
|
138
|
+
return [
|
|
139
|
+
{ ok: true, l: 'It leads with the answer', d: 'The headline is first and always in.' },
|
|
140
|
+
{ ok: true, l: 'It names the decision', d: 'Needs your call is always in, so the readers see what is asked of them.' },
|
|
141
|
+
{ ok: true, l: 'It shows its sources', d: 'Sources is always in, so each number can be checked.' },
|
|
142
|
+
{ ok: !(lead(d.audience) && L.length > 5), l: 'The length fits the audience', d: lead(d.audience) ? L.length + ' sections. Leadership reads five or fewer.' : L.length + ' sections for ' + (d.audience || 'its readers') + '.', fix: ['Ask to shorten it', 'say|Keep it to five sections or fewer.'] },
|
|
143
|
+
{ ok: n != null && n === s, l: 'The version shown is saved', d: n == null ? 'There is no structure yet. Say how to shape it.' : n === s ? 'S' + n + ' is the saved structure. The next cycle follows it.' : 'S' + n + ' is not saved. The next cycle follows ' + (s != null ? 'S' + s : 'the frame') + '.', fix: n != null ? ['Use this structure', 'save'] : null },
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
export function guide() {
|
|
147
|
+
const d = r();
|
|
148
|
+
return d.kind === 'new' ? 'A report leads with the answer, then the evidence, then what it needs from the reader.'
|
|
149
|
+
: 'Shape the sections of ' + esc(d.name) + ' in words. PMOS proposes each version. <button type="button" class="lk" data-st="new">Start a new report instead</button>';
|
|
150
|
+
}
|
|
151
|
+
export function footer() {
|
|
152
|
+
const d = r(), s = st();
|
|
153
|
+
if (d.kind === 'new') return { undo: s.h.rep.length > 0, cta: 'Set it up', off: s.busy };
|
|
154
|
+
const n = shownN(d);
|
|
155
|
+
return { undo: !d.working && !!(d.S && d.S.versions.some((v) => v.n < n)), cta: 'Use this structure', off: s.busy || d.working || n == null || n === savedN(d) };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* ── doing things ── */
|
|
159
|
+
export function set(f, v) {
|
|
160
|
+
const d = r(); if (d.kind !== 'new') return;
|
|
161
|
+
if (f === 'cadence' && CAD[v]) d.cadence = v;
|
|
162
|
+
else if (f === 'day' && DAYS.includes(v)) { d.day = v; if (d.cadence !== 'weekly' && d.cadence !== 'bi-weekly') d.cadence = 'weekly'; }
|
|
163
|
+
else if (f === 'output' && OUT[v]) d.output = v;
|
|
164
|
+
else if (f === 'from') d.from = v === 'dash' && board().id ? 'dash' : 'work';
|
|
165
|
+
else if (f === 'audience') d.audience = v;
|
|
166
|
+
}
|
|
167
|
+
/* Undo on a set-up report goes back to the version before the one shown (POST .../revert). → a promise of the answer, or null when there is none. */
|
|
168
|
+
export function undoSetup() {
|
|
169
|
+
const d = r(), n = shownN(d), V = ((d.S && d.S.versions) || []).filter((v) => v.n < n);
|
|
170
|
+
if (!V.length || d.working) return null;
|
|
171
|
+
const to = V[V.length - 1].n;
|
|
172
|
+
return X.P.structure.post('revert', d.id, { n: to }).then((res) => {
|
|
173
|
+
if (!res || res.ok !== true) return 'That did not go through: ' + ((res && res.error) || 'the structure could not be changed') + '.';
|
|
174
|
+
d.S = res.structure; return 'Done: back to S' + to + '. The next turn builds on it.';
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
export async function leaveOut(id) {
|
|
178
|
+
const d = r(), x = outline(d).find((o) => o.id === id); if (!x || d.working) return;
|
|
179
|
+
st().busy = true; st().msg = 'Leaving out ' + x.title + '.'; X.draw(['ft']);
|
|
180
|
+
const res = await X.P.structure.post('remove', d.id, { kind: 'section', ref: id });
|
|
181
|
+
st().busy = false;
|
|
182
|
+
if (!res || res.ok !== true) { st().msg = (res && res.error) || 'That section could not be left out.'; X.draw(); return; }
|
|
183
|
+
d.S = res.structure; st().msg = 'Made S' + d.S.current + ' without ' + x.title + '. It is not saved yet.'; X.draw();
|
|
184
|
+
}
|
|
185
|
+
export async function save() {
|
|
186
|
+
const d = r(), s = st();
|
|
187
|
+
if (d.kind === 'setup') {
|
|
188
|
+
const n = shownN(d); if (n == null || n === savedN(d)) return;
|
|
189
|
+
s.busy = true; s.msg = 'Saving the structure.'; X.draw(['ft']);
|
|
190
|
+
const res = await X.P.structure.post('accept', d.id, { n });
|
|
191
|
+
s.busy = false;
|
|
192
|
+
if (!res || res.ok !== true) { s.msg = (res && res.error) || 'The structure could not be saved.'; X.draw(); return; }
|
|
193
|
+
d.S = res.structure; s.msg = 'S' + n + ' is saved as the structure. The next cycle follows it.'; X.draw(); X.P.reportsChanged();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const title = d.title.trim(), purpose = d.purpose.trim(), audience = d.audience.trim();
|
|
197
|
+
if (!title) { s.msg = 'Give the report a title.'; X.draw(['ft']); return; }
|
|
198
|
+
if (!purpose && d.from === 'work') { s.msg = 'Say what the report answers, in one line.'; X.draw(['ft']); return; }
|
|
199
|
+
if (!audience) { s.msg = 'Name the audience.'; X.draw(['ft']); return; }
|
|
200
|
+
const schedule = { cadence: d.cadence, time: '09:00', ...(d.cadence === 'weekly' || d.cadence === 'bi-weekly' ? { day: d.day } : {}), ...(d.cadence === 'monthly' ? { dayOfMonth: 1 } : {}) };
|
|
201
|
+
s.busy = true; s.msg = 'Setting it up.'; X.draw(['ft']);
|
|
202
|
+
const res = d.from === 'dash'
|
|
203
|
+
? await X.P.setup('from-dashboard', { key: 'board:' + board().id, name: title, output: d.output, schedule, audience })
|
|
204
|
+
: await X.P.setup('setup', { proposal: { name: title, purpose, audience, source: 'work', output: d.output, schedule, sources: ['The records of this workspace'], learned_from: 'Set up in the Insight Studio.' } });
|
|
205
|
+
s.busy = false;
|
|
206
|
+
if (!res || res.ok !== true) { s.msg = (res && res.error) || 'The report could not be set up.'; X.draw(['ft']); return; }
|
|
207
|
+
const dr = res.drafted || {};
|
|
208
|
+
X.done('Set up "' + title + '". ' + (d.from === 'dash' ? 'It is drafted from the dashboard on its day.' : dr.path ? 'The first draft is ' + dr.path + '.' : 'The first draft was not written' + (dr.error ? ': ' + dr.error : '') + '. Draft it now on the report tries again.'));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* ── the conversation ── */
|
|
212
|
+
export const help = () => (r().kind === 'new' ? HELP : HELPS);
|
|
213
|
+
export function command(t, low) {
|
|
214
|
+
const d = r();
|
|
215
|
+
if (d.kind === 'setup') return turn(t, low);
|
|
216
|
+
if (/\b(start (a )?new|new report|start over)\b/.test(low)) { X.snap(); st().r = blankReport(); return 'Done: a new report. Say what it answers and who reads it.'; }
|
|
217
|
+
const before = JSON.stringify(d), said = []; X.snap();
|
|
218
|
+
const nm = t.match(/(?:call it|name it|title it|rename it to|called|named)\s+["“]?(.+?)(?=["”]|,|;|\s+and\s+(?:it|make|for)\b|$)/i);
|
|
219
|
+
if (nm && clean(nm[1])) { d.title = clean(nm[1]).slice(0, 80); said.push('title "' + d.title + '"'); }
|
|
220
|
+
const pu = t.match(/(?:it answers|answers|purpose[:\s]|it is about|it's about)\s*[:-]?\s*(.+?)(?=;|$)/i);
|
|
221
|
+
if (pu && clean(pu[1])) { d.purpose = clean(pu[1]).slice(0, 400); said.push('it answers "' + d.purpose + '"'); }
|
|
222
|
+
else if (/\?\s*$/.test(t) && t.split(/\s+/).length >= 3) { d.purpose = t.slice(0, 400); said.push('it answers "' + d.purpose + '"'); }
|
|
223
|
+
const au = t.match(/\baudience[:\s]+(.+?)(?=[,;]|$)/i) || t.match(/\b(?:it is |it's |write it |make it )?for\s+(leadership|the leadership|the team|my team|our team|the board|executives|the execs|stakeholders|investors)\b/i);
|
|
224
|
+
if (au && clean(au[1])) { const a = clean(au[1]); d.audience = (/^leadership$/i.test(a) ? 'Leadership' : a.charAt(0).toUpperCase() + a.slice(1)).slice(0, 120); said.push('for ' + d.audience); }
|
|
225
|
+
const rest = low.replace(/(?:it answers|answers|purpose[:\s]|it is about|it's about).*$/i, ' ').replace(/(?:call it|name it|title it|called|named)\s+.+?(?=,|;|$)/i, ' ');
|
|
226
|
+
const out = /\b(slides?|deck|presentation)\b/.test(rest) ? 'google-slides' : /\b(sheets?|spreadsheet)\b/.test(rest) ? 'google-sheets' : /\bconfluence\b/.test(rest) ? 'confluence' : /\bpdf\b/.test(rest) ? 'pdf' : /\b(google doc|doc|document)\b/.test(rest) ? 'google-doc' : null;
|
|
227
|
+
if (out && out !== d.output) { d.output = out; said.push('format: ' + OUT[out][0]); }
|
|
228
|
+
const cad = /\b(daily|every day)\b/.test(rest) ? 'daily' : /\b(every (two|2|other) weeks?|bi-?weekly|fortnightly)\b/.test(rest) ? 'bi-weekly' : /\b(weekly|every week)\b/.test(rest) ? 'weekly' : /\b(monthly|every month)\b/.test(rest) ? 'monthly' : null;
|
|
229
|
+
if (cad && cad !== d.cadence) { d.cadence = cad; said.push(CAD[cad].toLowerCase()); }
|
|
230
|
+
const dy = rest.match(/\b(mon|tue|wed|thu|fri)[a-z]*days?\b/);
|
|
231
|
+
if (dy) { const k = dy[1].charAt(0).toUpperCase() + dy[1].slice(1); if (k !== d.day || (d.cadence !== 'weekly' && d.cadence !== 'bi-weekly')) { set('day', k); said.push('on ' + DAYN[k] + 's'); } }
|
|
232
|
+
if (/\bfrom (the |this )?(board'?s? )?dashboard\b/.test(rest)) { if (d.from !== 'dash') { set('from', 'dash'); if (d.from === 'dash') said.push('drawn from the board\'s dashboard'); else said.push('this board has no dashboard to draw from'); } }
|
|
233
|
+
else if (/\bfrom (my|our|the) (work|records)\b/.test(rest) && d.from !== 'work') { set('from', 'work'); said.push('drawn from your work'); }
|
|
234
|
+
if (JSON.stringify(d) === before) {
|
|
235
|
+
st().h.rep.pop();
|
|
236
|
+
if (SECW.test(low) && /\b(leave out|drop|remove|without|skip|move|put|first|last|add)\b/.test(low)) return 'I changed nothing: a new report always has the same sections, in the same order. Set it up, then tell me here how to shape them.';
|
|
237
|
+
return said.length ? 'I changed nothing: ' + said.join('; ') + '.' : 'I changed nothing. ' + HELP;
|
|
238
|
+
}
|
|
239
|
+
st().pop = null;
|
|
240
|
+
return 'Done: ' + said.join('; ') + '. Nothing is set up until you press Set it up.';
|
|
241
|
+
}
|
|
242
|
+
/* A turn on a set-up report: one structure job. Its answer is PMOS's own words from the structure log. */
|
|
243
|
+
async function turn(t, low) {
|
|
244
|
+
const d = r();
|
|
245
|
+
if (/^(use this|save (it|this)|use this structure)\b/.test(low)) { await save(); return st().msg; }
|
|
246
|
+
if (d.working) return 'PMOS is still working on the last turn. Wait for its answer.';
|
|
247
|
+
d.working = true; X.draw();
|
|
248
|
+
const before = d.S ? d.S.log.length : 0;
|
|
249
|
+
const res = await X.P.structure.post('turn', d.id, { text: t });
|
|
250
|
+
if (!res || res.ok !== true) { d.working = false; X.draw(); return 'That did not go through: ' + ((res && res.error) || 'the turn could not start') + '.'; }
|
|
251
|
+
const end = Date.now() + 240000;
|
|
252
|
+
for (;;) {
|
|
253
|
+
await new Promise((ok) => setTimeout(ok, 800));
|
|
254
|
+
if (r() !== d) return 'The Studio moved on. The answer is in the report\'s structure.';
|
|
255
|
+
const g = await X.P.structure.get(d.id);
|
|
256
|
+
if (g && g.ok === true && !g.structure.running) {
|
|
257
|
+
d.working = false; d.S = g.structure; X.draw();
|
|
258
|
+
const said = g.structure.log.slice(before).filter((l) => l.who === 'pmos').pop();
|
|
259
|
+
return said ? said.text + (said.n ? ' Shown: S' + said.n + ', not saved yet.' : '') : 'PMOS ended without an answer.';
|
|
260
|
+
}
|
|
261
|
+
if (Date.now() > end) { d.working = false; X.draw(); return 'PMOS has not answered yet. The answer will show in the report\'s structure.'; }
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
export const focusInput = (v) => { const i = $('#stIn'); if (i) { i.value = v; i.focus(); } };
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
/* pm/premium-studio.js — the Insight Studio on the premium Insights page: its Dashboard mode (initiative premium-studio-dashboard)
|
|
2
|
-
* (initiative premium-studio-chart). The mockup's Studio (prototype/premium-ux-concept/build-src/stu.js.txt): a conversation on the left, and on the right a
|
|
1
|
+
/* pm/premium-studio.js — the Insight Studio on the premium Insights page: its Dashboard mode (initiative premium-studio-dashboard), its Chart mode
|
|
2
|
+
* (initiative premium-studio-chart) and its Report mode (initiative premium-studio-report, in premium-studio-report.js). The mockup's Studio (prototype/premium-ux-concept/build-src/stu.js.txt): a conversation on the left, and on the right a
|
|
3
3
|
* mode switch, a brief of chips, a library, a live preview and checks. Each mode keeps its own draft and its own Undo. A turn changes the draft in the
|
|
4
4
|
* page and writes nothing. The writes are Save and Remove, each behind the launch nonce: POST /api/premium-dashboards/save for a dashboard, and
|
|
5
|
-
* POST /api/premium-charts/save for a chart (then the dashboard's save when the chart is added to one).
|
|
5
|
+
* POST /api/premium-charts/save for a chart (then the dashboard's save when the chart is added to one). Report mode's writes are the existing
|
|
6
|
+
* report-setups and report-structure routes (premium-studio-report.js). Every title, value and point comes from the page's
|
|
6
7
|
* model: the KR metric records, the board's saved charts and its saved dashboards. No demo measure is drawn.
|
|
7
8
|
*
|
|
8
|
-
* openStudio(P) P = { M, mode ('dash' | 'chart'), D (the saved dashboard to edit, or null), C (the saved chart to edit, or null),
|
|
9
|
-
* chart tile), derive (a measure's chart and a draft → the draft's chart), save (dashboard
|
|
10
|
-
* answer),
|
|
9
|
+
* openStudio(P) P = { M, mode ('dash' | 'chart' | 'rep'), D (the saved dashboard to edit, or null), C (the saved chart to edit, or null), R (the set-up
|
|
10
|
+
* report to shape, or null), tile (the page's chart tile), derive (a measure's chart and a draft → the draft's chart), save (dashboard
|
|
11
|
+
* body → answer), saveChart (chart body → answer), setup (report-setups route, body → answer), structure ({ get(id), post(route, id,
|
|
12
|
+
* body) } → answer), reportsChanged (), done (saved dashboard id | null) } */
|
|
11
13
|
import { $, esc, openDlg, closeDlg, toast, turnA, turnU, ptx, setFull } from './premium-shell.js';
|
|
14
|
+
import * as REP from './premium-studio-report.js';
|
|
12
15
|
|
|
13
16
|
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
14
17
|
const UPI = ICO('<path d="M12 19V5M6 11l6-6 6 6"/>'), DNI = ICO('<path d="M12 5v14M6 13l6 6 6-6"/>'), XI = ICO('<path d="M6 6l12 12M18 6 6 18"/>');
|
|
15
18
|
const OKI = ICO('<path d="M5 12.5l4.5 4.5L19 7.5"/>'), WRN = ICO('<path d="M12 4 2.5 20h19z"/><path d="M12 10v4M12 17v.5"/>'), CHV = ICO('<path d="M6 9l6 6 6-6"/>');
|
|
16
19
|
const DSI = ICO('<rect x="3" y="3" width="8" height="8" rx="2"/><rect x="13" y="3" width="8" height="8" rx="2"/><rect x="3" y="13" width="8" height="8" rx="2"/><rect x="13" y="13" width="8" height="8" rx="2"/>');
|
|
17
20
|
const MAX_UNDO = 30;
|
|
18
|
-
const MODES = { chart: 'Chart', dash: 'Dashboard' };
|
|
21
|
+
const MODES = { chart: 'Chart', dash: 'Dashboard', rep: 'Report' };
|
|
19
22
|
const FORMN = { line: 'Line', bars: 'Bars', number: 'Number', meter: 'Meter' };
|
|
20
23
|
const FORMD = { line: 'How it moves over time. The default for a trend.', bars: 'One reading against another. Bars start at zero.', number: 'One current value, with its change and a small line.', meter: 'How far it is from its target or limit.' };
|
|
21
24
|
|
|
22
25
|
let P = null; // the page's hand
|
|
23
|
-
let st = null; // the Studio: { mode, d: dashboard draft, c: chart draft, h: { dash, chart } undo stacks, pop, more, lib, ck, msg, armed, busy }
|
|
26
|
+
let st = null; // the Studio: { mode, d: dashboard draft, c: chart draft, r: report draft, h: { dash, chart, rep } undo stacks, pop, more, lib, ck, msg, armed, busy }
|
|
24
27
|
|
|
25
28
|
const measures = () => P.M.measures || [];
|
|
26
29
|
const mineSaved = () => P.M.mineSaved || [];
|
|
@@ -29,11 +32,11 @@ const baseOf = (id) => (P.M.charts || []).find((c) => c.id === id) || null;
|
|
|
29
32
|
const titleOf = (id) => { const m = measures().find((x) => x.id === id) || mineSaved().find((x) => x.id === id); return m ? m.title : id; };
|
|
30
33
|
const savedDash = () => (P.M.dashboards || []).filter((x) => x.saved);
|
|
31
34
|
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
32
|
-
const draft = () => (st.mode === 'chart' ? st.c : st.d);
|
|
35
|
+
const draft = () => (st.mode === 'chart' ? st.c : st.mode === 'rep' ? st.r : st.d);
|
|
33
36
|
|
|
34
37
|
/* ── the drafts and their undo, one stack per mode ── */
|
|
35
38
|
const snap = () => { const h = st.h[st.mode], cur = JSON.stringify(draft()); if (h.length && h[h.length - 1] === cur) return; h.push(cur); if (h.length > MAX_UNDO) h.shift(); };
|
|
36
|
-
const undo = () => { const h = st.h[st.mode]; if (!h.length) return false; const v = JSON.parse(h.pop()); if (st.mode === 'chart') st.c = v; else st.d = v; return true; };
|
|
39
|
+
const undo = () => { const h = st.h[st.mode]; if (!h.length) return false; const v = JSON.parse(h.pop()); if (st.mode === 'chart') st.c = v; else if (st.mode === 'rep') st.r = v; else st.d = v; return true; };
|
|
37
40
|
const blank = () => ({ id: null, name: '', use: '', charts: [], main: false });
|
|
38
41
|
/* A new chart starts from the measure PMOS ranks first in What stands out, else the first measure with a series. */
|
|
39
42
|
function chartFrom(id) {
|
|
@@ -54,6 +57,7 @@ const formWhy = (c) => ({ line: 'A line, because it shows how the measure moves
|
|
|
54
57
|
const chip = (k, l, v) => `<button type="button" class="suc${st.pop === k ? ' on' : ''}${v === 'Not set' ? ' req' : ''}" data-st="chip|${k}" aria-expanded="${st.pop === k}"><em>${esc(l)}</em><b>${esc(v)}</b></button>`;
|
|
55
58
|
const rangeTxt = (c) => { const b = baseOf(c.measure), n = b ? b.pts.length : 0; return c.range && c.range < n ? 'Last ' + c.range + ' readings' : 'All ' + plural(n, 'reading', 'readings'); };
|
|
56
59
|
function briefHtml() {
|
|
60
|
+
if (st.mode === 'rep') return REP.brief();
|
|
57
61
|
if (st.mode === 'chart') {
|
|
58
62
|
const c = st.c; if (!c) return '';
|
|
59
63
|
const more = st.more ? chip('title', 'Title', c.title || 'Not set') + chip('better', 'Better when', c.better === 'lower' ? 'Lower' : 'Higher') + chip('note', 'Note', c.note || 'None')
|
|
@@ -82,7 +86,8 @@ function chartTray(p) {
|
|
|
82
86
|
function trayHtml() {
|
|
83
87
|
const p = st.pop; if (!p || !draft()) return '';
|
|
84
88
|
let h = '';
|
|
85
|
-
if (st.mode === '
|
|
89
|
+
if (st.mode === 'rep') h = REP.tray(p);
|
|
90
|
+
else if (st.mode === 'chart') h = chartTray(p);
|
|
86
91
|
else {
|
|
87
92
|
const d = st.d;
|
|
88
93
|
if (p === 'name') h = field('name', d.name, 'For example: Weekly partner review', 60);
|
|
@@ -103,6 +108,7 @@ function spark(c) {
|
|
|
103
108
|
}
|
|
104
109
|
function libHtml() {
|
|
105
110
|
if (!st.lib) return '';
|
|
111
|
+
if (st.mode === 'rep') return `<div class="stlib" role="region" aria-label="Library of ${esc(P.M.board.name || 'this board')}"><div class="stlh"><b>Library</b><small>${esc(P.M.board.name || '')}</small><button type="button" class="lk" data-st="lib">Close</button></div>${REP.libRows()}</div>`;
|
|
106
112
|
const L = measures(), Y = mineSaved();
|
|
107
113
|
let rows, yours, dl = '';
|
|
108
114
|
if (st.mode === 'chart') {
|
|
@@ -122,6 +128,7 @@ function libHtml() {
|
|
|
122
128
|
+ (dl ? `<p class="label">Dashboards · ${savedDash().filter((x) => x.id !== st.d.id).length}</p><div class="stlg">${dl}</div>` : '') + '</div>';
|
|
123
129
|
}
|
|
124
130
|
function previewHtml() {
|
|
131
|
+
if (st.mode === 'rep') return REP.preview();
|
|
125
132
|
if (st.mode === 'chart') {
|
|
126
133
|
const c = st.c; if (!c) return '<p class="note">Nothing to draw: no measure of this board has two readings yet.</p>';
|
|
127
134
|
const ch = drawn(c);
|
|
@@ -135,6 +142,7 @@ function previewHtml() {
|
|
|
135
142
|
}
|
|
136
143
|
/* The checks of the mockup, computed from the draft. A fix is an action the Studio can take in one press. */
|
|
137
144
|
function checks() {
|
|
145
|
+
if (st.mode === 'rep') return REP.checks();
|
|
138
146
|
if (st.mode === 'chart') {
|
|
139
147
|
const c = st.c; if (!c) return [];
|
|
140
148
|
const ch = drawn(c), pts = ch ? ch.pts.length : 0, tg = tgOf(c), trendQ = /\b(moved|move|moving|trend|over time|how has|changed|changing)\b/i.test(c.question);
|
|
@@ -164,10 +172,12 @@ function checksHtml() {
|
|
|
164
172
|
+ (st.ck ? `<ul class="sucl">${L.map((x, i) => `<li class="${x.ok ? 'ok' : 'bad'}">${x.ok ? OKI : WRN}<span><b>${esc(x.l)}</b><small>${esc(x.d)}</small></span>${!x.ok && x.fix ? `<button type="button" class="dmcta alt" data-st="fix|${i}">${esc(x.fix[0])}</button>` : ''}</li>`).join('')}</ul>` : '') + '</div>';
|
|
165
173
|
}
|
|
166
174
|
function footHtml() {
|
|
175
|
+
if (st.mode === 'rep') { const f = REP.footer(); return `<div class="stft"><button type="button" class="dmcta alt" data-st="undo"${f.undo ? '' : ' disabled'}>Undo</button><span class="sp"></span><button type="button" class="dmcta alt" data-st="cancel">Cancel</button><button type="button" class="dmcta" data-st="save"${f.off ? ' disabled' : ''}>${f.cta}</button></div>`; }
|
|
167
176
|
const ch = st.mode === 'chart', d = draft(), saved = !!(d && d.id), what = ch ? 'chart' : 'dashboard';
|
|
168
177
|
return `<div class="stft"><button type="button" class="dmcta alt" data-st="undo"${st.h[st.mode].length ? '' : ' disabled'}>Undo</button>${saved ? `<button type="button" class="dmcta alt" data-st="del">${st.armed ? 'Press again to remove it' : 'Remove the ' + what}</button>` : ''}<span class="sp"></span><button type="button" class="dmcta alt" data-st="cancel">Cancel</button><button type="button" class="dmcta" data-st="save"${st.busy || !d ? ' disabled' : ''}>${saved ? 'Save changes' : 'Save the ' + what}</button></div>`;
|
|
169
178
|
}
|
|
170
179
|
function guide() {
|
|
180
|
+
if (st.mode === 'rep') return REP.guide();
|
|
171
181
|
if (st.mode === 'chart') return st.c ? esc(formWhy(st.c)) + (st.c.id ? ' <button type="button" class="lk" data-st="new">Start a new one instead</button>' : '') : 'No measure of this board has two readings yet, so there is nothing to chart.';
|
|
172
182
|
return 'A dashboard answers one routine. Give it a purpose and keep it to six charts or fewer.' + (st.d.id ? ' <button type="button" class="lk" data-st="new">Start a new one instead</button>' : '');
|
|
173
183
|
}
|
|
@@ -187,7 +197,7 @@ function draw(parts) {
|
|
|
187
197
|
if (all || parts.includes('ft')) set('stFt', footHtml());
|
|
188
198
|
const m = $('#stMsg'); if (m) m.textContent = st.msg;
|
|
189
199
|
const l = $('.stu [data-st="lib"]'); if (l) l.setAttribute('aria-expanded', st.lib);
|
|
190
|
-
if (all) { const i = $('#stIn'); if (i) { i.placeholder = 'Say what to change'; i.setAttribute('aria-label', 'Say what to change in the ' + (
|
|
200
|
+
if (all) { const i = $('#stIn'); if (i) { i.placeholder = 'Say what to change'; i.setAttribute('aria-label', 'Say what to change in the ' + ({ chart: 'chart', rep: 'report' }[st.mode] || 'dashboard')); } const h = $('#stHelp'); if (h) h.textContent = help() + (st.mode === 'rep' ? '' : ' Nothing is saved until you press Save.'); }
|
|
191
201
|
}
|
|
192
202
|
|
|
193
203
|
/* ── doing things ── */
|
|
@@ -203,17 +213,24 @@ function setChart(f, v) {
|
|
|
203
213
|
function act(a) {
|
|
204
214
|
const [k, x, y] = a; st.msg = '';
|
|
205
215
|
if (k !== 'del') st.armed = false;
|
|
206
|
-
if (k === 'mode') { if (st.mode !== x) { st.mode = x; st.pop = null; st.ck = false; draw(); } return; }
|
|
216
|
+
if (k === 'mode') { if (st.mode !== x) { st.mode = x; st.pop = null; st.ck = false; if (x === 'rep' && !st.r) st.r = REP.blankReport(); draw(); } return; }
|
|
207
217
|
if (k === 'chip') { st.pop = st.pop === x ? null : x; draw(['br', 'tr', 'ft']); const i = $('#stI'); if (i) { i.focus(); try { i.setSelectionRange(i.value.length, i.value.length); } catch { /* no caret */ } } return; }
|
|
208
218
|
if (k === 'more') { st.more = !st.more; if (!st.more && /^(title|better|note|addTo)$/.test(st.pop || '')) st.pop = null; draw(['br', 'tr']); return; }
|
|
209
219
|
if (k === 'lib') { st.lib = !st.lib; draw(['lb', 'tr', 'ft']); return; }
|
|
210
220
|
if (k === 'ck') { st.ck = !st.ck; draw(['ck']); return; }
|
|
211
221
|
if (k === 'fix') { const f = checks()[+x]; if (f && f.fix) act(f.fix[1].split('|')); return; }
|
|
212
|
-
if (k === 'undo') { if (undo()) { st.pop = null; draw(); } return; }
|
|
222
|
+
if (k === 'undo') { if (st.mode === 'rep' && st.r.kind === 'setup') { const u = REP.undoSetup(); if (u) u.then((a) => { st.msg = a; draw(); }); return; } if (undo()) { st.pop = null; draw(); } return; }
|
|
213
223
|
if (k === 'cancel') { closeDlg(); return; }
|
|
214
|
-
if (k === 'save') { if (st.mode === 'chart') saveChart(); else save(); return; }
|
|
224
|
+
if (k === 'save') { if (st.mode === 'chart') saveChart(); else if (st.mode === 'rep') REP.save(); else save(); return; }
|
|
215
225
|
if (k === 'del') { if (st.mode === 'chart') removeChart(); else remove(); return; }
|
|
216
|
-
if (k === 'new') { snap(); if (st.mode === 'chart') st.c = chartFrom(st.c && st.c.measure); else st.d = blank(); st.pop = null; draw(); return; }
|
|
226
|
+
if (k === 'new') { snap(); if (st.mode === 'chart') st.c = chartFrom(st.c && st.c.measure); else if (st.mode === 'rep') { st.r = REP.blankReport(); st.h.rep = []; } else st.d = blank(); st.pop = null; draw(); return; }
|
|
227
|
+
if (st.mode === 'rep') {
|
|
228
|
+
if (k === 'set') { if (st.r.kind !== 'new') return; snap(); REP.set(x, y || ''); st.pop = null; draw(); return; }
|
|
229
|
+
if (k === 'rsec') { REP.leaveOut(x); return; }
|
|
230
|
+
if (k === 'say') { REP.focusInput(a.slice(1).join('|')); return; }
|
|
231
|
+
if (k === 'libr') { const R = ((P.M.reports || {}).setups || []).find((q) => q.id === x); if (!R || !R.fromWork) return; st.r = REP.setupReport(R); st.h.rep = []; st.pop = null; st.lib = false; draw(); }
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
217
234
|
if (st.mode === 'chart') {
|
|
218
235
|
if (k === 'set') { snap(); setChart(x, y || ''); st.pop = null; draw(); return; }
|
|
219
236
|
if (k === 'libm') { snap(); st.c = chartFrom(x); st.pop = null; draw(); return; }
|
|
@@ -230,7 +247,7 @@ function act(a) {
|
|
|
230
247
|
let typed = false; // one undo step per text field edit, not per key
|
|
231
248
|
function onInput(e) {
|
|
232
249
|
const f = e.target.dataset && e.target.dataset.stf; if (!f) return;
|
|
233
|
-
const o = draft(); if (!o) return;
|
|
250
|
+
const o = draft(); if (!o || (st.mode === 'rep' && o.kind !== 'new')) return;
|
|
234
251
|
let v = e.target.value;
|
|
235
252
|
if (f === 'target') { const t = v.replace(/[^0-9.-]/g, ''); if (t !== v) { v = t; e.target.value = t; } }
|
|
236
253
|
if (!typed) { snap(); typed = true; }
|
|
@@ -286,13 +303,15 @@ async function removeChart() {
|
|
|
286
303
|
/* ── the conversation: the phrases the Studio understands. A turn changes the draft only; it writes nothing and starts no agent. ── */
|
|
287
304
|
const HELP = 'I understand: add or remove a measure by its name, move a measure up, down or first, call it something, it is for something, make it the main dashboard (or not), undo, and start a new one.';
|
|
288
305
|
const HELPC = 'I understand: a measure by its name, a form (line, bars, number, meter), the last N readings or all of them, target N or no target, lower or higher is better, call it something, note something, add it to a dashboard, a question, undo, and why.';
|
|
289
|
-
const help = () => (st.mode === 'chart' ? HELPC : HELP);
|
|
306
|
+
const help = () => (st.mode === 'chart' ? HELPC : st.mode === 'rep' ? REP.help() : HELP);
|
|
290
307
|
const clean = (s) => s.trim().replace(/^["']|["']$/g, '').replace(/[.\s]+$/, '').trim();
|
|
291
308
|
function hits(low, L) { return (L || measures()).map((m) => ({ m, i: low.indexOf(m.title.toLowerCase()) })).filter((x) => x.i >= 0 && x.m.title).sort((a, b) => a.i - b.i || b.m.title.length - a.m.title.length); }
|
|
292
309
|
function command(text) {
|
|
293
310
|
const t = text.trim(), low = t.toLowerCase(), d = st.d, said = [];
|
|
311
|
+
if (/^undo\b/.test(low) && st.mode === 'rep' && st.r.kind === 'setup') return REP.undoSetup() || 'I changed nothing. There is no earlier version to go back to.';
|
|
294
312
|
if (/^undo\b/.test(low)) return undo() ? (st.pop = null, 'Done: one step undone.') : 'I changed nothing. There is nothing to undo.';
|
|
295
313
|
if (st.mode === 'chart') return chartCommand(t, low);
|
|
314
|
+
if (st.mode === 'rep') return REP.command(t, low);
|
|
296
315
|
if (/\b(start (a )?new|new dashboard|start over)\b/.test(low)) { snap(); st.d = blank(); return 'Done: a new, empty dashboard. Name it and say what it is for.'; }
|
|
297
316
|
const before = JSON.stringify(d); snap();
|
|
298
317
|
const nm = t.match(/(?:call it|name it|rename it to|rename it|called|named)\s+(.+?)(?=,|;|\s+and\s+(?:it|make|add|remove|for)\b|$)/i);
|
|
@@ -362,23 +381,35 @@ function onSay(e) {
|
|
|
362
381
|
e.preventDefault(); e.stopPropagation();
|
|
363
382
|
const inp = $('#stIn'), text = inp.value.trim(); if (!text) return;
|
|
364
383
|
inp.value = ''; const answer = command(text);
|
|
365
|
-
const s = $('#dBody .stream');
|
|
384
|
+
const s = $('#dBody .stream');
|
|
385
|
+
if (answer && typeof answer.then === 'function') {
|
|
386
|
+
// a structure turn: PMOS works, then its own answer replaces the working line
|
|
387
|
+
if (s) { s.insertAdjacentHTML('beforeend', turnU(text) + turnA(ptx('PMOS is working on it.'))); s.scrollTop = s.scrollHeight; }
|
|
388
|
+
const mine = s && s.lastElementChild;
|
|
389
|
+
draw();
|
|
390
|
+
answer.then((a) => { if (mine && mine.isConnected) mine.outerHTML = turnA(ptx(a)); else if (s) s.insertAdjacentHTML('beforeend', turnA(ptx(a))); if (s) s.scrollTop = s.scrollHeight; draw(); });
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (s) { s.insertAdjacentHTML('beforeend', turnU(text) + turnA(ptx(answer))); s.scrollTop = s.scrollHeight; }
|
|
366
394
|
draw();
|
|
367
395
|
}
|
|
368
396
|
|
|
369
397
|
/* ── opening ── */
|
|
370
398
|
export function openStudio(p) {
|
|
371
399
|
P = p; typed = false;
|
|
372
|
-
const D = p.D || null, C = p.C || null, mode = p.mode === 'chart'
|
|
373
|
-
st = { mode, d: D ? { id: D.id, name: D.name, use: D.purpose || '', charts: D.charts.slice(), main: !!D.main } : blank(), c: C ? chartSaved(C) : chartFrom(null), h: { dash: [], chart: [] }, pop: null, more: false, lib: mode === 'dash' && !D, ck: false, msg: '', armed: false, busy: false };
|
|
400
|
+
const D = p.D || null, C = p.C || null, Rp = p.R || null, mode = p.mode === 'chart' || p.mode === 'rep' ? p.mode : 'dash';
|
|
401
|
+
st = { mode, d: D ? { id: D.id, name: D.name, use: D.purpose || '', charts: D.charts.slice(), main: !!D.main } : blank(), c: C ? chartSaved(C) : chartFrom(null), r: null, h: { dash: [], chart: [], rep: [] }, pop: null, more: false, lib: mode === 'dash' && !D, ck: false, msg: '', armed: false, busy: false };
|
|
402
|
+
if (mode === 'rep') st.r = Rp ? REP.setupReport(Rp) : REP.blankReport();
|
|
374
403
|
const board = p.M.board.name || 'this board';
|
|
375
|
-
const say = mode === '
|
|
404
|
+
const say = mode === 'rep'
|
|
405
|
+
? (Rp ? 'This is "' + Rp.name + '". ' + REP.help() : 'Say what the report answers and who reads it. I set the title, format, schedule and source from what you say, or use the brief. A new report has a fixed set of sections; you shape them once it is set up. Nothing is set up until you press Set it up.')
|
|
406
|
+
: mode === 'chart'
|
|
376
407
|
? (C ? 'This is "' + C.title + '". Tell me what to change: the form, the range, the target, or a new question. Nothing is saved until you press Save.'
|
|
377
408
|
: st.c ? 'I started from ' + titleOf(st.c.measure) + '. Tell me what the chart should answer, or pick another measure. I choose the form from the question and say why. Nothing is saved until you press Save.'
|
|
378
409
|
: 'No measure of this board has two readings yet, so there is nothing to chart.')
|
|
379
410
|
: D ? 'This is "' + D.name + '". Tell me what to change: measures to add or remove, a new purpose, or make it the main dashboard. Nothing is saved until you press Save.'
|
|
380
411
|
: 'Name the dashboard and say what it is for. Then add measures from the library, or tell me which. Nothing is saved until you press Save.';
|
|
381
|
-
openDlg({ eye: 'Insight Studio · ' + board, title: 'Insight Studio', sub: 'Make a chart or a
|
|
412
|
+
openDlg({ eye: 'Insight Studio · ' + board, title: 'Insight Studio', sub: 'Make a chart, a dashboard or a report from ' + board + '. Say it, or use the brief.', stream: turnA(ptx(say)), noteKey: null, pane: canvasHtml(), label: 'Insight Studio' });
|
|
382
413
|
$('#dlg').classList.add('stud');
|
|
383
414
|
$('#askF').hidden = true; const an = $('#askNote'); if (an) an.hidden = true;
|
|
384
415
|
$('#dBody').insertAdjacentHTML('beforeend', `<form class="askbar" id="stF"><input id="stIn" placeholder="Say what to change" maxlength="400" autocomplete="off" aria-label="Say what to change"><button type="submit" aria-label="Send" title="Send">${ICO('<path d="M5 12h14M13 6l6 6-6 6"/>')}</button></form><p class="fine2" id="stHelp"></p>`);
|
|
@@ -386,6 +417,8 @@ export function openStudio(p) {
|
|
|
386
417
|
if (innerWidth >= 1000) setFull(true);
|
|
387
418
|
draw();
|
|
388
419
|
}
|
|
420
|
+
REP.useStudio({ get st() { return st; }, get P() { return P; }, chip: (k, l, v) => chip(k, l, v), opt: (...a) => opt(...a), field: (...a) => field(...a), draw: (x) => draw(x), snap: () => snap(),
|
|
421
|
+
done: (msg) => { closeDlg(); toast(msg); P.reportsChanged(); } });
|
|
389
422
|
/* The Studio's presses. The dialog is shared, so each listener first asks whether the Studio is what it holds. */
|
|
390
423
|
const inStudio = (e) => $('#dlg').classList.contains('stud') && $('#dlg').classList.contains('on') && e.target.closest('#oMain');
|
|
391
424
|
document.addEventListener('click', (e) => { if (!inStudio(e)) return; const t = e.target.closest('[data-st]'); if (t && !t.disabled) act(t.dataset.st.split('|')); });
|
|
@@ -928,6 +928,13 @@ a.round{color:inherit;text-decoration:none}
|
|
|
928
928
|
.mnote{margin:6px 0 0 4px;font-size:12.5px;color:var(--ink-2)}
|
|
929
929
|
.mt1 .mwhy{font-size:12px;color:var(--ink-3);margin-top:4px}
|
|
930
930
|
.ntf .lk+.lk{margin-left:4px}
|
|
931
|
+
/* ── Insight Studio, Report mode (initiative premium-studio-report): the report's sections in the preview ── */
|
|
932
|
+
.stsec{padding:10px 0;border-top:1px solid var(--hair)}
|
|
933
|
+
.stsec:first-of-type{margin-top:12px}
|
|
934
|
+
.stsec h4{margin:0;font-size:14.5px;font-weight:650;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
935
|
+
.stsec .mut{margin:3px 0 0;font-size:13px;line-height:1.4}
|
|
936
|
+
.stlc small{font-size:12px;color:var(--ink-3);white-space:nowrap;align-self:center}
|
|
937
|
+
.stlc button{font-size:13px;font-weight:600}
|
|
931
938
|
/* ── initiative page (initiative briefing-premium-initiative) ── */
|
|
932
939
|
.ckr.current i{background:var(--ember)}
|
|
933
940
|
.ckr.done i{background:var(--ok)}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-studio-report: the Insight Studio's Report mode, setting up a report and shaping a set-up one, against the real server on a scratch repository with a stub claude for the structure job.",
|
|
3
|
+
"seconds": {
|
|
4
|
+
"premium-studio-report-test.js": 60
|
|
5
|
+
},
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-studio-report-test.js"
|
|
8
|
+
]
|
|
9
|
+
}
|