create-pmos 0.271.0 → 0.273.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-calendar-3-test.js +3 -1
- package/workspace/briefing-premium-insights-test.js +4 -3
- package/workspace/guide/briefing-premium.md +5 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-report-read-test.js +206 -0
- package/workspace/premium-studio-report-test.js +203 -0
- package/workspace/public/pm/premium-insights.js +22 -7
- package/workspace/public/pm/premium-report-print.css +9 -0
- package/workspace/public/pm/premium-report-read.js +358 -0
- 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 +67 -0
- package/workspace/public/premium-insights.html +1 -1
- package/workspace/test-lists/premium-report-read.json +9 -0
- package/workspace/test-lists/premium-studio-report.json +9 -0
|
@@ -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,73 @@ 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}
|
|
938
|
+
/* ── a report read on the page (initiative premium-report-read): the deck, the page, the menus, the design row and Present. From the mockup's report sheet ── */
|
|
939
|
+
#dlg.rdrd #askF,#dlg.rdrd #askNote{display:none}
|
|
940
|
+
.rdr{display:grid;gap:12px;min-width:0}
|
|
941
|
+
.rdbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
942
|
+
.rdvw button{min-height:44px}
|
|
943
|
+
.rdvw button[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
|
|
944
|
+
.dsvw{position:relative;z-index:40}
|
|
945
|
+
.dsvb{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:0 12px 0 14px;border-radius:10px;background:var(--well);font:600 12.5px var(--mono);color:var(--ink)}
|
|
946
|
+
.dsvb svg{width:15px;height:15px}
|
|
947
|
+
.dsvb:hover{background:color-mix(in oklab,var(--ink) 9%,transparent)}
|
|
948
|
+
.dsmn{position:absolute;z-index:30;left:0;top:48px;min-width:min(290px,80vw);padding:6px;border-radius:14px;background:var(--card-solid);box-shadow:0 18px 44px -12px rgba(20,22,31,.35),0 0 0 1px var(--hair);display:grid;gap:2px}
|
|
949
|
+
.dsmn a,.dsmn button{display:flex;align-items:flex-start;gap:10px;min-height:44px;padding:9px 12px;border-radius:9px;font:600 13px var(--mono);color:var(--ink-2);text-align:left;text-decoration:none}
|
|
950
|
+
.dsmn a:hover,.dsmn button:hover{background:var(--well);color:var(--ink)}
|
|
951
|
+
.dsmn svg{width:15px;height:15px;flex:none;margin-top:2px}
|
|
952
|
+
.rpm .label{margin:8px 12px 2px}
|
|
953
|
+
.rpm small{display:block;font:400 12px/1.35 var(--sans);color:var(--ink-3);margin-top:2px}
|
|
954
|
+
.rpmn{margin:6px 12px 8px!important;font-size:12px}
|
|
955
|
+
.rdsrc{margin:0}
|
|
956
|
+
.rdz{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 14px;border-radius:14px;background:var(--well)}
|
|
957
|
+
.rdz .label{margin:0}
|
|
958
|
+
.rdz .dmcta{min-height:44px;padding:0 14px;font-size:12.5px}
|
|
959
|
+
.rdz .s{display:inline-flex;align-items:center;gap:5px}
|
|
960
|
+
.rdz .s svg{width:14px;height:14px}
|
|
961
|
+
.rdz .dlink{min-height:44px}
|
|
962
|
+
.rdv{display:inline-flex;gap:4px;flex-wrap:wrap}
|
|
963
|
+
.rdv button{min-width:44px;min-height:44px;padding:0 12px;border-radius:999px;font:650 12px var(--mono);background:var(--card-solid);color:var(--ink-2);box-shadow:inset 0 0 0 1px var(--hair)}
|
|
964
|
+
.rdv button[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
|
|
965
|
+
.rdv button:disabled{opacity:.5}
|
|
966
|
+
.rds2{font-size:12.5px;color:var(--ink-2);flex:1 1 160px}
|
|
967
|
+
.rds2 em{font-style:normal;font-weight:650;color:var(--ink)}
|
|
968
|
+
.rdk{--acc:var(--ember);display:grid;gap:4px;min-width:0}
|
|
969
|
+
.rds{container-type:inline-size;aspect-ratio:16/9;background:var(--card-solid);border-radius:18px;box-shadow:inset 0 0 0 1px var(--hair);border-top:6px solid var(--acc);padding:5cqw 6cqw;display:grid;align-content:center;gap:2.2cqw;overflow:hidden;box-sizing:border-box}
|
|
970
|
+
.rds h3{margin:0;font-size:4.4cqw;line-height:1.15;letter-spacing:-.015em}
|
|
971
|
+
.rds p{margin:0;font-size:2.6cqw;line-height:1.45;color:var(--ink-2)}
|
|
972
|
+
.rds ul{margin:0;padding-left:3.2cqw;display:grid;gap:1.4cqw;font-size:2.7cqw;line-height:1.4}
|
|
973
|
+
.rds li::marker{color:var(--acc)}
|
|
974
|
+
.rds.title{background:var(--solid);color:var(--on-solid);border-top-color:var(--acc)}
|
|
975
|
+
.rds.title h3{font-size:6.4cqw}
|
|
976
|
+
.rds.title p{color:color-mix(in oklab,var(--on-solid) 78%,transparent);font-size:3cqw}
|
|
977
|
+
.rdbig:focus-visible{outline:2px solid var(--ink);outline-offset:3px;border-radius:18px}
|
|
978
|
+
.rdfc{position:relative;width:100%;aspect-ratio:16/9;overflow:hidden;border-radius:18px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair)}
|
|
979
|
+
.rdfc>.rdif{position:absolute;top:0;left:0;width:1280px;height:720px;border:0;transform:scale(var(--rp-scale,.5));transform-origin:top left;pointer-events:none}
|
|
980
|
+
.rdpf>.rdif{display:block;width:100%;height:70vh;border:0;border-radius:14px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair)}
|
|
981
|
+
.rdnv{display:flex;align-items:center;justify-content:center;gap:14px;margin:10px 0 6px;font:600 12.5px var(--mono);color:var(--ink-2)}
|
|
982
|
+
.rdnv button,.rdpn button{width:44px;height:44px;border-radius:50%;background:var(--well);display:grid;place-items:center;color:var(--ink)}
|
|
983
|
+
.rdnv button:disabled,.rdpn button:disabled{opacity:.35}
|
|
984
|
+
.rdnv svg,.rdpn svg{width:18px;height:18px}
|
|
985
|
+
.rdt{display:flex;gap:8px;overflow-x:auto;padding:4px 2px 8px;scrollbar-width:thin}
|
|
986
|
+
.rdt button{flex:0 0 118px;display:grid;gap:4px;text-align:left;padding:8px 10px;border-radius:12px;background:var(--well);box-shadow:inset 0 0 0 1px var(--hair);min-height:56px}
|
|
987
|
+
.rdt button[aria-current="true"]{box-shadow:inset 0 0 0 2px var(--ember);background:var(--card-solid)}
|
|
988
|
+
.rdt span{font-size:12px;font-weight:600;line-height:1.25;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
|
|
989
|
+
.rdt i{font:650 10.5px var(--mono);font-style:normal;color:var(--ink-3)}
|
|
990
|
+
.rdpg h2{margin:0 0 8px;font-size:22px;letter-spacing:-.02em}
|
|
991
|
+
.rdpg ul{padding-left:20px}
|
|
992
|
+
.rdcon{margin:0}
|
|
993
|
+
.rdpres{position:fixed;inset:0;z-index:1000;background:var(--solid);display:grid;grid-template-rows:minmax(0,1fr) auto;gap:12px;padding:24px;box-sizing:border-box}
|
|
994
|
+
.rdpres:focus{outline:none}
|
|
995
|
+
.rdpbox{display:grid;place-items:center;min-height:0}
|
|
996
|
+
.rdpbox>.rds,.rdpbox>.rdfc{width:min(100%,calc((100vh - 120px) * 16 / 9))}
|
|
997
|
+
.rdpn{display:flex;align-items:center;justify-content:center;gap:14px;font:600 12.5px var(--mono);color:var(--on-solid)}
|
|
931
998
|
/* ── initiative page (initiative briefing-premium-initiative) ── */
|
|
932
999
|
.ckr.current i{background:var(--ember)}
|
|
933
1000
|
.ckr.done i{background:var(--ok)}
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
</section>
|
|
58
58
|
</aside>
|
|
59
59
|
</div>
|
|
60
|
-
<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
|
|
60
|
+
<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 or a chart in the workspace's state folder, a report setup, request or dismissal in the report ledger, or a report's look in its design folder. Left out: 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>
|
|
61
61
|
</main>
|
|
62
62
|
<noscript>This page needs JavaScript.</noscript>
|
|
63
63
|
<script type="module" src="/pm/premium-insights.js"></script>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-report-read: a report document read on the premium Insights page (deck, page, Present, download, print) and its look (samples, design versions, This is it), against the real server on a scratch repository with a stub claude for the report-design job.",
|
|
3
|
+
"seconds": {
|
|
4
|
+
"premium-report-read-test.js": 60
|
|
5
|
+
},
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-report-read-test.js"
|
|
8
|
+
]
|
|
9
|
+
}
|