create-pmos 0.278.0 → 0.280.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/bin/pmos.js +1 -1
- package/workspace/briefing-premium-test.js +16 -1
- package/workspace/guide/briefing-premium.md +10 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-welcome-test.js +213 -0
- package/workspace/public/pm/premium-first.js +36 -0
- package/workspace/public/pm/premium-shell.js +14 -3
- package/workspace/public/pm/premium-welcome-model.js +110 -0
- package/workspace/public/pm/premium-welcome.js +235 -0
- package/workspace/public/pm/premium.css +85 -0
- package/workspace/public/pm/premium.js +2 -0
- package/workspace/public/premium-welcome.html +23 -0
- package/workspace/server.js +2 -2
- package/workspace/test-files.json +2 -0
- package/workspace/test-lists/briefing-premium.json +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.280.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-18T18:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T18:55:32Z"}
|
|
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-18T18:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T18:55:32Z"}
|
|
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-18T18:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T18:55:32Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/bin/pmos.js
CHANGED
|
@@ -247,7 +247,7 @@ async function openWorkspace(dir, port, { open = true } = {}) {
|
|
|
247
247
|
} catch { first = false; }
|
|
248
248
|
}
|
|
249
249
|
if (first) say(FORCE_WELCOME ? '✓ opening Welcome' : '✓ first run — opening Welcome');
|
|
250
|
-
if (open) openBrowser(first ? `${urlOf(port)}/welcome?ws=${w.id}` : `${urlOf(port)}?ws=${w.id}`);
|
|
250
|
+
if (open) openBrowser(first ? `${urlOf(port)}/premium-welcome.html?ws=${w.id}` : `${urlOf(port)}?ws=${w.id}`);
|
|
251
251
|
return 0;
|
|
252
252
|
}
|
|
253
253
|
|
|
@@ -150,8 +150,23 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
150
150
|
ok('X8 the list re-reads and drops it, and the badge follows', !!(await until(() => p.evaluate(() => document.querySelectorAll('#oMain .ssr').length === 1 && document.querySelector('#sessBdg').textContent === '1'), 8000)));
|
|
151
151
|
const bare = await fetch(BASE + '/api/session/remove', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: 'sess-1' }) });
|
|
152
152
|
ok('X9 Stop is a page press: no nonce, no end (403)', bare.status === 403, String(bare.status));
|
|
153
|
+
/* premium-run-questions: a session whose card is asking shows the agent's own question and its offered options; a press is the one write, /api/runs/answer */
|
|
154
|
+
let asking = true; const answers = [];
|
|
155
|
+
await p.route('**/api/runs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, cards: asking ? { 'sess-1': { state: 'asking', asked: 'q-7', ask: { id: 'q-7', q: 'Which folder should the brief go in?', options: [{ label: 'planning/briefs', rec: true }, { label: 'planning/research' }] } } } : {} }) }));
|
|
156
|
+
await p.route('**/api/runs/answer', (r) => { answers.push({ ...JSON.parse(r.request().postData()), hasNonce: !!r.request().headers()['x-pmos-nonce'] }); asking = false; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
|
|
157
|
+
await p.keyboard.press('Escape'); await p.click('#sessBtn');
|
|
158
|
+
const q = await until(() => p.evaluate(() => { const b = document.querySelector('#oMain .ssq'); return b ? b.textContent : ''; }), 8000);
|
|
159
|
+
ok('Q1 a session that is asking shows its question and the options it offered, in its own words', /Which folder should the brief go in\?/.test(q) && /planning\/briefs/.test(q) && /planning\/research/.test(q), q);
|
|
160
|
+
ok('Q2 no question shows on a session that is not asking', (await p.evaluate(() => document.querySelectorAll('#oMain .ssq').length)) === 1);
|
|
161
|
+
await p.click('#oMain [data-ans="sess-1"][data-opt="planning/research"]');
|
|
162
|
+
await until(() => answers.length, 6000);
|
|
163
|
+
ok('Q3 a press sends the chosen option to /api/runs/answer with the run, the request id and the page nonce', answers.length === 1 && answers[0].run === 'sess-1' && answers[0].request === 'q-7' && answers[0].behavior === 'answer' && answers[0].message === 'planning/research' && answers[0].hasNonce, JSON.stringify(answers));
|
|
164
|
+
ok('Q4 the question leaves the row once answered, and the toast says so', !!(await until(() => p.evaluate(() => !document.querySelector('#oMain .ssq') && /Answered/.test(document.querySelector('#toast').textContent)), 6000)));
|
|
165
|
+
const bareAns = await fetch(BASE + '/api/runs/answer', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ run: 'sess-1', request: 'q-7', behavior: 'answer', message: 'planning/research' }) });
|
|
166
|
+
ok('Q5 answering is a page press: no nonce, no answer (403)', bareAns.status === 403, String(bareAns.status));
|
|
167
|
+
await p.unroute('**/api/runs'); await p.unroute('**/api/runs/answer');
|
|
153
168
|
await p.keyboard.press('Escape'); await p.unroute('**/api/sessions'); await p.unroute('**/api/session/remove');
|
|
154
|
-
for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/session\/remove$/.test(A.reqs[i])) A.reqs.splice(i, 1); }
|
|
169
|
+
for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/(session\/remove|runs\/answer)$/.test(A.reqs[i])) A.reqs.splice(i, 1); }
|
|
155
170
|
|
|
156
171
|
/* R2 */
|
|
157
172
|
const hero = await p.evaluate(() => ({ text: document.querySelector('#brief').textContent, k: [...document.querySelectorAll('#brief .k')].map((x) => x.textContent) }));
|
|
@@ -15,7 +15,7 @@ Every premium page has an **Open the console** button beside the theme button. I
|
|
|
15
15
|
|
|
16
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
|
-
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.
|
|
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. When a session has asked a question, its row shows the question in the agent's own words with the options it offered; a press sends that option as your answer, and the question leaves the row. A permission request ("Wants to run"), terminals and new sessions stay in the console; the dialog links to it. Answering needs the page's launch nonce, so an agent session cannot call it.
|
|
19
19
|
|
|
20
20
|
## Products
|
|
21
21
|
|
|
@@ -248,6 +248,15 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
248
248
|
|
|
249
249
|
Not built: a second measure next to a chart, bar highlights, speaker notes and notes on a slide, changing a set-up report's audience, format or schedule, tile sizes and free layout, the finder's settings, run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
|
|
250
250
|
|
|
251
|
+
## Welcome
|
|
252
|
+
|
|
253
|
+
Welcome is the premium first-run page, at `/premium-welcome.html`. It is a page of its own, with no rail. `pmos` opens it on a first run. The older `/welcome` page stays at its address.
|
|
254
|
+
|
|
255
|
+
- **About you.** Your name, role and the few lines PMOS should know. **Continue** saves them to the workspace's proactive settings.
|
|
256
|
+
- **Your sources.** Choose the tools PMOS may read (calendar, Jira, mail, Slack) and add folders. **Look at my work** starts the chosen tools, scans, and shows what it found.
|
|
257
|
+
- **What PMOS found.** The initiatives, the board each goes to, and the defaults, with a count. You can change a board or a title before you import. **Import** applies the import and opens the premium Briefing with a first card that lists what came in and each tool's state, and an **Undo** that reverses the import and returns here. **Not now** dismisses the import and opens the Briefing.
|
|
258
|
+
- If the workspace already holds an import, the page goes straight to the Briefing with the first card. After an Undo the found step shows the rows but not the first-look sentence, because PMOS does not keep it. An agent session cannot make the writes; a refused import shows the server's reason.
|
|
259
|
+
|
|
251
260
|
## The default page
|
|
252
261
|
|
|
253
262
|
The premium Briefing is the default page: `/` and `/index.html` open it. The console is at `/console.html`, and the header button **Open the console** on each premium page goes there. The old address `/c3.html` goes to the premium Briefing; with a query (for example `/c3.html?tab=rep`) it goes to `/console.html` with the same query. `/classic.html` is unchanged. To go back, change the last page name in the page-route chain in `server.js` from `premium.html` to `c3.html` and delete the `/c3.html` redirect above it.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.280.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.280.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-welcome-test.js — the premium Welcome page and the first-Briefing card (initiative premium-welcome; planning/prd/premium-welcome-prd.md R1 to R11).
|
|
4
|
+
* Serves the real pages from the real server. The onboarding routes, the proactive settings and the source routes are answered by stand-ins, so each press can be
|
|
5
|
+
* read off the request the page sent. The routes' own behaviour is in their own suites (pm-welcome-test.js, the onboarding suites).
|
|
6
|
+
* R1 own address · R2 About you · R3 sources · R4 found · R5 defaults · R6 import · R7 first card · R8 not now · R9 already imported · R10 writes · R11 floors and fidelity
|
|
7
|
+
* Every wait polls the page; no fixed sleep stands in for a state. */
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { spawn, spawnSync } = require('child_process');
|
|
12
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
13
|
+
const T = require('./test-run').configure({ name: 'premium-welcome' });
|
|
14
|
+
const B = require('./lib/briefing-premium.js');
|
|
15
|
+
const F = require('./fixtures/briefing-premium-facts.js');
|
|
16
|
+
|
|
17
|
+
const BASE = T.BASE;
|
|
18
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
19
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
20
|
+
const results = [];
|
|
21
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
|
|
22
|
+
let srv = null; let browser = null;
|
|
23
|
+
const finish = async (code) => {
|
|
24
|
+
if (browser) await browser.close().catch(() => {});
|
|
25
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
26
|
+
T.killTmux();
|
|
27
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
28
|
+
console.log(`\n${results.length - bad}/${results.length} premium-welcome browser assertions passed`);
|
|
29
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
30
|
+
};
|
|
31
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
32
|
+
|
|
33
|
+
const mockupFile = path.join(os.tmpdir(), `premium-welcome-mockup-${process.pid}.html`);
|
|
34
|
+
const built = spawnSync('python3', [path.join(__dirname, '..', 'prototype', 'premium-welcome', 'build.py'), mockupFile], { encoding: 'utf8' });
|
|
35
|
+
|
|
36
|
+
const STRUCT = {
|
|
37
|
+
ok: true,
|
|
38
|
+
boards: [
|
|
39
|
+
{ key: 'payments', name: 'Payments', unsorted: [{}, {}, {}], initiatives: [
|
|
40
|
+
{ proposal_id: 'p1', title: 'Refund reason codes', lane: 'feature', anchor: null, stage: 'Specified', checked: true, docs: [{ file: 'payments/refund-codes-prd.md' }, { file: 'payments/x.md' }] },
|
|
41
|
+
{ proposal_id: 'p3', title: 'Card vault migration', lane: 'feature', anchor: 'KR-P1', stage: 'Done', checked: false, docs: [{ file: 'a.md' }] }] },
|
|
42
|
+
{ key: 'growth', name: 'Growth', unsorted: [], initiatives: [{ proposal_id: 'g1', title: 'Win-back emails', lane: 'feature', anchor: 'KR-G1', stage: 'Building', checked: true, docs: [] }] }],
|
|
43
|
+
questions: [{ id: 'anchor', text: 'Anchor for the ones with none', default: 'per-board', options: [{ value: 'per-board', label: 'Each board’s domain anchor' }, { value: 'health:upkeep', label: 'health:upkeep for all' }] },
|
|
44
|
+
{ id: 'fiscal', text: 'Fiscal year starts', default: 'January' }],
|
|
45
|
+
};
|
|
46
|
+
const LOOK = { sentence: '214 files read. 3 initiatives on 2 boards, 41 documents.', findings: [
|
|
47
|
+
{ title: 'Deadline 30 Oct has no owner', why: 'A date within 30 days names no owner.', evidence: [{ file: 'payments/refund-codes-prd.md', line: 14 }] },
|
|
48
|
+
{ title: '<img src=x onerror="window.__pwn=1">', why: '<b>bold</b>', evidence: [{ file: 'growth/pricing.md' }] }] };
|
|
49
|
+
const BRIEFING = { ok: true, items: [{ title: 'Refund reason codes needs an anchor you confirm', why: 'It had no anchor.', evidence: [{ file: 'payments/refund-codes-prd.md', line: 1 }], initiative: { title: 'Refund reason codes', board: 'payments' } }] };
|
|
50
|
+
|
|
51
|
+
(async () => {
|
|
52
|
+
const exe = findBrowser();
|
|
53
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
54
|
+
let chromium;
|
|
55
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
56
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
57
|
+
await T.waitForServer(BASE);
|
|
58
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
59
|
+
const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
|
|
60
|
+
|
|
61
|
+
/* opts: status (the onboarding status answer), applyError, toolError, briefing, structure, w, h, theme, touch, url, tools (the sessionStorage record the first card reads) */
|
|
62
|
+
const open = async ({ url = '/premium-welcome.html?ws=w1', w = 1280, h = 900, theme = 'light', touch = false, status = { ok: true, state: 'new', first_run: true, imports: [] }, applyError = null, toolError = null, briefing = BRIEFING, structure = STRUCT, tools = null } = {}) => {
|
|
63
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h }, hasTouch: touch, isMobile: touch });
|
|
64
|
+
const page = await ctx.newPage();
|
|
65
|
+
const S = { errors: [], reqs: [], posts: [], headers: [], dismissed: 0, undone: [], settings: { name: 'Dana', about: { role: 'Senior PM', work: '', duties: '' } }, applied: [] };
|
|
66
|
+
page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
|
|
67
|
+
page.on('request', (r) => { if (r.url().startsWith(BASE)) { const u = new URL(r.url()); if (u.pathname.startsWith('/api/')) S.reqs.push(r.method() + ' ' + u.pathname); if (r.method() === 'POST') S.headers.push(r.headers()['x-pmos-nonce'] || ''); } });
|
|
68
|
+
const body = (r) => JSON.parse(r.request().postData() || '{}');
|
|
69
|
+
await page.route('**/api/workspaces', (r) => (r.request().method() === 'GET' ? json(r, { workspaces: [{ id: 'w1', name: 'checkout-team', root: '/home/u/checkout-team' }, { id: 'w2', name: 'growth-notes', root: '/home/u/growth-notes' }] }) : (S.posts.push(['workspaces', body(r)]), json(r, { workspace: { id: 'w2', name: 'growth-notes', root: '/home/u/growth-notes' } }))));
|
|
70
|
+
await page.route('**/api/pick-folder', (r) => { S.posts.push(['pick-folder', body(r)]); return json(r, { ok: true, root: '/home/u/growth-notes' }); });
|
|
71
|
+
await page.route('**/api/proactive/settings', (r) => { if (r.request().method() === 'GET') return json(r, { ok: true, settings: S.settings }); const b = body(r); S.posts.push(['settings', b]); return json(r, { ok: true }); });
|
|
72
|
+
await page.route('**/api/proactive/goals/plan', (r) => { S.posts.push(['plan', body(r)]); return json(r, { ok: true }); });
|
|
73
|
+
await page.route('**/api/sources/refresh', (r) => { const b = body(r); S.posts.push(['refresh', b]); return toolError && b.source === toolError.source ? json(r, { ok: false, error: toolError.error }, 409) : json(r, { ok: true }); });
|
|
74
|
+
await page.route('**/api/onboarding/status*', (r) => json(r, status));
|
|
75
|
+
await page.route('**/api/onboarding/scan', (r) => { S.posts.push(['scan', body(r)]); return json(r, { ok: true, scan_id: 's1', first_look: LOOK }); });
|
|
76
|
+
await page.route('**/api/onboarding/structure*', (r) => json(r, structure));
|
|
77
|
+
await page.route('**/api/onboarding/apply', (r) => { const b = body(r); S.posts.push(['apply', b]); S.applied.push(b); return applyError ? json(r, { ok: false, error: applyError }, 400) : json(r, { ok: true, import_id: 'imp1', boards: 2, initiatives: b.include.length }); });
|
|
78
|
+
await page.route('**/api/onboarding/briefing*', (r) => json(r, briefing));
|
|
79
|
+
await page.route('**/api/onboarding/dismiss', (r) => { S.dismissed++; S.posts.push(['dismiss', body(r)]); return json(r, { ok: true }); });
|
|
80
|
+
await page.route('**/api/onboarding/undo', (r) => { S.undone.push(body(r)); S.posts.push(['undo', body(r)]); return json(r, { ok: true, retracted: 1 }); });
|
|
81
|
+
await page.route('**/api/briefing-premium*', (r) => json(r, { ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }));
|
|
82
|
+
if (tools) await page.addInitScript((t) => { try { sessionStorage.setItem('pmos.welcome.tools', t); } catch { /* none */ } }, JSON.stringify(tools));
|
|
83
|
+
await page.goto(BASE + url + (url.includes('?') ? '&' : '?') + 'theme=' + theme);
|
|
84
|
+
return { ctx, page, S };
|
|
85
|
+
};
|
|
86
|
+
const text = (page, sel) => page.evaluate((s) => { const e = document.querySelector(s); return e ? e.textContent.replace(/\s+/g, ' ').trim() : null; }, sel);
|
|
87
|
+
const heading = (page, re) => until(() => page.evaluate((src) => new RegExp(src).test((document.querySelector('#wlH') || {}).textContent || ''), re.source));
|
|
88
|
+
const click = (page, sel) => page.evaluate((s) => document.querySelector(s).click(), sel);
|
|
89
|
+
const fillIn = async (page, sel, v) => { await page.fill(sel, v); };
|
|
90
|
+
|
|
91
|
+
if (built.status !== 0) { ok('the mockup builds (prototype/premium-welcome/build.py)', false, built.stderr); return finish(1); }
|
|
92
|
+
|
|
93
|
+
/* ── the whole flow ──────────────────────────────────────────────────────────────────────── */
|
|
94
|
+
const P = await open();
|
|
95
|
+
ok('R1 the page is served at its own address with the launch nonce', await until(() => P.page.evaluate(() => (document.querySelector('meta[name="pmos-nonce"]').content || '').length > 8)));
|
|
96
|
+
ok('R2 About you opens on its heading and is prefilled from the proactive settings', await heading(P.page, /Welcome to PMOS/) && await P.page.inputValue('[data-f=name]') === 'Dana' && await P.page.inputValue('[data-f=role]') === 'Senior PM');
|
|
97
|
+
ok('R2 the step bar and count say step 1 of 3', /step 1 of 3/.test(await text(P.page, '#wlCount')) && (await P.page.$$('#wlSteps li')).length === 3);
|
|
98
|
+
await fillIn(P.page, '[data-f=work]', 'I run checkout'); await fillIn(P.page, '[data-f=name]', 'Dana K');
|
|
99
|
+
await click(P.page, '[data-w=about]');
|
|
100
|
+
ok('R2 Continue saves the four fields through the proactive settings and moves on', await heading(P.page, /Where does your work live/) && JSON.stringify(P.S.posts.find((p) => p[0] === 'settings')[1]) === JSON.stringify({ name: 'Dana K', about: { role: 'Senior PM', work: 'I run checkout', duties: '' } }));
|
|
101
|
+
ok('R3 the folder being set up is listed, and each tool is Off until ticked', /checkout-team/.test(await text(P.page, '#wlCard')) && await P.page.evaluate(() => [...document.querySelectorAll('[data-w=tool]')].length === 4 && [...document.querySelectorAll('[data-w=tool]')].every((b) => b.getAttribute('aria-pressed') === 'false' && /Off/.test(b.textContent))));
|
|
102
|
+
ok('R3 nothing was read or started before Scan', !P.S.posts.some((p) => ['scan', 'plan', 'refresh'].includes(p[0])) && !P.S.reqs.some((r) => /onboarding\/(scan|structure)|sources\/refresh/.test(r)));
|
|
103
|
+
await click(P.page, '[data-w=folder]'); await until(() => P.page.evaluate(() => /growth-notes/.test(document.querySelector('#wlCard').textContent)));
|
|
104
|
+
ok('R3 Add another folder asks the chooser and registers the folder without focusing it', P.S.posts.some((p) => p[0] === 'pick-folder') && JSON.stringify(P.S.posts.find((p) => p[0] === 'workspaces')[1]) === JSON.stringify({ root: '/home/u/growth-notes', name: 'growth-notes', focus: false }));
|
|
105
|
+
await click(P.page, '[data-w=tool][data-k=calendar]'); await click(P.page, '[data-w=tool][data-k=inbox]');
|
|
106
|
+
ok('R3 the Scan button names the tools it will read', /Scan the folder and read 2 tools/.test(await text(P.page, '[data-w=scan]')));
|
|
107
|
+
await click(P.page, '[data-w=scan]');
|
|
108
|
+
ok('R4 the scan ends on What PMOS found', await heading(P.page, /What PMOS found/));
|
|
109
|
+
const posts = P.S.posts.map((p) => p[0]);
|
|
110
|
+
ok('R3 Scan turned the Inbox on for the Briefing, prepared the day, refreshed Calendar only, then scanned with the added folder', JSON.stringify(P.S.posts.find((p) => p[0] === 'settings' && p[1].briefSources)[1]) === '{"briefSources":{"mail":true}}' && posts.includes('plan') && P.S.posts.filter((p) => p[0] === 'refresh').map((p) => p[1].source).join() === 'calendar' && JSON.stringify(P.S.posts.find((p) => p[0] === 'scan')[1].extra_roots) === '["/home/u/growth-notes"]');
|
|
111
|
+
ok('R4 the scan\'s sentence and findings are shown with their file and line', /214 files read/.test(await text(P.page, '.wl-lede')) && /payments\/refund-codes-prd\.md:14/.test(await text(P.page, '#wlCard')));
|
|
112
|
+
ok('R10 text taken from the folder is text: no element was made from it', await P.page.evaluate(() => !window.__pwn && !document.querySelector('#wlCard img') && /<img src=x/.test(document.querySelector('#wlCard').textContent) && !document.querySelector('#wlCard b + small b')));
|
|
113
|
+
ok('R4 the portfolio shows each board with its unsorted count and each row with lane, anchor, stage and documents', /Payments/.test(await text(P.page, '.wl-bh')) && /3 documents unsorted/.test(await text(P.page, '.wl-bh')) && /feature · no anchor · Specified · 2 documents/.test(await text(P.page, '.wl-ed')));
|
|
114
|
+
ok('R4 the row the scan proposed unchecked starts left out, and the button counts the others', await P.page.evaluate(() => document.querySelectorAll('.wl-ed.off').length === 1) && /Import 2 initiatives into 2 boards/.test(await text(P.page, '[data-w=import]')));
|
|
115
|
+
await click(P.page, '[data-w=inc][data-id=g1]');
|
|
116
|
+
ok('R4 Leave out takes a row from the count and Edit is off for it', /Import 1 initiative into 1 board/.test(await text(P.page, '[data-w=import]')) && await P.page.evaluate(() => document.querySelector('[data-w=edit][data-id=g1]').disabled));
|
|
117
|
+
await click(P.page, '[data-w=inc][data-id=g1]'); await click(P.page, '[data-w=inc][data-id=p3]');
|
|
118
|
+
ok('R4 a left-out row can be brought back, and a left-in one counts', /Import 3 initiatives into 2 boards/.test(await text(P.page, '[data-w=import]')));
|
|
119
|
+
await click(P.page, '[data-w=inc][data-id=p3]');
|
|
120
|
+
await click(P.page, '[data-w=edit][data-id=p1]'); await fillIn(P.page, '[data-f=title][data-id=p1]', 'Refund codes');
|
|
121
|
+
await P.page.selectOption('[data-f=board][data-id=p1]', 'growth');
|
|
122
|
+
ok('R4 Edit changes the title and the board of a row', await until(() => P.page.evaluate(() => document.querySelector('[data-f=title][data-id=p1]').value === 'Refund codes')) && /Import 2 initiatives into 1 board/.test(await text(P.page, '[data-w=import]')));
|
|
123
|
+
ok('R5 the defaults list each scan question with the default it will send', /Anchor for the ones with none/.test(await text(P.page, '.wl-def')) && /Each board’s domain anchor/.test(await text(P.page, '.wl-def')) && /January/.test(await text(P.page, '.wl-def')));
|
|
124
|
+
await click(P.page, '[data-w=defs]'); await P.page.selectOption('[data-f=answer][data-id=anchor]', 'health:upkeep'); await click(P.page, '[data-w=skipq][data-id=fiscal]');
|
|
125
|
+
ok('R5 Change the defaults shows the inputs, and a skipped question says nothing is sent', await until(() => P.page.evaluate(() => /Skipped\. Nothing is sent/.test(document.querySelector('.wl-def dl').textContent))) && /health:upkeep/.test(await text(P.page, '.wl-def dl')));
|
|
126
|
+
await click(P.page, '[data-w=import]');
|
|
127
|
+
ok('R6 Import posts once with the ticked ids, the revisions and the answers', await until(() => P.S.applied.length === 1) && JSON.stringify(P.S.applied[0]) === JSON.stringify({ ws: 'w1', include: ['p1', 'g1'], revisions: { p1: { title: 'Refund codes', board: 'growth' } }, answers: { anchor: 'health:upkeep' } }), JSON.stringify(P.S.applied));
|
|
128
|
+
ok('R6 the page then lands on the premium Briefing with the import id', await until(() => P.page.url().includes('/premium.html?ws=w1&first=imp1'), 15000), P.page.url());
|
|
129
|
+
ok('R10 every write carried the launch nonce', P.S.headers.length > 5 && P.S.headers.every((h) => h.length > 8));
|
|
130
|
+
const allowed = /^(GET \/api\/(workspaces|proactive\/settings|onboarding\/(status|structure|briefing)|briefing-premium|notes|premium-[a-z-]+|calendar-views|search|bell|sessions[a-z/-]*|board-metrics-premium|[a-z-]+)|POST \/api\/(proactive\/settings|proactive\/goals\/plan|pick-folder|workspaces|sources\/refresh|onboarding\/(scan|apply|dismiss|undo)))$/;
|
|
131
|
+
const welcomeReqs = P.S.reqs.slice(0, P.S.reqs.findIndex((r) => /briefing-premium/.test(r)) > 0 ? P.S.reqs.findIndex((r) => /briefing-premium/.test(r)) : P.S.reqs.length);
|
|
132
|
+
ok('R10 Welcome sent no request beyond the onboarding, settings and source routes', welcomeReqs.every((r) => allowed.test(r)), welcomeReqs.filter((r) => !allowed.test(r)).join());
|
|
133
|
+
ok('R10 no script error on the way', P.S.errors.length === 0, P.S.errors.join(' | '));
|
|
134
|
+
|
|
135
|
+
/* R7 the first-Briefing card, and Undo */
|
|
136
|
+
const C = await open({ url: '/premium.html?ws=w1&first=imp1', tools: { calendar: { started: true }, inbox: { error: 'No connection for Inbox.' } } });
|
|
137
|
+
ok('R7 the card sits above the columns with the import\'s item, its initiative and its file', await until(() => C.page.evaluate(() => { const c = document.querySelector('#wlFirst'); return !!c && c.nextElementSibling && c.nextElementSibling.classList.contains('cols2') && /Refund reason codes needs an anchor/.test(c.textContent) && /payments board/.test(c.textContent) && /refund-codes-prd\.md:1/.test(c.textContent); })));
|
|
138
|
+
ok('R7 the card lists the ticked tools: one being read, one with its reason', await C.page.evaluate(() => /Calendar is being read in an agent session/.test(document.querySelector('#wlFirst').textContent) && /No connection for Inbox\./.test(document.querySelector('#wlFirst').textContent) && !/Slack|Jira/.test(document.querySelector('#wlFirst').textContent)));
|
|
139
|
+
await click(C.page, '#wlUndo');
|
|
140
|
+
ok('R7 Undo this import retracts that import and returns to the found step', await until(() => C.S.undone.length === 1) && JSON.stringify(C.S.undone[0]) === '{"ws":"w1","import_id":"imp1"}' && await until(() => C.page.url().includes('/premium-welcome.html?ws=w1&step=found')) && await heading(C.page, /What PMOS found/));
|
|
141
|
+
ok('R7 the found step after Undo shows no first-look sentence it does not hold', await C.page.evaluate(() => !document.querySelector('.wl-lede') && !/Nothing in this folder needs you/.test(document.querySelector('#wlCard').textContent) && document.querySelectorAll('.wl-ed').length === 3));
|
|
142
|
+
await C.ctx.close();
|
|
143
|
+
const E = await open({ url: '/premium.html?ws=w1&first=imp9', briefing: { ok: true, items: [] } });
|
|
144
|
+
ok('R7 a Briefing with no items says nothing needs the PM and lists nothing', await until(() => E.page.evaluate(() => { const c = document.querySelector('#wlFirst'); return !!c && /Nothing needs you right now/.test(c.textContent) && !c.querySelector('ol'); })));
|
|
145
|
+
await E.ctx.close();
|
|
146
|
+
const N = await open({ url: '/premium.html?ws=w1' });
|
|
147
|
+
ok('R7 without first= the Briefing has no first card', await until(() => N.page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0)) && await N.page.evaluate(() => !document.querySelector('#wlFirst')));
|
|
148
|
+
await N.ctx.close();
|
|
149
|
+
|
|
150
|
+
/* R8 not now, R9 already imported */
|
|
151
|
+
const Q = await open();
|
|
152
|
+
await heading(Q.page, /Welcome to PMOS/); await click(Q.page, '#wlSkip');
|
|
153
|
+
ok('R8 Not now dismisses the first run for this folder and lands on the premium Briefing, and writes nothing else', await until(() => Q.page.url().includes('/premium.html?ws=w1')) && Q.S.dismissed === 1 && Q.S.posts.every((p) => p[0] === 'dismiss'));
|
|
154
|
+
await Q.ctx.close();
|
|
155
|
+
const R = await open({ status: { ok: true, state: 'imported', first_run: false, imports: [{ import_id: 'old', retracted: true }, { import_id: 'imp7' }] } });
|
|
156
|
+
ok('R9 a folder with a live import goes to that import\'s card', await until(() => R.page.url().includes('/premium.html?ws=w1&first=imp7'), 15000), R.page.url());
|
|
157
|
+
await R.ctx.close();
|
|
158
|
+
|
|
159
|
+
/* failures say why and change nothing */
|
|
160
|
+
const X = await open({ applyError: 'the import stopped: a board is missing', toolError: { source: 'calendar', error: 'No calendar connection.' } });
|
|
161
|
+
await heading(X.page, /Welcome to PMOS/); await click(X.page, '[data-w=about]'); await heading(X.page, /Where does your work/);
|
|
162
|
+
await click(X.page, '[data-w=tool][data-k=calendar]'); await click(X.page, '[data-w=scan]'); await heading(X.page, /What PMOS found/);
|
|
163
|
+
ok('R3 a tool that cannot start does not stop the scan', X.S.posts.some((p) => p[0] === 'scan'));
|
|
164
|
+
await click(X.page, '[data-w=import]');
|
|
165
|
+
ok('R6 a refused import shows the server\'s reason, stays on the found step and keeps the choices', await until(() => X.page.evaluate(() => /a board is missing/.test((document.querySelector('.wl-err') || {}).textContent || ''))) && /What PMOS found/.test(await text(X.page, '#wlH')) && X.page.url().includes('premium-welcome') && await X.page.evaluate(() => document.querySelectorAll('.wl-ed.off').length === 1));
|
|
166
|
+
await click(X.page, '[data-w=inc][data-id=p1]'); await click(X.page, '[data-w=inc][data-id=g1]');
|
|
167
|
+
ok('R6 with nothing to import the button is off', await X.page.evaluate(() => document.querySelector('[data-w=import]').disabled && /Import 0 initiatives into 0 boards/.test(document.querySelector('[data-w=import]').textContent)));
|
|
168
|
+
await X.ctx.close();
|
|
169
|
+
|
|
170
|
+
/* R11 floors and fidelity */
|
|
171
|
+
let mk = null; let mp = { close: async () => {} };
|
|
172
|
+
const mkOf = async (w, th) => { if (mk) await mk.close(); mk = await browser.newContext({ viewport: { width: w, height: w === 390 ? 800 : 900 }, colorScheme: th }); return mk; };
|
|
173
|
+
const mockupHtml = fs.readFileSync(mockupFile, 'utf8');
|
|
174
|
+
const pick = (sel, props) => (s, p) => document.querySelector(s) && p.map((k) => getComputedStyle(document.querySelector(s))[k]).join('|');
|
|
175
|
+
const css = (page, sel, props) => page.evaluate(([s, p]) => { const e = document.querySelector(s); if (!e) return null; const k = getComputedStyle(e); return p.map((n) => k[n]).join('|'); }, [sel, props]);
|
|
176
|
+
const CMP = [
|
|
177
|
+
['the brand pill', '.wl-brand', ['fontWeight', 'fontSize', 'borderRadius', 'height', 'paddingLeft']],
|
|
178
|
+
['the heading', '#wlH', ['fontSize', 'fontWeight', 'letterSpacing', 'lineHeight', 'color']],
|
|
179
|
+
['the lede', '.wl-lede', ['fontSize', 'color', 'maxWidth']],
|
|
180
|
+
['a field label', '.wl-f label', ['fontSize', 'fontWeight', 'color']],
|
|
181
|
+
['a field', '.wl-f input', ['height', 'borderRadius', 'paddingLeft', 'fontSize', 'backgroundColor']],
|
|
182
|
+
['the text area', '.wl-f textarea', ['minHeight', 'borderRadius', 'lineHeight']],
|
|
183
|
+
['the main button', '.wl-foot .wl-btn', ['height', 'borderRadius', 'fontWeight', 'backgroundColor', 'color', 'paddingLeft']],
|
|
184
|
+
['the card', '.wl-card', ['borderRadius', 'paddingLeft', 'backgroundColor']],
|
|
185
|
+
['a step label', '.wl-steps li span', ['fontSize', 'fontWeight', 'letterSpacing', 'textTransform']],
|
|
186
|
+
];
|
|
187
|
+
for (const [w, th] of [[1280, 'light'], [1280, 'dark'], [390, 'light'], [390, 'dark']]) {
|
|
188
|
+
const A = await open({ w, h: w === 390 ? 800 : 900, theme: th, touch: w === 390 });
|
|
189
|
+
await heading(A.page, /Welcome to PMOS/);
|
|
190
|
+
await mp.close(); mp = await (await mkOf(w, th)).newPage(); await mp.goto('file://' + mockupFile); await mp.evaluate((t) => { document.documentElement.dataset.theme = t; }, th); await mp.waitForTimeout(500);
|
|
191
|
+
const diffs = [];
|
|
192
|
+
for (const [name, sel, props] of CMP) { const a = await css(A.page, sel, props), m = await css(mp, sel, props); if (a !== m) diffs.push(`${name}: ${a} vs ${m}`); }
|
|
193
|
+
ok(`R11 fidelity at ${w} px (${th}): About you keeps the mockup's type, radii, colours and sizes`, diffs.length === 0, diffs.join(' ; '));
|
|
194
|
+
const scrolls = [];
|
|
195
|
+
const floor = async (label) => scrolls.push(await A.page.evaluate((l) => ({ l, scroll: document.documentElement.scrollWidth <= innerWidth + 1, btn: [...document.querySelectorAll('#wlCard button, #wlSkip')].filter((b) => b.offsetParent).map((b) => Math.round(b.getBoundingClientRect().height)) }), label));
|
|
196
|
+
await floor('about'); await click(A.page, '[data-w=about]'); await heading(A.page, /Where does your work/); await floor('sources');
|
|
197
|
+
await click(A.page, '[data-w=scan]'); await heading(A.page, /What PMOS found/); await floor('found');
|
|
198
|
+
const foot = await A.page.evaluate(() => { const f = document.querySelector('.wl-foot').getBoundingClientRect(); return [Math.round(f.bottom), innerHeight]; });
|
|
199
|
+
ok(`R11 at ${w} px (${th}) the three steps have no sideways scroll${w === 390 ? ' and every press is at least 44 px' : ''}`, scrolls.every((s) => s.scroll) && (w !== 390 || scrolls.every((s) => s.btn.length && s.btn.every((n) => n >= 43.5))), JSON.stringify(scrolls));
|
|
200
|
+
if (w === 390) ok('R11 at 390 px the footer buttons stay at the bottom of the screen on the found step', foot[0] >= foot[1] - 2 && foot[0] <= foot[1] + 2, foot.join('/'));
|
|
201
|
+
if (th === 'light' && w === 1280) {
|
|
202
|
+
await mp.goto('file://' + mockupFile + '#found'); await mp.reload(); await mp.waitForTimeout(500);
|
|
203
|
+
const FCMP = [['a row', '.wl-ed .wl-row', ['display', 'gap', 'paddingLeft']], ['a row button', '.wl-ed .wgo', ['height', 'borderRadius', 'fontSize', 'fontWeight']], ['a section label', '.wl-sec', ['fontSize', 'letterSpacing', 'textTransform', 'color']], ['the defaults box', '.wl-def', ['borderRadius', 'borderTopStyle', 'paddingLeft']]];
|
|
204
|
+
const d2 = [];
|
|
205
|
+
for (const [name, sel, props] of FCMP) { const a = await css(A.page, sel, props), m = await css(mp, sel, props); if (a !== m) d2.push(`${name}: ${a} vs ${m}`); }
|
|
206
|
+
ok('R11 fidelity: the found step\'s rows, buttons, labels and defaults box keep the mockup\'s styles', d2.length === 0, d2.join(' ; '));
|
|
207
|
+
}
|
|
208
|
+
await A.ctx.close();
|
|
209
|
+
}
|
|
210
|
+
if (mk) await mk.close();
|
|
211
|
+
try { fs.unlinkSync(mockupFile); } catch { /* gone */ }
|
|
212
|
+
finish();
|
|
213
|
+
})();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* pm/premium-first.js — the "Your first Briefing" card on the premium Briefing (initiative premium-welcome). It shows only when the page was opened with
|
|
2
|
+
* first=<import id>, which the premium Welcome sets after an import. It reads GET /api/onboarding/briefing, lists each item, the state of the tools the PM
|
|
3
|
+
* ticked (what Welcome recorded in this browser) and Undo this import (POST /api/onboarding/undo), which goes back to Welcome's found step.
|
|
4
|
+
* The card keeps the page's own rows untouched: it is inserted above the columns. Text from the scanned folder is untrusted and goes through esc(). */
|
|
5
|
+
import { pmGet, pmPost } from './http.js';
|
|
6
|
+
import { firstView, FIRST_KEY } from './premium-welcome-model.js';
|
|
7
|
+
|
|
8
|
+
const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
9
|
+
const SUN = '<svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>';
|
|
10
|
+
|
|
11
|
+
function toolState() {
|
|
12
|
+
try { return JSON.parse(sessionStorage.getItem(FIRST_KEY) || '{}'); } catch { return {}; }
|
|
13
|
+
}
|
|
14
|
+
export async function mountFirst() {
|
|
15
|
+
const q = new URLSearchParams(location.search), id = q.get('first'), ws = q.get('ws') || '';
|
|
16
|
+
const cols = document.querySelector('.cols2');
|
|
17
|
+
if (!id || !cols || document.getElementById('wlFirst')) return;
|
|
18
|
+
const r = await pmGet(`/api/onboarding/briefing?ws=${encodeURIComponent(ws)}`);
|
|
19
|
+
const v = firstView(r, toolState());
|
|
20
|
+
const sec = document.createElement('section');
|
|
21
|
+
sec.className = 'card wl-first'; sec.id = 'wlFirst'; sec.setAttribute('aria-labelledby', 'hWl');
|
|
22
|
+
const items = v.items.map((f, i) => `<li class="wl-row"><span class="wl-ic wl-n">${String(i + 1).padStart(2, '0')}</span><span><b>${esc(f.title)}</b>${f.why ? `<small>${esc(f.why)}</small>` : ''}<span class="path">${f.ini ? esc(f.ini) + ' · ' : ''}${esc(f.ref)}</span></span><span></span></li>`).join('');
|
|
23
|
+
const tools = v.tools.map((t) => `<li class="wl-row"><span class="wl-ic">${SUN}</span><span><b>${esc(t.name)}</b><small${t.started ? '' : ' class="wl-bad"'}>${t.started ? `${esc(t.name)} is being read in an agent session. Its items join your Briefing when it finishes.` : esc(t.error || 'It did not start.')}</small></span><span></span></li>`).join('');
|
|
24
|
+
sec.innerHTML = `<div class="ch"><span class="ic">${SUN}</span><h2 id="hWl">Your first Briefing</h2><small>From the scan</small></div>
|
|
25
|
+
<p class="note wl-first-note">${r && r.ok ? (v.calm ? 'Your portfolio is in. Nothing needs you right now.' : 'Your portfolio is in. These need you first.') : esc((r && r.error) || 'The scan\'s Briefing could not be read.')}</p>
|
|
26
|
+
${items ? `<ol class="wl-list">${items}</ol>` : ''}${tools ? `<p class="wl-sec">Your tools</p><ul class="wl-list">${tools}</ul>` : ''}
|
|
27
|
+
<div class="wl-actions"><button class="wl-btn alt" type="button" id="wlUndo">Undo this import</button></div><p class="note wl-first-err" id="wlUndoErr" role="alert" hidden></p>`;
|
|
28
|
+
cols.parentNode.insertBefore(sec, cols);
|
|
29
|
+
document.addEventListener('click', async (e) => {
|
|
30
|
+
const b = e.target.closest('#wlUndo'); if (!b || b.disabled) return;
|
|
31
|
+
b.disabled = true;
|
|
32
|
+
const u = await pmPost('/api/onboarding/undo', { ws, import_id: id });
|
|
33
|
+
if (!u || !u.ok) { b.disabled = false; const e = document.getElementById('wlUndoErr'); e.textContent = (u && u.error) || 'Undo did not work.'; e.hidden = false; return; }
|
|
34
|
+
location.assign('/premium-welcome.html?ws=' + encodeURIComponent(ws) + '&step=found');
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -402,6 +402,8 @@ export async function openSettings() {
|
|
|
402
402
|
* session and a run's questions stay in the console. Every word on a row is a field of the session record. */
|
|
403
403
|
const sessLive = (s) => s && s.shown !== 'exited';
|
|
404
404
|
const readSessions = async () => { const r = await pmGet('/api/sessions'); return r && Array.isArray(r.sessions) ? r.sessions.filter(sessLive) : null; };
|
|
405
|
+
// The cards the console's run card reads (GET /api/runs): a session whose card is asking carries the agent's own question and the options it offered.
|
|
406
|
+
const readAsks = async () => { const r = await pmGet('/api/runs'); const out = {}; if (r && r.ok && r.cards) for (const [id, c] of Object.entries(r.cards)) if (c && c.state === 'asking' && c.ask && c.ask.q && Array.isArray(c.ask.options) && c.ask.options.length) out[id] = { request: c.asked || c.ask.id, q: c.ask.q, options: c.ask.options }; return out; };
|
|
405
407
|
const sessAgo = (t) => { const ms = Date.now() - new Date(t).getTime(); if (!(ms >= 0)) return ''; const m = Math.max(1, Math.round(ms / 60000)); return 'Started ' + (m < 60 ? m + ' min ago' : Math.floor(m / 60) + ' h ' + (m % 60) + ' min ago'); };
|
|
406
408
|
function sessBadge(n) { const b = $('#sessBdg'); if (!b) return; b.textContent = String(n || ''); b.hidden = !n; const a = $('#sessBtn'); if (a) a.setAttribute('aria-label', 'Agent sessions, ' + (n ? n + ' running' : 'none running')); }
|
|
407
409
|
{
|
|
@@ -413,7 +415,7 @@ function sessBadge(n) { const b = $('#sessBdg'); if (!b) return; b.textContent =
|
|
|
413
415
|
}
|
|
414
416
|
}
|
|
415
417
|
export async function openSessions() {
|
|
416
|
-
const M = { list: null, ask: null, busy: null, slow: null, done: null, err: '' };
|
|
418
|
+
const M = { list: null, ask: null, busy: null, slow: null, done: null, err: '', asks: {}, ans: null };
|
|
417
419
|
const draw = () => {
|
|
418
420
|
const l = M.list, n = l ? l.length : 0;
|
|
419
421
|
$('#dTitle').textContent = l === null ? 'Agent sessions' : n ? n + ' running' : 'None running';
|
|
@@ -425,19 +427,28 @@ export async function openSessions() {
|
|
|
425
427
|
<div class="ssb"><h3>${esc(x.name)}</h3><p class="ssn">${esc(x.note || 'No note')}</p>
|
|
426
428
|
<p class="ssm">${[x.headless ? 'Background run' : '', x.agent, x.label, x.cwd, sessAgo(x.created), x.automatic ? 'Started by PMOS' : ''].filter(Boolean).map((t) => `<span>${esc(t)}</span>`).join('')}</p></div>
|
|
427
429
|
<button type="button" class="cta alt" data-stop="${esc(x.id)}" aria-label="Stop ${esc(x.name)}"${ask || busy || slow ? ' disabled' : ''}>${busy ? 'Ending…' : 'Stop'}</button>
|
|
430
|
+
${M.asks[x.id] ? `<div class="ssc ssq" role="group" aria-label="${esc(x.name)} asks"><p><b>${esc(M.asks[x.id].q)}</b></p><div class="ssx">${M.asks[x.id].options.map((o) => `<button type="button" class="cta${o.rec ? '' : ' alt'}" data-ans="${esc(x.id)}" data-opt="${esc(o.label)}"${M.ans ? ' disabled' : ''}>${esc(o.label)}</button>`).join('')}</div></div>` : ''}
|
|
428
431
|
${ask && !busy ? `<div class="ssc" role="group" aria-label="Confirm stop"><p><b>Stop “${esc(x.name)}”?</b> ${what} Files it already wrote stay where they are.</p><div class="ssx"><button type="button" class="cta bad" data-yes="${esc(x.id)}">Stop</button><button type="button" class="cta alt" data-no="${esc(x.id)}">Keep running</button></div></div>` : ''}
|
|
429
432
|
${slow ? `<div class="ssc" role="group" aria-label="Still running"><p><b>Asked “${esc(x.name)}” to end.</b> It has not exited yet. Press Stop again to remove it.</p><div class="ssx"><button type="button" class="cta bad" data-yes="${esc(x.id)}">Stop again</button><button type="button" class="cta alt" data-no="${esc(x.id)}">Keep running</button></div></div>` : ''}</li>`;
|
|
430
433
|
}).join('')}</ul>` : '<div class="sse"><b>No agent sessions running.</b><p>New sessions start in the console.</p></div>';
|
|
431
434
|
$('#oMain').innerHTML = `<article class="paper doc"><div class="addf">${rows}
|
|
432
435
|
<p class="note" id="ssM" role="status" style="margin:0;min-height:1.2em">${esc(M.err)}</p>
|
|
433
|
-
<p class="note" style="margin:0">Terminals
|
|
436
|
+
<p class="note" style="margin:0">Terminals and new sessions stay in the console. <a href="/console.html">Open the console</a>.</p></div></article>`;
|
|
434
437
|
};
|
|
435
438
|
openDlg({ eye: 'Agent sessions · real data', title: 'Agent sessions', say: 'The sessions running now. Stop ends one.', stream: turnA(ptx('The sessions running now, read from the same list the console shows. Stop ends one and says so.')), noteKey: null, pane: '<article class="paper doc"></article>', label: 'Sessions' });
|
|
436
439
|
$('#askF').hidden = true; setMode('detail'); draw();
|
|
437
|
-
const load = async () => { M.list = await readSessions(); if (M.list === null) { M.list = []; M.err = 'The sessions could not be read.'; } else sessBadge(M.list.length); draw(); };
|
|
440
|
+
const load = async () => { M.list = await readSessions(); M.asks = M.list ? await readAsks() : {}; if (M.list === null) { M.list = []; M.err = 'The sessions could not be read.'; } else sessBadge(M.list.length); draw(); };
|
|
438
441
|
const focusNext = () => { const b = $('#oMain [data-stop]:not([disabled])') || $('#dTitle'); if (b) b.focus(); };
|
|
439
442
|
$('#oMain').onclick = async (e) => {
|
|
440
443
|
if (M.busy) return;
|
|
444
|
+
const an = e.target.closest('[data-ans]');
|
|
445
|
+
if (an) {
|
|
446
|
+
const id = an.dataset.ans, a = M.asks[id]; if (!a) return;
|
|
447
|
+
M.ans = id; M.err = ''; draw();
|
|
448
|
+
const r = await pmPost('/api/runs/answer', { run: id, request: a.request, behavior: 'answer', message: an.dataset.opt }); M.ans = null;
|
|
449
|
+
if (r && r.ok) { toast('Answered. The agent continues with your choice.'); delete M.asks[id]; } else M.err = (r && (r.error || r.reason)) || 'Not answered.';
|
|
450
|
+
draw(); return;
|
|
451
|
+
}
|
|
441
452
|
const st = e.target.closest('[data-stop]'), yes = e.target.closest('[data-yes]'), no = e.target.closest('[data-no]');
|
|
442
453
|
M.err = '';
|
|
443
454
|
if (st) { M.ask = st.dataset.stop; M.slow = null; draw(); const k = $(`#oMain [data-no="${M.ask}"]`); if (k) k.focus(); }
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* pm/premium-welcome-model.js — the pure half of the premium Welcome page (initiative premium-welcome). No DOM, no request: it turns the
|
|
2
|
+
* onboarding routes' answers and the PM's choices into the bodies the page posts and the rows it draws, so a node test loads it with import().
|
|
3
|
+
* Routes (lib/routes-onboarding.js): GET /api/onboarding/status | structure | briefing, POST /api/onboarding/scan | apply | undo | dismiss.
|
|
4
|
+
* Text taken from the scanned folder is untrusted. Nothing here quotes a file; the page escapes every value it draws. */
|
|
5
|
+
|
|
6
|
+
/** The tools a first run can read besides the folders. `source` is a lib/freshness.js SOURCES id with a read-only skill; `brief` is a lib/proactive.js BRIEF_SOURCES key. */
|
|
7
|
+
export const TOOLS = [
|
|
8
|
+
{ source: 'calendar', name: 'Calendar', adds: 'Your meetings today and for the next 14 days, so the Briefing can get you ready for them.' },
|
|
9
|
+
{ source: 'my-work', name: 'Jira', adds: 'The Jira issues assigned to you, so My work starts with them.' },
|
|
10
|
+
{ source: 'inbox', brief: 'mail', name: 'Inbox', adds: 'The threads waiting on you, by subject and sender only. No message text is kept.' },
|
|
11
|
+
{ source: 'slack', brief: 'slack', name: 'Slack', adds: 'Messages that mention you and your direct messages, as short summaries.' },
|
|
12
|
+
];
|
|
13
|
+
export const STEPS = [['about', 'About you'], ['sources', 'Your sources'], ['found', 'What PMOS found']];
|
|
14
|
+
export const FIELDS = ['name', 'role', 'work', 'duties'];
|
|
15
|
+
|
|
16
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
17
|
+
export const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
18
|
+
export const fileRef = (e) => (e && typeof e === 'object' ? (e.line ? `${str(e.file)}:${e.line}` : str(e.file)) : '');
|
|
19
|
+
|
|
20
|
+
/** The About you fields from GET /api/proactive/settings. Missing or malformed gives empty fields. */
|
|
21
|
+
export function aboutOf(ps) {
|
|
22
|
+
const s = ps && ps.ok && ps.settings && typeof ps.settings === 'object' ? ps.settings : {};
|
|
23
|
+
const a = s.about && typeof s.about === 'object' ? s.about : {};
|
|
24
|
+
return { name: str(s.name), role: str(a.role), work: str(a.work), duties: str(a.duties) };
|
|
25
|
+
}
|
|
26
|
+
/** The body of POST /api/proactive/settings for the About you step. */
|
|
27
|
+
export const aboutBody = (a) => ({ name: str(a.name).trim().slice(0, 40), about: { role: str(a.role).trim(), work: str(a.work).trim(), duties: str(a.duties).trim() } });
|
|
28
|
+
|
|
29
|
+
/** What pressing Scan starts: the tools to turn on for the daily brief, and the tools to refresh as their own read-only sessions. */
|
|
30
|
+
export function toolPlan(pick) {
|
|
31
|
+
const picked = TOOLS.filter((x) => pick && pick[x.source]);
|
|
32
|
+
return { brief: picked.filter((x) => x.brief), refresh: picked.filter((x) => !x.brief) };
|
|
33
|
+
}
|
|
34
|
+
export const briefBody = (brief) => ({ briefSources: Object.fromEntries(brief.map((x) => [x.brief, true])) });
|
|
35
|
+
|
|
36
|
+
/** The proposed initiatives of GET /api/onboarding/structure, flat, each with its board key. */
|
|
37
|
+
export function rowsOf(structure) {
|
|
38
|
+
const boards = structure && Array.isArray(structure.boards) ? structure.boards : [];
|
|
39
|
+
return boards.flatMap((b) => (Array.isArray(b.initiatives) ? b.initiatives : []).map((r) => ({ ...r, board: b.key })));
|
|
40
|
+
}
|
|
41
|
+
export const boardOfRow = (r, st) => (st.boardOf && st.boardOf[r.proposal_id]) || r.board;
|
|
42
|
+
/** The page's starting choices: a row is ticked as the scan proposed it, and keeps its own title. */
|
|
43
|
+
export function startChoices(structure) {
|
|
44
|
+
const checked = {}, titles = {};
|
|
45
|
+
for (const r of rowsOf(structure)) { checked[r.proposal_id] = !!r.checked; titles[r.proposal_id] = str(r.title); }
|
|
46
|
+
return { checked, titles };
|
|
47
|
+
}
|
|
48
|
+
export function counts(structure, st) {
|
|
49
|
+
const on = rowsOf(structure).filter((r) => st.checked[r.proposal_id]);
|
|
50
|
+
return { n: on.length, m: new Set(on.map((r) => boardOfRow(r, st))).size };
|
|
51
|
+
}
|
|
52
|
+
export const importText = (c) => `Import ${plural(c.n, 'initiative', 'initiatives')} into ${plural(c.m, 'board', 'boards')}`;
|
|
53
|
+
|
|
54
|
+
/** The revisions apply takes: a changed, non-empty title and a changed board. */
|
|
55
|
+
export function revisions(structure, st) {
|
|
56
|
+
const out = {};
|
|
57
|
+
for (const r of rowsOf(structure)) {
|
|
58
|
+
const rev = {}, t = str(st.titles && st.titles[r.proposal_id]).trim();
|
|
59
|
+
if (t && t !== r.title) rev.title = t;
|
|
60
|
+
if (st.boardOf && st.boardOf[r.proposal_id] && st.boardOf[r.proposal_id] !== r.board) rev.board = st.boardOf[r.proposal_id];
|
|
61
|
+
if (Object.keys(rev).length) out[r.proposal_id] = rev;
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/** The answers apply takes. An untouched question sends its default (the PM saw it listed); a skipped one sends nothing. */
|
|
66
|
+
export function answersOf(structure, st) {
|
|
67
|
+
const answers = {};
|
|
68
|
+
for (const q of (structure && Array.isArray(structure.questions) ? structure.questions : [])) {
|
|
69
|
+
if (st.skipped && st.skipped[q.id]) continue;
|
|
70
|
+
const v = st.answers && st.answers[q.id] != null ? st.answers[q.id] : q.default;
|
|
71
|
+
if (q.id === 'template') answers.template = Object.assign(answers.template || {}, { [q.board]: v });
|
|
72
|
+
else answers[q.id] = v;
|
|
73
|
+
}
|
|
74
|
+
return answers;
|
|
75
|
+
}
|
|
76
|
+
export function applyBody(ws, structure, st) {
|
|
77
|
+
const include = rowsOf(structure).filter((r) => st.checked[r.proposal_id]).map((r) => r.proposal_id);
|
|
78
|
+
return { ws, include, revisions: revisions(structure, st), answers: answersOf(structure, st) };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const optVal = (o) => (o && typeof o === 'object' ? o.value : o);
|
|
82
|
+
const optTxt = (o) => (o && typeof o === 'object' ? (o.label || o.value) : o);
|
|
83
|
+
/** One line per scan question for the "Defaults PMOS chose" block: what it asks and the default it will send. */
|
|
84
|
+
export function defaultsView(structure, st) {
|
|
85
|
+
return (structure && Array.isArray(structure.questions) ? structure.questions : []).map((q) => {
|
|
86
|
+
const skipped = !!(st.skipped && st.skipped[q.id]);
|
|
87
|
+
const cur = st.answers && st.answers[q.id] != null ? st.answers[q.id] : q.default;
|
|
88
|
+
const opts = Array.isArray(q.options) ? q.options : [];
|
|
89
|
+
const hit = opts.find((o) => String(optVal(o)) === String(cur));
|
|
90
|
+
return { id: str(q.id), text: str(q.text), value: skipped ? 'Skipped. Nothing is sent.' : String(hit ? optTxt(hit) : cur == null ? '' : cur), skipped, options: opts.map((o) => ({ value: String(optVal(o)), text: String(optTxt(o)) })), free: str(q.free) };
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The scan's findings, at most ten, as rows: title, why, and the first evidence's file and line. */
|
|
95
|
+
export function findingsOf(look) {
|
|
96
|
+
const f = look && Array.isArray(look.findings) ? look.findings : [];
|
|
97
|
+
return f.slice(0, 10).map((x) => ({ title: str(x.title), why: str(x.why), ref: fileRef(Array.isArray(x.evidence) ? x.evidence[0] : null) }));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The first-Briefing card's rows from GET /api/onboarding/briefing, and the ticked tools' state Welcome recorded in this browser. */
|
|
101
|
+
export function firstView(briefing, toolState) {
|
|
102
|
+
const items = (briefing && briefing.ok && Array.isArray(briefing.items) ? briefing.items : []).map((b) => ({
|
|
103
|
+
title: str(b.title), why: str(b.why), ref: fileRef(Array.isArray(b.evidence) ? b.evidence[0] : null),
|
|
104
|
+
ini: b.initiative && typeof b.initiative === 'object' ? `${str(b.initiative.title)} · ${str(b.initiative.board)} board` : '',
|
|
105
|
+
}));
|
|
106
|
+
const state = toolState && typeof toolState === 'object' ? toolState : {};
|
|
107
|
+
const tools = TOOLS.filter((x) => state[x.source]).map((x) => ({ name: x.name, started: !!state[x.source].started, error: str(state[x.source].error) }));
|
|
108
|
+
return { items, tools, calm: items.length === 0 };
|
|
109
|
+
}
|
|
110
|
+
export const FIRST_KEY = 'pmos.welcome.tools';
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/* pm/premium-welcome.js — the premium Welcome page (initiative premium-welcome). Three steps, then the premium Briefing.
|
|
2
|
+
* About you → Your sources → What PMOS found → (Import) /premium.html?first=<import id>
|
|
3
|
+
* Routes (lib/routes-onboarding.js): GET /api/onboarding/status | structure, POST /api/onboarding/scan | apply | dismiss. About you saves with
|
|
4
|
+
* POST /api/proactive/settings, the route console Settings uses. Scan starts each ticked tool (POST /api/sources/refresh, or the brief sources and
|
|
5
|
+
* POST /api/proactive/goals/plan) and then scans the folder. Presses carry the launch nonce through pm/http.js; the page writes nothing itself.
|
|
6
|
+
* Text taken from the scanned folder is untrusted: every value goes through esc() and no quoted file text is shown. The pure half is premium-welcome-model.js. */
|
|
7
|
+
import { pmGet, pmPost } from './http.js';
|
|
8
|
+
import * as W from './premium-welcome-model.js';
|
|
9
|
+
|
|
10
|
+
const $ = (s, r = document) => r.querySelector(s);
|
|
11
|
+
const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
12
|
+
const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* no storage */ } } };
|
|
13
|
+
const params = new URLSearchParams(location.search);
|
|
14
|
+
{ const t = params.get('theme') || store.get('pmos.c3.theme'); if (t === 'light' || t === 'dark') document.documentElement.dataset.theme = t; }
|
|
15
|
+
|
|
16
|
+
const S = {
|
|
17
|
+
ws: params.get('ws') || '', folder: null, added: [], step: 'about', busy: '', error: '', note: '',
|
|
18
|
+
about: { name: '', role: '', work: '', duties: '' }, pick: {}, sources: {},
|
|
19
|
+
look: null, structure: null, checked: {}, titles: {}, boardOf: {}, edit: {}, answers: {}, skipped: {}, defs: false,
|
|
20
|
+
};
|
|
21
|
+
const I = {
|
|
22
|
+
folder: '<svg class="i" viewBox="0 0 24 24"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>',
|
|
23
|
+
plus: '<svg class="i" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></svg>',
|
|
24
|
+
lock: '<svg class="i" viewBox="0 0 24 24"><rect x="5" y="11" width="14" height="9" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg>',
|
|
25
|
+
calendar: '<svg class="i" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="16" rx="3"/><path d="M3 10h18M8 3v4M16 3v4"/></svg>',
|
|
26
|
+
'my-work': '<svg class="i" viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="3"/><path d="M8 12l3 3 5-6"/></svg>',
|
|
27
|
+
inbox: '<svg class="i" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="3"/><path d="m4 8 8 6 8-6"/></svg>',
|
|
28
|
+
slack: '<svg class="i" viewBox="0 0 24 24"><path d="M5 9h14M5 15h14M9 4 8 20M16 4l-1 16"/></svg>',
|
|
29
|
+
check: '<svg class="i" viewBox="0 0 24 24"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>',
|
|
30
|
+
off: '<svg class="i" viewBox="0 0 24 24"><path d="M6 12h12"/></svg>',
|
|
31
|
+
};
|
|
32
|
+
const dis = (on) => (on ? ' disabled' : '');
|
|
33
|
+
const spin = (txt) => `<span class="wl-spin" aria-hidden="true"></span>${esc(txt)}`;
|
|
34
|
+
|
|
35
|
+
/* ── actions ───────────────────────────────────────────────────────────────────────────────────── */
|
|
36
|
+
const fail = (r, what) => { S.error = (r && r.error) || `${what} did not work.`; };
|
|
37
|
+
async function run(label, fn) {
|
|
38
|
+
S.busy = label; S.error = ''; draw();
|
|
39
|
+
try { await fn(); } catch (e) { S.error = String((e && e.message) || e); }
|
|
40
|
+
S.busy = ''; draw();
|
|
41
|
+
}
|
|
42
|
+
const go = (step) => { S.step = step; S.error = ''; draw(true); };
|
|
43
|
+
const saveAbout = () => run('about', async () => {
|
|
44
|
+
const r = await pmPost('/api/proactive/settings', W.aboutBody(S.about));
|
|
45
|
+
if (!r || !r.ok) { fail(r, 'Saving what you told PMOS'); return; }
|
|
46
|
+
S.step = 'sources';
|
|
47
|
+
});
|
|
48
|
+
const addFolder = () => run('add', async () => {
|
|
49
|
+
const p = await pmPost('/api/pick-folder', {});
|
|
50
|
+
if (!p || !p.ok) { if (p && p.cancelled) return; S.note = (p && p.unsupported) ? 'This system has no folder chooser. Start pmos in the folder instead.' : ''; if (!S.note) fail(p, 'Choosing a folder'); return; }
|
|
51
|
+
const w = await pmPost('/api/workspaces', { root: p.root, name: p.root.split(/[\\/]/).filter(Boolean).pop(), focus: false });
|
|
52
|
+
if (!w || !w.workspace) { fail(w, 'Adding the folder'); return; }
|
|
53
|
+
if (!S.added.some((a) => a.id === w.workspace.id) && w.workspace.id !== S.ws) S.added.push({ id: w.workspace.id, name: w.workspace.name, root: w.workspace.root });
|
|
54
|
+
});
|
|
55
|
+
/* Each ticked tool is its own read-only agent session. A tool that cannot start says why on its row and does not stop the folder scan. */
|
|
56
|
+
async function startTools() {
|
|
57
|
+
const plan = W.toolPlan(S.pick);
|
|
58
|
+
if (plan.brief.length) {
|
|
59
|
+
const on = await pmPost('/api/proactive/settings', W.briefBody(plan.brief));
|
|
60
|
+
const r = on && on.ok ? await pmPost('/api/proactive/goals/plan', { ws: S.ws }) : on;
|
|
61
|
+
for (const x of plan.brief) S.sources[x.source] = r && r.ok ? { started: true } : { error: (r && r.error) || 'Starting the read did not work.' };
|
|
62
|
+
}
|
|
63
|
+
for (const x of plan.refresh) {
|
|
64
|
+
const r = await pmPost('/api/sources/refresh', { ws: S.ws, source: x.source });
|
|
65
|
+
S.sources[x.source] = r && r.ok ? { started: true } : { error: (r && r.error) || 'Starting the read did not work.' };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const scan = () => run('scan', async () => {
|
|
69
|
+
await startTools();
|
|
70
|
+
const r = await pmPost('/api/onboarding/scan', { ws: S.ws, extra_roots: S.added.map((a) => a.root) });
|
|
71
|
+
if (!r || !r.ok) { fail(r, 'The scan'); return; }
|
|
72
|
+
const st = await pmGet(`/api/onboarding/structure?ws=${encodeURIComponent(S.ws)}`);
|
|
73
|
+
if (!st || !st.ok) { fail(st, 'Reading the portfolio'); return; }
|
|
74
|
+
S.look = r.first_look; S.structure = st; S.boardOf = {}; S.edit = {}; S.answers = {}; S.skipped = {}; S.defs = false;
|
|
75
|
+
Object.assign(S, W.startChoices(st));
|
|
76
|
+
S.step = 'found';
|
|
77
|
+
});
|
|
78
|
+
const importNow = () => {
|
|
79
|
+
if (!W.counts(S.structure, S).n) return;
|
|
80
|
+
run('apply', async () => {
|
|
81
|
+
const r = await pmPost('/api/onboarding/apply', W.applyBody(S.ws, S.structure, S));
|
|
82
|
+
if (!r || !r.ok) { fail(r, 'The import'); return; }
|
|
83
|
+
try { sessionStorage.setItem(W.FIRST_KEY, JSON.stringify(S.sources)); } catch { /* no storage */ }
|
|
84
|
+
location.assign('/premium.html?ws=' + encodeURIComponent(S.ws) + '&first=' + encodeURIComponent(r.import_id));
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
// "Not now": Welcome stops opening on its own for this folder (`pmos welcome` still opens it), then the premium Briefing opens
|
|
88
|
+
const notNow = () => run('dismiss', async () => {
|
|
89
|
+
const r = await pmPost('/api/onboarding/dismiss', { ws: S.ws });
|
|
90
|
+
if (!r || !r.ok) { fail(r, 'Not now'); return; }
|
|
91
|
+
location.assign('/premium.html?ws=' + encodeURIComponent(S.ws));
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/* ── views ─────────────────────────────────────────────────────────────────────────────────────── */
|
|
95
|
+
const btn = (act, label, o = {}) => `<button class="wl-btn${o.alt ? ' alt' : ''}${o.quiet ? ' quiet' : ''}" type="button" data-w="${act}"${o.attrs || ''}${dis(o.off || (S.busy && !o.free))}${S.busy === o.busy ? ' aria-busy="true"' : ''}>${S.busy === o.busy && o.busyText ? spin(o.busyText) : (o.lead || '') + label}</button>`;
|
|
96
|
+
const foot = (left, right) => `<div class="wl-foot"><div>${left}</div><div class="r">${right}</div></div>`;
|
|
97
|
+
const err = () => (S.error ? `<p class="wl-err" role="alert">${esc(S.error)}</p>` : '');
|
|
98
|
+
|
|
99
|
+
function viewAbout() {
|
|
100
|
+
const a = S.about;
|
|
101
|
+
const f = (k, text, hint, max) => `<label>${text}<input data-f="${k}" maxlength="${max}" value="${esc(a[k])}" placeholder="${esc(hint)}" autocomplete="off"></label>`;
|
|
102
|
+
return `<h1 id="wlH" tabindex="-1">Welcome to PMOS</h1><p class="wl-lede">Tell PMOS who you are, so your Briefing knows what matters to you. Every field is optional, and you can change them later in the console's Settings.</p>
|
|
103
|
+
<div class="wl-f">${f('name', 'Your name', 'For example: Dana', 40)}${f('role', 'Your role', 'For example: Senior PM, Payments', 80)}${f('work', 'What you do', 'In one line, for example: I run checkout and the payment methods', 200)}
|
|
104
|
+
<label>Your job description<textarea data-f="duties" maxlength="1000" placeholder="What you own, decide and deliver. Paste it from your job description if you have one.">${esc(a.duties)}</textarea></label></div>${err()}`
|
|
105
|
+
+ foot('', btn('about', 'Continue', { busy: 'about', busyText: 'Saving' }));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function toolRow(x) {
|
|
109
|
+
const on = !!S.pick[x.source], st = S.sources[x.source] || {};
|
|
110
|
+
return `<li><button type="button" class="wl-row" data-w="tool" data-k="${esc(x.source)}" aria-pressed="${on}"${dis(S.busy)}><span class="wl-ic">${I[x.source] || ''}</span><span><b>${esc(x.name)}</b><small>${esc(x.adds)}</small>${st.error ? `<small class="wl-bad" role="alert">${esc(st.error)}</small>` : ''}</span><span class="wl-tog">${on ? 'Read it' : 'Off'}</span></button></li>`;
|
|
111
|
+
}
|
|
112
|
+
function viewSources() {
|
|
113
|
+
const f = S.folder || { name: '', root: '' };
|
|
114
|
+
const n = W.TOOLS.filter((x) => S.pick[x.source]).length;
|
|
115
|
+
const rows = [`<li class="wl-row"><span class="wl-ic">${I.folder}</span><span><b>${esc(f.name || 'This folder')}</b><span class="path">${esc(f.root)}</span></span><span class="chip">this folder</span></li>`]
|
|
116
|
+
.concat(S.added.map((a) => `<li class="wl-row"><span class="wl-ic">${I.folder}</span><span><b>${esc(a.name)}</b><span class="path">${esc(a.root)}</span></span><span></span></li>`)).join('');
|
|
117
|
+
if (S.busy === 'scan') {
|
|
118
|
+
return `<h1 id="wlH" tabindex="-1">Reading ${esc(f.name || 'your folder')}</h1><p class="wl-lede">A large folder can take a minute or two. The rest of PMOS keeps working.</p>
|
|
119
|
+
<div class="wl-scan" role="status"><div>${spin('Starting the tools you ticked, then reading the folder')}</div></div>`;
|
|
120
|
+
}
|
|
121
|
+
return `<h1 id="wlH" tabindex="-1">Where does your work live?</h1><p class="wl-lede">PMOS reads your folders and the tools you tick, then shows you your initiatives, your documents and what needs you first.</p>
|
|
122
|
+
<p class="wl-sec">Folders<span class="chip mono">${1 + S.added.length}</span></p><ul class="wl-list">${rows}</ul>
|
|
123
|
+
<div class="wl-add">${btn('folder', 'Add another folder', { alt: true, lead: I.plus, busy: 'add', busyText: 'Waiting for the chooser' })}</div>${S.note ? `<p class="note">${esc(S.note)}</p>` : ''}
|
|
124
|
+
<p class="wl-sec">Tools<span class="chip">optional</span></p><ul class="wl-list">${W.TOOLS.map(toolRow).join('')}</ul>
|
|
125
|
+
<p class="note wl-lock">${I.lock}<span>Reads only. PMOS writes nothing in your folders or your tools, and sends nothing out. Your agent reads the tools you tick with your own connection.</span></p>${err()}`
|
|
126
|
+
+ foot(btn('back', 'Back', { alt: true }), btn('scan', n ? `Scan the folder and read ${W.plural(n, 'tool', 'tools')}` : 'Scan this folder', { busy: 'scan' }));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function rowView(r) {
|
|
130
|
+
const id = r.proposal_id, ed = !!S.edit[id], on = !!S.checked[id], t = S.titles[id];
|
|
131
|
+
const docs = (r.docs || []).length;
|
|
132
|
+
const opts = S.structure.boards.map((b) => `<option value="${esc(b.key)}"${b.key === W.boardOfRow(r, S) ? ' selected' : ''}>${esc(b.name)}</option>`).join('');
|
|
133
|
+
const meta = [r.lane, r.anchor || 'no anchor', r.stage, W.plural(docs, 'document', 'documents')].filter(Boolean).map(esc).join(' · ');
|
|
134
|
+
return `<li class="wl-ed${on ? '' : ' off'}"><div class="wl-row"><span class="wl-ic wl-n">${on ? I.check : I.off}</span><span><b>${esc(t)}</b><small>${meta}</small></span>
|
|
135
|
+
<span class="acts"><button type="button" class="wgo" data-w="inc" data-id="${esc(id)}" aria-pressed="${on}" aria-label="${on ? 'Leave out' : 'Import'} ${esc(t)}"${dis(S.busy)}>${on ? 'Leave out' : 'Import'}</button><button type="button" class="wgo" data-w="edit" data-id="${esc(id)}" aria-expanded="${ed}"${dis(!on || S.busy)}>${ed ? 'Done' : 'Edit'}</button></span></div>
|
|
136
|
+
${ed ? `<div class="wl-edit"><label>Title<input data-f="title" data-id="${esc(id)}" value="${esc(t)}" maxlength="80"></label><label>Board<select data-f="board" data-id="${esc(id)}">${opts}</select></label></div>` : ''}</li>`;
|
|
137
|
+
}
|
|
138
|
+
function questionInputs() {
|
|
139
|
+
return W.defaultsView(S.structure, S).map((q) => {
|
|
140
|
+
const cur = S.answers[q.id] != null ? S.answers[q.id] : ((S.structure.questions.find((x) => x.id === q.id) || {}).default);
|
|
141
|
+
const input = q.options.length
|
|
142
|
+
? `<select data-f="answer" data-id="${esc(q.id)}" aria-label="${esc(q.text)}"${dis(q.skipped)}>${q.options.map((o) => `<option value="${esc(o.value)}"${String(cur) === o.value ? ' selected' : ''}>${esc(o.text)}</option>`).join('')}</select>`
|
|
143
|
+
: `<input data-f="answer" data-id="${esc(q.id)}" aria-label="${esc(q.text)}" value="${esc(cur == null ? '' : cur)}"${dis(q.skipped)}>`;
|
|
144
|
+
return `<div class="wl-q"><b>${esc(q.text)}</b>${input}<button type="button" class="wgo" data-w="skipq" data-id="${esc(q.id)}" aria-pressed="${q.skipped}">${q.skipped ? 'Skipped. Use the default' : 'Skip'}</button></div>`;
|
|
145
|
+
}).join('');
|
|
146
|
+
}
|
|
147
|
+
function viewFound() {
|
|
148
|
+
const L = S.look || {}, c = W.counts(S.structure, S), all = W.rowsOf(S.structure), found = W.findingsOf(L), defs = W.defaultsView(S.structure, S);
|
|
149
|
+
const boards = S.structure.boards.map((b) => {
|
|
150
|
+
const mine = all.filter((r) => W.boardOfRow(r, S) === b.key);
|
|
151
|
+
return `<div class="wl-bh"><b>${esc(b.name)}</b><span class="chip">${W.plural((b.unsorted || []).length, 'document', 'documents')} unsorted</span></div><ul class="wl-list">${mine.length ? mine.map(rowView).join('') : '<li class="note">No initiatives here.</li>'}</ul>`;
|
|
152
|
+
}).join('');
|
|
153
|
+
return `<h1 id="wlH" tabindex="-1">What PMOS found</h1>${L.sentence ? `<p class="wl-lede">${esc(L.sentence)}</p>` : ''}
|
|
154
|
+
${S.look ? `<p class="wl-sec">What matters most<span class="chip mono">${found.length}</span></p>` : ''}
|
|
155
|
+
${!S.look ? '' : found.length ? `<ol class="wl-list">${found.map((f, i) => `<li class="wl-row"><span class="wl-ic wl-n">${String(i + 1).padStart(2, '0')}</span><span><b>${esc(f.title)}</b>${f.why ? `<small>${esc(f.why)}</small>` : ''}<span class="path">${esc(f.ref)}</span></span><span></span></li>`).join('')}</ol>` : '<p class="note">Nothing in this folder needs you urgently.</p>'}
|
|
156
|
+
<p class="wl-sec">Your portfolio<span class="chip mono">${c.n} of ${all.length} to import</span></p>${boards}
|
|
157
|
+
<div class="wl-def"><span class="wl-sec wl-sec0">Defaults PMOS chose</span>${defs.length ? `<dl>${defs.map((d) => `<dt>${esc(d.text)}</dt><dd>${esc(d.value)}</dd>`).join('')}</dl>` : '<p class="note">The scan left no questions. Nothing needs a default.</p>'}
|
|
158
|
+
${S.defs && defs.length ? `<div class="wl-qs">${questionInputs()}</div>` : ''}
|
|
159
|
+
${defs.length ? `<div class="wl-add">${btn('defs', S.defs ? 'Done' : 'Change the defaults', { alt: true, attrs: ` aria-expanded="${S.defs}"` })}</div>` : ''}</div>${err()}`
|
|
160
|
+
+ foot(btn('back', 'Back', { alt: true }), btn('import', esc(W.importText(c)), { busy: 'apply', busyText: 'Importing', off: !c.n }));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const VIEWS = { about: viewAbout, sources: viewSources, found: viewFound };
|
|
164
|
+
function draw(focusHead) {
|
|
165
|
+
const at = Math.max(0, W.STEPS.findIndex(([k]) => k === S.step));
|
|
166
|
+
$('#wlSteps').innerHTML = W.STEPS.map(([, t], i) => `<li data-s="${i < at ? 'done' : i === at ? 'now' : 'todo'}"${i === at ? ' aria-current="step"' : ''}><b><i></i></b><span>${esc(t)}</span></li>`).join('');
|
|
167
|
+
$('#wlCount').textContent = `Set up · step ${at + 1} of ${W.STEPS.length}`;
|
|
168
|
+
$('#wlSkip').disabled = !!S.busy;
|
|
169
|
+
const keep = document.activeElement && document.activeElement.dataset ? [document.activeElement.dataset.w, document.activeElement.dataset.id || document.activeElement.dataset.k || '', document.activeElement.dataset.f] : null;
|
|
170
|
+
const y = scrollY;
|
|
171
|
+
$('#wlCard').innerHTML = VIEWS[S.step]();
|
|
172
|
+
$('#wlCard').setAttribute('aria-busy', S.busy ? 'true' : 'false');
|
|
173
|
+
if (focusHead) { const h = $('#wlH'); if (h) h.focus({ preventScroll: true }); scrollTo(0, 0); }
|
|
174
|
+
else {
|
|
175
|
+
scrollTo(0, y);
|
|
176
|
+
if (keep && (keep[0] || keep[2])) {
|
|
177
|
+
const again = [...document.querySelectorAll('#wlCard [data-w],#wlCard [data-f]')].find((x) => (x.dataset.w || null) === (keep[0] || null) && (x.dataset.id || x.dataset.k || '') === keep[1] && (x.dataset.f || undefined) === keep[2]);
|
|
178
|
+
if (again && !again.disabled) again.focus();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* ── events: one delegate for presses, input and change on the card ──────────────────────────── */
|
|
184
|
+
document.addEventListener('click', (e) => {
|
|
185
|
+
const b = e.target.closest('[data-w]'); if (!b || b.disabled || !b.closest('#wlRoot')) return;
|
|
186
|
+
const a = b.dataset.w, id = b.dataset.id;
|
|
187
|
+
if (a === 'about') saveAbout();
|
|
188
|
+
else if (a === 'back') go(S.step === 'found' ? 'sources' : 'about');
|
|
189
|
+
else if (a === 'folder') addFolder();
|
|
190
|
+
else if (a === 'tool') { S.pick[b.dataset.k] = !S.pick[b.dataset.k]; draw(); }
|
|
191
|
+
else if (a === 'scan') scan();
|
|
192
|
+
else if (a === 'inc') { S.checked[id] = !S.checked[id]; if (!S.checked[id]) S.edit[id] = false; draw(); }
|
|
193
|
+
else if (a === 'edit') { S.edit[id] = !S.edit[id]; draw(); }
|
|
194
|
+
else if (a === 'defs') { S.defs = !S.defs; draw(); }
|
|
195
|
+
else if (a === 'skipq') { S.skipped[id] = !S.skipped[id]; draw(); }
|
|
196
|
+
else if (a === 'import') importNow();
|
|
197
|
+
else if (a === 'skip') notNow();
|
|
198
|
+
});
|
|
199
|
+
const card = $('#wlCard');
|
|
200
|
+
card.addEventListener('input', (e) => {
|
|
201
|
+
const t = e.target, f = t.dataset && t.dataset.f; if (!f) return;
|
|
202
|
+
if (W.FIELDS.includes(f)) S.about[f] = t.value;
|
|
203
|
+
else if (f === 'title') S.titles[t.dataset.id] = t.value;
|
|
204
|
+
else if (f === 'answer') {
|
|
205
|
+
const q = ((S.structure && S.structure.questions) || []).find((x) => x.id === t.dataset.id);
|
|
206
|
+
S.answers[t.dataset.id] = t.value.trim() ? t.value : (q ? q.default : t.value); // an emptied answer goes back to the default
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
card.addEventListener('change', (e) => {
|
|
210
|
+
const t = e.target, f = t.dataset && t.dataset.f; if (!f) return;
|
|
211
|
+
if (f === 'board') { S.boardOf[t.dataset.id] = t.value; draw(); }
|
|
212
|
+
else if (f === 'answer') draw();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
/* ── start ────────────────────────────────────────────────────────────────────────────────────── */
|
|
216
|
+
async function start() {
|
|
217
|
+
draw();
|
|
218
|
+
const list = await pmGet('/api/workspaces');
|
|
219
|
+
const all = (list && list.workspaces) || [];
|
|
220
|
+
const mine = all.find((w) => w.id === S.ws) || (!S.ws ? all[0] : null);
|
|
221
|
+
if (!mine) { S.error = 'This folder is not open in PMOS. Start pmos in the folder, then reload.'; $('#wlCard').setAttribute('aria-busy', 'false'); draw(); return; }
|
|
222
|
+
S.ws = mine.id; S.folder = { name: mine.name, root: mine.root };
|
|
223
|
+
const st = await pmGet(`/api/onboarding/status?ws=${encodeURIComponent(S.ws)}`);
|
|
224
|
+
if (st && st.ok && st.state === 'imported') {
|
|
225
|
+
const live = (st.imports || []).filter((i) => !i.retracted).pop();
|
|
226
|
+
if (live) { location.replace('/premium.html?ws=' + encodeURIComponent(S.ws) + '&first=' + encodeURIComponent(live.import_id)); return; }
|
|
227
|
+
}
|
|
228
|
+
S.about = W.aboutOf(await pmGet('/api/proactive/settings'));
|
|
229
|
+
if (params.get('step') === 'found') { // back from "Undo this import": the scan is still on disk, but its first-look sentence is not, so the page does not show one
|
|
230
|
+
const sr = await pmGet(`/api/onboarding/structure?ws=${encodeURIComponent(S.ws)}`);
|
|
231
|
+
if (sr && sr.ok) { S.structure = sr; Object.assign(S, W.startChoices(sr)); S.step = 'found'; } else fail(sr, 'Reading the portfolio');
|
|
232
|
+
}
|
|
233
|
+
draw(true);
|
|
234
|
+
}
|
|
235
|
+
start();
|
|
@@ -1645,6 +1645,91 @@ button.m3-stc{min-height:44px;margin:-7px 0}button.m3-stc:hover{background:var(-
|
|
|
1645
1645
|
.m3-shot{margin:8px 0;display:grid;gap:6px}.m3-shot img{max-width:100%;border-radius:14px;border:1px solid var(--hair)}.m3-shot figcaption{margin:0}
|
|
1646
1646
|
@media (max-width:1000px){.m3-cap{grid-template-columns:1fr}.m3-kps button,.m3-kp0{grid-template-columns:70px minmax(0,1fr)}.m3-kps time,.m3-kp0 em{display:none}.m3-ln{grid-template-columns:40px 48px minmax(0,1fr)}}
|
|
1647
1647
|
|
|
1648
|
+
/* ---- the premium Welcome page and the first-Briefing card (initiative premium-welcome): the approved mockup's rules (prototype/premium-welcome) ---- */
|
|
1649
|
+
.wl-in{position:relative;max-width:700px;margin:0 auto;padding:max(20px,env(safe-area-inset-top,0px)) 16px calc(40px + env(safe-area-inset-bottom,0px))}
|
|
1650
|
+
.wl-top{display:flex;align-items:center;justify-content:space-between;gap:12px}
|
|
1651
|
+
.wl-brand{height:44px;display:inline-flex;align-items:center;gap:12px;padding:0 20px;border-radius:var(--r-chip);font-weight:650}
|
|
1652
|
+
.wl-brand small{font:500 var(--t-small) var(--mono);color:var(--ink-2)}
|
|
1653
|
+
.wl-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:44px;padding:0 22px;border-radius:var(--r-chip);background:var(--solid);color:var(--on-solid);font-weight:650;font-size:var(--t-body);white-space:nowrap;transition:transform .3s var(--spring),filter .2s}
|
|
1654
|
+
.wl-btn:hover{filter:brightness(1.18)}.wl-btn:active{transform:scale(.97)}.wl-btn:disabled{opacity:.4;pointer-events:none}
|
|
1655
|
+
.wl-btn.alt{background:var(--card-solid);color:var(--ink);box-shadow:inset 0 0 0 1px var(--hair)}.wl-btn.alt:hover{filter:none;background:var(--well)}
|
|
1656
|
+
.wl-btn.quiet{background:none;color:var(--ink-2);padding:0 14px}.wl-btn.quiet:hover{filter:none;background:var(--well)}
|
|
1657
|
+
.wl-btn svg{width:16px;height:16px}
|
|
1658
|
+
.wl-steps{display:flex;gap:8px;list-style:none;margin:22px 0 0;padding:0}
|
|
1659
|
+
.wl-steps li{flex:1;min-width:0}
|
|
1660
|
+
.wl-steps b{display:block;height:4px;border-radius:8px;background:color-mix(in oklab,var(--ink) 12%,transparent);margin-bottom:8px;overflow:hidden}
|
|
1661
|
+
.wl-steps b i{display:block;height:100%;width:0;background:var(--ink);border-radius:8px;transition:width .6s var(--spring)}
|
|
1662
|
+
.wl-steps li[data-s="done"] b i{width:100%;background:var(--ok)}.wl-steps li[data-s="now"] b i{width:100%}
|
|
1663
|
+
.wl-steps span{display:block;font:600 var(--t-micro) var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
1664
|
+
.wl-steps li[data-s="now"] span{color:var(--ink)}
|
|
1665
|
+
.wl-card{margin-top:18px;padding:32px}
|
|
1666
|
+
.wl-card h1{font-size:clamp(26px,4vw,34px);line-height:1.1;letter-spacing:-.03em;font-weight:700;text-wrap:balance}
|
|
1667
|
+
.wl-lede{margin-top:10px;color:var(--ink-2);max-width:56ch;text-wrap:pretty}
|
|
1668
|
+
.wl-sec{display:flex;align-items:center;gap:10px;margin:30px 0 10px;font:600 var(--t-micro) var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3)}
|
|
1669
|
+
.wl-sec .chip{margin-left:auto}
|
|
1670
|
+
.wl-f{display:grid;gap:16px;margin-top:24px}
|
|
1671
|
+
.wl-f label{display:grid;gap:6px;font-size:var(--t-small);font-weight:600;color:var(--ink-2)}
|
|
1672
|
+
.wl-f label em{font-style:normal;font-weight:500;color:var(--ink-3);margin-left:4px}
|
|
1673
|
+
.wl-f input,.wl-f select,.wl-f textarea,.wl-edit input,.wl-edit select{border-radius:14px;border:1px solid var(--hair);background:var(--card-solid);padding:0 14px;font:inherit;font-size:var(--t-body);color:var(--ink);min-width:0;width:100%;height:46px}
|
|
1674
|
+
.wl-f textarea{height:auto;min-height:118px;padding:12px 14px;resize:vertical;line-height:1.5}
|
|
1675
|
+
.wl-f input:focus-visible,.wl-f select:focus-visible,.wl-f textarea:focus-visible,.wl-edit input:focus-visible,.wl-edit select:focus-visible{outline:2px solid var(--ember);outline-offset:1px}
|
|
1676
|
+
.wl-list{display:grid;gap:8px;list-style:none;margin:0;padding:0}
|
|
1677
|
+
.wl-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:14px;align-items:center;padding:14px 16px;border-radius:var(--r-in);background:var(--well);width:100%;text-align:left}
|
|
1678
|
+
.wl-row > .wl-ic{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:var(--card-solid);color:var(--ink-2)}
|
|
1679
|
+
.wl-row b{display:block;font-weight:650;overflow-wrap:anywhere}
|
|
1680
|
+
.wl-row small{display:block;margin-top:2px;font-size:var(--t-small);color:var(--ink-3);line-height:1.45}
|
|
1681
|
+
.wl-row .path{font:500 var(--t-small) var(--mono);color:var(--ink-3);overflow-wrap:anywhere}
|
|
1682
|
+
.wl-row.off{opacity:.62}
|
|
1683
|
+
.wl-tog{font-size:var(--t-small);font-weight:650;height:30px;padding:0 14px;border-radius:var(--r-chip);display:inline-flex;align-items:center;background:var(--card-solid);color:var(--ink-2);box-shadow:inset 0 0 0 1px var(--hair);white-space:nowrap}
|
|
1684
|
+
button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--on-solid);box-shadow:none}
|
|
1685
|
+
.wl-n{font:600 var(--t-small) var(--mono);color:var(--ink-2)}
|
|
1686
|
+
.wl-edit{display:grid;gap:10px;grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);margin:10px 0 0}
|
|
1687
|
+
.wl-edit label{display:grid;gap:4px;font-size:var(--t-small);font-weight:600;color:var(--ink-2)}
|
|
1688
|
+
.wl-edit input,.wl-edit select{height:40px}
|
|
1689
|
+
.wl-ed{background:var(--well);border-radius:var(--r-in);padding:14px 16px}
|
|
1690
|
+
.wl-ed .wl-row{padding:0;background:none;border-radius:0}
|
|
1691
|
+
.wl-ed .acts{display:flex;gap:6px;align-items:center}
|
|
1692
|
+
.wl-ed.off b{text-decoration:line-through;text-decoration-color:var(--ink-3)}
|
|
1693
|
+
.wl-ed .wgo,.wl-q .wgo{flex:none;white-space:nowrap;height:32px;padding:0 12px;border-radius:var(--r-chip);font-size:var(--t-small);font-weight:650;color:var(--ink-2);background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair)}
|
|
1694
|
+
.wl-def{margin-top:24px;border-radius:var(--r-in);border:1px dashed var(--b2);padding:16px 18px}
|
|
1695
|
+
.wl-def dl{display:grid;grid-template-columns:auto minmax(0,1fr);gap:6px 18px;margin:10px 0 0;font-size:var(--t-small)}
|
|
1696
|
+
.wl-def dt{color:var(--ink-3);font-weight:600}.wl-def dd{margin:0;color:var(--ink)}
|
|
1697
|
+
.wl-foot{display:flex;gap:10px;align-items:center;justify-content:space-between;margin-top:32px;flex-wrap:wrap}
|
|
1698
|
+
.wl-foot .r{margin-left:auto;display:flex;gap:10px;flex-wrap:wrap}
|
|
1699
|
+
.wl-lock{display:flex;gap:10px;align-items:flex-start;margin-top:22px}.wl-lock svg{width:16px;height:16px;margin-top:2px}
|
|
1700
|
+
.wl-scan{display:grid;gap:12px;margin-top:26px}.wl-scan div{display:flex;gap:12px;align-items:center;color:var(--ink-2)}
|
|
1701
|
+
.wl-scan svg{width:18px;height:18px;color:var(--ok)}
|
|
1702
|
+
.wl-spin{width:18px;height:18px;border-radius:50%;border:2px solid var(--b3);border-top-color:var(--ink);animation:wlspin .8s linear infinite;flex:none}
|
|
1703
|
+
@keyframes wlspin{to{transform:rotate(360deg)}}
|
|
1704
|
+
.wl-about{margin-top:18px}.wl-about summary{cursor:pointer;font-size:var(--t-small);font-weight:600;color:var(--ink-2);padding:8px 0}
|
|
1705
|
+
.wl-about ul{margin:8px 0 0;padding-left:18px;font-size:var(--t-small);color:var(--ink-2);line-height:1.55;display:grid;gap:6px}
|
|
1706
|
+
.wl-about code{font:500 var(--t-small) var(--mono)}
|
|
1707
|
+
@media (max-width:640px){
|
|
1708
|
+
.wl-card{padding:22px 18px;border-radius:24px}
|
|
1709
|
+
.wl-brand small{display:none}
|
|
1710
|
+
.wl-edit{grid-template-columns:minmax(0,1fr)}
|
|
1711
|
+
.wl-row{grid-template-columns:auto minmax(0,1fr);}
|
|
1712
|
+
.wl-row>:nth-child(3){grid-column:2;justify-self:start}.wl-row>:nth-child(3):empty{display:none}
|
|
1713
|
+
.wl-foot{position:sticky;bottom:0;margin:28px -18px -22px;padding:14px 18px calc(14px + env(safe-area-inset-bottom,0px));background:var(--card);border-top:1px solid var(--hair);border-radius:0 0 24px 24px;z-index:2}
|
|
1714
|
+
.wl-foot .r{flex:1;justify-content:flex-end}.wl-foot .wl-btn{flex:1}.wl-foot .wl-btn.quiet{flex:0 0 auto}
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
.wl-first{margin-top:24px}
|
|
1718
|
+
.wl-first-note{margin:12px 0 14px}
|
|
1719
|
+
.wl-actions{display:flex;gap:10px;margin-top:18px;flex-wrap:wrap}
|
|
1720
|
+
.wl-err,.wl-bad,.wl-first-err{color:var(--bad);font-size:var(--t-small);line-height:1.45;margin:12px 0 0}
|
|
1721
|
+
.wl-lede:empty{display:none}
|
|
1722
|
+
.wl-add{margin-top:10px}
|
|
1723
|
+
.wl-bh{display:flex;align-items:center;gap:10px;margin:14px 0 8px}
|
|
1724
|
+
.wl-sec0{margin:0}
|
|
1725
|
+
.wl-qs{display:grid;gap:14px;margin-top:14px}
|
|
1726
|
+
.wl-q{display:grid;gap:8px}.wl-q select,.wl-q input{border-radius:14px;border:1px solid var(--hair);background:var(--card-solid);padding:0 14px;font:inherit;font-size:var(--t-body);color:var(--ink);min-width:0;width:100%;height:46px}
|
|
1727
|
+
.wl-q select:focus-visible,.wl-q input:focus-visible{outline:2px solid var(--ember);outline-offset:1px}
|
|
1728
|
+
.wl-q .wgo{justify-self:start}
|
|
1729
|
+
.wl-ed .wgo,.wl-tog,.wl-q .wgo{min-height:32px}
|
|
1730
|
+
@media (pointer:coarse){.wl-ed .wgo,.wl-q .wgo{min-height:44px;padding:0 16px}.wl-btn.quiet{min-height:44px}}
|
|
1731
|
+
.wl-row .wl-ic.wl-n{font:600 var(--t-small) var(--mono)}
|
|
1732
|
+
.wl-in h1:focus{outline:none}
|
|
1648
1733
|
/* ── Around you (initiative premium-briefing-depth): the card on the Briefing and the dialogs its rows open. Own block, prefix bd-. ───────────────────── */
|
|
1649
1734
|
#aroundCard .bd-rows{margin-top:6px}
|
|
1650
1735
|
#aroundCard .due.od{color:var(--ember-ink);background:color-mix(in oklab,var(--ember) 16%,transparent)}
|
|
@@ -4,6 +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 { mountFirst } from './premium-first.js';
|
|
7
8
|
import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
|
|
8
9
|
import { momentOf, inText } from './c3-phone-model.js';
|
|
9
10
|
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';
|
|
@@ -809,3 +810,4 @@ async function load() {
|
|
|
809
810
|
}
|
|
810
811
|
$('#brief').textContent = 'Reading the repository.';
|
|
811
812
|
load();
|
|
813
|
+
mountFirst(); // the "Your first Briefing" card, only when the page was opened with first=<import id> (initiative premium-welcome)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="pmos-nonce" content="" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
|
7
|
+
<title>PMOS · Welcome</title>
|
|
8
|
+
<!-- The premium Welcome (initiative premium-welcome). The first-run flow in the Briefing's shell: About you, Your sources, What PMOS found, then the premium Briefing. It reads and writes only through the onboarding routes (lib/routes-onboarding.js) and the proactive settings, every press behind the launch nonce. -->
|
|
9
|
+
<link rel="preload" href="/vendor/geist-var.woff2" as="font" type="font/woff2" crossorigin />
|
|
10
|
+
<link rel="stylesheet" href="/pm/premium.css" />
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div class="sky"><i class="a"></i><i class="b"></i><i class="c"></i></div>
|
|
14
|
+
<div class="toast glass" id="toast" role="status"></div>
|
|
15
|
+
<main class="wl-in" id="wlRoot">
|
|
16
|
+
<div class="wl-top"><span class="glass wl-brand">PMOS <small id="wlCount">Set up</small></span><button class="wl-btn quiet" id="wlSkip" type="button" data-w="skip">Not now</button></div>
|
|
17
|
+
<ol class="wl-steps" id="wlSteps" aria-label="Setup steps"></ol>
|
|
18
|
+
<section class="card wl-card" id="wlCard" aria-live="polite" aria-busy="true"><h1 id="wlH" tabindex="-1">Welcome to PMOS</h1><p class="wl-lede">Reading this folder.</p></section>
|
|
19
|
+
</main>
|
|
20
|
+
<noscript>This page needs JavaScript.</noscript>
|
|
21
|
+
<script type="module" src="/pm/premium-welcome.js"></script>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
package/workspace/server.js
CHANGED
|
@@ -6101,12 +6101,12 @@ async function handleRequest(req, res) {
|
|
|
6101
6101
|
res.writeHead(302, { Location: (url.search ? '/console.html' : '/premium.html') + url.search, 'Cache-Control': 'no-store' });
|
|
6102
6102
|
return res.end();
|
|
6103
6103
|
}
|
|
6104
|
-
if (p === '/' || p === '/index.html' || p === '/console' || p === '/console.html' || p === '/classic' || p === '/classic.html' || p === '/welcome' || p === '/welcome.html' || p === '/premium' || p === '/premium.html' || p === '/premium-work' || p === '/premium-work.html' || p === '/premium-board' || p === '/premium-board.html' || p === '/premium-initiative' || p === '/premium-initiative.html' || p === '/premium-insights' || p === '/premium-insights.html') {
|
|
6104
|
+
if (p === '/' || p === '/index.html' || p === '/console' || p === '/console.html' || p === '/classic' || p === '/classic.html' || p === '/welcome' || p === '/welcome.html' || p === '/premium' || p === '/premium.html' || p === '/premium-work' || p === '/premium-work.html' || p === '/premium-board' || p === '/premium-board.html' || p === '/premium-initiative' || p === '/premium-initiative.html' || p === '/premium-insights' || p === '/premium-insights.html' || p === '/premium-welcome' || p === '/premium-welcome.html') {
|
|
6105
6105
|
// pm-os-absorb Run 2 (R25, X11): the per-launch nonce goes into the base meta line, nowhere else. no-store, so a
|
|
6106
6106
|
// restarted server never answers a press from a page that holds the previous launch's value. The page code is
|
|
6107
6107
|
// referenced under this launch's build prefix.
|
|
6108
6108
|
const n = pmGuard.launchNonce();
|
|
6109
|
-
return fs.readFile(path.join(PUB, (p === '/classic' || p === '/classic.html') ? 'index.html' : (p === '/welcome' || p === '/welcome.html') ? 'welcome.html' : (p === '/premium' || p === '/premium.html') ? 'premium.html' : (p === '/premium-work' || p === '/premium-work.html') ? 'premium-work.html' : (p === '/premium-board' || p === '/premium-board.html') ? 'premium-board.html' : (p === '/premium-initiative' || p === '/premium-initiative.html') ? 'premium-initiative.html' : (p === '/premium-insights' || p === '/premium-insights.html') ? 'premium-insights.html' : (p === '/console' || p === '/console.html') ? 'c3.html' : 'premium.html'), 'utf8', (err, html) => {
|
|
6109
|
+
return fs.readFile(path.join(PUB, (p === '/classic' || p === '/classic.html') ? 'index.html' : (p === '/welcome' || p === '/welcome.html') ? 'welcome.html' : (p === '/premium' || p === '/premium.html') ? 'premium.html' : (p === '/premium-work' || p === '/premium-work.html') ? 'premium-work.html' : (p === '/premium-board' || p === '/premium-board.html') ? 'premium-board.html' : (p === '/premium-initiative' || p === '/premium-initiative.html') ? 'premium-initiative.html' : (p === '/premium-insights' || p === '/premium-insights.html') ? 'premium-insights.html' : (p === '/premium-welcome' || p === '/premium-welcome.html') ? 'premium-welcome.html' : (p === '/console' || p === '/console.html') ? 'c3.html' : 'premium.html'), 'utf8', (err, html) => {
|
|
6110
6110
|
if (err) { res.writeHead(404); res.end('not found'); return; }
|
|
6111
6111
|
let out = withBuild(html);
|
|
6112
6112
|
if (n) out = out.replace('<meta name="' + pmGuard.NONCE_META + '" content="" />', '<meta name="' + pmGuard.NONCE_META + '" content="' + n + '" />');
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"briefing-premium-products.test.js",
|
|
52
52
|
"briefing-premium-sources.test.js",
|
|
53
53
|
"briefing-premium-metrics.test.js",
|
|
54
|
+
"premium-welcome.test.js",
|
|
54
55
|
"calendar-events.test.js",
|
|
55
56
|
"calendar-supersede.test.js",
|
|
56
57
|
"tracker-read.test.js",
|
|
@@ -220,6 +221,7 @@
|
|
|
220
221
|
"briefing-premium-products.test.js": 1,
|
|
221
222
|
"briefing-premium-sources.test.js": 1,
|
|
222
223
|
"briefing-premium-metrics.test.js": 1,
|
|
224
|
+
"premium-welcome.test.js": 1,
|
|
223
225
|
"calendar-events.test.js": 1,
|
|
224
226
|
"calendar-supersede.test.js": 1,
|
|
225
227
|
"tracker-read.test.js": 1,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"briefing-premium-products-test.js",
|
|
15
15
|
"briefing-premium-sources-test.js",
|
|
16
16
|
"briefing-premium-metrics-test.js",
|
|
17
|
+
"premium-welcome-test.js",
|
|
17
18
|
"briefing-premium-agent-server.test.js"
|
|
18
19
|
],
|
|
19
20
|
"seconds": {
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"briefing-premium-products-test.js": 90,
|
|
31
32
|
"briefing-premium-sources-test.js": 90,
|
|
32
33
|
"briefing-premium-metrics-test.js": 120,
|
|
34
|
+
"premium-welcome-test.js": 120,
|
|
33
35
|
"briefing-premium-agent-server.test.js": 40
|
|
34
36
|
}
|
|
35
37
|
}
|