create-pmos 0.591.0 → 0.592.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 +14 -14
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +13 -0
- package/workspace/guide/agent-capabilities.md +23 -12
- package/workspace/guide/cli.md +2 -2
- package/workspace/lib/idle-lab.js +17 -5
- package/workspace/lib/lab-cli.js +5 -5
- package/workspace/lib/live-round.js +320 -66
- package/workspace/lib/proto-runtime.js +104 -0
- package/workspace/lib/routes-briefing-premium.js +26 -14
- package/workspace/lib/routes-lab.js +53 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-home.css +8 -0
- package/workspace/public/pm/cozy-lab.js +15 -7
- package/workspace/public/pm/cozy-proto.css +138 -0
- package/workspace/public/pm/cozy-proto.js +436 -0
- package/workspace/public/pm/home-app.js +2 -0
- package/workspace/public/pm/home-chat.js +39 -5
- package/workspace/server.js +2 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
/* pm/cozy-proto.js — Prototype by chatting: the Viewer as ONE canvas (initiative live-round-iterative; design
|
|
2
|
+
* https://claude.ai/artifact/9fxuukKr3XixwkGFMTfeba, main canvas boards PbcChat, PbcPoint, PbcLanes, PbcDesk, PbcPlay; Wawan "Agreed"
|
|
3
|
+
* 2026-11-17). The initiative chat sits on the left; this draws the right side for a live round (lib/live-round.js), from the compare view
|
|
4
|
+
* pm/cozy-lab.js reads (GET /api/lab/compare: the version's file and its companions as data, lib/live-round.js partsAt).
|
|
5
|
+
*
|
|
6
|
+
* The toolbar: Point (S), Comment (C), Draw (D) · Phone, Desktop · Version n of N (‹ ›, Back to latest, Continue from version n) · zoom
|
|
7
|
+
* −, +, fit · Play. Icon-only presses with aria-labels.
|
|
8
|
+
* The cards, which update together: the prototype in a phone or desktop frame (Tweaks under it for the element pointed at, the comments,
|
|
9
|
+
* the ✦ test-link suggestion); the flow (screens as cards, decisions as diamonds, drawn as SVG from flow.json: a screen shows that moment
|
|
10
|
+
* on the prototype, a branch plays its scenario); the page copy (copy.json, edited in place: the prototype changes as the PM types and
|
|
11
|
+
* the edit is kept with the version, POST /api/lab/edit); who does what (lanes.json as a swimlane with arrows: a step shows its screen).
|
|
12
|
+
* A card the version changed says Updated (compare.updated).
|
|
13
|
+
* Three ways (a round with several versions): a tray; a press previews one; ✓ keeps it, ✕ closes the round.
|
|
14
|
+
* Play: the prototype full size through a scenario of flow.json; a tap where the user would tap moves on, a miss shows the hotspots.
|
|
15
|
+
* The chat (pm/home-chat.js) hears 'pmos:point', 'pmos:from' and 'pmos:say' (window events, detail.ini names the initiative); it says
|
|
16
|
+
* 'pmos:version' when the PM taps a Version n tag.
|
|
17
|
+
* The frame is the sandboxed specimen with the canvas runtime (GET /api/lab/specimen?rt=1, lib/proto-runtime.js): it cannot reach PMOS,
|
|
18
|
+
* and it talks to this page only through postMessage.
|
|
19
|
+
*
|
|
20
|
+
* draw(body, compare, { at, H, history? }) draws or updates the canvas in the Viewer's body (pm/cozy-lab.js calls it for a live round)
|
|
21
|
+
* openVersion({ ws, board?, ini, n }) shows version n of the initiative's newest round (the chat's Version n tag)
|
|
22
|
+
* flowLayout(flow) · lanesLayout(lanes) PURE: where the SVG puts each node and arrow (exported for the source check) */
|
|
23
|
+
import { pmGet, pmPost, pmHeaders } from './http.js';
|
|
24
|
+
|
|
25
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
26
|
+
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>`;
|
|
27
|
+
const I = {
|
|
28
|
+
point: 'M5 3l14 7-6 2-2 6z', comment: 'M4 5h16v11H9l-5 4z', draw: 'M4 20l4-1 11-11-3-3L5 16zM14 6l3 3',
|
|
29
|
+
phone: 'M8 3h8a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM11 18h2', desk: 'M3 5h18v11H3zM8 20h8M12 16v4',
|
|
30
|
+
minus: 'M6 12h12', plus: 'M12 6v12M6 12h12', fit: 'M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5', play: 'M7 5l12 7-12 7z',
|
|
31
|
+
prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6', latest: 'M5 12h14M13 6l6 6-6 6', cont: 'M4 12a8 8 0 1 0 2.3-5.6L4 9M4 4v5h5',
|
|
32
|
+
restart: 'M4 12a8 8 0 1 0 2.3-5.6L4 9M4 4v5h5', x: 'M6 6l12 12M18 6L6 18', check: 'M5 12l5 5 9-10', send: 'M12 19V5M6 11l6-6 6 6',
|
|
33
|
+
keep: 'M6 4h12v16l-6-4-6 4z', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
|
|
34
|
+
attach: 'M20 11l-8.5 8.5a5 5 0 0 1-7-7L13 4a3.5 3.5 0 0 1 5 5l-8.5 8.5a2 2 0 0 1-3-3L14 7', star: 'M12 3l2.2 6.3H21l-5.4 4 2 6.4L12 15.8 6.4 19.7l2-6.4L3 9.3h6.8z',
|
|
35
|
+
};
|
|
36
|
+
const ib = (attr, label, icon, cls = '') => `<button type="button" class="pc-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16)}</button>`;
|
|
37
|
+
const store = { get: (k) => { try { return localStorage.getItem(k); } catch { return null; } }, set: (k, v) => { try { if (v == null) localStorage.removeItem(k); else localStorage.setItem(k, v); } catch { /* private window */ } } };
|
|
38
|
+
const human = (k) => String(k || '').replace(/[-_.]+/g, ' ').replace(/^./, (c) => c.toUpperCase());
|
|
39
|
+
/** A label in two lines of about n characters each (the second one cut with …), as SVG tspans. */
|
|
40
|
+
function lines(text, x, y, n, dy = 14) {
|
|
41
|
+
const w = String(text || '').split(/\s+/), out = ['', ''];
|
|
42
|
+
let i = 0;
|
|
43
|
+
for (const word of w) { if (i === 0 && out[0] && (out[0] + ' ' + word).length > n) i = 1; out[i] = out[i] ? out[i] + ' ' + word : word; }
|
|
44
|
+
if (out[1].length > n) out[1] = out[1].slice(0, n - 1).trimEnd() + '…';
|
|
45
|
+
if (out[0].length > n) out[0] = out[0].slice(0, n - 1) + '…';
|
|
46
|
+
return out.filter(Boolean).map((t, k) => `<tspan x="${x}" y="${y + k * dy}">${esc(t)}</tspan>`).join('');
|
|
47
|
+
}
|
|
48
|
+
const fire = (name, detail) => { try { window.dispatchEvent(new CustomEvent(name, { detail })); } catch { /* old browser */ } };
|
|
49
|
+
|
|
50
|
+
// the look, loaded once (cozy-proto.css)
|
|
51
|
+
if (typeof document !== 'undefined' && typeof document.createElement === 'function' && document.head && !document.querySelector('link[data-proto-css]')) {
|
|
52
|
+
const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./cozy-proto.css', import.meta.url).href; l.dataset.protoCss = '1'; document.head.appendChild(l);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* ── layout (PURE) ── */
|
|
56
|
+
const SW = 132, SH = 58, DD = 62, GX = 46, GY = 30, PAD = 16;
|
|
57
|
+
/** PURE. flow → { w, h, nodes: [{ id, kind, title, x, y, w, h, main }], edges: [{ from, to, label, d, lx, ly, main }] }. Columns by the
|
|
58
|
+
* shortest path from the first screen; a node off the main scenario is a branch (drawn dashed). */
|
|
59
|
+
export function flowLayout(flow) {
|
|
60
|
+
const f = flow || {}, nodes = [...(f.screens || []).map((s) => ({ ...s, kind: 'screen' })), ...(f.decisions || []).map((d) => ({ ...d, kind: 'decision' }))];
|
|
61
|
+
if (!nodes.length) return { w: 0, h: 0, nodes: [], edges: [] };
|
|
62
|
+
const by = new Map(nodes.map((n) => [n.id, n])), out = new Map(nodes.map((n) => [n.id, []]));
|
|
63
|
+
for (const e of f.edges || []) if (by.has(e.from) && by.has(e.to)) out.get(e.from).push(e);
|
|
64
|
+
const col = new Map(), q = [nodes[0].id]; col.set(nodes[0].id, 0);
|
|
65
|
+
while (q.length) { const u = q.shift(); for (const e of out.get(u)) if (!col.has(e.to)) { col.set(e.to, col.get(u) + 1); q.push(e.to); } }
|
|
66
|
+
let extra = Math.max(0, ...col.values()) + 1;
|
|
67
|
+
for (const n of nodes) if (!col.has(n.id)) col.set(n.id, extra++);
|
|
68
|
+
const main = new Set(((f.scenarios || [])[0] || { steps: [] }).steps.map((s) => s.screen));
|
|
69
|
+
const rows = new Map();
|
|
70
|
+
for (const n of nodes) { const c = col.get(n.id), r = rows.get(c) || 0; rows.set(c, r + 1); n.c = c; n.r = r; }
|
|
71
|
+
const cw = SW + GX, rh = SH + GY + 10;
|
|
72
|
+
for (const n of nodes) {
|
|
73
|
+
n.w = n.kind === 'decision' ? DD : SW; n.h = n.kind === 'decision' ? DD : SH;
|
|
74
|
+
n.x = PAD + n.c * cw + (SW - n.w) / 2; n.y = PAD + n.r * rh + (SH + 10 - n.h) / 2;
|
|
75
|
+
n.main = n.kind === 'decision' || main.size === 0 || main.has(n.id);
|
|
76
|
+
}
|
|
77
|
+
const edges = [];
|
|
78
|
+
for (const e of f.edges || []) {
|
|
79
|
+
const a = by.get(e.from), b = by.get(e.to); if (!a || !b) continue;
|
|
80
|
+
let d, lx, ly;
|
|
81
|
+
if (b.c > a.c) {
|
|
82
|
+
const x1 = a.x + a.w, y1 = a.y + a.h / 2, x2 = b.x, y2 = b.y + b.h / 2, mx = x1 + Math.min(GX / 2, (x2 - x1) / 2);
|
|
83
|
+
d = `M${x1} ${y1}H${mx}V${y2}H${x2 - 2}`; lx = x1 + 4; ly = y1 - 5;
|
|
84
|
+
if (y1 !== y2) { lx = mx + 4; ly = (y1 + y2) / 2; }
|
|
85
|
+
} else {
|
|
86
|
+
// back or same column: under both boxes
|
|
87
|
+
const x1 = a.x + a.w / 2, y1 = a.y + a.h, x2 = b.x + b.w / 2, y2 = b.y + b.h, by2 = Math.max(y1, y2) + 16;
|
|
88
|
+
d = `M${x1} ${y1}V${by2}H${x2}V${y2 + 2}`; lx = (x1 + x2) / 2; ly = by2 - 4;
|
|
89
|
+
}
|
|
90
|
+
edges.push({ from: e.from, to: e.to, label: e.label || '', d, lx, ly, main: a.main && b.main });
|
|
91
|
+
}
|
|
92
|
+
const w = Math.max(...nodes.map((n) => n.x + n.w)) + PAD, h = Math.max(...nodes.map((n) => n.y + n.h)) + PAD + 22;
|
|
93
|
+
return { w, h, nodes: nodes.map(({ id, kind, title, x, y, w: nw, h: nh, main: m }) => ({ id, kind, title, x, y, w: nw, h: nh, main: m })), edges };
|
|
94
|
+
}
|
|
95
|
+
const LW = 110, LH = 68, BW = 136, BH = 44, BG = 26;
|
|
96
|
+
/** PURE. lanes → { w, h, lanes: [{ id, name, y }], boxes: [{ n, title, screen, x, y, lane }], arrows: [{ d }] }: one column per step, in
|
|
97
|
+
* the order of n; an arrow from each step to the next. */
|
|
98
|
+
export function lanesLayout(lanes) {
|
|
99
|
+
const L = (lanes && lanes.lanes) || [];
|
|
100
|
+
const steps = [];
|
|
101
|
+
L.forEach((l, i) => { for (const s of l.steps || []) steps.push({ ...s, lane: i }); });
|
|
102
|
+
steps.sort((a, b) => a.n - b.n);
|
|
103
|
+
const boxes = steps.map((s, c) => ({ n: s.n, title: s.title, screen: s.screen || '', lane: s.lane, x: LW + 14 + c * (BW + BG), y: s.lane * LH + (LH - BH) / 2 }));
|
|
104
|
+
const arrows = [];
|
|
105
|
+
for (let i = 0; i + 1 < boxes.length; i += 1) {
|
|
106
|
+
const a = boxes[i], b = boxes[i + 1], x1 = a.x + BW, y1 = a.y + BH / 2, x2 = b.x, y2 = b.y + BH / 2, mx = x1 + BG / 2;
|
|
107
|
+
arrows.push({ d: a.lane === b.lane ? `M${x1} ${y1}H${x2 - 2}` : `M${x1} ${y1}H${mx}V${y2}H${x2 - 2}` });
|
|
108
|
+
}
|
|
109
|
+
return { w: LW + 14 + boxes.length * (BW + BG) + 6, h: L.length * LH, lanes: L.map((l, i) => ({ id: l.id, name: l.name, y: i * LH })), boxes, arrows };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* ── state ── */
|
|
113
|
+
const V = { body: null, c: null, at: null, H: null, last: null, mode: 'view', device: store.get('pmos.pc.device') || 'phone', zoom: Number(store.get('pmos.pc.zoom')) || 0,
|
|
114
|
+
sel: null, screen: '', frameUrl: '', ready: null, edits: { copy: {}, vars: {} }, pend: null, saveT: null, draft: null, drawing: false, strokes: 0,
|
|
115
|
+
play: null, sig: '' };
|
|
116
|
+
const ARROW = '<marker id="pcArr" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="currentColor"/></marker>';
|
|
117
|
+
const frameUrl = (c) => (c && c.url ? c.url + '&rt=1' : '');
|
|
118
|
+
const toFrame = (m, f) => { const fr = f || (V.body && V.body.querySelector('.pc-frame iframe')); if (fr && fr.contentWindow) fr.contentWindow.postMessage({ pmos: 1, ...m }, '*'); };
|
|
119
|
+
const say = (m, u) => { if (V.H && V.H.toast) V.H.toast(m, u); };
|
|
120
|
+
|
|
121
|
+
/** The version shown: the compare itself, or (while the next version is being made) the last one that rendered, with a note. */
|
|
122
|
+
function shown(c) {
|
|
123
|
+
if (c && c.file) return { v: c, making: c.working && !c.file };
|
|
124
|
+
if (V.last && c && V.last.ini === c.ini) return { v: V.last, making: true };
|
|
125
|
+
return { v: c, making: true };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* ── the parts ── */
|
|
129
|
+
function barHtml(c, v) {
|
|
130
|
+
const H = (c.history || []).filter((h) => h.round), N = H.length ? Math.max(...H.map((h) => h.round)) : 1;
|
|
131
|
+
const at = H.findIndex((h) => h.current), newest = H[0];
|
|
132
|
+
const older = at >= 0 && at + 1 < H.length ? H[at + 1] : null, newer = at > 0 ? H[at - 1] : null;
|
|
133
|
+
const old = at > 0 && newest;
|
|
134
|
+
const tool = (m, label, icon, key) => `<button type="button" class="pc-ib" data-pc-mode="${m}" aria-pressed="${V.mode === m}" aria-label="${esc(label + ' (' + key + ')')}" title="${esc(label + ' (' + key + ')')}">${SVG(icon, 16)}</button>`;
|
|
135
|
+
const dev = (d, label, icon) => `<button type="button" class="pc-ib" data-pc-dev="${d}" aria-pressed="${V.device === d}" aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16)}</button>`;
|
|
136
|
+
const ver = H.length > 1 ? `<span class="pc-ver">${ib(`data-lab-round="${esc(older ? older.id : '')}"${older ? '' : ' disabled'}`, 'Earlier version', I.prev)}<b>Version ${c.round} of ${N}</b>${ib(`data-lab-round="${esc(newer ? newer.id : '')}"${newer ? '' : ' disabled'}`, 'Later version', I.next)}`
|
|
137
|
+
+ (old ? ib(`data-lab-round="${esc(newest.id)}"`, 'Back to latest', I.latest) + ib(`data-pc-from="${c.round}"`, 'Continue from version ' + c.round, I.cont) : '') + '</span>'
|
|
138
|
+
: `<span class="pc-ver"><b>Version ${c.round || 1}</b></span>`;
|
|
139
|
+
const z = Math.round((V.zoom || 1) * 100);
|
|
140
|
+
return `<div class="pc-bar" role="toolbar" aria-label="Prototype tools"><span class="pc-grp">${tool('point', 'Point at an element', I.point, 'S')}${tool('comment', 'Comment', I.comment, 'C')}${tool('draw', 'Draw a sketch', I.draw, 'D')}</span>`
|
|
141
|
+
+ `<span class="pc-grp">${dev('phone', 'Phone', I.phone)}${dev('desktop', 'Desktop', I.desk)}</span>${ver}<span class="pc-sp"></span>`
|
|
142
|
+
+ `<span class="pc-grp">${ib('data-pc-zoom="-1"', 'Zoom out', I.minus)}<span class="pc-z" aria-live="polite">${z}%</span>${ib('data-pc-zoom="1"', 'Zoom in', I.plus)}${ib('data-pc-zoom="0"', 'Fit to the Viewer', I.fit)}</span>`
|
|
143
|
+
+ `${ib('data-pc-play', 'Play the prototype', I.play, 'blue')}</div>`;
|
|
144
|
+
}
|
|
145
|
+
function trayHtml(c) {
|
|
146
|
+
const cols = (c.columns || []).filter((x) => /^[A-C]$/.test(x.id));
|
|
147
|
+
if (cols.length < 2) return '';
|
|
148
|
+
return `<div class="pc-tray" role="group" aria-label="${cols.length} ways"><span class="pc-tl">${cols.length} ways · tap one to preview it</span>`
|
|
149
|
+
+ cols.map((x) => (x.file ? `<button type="button" class="pc-th" data-lab-key="${esc(x.id)}" aria-pressed="${x.id === c.key}" aria-label="${esc('Preview ' + x.title)}"><span class="pc-thf" aria-hidden="true"><iframe src="${esc(x.url)}" sandbox="allow-scripts" loading="lazy" tabindex="-1" title="${esc(x.title)}"></iframe></span><b>${esc(x.id)}</b></button>`
|
|
150
|
+
: `<span class="pc-th wk"><span class="pc-thf" aria-hidden="true"></span><b>${esc(x.id)}</b><small>${esc(x.left || '')}</small></span>`)).join('')
|
|
151
|
+
+ `<span class="pc-tacts">${c.state === 'open' && !c.working ? ib('data-pc-tray="keep"', 'Keep ' + c.key, I.check, 'blue') : ''}${ib('data-pc-tray="close"', 'Close these ways', I.x)}</span></div>`;
|
|
152
|
+
}
|
|
153
|
+
const upd = (c, k) => (c.updated && c.updated[k] ? '<span class="pc-upd">Updated</span>' : '');
|
|
154
|
+
function protoCard(c, v, making) {
|
|
155
|
+
const data = v.data || {}, tw = ((data.tweaks && data.tweaks.tweaks) || []).filter((t) => !t.el || (V.sel && t.el === V.sel.el));
|
|
156
|
+
const tweaks = tw.length ? `<div class="pc-tw" aria-label="Tweaks">${tw.map((t) => { const val = parseFloat(V.edits.vars[t.var]) || t.value; return `<label><span>${esc(t.label)}</span><input type="range" min="${t.min}" max="${t.max}" step="${t.step}" value="${val}" data-pc-var="${esc(t.var)}" data-pc-unit="${esc(t.unit)}"><em>${esc(val + t.unit)}</em></label>`; }).join('')}</div>` : '';
|
|
157
|
+
const sel = V.sel ? `<p class="pc-sel">${SVG(I.point, 14)}<b>${esc(V.sel.label || V.sel.el)}</b> is in the chat box: say the change.${ib('data-pc-unsel', 'Clear the element', I.x)}</p>` : '';
|
|
158
|
+
const cm = (c.comments || []).filter((x) => !x.send);
|
|
159
|
+
const draft = V.draft ? `<div class="pc-cdraft"><label for="pcCm">Comment${V.draft.label ? ' on ' + esc(V.draft.label) : ''}</label><textarea id="pcCm" rows="2" maxlength="500" placeholder="Say what should change"></textarea><span>${ib('data-pc-cm="send"', 'Send to PMOS as the next change', I.send, 'blue')}${ib('data-pc-cm="keep"', 'Keep for the team', I.keep)}${ib('data-pc-cm="x"', 'Cancel', I.x)}</span></div>` : '';
|
|
160
|
+
const list = cm.length ? `<ol class="pc-cms">${cm.map((x, i) => `<li><span class="pc-pin">${i + 1}</span><span class="w">${x.label ? `<small>on ${esc(x.label)}</small>` : ''}${esc(x.text)}</span>${ib(`data-pc-make="${esc(x.id)}"`, 'Make this change', I.star)}</li>`).join('')}</ol>` : '';
|
|
161
|
+
const sug = suggestion(c);
|
|
162
|
+
const draw = V.mode === 'draw' ? `<canvas class="pc-ink" aria-label="Sketch over the prototype"></canvas><span class="pc-inkacts">${ib('data-pc-ink="attach"', 'Attach the sketch to your next message', I.attach, 'blue')}${ib('data-pc-ink="clear"', 'Clear the sketch', I.x)}</span>` : '';
|
|
163
|
+
return `<section class="pc-card pc-proto" aria-label="The prototype">${making ? `<p class="pc-making"><i></i><i></i><i></i> PMOS is making version ${c.round}${c.working ? '' : ''}.</p>` : ''}`
|
|
164
|
+
+ `<div class="pc-dev ${V.device}"><div class="pc-frame" data-pc-frame>${v.url ? '' : '<p class="pc-none">PMOS is making it.</p>'}</div>${draw}</div>${sel}${tweaks}${draft}${list}${sug}</section>`;
|
|
165
|
+
}
|
|
166
|
+
function suggestion(c) {
|
|
167
|
+
// the design sprint runs silently: PMOS recommends good practice as ONE ✦ (canvas PbcChat), here: test it with people once it settles
|
|
168
|
+
const H = (c.history || []).filter((h) => h.round), N = H.length;
|
|
169
|
+
const root = H[H.length - 1], key = 'pmos.pc.sug.' + (root ? root.id : c.id);
|
|
170
|
+
if (N < 3 || c.working || store.get(key)) return '';
|
|
171
|
+
return `<div class="pc-sug"><span class="pc-star" aria-hidden="true">✦</span><p>Version ${c.round} answers the brief. Try it on 3 to 5 people it is for before more polish.</p>${ib(`data-pc-sug="link" data-pc-sugk="${esc(key)}"`, 'Get a test link', I.link, 'blue')}${ib(`data-pc-sug="no" data-pc-sugk="${esc(key)}"`, 'Not now', I.x)}</div>`;
|
|
172
|
+
}
|
|
173
|
+
function flowCard(c, v) {
|
|
174
|
+
const f = (v.data || {}).flow, st = (c.parts || {}).flow;
|
|
175
|
+
if (!f) return `<section class="pc-card pc-flowc" aria-label="The flow"><h3>The flow</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No flow for this version.')}</p></section>`;
|
|
176
|
+
const L = flowLayout(f), scen = f.scenarios || [];
|
|
177
|
+
const branchOf = (to) => { for (let i = 1; i < scen.length; i += 1) if (scen[i].steps.some((s) => s.screen === to)) return scen[i].id; return ''; };
|
|
178
|
+
const nodes = L.nodes.map((n) => n.kind === 'decision'
|
|
179
|
+
? `<g class="pc-dn"><path d="M${n.x + n.w / 2} ${n.y}L${n.x + n.w} ${n.y + n.h / 2}L${n.x + n.w / 2} ${n.y + n.h}L${n.x} ${n.y + n.h / 2}Z"/><text x="${n.x + n.w / 2}" y="${n.y + n.h / 2 + 4}" text-anchor="middle">${esc(n.title.slice(0, 12))}</text></g>`
|
|
180
|
+
: `<g class="pc-sn${n.main ? '' : ' br'}${V.screen === n.id ? ' on' : ''}" data-pc-screen="${esc(n.id)}" role="button" tabindex="0" aria-label="${esc('Show ' + n.title + ' on the prototype')}"><rect x="${n.x}" y="${n.y}" width="${n.w}" height="${n.h}" rx="8"/><text x="${n.x + 10}" y="${n.y + 15}" class="k">SCREEN</text><text>${lines(n.title, n.x + 10, n.y + 31, 21)}</text></g>`).join('');
|
|
181
|
+
const edges = L.edges.map((e) => { const sc = e.main ? '' : branchOf(e.to); return `<g class="pc-e${e.main ? '' : ' br'}"${sc ? ` data-pc-scen="${esc(sc)}" role="button" tabindex="0" aria-label="${esc('Play ' + (scen.find((x) => x.id === sc) || {}).name)}"` : ''}><path d="${e.d}" marker-end="url(#pcArr)"/>${sc ? `<path class="hit" d="${e.d}"/>` : ''}${e.label ? `<text x="${e.lx}" y="${e.ly}">${esc(e.label)}</text>` : ''}</g>`; }).join('');
|
|
182
|
+
const chips = scen.length ? `<div class="pc-scens">${scen.map((s, i) => `<button type="button" class="pc-chip" data-pc-scen="${esc(s.id)}" title="${esc(s.description || '')}">${SVG(I.play, 12)}${esc(i === 0 ? s.name : s.name)}</button>`).join('')}</div>` : '';
|
|
183
|
+
return `<section class="pc-card pc-flowc" aria-label="The flow"><h3>The flow ${upd(c, 'flow')}</h3><div class="pc-svgw"><svg class="pc-flow" width="100%" style="max-width:${L.w}px" viewBox="0 0 ${L.w} ${L.h}" preserveAspectRatio="xMinYMin meet"><defs>${ARROW}</defs>${edges}${nodes}</svg></div>`
|
|
184
|
+
+ `<p class="pc-hint">Tap a screen to see it on the prototype. Tap a side branch to play that scenario.</p>${chips}</section>`;
|
|
185
|
+
}
|
|
186
|
+
function copyCard(c, v) {
|
|
187
|
+
const copy = (v.data || {}).copy || {}, keys = Object.keys(copy);
|
|
188
|
+
if (!keys.length) return `<section class="pc-card pc-copyc" aria-label="Page copy"><h3>Page copy</h3><p class="pc-none">${esc(v.url ? 'This version has no editable copy.' : 'PMOS is writing it.')}</p></section>`;
|
|
189
|
+
const changed = new Set((c.updated && c.updated.keys) || []);
|
|
190
|
+
return `<section class="pc-card pc-copyc" aria-label="Page copy"><h3>Page copy ${upd(c, 'copy')}</h3><div class="pc-copy" role="table">${keys.map((k) => `<div class="pc-cr${changed.has(k) ? ' ch' : ''}" role="row"><span role="rowheader">${esc(human(k))}</span><span role="cell" contenteditable="plaintext-only" spellcheck="true" data-pc-copy="${esc(k)}" aria-label="${esc(human(k))}">${esc(k in V.edits.copy ? V.edits.copy[k] : copy[k])}</span></div>`).join('')}</div>`
|
|
191
|
+
+ '<p class="pc-hint">Edit any line: the prototype changes as you type, and the next version keeps it.</p></section>';
|
|
192
|
+
}
|
|
193
|
+
function lanesCard(c, v) {
|
|
194
|
+
const l = (v.data || {}).lanes, st = (c.parts || {}).lanes;
|
|
195
|
+
if (!l) return `<section class="pc-card pc-lanesc" aria-label="Who does what"><h3>Who does what</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No swimlane for this version.')}</p></section>`;
|
|
196
|
+
const L = lanesLayout(l), chg = new Set((c.updated && c.updated.steps) || []);
|
|
197
|
+
const lanes = L.lanes.map((x, i) => `<g class="pc-ln${i % 2 ? ' alt' : ''}"><rect x="0" y="${x.y}" width="${L.w}" height="${LH}"/><text x="12" y="${x.y + LH / 2 + 4}">${esc(x.name.slice(0, 14))}</text></g>`).join('');
|
|
198
|
+
const boxes = L.boxes.map((b) => `<g class="pc-bx${chg.has(b.n) ? ' ch' : ''}${b.screen ? '' : ' ns'}"${b.screen ? ` data-pc-screen="${esc(b.screen)}" role="button" tabindex="0" aria-label="${esc('Show step ' + b.n + ' on the prototype')}"` : ''}><rect x="${b.x}" y="${b.y}" width="${BW}" height="${BH}" rx="8"/><text text-anchor="middle">${lines(b.title, b.x + BW / 2, b.y + (b.title.length > 21 ? 17 : 24), 21, 12)}</text><circle cx="${b.x}" cy="${b.y}" r="9"/><text class="n" x="${b.x}" y="${b.y + 3.5}" text-anchor="middle">${b.n}</text></g>`).join('');
|
|
199
|
+
const arrows = L.arrows.map((a) => `<path class="pc-ar" d="${a.d}" marker-end="url(#pcArr)"/>`).join('');
|
|
200
|
+
return `<section class="pc-card pc-lanesc" aria-label="Who does what"><h3>Who does what ${upd(c, 'lanes')}</h3><div class="pc-svgw"><svg class="pc-lanes" width="100%" style="max-width:${L.w}px" viewBox="0 0 ${L.w} ${L.h}" preserveAspectRatio="xMinYMin meet"><defs>${ARROW}</defs>${lanes}${arrows}${boxes}</svg></div><p class="pc-hint">Tap a step to see it on the prototype.</p></section>`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* ── draw ── */
|
|
204
|
+
/** Draw or update the canvas. body: the Viewer's body; c: GET /api/lab/compare's compare (live); o: { at, H } */
|
|
205
|
+
export function draw(body, c, o = {}) {
|
|
206
|
+
if (!body || !c) return;
|
|
207
|
+
Object.assign(V, { at: o.at || V.at || {}, H: o.H || V.H });
|
|
208
|
+
if (c.file && c.data) V.last = c;
|
|
209
|
+
const { v, making } = shown(c), prevFile = V.v && V.v.file;
|
|
210
|
+
// a new version: its own edits, nothing pointed at
|
|
211
|
+
if (prevFile !== v.file) { V.edits = (v.data && v.data.edits) ? { copy: { ...v.data.edits.copy }, vars: { ...v.data.edits.vars } } : { copy: {}, vars: {} }; V.sel = null; V.ready = null; }
|
|
212
|
+
V.c = c; V.v = v;
|
|
213
|
+
let root = body.querySelector(':scope > .pc');
|
|
214
|
+
if (!root) { body.innerHTML = '<div class="pc"></div>'; root = body.querySelector('.pc'); wire(root); }
|
|
215
|
+
V.body = body;
|
|
216
|
+
// keep the frame (and what the PM typed) while the canvas reads again every 2 seconds
|
|
217
|
+
const sig = JSON.stringify([c.id, c.key, c.round, c.file, v.file, c.working, c.updated, c.parts, (c.comments || []).length, V.mode, V.device, V.sel && V.sel.el, !!V.draft, (c.history || []).length, c.state]);
|
|
218
|
+
const focus = document.activeElement && root.contains(document.activeElement) && document.activeElement.matches('[data-pc-copy],textarea,input');
|
|
219
|
+
if (sig === V.sig && root.firstChild) return;
|
|
220
|
+
if (focus && prevFile === v.file) return; // the PM is typing in this version: draw on a later read
|
|
221
|
+
V.sig = sig;
|
|
222
|
+
const frame = root.querySelector('.pc-frame iframe'), keepFrame = frame && V.frameUrl === frameUrl(v);
|
|
223
|
+
const draftText = root.querySelector('#pcCm') ? root.querySelector('#pcCm').value : '';
|
|
224
|
+
if (keepFrame) frame.remove();
|
|
225
|
+
root.innerHTML = barHtml(c, v) + trayHtml(c) + `<div class="pc-vp"><div class="pc-board">${protoCard(c, v, making)}<div class="pc-col">${flowCard(c, v)}${copyCard(c, v)}</div>${lanesCard(c, v)}</div></div>` + (V.play ? playHtml(v) : '');
|
|
226
|
+
const slot = root.querySelector('[data-pc-frame]');
|
|
227
|
+
if (slot && v.url) {
|
|
228
|
+
if (keepFrame) slot.appendChild(frame);
|
|
229
|
+
else { V.frameUrl = frameUrl(v); V.ready = null; slot.innerHTML = `<iframe src="${esc(V.frameUrl)}" sandbox="allow-scripts" title="${esc('The prototype, version ' + (v.round || 1))}"></iframe>`; }
|
|
230
|
+
}
|
|
231
|
+
if (draftText && root.querySelector('#pcCm')) root.querySelector('#pcCm').value = draftText;
|
|
232
|
+
applyZoom(root);
|
|
233
|
+
if (V.mode === 'draw') ink(root);
|
|
234
|
+
if (keepFrame) { toFrame({ t: 'mode', mode: V.play ? 'view' : V.mode === 'draw' ? 'view' : V.mode }); pins(); }
|
|
235
|
+
if (V.play) startPlay(V.play.id, V.play.i);
|
|
236
|
+
if (V.draft && root.querySelector('#pcCm')) root.querySelector('#pcCm').focus();
|
|
237
|
+
}
|
|
238
|
+
function applyZoom(root) {
|
|
239
|
+
const b = root.querySelector('.pc-board'), vp = root.querySelector('.pc-vp'); if (!b || !vp) return;
|
|
240
|
+
let z = V.zoom;
|
|
241
|
+
if (!z) { b.style.zoom = 1; z = Math.max(0.4, Math.min(1, (vp.clientWidth - 24) / Math.max(1, b.scrollWidth))); }
|
|
242
|
+
b.style.zoom = z;
|
|
243
|
+
const zl = root.querySelector('.pc-z'); if (zl) zl.textContent = Math.round(z * 100) + '%';
|
|
244
|
+
}
|
|
245
|
+
function pins() {
|
|
246
|
+
const cm = ((V.c && V.c.comments) || []).filter((x) => !x.send);
|
|
247
|
+
toFrame({ t: 'pins', pins: cm.map((x, i) => ({ n: i + 1, el: x.el, x: x.x, y: x.y })) });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* ── the frame talks back ── */
|
|
251
|
+
if (typeof window !== 'undefined') window.addEventListener('message', (e) => {
|
|
252
|
+
const m = e.data; if (!m || m.pmos !== 1 || !V.body) return;
|
|
253
|
+
const fr = V.body.querySelector('.pc-frame iframe'), pf = V.body.querySelector('.pc-pframe iframe');
|
|
254
|
+
if (pf && e.source === pf.contentWindow) return playMsg(m, pf);
|
|
255
|
+
if (!fr || e.source !== fr.contentWindow) return;
|
|
256
|
+
if (m.t === 'ready') {
|
|
257
|
+
V.ready = m;
|
|
258
|
+
if (Object.keys(V.edits.copy).length) toFrame({ t: 'copyAll', copy: V.edits.copy });
|
|
259
|
+
if (Object.keys(V.edits.vars).length) toFrame({ t: 'vars', vars: V.edits.vars });
|
|
260
|
+
toFrame({ t: 'mode', mode: V.mode === 'draw' ? 'view' : V.mode });
|
|
261
|
+
if (V.screen) toFrame({ t: 'screen', id: V.screen });
|
|
262
|
+
if (V.sel) toFrame({ t: 'sel', el: V.sel.el });
|
|
263
|
+
pins();
|
|
264
|
+
} else if (m.t === 'screen') {
|
|
265
|
+
V.screen = String(m.id || '');
|
|
266
|
+
V.body.querySelectorAll('.pc-sn').forEach((g) => g.classList.toggle('on', g.dataset.pcScreen === V.screen));
|
|
267
|
+
} else if (m.t === 'point') {
|
|
268
|
+
// Point, then say (canvas PbcPoint): the element becomes a chip in the chat box, with Tweaks for it here
|
|
269
|
+
V.sel = { el: String(m.el || ''), label: String(m.label || '').slice(0, 80) };
|
|
270
|
+
fire('pmos:point', { ini: V.c && V.c.ini, ...V.sel });
|
|
271
|
+
V.sig = ''; draw(V.body, V.c);
|
|
272
|
+
} else if (m.t === 'pin') {
|
|
273
|
+
V.draft = { el: String(m.el || ''), label: String(m.label || '').slice(0, 80), x: m.x, y: m.y };
|
|
274
|
+
V.sig = ''; draw(V.body, V.c);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
/* ── presses ── */
|
|
279
|
+
function wire(root) {
|
|
280
|
+
root.addEventListener('click', (e) => {
|
|
281
|
+
const b = e.target.closest('button, [data-pc-screen], [data-pc-scen]'); if (!b || !root.contains(b)) return;
|
|
282
|
+
const d = b.dataset;
|
|
283
|
+
if (d.pcMode) { setMode(V.mode === d.pcMode ? 'view' : d.pcMode); return; }
|
|
284
|
+
if (d.pcDev) { V.device = d.pcDev; store.set('pmos.pc.device', V.device); V.sig = ''; draw(V.body, V.c); return; }
|
|
285
|
+
if (d.pcZoom != null) { const k = Number(d.pcZoom); V.zoom = k === 0 ? 0 : Math.max(0.4, Math.min(1.6, Math.round(((V.zoom || currentZoom()) + k * 0.1) * 10) / 10)); store.set('pmos.pc.zoom', V.zoom ? String(V.zoom) : null); applyZoom(root); return; }
|
|
286
|
+
if ('pcPlay' in d) { const sc = ((V.v.data || {}).flow || {}).scenarios || []; startPlay(sc.length ? sc[0].id : '', 0, true); return; }
|
|
287
|
+
if (d.pcFrom) { fire('pmos:from', { ini: V.c.ini, n: Number(d.pcFrom) }); say('The next change you send continues from version ' + d.pcFrom + '.'); return; }
|
|
288
|
+
if (d.pcScreen) { V.screen = d.pcScreen; toFrame({ t: 'screen', id: d.pcScreen }); return; }
|
|
289
|
+
if (d.pcScen) { startPlay(d.pcScen, 0, true); return; }
|
|
290
|
+
if ('pcUnsel' in d) { V.sel = null; toFrame({ t: 'sel', el: '' }); fire('pmos:point', { ini: V.c.ini, el: '', label: '' }); V.sig = ''; draw(V.body, V.c); return; }
|
|
291
|
+
if (d.pcCm) { comment(d.pcCm); return; }
|
|
292
|
+
if (d.pcMake) { const x = (V.c.comments || []).find((y) => y.id === d.pcMake); if (x) fire('pmos:say', { ini: V.c.ini, text: (x.label || x.el ? `[On: ${x.label || x.el}${x.el ? ' · ' + x.el : ''}] ` : '') + x.text }); return; }
|
|
293
|
+
if (d.pcSug) { if (d.pcSug === 'link') testLink(); store.set(d.pcSugk, '1'); V.sig = ''; draw(V.body, V.c); return; }
|
|
294
|
+
if (d.pcInk) { if (d.pcInk === 'clear') clearInk(); else attachInk(); return; }
|
|
295
|
+
if (d.pcTray) { tray(d.pcTray); return; }
|
|
296
|
+
if (d.pcPlayx) { if (d.pcPlayx === 'close') { V.play = null; const p = root.querySelector('.pc-play'); if (p) p.remove(); } else startPlay(V.play.id, 0); return; }
|
|
297
|
+
if (d.pcPlaysc) { startPlay(d.pcPlaysc, 0, true); }
|
|
298
|
+
});
|
|
299
|
+
root.addEventListener('keydown', (e) => { if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('[data-pc-screen],[data-pc-scen]') && e.target.tagName !== 'BUTTON') { e.preventDefault(); e.target.dispatchEvent(new MouseEvent('click', { bubbles: true })); } });
|
|
300
|
+
root.addEventListener('input', (e) => {
|
|
301
|
+
const t = e.target;
|
|
302
|
+
if (t.matches('[data-pc-copy]')) { const k = t.dataset.pcCopy, text = t.textContent; V.edits.copy[k] = text; toFrame({ t: 'copy', key: k, text }); save({ copy: { [k]: text } }); }
|
|
303
|
+
else if (t.matches('[data-pc-var]')) { const val = t.value + (t.dataset.pcUnit || ''); V.edits.vars[t.dataset.pcVar] = val; toFrame({ t: 'vars', vars: { [t.dataset.pcVar]: val } }); const em = t.parentElement.querySelector('em'); if (em) em.textContent = val; save({ vars: { [t.dataset.pcVar]: val } }); }
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
const currentZoom = () => { const b = V.body && V.body.querySelector('.pc-board'); return (b && Number(b.style.zoom)) || 1; };
|
|
307
|
+
function setMode(m) {
|
|
308
|
+
V.mode = m; if (m !== 'comment') V.draft = null;
|
|
309
|
+
toFrame({ t: 'mode', mode: m === 'draw' ? 'view' : m });
|
|
310
|
+
V.sig = ''; draw(V.body, V.c);
|
|
311
|
+
}
|
|
312
|
+
// the PM's copy edits and tweaks are kept with the version (edits.json), so the next version reads them
|
|
313
|
+
function save(part) {
|
|
314
|
+
V.pend = { copy: { ...((V.pend && V.pend.copy) || {}), ...(part.copy || {}) }, vars: { ...((V.pend && V.pend.vars) || {}), ...(part.vars || {}) } };
|
|
315
|
+
clearTimeout(V.saveT);
|
|
316
|
+
const file = V.v && V.v.file;
|
|
317
|
+
V.saveT = setTimeout(async () => {
|
|
318
|
+
const body = V.pend; V.pend = null; if (!file) return;
|
|
319
|
+
const r = await pmPost('/api/lab/edit', { ws: (V.at || {}).ws, file, ...body }).catch(() => null);
|
|
320
|
+
if (!r || r.ok === false) say((r && r.error) || 'The edit was not saved.');
|
|
321
|
+
}, 700);
|
|
322
|
+
}
|
|
323
|
+
async function comment(how) {
|
|
324
|
+
const ta = V.body.querySelector('#pcCm'), text = ta ? ta.value.trim() : '', dft = V.draft;
|
|
325
|
+
if (how === 'x' || !dft) { V.draft = null; V.sig = ''; draw(V.body, V.c); return; }
|
|
326
|
+
if (!text) { say('Say what should change first.'); return; }
|
|
327
|
+
const r = await pmPost('/api/lab/comment', { ws: (V.at || {}).ws, ini: V.c.ini, file: V.v.file, el: dft.el, label: dft.label, x: dft.x, y: dft.y, text, send: how === 'send' }).catch(() => null);
|
|
328
|
+
if (!r || r.ok === false) { say((r && r.error) || 'The comment was not saved.'); return; }
|
|
329
|
+
V.draft = null;
|
|
330
|
+
// Send to PMOS: the comment is the next change, said in the chat about that element
|
|
331
|
+
if (how === 'send') fire('pmos:say', { ini: V.c.ini, text: (dft.label || dft.el ? `[On: ${dft.label || dft.el}${dft.el ? ' · ' + dft.el : ''}] ` : '') + text });
|
|
332
|
+
else say('Kept for the team.');
|
|
333
|
+
V.c.comments = [...(V.c.comments || []), { id: r.id, el: dft.el, label: dft.label, text, x: dft.x, y: dft.y, send: how === 'send' }];
|
|
334
|
+
V.sig = ''; draw(V.body, V.c);
|
|
335
|
+
}
|
|
336
|
+
async function testLink() {
|
|
337
|
+
const at = V.at || {}, url = location.origin + '/pm/present?ws=' + encodeURIComponent(at.ws || '') + '&board=' + encodeURIComponent(at.board || V.c.board || '') + '&id=' + encodeURIComponent(V.c.id);
|
|
338
|
+
try { await navigator.clipboard.writeText(url); say('The test link is copied. It opens the prototype on a clean screen.'); } catch { say('Test link: ' + url); }
|
|
339
|
+
}
|
|
340
|
+
async function tray(a) {
|
|
341
|
+
const at = V.at || {}, c = V.c;
|
|
342
|
+
if (a === 'keep') {
|
|
343
|
+
const r = await pmPost('/api/proposals/keep', { ws: at.ws, board: at.board || c.board, initiative: c.ini, ids: [c.id], choices: { [c.id]: c.key } }).catch(() => null);
|
|
344
|
+
say(r && r.ok !== false ? (r.said || 'Kept ' + c.key + '.') : (r && r.error) || 'Nothing was kept.');
|
|
345
|
+
} else {
|
|
346
|
+
const r = await pmPost('/api/proposals/drop', { ws: at.ws, board: at.board || c.board, initiative: c.ini, sig: c.sig }).catch(() => null);
|
|
347
|
+
say(r && r.ok !== false ? 'Closed these ways.' : (r && r.error) || 'Nothing was changed.');
|
|
348
|
+
}
|
|
349
|
+
if (V.H && V.H.reload) V.H.reload();
|
|
350
|
+
if (V.H && V.H.load) V.H.load();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/* ── Draw: a sketch goes with the next message as the reference ── */
|
|
354
|
+
function ink(root) {
|
|
355
|
+
const cv = root.querySelector('.pc-ink'); if (!cv) return;
|
|
356
|
+
const box = cv.parentElement.getBoundingClientRect(), z = currentZoom();
|
|
357
|
+
cv.width = Math.round(box.width / z); cv.height = Math.round(box.height / z);
|
|
358
|
+
const g = cv.getContext('2d'); g.lineWidth = 3; g.lineCap = 'round'; g.lineJoin = 'round'; g.strokeStyle = getComputedStyle(cv).getPropertyValue('--cz-red').trim() || 'red';
|
|
359
|
+
let on = false;
|
|
360
|
+
const pt = (e) => { const r = cv.getBoundingClientRect(); return [(e.clientX - r.left) * cv.width / r.width, (e.clientY - r.top) * cv.height / r.height]; };
|
|
361
|
+
cv.onpointerdown = (e) => { on = true; cv.setPointerCapture(e.pointerId); const [x, y] = pt(e); g.beginPath(); g.moveTo(x, y); };
|
|
362
|
+
cv.onpointermove = (e) => { if (!on) return; const [x, y] = pt(e); g.lineTo(x, y); g.stroke(); V.strokes += 1; };
|
|
363
|
+
cv.onpointerup = () => { on = false; };
|
|
364
|
+
}
|
|
365
|
+
function clearInk() { const cv = V.body.querySelector('.pc-ink'); if (cv) cv.getContext('2d').clearRect(0, 0, cv.width, cv.height); V.strokes = 0; }
|
|
366
|
+
async function attachInk() {
|
|
367
|
+
const cv = V.body.querySelector('.pc-ink'); if (!cv || !V.strokes) { say('Draw on the prototype first.'); return; }
|
|
368
|
+
const out = document.createElement('canvas'); out.width = cv.width; out.height = cv.height;
|
|
369
|
+
const g = out.getContext('2d'); g.fillStyle = getComputedStyle(cv).getPropertyValue('--cz-onsolid').trim() || 'white'; g.fillRect(0, 0, out.width, out.height); g.drawImage(cv, 0, 0);
|
|
370
|
+
const blob = await new Promise((r) => out.toBlob(r, 'image/png'));
|
|
371
|
+
const name = 'sketch-' + Date.now().toString(36) + '.png';
|
|
372
|
+
const res = await fetch('/api/chat-file?key=' + encodeURIComponent('init:' + V.c.ini) + '&name=' + encodeURIComponent(name), { method: 'POST', credentials: 'same-origin', headers: { ...pmHeaders(), 'Content-Type': 'application/octet-stream' }, body: blob }).then((x) => x.json()).catch(() => null);
|
|
373
|
+
if (!res || !res.ok) { say((res && res.error) || 'The sketch was not attached.'); return; }
|
|
374
|
+
const M = await import('./premium-attach.js');
|
|
375
|
+
M.attachSaved({ name, size: blob.size, saved: res.name, path: res.path });
|
|
376
|
+
say('The sketch goes with your next message as the reference.');
|
|
377
|
+
clearInk(); setMode('view');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/* ── Play (canvas PbcPlay) ── */
|
|
381
|
+
function playHtml(v) {
|
|
382
|
+
const sc = ((v.data || {}).flow || {}).scenarios || [], p = V.play, s = sc.find((x) => x.id === p.id), step = s ? s.steps[Math.min(p.i, s.steps.length - 1)] : null;
|
|
383
|
+
const done = s && p.i >= s.steps.length - 1;
|
|
384
|
+
return `<div class="pc-play" role="dialog" aria-label="Play the prototype"><div class="pc-pbar">${sc.map((x) => `<button type="button" class="pc-chip" data-pc-playsc="${esc(x.id)}" aria-pressed="${x.id === p.id}">${esc(x.name)}</button>`).join('')}<span class="pc-sp"></span>`
|
|
385
|
+
+ `${ib('data-pc-playx="restart"', 'Restart', I.restart)}${ib('data-pc-playx="close"', 'Close Play', I.x)}</div>`
|
|
386
|
+
+ `<p class="pc-pstep">${s ? (done ? `<b>Done:</b> ${esc(s.name)}. ${esc(step && step.say ? step.say : '')}` : `<b>Step ${p.i + 1} of ${s.steps.length}</b> ${esc(step && step.say ? step.say : 'Tap where the user would tap.')}`) : 'This version has no scenarios yet. Ask for one in the chat.'}</p>`
|
|
387
|
+
+ `<div class="pc-pframe ${V.device}">${v.url ? `<iframe src="${esc(frameUrl(v))}" sandbox="allow-scripts" title="Play the prototype"></iframe>` : ''}</div></div>`;
|
|
388
|
+
}
|
|
389
|
+
function startPlay(id, i = 0, fresh = false) {
|
|
390
|
+
const root = V.body && V.body.querySelector('.pc'); if (!root) return;
|
|
391
|
+
const keep = !fresh && V.play && V.play.id === id ? root.querySelector('.pc-pframe iframe') : null;
|
|
392
|
+
V.play = { id, i };
|
|
393
|
+
const old = root.querySelector('.pc-play'); if (old) { if (keep) keep.remove(); old.remove(); }
|
|
394
|
+
root.insertAdjacentHTML('beforeend', playHtml(V.v));
|
|
395
|
+
if (keep) { const slot = root.querySelector('.pc-pframe'); slot.innerHTML = ''; slot.appendChild(keep); playGo(keep); }
|
|
396
|
+
}
|
|
397
|
+
function playGo(fr) {
|
|
398
|
+
const sc = ((V.v.data || {}).flow || {}).scenarios || [], s = sc.find((x) => x.id === (V.play || {}).id);
|
|
399
|
+
toFrame({ t: 'mode', mode: 'play' }, fr);
|
|
400
|
+
if (s) toFrame({ t: 'screen', id: s.steps[Math.min(V.play.i, s.steps.length - 1)].screen }, fr);
|
|
401
|
+
if (Object.keys(V.edits.copy).length) toFrame({ t: 'copyAll', copy: V.edits.copy }, fr);
|
|
402
|
+
if (Object.keys(V.edits.vars).length) toFrame({ t: 'vars', vars: V.edits.vars }, fr);
|
|
403
|
+
}
|
|
404
|
+
function playMsg(m, fr) {
|
|
405
|
+
if (!V.play) return;
|
|
406
|
+
if (m.t === 'ready') { playGo(fr); return; }
|
|
407
|
+
if (m.t !== 'tap') return;
|
|
408
|
+
const sc = ((V.v.data || {}).flow || {}).scenarios || [], s = sc.find((x) => x.id === V.play.id); if (!s) return;
|
|
409
|
+
const step = s.steps[V.play.i]; if (!step || V.play.i >= s.steps.length - 1) return;
|
|
410
|
+
const next = s.steps[V.play.i + 1];
|
|
411
|
+
// a tap on the hotspot this step needs moves on; a tap that goes to the next screen counts too; a miss shows the hotspots
|
|
412
|
+
if ((step.tap && m.el === step.tap) || (!step.tap && m.go === next.screen) || (m.go && m.go === next.screen)) { V.play.i += 1; startPlay(V.play.id, V.play.i); }
|
|
413
|
+
else toFrame({ t: 'hint', els: step.tap ? [step.tap] : [] }, fr);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/* ── the chat's Version n tag ── */
|
|
417
|
+
/** Show version n of the initiative's newest round (pm/home-chat.js, a tap on a Version n tag). */
|
|
418
|
+
export async function openVersion({ ws, board = '', ini, n }) {
|
|
419
|
+
const r = await pmGet('/api/lab/rounds?ws=' + encodeURIComponent(ws || '') + '&initiative=' + encodeURIComponent(ini)).catch(() => null);
|
|
420
|
+
const root = r && r.ok && (r.rounds || [])[0]; if (!root) { say('That version is no longer here.'); return; }
|
|
421
|
+
const c = await pmGet('/api/lab/compare?ws=' + encodeURIComponent(ws || '') + '&board=' + encodeURIComponent(board) + '&id=' + encodeURIComponent(root.id)).catch(() => null);
|
|
422
|
+
const h = c && c.ok ? (c.compare.history || []).find((x) => x.round === Number(n)) : null;
|
|
423
|
+
const LC = await import('./cozy-lab.js');
|
|
424
|
+
LC.openCompare({ where: { ws, board }, id: h ? h.id : root.id, H: V.H });
|
|
425
|
+
}
|
|
426
|
+
if (typeof window !== 'undefined') {
|
|
427
|
+
window.addEventListener('keydown', (e) => {
|
|
428
|
+
if (!V.body || !V.body.isConnected || !V.body.querySelector('.pc') || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
429
|
+
const t = e.target; if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;
|
|
430
|
+
const k = e.key.toLowerCase();
|
|
431
|
+
if (k === 's') setMode(V.mode === 'point' ? 'view' : 'point');
|
|
432
|
+
else if (k === 'c') setMode(V.mode === 'comment' ? 'view' : 'comment');
|
|
433
|
+
else if (k === 'd') setMode(V.mode === 'draw' ? 'view' : 'draw');
|
|
434
|
+
else if (k === 'escape' && (V.mode !== 'view' || V.play)) { if (V.play) { V.play = null; const p = V.body.querySelector('.pc-play'); if (p) p.remove(); } else setMode('view'); }
|
|
435
|
+
});
|
|
436
|
+
}
|
|
@@ -1142,6 +1142,8 @@ function iniTarget(id) {
|
|
|
1142
1142
|
const h = S.H || {};
|
|
1143
1143
|
return { key: 'init:' + id, ini: id, ws: (otherIni(id) || {}).ws || WS || undefined, title: iniTitle(id), about: iniTitle(id), newChat: () => newIn(id), sub: (S.IMid === id && h.stage) || '', scope: scopeOf(id), rich: true, placeholder: 'Message PMOS about ' + iniTitle(id),
|
|
1144
1144
|
empty: 'Ask about ' + iniTitle(id) + '. PMOS reads its records and works in a real Claude Code session.', also: alsoOf(id),
|
|
1145
|
+
// a prototype the sentence started (lib/routes-briefing-premium.js liveAsk): the Viewer opens it beside the chat, and shows it as it renders
|
|
1146
|
+
onSent: (r) => { if (r && r.live && r.live.id) import('./cozy-lab.js').then((LC) => LC.openCompare({ where: { ws: r.live.ws || WS, board: r.live.board || '' }, id: r.live.id, H: { toast } })).catch(() => {}); },
|
|
1145
1147
|
// the initiative's conversation opens on where it stands (AgInitYou), until it has messages of its own
|
|
1146
1148
|
intro: S.IMid === id && h.cur ? { role: CLAUDE, onlyEmpty: true, text: h.cur + '. ' + h.doneOf + '.' + (h.rest.length ? ' Waiting: ' + h.rest.map((x) => x.label).join(', ') + '.' : ''), pills: [{ label: h.cta, primary: true, go: () => cta() }, { label: 'Discuss', go: () => chat.focus() }] } : undefined, context: h.payoff ? 'Initiative ' + id + ': ' + (h.stage || '') + '. ' + (h.time || '') : undefined };
|
|
1147
1149
|
}
|
|
@@ -50,6 +50,22 @@ const PANE = '<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24"
|
|
|
50
50
|
const INTERRUPT = /^\[Request interrupted by user/;
|
|
51
51
|
const POLL = 2000, IDLE_POLL = 9000;
|
|
52
52
|
|
|
53
|
+
/* Prototype by chatting (pm/cozy-proto.js): the element the PM pointed at and "Continue from version n" go before the words as marks
|
|
54
|
+
* ("[On: Screen list · screen-list]", "[From version 2]", lib/live-round.js marksOf); a bubble shows them as chips. A reply that starts
|
|
55
|
+
* "Version n:" shows a Version n tag; a tap shows that version in the Viewer. */
|
|
56
|
+
const MARK_RE = /^\s*\[(On: ([^\]·]{1,80}?)(?: · [A-Za-z0-9_-]{1,60})?|From version (\d{1,3}))\]\s*/;
|
|
57
|
+
const PT = 'M5 3l14 7-6 2-2 6z';
|
|
58
|
+
function marksHtml(text) {
|
|
59
|
+
let t = String(text || ''), chips = '', m;
|
|
60
|
+
while ((m = MARK_RE.exec(t))) { chips += `<span class="hm-mark">${m[2] ? SVG(PT, 12) + esc(m[2]) : 'From version ' + esc(m[3])}</span>`; t = t.slice(m[0].length); }
|
|
61
|
+
return (chips ? `<span class="hm-marks">${chips}</span>` : '') + (t ? userHtml(t) : '');
|
|
62
|
+
}
|
|
63
|
+
const VER_RE = /^\s*\**Version (\d{1,3})\**\s*[:·—-]\s*/;
|
|
64
|
+
function verHtml(text) {
|
|
65
|
+
const m = VER_RE.exec(text);
|
|
66
|
+
return m ? `<button type="button" class="hm-ver" data-hm-ver="${m[1]}" aria-label="Show version ${m[1]} in the Viewer">Version ${m[1]}</button>${mdHtml(text.slice(m[0].length))}` : mdHtml(text);
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
export function avHtml(role, size = 28, cls = '') {
|
|
54
70
|
const k = (role && role.initial) || 'P';
|
|
55
71
|
return `<span class="hm-av t-${tintOf(k)} s${size}${k.length > 1 ? ' two' : ''}${cls ? ' ' + cls : ''}" aria-hidden="true">${k}</span>`;
|
|
@@ -136,7 +152,7 @@ export function mountChat(el, host) {
|
|
|
136
152
|
if (it.t === 'user') {
|
|
137
153
|
if (INTERRUPT.test(it.text)) return '<p class="hm-stopped">Stopped</p>';
|
|
138
154
|
const a = splitFiles(shownUser(it.text));
|
|
139
|
-
return `<div class="hm-u"><div class="hm-bub">${filesHtml(a.files)}${a.text ?
|
|
155
|
+
return `<div class="hm-u"><div class="hm-bub">${filesHtml(a.files)}${a.text ? marksHtml(a.text) : ''}</div>${it.at ? `<span class="hm-you">You · ${esc(hm(it.at))}</span>` : ''}</div>`;
|
|
140
156
|
}
|
|
141
157
|
if (it.t === 'worked') {
|
|
142
158
|
const id = 'w' + i, on = C.open.has(id);
|
|
@@ -154,7 +170,7 @@ export function mountChat(el, host) {
|
|
|
154
170
|
// a run that stopped: the divider sits where it finished, over Claude's last message, and the fix sits under it (canvas XcbOptions, Routine)
|
|
155
171
|
const stopAt = R.stop && i === R.lastAgent;
|
|
156
172
|
const av = last && isClaude(R.role) ? adlerAvHtml(asking || ak.block ? 'needs-you' : stopAt ? 'honest' : running() ? 'thinking' : 'handled') : avHtml(R.role);
|
|
157
|
-
return (stopAt ? dividerHtml({ tone: R.stop.tone, text: R.stop.text }) : '') + `<div class="hm-a${asking ? ' ask' : ''}">${av}<div class="hm-ab"><p class="hm-who">${esc(R.role.name)} <span>${esc(hm(it.at))}</span></p>${rp.text ?
|
|
173
|
+
return (stopAt ? dividerHtml({ tone: R.stop.tone, text: R.stop.text }) : '') + `<div class="hm-a${asking ? ' ask' : ''}">${av}<div class="hm-ab"><p class="hm-who">${esc(R.role.name)} <span>${esc(hm(it.at))}</span></p>${rp.text ? verHtml(rp.text) : ''}${srcHtml(sr.src)}${goalBlockHtml(go.block, go)}${reportChipHtml(rp.block, it.mi)}${R.chips(it.mi)}`
|
|
158
174
|
+ (asking ? '' : `<div class="hm-tools" role="group" aria-label="Message actions"><button type="button" data-hm-copy="${i}">Copy</button>${last && !running() && !(stopAt && R.stop.actions.length) ? `<button type="button" data-hm-retry>Retry</button>` : ''}<button type="button" data-hm-wi="${i}">Make a work-item</button></div>`) + '</div></div>'
|
|
159
175
|
+ (stopAt && R.stop.actions.length ? `<div class="hm-fix" role="group" aria-label="What to do next">${R.stop.actions.map((a, k) => iconBtn({ icon: a.icon, label: a.label, attr: a.data, pri: k === 0 })).join('')}</div>` : '')
|
|
160
176
|
+ blockAskHtml(ak.block, it, R);
|
|
@@ -228,7 +244,7 @@ export function mountChat(el, host) {
|
|
|
228
244
|
}
|
|
229
245
|
function pendHtml() {
|
|
230
246
|
settlePend();
|
|
231
|
-
return C.pend.map((p) => `<div class="hm-u hm-pend${p.sent ? '' : ' sending'}"><div class="hm-bub">${filesHtml(p.files)}${p.text ?
|
|
247
|
+
return C.pend.map((p) => `<div class="hm-u hm-pend${p.sent ? '' : ' sending'}"><div class="hm-bub">${filesHtml(p.files)}${p.text ? marksHtml(p.text) : ''}</div>`
|
|
232
248
|
+ `<span class="hm-you" role="status">${p.sent ? 'You · ' + esc(hm(p.at)) : 'Sending…'}</span></div>`).join('');
|
|
233
249
|
}
|
|
234
250
|
// A loose chat that reads like one initiative gets one quiet chip at its top: "Looks like <initiative> · Link it ×" (XvALinkSuggest).
|
|
@@ -457,7 +473,7 @@ export function mountChat(el, host) {
|
|
|
457
473
|
+ `<div class="hm-tb">${add}`
|
|
458
474
|
+ to + wait + scope + `<span class="sp"></span>${host.viewerClosed() ? '<span class="hm-key">Enter sends · Shift+Enter for a new line</span>' : ''}`
|
|
459
475
|
+ `${NPU.undoHtml()}${mic}<button type="submit" class="hm-send" aria-label="Send" title="Send">${SVG(UP, 18)}</button></div>`
|
|
460
|
-
+ filesRow()
|
|
476
|
+
+ marksRow() + filesRow()
|
|
461
477
|
+ '</form>';
|
|
462
478
|
if (foot.__h !== html) {
|
|
463
479
|
const focused = document.activeElement && document.activeElement.id === 'hmIn';
|
|
@@ -470,6 +486,12 @@ export function mountChat(el, host) {
|
|
|
470
486
|
const filesRow = () => (C.files.length ? `<div class="hm-files" id="hmFiles">${C.files.map((f, i) => `<span class="hm-att${f.state === 'saving' ? ' saving' : ''}">`
|
|
471
487
|
+ (f.url ? `<img class="hm-ath" src="${esc(f.url)}" alt="">` : '') + `<b>${esc(f.name)}</b><em>${f.state === 'saving' ? 'Saving…' : f.note ? 'Note' : esc(sizeText(f.size || 0))}</em>`
|
|
472
488
|
+ `<button type="button" data-hm-unfile="${i}" aria-label="Remove ${esc(f.name)}">×</button></span>`).join('')}</div>` : '');
|
|
489
|
+
const marksRow = () => {
|
|
490
|
+
const k = C.mark || {}, x = (w, label) => `<button type="button" data-hm-unmark="${w}" aria-label="Remove ${esc(label)}">×</button>`;
|
|
491
|
+
const a = k.point ? `<span class="hm-att hm-markc">${SVG(PT, 12)}<b>${esc(k.point.label || k.point.el)}</b>${x('point', k.point.label || k.point.el)}</span>` : '';
|
|
492
|
+
const b = k.from ? `<span class="hm-att hm-markc"><b>From version ${esc(k.from)}</b>${x('from', 'from version ' + k.from)}</span>` : '';
|
|
493
|
+
return a || b ? `<div class="hm-files hm-marksr">${a}${b}</div>` : '';
|
|
494
|
+
};
|
|
473
495
|
const grow = (ta) => { ta.rows = 1; while (ta.rows < 9 && ta.scrollHeight > ta.clientHeight + 1) ta.rows += 1; }; // the box grows with its text, up to 9 lines (rows, not geometry)
|
|
474
496
|
|
|
475
497
|
/* ── writing ── */
|
|
@@ -477,6 +499,10 @@ export function mountChat(el, host) {
|
|
|
477
499
|
const t = C.t; text = String(text || '').trim();
|
|
478
500
|
if (!t || (!text && !C.files.length) || C.sending) return false;
|
|
479
501
|
if (t.key && C.files.some((f) => f.state === 'saving')) { host.toast('A file is still being saved. Send again in a moment.'); return false; }
|
|
502
|
+
// the canvas's marks go before the words (lib/live-round.js marksOf reads them), then they are used up
|
|
503
|
+
const mk = C.mark || {};
|
|
504
|
+
if (text && (mk.point || mk.from)) text = (mk.from ? `[From version ${mk.from}] ` : '') + (mk.point ? `[On: ${String(mk.point.label || mk.point.el).replace(/[\]·]/g, ' ').trim()}${mk.point.el ? ' · ' + mk.point.el : ''}] ` : '') + text;
|
|
505
|
+
if (text) C.mark = null;
|
|
480
506
|
C.sending = true;
|
|
481
507
|
let r;
|
|
482
508
|
const was = running();
|
|
@@ -549,6 +575,8 @@ export function mountChat(el, host) {
|
|
|
549
575
|
const ic = b.closest('.hm-icard'), card = C.t && C.t.intro && C.t.intro.card;
|
|
550
576
|
if (ic && card && card.press) { if (await card.press(b)) draw(); return; }
|
|
551
577
|
if ('hmMic' in d) { mic(); return; }
|
|
578
|
+
if (d.hmVer && C.t && C.t.ini) { import('./cozy-proto.js').then((M) => M.openVersion({ ws: C.t.ws, ini: C.t.ini, n: Number(d.hmVer) })).catch(() => {}); return; }
|
|
579
|
+
if (d.hmUnmark) { if (C.mark) C.mark[d.hmUnmark] = null; drawFoot({ role: role() }); return; }
|
|
552
580
|
if (d.utSpeak) { speakPress(d.utSpeak); return; }
|
|
553
581
|
if ('hmAdd' in d) { C.addOpen = !C.addOpen; drawFoot({ role: role() }); const f = C.addOpen && foot.querySelector('.hm-addm [role=menuitem]'); if (f) f.focus(); return; }
|
|
554
582
|
if (C.addOpen && b.closest('.hm-addm')) { C.addOpen = false; drawFoot({ role: role() }); } // a press in the + menu closes it, then does its part
|
|
@@ -691,6 +719,12 @@ export function mountChat(el, host) {
|
|
|
691
719
|
C.files.push({ name: f.name, size: f.size, state: 'saved', saved: f.saved, path: f.path, note: !!f.note }); drawFoot({ role: role() });
|
|
692
720
|
});
|
|
693
721
|
function openNotesHere(id) { notesLib().then((M) => M.openNotes(id)); }
|
|
722
|
+
// the canvas beside an initiative's chat (pm/cozy-proto.js): Point puts the element in the box, Continue from version n marks the next
|
|
723
|
+
// message, Send to PMOS and Make this change send a comment as the next change
|
|
724
|
+
const mine = (e) => C.t && C.t.ini && e.detail && e.detail.ini === C.t.ini;
|
|
725
|
+
window.addEventListener('pmos:point', (e) => { if (!mine(e)) return; C.mark = { ...(C.mark || {}), point: e.detail.el || e.detail.label ? { el: e.detail.el || '', label: e.detail.label || '' } : null }; drawFoot({ role: role() }); const ta = foot.querySelector('textarea'); if (ta && C.mark.point) ta.focus(); });
|
|
726
|
+
window.addEventListener('pmos:from', (e) => { if (!mine(e)) return; C.mark = { ...(C.mark || {}), from: Number(e.detail.n) || null }; drawFoot({ role: role() }); const ta = foot.querySelector('textarea'); if (ta) ta.focus(); });
|
|
727
|
+
window.addEventListener('pmos:say', (e) => { if (!mine(e) || !e.detail.text) return; send(String(e.detail.text)); });
|
|
694
728
|
el.addEventListener('change', (e) => { if (e.target.id === 'hmFile') { upload([...e.target.files]); e.target.value = ''; } });
|
|
695
729
|
// a pasted file, or one dropped on the conversation, is attached like a picked one
|
|
696
730
|
el.addEventListener('paste', (e) => { if (e.target.id !== 'hmIn' || !C.t || !C.t.key) return; const fs = e.clipboardData ? [...e.clipboardData.files] : []; if (!fs.length) return; e.preventDefault(); upload(fs); });
|
|
@@ -703,7 +737,7 @@ export function mountChat(el, host) {
|
|
|
703
737
|
if (notesM) notesM.then((M) => setTimeout(() => M.syncNotes(), 0)); // the Notes open in the Viewer belonged to the conversation before
|
|
704
738
|
const same = C.t && t && C.t.key === t.key && C.t.sid === t.sid;
|
|
705
739
|
C.t = t;
|
|
706
|
-
if (!same) { NPU.open(); C.addOpen = false; C.th = null; C.conv = null; C.show = 12; C.open = new Set(); C.files = []; C.marked = null; C.touched = null; C.picked = {}; C.pend = []; C.plOpen = false; C.plAll = false; C.seenAt = t.key ? host.seen(t.key) : null; put(log, introHtml(t.intro)); put(pl, ''); pl.hidden = true; C.jump = true; peek(null); }
|
|
740
|
+
if (!same) { C.mark = null; NPU.open(); C.addOpen = false; C.th = null; C.conv = null; C.show = 12; C.open = new Set(); C.files = []; C.marked = null; C.touched = null; C.picked = {}; C.pend = []; C.plOpen = false; C.plAll = false; C.seenAt = t.key ? host.seen(t.key) : null; put(log, introHtml(t.intro)); put(pl, ''); pl.hidden = true; C.jump = true; peek(null); }
|
|
707
741
|
draw(); read();
|
|
708
742
|
},
|
|
709
743
|
refresh() { if (C.t) draw(); },
|
package/workspace/server.js
CHANGED
|
@@ -3460,6 +3460,8 @@ const liveRound = require('./lib/live-round.js').install({
|
|
|
3460
3460
|
writePaths: spec.writePaths, addDirs: spec.addDirs, autoDelete: undefined, onDone: spec.onDone }),
|
|
3461
3461
|
stop: (s) => { if (s && s.child) stopHeadless(s); },
|
|
3462
3462
|
artefact: (dir, line, by) => { const AF = require('./lib/artefacts.js'); return AF.set(AF.file(dir), line, { by }); },
|
|
3463
|
+
// the chat explains the change (initiative live-round-iterative): a line typed into the initiative's chat session, when one is open
|
|
3464
|
+
tell: (ws, ini, text) => { const id = require('./lib/briefing-premium-agent.js').chatSessionOf(STATE, 'init:' + ini); return id ? sendToSession(id, text) : false; },
|
|
3463
3465
|
warn: (what, e) => warnWriteFail(what, e),
|
|
3464
3466
|
});
|
|
3465
3467
|
// live round before a meeting (lib/live-round-meeting.js, initiative live-round-meeting): step 2 of the queue. A meeting in the next hour
|