create-pmos 0.482.0 → 0.484.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 +27 -27
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/guide/briefing-premium.md +6 -2
- package/workspace/guide/home.md +1 -1
- package/workspace/home-rows-test.js +3 -1
- package/workspace/lib/goal-chat.js +29 -5
- package/workspace/lib/report-chat.js +3 -2
- package/workspace/lib/report-templates.js +172 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-report-flow.js +184 -0
- package/workspace/lib/routes-reports.js +4 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-report-tab-test.js +40 -33
- package/workspace/premium-html-viewer-test.js +6 -0
- package/workspace/public/pm/cozy-vw-rp.css +48 -0
- package/workspace/public/pm/home-app.js +6 -2
- package/workspace/public/pm/home-chat.js +3 -3
- package/workspace/public/pm/home-list.js +10 -3
- package/workspace/public/pm/home-today.js +2 -2
- package/workspace/public/pm/premium-report-read.js +40 -6
- package/workspace/public/pm/premium-report-tab.js +163 -74
- package/workspace/public/pm/premium-vw-doc.css +6 -1
- package/workspace/public/pm/premium-vw-file.js +7 -2
- package/workspace/public/pm/premium-vw-pdf.js +42 -0
- package/workspace/public/pm/report-chat.js +5 -3
- package/workspace/public/pm/report-flow.js +163 -0
- package/workspace/public/vendor/pdf.min.js +28 -0
- package/workspace/public/vendor/pdf.worker.min.js +28 -0
- package/workspace/ready-dash-ui-test.js +2 -1
- package/workspace/server.js +3 -0
- package/workspace/test-lists/report-flow.json +11 -0
- package/workspace/third-party/README.md +9 -4
- package/workspace/third-party/pdfjs-dist-5.4.296.LICENSE +177 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-report-flow.js — the report building flow's routes (batch 22 item 14, "A+ on Home", canvas RfH1–RfH7; lib/report-templates.js).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/report-flow?ws&id → { ok, id, name, audience, output, schedule, status, template: { current, versions: [{ n, settings, words,
|
|
5
|
+
* why, at, current, cycles }] }, cycles: [{ path, slot, state }] (newest first), latest, drafting, session,
|
|
6
|
+
* review } the report's current state: what the chat chip opens
|
|
7
|
+
* GET /api/report-flow/review?ws&path → { ok, review: { fix: [{ id, title, why }], passed: [label] } } Claude's review of one draft
|
|
8
|
+
* POST /api/report-flow/start { ws, id, chat? } → { ok, n } T1 of a report just set up, and the conversation it came from
|
|
9
|
+
* POST /api/report-flow/template { ws, id, settings } → { ok, n } the PM's ✓ on a changed template: applied, and T<n+1>
|
|
10
|
+
* POST /api/report-flow/restore { ws, id, n } → { ok, n } Go back to T<n>: applied; nothing is deleted
|
|
11
|
+
* POST /api/report-flow/ask { ws, id, text, path? } → { ok, session, passed | started } a change for the report's own session
|
|
12
|
+
*
|
|
13
|
+
* THE REPORT'S OWN SESSION. Each template drafts in a session of its own, never in the PM's chat (the agreed note). A report with a saved
|
|
14
|
+
* structure drafts in the session its schedule starts (lib/routes-report-structure.js draftNow, origin schedule:<id>). A change the PM asks for
|
|
15
|
+
* (a ✦ Do it, or a change Claude passes from the chat) goes to the session that is drafting now, else to the report's own session
|
|
16
|
+
* (origin report-session:<id>), which is started when none is alive. That session runs the report-template skill on the named draft.
|
|
17
|
+
* It never issues, sends or shares: Issue it is the PM's press (POST /api/report/issue).
|
|
18
|
+
*
|
|
19
|
+
* WHO WRITES. Every POST passes pm-guard requirePagePress, and a request with an agent session header is refused first (403), as
|
|
20
|
+
* routes-report-design.js does. Nothing here sends anything outward.
|
|
21
|
+
*/
|
|
22
|
+
const fs = require('fs');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
const guard = require('./pm-guard.js');
|
|
25
|
+
const RT = require('./report-templates.js');
|
|
26
|
+
const RS = require('./report-setups.js');
|
|
27
|
+
const RN = require('./report-needs.js');
|
|
28
|
+
const issues = require('./issues.js');
|
|
29
|
+
|
|
30
|
+
const prefixes = ['/api/report-flow'];
|
|
31
|
+
const POSTS = ['start', 'template', 'restore', 'ask'];
|
|
32
|
+
const MAX_ASK = 2000;
|
|
33
|
+
const text = (v) => (typeof v === 'string' ? v : '');
|
|
34
|
+
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
35
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
36
|
+
function wsOf(ctx, id) { const w = ctx.getWs(id || null); return w && (!id || w.id === id) ? w : null; }
|
|
37
|
+
|
|
38
|
+
function setupOf(root, id) { try { return RS.fold(RS.readLines(RS.ledgerFile(root))).setups.get(id) || null; } catch { return null; } }
|
|
39
|
+
function cyclesOf(root, id) {
|
|
40
|
+
let list; try { list = RN.reportsOf(root).reports; } catch { return []; }
|
|
41
|
+
return list.filter((r) => r.cadence === id).map((r) => ({ path: r.path, slot: r.slot, state: r.issued ? 'issued' : 'draft', issued_at: r.issued ? r.issued.at : null }));
|
|
42
|
+
}
|
|
43
|
+
function readText(root, rel) { try { return fs.readFileSync(path.join(path.resolve(String(root)), rel), 'utf8'); } catch { return null; } }
|
|
44
|
+
function sessionFile(root, id) { return path.join(path.dirname(RT.ledgerOf(root, id)), 'session.json'); }
|
|
45
|
+
function readSession(root, id) { try { const o = JSON.parse(fs.readFileSync(sessionFile(root, id), 'utf8')); return isObj(o) && typeof o.session === 'string' ? o : null; } catch { return null; } }
|
|
46
|
+
const alive = (ctx, sid) => !!sid && !!(ctx.chatSessions && typeof ctx.chatSessions.alive === 'function' && ctx.chatSessions.alive(sid));
|
|
47
|
+
function draftingOf(ctx, w, id) { try { return typeof ctx.structureDraftState === 'function' ? ctx.structureDraftState(w, id) || null : null; } catch { return null; } }
|
|
48
|
+
|
|
49
|
+
/** The report's current state, as the chip and the reader read it. */
|
|
50
|
+
function stateOf(ctx, w, id, now = Date.now()) {
|
|
51
|
+
const root = w.root, s = setupOf(root, id);
|
|
52
|
+
const cycles = cyclesOf(root, id);
|
|
53
|
+
const f = RT.fold(RT.readLines(root, id));
|
|
54
|
+
const counts = RT.cyclesOf(f, cycles.filter((c) => c.issued_at).map((c) => ({ at: c.issued_at })));
|
|
55
|
+
const sess = readSession(root, id);
|
|
56
|
+
const drafting = draftingOf(ctx, w, id);
|
|
57
|
+
const latest = cycles[0] || null;
|
|
58
|
+
let review = null;
|
|
59
|
+
if (latest && latest.state === 'draft') { const t = readText(root, latest.path); if (t != null) review = RT.review(t, { slot: latest.slot, now, listed: s && Array.isArray(s.sections) ? s.sections : [] }); }
|
|
60
|
+
return {
|
|
61
|
+
ok: true, id, name: s ? s.name : id, audience: s ? s.audience : '', output: s ? s.output : '', schedule: s ? s.schedule : null, status: s ? s.status : 'removed',
|
|
62
|
+
template: { current: f.current, versions: f.versions.map((v) => ({ ...v, words: RT.settingsWords(v.settings), cycles: counts.get(v.n) || 0 })) },
|
|
63
|
+
cycles, latest, drafting,
|
|
64
|
+
session: sess ? { id: sess.session, alive: alive(ctx, sess.session), since: sess.since || null } : null,
|
|
65
|
+
review,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Apply a template's settings to the setup line (report-setups change and reschedule): the live values follow the current version. */
|
|
70
|
+
function apply(root, id, settings, opts) {
|
|
71
|
+
const patch = {};
|
|
72
|
+
if (settings.output) patch.output = settings.output;
|
|
73
|
+
if (settings.audience) patch.audience = settings.audience;
|
|
74
|
+
if (Object.keys(patch).length) { const r = RS.change(root, id, patch, opts); if (!r.ok) return r; }
|
|
75
|
+
if (settings.schedule) {
|
|
76
|
+
const r = RS.reschedule(root, id, settings.schedule === 'off' ? { cadence: 'off' } : settings.schedule, opts);
|
|
77
|
+
if (!r.ok) return r;
|
|
78
|
+
}
|
|
79
|
+
return { ok: true };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The words the report's session gets for one change. */
|
|
83
|
+
function askPrompt(skill, id, rel, change) {
|
|
84
|
+
return `${skill}\n\nThe PM's request for this run, given when it was scheduled (do not ask again): ${id}\n\n`
|
|
85
|
+
+ `This is the report's own drafting session (the PMOS report flow), not the PM's chat. ${rel ? `Change the draft ${rel} in place. ` : ''}`
|
|
86
|
+
+ `The change the PM asked for: ${change}\nChange only the draft. Never issue, send or share it: the PM issues it on the page.`;
|
|
87
|
+
}
|
|
88
|
+
function ask(ctx, w, id, change, rel) {
|
|
89
|
+
const root = w.root;
|
|
90
|
+
const d = draftingOf(ctx, w, id);
|
|
91
|
+
const sess = readSession(root, id);
|
|
92
|
+
const target = d && d.state === 'drafting' && alive(ctx, d.session) ? d.session : sess && alive(ctx, sess.session) ? sess.session : null;
|
|
93
|
+
const msg = `[PMOS report change] ${rel ? `Draft ${rel}: ` : ''}${change}. Change only the draft; never issue, send or share it.`;
|
|
94
|
+
if (target) {
|
|
95
|
+
const sent = typeof ctx.sendToSession === 'function' && ctx.sendToSession(target, msg);
|
|
96
|
+
if (sent) return { ok: true, session: target, passed: true };
|
|
97
|
+
}
|
|
98
|
+
if (typeof ctx.spawnSession !== 'function') return { ok: false, status: 409, error: 'This workspace cannot start a session for the report.' };
|
|
99
|
+
const skill = typeof ctx.skillPrompt === 'function' ? ctx.skillPrompt('report-template', w) : null;
|
|
100
|
+
if (!skill) return { ok: false, status: 500, error: 'The report-template skill is not installed, so the report has no session to draft in.' };
|
|
101
|
+
const origin = 'report-session:' + id;
|
|
102
|
+
if (typeof ctx.endSupersededRuns === 'function') { try { ctx.endSupersededRuns(origin); } catch { /* the old one ends by itself */ } }
|
|
103
|
+
const s = setupOf(root, id);
|
|
104
|
+
const sp = ctx.spawnSession({ name: 'Report · ' + ((s && s.name) || id), agent: 'claude', ws: w.id, origin, initialInput: askPrompt(skill, id, rel, change) + '\r' });
|
|
105
|
+
if (!sp || sp.state === 'exited' || !sp.id) return { ok: false, status: 409, error: 'The report\'s session did not start: ' + ((sp && sp.note) || 'no session') };
|
|
106
|
+
try { fs.mkdirSync(path.dirname(sessionFile(root, id)), { recursive: true }); fs.writeFileSync(sessionFile(root, id), JSON.stringify({ session: sp.id, since: new Date().toISOString() }) + '\n'); } catch { /* shown as no session */ }
|
|
107
|
+
return { ok: true, session: sp.id, started: true };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function handle(req, res, url, ctx) {
|
|
111
|
+
const p = url.pathname;
|
|
112
|
+
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
113
|
+
const sub = p.replace(/^\/api\/report-flow\/?/, '');
|
|
114
|
+
if (req.method === 'GET') {
|
|
115
|
+
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
116
|
+
if (!w) return send(bad(404, 'no such workspace'));
|
|
117
|
+
if (sub === 'review') {
|
|
118
|
+
const rel = text(url.searchParams.get('path'));
|
|
119
|
+
const m = /(?:^|\/)reports\/([a-z][a-z0-9-]{0,39})\/(\d{4}-\d{2}-\d{2})\.md$/.exec(rel);
|
|
120
|
+
if (!m || rel.split('/').includes('..')) return send(bad(400, 'path must be a report draft'));
|
|
121
|
+
const t = readText(w.root, rel);
|
|
122
|
+
if (t == null) return send(bad(404, 'no such report'));
|
|
123
|
+
let iss = false; try { iss = issues.isIssued(issues.readIssues(w.root), m[1], m[2]); } catch { iss = false; }
|
|
124
|
+
const s = setupOf(w.root, m[1]);
|
|
125
|
+
return send({ status: 200, body: { ok: true, issued: iss, review: iss ? null : RT.review(t, { slot: m[2], listed: s && Array.isArray(s.sections) ? s.sections : [] }) } });
|
|
126
|
+
}
|
|
127
|
+
if (sub !== '') return send(bad(404, 'no such route'));
|
|
128
|
+
const id = text(url.searchParams.get('id'));
|
|
129
|
+
if (!RT.ID_RE.test(id)) return send(bad(400, 'id must be a report id'));
|
|
130
|
+
if (!setupOf(w.root, id) && !cyclesOf(w.root, id).length) return send(bad(404, 'no such report'));
|
|
131
|
+
return send({ status: 200, body: stateOf(ctx, w, id) });
|
|
132
|
+
}
|
|
133
|
+
if (!POSTS.includes(sub)) return send(bad(404, 'no such route'));
|
|
134
|
+
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
135
|
+
if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'a session cannot change a report: the PM presses on the page'));
|
|
136
|
+
const read = await ctx.readJson(req);
|
|
137
|
+
if (!read.ok) return send(bad(400, 'the body is not JSON'));
|
|
138
|
+
const body = read.body || {};
|
|
139
|
+
const g = guard.requirePagePress(req, body);
|
|
140
|
+
if (!g.ok) return send(bad(g.status, g.error));
|
|
141
|
+
const w = wsOf(ctx, text(body.ws));
|
|
142
|
+
if (!w) return send(bad(404, 'no such workspace'));
|
|
143
|
+
const id = text(body.id);
|
|
144
|
+
if (!RT.ID_RE.test(id)) return send(bad(400, 'id must be a report id'));
|
|
145
|
+
const s = setupOf(w.root, id);
|
|
146
|
+
if (!s || s.status === 'removed') return send(bad(404, 'no such report'));
|
|
147
|
+
const opts = { by: g.actor, wsId: w.id, scheduleStore: ctx.scheduleStore };
|
|
148
|
+
const fail = (r) => send({ status: r.status || 400, body: { ok: false, error: r.error } });
|
|
149
|
+
|
|
150
|
+
if (sub === 'start') {
|
|
151
|
+
const r = RT.ensureFirst(w.root, id, s, { chat: text(body.chat) || null });
|
|
152
|
+
return r.ok ? send({ status: 200, body: { ok: true, n: r.n } }) : fail(r);
|
|
153
|
+
}
|
|
154
|
+
if (sub === 'template') {
|
|
155
|
+
const want = RT.cleanSettings(body.settings);
|
|
156
|
+
if (!want) return send(bad(400, 'say what changes: the format, who reads it or when it goes out'));
|
|
157
|
+
RT.ensureFirst(w.root, id, s);
|
|
158
|
+
const f = RT.fold(RT.readLines(w.root, id)), cur = f.versions.find((v) => v.current);
|
|
159
|
+
const next = { ...(cur ? cur.settings : RT.settingsOf(s)), ...want };
|
|
160
|
+
if (cur && RT.sameSettings(cur.settings, next)) return send({ status: 200, body: { ok: true, n: cur.n, unchanged: true } });
|
|
161
|
+
const a = apply(w.root, id, next, opts);
|
|
162
|
+
if (!a.ok) return fail(a);
|
|
163
|
+
const v = RT.addVersion(w.root, id, next);
|
|
164
|
+
return v.ok ? send({ status: 200, body: { ok: true, n: v.n, state: stateOf(ctx, w, id) } }) : fail(v);
|
|
165
|
+
}
|
|
166
|
+
if (sub === 'restore') {
|
|
167
|
+
const f = RT.fold(RT.readLines(w.root, id)), v = f.versions.find((x) => x.n === +body.n);
|
|
168
|
+
if (!v) return send(bad(404, 'no such template version'));
|
|
169
|
+
const a = apply(w.root, id, v.settings, opts);
|
|
170
|
+
if (!a.ok) return fail(a);
|
|
171
|
+
const r = RT.restore(w.root, id, v.n);
|
|
172
|
+
return r.ok ? send({ status: 200, body: { ok: true, n: r.n, state: stateOf(ctx, w, id) } }) : fail(r);
|
|
173
|
+
}
|
|
174
|
+
// ask
|
|
175
|
+
const change = text(body.text).replace(/\s+/g, ' ').trim();
|
|
176
|
+
if (!change) return send(bad(400, 'say the change'));
|
|
177
|
+
if (change.length > MAX_ASK) return send(bad(413, 'a change is at most ' + MAX_ASK + ' characters'));
|
|
178
|
+
const rel = text(body.path);
|
|
179
|
+
if (rel && !(new RegExp('(?:^|/)reports/' + id + '/\\d{4}-\\d{2}-\\d{2}\\.md$').test(rel) && !rel.split('/').includes('..'))) return send(bad(400, 'path must be a draft of this report'));
|
|
180
|
+
const r = ask(ctx, w, id, change, rel || null);
|
|
181
|
+
return r.ok ? send({ status: 200, body: r }) : fail(r);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
module.exports = { prefixes, handle, stateOf, askPrompt };
|
|
@@ -168,7 +168,10 @@ async function handle(req, res, url, ctx) {
|
|
|
168
168
|
if (!hit) return refuse(ctx, res, 404, `there is no ${cs.cadence} report for ${cs.slot}; nothing was issued`);
|
|
169
169
|
const r = issues.appendFromUi(root, [{ ev: 'issued', cadence: cs.cadence, slot: cs.slot, path: hit.path, sha: body.sha }], { actor: g.actor });
|
|
170
170
|
if (!r || r.ok === false) return failed(r || { status: 500, error: 'the writer answered nothing' });
|
|
171
|
-
|
|
171
|
+
// a goal's report point counts at Issued (batch 22 item 14): the goal of the conversation this report came from takes it
|
|
172
|
+
let goal = false;
|
|
173
|
+
try { const chat = require('./report-templates.js').chatOf(root, cs.cadence); if (chat && ctx.runtimeDir) goal = require('./goal-chat.js').reportIssued({ runtimeDir: ctx.runtimeDir, key: chat, report: cs.cadence }); } catch { goal = false; }
|
|
174
|
+
return done({ slot: cs.slot, path: hit.path, ...(goal ? { goal_point: true } : {}), written: (r.written || []).map((x) => ({ cadence: x.cadence, slot: x.slot, path: x.path, sha: x.sha, at: x.at })) });
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
module.exports = { prefixes, handle };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.484.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.484.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* here; every report press goes to the real report-setups and report-documents routes.
|
|
6
6
|
* R1 at 1280 a pmos-report block is a chip under Claude's words, never JSON; opening the chat opens no tab; the chip opens the Report tab
|
|
7
7
|
* R2 a new answer with a block opens the Report tab by itself
|
|
8
|
-
* R3
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* R3 (batch 22 item 14, canvas RfH4) a new report asks its questions first, Claude's picks filled in: Format, Readers, Goes out, Look,
|
|
9
|
+
* Sources, Nothing goes out and Draft it; a pick writes nothing
|
|
10
|
+
* R4 Draft it with Once records the report, T1 and the conversation, writes its first draft and pauses it; the report's current state opens:
|
|
11
|
+
* the reader with Claude's review (RfH2) and the template icon
|
|
12
|
+
* R5 the template (RfH3): a changed format is marked, Make a different template applies it as T2, Go back to T1 restores it
|
|
13
|
+
* R6 under Sections, look and cycles: a draft is discarded after a confirm; the template is deleted after a confirm, and its reports stay
|
|
12
14
|
* R7 at 390 the chip covers the page with the Report tab; no sideways scroll; no page error
|
|
13
15
|
* Set REPORT_TAB_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
|
|
14
16
|
const fs = require('fs');
|
|
@@ -43,7 +45,8 @@ const ANSWER = { role: 'assistant', text: 'Signups from the lightbox rose to 1,2
|
|
|
43
45
|
* card ([data-rt="askyes"]). */
|
|
44
46
|
const look = () => {
|
|
45
47
|
const vw = document.querySelector('#czViewer:not([hidden])'), pane = vw ? vw.querySelector('.vz[data-vw^="report:"]') : null;
|
|
46
|
-
return { shut: !pane,
|
|
48
|
+
return { shut: !pane, title: vw ? ((vw.querySelector('.cz-vw-title') || {}).textContent || '') : '', reader: !!(vw && vw.querySelector('.vz-rp0')), review: vw && vw.querySelector('.rf-rv') ? vw.querySelector('.rf-rv').textContent : null,
|
|
49
|
+
tpl: !!(vw && vw.querySelector('[data-cz-vw-p="template"]')), layer: false, chip: (document.querySelector('#hmLog [data-report-open]') || {}).textContent || null,
|
|
47
50
|
json: /pmos-report|"kind"/.test((document.querySelector('#hmLog') || {}).textContent || ''), user: [...document.querySelectorAll('#hmLog .hm-u .hm-bub')].map((u) => u.textContent.trim()),
|
|
48
51
|
tabs: pane ? [(vw.querySelector('.cz-vw-kind') || {}).textContent || ''] : [], pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null,
|
|
49
52
|
secs: pane ? (pane.querySelector('.vz-dkt') ? pane.querySelectorAll('.vz-dkt button').length - 1 : pane.querySelectorAll('.vz-secs li').length) : 0,
|
|
@@ -66,7 +69,7 @@ const look = () => {
|
|
|
66
69
|
const open = async (width, scheme, messages) => {
|
|
67
70
|
const st = { messages };
|
|
68
71
|
const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 860 }, colorScheme: scheme, hasTouch: width < 1000 });
|
|
69
|
-
const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
|
|
72
|
+
const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e.stack || e)));
|
|
70
73
|
await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-rep', goal: null } }));
|
|
71
74
|
await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'pm', messages: st.messages } }));
|
|
72
75
|
await p.goto(chat + '&about=work:report-test'); // premium-agreed-design: /premium-chat.html opens Home with the chat ?about names; on a phone the chat is the page
|
|
@@ -81,33 +84,37 @@ const look = () => {
|
|
|
81
84
|
ok('R1 opening the chat opens no tab by itself', s0.tabs.length === 0, JSON.stringify(s0));
|
|
82
85
|
await p.click('#hmLog [data-report-open]');
|
|
83
86
|
const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane ? v : null; }) || await p.evaluate(look);
|
|
84
|
-
ok('R3
|
|
85
|
-
&&
|
|
86
|
-
&&
|
|
87
|
-
|
|
88
|
-
ok('R3 At a glance opens with For, Read by, Goes out and Format', await until(() => p.evaluate(() => /Read byGrowth leads/.test(document.querySelector('#czViewer .czs-sec.on').textContent) && /FormatGoogle Slides/.test(document.querySelector('#czViewer .czs-sec.on').textContent) && /Goes outOff · runs once/.test(document.querySelector('#czViewer .czs-sec.on').textContent))));
|
|
89
|
-
await p.click('#czViewer .czs-row[data-czs-fold="glance"]');
|
|
90
|
-
await p.click('#czViewer [data-rt="view|doc"]');
|
|
91
|
-
ok('R3 Document shows the outline as a page, and Slides brings the deck back', await until(() => p.evaluate(() => document.querySelectorAll('#czViewer .vz-dkp .vz-secs li').length === 7 && !document.querySelector('#czViewer .vz-dks'))));
|
|
92
|
-
await p.click('#czViewer [data-rt="view|deck"]');
|
|
93
|
-
await p.click('#czViewer [data-rt="sl|1"]');
|
|
94
|
-
ok('R3 next shows the second slide, a section of the report', /Slide 2 of 8/.test((await p.evaluate(look)).slide || '') && /Headline/.test(await p.textContent('#czViewer .vz-dks')));
|
|
87
|
+
ok('R3 a new report asks its questions first (RfH4): Waits on your answers, Claude\'s picks filled in (Slides, Growth leads, Once), the standard look, its sources, Nothing goes out and Draft it', /Report · Growth leads/.test(s1.tabs.join(' ')) && /Social login weekly/.test(s1.title)
|
|
88
|
+
&& /Waits on your answers/.test(s1.pane || '') && /my pick/.test(s1.pane || '') && /Standard PMOS look/.test(s1.pane || '') && /GA4/.test(s1.pane || '') && /Nothing goes out/.test(s1.pane || '')
|
|
89
|
+
&& await p.evaluate(() => document.querySelector('#czViewer [data-rt="fmt|google-slides"]').getAttribute('aria-checked') === 'true' && document.querySelector('#czViewer [data-rt="rep|0"]').getAttribute('aria-checked') === 'true' && document.querySelector('#czViewer input[data-rt="aud"]').value === 'Growth leads' && !!document.querySelector('#czViewer [data-rt="draftit"]:not([disabled])'))
|
|
90
|
+
&& !/Customer service|Follow a sample deck/.test(s1.pane || '') && !(await p.$('#czViewer .rt, #czViewer .obody, #dlg:not([hidden])')), JSON.stringify(s1));
|
|
95
91
|
if (shots) await p.screenshot({ path: `${shots}/new-1280-light.png` });
|
|
96
|
-
await p.click('#czViewer [data-rt="
|
|
97
|
-
await p.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
await p.click('#czViewer [data-rt="
|
|
101
|
-
await p.
|
|
102
|
-
const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Report template/.test(v.tabs.join()) && /Draft/.test(v.pane) ? v : null; }, 15000) || await p.evaluate(look);
|
|
92
|
+
await p.click('#czViewer [data-rt="rep|1"]');
|
|
93
|
+
const rp = await until(() => p.evaluate(() => !!document.querySelector('#czViewer select[data-rt="cad"]') && !!document.querySelector('#czViewer select[data-rt="day"]')));
|
|
94
|
+
ok('R3 Repeats asks how often, the day and the time; a pick writes nothing', rp && !ledger().some((l) => l.ev === 'setup'));
|
|
95
|
+
await p.click('#czViewer [data-rt="rep|0"]');
|
|
96
|
+
await p.click('#czViewer [data-rt="draftit"]');
|
|
97
|
+
const s3 = await until(async () => { const v = await p.evaluate(look); return v.reader && v.review != null ? v : null; }, 20000) || await p.evaluate(look);
|
|
103
98
|
const L = ledger(), setup = L.find((l) => l.ev === 'setup');
|
|
104
|
-
|
|
105
|
-
ok('R4
|
|
99
|
+
const T1 = setup ? require('./lib/report-templates.js').fold(require('./lib/report-templates.js').readLines(F.team, setup.id)) : null;
|
|
100
|
+
ok('R4 Draft it records the report, pauses it (Once) and records T1', !!setup && setup.output === 'google-slides' && setup.audience === 'Growth leads' && L.some((l) => l.ev === 'pause' && l.id === setup.id) && T1 && T1.current === 1, JSON.stringify([L.map((l) => l.ev), T1]));
|
|
101
|
+
ok('R4 the report\'s current state opens: its first draft in the reader, Claude\'s review under it (RfH2), the template icon in the header', s3.reader && /I read it as your readers would/.test(s3.review || '') && s3.tpl, JSON.stringify(s3).slice(0, 600));
|
|
102
|
+
if (shots) await p.screenshot({ path: `${shots}/draft-1280-light.png` });
|
|
103
|
+
await p.click('#czViewer [data-cz-vw-p="template"]');
|
|
104
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer .vz[data-panel="template"] [data-rt="fmt|google-doc"]')));
|
|
105
|
+
await p.click('#czViewer [data-rt="fmt|google-doc"]');
|
|
106
|
+
const t1 = await until(() => p.evaluate(() => { const v = document.querySelector('#czViewer .vz[data-panel="template"]'); return v && /changed, not saved yet/.test(v.textContent) ? v.textContent.replace(/\s+/g, ' ') : null; }));
|
|
107
|
+
ok('R5 a changed format is marked and makes a different template (RfH3)', !!t1 && /Format: Slides → Document/.test(t1) && /This makes a different template/.test(t1) && /Template history/.test(t1), t1);
|
|
108
|
+
await p.click('#czViewer [data-rt="maketpl"]');
|
|
109
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-rt="restore|1"]')), 10000);
|
|
110
|
+
const c1 = RS.fold(ledger()).setups.get(setup.id);
|
|
111
|
+
ok('R5 Make a different template applies it as T2, and T1 keeps Go back', c1.output === 'google-doc' && require('./lib/report-templates.js').fold(require('./lib/report-templates.js').readLines(F.team, setup.id)).current === 2, JSON.stringify(c1.output));
|
|
106
112
|
if (shots) await p.screenshot({ path: `${shots}/template-1280-light.png` });
|
|
107
|
-
await p.click('#czViewer [data-rt="
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
await p.click('#czViewer [data-rt="restore|1"]');
|
|
114
|
+
await until(() => p.evaluate(() => /Back to T1/.test((document.querySelector('#czViewer .vz[data-panel="template"]') || {}).textContent || '')), 10000);
|
|
115
|
+
ok('R5 Go back to T1 restores its format; nothing is deleted', RS.fold(ledger()).setups.get(setup.id).output === 'google-slides' && require('./lib/report-templates.js').fold(require('./lib/report-templates.js').readLines(F.team, setup.id)).versions.length === 2);
|
|
116
|
+
await p.click('#czViewer [data-rt="manage"]');
|
|
117
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer .vz[data-panel="manage"] [data-rt="view|design"]')), 10000);
|
|
111
118
|
/* R8 the look conversation's card (canvas RpDesign): D1 is the saved look, D2 a new one; Design previews D2 beside the current look */
|
|
112
119
|
const RDS = require('./lib/report-design.js');
|
|
113
120
|
const look1 = '<style>.pmos-slide{background:#fff}</style><section class="pmos-slide" data-title="Headline"><h2>Light, long</h2></section>';
|
|
@@ -130,8 +137,8 @@ const look = () => {
|
|
|
130
137
|
const s6 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Template deleted/.test(v.pane) ? v : null; }) || await p.evaluate(look);
|
|
131
138
|
ok('R6 Delete template asks once, then the template is gone and the tab says its reports stay', /Template deleted/.test(s6.pane || '') && ledger().some((l) => l.ev === 'remove'), JSON.stringify(s6));
|
|
132
139
|
st.messages = [ASK, ANSWER, { role: 'user', text: '[PMOS report] rule\n\nThe PM says: one for the board too' }, { role: 'assistant', text: 'Here.\n\n' + block({ kind: 'report', proposal: { ...PROP.proposal, name: 'Board summary' } }) }];
|
|
133
|
-
const s7 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Board summary/.test(v.
|
|
134
|
-
ok('R2 a new answer with a block opens the Report tab by itself', /Board summary/.test(s7.pane || ''), JSON.stringify(s7));
|
|
140
|
+
const s7 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Board summary/.test(v.title) ? v : null; }) || await p.evaluate(look);
|
|
141
|
+
ok('R2 a new answer with a block opens the Report tab by itself, on its questions', /Board summary/.test(s7.title) && /Waits on your answers/.test(s7.pane || ''), JSON.stringify(s7));
|
|
135
142
|
ok('F1 no page error and no sideways scroll', !errs.length && !s7.wide, errs.join(' | '));
|
|
136
143
|
await ctx.close(); }
|
|
137
144
|
|
|
@@ -143,7 +150,7 @@ const look = () => {
|
|
|
143
150
|
const shown = () => p.evaluate(() => { const v = document.querySelector('#czViewer:not([hidden])'); return !!v && v.getBoundingClientRect().width >= innerWidth - 1; });
|
|
144
151
|
const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && await shown() ? v : null; }) || await p.evaluate(look);
|
|
145
152
|
s1.detail = await shown();
|
|
146
|
-
ok(`R7 (${scheme}) at 390 the chip covers the page with the
|
|
153
|
+
ok(`R7 (${scheme}) at 390 the chip covers the page with the report's questions`, s1.detail && /Social login weekly/.test(s1.title) && /Waits on your answers/.test(s1.pane || ''), JSON.stringify(s1));
|
|
147
154
|
if (shots) await p.screenshot({ path: `${shots}/new-390-${scheme}.png` });
|
|
148
155
|
ok(`F1 (${scheme}) no page error and no sideways scroll at 390`, !errs.length && !s1.wide, errs.join(' | '));
|
|
149
156
|
await ctx.close();
|
|
@@ -51,6 +51,12 @@ const SHOTS = process.env.PMOS_SHOTS || '', TAG = process.env.PMOS_SHOTS_TAG ||
|
|
|
51
51
|
ok('H5 the frame is sandboxed to scripts alone', /sandbox="allow-scripts"/.test(src) && !/allow-same-origin/.test(src), src);
|
|
52
52
|
const pdf = M.fileHtml({ name: 'deck.pdf', kind: 'pdf', src: '/api/asset?ws=w&path=planning%2Fdeck.pdf', rel: 'planning/deck.pdf' });
|
|
53
53
|
ok('H5b batch 22 item 12: a PDF shows in the browser\'s PDF viewer, from /api/asset, never "could not be shown", and full width with no card (item 15)', /<iframe class="vwframe vwpdff"[^>]*src="\/api\/asset\?ws=w&path=planning%2Fdeck\.pdf#view=FitH"/.test(pdf) && !/could not be shown/.test(pdf) && !/class="cf /.test(pdf) && M.downloadsOf({ name: 'deck.pdf', kind: 'pdf', src: 'x' }).length === 0, pdf);
|
|
54
|
+
const rd = M.fileHtml({ name: 'deck.pdf', kind: 'pdf', reader: true, src: '/api/asset?ws=w&path=deck.pdf', rel: 'deck.pdf' });
|
|
55
|
+
const P = await import('./public/pm/premium-vw-pdf.js');
|
|
56
|
+
ok('H5c batch 22 item 18: on a phone the Viewer draws the PDF\'s pages itself (no frame); an iPhone, an iPad and a phone\'s Chrome need it, a desktop does not',
|
|
57
|
+
/class="vwpdfr" data-pdf-src="\/api\/asset\?ws=w&path=deck\.pdf"/.test(rd) && !/<iframe/.test(rd)
|
|
58
|
+
&& P.needsReader({ userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)' }) && P.needsReader({ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)', maxTouchPoints: 5 })
|
|
59
|
+
&& P.needsReader({ userAgent: 'Mozilla/5.0 (Linux; Android 14)', pdfViewerEnabled: false }) && !P.needsReader({ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)', maxTouchPoints: 0, pdfViewerEnabled: true }), rd);
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
const exe = findBrowser();
|
|
@@ -231,3 +231,51 @@ button.rp-cy:hover { background: var(--cz-well); }
|
|
|
231
231
|
.rp-wait::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cz-blue); animation: rp-wait 1.6s ease-in-out infinite; }
|
|
232
232
|
@keyframes rp-wait { 50% { opacity: .3; } }
|
|
233
233
|
@media (prefers-reduced-motion: reduce) { .rp-wait::before { animation: none; } }
|
|
234
|
+
|
|
235
|
+
/* ── the report building flow (batch 22 item 14, canvas RfH1–RfH7; public/pm/report-flow.js) ── */
|
|
236
|
+
.rf-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
237
|
+
.rf-qs { display: flex; flex-direction: column; gap: 14px; }
|
|
238
|
+
.rf-st { display: flex; align-items: center; gap: 7px; margin: 0; font-size: var(--fs-2); font-weight: 700; color: var(--cz-blueink); }
|
|
239
|
+
.rf-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cz-blue); flex: none; }
|
|
240
|
+
.rf-q { border: 0; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--cz-hair); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
|
|
241
|
+
.rf-q legend { float: left; width: 100%; padding: 0 0 6px; font-weight: 800; color: var(--cz-ink); display: flex; align-items: center; gap: 8px; }
|
|
242
|
+
.rf-opt { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; margin: 0 0 6px; border-radius: 12px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); font: inherit; cursor: pointer; min-height: 44px; }
|
|
243
|
+
.rf-opt[aria-checked="true"] { border-color: color-mix(in oklab, var(--cz-blue) 55%, transparent); background: var(--cz-bluebg); }
|
|
244
|
+
.rf-opt .vz-ring { margin-top: 3px; }
|
|
245
|
+
.rf-ot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
|
|
246
|
+
.rf-ot > span:last-child { flex-basis: 100%; color: var(--cz-ink2); font-size: var(--fs-2); }
|
|
247
|
+
.rf-tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 99px; background: var(--cz-well); color: var(--cz-ink2); font-size: var(--fs-1); font-weight: 700; }
|
|
248
|
+
.rf-tag[data-k="ch"] { background: var(--cz-bluebg); color: var(--cz-blueink); }
|
|
249
|
+
.rf-in input, .rf-sel select { width: 100%; box-sizing: border-box; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); font: inherit; }
|
|
250
|
+
.rf-row { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
251
|
+
.rf-row .rf-sel { flex: 1 1 120px; }
|
|
252
|
+
.rf-seg { min-height: 40px; padding: 0 16px; border-radius: 99px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); font: inherit; font-weight: 700; cursor: pointer; }
|
|
253
|
+
.rf-seg[aria-checked="true"] { background: var(--cz-bluebg); border-color: transparent; color: var(--cz-blueink); }
|
|
254
|
+
.rf-fix { margin: 0; display: flex; flex-direction: column; gap: 2px; } .rf-fix span { color: var(--cz-ink2); font-size: var(--fs-2); }
|
|
255
|
+
.rf-src { margin: 0; padding-left: 18px; color: var(--cz-ink); }
|
|
256
|
+
.rf-chg { margin: 0; font-size: var(--fs-2); color: var(--cz-ink2); }
|
|
257
|
+
.rf-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--cz-hair); }
|
|
258
|
+
.rf-foot .vz-note { margin-right: auto; }
|
|
259
|
+
.rf-ib { width: 36px; height: 36px; min-width: 36px; border-radius: 50%; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
|
|
260
|
+
.rf-ib.pri { background: var(--cz-blue); border-color: transparent; color: var(--cz-onsolid); }
|
|
261
|
+
.rf-ib[disabled] { opacity: .45; cursor: default; }
|
|
262
|
+
.rf-hist h3 { margin: 4px 0 6px; font-size: var(--fs-3); }
|
|
263
|
+
.rf-hist ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
|
|
264
|
+
.rf-hv { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--cz-hair); }
|
|
265
|
+
.rf-hv > b { min-width: 28px; color: var(--cz-ink3); }
|
|
266
|
+
.rf-hv[aria-current="true"] > b, .rf-hv[data-k="new"] > b { color: var(--cz-blueink); }
|
|
267
|
+
.rf-hv > span { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
|
268
|
+
.rf-hv em { font-style: normal; color: var(--cz-ink3); font-size: var(--fs-2); }
|
|
269
|
+
.rf-wait { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--cz-bluebg); }
|
|
270
|
+
.rf-wait[data-k="bad"] { background: var(--cz-well); }
|
|
271
|
+
.rf-wait p { flex: 1; margin: 0; display: flex; flex-direction: column; gap: 2px; } .rf-wait p span { color: var(--cz-ink2); font-size: var(--fs-2); }
|
|
272
|
+
.rf-rv { display: flex; flex-direction: column; margin: 12px 0; }
|
|
273
|
+
.rf-rvh { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--cz-bluebg); }
|
|
274
|
+
.rf-rvh > b { flex: 1; font-size: var(--fs-2); }
|
|
275
|
+
.rf-fx { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--cz-hair); }
|
|
276
|
+
.rf-fx + .rf-fx { margin-top: 0; } .rf-rvh + .rf-fx { border-top: 0; }
|
|
277
|
+
.rf-star { color: var(--cz-blueink); margin-top: 2px; }
|
|
278
|
+
.rf-fxt { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; } .rf-fxt span { color: var(--cz-ink2); font-size: var(--fs-2); }
|
|
279
|
+
.rf-pass { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin: 0; padding: 10px 4px; border-top: 1px solid var(--cz-hair); font-size: var(--fs-2); }
|
|
280
|
+
.rf-pass span { color: var(--cz-ink3); }
|
|
281
|
+
.rf-opt[aria-checked="true"] .vz-ring { border: 5px solid var(--cz-blue); }
|
|
@@ -836,7 +836,11 @@ function sessionTarget(s) {
|
|
|
836
836
|
const key = H.keyOfSession(s);
|
|
837
837
|
const ini = H.iniOfSession(s);
|
|
838
838
|
const role = H.roleOf(s, S.D.desk && S.D.desk.roles);
|
|
839
|
-
|
|
839
|
+
// a program's or a product's own chat says so in its scope, never "Loose" (batch 22 item 17)
|
|
840
|
+
const pm = /^chat:program:([^:]+)/.exec(key || ''), pr = pm ? (S.D.programs || []).find((p) => p && p.id === pm[1]) : null;
|
|
841
|
+
const prod = !ini && !pr && /^product(:|$)/.test(key || '') ? H.productName(S.D) : '';
|
|
842
|
+
const home = pr ? { text: pr.title, icon: TD.P.layers } : prod ? { text: prod, icon: I.home } : null;
|
|
843
|
+
const t = { title: H.nameOf(s), ses: s.id, sub: [role.name, ini ? iniTitle(ini) : home ? home.text : 'Loose'].join(' · '), ini, role, scope: ini ? scopeOf(ini) : home || { text: 'Loose', icon: I.chat, loose: true }, rich: rich(), to: rich() ? role : null, also: alsoOf(ini) };
|
|
840
844
|
if (key && /^(decision|blocked|waited|src|ev|work|board|init|doc|ins|chat|pop):/.test(key)) { t.key = key; t.sid = undefined; } else t.sid = s.id;
|
|
841
845
|
if (!t.key) t.sid = s.id;
|
|
842
846
|
if (/^schedule:/.test(s.origin || '')) t.routine = true; // a scheduled run: a stop reads "Run stopped at 3 of 5" with Run again (home-sweep.js)
|
|
@@ -1744,7 +1748,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
|
|
|
1744
1748
|
if (d.hmSes) { sesPill(d.hmSes === S.ses ? null : d.hmSes); return; } // an initiative's pill: what sits in it, under it (a sheet on a phone)
|
|
1745
1749
|
if ('hmSesx' in d) { sesPill(null); return; }
|
|
1746
1750
|
if (d.hmSesnew) { sesPill(null, false); newIn(d.hmSesnew); return; }
|
|
1747
|
-
if (d.hmProdnew) { sesPill(null, false); const g = ((S.M && S.M.groups) || []).find((x) => x.key === d.hmProdnew); if (g && !g.primary && g.product && g.product.ws) goOtherProduct(g); else goIni('product'); { const c = chat.current(); if (c && c.newChat) c.newChat(); } return; }
|
|
1751
|
+
if (d.hmProdnew) { sesPill(null, false); const g = ((S.M && S.M.groups) || []).find((x) => x.key === d.hmProdnew); if (g && g.kind === 'program') goProgram(g.program.id); else if (g && !g.primary && g.product && g.product.ws) goOtherProduct(g); else goIni('product'); { const c = chat.current(); if (c && c.newChat) c.newChat(); } return; }
|
|
1748
1752
|
if (d.hmCompact) { compact(d.hmCompact); return; } // ✓ on Claude's ✦ Compact (batch 13 item 8): the pill's list stays open
|
|
1749
1753
|
if (S.ses && !b.closest('.hv-spp, .hv-sps, .hv-rcs')) sesPill(null, false); // a press anywhere else in the list closes it
|
|
1750
1754
|
if (d.hmSel) { if (S.ses) sesPill(null, false); if (S.day) S.day = false; select(d.hmSel); return; }
|
|
@@ -36,7 +36,7 @@ import { adler } from './cozy-adler.js';
|
|
|
36
36
|
/* The views a chat opens go in the Viewer: on a page with no dialog the old viewer's views draw in the cozy card (premium-viewer.js). */
|
|
37
37
|
const views = {
|
|
38
38
|
ctx: () => import('./premium-vw-ctx.js'), file: () => import('./premium-vw-file.js'), attach: () => import('./premium-attach.js'),
|
|
39
|
-
block: (b) => (b.kind === 'report' ? import('./premium-report-tab.js').then((M) => M.openReportTab(b)) : import('./premium-chart-tab.js').then((M) => M.openChartTab(b))),
|
|
39
|
+
block: (b, o) => (b.kind === 'report' ? import('./premium-report-tab.js').then((M) => M.openReportTab(b, o)) : import('./premium-chart-tab.js').then((M) => M.openChartTab(b))),
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const SVG = (d, w = 16, sw = 2) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
@@ -327,7 +327,7 @@ export function mountChat(el, host) {
|
|
|
327
327
|
function show(it) { if (host.desk()) openIt(it); else peek(it); }
|
|
328
328
|
function openIt(it) {
|
|
329
329
|
if (it.kind === 'goal') return openGoal();
|
|
330
|
-
if (it.kind === 'report') return views.block(it.block);
|
|
330
|
+
if (it.kind === 'report') return views.block(it.block, { chat: C.t.key || null, auto: true });
|
|
331
331
|
return views.ctx().then((M) => M.openCtx(it.item, where()));
|
|
332
332
|
}
|
|
333
333
|
function peek(it) {
|
|
@@ -480,7 +480,7 @@ export function mountChat(el, host) {
|
|
|
480
480
|
if (C.addOpen && b.closest('.hm-addm')) { C.addOpen = false; drawFoot({ role: role() }); } // a press in the + menu closes it, then does its part
|
|
481
481
|
if ('hmSignin' in d) { import('./cozy-settings.js').then((S) => S.openSettings('connectors')); return; } // a reach ask: Sign in to Jira opens Settings › Connectors
|
|
482
482
|
if ('hmFile' in d) { const i = foot.querySelector('#hmFile'); if (i) i.click(); return; }
|
|
483
|
-
if (d.reportOpen != null && d.reportOpen !== '') { e.preventDefault(); const m = ((C.conv && C.conv.messages) || [])[+d.reportOpen]; const bl = m ? splitReport(splitGoal(m.text).text).block : null; if (bl) views.block(bl); return; }
|
|
483
|
+
if (d.reportOpen != null && d.reportOpen !== '') { e.preventDefault(); const m = ((C.conv && C.conv.messages) || [])[+d.reportOpen]; const bl = m ? splitReport(splitGoal(m.text).text).block : null; if (bl) views.block(bl, { chat: C.t.key || null }); return; }
|
|
484
484
|
if (d.ctx != null) { e.preventDefault(); views.ctx().then((M) => M.openCtx(M.itemOf(b), where())); return; }
|
|
485
485
|
if (d.file) { e.preventDefault(); views.file().then((M) => M.openChatFile(d.file, where())); return; }
|
|
486
486
|
if (d.att) { e.preventDefault(); if (/\/notes\/n[0-9a-z]{6,16}\.md$/.test(d.att)) openNotesHere(d.att.split('/').pop().replace(/\.md$/, '')); else views.attach().then((M) => M.openAttachment(d.att)); return; }
|
|
@@ -150,6 +150,11 @@ function iniRowOf(D, r, needs, now) {
|
|
|
150
150
|
|
|
151
151
|
/** A product's own chat key: the board's product is `product` or `product:<n>`; another product is `product:<ws>` or `product:<ws>:<n>`
|
|
152
152
|
* (home-app.js productTarget, goOtherProduct, newProduct). */
|
|
153
|
+
/** A program's own chat key: `chat:program:<id>` (home-app.js programTarget), or a new session of it (`chat:program:<id>:<n>`). */
|
|
154
|
+
export function isProgramChat(key, id) {
|
|
155
|
+
const k = String(key || ''), b = 'chat:program:' + id;
|
|
156
|
+
return !!id && (k === b || k.startsWith(b + ':'));
|
|
157
|
+
}
|
|
153
158
|
export function isProductChat(key, p) {
|
|
154
159
|
const k = String(key || ''), ws = p && p.ws ? 'product:' + p.ws : null;
|
|
155
160
|
return !!((p && p.primary && (k === 'product' || /^product:\d+$/.test(k))) || (ws && (k === ws || /^:\d+$/.test(k.slice(ws.length)) && k.startsWith(ws + ':'))));
|
|
@@ -197,8 +202,10 @@ export function programGroups(D, groups, products, o, now) {
|
|
|
197
202
|
// Claude's milestone changes wait on the PM: one Your move line per program, never one per change (canvas XmsgB, Home frame)
|
|
198
203
|
const msSub = homeSub(pr);
|
|
199
204
|
const msRow = msSub ? { id: 'ms:' + pr.id, kind: 'msreview', program: pr.id, name: pr.title, hint: msSub, state: 'needs' } : null;
|
|
200
|
-
|
|
201
|
-
|
|
205
|
+
// the program's own chats sit in its header's pill, as a product's do, never under "Not in an initiative" (Wawan, 2026-11-02, batch 22 item 17)
|
|
206
|
+
const kids = (D.sessions || []).filter((s) => listed(s) && isProgramChat(keyOfSession(s), pr.id)).map((s) => sessionRow(s, D.desk && D.desk.roles)).sort((a, b) => (RANK[b.state] || 0) - (RANK[a.state] || 0));
|
|
207
|
+
out.push({ key: 'g:' + pr.id, kind: 'program', program: pr, st, name: pr.title, subs, inis, rest: [], tasks, count: inis.length, turnN, msRow, kids,
|
|
208
|
+
yours: inis.reduce((n, x) => n + x.yours, 0) + tasks.filter((t) => t.mine && t.late).length + (msRow ? 1 : 0) + kids.filter((k) => k.state === 'needs' || k.state === 'blocked').length, late: inis.some((x) => x.late) || tasks.some((t) => t.late),
|
|
202
209
|
products: st.products, closedLine: closedOf(inis.length, turnN) });
|
|
203
210
|
}
|
|
204
211
|
return out;
|
|
@@ -268,7 +275,7 @@ export function homeList(D, o = {}) {
|
|
|
268
275
|
// an item the PM linked to an initiative (the clean-up, batch 13 item 3) sits under that initiative, not here
|
|
269
276
|
for (const r of tabRows('today')) if (!r.ini || !groups.some((g) => g.inis.concat(g.rest).some((i) => i.ini === r.ini))) loose.push(itemRow(r));
|
|
270
277
|
for (const m of todayOf(D).filter((x) => !meetIni(x) && x.state !== 'past')) loose.push(meetRow(m, null));
|
|
271
|
-
const inProduct = (s) => products.some((p) => isProductChat(keyOfSession(s), p));
|
|
278
|
+
const inProduct = (s) => products.some((p) => isProductChat(keyOfSession(s), p)) || /^chat:program:/.test(keyOfSession(s) || '');
|
|
272
279
|
for (const s of (D.sessions || []).filter((s) => listed(s) && !iniOfSession(s) && !inProduct(s) && s.shown !== 'needs' && s.shown !== 'blocked')) loose.push({ ...sessionRow(s, D.desk && D.desk.roles), loose: true });
|
|
273
280
|
// the folded line's signals (HvAC .lh): a blue dot when a row waits on the PM, an amber square when one of the PM's own is late
|
|
274
281
|
const lsig = { needs: loose.filter((r) => r.state === 'needs' || r.state === 'blocked').length, sessions: loose.filter((r) => r.kind === 'session' || r.needSession).length, tasks: loose.filter((r) => r.check).length, late: loose.filter((r) => r.check && r.late).length };
|
|
@@ -205,8 +205,8 @@ function programHtml(g, o) {
|
|
|
205
205
|
const ms = msHtml(g);
|
|
206
206
|
const line = nx ? 'Next milestone ' + nx.name + (nx.day ? ', ' + nx.day : '') + (nx.late ? ', late' : '') + (nx.n ? ', ' + nx.ready + ' of ' + nx.n + (nx.n === 1 ? ' initiative' : ' initiatives') + ' ready' : '') : 'No open milestone';
|
|
207
207
|
const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prog="${esc(g.program.id)}" aria-label="Open ${esc(g.name)}, a program"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
|
|
208
|
-
+ `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}"${o.here === g.key ? ' data-cz-rail-here' : ''}>${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>${open && g.st ? sugHtml(g.program, g.st) : ''}`
|
|
209
|
-
+ `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}. ${esc(line)}${g.yours ? '. ' + yoursWords(g) : ''}. ${open ? 'Close' : 'Open'} the group">${ms}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button
|
|
208
|
+
+ `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}"${o.here === g.key ? ' data-cz-rail-here' : ''}>${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>${prodPillHtml(g, o)}${open && g.st ? sugHtml(g.program, g.st) : ''}`
|
|
209
|
+
+ `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}. ${esc(line)}${g.yours ? '. ' + yoursWords(g) : ''}. ${open ? 'Close' : 'Open'} the group">${ms}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button>${prodPopHtml(g, o)}</div>`;
|
|
210
210
|
const sec = `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}" data-po-id="g:${esc(g.program.id)}">${SO.gripHtml(g.name)}`;
|
|
211
211
|
if (!open) return `${sec}${head}</section>`;
|
|
212
212
|
// the program's tasks are on its panel (On the program), not on Home: Home lists no tasks (Wawan, 2026-10-25)
|