create-pmos 0.268.0 → 0.269.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 +13 -9
- package/workspace/briefing-premium-test.js +26 -0
- package/workspace/guide/briefing-premium.md +3 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-studio-test.js +156 -0
- package/workspace/public/pm/premium-insights.js +3 -45
- package/workspace/public/pm/premium-shell.js +99 -0
- package/workspace/public/pm/premium-studio.js +217 -0
- package/workspace/public/pm/premium.css +96 -0
- package/workspace/public/pm/premium.js +2 -1
- package/workspace/test-lists/premium-studio.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.269.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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T12:16:13Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T12:16:13Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T12:16:13Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -155,20 +155,23 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
155
155
|
const qt = (sel) => q.evaluate((x) => (document.querySelector(x) || {}).textContent || '', sel);
|
|
156
156
|
const last = () => sent[sent.length - 1] || [null, {}];
|
|
157
157
|
const dlgOn = () => until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
|
|
158
|
-
const shut = async () => { await q.keyboard.press('Escape'); await until(() => q.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))); };
|
|
158
|
+
const shut = async () => { for (let i = 0; i < 2 && await q.evaluate(() => document.querySelector('#dlg').classList.contains('on')); i++) { await q.keyboard.press('Escape'); await sleep(150); } await until(() => q.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))); }; // a full-screen dialog leaves full screen on the first Escape
|
|
159
159
|
await q.click('#dashTabs [data-d="pd-1"]'); await sleep(200);
|
|
160
160
|
const sv = await q.evaluate(() => ({ tiles: [...document.querySelectorAll('#dashBody .mch .mlab')].map((e) => e.firstChild.textContent), gone: [...document.querySelectorAll('#dashBody .dplist .nempty')].map((e) => e.textContent.replace(/\s+/g, ' ')), bar: document.querySelector('#dashBar').textContent }));
|
|
161
161
|
ok('R1 a saved dashboard draws its charts in its order and says which chart is gone, in its place', sv.tiles.join() === 'Partner activation,Time to first call' && sv.gone.length === 1 && /krm-gone.*No KR metric record is called krm-gone/.test(sv.gone[0]) && /Main dashboard\..*Monday partner review/.test(sv.bar), JSON.stringify(sv));
|
|
162
162
|
await q.click('#pdEdit'); await dlgOn();
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
const chipv = (k) => q.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
|
|
164
|
+
await q.click('#oMain [data-st="chip|charts"]');
|
|
165
|
+
const ed = await q.evaluate(() => ({ eye: document.querySelector('#dEye').textContent, rows: [...document.querySelectorAll('#stTr .sul li > span:first-child')].map((b) => b.childNodes[0].textContent) }));
|
|
166
|
+
ok('R2 Edit opens the Studio with the name, Main and the charts in order', /^Insight Studio · /.test(ed.eye) && await chipv('name') === 'Weekly partner review' && await chipv('main') === 'Yes' && ed.rows.join() === 'Partner activation,Time to first call,krm-gone', JSON.stringify(ed));
|
|
167
|
+
await q.click('#stTr [data-st="mv|1|-1"]'); await q.click('#stTr [data-st="rm|2"]'); await q.click('#oMain [data-st="lib"]'); await q.click('#stLb [data-st="libc|krm-up"]');
|
|
168
|
+
await q.click('#oMain [data-st="chip|name"]'); await q.fill('#stI', 'Monday review'); await q.click('#oMain [data-st="save"]'); await sleep(400);
|
|
166
169
|
ok('R2 Save posts the dashboard with the new order, name and Main to the one save route', last()[0] === '/api/premium-dashboards/save' && JSON.stringify(last()[1]) === JSON.stringify({ ws: 'w1', board: 'w1', id: 'pd-1', name: 'Monday review', purpose: 'The measures the Monday partner review reads.', charts: ['krm-ttfc', 'krm-act', 'krm-up'], main: true }), JSON.stringify(last()));
|
|
167
|
-
await q.click('#pdNew'); await dlgOn(); await q.click('#
|
|
168
|
-
ok('R2 a new dashboard without a name says so and posts nothing', /Give the dashboard a name/.test(await qt('#
|
|
170
|
+
await q.click('#pdNew'); await dlgOn(); await q.click('#oMain [data-st="save"]'); await sleep(200);
|
|
171
|
+
ok('R2 a new dashboard without a name says so and posts nothing', /Give the dashboard a name/.test(await qt('#stMsg')) && last()[1].id === 'pd-1');
|
|
169
172
|
answer = () => ({ ok: false, error: '“Weekly partner review” is already a dashboard on this board.' });
|
|
170
|
-
await q.fill('#
|
|
171
|
-
ok('R7 the server\'s refusal is shown in words and the dialog stays open', /already a dashboard on this board/.test(await qt('#
|
|
173
|
+
await q.click('#oMain [data-st="chip|name"]'); await q.fill('#stI', 'Weekly partner review'); await q.click('#oMain [data-st="chip|use"]'); await q.fill('#stI', 'x'); await q.click('#oMain [data-st="save"]'); await sleep(300);
|
|
174
|
+
ok('R7 the server\'s refusal is shown in words and the dialog stays open', /already a dashboard on this board/.test(await qt('#stMsg')) && await q.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !document.querySelector('#oMain [data-st="save"]').disabled));
|
|
172
175
|
answer = (u, b) => ({ ok: true, dashboard: { id: b.id || 'pd-9' }, dashboards: [], setup: {}, drafted: { slot: '2026-10-23', path: 'planning/reports/release-readiness/2026-10-23.md' } });
|
|
173
176
|
await shut();
|
|
174
177
|
await q.click('#dashTabs [data-d="all"]'); await q.locator('#dashBody [data-open="ins:krm-up"]').click(); await dlgOn(); await q.click('#oMain [data-pdsw="pd-1"]'); await sleep(300);
|
|
@@ -253,7 +256,8 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
253
256
|
ok('E7 the real page draws that chart with the record\'s numbers and no script error', await until(() => pg.evaluate(() => { const t = document.querySelector('#dashBody .mch'); return !!t && t.querySelector('.mval').textContent === '30%' && /Partner activation/.test(t.textContent); }), 20000) && errs.length === 0, errs.join(' | '));
|
|
254
257
|
/* briefing-premium-reports against the real server: New dashboard, Save, the switch, then the ledger answers it back */
|
|
255
258
|
await pg.click('#pdNew'); await until(() => pg.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
|
|
256
|
-
await pg.
|
|
259
|
+
await pg.click('#oMain [data-st="chip|name"]'); await pg.fill('#stI', 'Partner review'); await pg.click('#oMain [data-st="chip|use"]'); await pg.fill('#stI', 'The Monday partner review.');
|
|
260
|
+
await pg.click('#stLb [data-st="libc|' + m.charts[0].id + '"]'); await pg.click('#oMain [data-st="chip|main"]'); await pg.click('#stTr [data-st="set|main|1"]'); await pg.click('#oMain [data-st="save"]');
|
|
257
261
|
ok('E8 a dashboard made on the real page is saved and drawn as the main one', await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && [...document.querySelectorAll('#dashTabs button')].some((b) => b.textContent === 'Partner review · Main' && b.getAttribute('aria-pressed') === 'true') && document.querySelectorAll('#dashBody .mch').length === 1), 10000), await pg.evaluate(() => (document.querySelector('#pdM') || {}).textContent + ' / ' + [...document.querySelectorAll('#dashTabs button')].map((b) => b.textContent).join()));
|
|
258
262
|
const j2 = await (await fetch(base2 + '/api/insights-premium')).json(), d2 = j2.model.dashboards.find((d) => d.saved);
|
|
259
263
|
ok('E8 the model reads it back from the ledger', !!d2 && d2.name === 'Partner review' && d2.main && d2.charts.join() === m.charts[0].id, JSON.stringify(d2));
|
|
@@ -78,6 +78,32 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
78
78
|
ok('R1 the console stays the default page', /id="c3-root"/.test(def) && !/class="rail/.test(def));
|
|
79
79
|
{ const tc = await p.evaluate(() => { const a = document.querySelector('#toConsole'); if (!a) return null; const r = a.getBoundingClientRect(); return { href: a.getAttribute('href'), label: a.getAttribute('aria-label'), w: Math.round(r.width), h: Math.round(r.height), tab: a.tabIndex }; }); ok('R1 the header links to the console (premium-console-link)', tc && tc.href === '/c3.html' && tc.label === 'Open the console' && tc.w >= 44 && tc.h >= 44 && tc.tab === 0, JSON.stringify(tc)); }
|
|
80
80
|
|
|
81
|
+
/* premium-search-bell: the Search button, the bell and Ctrl K, from the shared shell */
|
|
82
|
+
{
|
|
83
|
+
await p.route('**/api/boards/backlog*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, ws: 'w1', board: 'b1', rows: [{ id: 'sb-alpha', title: 'Alpha launch plan', lane: 'feature', stage: 'Build' }] }) }));
|
|
84
|
+
await p.route('**/api/core-docs*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, scope: { name: 'PMOS' }, docs: [{ key: 'roadmap', title: 'Roadmap' }] }) }));
|
|
85
|
+
await p.route('**/api/sessions', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ sessions: [{ id: 's1', name: 'Fix the footer', state: 'idle', cwd: '.' }, { id: 's2', name: 'Nightly run', state: 'idle', automatic: true }] }) }));
|
|
86
|
+
const sb = await until(() => p.evaluate(() => { const s = document.querySelector('#pvSearch'), b = document.querySelector('#pvBell'), g = document.querySelector('#pvBdg'); if (!s || !b || !g || g.hidden) return null; const rs = s.getBoundingClientRect(), rb = b.getBoundingClientRect(); return { sw: Math.round(rs.width), sh: Math.round(rs.height), bw: Math.round(rb.width), bh: Math.round(rb.height), n: g.textContent, lab: b.getAttribute('aria-label') }; }), 8000);
|
|
87
|
+
const want = MODEL.list.count;
|
|
88
|
+
ok('SB1 the header has a Search button and a bell, 44 px, and the bell counts what the Briefing lists', sb && sb.sw >= 44 && sb.sh >= 44 && sb.bw >= 44 && sb.bh >= 44 && sb.n === String(want) && sb.lab === 'Needs you: ' + want, JSON.stringify(sb));
|
|
89
|
+
await p.keyboard.press('Control+k');
|
|
90
|
+
const pal = await until(() => p.evaluate(() => { const o = document.querySelector('#pvOv'); return o && !o.hidden && document.activeElement && document.activeElement.id === 'pvQ' ? { rail: document.querySelector('.rail').inert, groups: [...document.querySelectorAll('#pvList .pv-grp')].map((x) => x.textContent) } : null; }), 6000);
|
|
91
|
+
ok('SB2 Ctrl K opens the search with the box focused and the page behind it inert', pal && pal.rail === true, JSON.stringify(pal));
|
|
92
|
+
await p.keyboard.type('alpha');
|
|
93
|
+
const hit = await until(() => p.evaluate(() => { const r = [...document.querySelectorAll('#pvList .pv-row b')].map((x) => x.textContent); return r.length === 1 && r[0] === 'Alpha launch plan' ? r : null; }), 6000);
|
|
94
|
+
ok('SB3 typing narrows the results to a record read from the board', !!hit);
|
|
95
|
+
await p.keyboard.press('Control+a'); await p.keyboard.type('fix');
|
|
96
|
+
const ses = await until(() => p.evaluate(() => [...document.querySelectorAll('#pvList .pv-row b')].map((x) => x.textContent).join() === 'Fix the footer' ? 1 : 0), 6000);
|
|
97
|
+
ok('SB4 sessions are listed and automatic ones are left out', !!ses);
|
|
98
|
+
await p.keyboard.press('Escape');
|
|
99
|
+
const closed = await until(() => p.evaluate(() => document.querySelector('#pvOv').hidden && !document.querySelector('.rail').inert && document.activeElement.id === 'pvSearch'), 4000);
|
|
100
|
+
ok('SB5 Escape closes it and puts the focus back on the button', !!closed);
|
|
101
|
+
await p.click('#pvBell');
|
|
102
|
+
const rows = await until(() => p.evaluate(() => { const o = document.querySelector('#pvOv'); return !o.hidden ? document.querySelectorAll('#pvList .pv-row').length : 0; }), 6000);
|
|
103
|
+
ok('SB6 the bell lists the Briefing rows and a row opens the Briefing', rows === MODEL.list.rows.length, String(rows));
|
|
104
|
+
await p.keyboard.press('Escape');
|
|
105
|
+
ok('SB7 search and the bell only read: no POST left the page', !A.reqs.some((x) => x.startsWith('POST ')));
|
|
106
|
+
}
|
|
81
107
|
/* premium-settings: the dialog holds Workspaces and Connectors only; each press goes to its existing route */
|
|
82
108
|
{ const bt = await p.evaluate(() => { const b = document.querySelector('#settingsBtn'); if (!b) return null; const r = b.getBoundingClientRect(); return { label: b.getAttribute('aria-label'), w: Math.round(r.width), h: Math.round(r.height) }; });
|
|
83
109
|
ok('S1 the header has a Settings button of at least 44 px', bt && bt.label === 'Settings' && bt.w >= 44 && bt.h >= 44, JSON.stringify(bt));
|
|
@@ -13,7 +13,7 @@ A rail on the left names four places: Briefing, My work, Board and Insights. Eac
|
|
|
13
13
|
|
|
14
14
|
Every premium page has an **Open the console** button beside the theme button. It opens the console at `/c3.html`, for the places premium does not have yet (agent sessions, Calendar, Settings). In the console, the More menu has **Open premium**, which opens this page.
|
|
15
15
|
|
|
16
|
-
Every premium page has a **Settings** button beside it. It opens one dialog with two sections. **Workspaces** lists the repositories PMOS works in, with Add (a folder path) and Remove; Remove forgets the address and never deletes the folder, and a refusal shows the server's reason. **Connectors** has an On/Off switch for each source the Briefing reads. Each press saves that one record. Every other setting runs on a default and stays in the console; the dialog links to it. Remove needs the page's launch nonce, so an agent session cannot call it.
|
|
16
|
+
Every premium page also has a **Search** button and a bell. Ctrl K (or `/`) opens the search over places, initiatives, documents and your running sessions; Enter opens the result. The bell counts the same things the Briefing lists under what you need to do, and a press opens the Briefing. Both only read; neither changes a record. Every premium page has a **Settings** button beside it. It opens one dialog with two sections. **Workspaces** lists the repositories PMOS works in, with Add (a folder path) and Remove; Remove forgets the address and never deletes the folder, and a refusal shows the server's reason. **Connectors** has an On/Off switch for each source the Briefing reads. Each press saves that one record. Every other setting runs on a default and stays in the console; the dialog links to it. Remove needs the page's launch nonce, so an agent session cannot call it.
|
|
17
17
|
|
|
18
18
|
Every premium page has an **Agent sessions** button beside the console button, with a count of the sessions running. It opens a dialog that lists each running session and background run with its note, state and start time. **Stop** asks first and says what it ends, then ends the session and closes its terminal. If the session has not exited yet, the row says so and offers Stop again. Terminals, new sessions and run questions stay in the console; the dialog links to it.
|
|
19
19
|
|
|
@@ -192,7 +192,7 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
192
192
|
|
|
193
193
|
- **Charts.** One chart for each KR metric that holds at least two readings. The line runs through the readings at their dates, so a month with no reading is a gap and not a zero. The dashed line is the metric's target. The chip is the record's own line status: on its line, behind it, or well behind it. Pressing a chart, or its Details link, opens the metric's record in the dialog with the read-only agent beside it.
|
|
194
194
|
- **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.
|
|
195
|
-
- **Make or edit a dashboard.**
|
|
195
|
+
- **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.
|
|
196
196
|
- **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.
|
|
197
197
|
- **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
|
|
198
198
|
- **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**.
|
|
@@ -200,4 +200,4 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
200
200
|
- **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**.
|
|
201
201
|
- **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.
|
|
202
202
|
|
|
203
|
-
Not built: the Insight Studio
|
|
203
|
+
Not built: the Insight Studio's Chart and Report modes, the report deck, present and print, 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.269.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.269.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-studio-test.js — the Insight Studio's Dashboard mode on the premium Insights page (initiative premium-studio-dashboard;
|
|
4
|
+
* planning/prd/premium-studio-dashboard-prd.md S1 to S10). A real server on a scratch repository whose KR metric records hold two measures with a series
|
|
5
|
+
* and one without. The real page presses the real save route:
|
|
6
|
+
* O opening · C the conversation · B the brief and tray · K the checks · U Undo · S save, edit and remove · P the POST allow-list · F floors */
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { spawn } = require('child_process');
|
|
11
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
12
|
+
const T = require('./test-run').configure({ name: 'premium-studio' });
|
|
13
|
+
|
|
14
|
+
const BASE = T.BASE;
|
|
15
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
16
|
+
const until = async (fn, ms = 20000, step = 150) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
17
|
+
const results = [];
|
|
18
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
|
|
19
|
+
let srv = null, browser = null;
|
|
20
|
+
const finish = async (code) => {
|
|
21
|
+
if (browser) await browser.close().catch(() => {});
|
|
22
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
23
|
+
T.killTmux();
|
|
24
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
25
|
+
console.log(`\n${results.length - bad}/${results.length} premium-studio assertions passed`);
|
|
26
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
27
|
+
};
|
|
28
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
29
|
+
|
|
30
|
+
/* the scratch repository: Partner activation (3 readings), Time to first call (2 readings), Lonely (1 reading, no series) */
|
|
31
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'studio-repo-'));
|
|
32
|
+
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), 'studio-state-'));
|
|
33
|
+
fs.mkdirSync(path.join(dir, 'planning', 'records'), { recursive: true });
|
|
34
|
+
const L = [
|
|
35
|
+
{ id: '1', kind: 'add', rid: 'krm-a', fields: { metric: 'Partner activation', baseline: 20, target: 50, by: '2026-12-31', pillar: 'Growth', unit: '%' } },
|
|
36
|
+
{ id: '2', kind: 'reading', rid: 'krm-a', fields: { at: '2026-07-01', value: 20 } }, { id: '3', kind: 'reading', rid: 'krm-a', fields: { at: '2026-08-01', value: 24 } }, { id: '4', kind: 'reading', rid: 'krm-a', fields: { at: '2026-10-01', value: 30 } },
|
|
37
|
+
{ id: '5', kind: 'add', rid: 'krm-t', fields: { metric: 'Time to first call', baseline: 10, target: 4, by: '2026-12-31', pillar: 'Growth', unit: ' days' } },
|
|
38
|
+
{ id: '6', kind: 'reading', rid: 'krm-t', fields: { at: '2026-08-01', value: 9 } }, { id: '7', kind: 'reading', rid: 'krm-t', fields: { at: '2026-10-01', value: 7 } },
|
|
39
|
+
{ id: '8', kind: 'add', rid: 'krm-l', fields: { metric: 'Lonely', baseline: 1, target: 2, by: '2026-12-31' } }, { id: '9', kind: 'reading', rid: 'krm-l', fields: { at: '2026-10-01', value: 1 } },
|
|
40
|
+
];
|
|
41
|
+
fs.writeFileSync(path.join(dir, 'planning', 'records', 'kr-metrics.jsonl'), L.map((x) => JSON.stringify(x)).join('\n') + '\n');
|
|
42
|
+
const saved = async () => { const j = await (await fetch(BASE + '/api/insights-premium')).json(); return (j.model && j.model.dashboards || []).filter((d) => d.saved); };
|
|
43
|
+
|
|
44
|
+
(async () => {
|
|
45
|
+
const exe = findBrowser();
|
|
46
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
47
|
+
let chromium;
|
|
48
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
49
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: dir, PMOS_STATE_DIR: stateDir }) });
|
|
50
|
+
await T.waitForServer(BASE);
|
|
51
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
52
|
+
|
|
53
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p = await ctx.newPage(), errs = [], posts = [];
|
|
54
|
+
p.on('pageerror', (e) => errs.push(String(e)));
|
|
55
|
+
p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
|
|
56
|
+
await p.goto(BASE + '/premium-insights.html');
|
|
57
|
+
await until(() => p.evaluate(() => !!document.querySelector('#dashBody .mch') && !!document.querySelector('#pdNew')));
|
|
58
|
+
const say = async (t) => { await p.fill('#stIn', t); await p.press('#stIn', 'Enter'); await sleep(150); return p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; }); };
|
|
59
|
+
const chipv = (k) => p.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
|
|
60
|
+
const tiles = () => p.evaluate(() => [...document.querySelectorAll('#stPv .mch .mlab')].map((e) => e.firstChild.textContent));
|
|
61
|
+
const checksTxt = () => p.evaluate(() => (document.querySelector('#stCk .suckb b') || {}).textContent || '');
|
|
62
|
+
const tap = (sel) => p.$eval(sel, (b) => b.click());
|
|
63
|
+
const open = async (sel) => { await p.click(sel); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu'))); await sleep(300); };
|
|
64
|
+
const shut = async () => { for (let i = 0; i < 2 && await p.evaluate(() => document.querySelector('#dlg').classList.contains('on')); i++) { await p.keyboard.press('Escape'); await sleep(150); } };
|
|
65
|
+
|
|
66
|
+
/* O: New dashboard opens the Studio */
|
|
67
|
+
await open('#pdNew');
|
|
68
|
+
const o = await p.evaluate(() => ({ eye: document.querySelector('#dEye').textContent, full: document.querySelector('#dlg').classList.contains('full'), lib: [...document.querySelectorAll('#stLb .stli b')].map((b) => b.textContent), agent: getComputedStyle(document.querySelector('#askF')).display === 'none', own: !!document.querySelector('#stF') }));
|
|
69
|
+
ok('O1 New dashboard opens the Studio as the wide dialog, full screen at 1280 px', /^Insight Studio · /.test(o.eye) && o.full, JSON.stringify(o));
|
|
70
|
+
ok('O2 the library lists the three measures of the records and nothing else', o.lib.join() === 'Partner activation,Time to first call,Lonely', o.lib.join());
|
|
71
|
+
ok('O3 the agent\'s ask bar is hidden and the Studio\'s own sits in its place', o.agent && o.own);
|
|
72
|
+
ok('O4 a new draft shows Not set on Name and Purpose and 0 charts', await chipv('name') === 'Not set' && await chipv('use') === 'Not set' && await chipv('charts') === '0');
|
|
73
|
+
ok('K1 the checks start at 2 of 6 (count and repeats pass)', await checksTxt() === '2 of 6 checks pass', await checksTxt());
|
|
74
|
+
|
|
75
|
+
/* C: the conversation */
|
|
76
|
+
let a = await say('add Partner activation and Time to first call');
|
|
77
|
+
ok('C1 "add" names the measures it added and draws them', /^Done: added Partner activation, added Time to first call/.test(a) && (await tiles()).join() === 'Partner activation,Time to first call', a);
|
|
78
|
+
a = await say('call it Partner review');
|
|
79
|
+
ok('C2 "call it" sets the name chip', /^Done: named it "Partner review"/.test(a) && await chipv('name') === 'Partner review', a);
|
|
80
|
+
a = await say('it is for the Monday partner review');
|
|
81
|
+
ok('C3 "it is for" sets the purpose', await chipv('use') === 'the Monday partner review', a);
|
|
82
|
+
a = await say('make it the main dashboard');
|
|
83
|
+
ok('C4 "make it the main dashboard" sets Main, and the checks pass 6 of 6', await chipv('main') === 'Yes' && await checksTxt() === '6 of 6 checks pass', a + ' ' + await checksTxt());
|
|
84
|
+
a = await say('add Revenue per seat');
|
|
85
|
+
ok('C5 a measure the board does not have changes nothing and says so', /^I changed nothing/.test(a) && await chipv('charts') === '2', a);
|
|
86
|
+
a = await say('move Time to first call first');
|
|
87
|
+
ok('C6 "move … first" reorders the preview', (await tiles()).join() === 'Time to first call,Partner activation', a);
|
|
88
|
+
ok('C7 no turn posted anything', posts.length === 0, posts.join());
|
|
89
|
+
|
|
90
|
+
/* U: Undo */
|
|
91
|
+
await tap('#oMain [data-st="undo"]'); await sleep(150);
|
|
92
|
+
ok('U1 Undo steps back one change (the move)', (await tiles()).join() === 'Partner activation,Time to first call');
|
|
93
|
+
a = await say('undo');
|
|
94
|
+
ok('U2 "undo" in words steps back again (Main)', await chipv('main') === 'No' && /^Done: one step undone/.test(a), a);
|
|
95
|
+
|
|
96
|
+
/* B and K: the brief, the library and a check's fix */
|
|
97
|
+
await tap('#stLb [data-st="libc|krm-l"]'); await sleep(150);
|
|
98
|
+
const gone = await p.evaluate(() => [...document.querySelectorAll('#stPv .stgone')].map((e) => e.textContent).join(' | '));
|
|
99
|
+
ok('B1 a measure with no series is added, listed as not drawn with the reason, and not drawn', /Lonely has fewer than two readings, so it has no chart/.test(gone) && (await tiles()).length === 2 && await chipv('charts') === '3', gone);
|
|
100
|
+
await tap('#oMain [data-st="ck"]'); await sleep(100);
|
|
101
|
+
const fix = await p.evaluate(() => [...document.querySelectorAll('#stCk .sucl li.bad button')].map((b) => b.textContent));
|
|
102
|
+
ok('K2 the failing check (no main dashboard) offers its fix', fix.join() === 'Make it the main one', fix.join());
|
|
103
|
+
await tap('#stCk .sucl li.bad button'); await sleep(150);
|
|
104
|
+
ok('K3 the fix sets what it names', await chipv('main') === 'Yes' && await checksTxt() === '6 of 6 checks pass');
|
|
105
|
+
await tap('#oMain [data-st="chip|charts"]'); await sleep(100);
|
|
106
|
+
await tap('#stTr [data-st="rm|2"]'); await sleep(100);
|
|
107
|
+
ok('B2 the Charts tray removes a measure', await chipv('charts') === '2');
|
|
108
|
+
|
|
109
|
+
/* S: save, read back, edit, remove */
|
|
110
|
+
await tap('#oMain [data-st="save"]');
|
|
111
|
+
ok('S1 Save closes the Studio and the page draws the saved dashboard as the main one', await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && [...document.querySelectorAll('#dashTabs button')].some((b) => b.textContent === 'Partner review · Main' && b.getAttribute('aria-pressed') === 'true'))));
|
|
112
|
+
let S = await saved();
|
|
113
|
+
ok('S2 the ledger holds the name, purpose, order and Main', S.length === 1 && S[0].name === 'Partner review' && S[0].purpose === 'the Monday partner review' && S[0].charts.join() === 'krm-a,krm-t' && S[0].main, JSON.stringify(S));
|
|
114
|
+
await open('#pdEdit');
|
|
115
|
+
ok('S3 Edit opens the Studio on the saved dashboard', await chipv('name') === 'Partner review' && await chipv('main') === 'Yes' && (await tiles()).join() === 'Partner activation,Time to first call');
|
|
116
|
+
await say('move Time to first call first'); await say('remove Partner activation');
|
|
117
|
+
await tap('#oMain [data-st="save"]');
|
|
118
|
+
await until(async () => { const x = await saved(); return x.length === 1 && x[0].charts.join() === 'krm-t'; });
|
|
119
|
+
S = await saved();
|
|
120
|
+
ok('S4 an edit made in words is saved', S.length === 1 && S[0].charts.join() === 'krm-t', JSON.stringify(S));
|
|
121
|
+
await open('#pdEdit');
|
|
122
|
+
await tap('#oMain [data-st="del"]'); await sleep(100);
|
|
123
|
+
const armed = await p.evaluate(() => ({ b: document.querySelector('#oMain [data-st="del"]').textContent, m: document.querySelector('#stMsg').textContent }));
|
|
124
|
+
ok('S5 Remove asks for a second press and says what stays', armed.b === 'Press again to remove it' && /measures and their records stay/.test(armed.m), JSON.stringify(armed));
|
|
125
|
+
await tap('#oMain [data-st="del"]');
|
|
126
|
+
await until(async () => (await saved()).length === 0);
|
|
127
|
+
ok('S6 the second press removes the dashboard', (await saved()).length === 0);
|
|
128
|
+
|
|
129
|
+
/* P: the POST allow-list and the guard */
|
|
130
|
+
ok('P1 the page posted only to the dashboard save route', posts.length === 3 && posts.every((x) => x === '/api/premium-dashboards/save'), posts.join());
|
|
131
|
+
const j = await (await fetch(BASE + '/api/insights-premium')).json(), body = JSON.stringify({ ws: j.model.board.ws, board: j.model.board.id, name: 'From an agent', purpose: 'x', charts: [] });
|
|
132
|
+
const H = await T.pressHeaders(BASE);
|
|
133
|
+
const asAgent = await fetch(BASE + '/api/premium-dashboards/save', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body }).then((x) => x.status);
|
|
134
|
+
ok('P2 an agent session is refused by the save route, unchanged', asAgent === 403, String(asAgent));
|
|
135
|
+
ok('P3 no script error', errs.length === 0, errs.join(' | '));
|
|
136
|
+
await ctx.close();
|
|
137
|
+
|
|
138
|
+
/* F: floors at 390 px, both themes */
|
|
139
|
+
for (const theme of ['light', 'dark']) {
|
|
140
|
+
const c2 = await browser.newContext({ viewport: { width: 390, height: 844 }, colorScheme: theme }), q = await c2.newPage();
|
|
141
|
+
await q.goto(BASE + '/premium-insights.html');
|
|
142
|
+
await until(() => q.evaluate(() => !!document.querySelector('#pdNew')));
|
|
143
|
+
await q.click('#pdNew'); await until(() => q.evaluate(() => !!document.querySelector('#oMain .stu'))); await sleep(400);
|
|
144
|
+
// measured once the dialog has finished opening: its rise animation scales the targets while it runs
|
|
145
|
+
const measure = () => q.evaluate(() => {
|
|
146
|
+
const sm = [...document.querySelectorAll('#oMain .stu button')].filter((b) => b.offsetParent).filter((b) => { const r = b.getBoundingClientRect(); return r.height < 44 || r.width < 44; }).map((b) => (b.dataset.st || b.textContent) + ':' + Math.round(b.getBoundingClientRect().width) + 'x' + Math.round(b.getBoundingClientRect().height));
|
|
147
|
+
const pane = document.querySelector('#dOut'); return { small: sm.length, which: sm, side: pane.scrollWidth - pane.clientWidth, doc: document.documentElement.scrollWidth - innerWidth };
|
|
148
|
+
});
|
|
149
|
+
await until(async () => (await measure()).small === 0, 4000);
|
|
150
|
+
const f = await measure();
|
|
151
|
+
ok(`F1 at 390 px (${theme}) every Studio target is 44 px or more and nothing scrolls sideways`, f.small === 0 && f.side <= 1 && f.doc <= 1, JSON.stringify(f));
|
|
152
|
+
await c2.close();
|
|
153
|
+
}
|
|
154
|
+
await shut().catch(() => {});
|
|
155
|
+
finish();
|
|
156
|
+
})().catch((e) => { console.error(e); finish(1); });
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* draft, PRD R2 to R4). Nothing else posts, and nothing is sent outward. */
|
|
7
7
|
import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb, kv } from './premium-shell.js';
|
|
8
8
|
import { pmPost } from './http.js';
|
|
9
|
+
import { openStudio } from './premium-studio.js';
|
|
9
10
|
|
|
10
11
|
let M = null; // the model
|
|
11
12
|
let dash = 'all'; // the dashboard on screen
|
|
@@ -105,52 +106,9 @@ function noSeriesHtml() {
|
|
|
105
106
|
$('#dashTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-d]'); if (!b) return; dash = b.dataset.d; drawDash(); });
|
|
106
107
|
$('#dashBar').addEventListener('click', (e) => { if (e.target.closest('#pdEdit')) openDashEdit(curDash()); else if (e.target.closest('#pdNew')) openDashEdit(null); });
|
|
107
108
|
|
|
108
|
-
/* ── a
|
|
109
|
+
/* ── a dashboard is made and edited in the Insight Studio (initiative premium-studio-dashboard). Its one press posts POST /api/premium-dashboards/save. ── */
|
|
109
110
|
async function saveDash(body) { return pmPost('/api/premium-dashboards/save', Object.assign({ ws: M.board.ws, board: M.board.id }, body)); }
|
|
110
|
-
function openDashEdit(D) {
|
|
111
|
-
const fresh = !D, ids = D ? D.charts.slice() : [];
|
|
112
|
-
const title = (id) => { const m = (M.measures || []).find((x) => x.id === id); return m ? m.title : id; };
|
|
113
|
-
const why = (id) => { const m = (M.measures || []).find((x) => x.id === id); return !m ? 'No record any more' : m.charted ? '' : 'No series yet'; };
|
|
114
|
-
const listHtml = () => ids.length ? ids.map((id, i) => `<div class="pdrow" role="listitem"><span><b>${esc(title(id))}</b>${why(id) ? `<small>${esc(why(id))}</small>` : ''}</span><span class="pdmv"><button type="button" class="round" data-mv="${i}:-1" aria-label="Move ${esc(title(id))} up" ${i ? '' : 'disabled'}>${ICO('<path d="M12 19V5M6 11l6-6 6 6"/>')}</button><button type="button" class="round" data-mv="${i}:1" aria-label="Move ${esc(title(id))} down" ${i < ids.length - 1 ? '' : 'disabled'}>${ICO('<path d="M12 5v14M6 13l6 6 6-6"/>')}</button><button type="button" class="round" data-rm="${i}" aria-label="Take ${esc(title(id))} off">${ICO('<path d="M6 6l12 12M18 6 6 18"/>')}</button></span></div>`).join('') : '<p class="note" style="margin:0">No measure yet. Add one below.</p>';
|
|
115
|
-
const addHtml = () => { const L = (M.measures || []).filter((m) => !ids.includes(m.id)); return L.length ? `<label>Add a measure<select id="pdAdd"><option value="">Choose a KR metric</option>${L.map((m) => `<option value="${esc(m.id)}">${esc(m.title)}${m.charted ? '' : ' (no series yet)'}</option>`).join('')}</select></label>` : '<p class="note" style="margin:0">Every KR metric of this workspace is on this dashboard.</p>'; };
|
|
116
|
-
const checksTxt = () => [ids.length > 6 ? 'This dashboard holds ' + ids.length + ' charts. A dashboard that serves one routine usually holds six or fewer.' : '', new Set(ids).size !== ids.length ? 'The same measure is on this dashboard twice.' : ''].filter(Boolean).join(' ');
|
|
117
|
-
const form = `<div class="addf"><p class="note" style="margin:0">A dashboard is a named list of this board's measures. It is saved in the workspace's state folder and changes nothing else: no record, no report and no console layout.</p>
|
|
118
|
-
<label>Name<input id="pdN" maxlength="60" value="${esc(D ? D.name : '')}" placeholder="For example: Weekly partner review"></label>
|
|
119
|
-
<label>What it is for<input id="pdP" maxlength="200" value="${esc(D ? D.purpose : '')}" placeholder="The routine it serves, in one line"></label>
|
|
120
|
-
<label class="pdchk"><input type="checkbox" id="pdMain" ${D && D.main ? 'checked' : ''}>Make it the main dashboard of this board</label>
|
|
121
|
-
<div><span class="label">Charts, in order</span><div class="pdlist" id="pdList" role="list">${listHtml()}</div></div>
|
|
122
|
-
<div id="pdAddW">${addHtml()}</div>
|
|
123
|
-
<p class="note pdck" id="pdCk" role="status">${esc(checksTxt())}</p>
|
|
124
|
-
<p class="note" id="pdM" role="status" style="margin:0;min-height:1.2em"></p>
|
|
125
|
-
<div class="cact"><button class="cta" id="pdGo">Save</button><button class="cta alt" id="pdNo">Cancel</button>${fresh ? '' : '<button class="cta alt" id="pdDel">Remove the dashboard</button>'}</div></div>`;
|
|
126
|
-
openDlg({ eye: (fresh ? 'New dashboard' : 'Dashboard') + ' · real data', title: fresh ? 'New dashboard' : D.name, sub: M.board.name, say: 'Name the dashboard, say what it is for and choose its measures.', stream: turnA(ptx('Name the dashboard, say what it is for and choose its measures in the order you read them. I save it in the workspace\'s state folder and change nothing else.')), noteKey: null, pane: `<article class="paper doc">${form}</article>`, label: 'Dashboard' });
|
|
127
|
-
$('#askF').hidden = true;
|
|
128
|
-
const redraw = () => { $('#pdList').innerHTML = listHtml(); $('#pdAddW').innerHTML = addHtml(); $('#pdCk').textContent = checksTxt(); };
|
|
129
|
-
let armed = false;
|
|
130
|
-
$('#oMain').onchange = (e) => { if (e.target.id === 'pdAdd' && e.target.value) { ids.push(e.target.value); redraw(); const s = $('#pdAdd'); if (s) s.focus(); } };
|
|
131
|
-
$('#oMain').onclick = async (e) => {
|
|
132
|
-
const mv = e.target.closest('[data-mv]'), rm = e.target.closest('[data-rm]');
|
|
133
|
-
if (mv) { const [i, d] = mv.dataset.mv.split(':').map(Number), j = i + d; [ids[i], ids[j]] = [ids[j], ids[i]]; redraw(); const b = $(`#pdList [data-mv="${j}:${d}"]`) || $(`#pdList [data-mv="${j}:${-d}"]`); if (b) b.focus(); return; }
|
|
134
|
-
if (rm) { ids.splice(+rm.dataset.rm, 1); redraw(); return; }
|
|
135
|
-
if (e.target.closest('#pdNo')) { closeDlg(); return; }
|
|
136
|
-
const m = $('#pdM');
|
|
137
|
-
if (e.target.closest('#pdDel')) {
|
|
138
|
-
if (!armed) { armed = true; e.target.closest('#pdDel').textContent = 'Press again to remove it'; m.textContent = 'Removing takes the dashboard off this board. The measures and their records stay.'; return; }
|
|
139
|
-
const b = e.target.closest('#pdDel'); b.disabled = true;
|
|
140
|
-
const res = await saveDash({ id: D.id, remove: true });
|
|
141
|
-
if (!res || res.ok !== true) { b.disabled = false; m.textContent = (res && res.error) || 'The dashboard could not be removed.'; return; }
|
|
142
|
-
toast('Dashboard removed. The line is saved in the workspace\'s state folder.'); dash = 'all'; closeDlg(); await load(); return;
|
|
143
|
-
}
|
|
144
|
-
if (!e.target.closest('#pdGo')) return;
|
|
145
|
-
const name = $('#pdN').value.trim(), purpose = $('#pdP').value.trim();
|
|
146
|
-
if (!name) { m.textContent = 'Give the dashboard a name.'; $('#pdN').focus(); return; }
|
|
147
|
-
if (!purpose) { m.textContent = 'Say what the dashboard is for, in one line.'; $('#pdP').focus(); return; }
|
|
148
|
-
const go = $('#pdGo'); go.disabled = true; m.textContent = 'Saving.';
|
|
149
|
-
const res = await saveDash({ id: D ? D.id : undefined, name, purpose, charts: ids, main: $('#pdMain').checked });
|
|
150
|
-
if (!res || res.ok !== true) { go.disabled = false; m.textContent = (res && res.error) || 'The dashboard could not be saved.'; return; }
|
|
151
|
-
toast('Dashboard saved in the workspace\'s state folder.'); if (res.dashboard) dash = res.dashboard.id; closeDlg(); await load();
|
|
152
|
-
};
|
|
153
|
-
}
|
|
111
|
+
function openDashEdit(D) { openStudio({ M, D, tile: tileHtml, save: saveDash, done: async (id) => { dash = id || 'all'; await load(); } }); }
|
|
154
112
|
$('#dashBody').addEventListener('click', (e) => { const o = e.target.closest('[data-open]'); if (o) openChart(byKey(o.dataset.open)); });
|
|
155
113
|
$('#dashBody').addEventListener('keydown', (e) => {
|
|
156
114
|
const t = e.target.closest && e.target.closest('.mch'); if (!t || !/^Arrow(Left|Right)$/.test(e.key)) return;
|
|
@@ -213,6 +213,105 @@ export function openAddDoc(o) {
|
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
/* ── Search (Ctrl K or "/") and the bell, in the header of every premium page (initiative premium-search-bell). Reads only; a press goes to a page. ── */
|
|
217
|
+
const SRCH = '<svg class="i" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg>';
|
|
218
|
+
const BELL = '<svg class="i" viewBox="0 0 24 24"><path d="M6 16V11a6 6 0 0 1 12 0v5l2 2H4z"/><path d="M10 20a2 2 0 0 0 4 0"/></svg>';
|
|
219
|
+
const IC = (d) => `<svg class="i" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
|
|
220
|
+
const GL = { place: IC('M4 5h16v14H4zM4 10h16'), ini: IC('M12 3l9 9-9 9-9-9z'), doc: IC('M6 3h9l4 4v14H6zM14 3v5h5'), ses: IC('M5 4l14 8-14 8z'), need: IC('M12 4v10M12 18v2') };
|
|
221
|
+
const PLACES = [['Briefing', '/premium.html'], ['My work', '/premium-work.html'], ['Board', '/premium-board.html'], ['Insights', '/premium-insights.html']];
|
|
222
|
+
const PV_WS = new URLSearchParams(location.search).get('ws');
|
|
223
|
+
const pvQ = (sep) => (PV_WS ? sep + 'ws=' + encodeURIComponent(PV_WS) : '');
|
|
224
|
+
async function pvGet(u) { try { const r = await fetch(u, { credentials: 'same-origin' }); return { status: r.status, j: await r.json() }; } catch { return { status: 0, j: null }; } }
|
|
225
|
+
const pvOv = { kind: null, back: null, at: 0, list: [], pal: null, need: null };
|
|
226
|
+
function pvMount() {
|
|
227
|
+
const a = $('#toConsole'); if (!a || $('#pvSearch')) return;
|
|
228
|
+
a.insertAdjacentHTML('beforebegin', `<button class="glass round" id="pvSearch" aria-haspopup="dialog" aria-label="Search (Ctrl K)" title="Search (Ctrl K)">${SRCH}</button><button class="glass round pv-hp" id="pvBell" aria-haspopup="dialog" aria-label="Needs you" title="Needs you">${BELL}<span class="pv-bdg" id="pvBdg" hidden></span></button>`);
|
|
229
|
+
document.body.insertAdjacentHTML('beforeend', '<div class="pv-scrim" id="pvScrim"></div><div class="pv-ov" id="pvOv" role="dialog" aria-modal="true" hidden inert></div>');
|
|
230
|
+
$('#pvSearch').onclick = () => pvOpen('pal'); $('#pvBell').onclick = () => pvOpen('bell'); $('#pvScrim').onclick = pvClose;
|
|
231
|
+
pvNeeds();
|
|
232
|
+
}
|
|
233
|
+
export function pvClose() {
|
|
234
|
+
if (!pvOv.kind) return;
|
|
235
|
+
pvOv.kind = null; $('#pvOv').hidden = true; $('#pvOv').inert = true; $('#pvScrim').classList.remove('on');
|
|
236
|
+
$$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; }); $('#dock').inert = !document.body.classList.contains('docked'); document.documentElement.style.overflow = '';
|
|
237
|
+
if (pvOv.back) { try { pvOv.back.focus(); } catch { /* gone */ } }
|
|
238
|
+
}
|
|
239
|
+
function pvOpen(kind) {
|
|
240
|
+
if (pvOv.kind === kind) { pvClose(); return; }
|
|
241
|
+
if (pvOv.kind) pvClose();
|
|
242
|
+
const ae = document.activeElement; pvOv.back = ae && ae !== document.body ? ae : $(kind === 'pal' ? '#pvSearch' : '#pvBell');
|
|
243
|
+
pvOv.kind = kind; pvOv.at = 0;
|
|
244
|
+
$$('.rail,main.stage,#dock').forEach((x) => { x.inert = true; }); document.documentElement.style.overflow = 'hidden';
|
|
245
|
+
const o = $('#pvOv'); o.className = 'pv-ov ' + kind; o.setAttribute('aria-label', kind === 'pal' ? 'Search' : 'Needs you'); o.hidden = false; o.inert = false; $('#pvScrim').classList.add('on');
|
|
246
|
+
if (kind === 'pal') { o.innerHTML = '<div class="pv-pin">' + SRCH + '<input id="pvQ" type="text" placeholder="Search places, initiatives, documents and sessions" aria-label="Search" autocomplete="off" role="combobox" aria-expanded="true" aria-controls="pvList"><kbd>Esc</kbd></div><div id="pvList" role="listbox" aria-label="Results"></div><p class="pv-note">Ctrl K or / opens this from any page. Arrow keys move, Enter opens.</p>'; $('#pvQ').focus(); pvPal(); }
|
|
247
|
+
else { o.innerHTML = '<div class="pv-hd"><h2>Needs you</h2><small id="pvN"></small></div><div id="pvList" class="pv-lst"></div><p class="pv-note">Read from the Briefing. A press opens it.</p>'; pvBellDraw(); pvNeeds(); }
|
|
248
|
+
}
|
|
249
|
+
const pvGo = (it) => { pvClose(); if (it.go) location.assign(it.go); };
|
|
250
|
+
const pvRow = (it, i, sel) => `<button type="button" class="pv-row" role="option" id="pvo${i}" data-i="${i}" aria-selected="${sel}"><span class="gl">${GL[it.gl]}</span><span><b>${esc(it.t)}</b>${it.s ? `<small>${esc(it.s)}</small>` : ''}</span></button>`;
|
|
251
|
+
async function pvPal() {
|
|
252
|
+
if (!pvOv.pal) {
|
|
253
|
+
const [b, d, s] = await Promise.all([pvGet('/api/boards/backlog?limit=200' + pvQ('&')), pvGet('/api/core-docs?level=board' + pvQ('&')), pvGet('/api/sessions')]);
|
|
254
|
+
const miss = [];
|
|
255
|
+
const ini = b.j && b.j.ok && Array.isArray(b.j.rows) ? b.j.rows.map((r) => ({ g: 'Initiatives', gl: 'ini', t: r.title || r.id, s: [r.lane, r.stage].filter(Boolean).join(' · '), go: '/premium-initiative.html?id=' + encodeURIComponent(r.id) + (b.j.ws ? '&ws=' + encodeURIComponent(b.j.ws) + '&board=' + encodeURIComponent(b.j.board) : '') })) : (miss.push('initiatives'), []);
|
|
256
|
+
const docs = d.j && d.j.ok && Array.isArray(d.j.docs) ? d.j.docs.map((x) => ({ g: 'Documents', gl: 'doc', t: x.title || x.key, s: d.j.scope && d.j.scope.name ? d.j.scope.name : 'Board', go: '/premium-board.html' + pvQ('?') })) : (miss.push('documents'), []);
|
|
257
|
+
const ses = s.j && Array.isArray(s.j.sessions) ? s.j.sessions.filter((x) => !x.automatic).map((x) => ({ g: 'Sessions', gl: 'ses', t: x.name || x.id, s: [x.cwd && x.cwd !== '.' ? x.cwd : '', x.state].filter(Boolean).join(' · '), go: '/c3.html' })) : (miss.push('sessions'), []);
|
|
258
|
+
pvOv.pal = { items: [...PLACES.map(([t, go]) => ({ g: 'Places', gl: 'place', t, s: 'Place', go })), ...ini, ...docs, ...ses], miss };
|
|
259
|
+
}
|
|
260
|
+
if (pvOv.kind === 'pal') pvPalDraw();
|
|
261
|
+
}
|
|
262
|
+
function pvPalDraw() {
|
|
263
|
+
const box = $('#pvList'), q = ($('#pvQ') || { value: '' }).value.trim().toLowerCase(), P = pvOv.pal;
|
|
264
|
+
const items = P ? P.items.filter((x) => !q || (x.t + ' ' + (x.s || '')).toLowerCase().includes(q)) : PLACES.map(([t, go]) => ({ g: 'Places', gl: 'place', t, s: 'Place', go }));
|
|
265
|
+
const per = {}, list = items.filter((x) => (per[x.g] = (per[x.g] || 0) + 1) <= (q ? 6 : 4));
|
|
266
|
+
pvOv.list = list; pvOv.at = Math.min(pvOv.at, Math.max(0, list.length - 1));
|
|
267
|
+
let g = '', h = '';
|
|
268
|
+
list.forEach((it, i) => { if (it.g !== g) { g = it.g; h += `<div class="pv-grp">${esc(g)}</div>`; } h += pvRow(it, i, i === pvOv.at); });
|
|
269
|
+
if (!list.length) h = '<p class="pv-note" role="status">Nothing matches.</p>';
|
|
270
|
+
if (!P) h += '<p class="pv-note" role="status">Reading the records.</p>'; else if (P.miss.length) h += `<p class="pv-note" role="status">Not read: ${esc(P.miss.join(', '))}.</p>`;
|
|
271
|
+
box.innerHTML = h;
|
|
272
|
+
const a = $('#pvo' + pvOv.at); if (a) { $('#pvQ').setAttribute('aria-activedescendant', a.id); a.scrollIntoView({ block: 'nearest' }); }
|
|
273
|
+
}
|
|
274
|
+
/** The Briefing page feeds the bell the answer it has already read (so the bell asks nothing there); every other page asks once. r: the parsed /api/briefing-premium answer or null. */
|
|
275
|
+
export function pvFeed(r) {
|
|
276
|
+
const M = r && r.ok && r.model, L = M && M.list;
|
|
277
|
+
pvOv.need = r && r.state === 'reading' ? { state: 'reading' } : L ? { state: 'ready', count: L.count, rows: L.rows || [] } : { state: 'error' };
|
|
278
|
+
const n = pvOv.need, b = $('#pvBdg'), btn = $('#pvBell'); if (!b) return;
|
|
279
|
+
const on = n.state === 'ready' && n.count > 0;
|
|
280
|
+
b.hidden = !on; b.textContent = on ? (n.count > 99 ? '99+' : String(n.count)) : '';
|
|
281
|
+
btn.setAttribute('aria-label', n.state === 'ready' ? 'Needs you: ' + n.count : 'Needs you');
|
|
282
|
+
if (pvOv.kind === 'bell') pvBellDraw();
|
|
283
|
+
}
|
|
284
|
+
const pvOnBriefing = () => /^\/premium\.html$/.test(location.pathname);
|
|
285
|
+
async function pvNeeds() {
|
|
286
|
+
if (pvOnBriefing()) return;
|
|
287
|
+
const r = await pvGet('/api/briefing-premium' + pvQ('?'));
|
|
288
|
+
pvFeed(r.status === 202 ? { state: 'reading' } : r.j);
|
|
289
|
+
}
|
|
290
|
+
function pvBellDraw() {
|
|
291
|
+
const n = pvOv.need, box = $('#pvList'); if (!box) return;
|
|
292
|
+
$('#pvN').textContent = n && n.state === 'ready' ? String(n.count) : '';
|
|
293
|
+
if (!n || n.state === 'reading') { box.innerHTML = '<p class="pv-note" role="status">Reading the initiative state. What needs you is not known yet.</p>'; return; }
|
|
294
|
+
if (n.state === 'error') { box.innerHTML = '<p class="pv-note" role="status">What needs you could not be read.</p>'; return; }
|
|
295
|
+
if (!n.rows.length) { box.innerHTML = '<p class="pv-note" role="status">Nothing needs you.</p>'; return; }
|
|
296
|
+
pvOv.list = n.rows.map((r) => ({ gl: 'need', t: r.title, s: r.subject, go: '/premium.html' + pvQ('?') }));
|
|
297
|
+
box.innerHTML = pvOv.list.map((it, i) => pvRow(it, i, false).replace('role="option"', 'role="listitem"').replace(' aria-selected="false"', '')).join('') + (n.count > n.rows.length ? `<p class="pv-note">${n.count - n.rows.length} more on the Briefing.</p>` : '');
|
|
298
|
+
}
|
|
299
|
+
document.addEventListener('click', (e) => { const b = e.target.closest('#pvList .pv-row'); if (b && pvOv.list[+b.dataset.i]) pvGo(pvOv.list[+b.dataset.i]); });
|
|
300
|
+
document.addEventListener('input', (e) => { if (e.target.id === 'pvQ') { pvOv.at = 0; pvPalDraw(); } });
|
|
301
|
+
addEventListener('keydown', (e) => {
|
|
302
|
+
if (pvOv.kind) {
|
|
303
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopImmediatePropagation(); pvClose(); return; }
|
|
304
|
+
if (pvOv.kind === 'pal' && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) { e.preventDefault(); const n = pvOv.list.length; if (n) { pvOv.at = (pvOv.at + (e.key === 'ArrowDown' ? 1 : n - 1)) % n; pvPalDraw(); } }
|
|
305
|
+
else if (pvOv.kind === 'pal' && e.key === 'Enter' && pvOv.list[pvOv.at]) { e.preventDefault(); pvGo(pvOv.list[pvOv.at]); }
|
|
306
|
+
else if ((e.ctrlKey || e.metaKey) && (e.key === 'k' || e.key === 'K')) { e.preventDefault(); pvClose(); }
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if ($('#dlg').classList.contains('on') || !$('#pvSearch')) return;
|
|
310
|
+
if ((e.ctrlKey || e.metaKey) && !e.altKey && (e.key === 'k' || e.key === 'K')) { e.preventDefault(); pvOpen('pal'); return; }
|
|
311
|
+
const t = document.activeElement;
|
|
312
|
+
if (e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey && !(t && t.matches && t.matches('input,textarea,select,[contenteditable="true"]'))) { e.preventDefault(); pvOpen('pal'); }
|
|
313
|
+
}, true);
|
|
314
|
+
pvMount();
|
|
216
315
|
/* ── Settings: the two things that cannot be defaulted (initiative premium-settings) ────────────────────────────────────────────────────
|
|
217
316
|
* Workspaces: GET /api/workspaces · POST /api/workspaces, /api/workspaces/forget. Connectors: GET and POST /api/proactive/settings {briefSources}.
|
|
218
317
|
* Each press saves what the console's section saves, and nothing else. Every other setting runs on a default and stays in the console. */
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/* pm/premium-studio.js — the Insight Studio on the premium Insights page, part 1: dashboards (initiative premium-studio-dashboard).
|
|
2
|
+
* The mockup's Studio (prototype/premium-ux-concept/build-src/stu.js.txt) in its Dashboard mode: a conversation on the left, and on the right a brief of
|
|
3
|
+
* chips, a library, a live preview and checks. A turn changes the draft in the page and writes nothing. The one write is Save (or Remove), through the
|
|
4
|
+
* existing POST /api/premium-dashboards/save behind the launch nonce. Every title and chart comes from the page's model: the KR metric records and the
|
|
5
|
+
* board's saved dashboards. No demo measure is drawn.
|
|
6
|
+
*
|
|
7
|
+
* openStudio(P) P = { M, D (the saved dashboard to edit, or null), tile (the page's chart tile), save (body → answer), done (saved id | null) } */
|
|
8
|
+
import { $, esc, openDlg, closeDlg, toast, turnA, turnU, ptx, setFull } from './premium-shell.js';
|
|
9
|
+
|
|
10
|
+
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
11
|
+
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"/>');
|
|
12
|
+
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"/>');
|
|
13
|
+
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"/>');
|
|
14
|
+
const MAX_UNDO = 30;
|
|
15
|
+
|
|
16
|
+
let P = null; // the page's hand: { M, D, tile, save, done }
|
|
17
|
+
let st = null; // the Studio: { d: draft, h: undo stack, pop, lib, ck, msg, armed, busy }
|
|
18
|
+
|
|
19
|
+
const measures = () => P.M.measures || [];
|
|
20
|
+
const chartOf = (id) => (P.M.charts || []).find((c) => c.id === id) || null;
|
|
21
|
+
const titleOf = (id) => { const m = measures().find((x) => x.id === id); return m ? m.title : id; };
|
|
22
|
+
const savedDash = () => (P.M.dashboards || []).filter((x) => x.saved);
|
|
23
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
24
|
+
|
|
25
|
+
/* ── the draft and its undo ── */
|
|
26
|
+
const snap = () => { const h = st.h, cur = JSON.stringify(st.d); if (h.length && h[h.length - 1] === cur) return; h.push(cur); if (h.length > MAX_UNDO) h.shift(); };
|
|
27
|
+
const undo = () => { if (!st.h.length) return false; st.d = JSON.parse(st.h.pop()); return true; };
|
|
28
|
+
const blank = () => ({ id: null, name: '', use: '', charts: [], main: false });
|
|
29
|
+
|
|
30
|
+
/* ── the canvas ── */
|
|
31
|
+
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>`;
|
|
32
|
+
function briefHtml() {
|
|
33
|
+
const d = st.d;
|
|
34
|
+
return `<div class="stbr" role="group" aria-label="Brief">${chip('name', 'Name', d.name || 'Not set')}${chip('use', 'Purpose', d.use || 'Not set')}${chip('charts', 'Charts', String(d.charts.length))}${chip('main', 'Main dashboard', d.main ? 'Yes' : 'No')}</div>`;
|
|
35
|
+
}
|
|
36
|
+
const opt = (act, l, sub, on) => `<button type="button" class="sto" data-st="${act}" aria-pressed="${!!on}"><b>${esc(l)}</b>${sub ? `<small>${esc(sub)}</small>` : ''}</button>`;
|
|
37
|
+
const field = (f, v, ph, max) => `<input class="sti" id="stI" data-stf="${f}" value="${esc(v)}" placeholder="${esc(ph)}" maxlength="${max}" aria-label="${esc(ph)}" autocomplete="off">`;
|
|
38
|
+
function trayHtml() {
|
|
39
|
+
const p = st.pop, d = st.d; if (!p) return '';
|
|
40
|
+
let h = '';
|
|
41
|
+
if (p === 'name') h = field('name', d.name, 'For example: Weekly partner review', 60);
|
|
42
|
+
else if (p === 'use') h = field('use', d.use, 'What routine is this for?', 200);
|
|
43
|
+
else if (p === 'main') h = `<div class="sol">${opt('set|main|1', 'Yes', 'It opens first on this board. One dashboard is main.', d.main)}${opt('set|main|0', 'No', 'Keep it as another dashboard', !d.main)}</div>`;
|
|
44
|
+
else if (p === 'charts') {
|
|
45
|
+
h = (d.charts.length ? `<ul class="sul">${d.charts.map((id, i) => `<li><span>${esc(titleOf(id))}${chartOf(id) ? '' : '<small>No series yet</small>'}</span><span class="stlc"><button type="button" data-st="mv|${i}|-1" aria-label="Move ${esc(titleOf(id))} up"${i ? '' : ' disabled'}>${UPI}</button><button type="button" data-st="mv|${i}|1" aria-label="Move ${esc(titleOf(id))} down"${i < d.charts.length - 1 ? '' : ' disabled'}>${DNI}</button><button type="button" data-st="rm|${i}" aria-label="Remove ${esc(titleOf(id))}">${XI}</button></span></li>`).join('')}</ul>` : '<p class="note">No charts yet.</p>')
|
|
46
|
+
+ '<button type="button" class="dmcta alt" data-st="lib">Add from the library</button>';
|
|
47
|
+
}
|
|
48
|
+
return h ? `<div class="sup" role="group" aria-label="Change this">${h}<button type="button" class="lk stdone" data-st="chip|${p}">Done</button></div>` : '';
|
|
49
|
+
}
|
|
50
|
+
const W = 96, H = 30;
|
|
51
|
+
function spark(c) {
|
|
52
|
+
if (!c) return '<span class="stlic" aria-hidden="true"></span>';
|
|
53
|
+
const d = c.pts.map((p, i) => (i ? 'L' : 'M') + (2 + p.fx * (W - 4)).toFixed(1) + ',' + (2 + (1 - p.fy) * (H - 4)).toFixed(1)).join('');
|
|
54
|
+
return `<svg class="spk" viewBox="0 0 ${W} ${H}" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
55
|
+
}
|
|
56
|
+
function libHtml() {
|
|
57
|
+
if (!st.lib) return '';
|
|
58
|
+
const d = st.d, L = measures(), S = savedDash().filter((x) => x.id !== d.id);
|
|
59
|
+
const rows = L.map((m) => { const on = d.charts.includes(m.id), c = chartOf(m.id); return `<button type="button" class="stli" data-st="libc|${esc(m.id)}"${on ? ' disabled' : ''}>${spark(c)}<span><b>${esc(m.title)}</b><small>${esc(c ? c.sub : 'No series yet')}</small></span><em>${on ? 'Added' : 'Add'}</em></button>`; }).join('');
|
|
60
|
+
const dl = S.map((x) => `<button type="button" class="stli" data-st="libd|${esc(x.id)}"><span class="stlic">${DSI}</span><span><b>${esc(x.name)}</b><small>${plural(x.charts.length, 'chart', 'charts')}</small></span><em>Add its charts</em></button>`).join('');
|
|
61
|
+
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>`
|
|
62
|
+
+ `<p class="label">Measures · ${L.length}</p>${L.length ? `<div class="stlg">${rows}</div>` : '<p class="note">No KR metric is recorded for this workspace.</p>'}`
|
|
63
|
+
+ (dl ? `<p class="label">Dashboards · ${S.length}</p><div class="stlg">${dl}</div>` : '') + '</div>';
|
|
64
|
+
}
|
|
65
|
+
function previewHtml() {
|
|
66
|
+
const d = st.d, L = d.charts.map(chartOf).filter(Boolean), gone = d.charts.filter((id) => !chartOf(id));
|
|
67
|
+
return `<div class="stpvw"><h3 class="ndt">${esc(d.name || 'Untitled dashboard')}${d.main ? '<span class="npin2">Main dashboard</span>' : ''}</h3><p class="mut stuse">${esc(d.use || 'No purpose yet.')}</p>`
|
|
68
|
+
+ (L.length ? `<div class="ngrid">${L.map((c) => `<div class="ntw">${P.tile(c)}</div>`).join('')}</div>` : '<p class="note">No chart is drawn yet. Add a measure with a series.</p>')
|
|
69
|
+
+ (gone.length ? `<p class="label ngl">Not drawn · ${gone.length}</p>${gone.map((id) => `<p class="note stgone"><b>${esc(titleOf(id))}</b> has fewer than two readings, so it has no chart.</p>`).join('')}` : '') + '</div>';
|
|
70
|
+
}
|
|
71
|
+
/* The six checks of the mockup, computed from the draft. A fix is an action the Studio can take in one press. */
|
|
72
|
+
function checks() {
|
|
73
|
+
const d = st.d, dup = d.charts.length - new Set(d.charts).size, other = savedDash().some((x) => x.main && x.id !== d.id);
|
|
74
|
+
return [
|
|
75
|
+
{ ok: !!d.name.trim(), l: 'It has a name', d: d.name.trim() || 'Give it a name.', fix: ['Name it', 'chip|name'] },
|
|
76
|
+
{ ok: !!d.use.trim(), l: 'It says what routine it serves', d: d.use.trim() || 'A dashboard without a purpose collects charts.', fix: ['Say the purpose', 'chip|use'] },
|
|
77
|
+
{ ok: d.charts.length > 0, l: 'It has a chart', d: plural(d.charts.length, 'chart', 'charts') + '.', fix: ['Open the library', 'lib'] },
|
|
78
|
+
{ ok: d.charts.length <= 6, l: 'Six charts or fewer', d: d.charts.length > 6 ? d.charts.length + ' charts. Past six, readers stop looking at each one.' : 'The count is easy to scan.', fix: ['Choose which to keep', 'chip|charts'] },
|
|
79
|
+
{ ok: !dup, l: 'No measure appears twice', d: dup ? plural(dup, 'measure is', 'measures are') + ' drawn twice.' : 'Each measure appears once.', fix: ['Take out the repeats', 'dedup'] },
|
|
80
|
+
{ ok: d.main || other, l: 'The board has a main dashboard', d: d.main || other ? 'One dashboard opens first.' : 'No dashboard opens first on this board.', fix: ['Make it the main one', 'set|main|1'] },
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
function checksHtml() {
|
|
84
|
+
const L = checks(), bad = L.filter((x) => !x.ok), n = L.length - bad.length;
|
|
85
|
+
return `<div class="suck${bad.length ? ' bad' : ''}"><button type="button" class="suckb" data-st="ck" aria-expanded="${st.ck}">${bad.length ? WRN : OKI}<b>${n} of ${L.length} checks pass</b>${bad.length && !st.ck ? `<span>${esc(bad[0].d)}</span>` : ''}${CHV}</button>`
|
|
86
|
+
+ `<div class="mprog stbar" role="progressbar" aria-label="Checks passing" aria-valuemin="0" aria-valuemax="${L.length}" aria-valuenow="${n}" data-n="${n}"><b></b></div>`
|
|
87
|
+
+ (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>';
|
|
88
|
+
}
|
|
89
|
+
function footHtml() {
|
|
90
|
+
const saved = !!st.d.id;
|
|
91
|
+
return `<div class="stft"><button type="button" class="dmcta alt" data-st="undo"${st.h.length ? '' : ' disabled'}>Undo</button>${saved ? `<button type="button" class="dmcta alt" data-st="del">${st.armed ? 'Press again to remove it' : 'Remove the dashboard'}</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 ? ' disabled' : ''}>${saved ? 'Save changes' : 'Save the dashboard'}</button></div>`;
|
|
92
|
+
}
|
|
93
|
+
const guide = () => '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>' : '');
|
|
94
|
+
function canvasHtml() {
|
|
95
|
+
return `<div class="stu"><div class="stt"><span class="stx"><button type="button" class="lk" data-st="lib" aria-expanded="${st.lib}">Library</button></span></div><p class="stsug" id="stG">${guide()}</p><div id="stBr">${briefHtml()}</div><div id="stTr">${trayHtml()}</div><div id="stLb">${libHtml()}</div><div id="stPv">${previewHtml()}</div><div id="stCk">${checksHtml()}</div><p class="note stmsg" id="stMsg" role="status"></p><div id="stFt">${footHtml()}</div></div>`;
|
|
96
|
+
}
|
|
97
|
+
function draw(parts) {
|
|
98
|
+
const all = !parts, set = (id, h) => { const e = $('#' + id); if (e) e.innerHTML = h; };
|
|
99
|
+
if (all || parts.includes('g')) set('stG', guide());
|
|
100
|
+
if (all || parts.includes('br')) set('stBr', briefHtml());
|
|
101
|
+
if (all || parts.includes('tr')) set('stTr', trayHtml());
|
|
102
|
+
if (all || parts.includes('lb')) set('stLb', libHtml());
|
|
103
|
+
if (all || parts.includes('pv')) set('stPv', previewHtml());
|
|
104
|
+
if (all || parts.includes('ck')) set('stCk', checksHtml());
|
|
105
|
+
if (all || parts.includes('ft')) set('stFt', footHtml());
|
|
106
|
+
const m = $('#stMsg'); if (m) m.textContent = st.msg;
|
|
107
|
+
const l = $('.stu [data-st="lib"]'); if (l) l.setAttribute('aria-expanded', st.lib);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ── doing things ── */
|
|
111
|
+
function act(a) {
|
|
112
|
+
const [k, x, y] = a; st.msg = '';
|
|
113
|
+
if (k !== 'del') st.armed = false;
|
|
114
|
+
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; }
|
|
115
|
+
if (k === 'lib') { st.lib = !st.lib; draw(['lb', 'tr', 'ft']); return; }
|
|
116
|
+
if (k === 'ck') { st.ck = !st.ck; draw(['ck']); return; }
|
|
117
|
+
if (k === 'fix') { const f = checks()[+x]; if (f && f.fix) act(f.fix[1].split('|')); return; }
|
|
118
|
+
if (k === 'undo') { if (undo()) { st.pop = null; draw(); } return; }
|
|
119
|
+
if (k === 'cancel') { closeDlg(); return; }
|
|
120
|
+
if (k === 'save') { save(); return; }
|
|
121
|
+
if (k === 'del') { remove(); return; }
|
|
122
|
+
if (k === 'new') { snap(); st.d = blank(); st.pop = null; draw(); return; }
|
|
123
|
+
if (k === 'set' && x === 'main') { snap(); st.d.main = y === '1'; st.pop = null; draw(); return; }
|
|
124
|
+
if (k === 'dedup') { snap(); st.d.charts = st.d.charts.filter((id, i) => st.d.charts.indexOf(id) === i); draw(); return; }
|
|
125
|
+
if (k === 'mv') { const i = +x, j = i + +y, c = st.d.charts; if (j < 0 || j >= c.length) return; snap(); [c[i], c[j]] = [c[j], c[i]]; draw(); const b = $(`#stTr [data-st="mv|${j}|${y}"]`) || $(`#stTr [data-st="mv|${j}|${-y}"]`); if (b) b.focus(); return; }
|
|
126
|
+
if (k === 'rm') { snap(); st.d.charts.splice(+x, 1); draw(); return; }
|
|
127
|
+
if (k === 'libc') { if (st.d.charts.includes(x)) return; snap(); st.d.charts.push(x); draw(); return; }
|
|
128
|
+
if (k === 'libd') { const D = savedDash().find((q) => q.id === x); if (!D) return; snap(); D.charts.forEach((id) => { if (!st.d.charts.includes(id)) st.d.charts.push(id); }); draw(); }
|
|
129
|
+
}
|
|
130
|
+
let typed = false; // one undo step per text field edit, not per key
|
|
131
|
+
function onInput(e) {
|
|
132
|
+
const f = e.target.dataset && e.target.dataset.stf; if (!f) return;
|
|
133
|
+
if (!typed) { snap(); typed = true; }
|
|
134
|
+
st.d[f] = e.target.value; st.msg = ''; draw(['g', 'br', 'pv', 'ck', 'ft']);
|
|
135
|
+
}
|
|
136
|
+
async function save() {
|
|
137
|
+
const d = st.d, name = d.name.trim(), use = d.use.trim();
|
|
138
|
+
if (!name) { st.msg = 'Give the dashboard a name.'; draw(['ft']); return; }
|
|
139
|
+
if (!use) { st.msg = 'Say what the dashboard is for, in one line.'; draw(['ft']); return; }
|
|
140
|
+
st.busy = true; st.msg = 'Saving.'; draw(['ft']);
|
|
141
|
+
const res = await P.save({ id: d.id || undefined, name, purpose: use, charts: d.charts, main: d.main });
|
|
142
|
+
st.busy = false;
|
|
143
|
+
if (!res || res.ok !== true) { st.msg = (res && res.error) || 'The dashboard could not be saved.'; draw(['ft']); return; }
|
|
144
|
+
closeDlg(); toast('Dashboard "' + name + '" saved in the workspace\'s state folder.'); P.done(res.dashboard ? res.dashboard.id : d.id);
|
|
145
|
+
}
|
|
146
|
+
async function remove() {
|
|
147
|
+
if (!st.armed) { st.armed = true; st.msg = 'Removing takes the dashboard off this board. The measures and their records stay.'; draw(['ft']); return; }
|
|
148
|
+
st.busy = true; draw(['ft']);
|
|
149
|
+
const res = await P.save({ id: st.d.id, remove: true });
|
|
150
|
+
st.busy = false;
|
|
151
|
+
if (!res || res.ok !== true) { st.armed = false; st.msg = (res && res.error) || 'The dashboard could not be removed.'; draw(['ft']); return; }
|
|
152
|
+
closeDlg(); toast('Dashboard removed. The line is saved in the workspace\'s state folder.'); P.done(null);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* ── the conversation: the phrases the Studio understands. A turn changes the draft only; it writes nothing and starts no agent. ── */
|
|
156
|
+
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.';
|
|
157
|
+
const clean = (s) => s.trim().replace(/^["']|["']$/g, '').replace(/[.\s]+$/, '').trim();
|
|
158
|
+
function hits(low) { return 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); }
|
|
159
|
+
function command(text) {
|
|
160
|
+
const t = text.trim(), low = t.toLowerCase(), d = st.d, said = [];
|
|
161
|
+
if (/^undo\b/.test(low)) return undo() ? (st.pop = null, 'Done: one step undone.') : 'I changed nothing. There is nothing to undo.';
|
|
162
|
+
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.'; }
|
|
163
|
+
const before = JSON.stringify(d); snap();
|
|
164
|
+
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);
|
|
165
|
+
if (nm && clean(nm[1])) { d.name = clean(nm[1]).slice(0, 60); said.push('named it "' + d.name + '"'); }
|
|
166
|
+
const us = t.match(/(?:(?:it is|it's|its purpose is|purpose is|purpose:|use it)\s+for|purpose[:\s]+)\s*(.+?)(?=;|$)/i);
|
|
167
|
+
if (us && clean(us[1])) { d.use = clean(us[1]).slice(0, 200); said.push('the purpose is "' + d.use + '"'); }
|
|
168
|
+
if (/\b(not|no longer|don't make it|do not make it)\b[^.]*\bmain\b/.test(low)) { if (d.main) { d.main = false; said.push('it is not the main dashboard'); } }
|
|
169
|
+
else if (/\bmain\b/.test(low) && /\b(make|set|mark|as)\b/.test(low)) { if (!d.main) { d.main = true; said.push('it is the main dashboard'); } }
|
|
170
|
+
const H = hits(low), verbs = H.reduce((v, x) => v.split(x.m.title.toLowerCase()).join(' '), low); // the verbs, read with the measures' names taken out ("Time to first call" is not "first")
|
|
171
|
+
if (H.length && /\b(remove|take off|take out|drop|delete|without)\b/.test(verbs)) {
|
|
172
|
+
H.forEach(({ m }) => { const i = d.charts.indexOf(m.id); if (i >= 0) { d.charts.splice(i, 1); said.push('removed ' + m.title); } });
|
|
173
|
+
} else if (H.length && /\b(move|put|first|top|up|down|last|bottom)\b/.test(verbs)) {
|
|
174
|
+
const m = H[0].m, i = d.charts.indexOf(m.id);
|
|
175
|
+
if (i >= 0) {
|
|
176
|
+
const j = /\b(first|top)\b/.test(verbs) ? 0 : /\b(last|bottom)\b/.test(verbs) ? d.charts.length - 1 : /\bup\b/.test(verbs) ? Math.max(0, i - 1) : Math.min(d.charts.length - 1, i + 1);
|
|
177
|
+
if (j !== i) { d.charts.splice(i, 1); d.charts.splice(j, 0, m.id); said.push('moved ' + m.title + ' to place ' + (j + 1)); }
|
|
178
|
+
}
|
|
179
|
+
} else if (H.length && /\b(add|include|show|put in|with)\b/.test(verbs)) {
|
|
180
|
+
H.forEach(({ m }) => { if (!d.charts.includes(m.id)) { d.charts.push(m.id); said.push('added ' + m.title + (chartOf(m.id) ? '' : ' (it has no series yet, so it is listed, not drawn)')); } });
|
|
181
|
+
}
|
|
182
|
+
if (JSON.stringify(d) === before) { st.h.pop(); return 'I changed nothing. ' + (H.length || !/\b(add|remove)\b/.test(low) ? HELP : 'No measure of this board has that name. Open the Library to see them.'); }
|
|
183
|
+
st.pop = null;
|
|
184
|
+
return 'Done: ' + said.join(', ') + '.';
|
|
185
|
+
}
|
|
186
|
+
function onSay(e) {
|
|
187
|
+
e.preventDefault(); e.stopPropagation();
|
|
188
|
+
const inp = $('#stIn'), text = inp.value.trim(); if (!text) return;
|
|
189
|
+
inp.value = ''; const answer = command(text);
|
|
190
|
+
const s = $('#dBody .stream'); if (s) { s.insertAdjacentHTML('beforeend', turnU(text) + turnA(ptx(answer))); s.scrollTop = s.scrollHeight; }
|
|
191
|
+
draw();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* ── opening ── */
|
|
195
|
+
export function openStudio(p) {
|
|
196
|
+
P = p; typed = false;
|
|
197
|
+
const D = p.D;
|
|
198
|
+
st = { d: D ? { id: D.id, name: D.name, use: D.purpose || '', charts: D.charts.slice(), main: !!D.main } : blank(), h: [], pop: null, lib: !D, ck: false, msg: '', armed: false, busy: false };
|
|
199
|
+
const board = p.M.board.name || 'this board';
|
|
200
|
+
const say = 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.'
|
|
201
|
+
: '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.';
|
|
202
|
+
openDlg({ eye: 'Insight Studio · ' + board, title: 'Insight Studio', sub: 'Make a dashboard from ' + board + '. Say it, or use the brief.', stream: turnA(ptx(say)), noteKey: null, pane: canvasHtml(), label: 'Dashboard' });
|
|
203
|
+
$('#dlg').classList.add('stud');
|
|
204
|
+
$('#askF').hidden = true; const an = $('#askNote'); if (an) an.hidden = true;
|
|
205
|
+
$('#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 in the dashboard"><button type="submit" aria-label="Send" title="Send">${ICO('<path d="M5 12h14M13 6l6 6-6 6"/>')}</button></form><p class="fine2">${esc(HELP)} Nothing is saved until you press Save.</p>`);
|
|
206
|
+
$('#stF').onsubmit = onSay;
|
|
207
|
+
if (innerWidth >= 1000) setFull(true);
|
|
208
|
+
draw();
|
|
209
|
+
}
|
|
210
|
+
/* The Studio's presses. The dialog is shared, so each listener first asks whether the Studio is what it holds. */
|
|
211
|
+
const inStudio = (e) => $('#dlg').classList.contains('stud') && $('#dlg').classList.contains('on') && e.target.closest('#oMain');
|
|
212
|
+
document.addEventListener('click', (e) => { if (!inStudio(e)) return; const t = e.target.closest('[data-st]'); if (t && !t.disabled) act(t.dataset.st.split('|')); });
|
|
213
|
+
document.addEventListener('input', (e) => { if (inStudio(e)) onInput(e); });
|
|
214
|
+
document.addEventListener('focusout', (e) => { if (e.target && e.target.id === 'stI') typed = false; });
|
|
215
|
+
document.addEventListener('keydown', (e) => { if (e.key === 'Enter' && e.target.id === 'stI' && inStudio(e)) { e.preventDefault(); st.pop = null; typed = false; draw(['br', 'tr']); } });
|
|
216
|
+
/* Another dialog of the page opens without the Studio's class. */
|
|
217
|
+
new MutationObserver(() => { const d = $('#dlg'); if (d && !d.classList.contains('on') && d.classList.contains('stud')) d.classList.remove('stud'); }).observe($('#dlg'), { attributes: true, attributeFilter: ['class'] });
|
|
@@ -826,6 +826,77 @@ a.round{color:inherit;text-decoration:none}
|
|
|
826
826
|
.addf .cact{display:flex;flex-wrap:wrap;gap:10px}.addf .note[role="status"]{margin:0;min-height:1.2em}
|
|
827
827
|
@media (max-width:760px){.inirw>.ini2{padding-right:48px}.baiact .dmcta,.lifeb .dmcta,.baa .dmcta{height:44px}.baa .baact .dmcta{flex:1;justify-content:center}.bapl button{min-height:44px}}
|
|
828
828
|
|
|
829
|
+
/* ── Insight Studio (initiative premium-studio-dashboard): the mockup's Dashboard mode; brief, tray, library, preview, checks and footer ── */
|
|
830
|
+
#dlg.stud .p-out .obody{padding-bottom:0}
|
|
831
|
+
.stu{display:grid;gap:12px;min-width:0}
|
|
832
|
+
.stt{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}
|
|
833
|
+
#dlg.stud #askF,#dlg.stud #askNote{display:none}
|
|
834
|
+
.stx{display:flex;align-items:center;gap:12px}
|
|
835
|
+
.stx .lk,.stlh .lk,.stdone{min-height:44px;padding:0 10px;font-size:13px}
|
|
836
|
+
.stsug{margin:0;font-size:13.5px;color:var(--ink-2);line-height:1.5;padding:0 2px}
|
|
837
|
+
.stbr{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px}
|
|
838
|
+
.suc{display:grid;gap:2px;align-content:center;min-height:52px;padding:8px 12px;border-radius:14px;background:var(--well);box-shadow:inset 0 0 0 1px var(--hair);max-width:100%;text-align:left;transition:background .2s}
|
|
839
|
+
.suc em{font-style:normal;font-size:11px;font-weight:600;color:var(--ink-3);white-space:nowrap}
|
|
840
|
+
.suc b{font-size:14px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
|
|
841
|
+
.suc.on{background:var(--solid);color:var(--on-solid)}
|
|
842
|
+
.suc.on em{color:color-mix(in oklab,var(--on-solid) 70%,transparent)}
|
|
843
|
+
.suc.req{box-shadow:inset 0 0 0 1.5px color-mix(in oklab,var(--ember) 60%,transparent)}
|
|
844
|
+
.sup{padding:14px;border-radius:18px;background:var(--well);display:grid;gap:10px}
|
|
845
|
+
.stdone{justify-self:end}
|
|
846
|
+
.sol{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:8px}
|
|
847
|
+
.sto{display:grid;gap:2px;text-align:left;padding:10px 12px;border-radius:14px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);align-content:start;min-height:44px}
|
|
848
|
+
.sto b{font-size:13.5px}
|
|
849
|
+
.sto small{font-size:12px;color:var(--ink-3);line-height:1.35}
|
|
850
|
+
.sto[aria-pressed="true"]{box-shadow:inset 0 0 0 2px var(--ink)}
|
|
851
|
+
.sti{width:100%;height:44px;border-radius:12px;border:1px solid var(--hair);background:var(--card-solid);padding:0 12px;font:inherit;font-size:14px;color:var(--ink)}
|
|
852
|
+
.sti:focus{outline:2px solid var(--ember);outline-offset:1px}
|
|
853
|
+
.sul{list-style:none;margin:0;padding:0;display:grid;gap:6px}
|
|
854
|
+
.sul li{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 12px;border-radius:12px;background:var(--card-solid)}
|
|
855
|
+
.sul small{display:block;color:var(--ink-3);font-size:12px}
|
|
856
|
+
.stlc{display:flex;gap:4px;flex:none}
|
|
857
|
+
.stlc button{min-width:44px;height:44px;border-radius:10px;background:var(--well);display:grid;place-items:center;padding:0 10px}
|
|
858
|
+
.stlc svg{width:15px;height:15px}
|
|
859
|
+
.stlc button:disabled{opacity:.35}
|
|
860
|
+
.stlib{padding:14px;border-radius:18px;background:var(--well)}
|
|
861
|
+
.stlh{display:flex;align-items:center;gap:10px}
|
|
862
|
+
.stlh small{color:var(--ink-3);margin-right:auto}
|
|
863
|
+
.stlib .label{margin:10px 0 0}
|
|
864
|
+
.stlg{display:grid;gap:6px;margin-top:6px}
|
|
865
|
+
.stli{display:grid;grid-template-columns:96px minmax(0,1fr) auto;gap:12px;align-items:center;text-align:left;padding:8px 12px;border-radius:12px;background:var(--card-solid);min-height:44px}
|
|
866
|
+
.stli .spk{width:96px;height:30px}
|
|
867
|
+
.stli .spk path{fill:none;stroke:var(--ink-2);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
|
|
868
|
+
.stli b{font-size:13.5px}
|
|
869
|
+
.stli small{display:block;color:var(--ink-3);font-size:12px}
|
|
870
|
+
.stli em{font-style:normal;font-size:12.5px;font-weight:650;color:var(--ink-2)}
|
|
871
|
+
.stli:disabled{opacity:.5}
|
|
872
|
+
.stlic{display:grid;place-items:center;width:96px}
|
|
873
|
+
.stlic svg{width:22px;height:22px;color:var(--ink-3)}
|
|
874
|
+
.stpvw{padding:16px;border-radius:18px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);min-width:0}
|
|
875
|
+
.stpvw .ndt{margin:0;font-size:18px;font-weight:650;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
876
|
+
.stpvw .npin2{font-size:11.5px;font-weight:650;padding:3px 9px;border-radius:999px;background:var(--well);color:var(--ink-2)}
|
|
877
|
+
.stpvw .stuse{margin:4px 0 10px;font-size:13.5px}
|
|
878
|
+
.stgone{margin:4px 0 0}
|
|
879
|
+
.suck{border-radius:16px;background:var(--well);overflow:hidden}
|
|
880
|
+
.suckb{display:flex;align-items:center;gap:10px;width:100%;min-height:48px;padding:10px 14px;text-align:left}
|
|
881
|
+
.suckb svg{width:18px;height:18px;flex:none}
|
|
882
|
+
.suckb b{font-size:13.5px;white-space:nowrap}
|
|
883
|
+
.suckb span{font-size:12.5px;color:var(--ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}
|
|
884
|
+
.suckb svg:last-child{margin-left:auto;transition:transform .2s}
|
|
885
|
+
.suckb[aria-expanded="true"] svg:last-child{transform:rotate(180deg)}
|
|
886
|
+
.suck.bad .suckb>svg:first-child{color:var(--ember-ink)}
|
|
887
|
+
.stbar{margin:0 14px 12px;width:auto}
|
|
888
|
+
.stbar b{width:0}.stbar[data-n="1"] b{width:16.67%}.stbar[data-n="2"] b{width:33.33%}.stbar[data-n="3"] b{width:50.0%}.stbar[data-n="4"] b{width:66.67%}.stbar[data-n="5"] b{width:83.33%}.stbar[data-n="6"] b{width:100.0%}
|
|
889
|
+
.sucl{list-style:none;margin:0;padding:0 14px 12px;display:grid;gap:8px}
|
|
890
|
+
.sucl li{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center}
|
|
891
|
+
.sucl li svg{width:16px;height:16px}
|
|
892
|
+
.sucl li.bad svg{color:var(--ember-ink)}
|
|
893
|
+
.sucl b{font-size:13px;display:block}
|
|
894
|
+
.sucl small{font-size:12px;color:var(--ink-3)}
|
|
895
|
+
.stmsg{min-height:1.2em;margin:0;color:var(--ember-ink)}
|
|
896
|
+
.stft{display:flex;gap:8px;align-items:center;flex-wrap:wrap;position:sticky;bottom:0;padding:10px 0 12px;background:linear-gradient(to top,var(--card-solid) 70%,transparent)}
|
|
897
|
+
.stft .sp{flex:1}
|
|
898
|
+
.stft .dmcta{height:44px}
|
|
899
|
+
@media (max-width:700px){.sol{grid-template-columns:minmax(0,1fr)}.stli{grid-template-columns:72px minmax(0,1fr)}.stli .spk,.stlic{width:72px}.stli em{grid-column:2}.stt{gap:8px}.sucl li{grid-template-columns:18px minmax(0,1fr)}.sucl li .dmcta{grid-column:2;justify-self:start}}
|
|
829
900
|
/* ── initiative page (initiative briefing-premium-initiative) ── */
|
|
830
901
|
.ckr.current i{background:var(--ember)}
|
|
831
902
|
.ckr.done i{background:var(--ok)}
|
|
@@ -1300,6 +1371,31 @@ button.dsn:hover{box-shadow:inset 0 0 0 1.5px rgb(79,109,245)}
|
|
|
1300
1371
|
.top:has(#iH1) .tools-top{flex-basis:100%;justify-content:flex-start}
|
|
1301
1372
|
#cIniChk .ckr small{overflow-wrap:anywhere}
|
|
1302
1373
|
|
|
1374
|
+
/* search and the bell in the header (initiative premium-search-bell); the look is the mockup's overlays ov-pal and ov-bell */
|
|
1375
|
+
.pv-hp{position:relative}
|
|
1376
|
+
.pv-bdg{position:absolute;top:-4px;right:-4px;min-width:20px;height:20px;padding:0 5px;border-radius:999px;display:grid;place-items:center;background:var(--ember);color:rgb(255,255,255);font:700 11.5px var(--mono)}
|
|
1377
|
+
.pv-bdg[hidden]{display:none}
|
|
1378
|
+
.pv-scrim{position:fixed;inset:0;z-index:44;background:rgba(30,34,60,.34);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;pointer-events:none;transition:opacity .3s}
|
|
1379
|
+
.pv-scrim.on{opacity:1;pointer-events:auto}
|
|
1380
|
+
.pv-ov{position:fixed;z-index:45;left:50%;top:12vh;transform:translateX(-50%);width:min(640px,calc(100% - 32px));max-height:72vh;overflow:auto;overscroll-behavior:contain;background:var(--card-solid);border:1px solid var(--hair);border-radius:var(--r-card);box-shadow:var(--card-shadow);padding:14px}
|
|
1381
|
+
.pv-ov[hidden]{display:none}
|
|
1382
|
+
.pv-ov.bell{left:auto;right:max(16px,calc((100vw - 1360px)/2 + 16px));top:96px;transform:none;width:min(420px,calc(100% - 32px))}
|
|
1383
|
+
.pv-pin{display:flex;align-items:center;gap:12px;height:56px;padding:0 16px;border-radius:999px;background:var(--well)}
|
|
1384
|
+
.pv-pin input{flex:1;min-width:0;height:100%;border:0;background:transparent;color:var(--ink);font:inherit;font-size:16px;outline:0}
|
|
1385
|
+
.pv-pin kbd{font:600 11.5px var(--mono);color:var(--ink-3);border:1px solid var(--b3);border-radius:8px;padding:2px 6px}
|
|
1386
|
+
.pv-grp{font:600 var(--t-micro) var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3);padding:18px 14px 6px}
|
|
1387
|
+
.pv-lst{display:grid;gap:2px;margin-top:8px}
|
|
1388
|
+
.pv-row{display:grid;grid-template-columns:40px minmax(0,1fr);gap:14px;align-items:center;width:100%;min-height:56px;padding:8px 14px;border-radius:var(--r-in);text-align:left}
|
|
1389
|
+
.pv-row:hover,.pv-row[aria-selected="true"],.pv-row:focus-visible{background:var(--well)}
|
|
1390
|
+
.pv-row .gl{width:40px;height:40px;border-radius:14px;display:grid;place-items:center;background:var(--well);color:var(--ink-2)}
|
|
1391
|
+
.pv-row b{display:block;font-weight:620;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1392
|
+
.pv-row small{display:block;color:var(--ink-3);font-size:var(--t-small);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1393
|
+
.pv-lst .pv-row .gl{background:var(--spot);color:var(--ember-ink)}
|
|
1394
|
+
.pv-hd{display:flex;align-items:baseline;gap:10px;padding:8px 6px 4px}.pv-hd h2{margin:0;font-size:18px}.pv-hd small{color:var(--ink-3);font:600 12px var(--mono)}
|
|
1395
|
+
.pv-note{margin:0;padding:10px 14px 4px;color:var(--ink-3);font-size:var(--t-small)}
|
|
1396
|
+
@media (max-width:700px){.pv-ov{top:8vh}.pv-ov.bell{right:16px}}
|
|
1397
|
+
.pv-row .gl svg{width:20px;height:20px}
|
|
1398
|
+
@media (max-width:700px){.top .tools{position:relative}.pkw{position:static}.pkmenu{left:0;right:0;min-width:0}}
|
|
1303
1399
|
/* Settings dialog rows (initiative premium-settings) */
|
|
1304
1400
|
.sr{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:44px;padding:8px 0;border-bottom:1px solid var(--hair)}
|
|
1305
1401
|
.sr .sn{display:grid;gap:2px;min-width:0}.sr .sn b{font-size:15px}.sr .sn em{font-style:normal;font-size:12.5px;color:var(--ink-3);overflow-wrap:anywhere}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Slice 3: the reply box asks a read-only agent. A control with nothing honest to write stays disabled and says why. */
|
|
5
5
|
import { pmPost, pmGet } from './http.js';
|
|
6
6
|
import { mountMeeting } from './premium-meeting.js';
|
|
7
|
-
import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail } from './premium-shell.js';
|
|
7
|
+
import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail, pvFeed } from './premium-shell.js';
|
|
8
8
|
const ICON = {
|
|
9
9
|
meeting: '<rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/>',
|
|
10
10
|
merge: '<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="9" r="2"/><path d="M6 8v8M18 11c0 4-6 3-12 5"/>',
|
|
@@ -259,6 +259,7 @@ async function load() {
|
|
|
259
259
|
const ws = new URLSearchParams(location.search).get('ws');
|
|
260
260
|
try { const res = await fetch('/api/briefing-premium' + (ws ? '?ws=' + encodeURIComponent(ws) : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
|
|
261
261
|
clearInterval(readTimer);
|
|
262
|
+
pvFeed(r);
|
|
262
263
|
if (r && r.state === 'reading') {
|
|
263
264
|
// the first read has no end I can promise: say how long it has run, and ask again
|
|
264
265
|
const t0 = Date.now() - (r.elapsed_ms || 0), tick = () => { $('#brief').textContent = 'Reading the products for the first time. ' + Math.round((Date.now() - t0) / 1000) + ' s so far. This page shows nothing until it has read, rather than guess.'; };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-studio-dashboard: the Insight Studio's Dashboard mode on the premium Insights page, against the real server on a scratch repository's KR metric records.",
|
|
3
|
+
"panels": [
|
|
4
|
+
"premium-studio-test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"premium-studio-test.js": 120
|
|
8
|
+
}
|
|
9
|
+
}
|