create-pmos 0.481.0 → 0.483.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 +7 -3
- 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 +1 -1
- package/workspace/public/pm/cozy-vw-rp.css +48 -0
- package/workspace/public/pm/home-chat.js +13 -5
- 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 +5 -0
- package/workspace/public/pm/premium-vw-file.js +1 -1
- package/workspace/public/pm/report-chat.js +5 -3
- package/workspace/public/pm/report-flow.js +163 -0
- package/workspace/stage-card-tasks-test.js +3 -1
- package/workspace/test-lists/report-flow.json +11 -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.483.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.483.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();
|
|
@@ -50,7 +50,7 @@ const SHOTS = process.env.PMOS_SHOTS || '', TAG = process.env.PMOS_SHOTS_TAG ||
|
|
|
50
50
|
const src = M.fileHtml({ name: 'r.html', kind: 'html', text: '<b>"x"</b>', rel: 'r.html' });
|
|
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
|
-
ok('H5b batch 22 item 12: a PDF shows in the browser\'s PDF viewer, from /api/asset, never "could not be shown"', /<iframe class="vwframe vwpdff"[^>]*src="\/api\/asset\?ws=w&path=planning%2Fdeck\.pdf#view=FitH"/.test(pdf) && !/could not be shown/.test(pdf) && M.downloadsOf({ name: 'deck.pdf', kind: 'pdf', src: 'x' }).length === 0, pdf);
|
|
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
54
|
}
|
|
55
55
|
}
|
|
56
56
|
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); }
|
|
@@ -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>`;
|
|
@@ -162,8 +162,16 @@ export function mountChat(el, host) {
|
|
|
162
162
|
// as typed: PMOS wraps a report ask or a /goal in its rule, adds the files line, and a live session joins the lines (batch 22 item 10:
|
|
163
163
|
// a /goal sent with a file stayed "reads it after this tool call" after Claude had read it), so compare the words alone
|
|
164
164
|
const key = (t) => splitFiles(shownUser(t)).text.replace(/\s+/g, ' ').trim();
|
|
165
|
-
const
|
|
166
|
-
|
|
165
|
+
const users = ((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user');
|
|
166
|
+
const said = new Set(users.map((m) => key(m.text)));
|
|
167
|
+
// a queued line is read once any PM turn lands at or after it: the chat may hold only its latest messages, or PMOS may have wrapped the
|
|
168
|
+
// words (Wawan, 2026-11-02, batch 22 item 16: the very first /goal stayed "reads it after this tool call" for hours). Read lines leave the queue.
|
|
169
|
+
const t0 = (x) => Date.parse(x.at) || 0;
|
|
170
|
+
const lastUser = users.reduce((n, m) => Math.max(n, Date.parse(m.at) || 0), 0);
|
|
171
|
+
const read = (x) => said.has(key(x.text)) || (lastUser && t0(x) && lastUser >= t0(x) - 2000);
|
|
172
|
+
const gone = q.filter(read);
|
|
173
|
+
if (gone.length && host.unqueue) setTimeout(() => gone.forEach((x) => host.unqueue(sid(), x.at)), 0);
|
|
174
|
+
return q.filter((x) => !read(x)).map((x) => `<div class="hm-q"><div class="hm-qb">${userHtml(x.text)}</div><span class="hm-qn">${esc(role().name)} reads it after this tool call, in seconds<button type="button" class="hm-qx" data-hm-qdel="${esc(x.at)}" aria-label="Take it back" title="Take it back">${SVG(XX, 13)}</button></span></div>`).join('');
|
|
167
175
|
}
|
|
168
176
|
const sid = () => (C.t && C.t.sid) || (C.th && C.th.session) || null;
|
|
169
177
|
// A loose chat that reads like one initiative gets one quiet chip at its top: "Looks like <initiative> · Link it ×" (XvALinkSuggest).
|
|
@@ -319,7 +327,7 @@ export function mountChat(el, host) {
|
|
|
319
327
|
function show(it) { if (host.desk()) openIt(it); else peek(it); }
|
|
320
328
|
function openIt(it) {
|
|
321
329
|
if (it.kind === 'goal') return openGoal();
|
|
322
|
-
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 });
|
|
323
331
|
return views.ctx().then((M) => M.openCtx(it.item, where()));
|
|
324
332
|
}
|
|
325
333
|
function peek(it) {
|
|
@@ -472,7 +480,7 @@ export function mountChat(el, host) {
|
|
|
472
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
|
|
473
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
|
|
474
482
|
if ('hmFile' in d) { const i = foot.querySelector('#hmFile'); if (i) i.click(); return; }
|
|
475
|
-
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; }
|
|
476
484
|
if (d.ctx != null) { e.preventDefault(); views.ctx().then((M) => M.openCtx(M.itemOf(b), where())); return; }
|
|
477
485
|
if (d.file) { e.preventDefault(); views.file().then((M) => M.openChatFile(d.file, where())); return; }
|
|
478
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; }
|
|
@@ -53,7 +53,9 @@ import { open as vOpen, current as vCur, czSections } from './cozy-viewer.js';
|
|
|
53
53
|
import * as MP from './premium-mtg-present.js'; // the one presenter window for every kind (canvas note xvPresent)
|
|
54
54
|
import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, the recording tab presents it (rule 10)
|
|
55
55
|
import { placeholderHtml } from './cozy-placeholder.js';
|
|
56
|
-
import { vzStyle } from './premium-vw-open.js';
|
|
56
|
+
import { vzStyle } from './premium-vw-open.js';
|
|
57
|
+
import { reviewHtml, ICON as RF_ICON } from './report-flow.js'; // Claude's review and the template icon (batch 22 item 14, canvas RfH2, RfH6)
|
|
58
|
+
import { adler } from './cozy-adler.js'; // registers window.czViews; vzStyle adds the Viewer's sheet (cozy-vw.css)
|
|
57
59
|
import { cycleGroups, cycleName, briefModel, briefGlanceHtml, briefConfirmHtml, briefWhyHtml, briefLooksHtml, paperModel, paperHtml, liveModel, liveHtml, presentHtml, dayMon, reportSummary,
|
|
58
60
|
rpSumHtml, rpBarHtml, cadenceWords, goesOutWords, FORMATS } from './rp-parts.js';
|
|
59
61
|
|
|
@@ -434,8 +436,35 @@ function bodyHtml() {
|
|
|
434
436
|
}
|
|
435
437
|
const view = R.err ? `<p class="vz-msg" data-tone="bad" role="alert">The document could not be read: ${esc(R.err)}</p>` : !R.W ? '<p class="vz-empty" role="status">Reading the report.</p>'
|
|
436
438
|
: R.view === 'deck' ? deckHtml() : R.view === 'live' ? liveView() : pageHtml();
|
|
437
|
-
return `<div class="vz-rpb">${R.conf ? confHtml() : R.W ? sumHtml() : ''}${R.W && !R.err ? cutsHtml() : ''}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}${R.edit ? '' : waitHtml()}${R.W && !R.err ? barHtml() : ''}${view}${R.W && !R.err ? foldsHtml() : ''}${askHtml()}</div>`;
|
|
439
|
+
return `<div class="vz-rpb">${R.conf ? confHtml() : R.W ? sumHtml() : ''}${R.W && !R.err ? cutsHtml() : ''}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}${R.edit ? '' : waitHtml()}${R.W && !R.err ? barHtml() : ''}${view}${R.W && !R.err && !R.issued ? rvHtml() : ''}${R.W && !R.err ? foldsHtml() : ''}${askHtml()}</div>`;
|
|
438
440
|
}
|
|
441
|
+
/* ── Claude's review (batch 22 item 14, canvas RfH2): the checks PMOS runs on the draft, as ✦ fixes the report's own session makes ── */
|
|
442
|
+
function rvHtml() {
|
|
443
|
+
if (!R.rv) return '';
|
|
444
|
+
const n = (R.rv.fix || []).filter((f) => !R.rvHide.has(f.id) && !R.rvSent.has(f.id)).length;
|
|
445
|
+
return reviewHtml(R.rv, { hidden: R.rvHide, sent: R.rvSent, busy: R.busy, face: adler(n ? 'needs-you' : 'handled', 36) });
|
|
446
|
+
}
|
|
447
|
+
async function readReview() {
|
|
448
|
+
const me = R; if (!R || R.issued || !R.row.path) return;
|
|
449
|
+
const j = await Promise.resolve(pmGet('/api/report-flow/review?' + q({ ws: R.ws, path: R.row.path }))).catch(() => null);
|
|
450
|
+
if (R !== me) return;
|
|
451
|
+
R.rv = j && j.ok && j.review ? j.review : null; draw();
|
|
452
|
+
}
|
|
453
|
+
/** Do it (one fix, or all of them): the change goes to the report's own session, never to the PM's chat. */
|
|
454
|
+
async function rvAct(k, v) {
|
|
455
|
+
const me = R, L = (R.rv && R.rv.fix) || [];
|
|
456
|
+
if (k === 'rv-no') { R.rvHide.add(v); return draw(); }
|
|
457
|
+
const todo = (k === 'rv-all' ? L : L.filter((f) => f.id === v)).filter((f) => !R.rvHide.has(f.id) && !R.rvSent.has(f.id));
|
|
458
|
+
if (!todo.length || R.busy) return;
|
|
459
|
+
R.busy = true; draw();
|
|
460
|
+
const r = await pmPost('/api/report-flow/ask', { ws: R.ws, id: R.id, path: R.row.path, text: todo.map((f) => f.title + ' (' + f.why + ')').join('; ') }).catch(() => null);
|
|
461
|
+
if (R !== me) return;
|
|
462
|
+
R.busy = false;
|
|
463
|
+
if (!r || !r.ok) return say('That was not passed on: ' + ((r && r.error) || 'the page could not reach PMOS') + '.', 'bad');
|
|
464
|
+
todo.forEach((f) => R.rvSent.add(f.id));
|
|
465
|
+
say((r.started ? 'The report\'s session started with ' : 'Passed to the report\'s session: ') + (todo.length === 1 ? 'one change' : todo.length + ' changes') + '. They show here as it writes them. Nothing is issued.');
|
|
466
|
+
}
|
|
467
|
+
function openTemplate() { import('./premium-report-tab.js').then((M) => M.openReportTab({ kind: 'report', id: R.id }, { panel: 'template' })); }
|
|
439
468
|
/** What Claude is still doing on this report, said where the PM reads it (Wawan, 2026-11-01, batch 22 item 13: "I have to wait, but there's
|
|
440
469
|
* no indication of me having to wait"). Nothing running → ''. */
|
|
441
470
|
export function waitWords(x, draft) {
|
|
@@ -526,7 +555,7 @@ function wire(b) {
|
|
|
526
555
|
const top = b.getBoundingClientRect().top + 80; let n = 1; pgs.forEach((g, k) => { if (g.getBoundingClientRect().top <= top) n = k + 1; });
|
|
527
556
|
const t = 'Page ' + n + ' of ' + pgs.length; if (c.textContent !== t) c.textContent = t;
|
|
528
557
|
};
|
|
529
|
-
b.onmousemove = (e) => { if (R.view !== 'live' || !R.LV) return; const pt = e.target.closest('.rp-pt'); if (pt) { const h = +pt.dataset.r.split('|')[2]; if (R.LV.hover !== h) { R.LV.hover = h; draw(); } } };
|
|
558
|
+
b.onmousemove = (e) => { if (!R || R.view !== 'live' || !R.LV) return; const pt = e.target.closest('.rp-pt'); if (pt) { const h = +pt.dataset.r.split('|')[2]; if (R.LV.hover !== h) { R.LV.hover = h; draw(); } } };
|
|
530
559
|
}
|
|
531
560
|
/* a 1280 x 720 frame scales to its slide's width */
|
|
532
561
|
const RO = typeof ResizeObserver === 'function' ? new ResizeObserver((es) => { for (const e of es) scaleOf(e.target, e.contentRect.width); }) : null;
|
|
@@ -536,6 +565,7 @@ export function fit(root) { root.querySelectorAll('.vz-fr').forEach((c) => { if
|
|
|
536
565
|
/* ── the presses ── */
|
|
537
566
|
const say = (text, tone) => { R.msg = { text, tone }; draw(); };
|
|
538
567
|
async function act([k, v], t) {
|
|
568
|
+
if (k === 'rv-do' || k === 'rv-no' || k === 'rv-all') return rvAct(k, v);
|
|
539
569
|
if (k === 'pop') { R.pop = v || null; return draw(); }
|
|
540
570
|
if (k === 'cut') return cutTo(v);
|
|
541
571
|
if (k === 'bf') return briefAct(v, t.dataset.r.split('|').slice(2).join('|'));
|
|
@@ -927,8 +957,10 @@ export async function openReport(row, hand = {}) {
|
|
|
927
957
|
if (R) present(false);
|
|
928
958
|
const me = R = { row, ws: hand.ws || '', id: c.cadence, name: hand.name || row.name || c.cadence || 'Report', audience: hand.audience || '', issued: row.state === 'issued', archived: !!row.archived,
|
|
929
959
|
text: '', err: '', W: null, view: 'deck', BF: null, bfRaw: null, bfMsg: '', LV: null, blank: false, i: 0, cyc: null, setup: undefined, pop: null, conf: false, checks: null, issueErr: '', busy: false, ask: '', askErr: '', edit: false, msg: null,
|
|
930
|
-
sch: schedPick(null), schErr: '', shr: null, shares: null, more: [], hand, cuts: hand.cuts ? { on: 'team', team: null, sponsors: null, err: '' } : null, cycles: (hand.cycles || []).slice(), onIssue: hand.onIssue || null, onChange: hand.onChange || null, vid: 'report:' + row.path };
|
|
960
|
+
sch: schedPick(null), schErr: '', shr: null, rv: null, rvHide: new Set(), rvSent: new Set(), shares: null, more: [], hand, cuts: hand.cuts ? { on: 'team', team: null, sponsors: null, err: '' } : null, cycles: (hand.cycles || []).slice(), onIssue: hand.onIssue || null, onChange: hand.onChange || null, vid: 'report:' + row.path };
|
|
931
961
|
const head = me.head = () => ({ id: me.vid, kind: 'Report' + (me.audience ? ' · ' + me.audience : ''), title: me.name, icon: me.view === 'doc' ? 'doc' : 'report', full: true, url: viewUrl(row, me.ws), more: me.more,
|
|
962
|
+
// the template behind one icon (batch 22 item 14, canvas RfH1): format, readers, when it goes out, and its history
|
|
963
|
+
presses: me.setup ? [{ act: 'template', label: 'Template: format, readers, look, sources', icon: RF_ICON.tune }] : [], onPress: (a) => { if (a === 'template' && R === me) openTemplate(); },
|
|
932
964
|
render: (b) => { syncMore(); b.innerHTML = panelHtml(); wire(b); }, onClose: () => { if (R === me && !me.reopen) { present(false); R = null; } } });
|
|
933
965
|
vOpen(head());
|
|
934
966
|
try { R.text = await textOf('/api/doc?' + q({ ws: R.ws, path: row.path })); R.W = wordsOf(R.text, R.name); if (!hand.name && R.W.title) R.name = R.W.title; } catch (x) { R.err = String((x && x.message) || x); R.W = { title: R.name, sections: [] }; }
|
|
@@ -941,7 +973,9 @@ export async function openReport(row, hand = {}) {
|
|
|
941
973
|
await Promise.all([readCycle(), readSetup(), readShares()]);
|
|
942
974
|
if (R !== me) return me;
|
|
943
975
|
readBrief(); // the Brief tab's count shows at once
|
|
944
|
-
|
|
976
|
+
readReview();
|
|
977
|
+
if (hand.say) me.msg = { text: hand.say };
|
|
978
|
+
if (vCur() && vCur().id === me.vid && (vCur().title !== me.name || me.audience || me.setup)) { me.reopen = true; vOpen(head()); me.reopen = false; } // the name and audience are known now
|
|
945
979
|
draw();
|
|
946
980
|
watchFile(me);
|
|
947
981
|
return me;
|
|
@@ -957,7 +991,7 @@ async function watchFile(me) {
|
|
|
957
991
|
if (document.hidden || me.edit || me.busy || me.pop || (me.cuts && me.cuts.on === 'sponsors')) continue; // the sponsors cut is read from the file, not the file
|
|
958
992
|
const h = await stamp();
|
|
959
993
|
if (R !== me || !h) continue;
|
|
960
|
-
if (seen && h !== seen) { await reread(); if (R === me && !me.edit && !me.pop) draw(); }
|
|
994
|
+
if (seen && h !== seen) { await reread(); if (R === me && !me.edit && !me.pop) { draw(); readReview(); } }
|
|
961
995
|
seen = h;
|
|
962
996
|
}
|
|
963
997
|
}
|