create-pmos 0.268.0 → 0.270.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.
@@ -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
 
@@ -94,7 +94,17 @@ When the meeting is not linked, the dialog has a **Link it** press. You choose t
94
94
 
95
95
  In **Notes**, each next step has **Make task** when the note is linked to an initiative. It adds the step to the first stage of that initiative's breakdown, with its owner and due day when the step names them, and the status says where it went. **Undo** withdraws the task. A note with no initiative explains that it must be linked first, and writes nothing. Both writes need the page's launch nonce, so an agent session is refused. A refused write shows its reason and changes nothing on screen.
96
96
 
97
- Recording and Focus stay in the console for now.
97
+ **Record.** A meeting of today that ended less than 10 minutes ago, or has not started, has a **Record** press in the dialog. Before the first press, the dialog says "Tell everyone first" and what the press does: it makes the meeting's note, or uses the one it has, and starts to listen to your microphone and the sound of the meeting. The audio and the notes stay on this machine. The console's own sheet asks where the meeting's sound comes from. While it records, the dialog shows the clock, **Pause** and **Stop**. A paused meeting stays open for one hour and has **Resume**. **Stop** asks first, because a stopped meeting cannot be resumed, and offers **Pause instead**. A refusal shows the reason and changes nothing. What the dialog shows comes from the recorder and from the notes the server holds, not from the last press. Only one meeting records at a time. A row in Today or in the week shows **Recording** or **Paused** when its note is in that state.
98
+
99
+ **The recording chip.** While a note records or is paused, every premium page shows a chip at the bottom left with its name, **Open** (the meeting's dialog on the Briefing) and **Stop**. On the Briefing it also has **Pause** and **Resume**. The browser can capture audio only while the Briefing is open, because each premium page is its own page. If you leave the Briefing while it records, the browser asks first. If you leave anyway, the meeting is paused, so the record does not say "recording" for audio that nobody captures. The chip on the next page says "Paused", and **Open** takes you back to resume. A note that the server marks as recording, while the Briefing holds no recorder, shows "marked recording, but this page is not capturing audio".
100
+
101
+ **Focus.** The dialog has a **Focus** press. Focus shows the meeting as it is now: the state (starts in, recording, paused, ended), a bar of the stretches by topic, the topic now (or the first topic before the start), the last lines of the talk with who said them, the topics, the material and the counts of decisions, next steps and questions. It reads the meeting every 3 seconds while it is open and stops when you leave it. While the note records, PMOS's companion, a read-only Claude run that sends nothing, may read the last minutes of the talk at most every 40 seconds and writes its own notes. The dialog says this before the first read. **Change** lists the topics. A press records one correction on the meeting through the console's route. If the companion is off, has not answered or has failed, Focus says so and shows only the talk. It shows no topic, line or count that the record does not hold.
102
+
103
+ **Replay.** When a recording is kept, the Replay part has a **Replay** press. The player plays the note's audio, with Back 10 s and 1x, 1.5x or 2x. It shows a bar of the stretches by topic with a mark for each decision, next step and question, the topic being talked about, the key points and the transcript. A press on a stretch, a key point or a line plays from there, and the current line is marked. A key point with no time has no play press. If no audio was kept, the playhead keeps its own clock. A screen shot is shown only when the recording holds one for that time.
104
+
105
+ In the **Add material** sheet, a **Topic** choice ties the item to one of the meeting's topics, so Focus can bring it up. It appears only when the meeting has topics.
106
+
107
+ Not built in premium: translation, Present and the slides stage, Ask PMOS quietly, Park and Add topic, the phone companion and the Meet extension view. The console keeps them.
98
108
 
99
109
  ## The dock
100
110
 
@@ -192,7 +202,7 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
192
202
 
193
203
  - **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
204
  - **Dashboards.** The switch lists All measures first, then your saved dashboards (the main one first, marked Main), then the pillars the metrics name. A saved dashboard draws its charts in the order you saved them. A chart whose record is gone, or that has fewer than two readings, is listed in its place with the reason and is not drawn.
195
- - **Make or edit a dashboard.** Press **New dashboard**, or **Edit** on a saved one. Give it a name, say what it is for, choose its measures and their order, and decide whether it is the main dashboard. **Save** records it. **Remove the dashboard** asks once more and then removes it. The dialog says when a dashboard holds more than six charts, and it still saves. 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.
205
+ - **Make or edit a dashboard.** **New dashboard**, or **Edit** on a saved one, opens the **Insight Studio**, a wide dialog. On the right, the brief shows the Name, Purpose, Charts and Main dashboard; press a chip to change it. **Library** lists the board's measures and saved dashboards to add. The preview draws the dashboard as the page will, and lists a measure with no series as not drawn. The checks (a name, a purpose, a chart, six or fewer, no repeat, a main dashboard on the board) say what fails, with a one-press fix. On the left you can say it instead: "add Partner activation", "remove …", "move … first", "call it …", "it is for …", "make it the main dashboard", "undo" or "start a new one". A turn changes the draft only. **Undo** steps back one change. **Save the dashboard** records it; **Remove the dashboard** asks once more and then removes it. In a chart's dialog, **On your dashboards** has a switch for each saved dashboard, which adds the chart to it or takes it off.
196
206
  - **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
207
  - **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
198
208
  - **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 +210,4 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
200
210
  - **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
211
  - **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
212
 
203
- Not built: the Insight Studio (making a chart or a report by conversation), 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.
213
+ 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.268.0",
3
+ "version": "0.270.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.268.0",
9
+ "version": "0.270.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.268.0",
3
+ "version": "0.270.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -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 saved dashboard: the edit dialog (PRD D4/D5). The one press posts POST /api/premium-dashboards/save. ─────────────────────────────── */
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;