create-pmos 0.414.0 → 0.416.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.
Files changed (86) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/bin/pmos.js +1 -1
  8. package/workspace/briefing-premium-adddoc-test.js +3 -3
  9. package/workspace/briefing-premium-board-test.js +72 -43
  10. package/workspace/briefing-premium-doc-edit-test.js +2 -2
  11. package/workspace/briefing-premium-initiative-test.js +19 -22
  12. package/workspace/briefing-premium-insights-test.js +28 -17
  13. package/workspace/changelog.json +24 -0
  14. package/workspace/core-docs-workflow-test.js +1 -1
  15. package/workspace/guide/workflows.md +6 -2
  16. package/workspace/ini-workflow-test.js +11 -11
  17. package/workspace/lib/board-premium.js +13 -0
  18. package/workspace/lib/board-trail.js +6 -1
  19. package/workspace/lib/engine/boards.js +12 -4
  20. package/workspace/lib/goal-chat.js +46 -15
  21. package/workspace/lib/initiative-chat.js +7 -5
  22. package/workspace/lib/initiative-premium.js +4 -2
  23. package/workspace/lib/insights-premium.js +9 -1
  24. package/workspace/lib/item-cli.js +2 -1
  25. package/workspace/lib/pmos-verbs.js +1 -1
  26. package/workspace/lib/route-modules.js +1 -0
  27. package/workspace/lib/routes-boards.js +149 -18
  28. package/workspace/lib/routes-briefing-premium.js +14 -1
  29. package/workspace/lib/routes-live.js +53 -0
  30. package/workspace/lib/task-cli.js +137 -25
  31. package/workspace/lib/task-items.js +88 -0
  32. package/workspace/lib/workflow-cli.js +1 -1
  33. package/workspace/milestone-suggest-test.js +2 -1
  34. package/workspace/package-lock.json +2 -2
  35. package/workspace/package.json +1 -1
  36. package/workspace/premium-board-actions-test.js +3 -3
  37. package/workspace/premium-chat-report-tab-test.js +13 -5
  38. package/workspace/premium-core-doc-issue-test.js +1 -1
  39. package/workspace/premium-report-read-test.js +66 -51
  40. package/workspace/premium-vw-backlog-test.js +3 -3
  41. package/workspace/premium-vw-doc-test.js +3 -3
  42. package/workspace/premium-vw-item-test.js +4 -4
  43. package/workspace/premium-vw-jira-test.js +14 -13
  44. package/workspace/premium-vw-slides-test.js +7 -5
  45. package/workspace/program-panel-test.js +1 -1
  46. package/workspace/public/pm/bd-ini-panel.js +68 -210
  47. package/workspace/public/pm/cozy-insights.css +15 -0
  48. package/workspace/public/pm/cozy-live-pill.css +48 -0
  49. package/workspace/public/pm/cozy-live-pill.js +141 -0
  50. package/workspace/public/pm/cozy-viewer.js +4 -3
  51. package/workspace/public/pm/cozy-vw-rp.css +48 -0
  52. package/workspace/public/pm/home-app.js +45 -8
  53. package/workspace/public/pm/home-chat.js +5 -2
  54. package/workspace/public/pm/home-ini.js +57 -22
  55. package/workspace/public/pm/home-stage-card.js +3 -2
  56. package/workspace/public/pm/home-task.js +16 -5
  57. package/workspace/public/pm/ini-view-model.js +277 -0
  58. package/workspace/public/pm/ini-view.css +122 -0
  59. package/workspace/public/pm/ini-view.js +180 -0
  60. package/workspace/public/pm/live-model.js +104 -0
  61. package/workspace/public/pm/ov-view.css +44 -0
  62. package/workspace/public/pm/premium-board.js +23 -15
  63. package/workspace/public/pm/premium-initiative-head.js +12 -2
  64. package/workspace/public/pm/premium-insights.js +61 -35
  65. package/workspace/public/pm/premium-report-read.js +74 -50
  66. package/workspace/public/pm/premium-report-tab.js +36 -15
  67. package/workspace/public/pm/premium-shell.js +1 -1
  68. package/workspace/public/pm/premium-vw-item-model.js +6 -3
  69. package/workspace/public/pm/premium-vw-item.js +25 -6
  70. package/workspace/public/pm/premium-vw-jira.js +17 -15
  71. package/workspace/public/pm/rp-parts.js +75 -12
  72. package/workspace/public/pm/task-card.css +24 -49
  73. package/workspace/public/pm/task-card.js +90 -64
  74. package/workspace/public/pm/tk-view.css +21 -0
  75. package/workspace/public/pm/tk-view.js +216 -0
  76. package/workspace/public/pm/wf-page.js +2 -0
  77. package/workspace/server.js +24 -1
  78. package/workspace/stage-card-test.js +49 -41
  79. package/workspace/task-card-test.js +83 -38
  80. package/workspace/test-files.json +3 -1
  81. package/workspace/test-lists/bd-ini-panel.json +3 -3
  82. package/workspace/test-lists/one-task-list.json +5 -0
  83. package/workspace/tk-tasks-test.js +3 -3
  84. package/workspace/public/pm/bd-ini-model.js +0 -81
  85. package/workspace/public/pm/cozy-rec-pill.css +0 -12
  86. package/workspace/public/pm/cozy-rec-pill.js +0 -46
@@ -0,0 +1,216 @@
1
+ /* pm/tk-view.js — one Jira ticket Viewer, the same from Board, Home, Insights and Search (feedback batch 6 item 1b; canvas OvViewers
2
+ * "Jira ticket", phone dark).
3
+ *
4
+ * What blocks it leads: a summary card only when Jira flags it ("Blocked by PLAT-88", "Jira · 4 min ago", what that holds up). Then:
5
+ * facts card Status, Due, Assignee, Sprint, Points in plain text, and "Jira owns these. They change only in Jira." (with how fresh the
6
+ * read is when no summary card says it). A fact no reading holds is left out (zero is silence).
7
+ * Description the ticket's text as it went to Jira, shown open, cut at five lines with an icon that opens the rest.
8
+ * Your notes the PM's own words (POST /api/boards/tickets/note), edited in place; Jira never sees them.
9
+ * where it sits the same row as the task: initiative › stage › epic. It opens the initiative; Jira keeps the epic, so there is no move.
10
+ * folds Acceptance criteria, Subtasks, Linked: each only when the record holds something for it.
11
+ * foot Open in Jira.
12
+ * The header (cozy-viewer.js): the Jira tile, "KEY Title", Discuss in chat, ⋯ (Read Jira again, Copy link, Copy as text), open wide, ×.
13
+ * ticketOf(src) → t pure: one shape from the Board's ticket (board-premium track.tickets), the Jira tickets route's model
14
+ * (premium-vw-jira-model.js ticketModel) and the board items' notes
15
+ * tkSummary(t, o) → czSummary input | null pure: the blocked card, or nothing
16
+ * tkHtml(t, o) → markup pure, for a node test. o: { now, extra: [czSections rows], more: true when the description is open }
17
+ * mountTicket(el, t, h) draws and wires it in a body. h: { ws, board, post(path, body), toast(msg, undo?), openIni(id), changed?(t) }
18
+ * openTicketView(o) → body opens it in the Viewer and reads the rest. o: { ws, board, ini, iniTitle, ref, base, stage, back, from,
19
+ * extra(t) → rows, onShow(), onHide(), openIni(id), askHref(q), refresh() } */
20
+ import * as VW from './cozy-viewer.js';
21
+ import { ticketModel, storedModel } from './premium-vw-jira-model.js';
22
+ import { esc, freshness, cardStyle, toastUndo } from './task-card.js';
23
+
24
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
25
+ const day = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? MON[+m[2] - 1] + ' ' + +m[3] : ''; };
26
+ const ico = (d, w = 16) => `<svg width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${d}</svg>`;
27
+ const I = { flag: '<path d="M6 21V4M6 4h11l-2 4 2 4H6"/>', chev: '<path d="M10 7l5 5-5 5"/>', down: '<path d="M6 9l6 6 6-6"/>', up: '<path d="M6 15l6-6 6 6"/>',
28
+ ext: '<path d="M14 4h6v6M20 4l-9 9M18 14v6H4V6h6"/>', done: '<circle cx="12" cy="12" r="8"/><path d="M8.5 12.2l2.4 2.4 4.6-5"/>', todo: '<circle cx="12" cy="12" r="8"/>' };
29
+ const initials = (name) => String(name || '').trim().split(/\s+/).slice(0, 2).map((w) => w[0] || '').join('').toUpperCase() || '?';
30
+ const plural = (n, a, b) => (n === 1 ? a : b);
31
+ const KEY_RE = /\b([A-Z][A-Z0-9]+-\d+)\b/;
32
+ /** Lines of ticket text (markdown-ish) as safe html: paragraphs, bullets, sub-headings. Nothing in it runs: every word is escaped. */
33
+ export function textHtml(text) {
34
+ const out = []; let list = [];
35
+ const il = (x) => esc(x).replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>').replace(/`([^`]+)`/g, '<code>$1</code>'); // bold and code, after the escape: nothing in the text runs
36
+ const flush = () => { if (list.length) { out.push('<ul>' + list.map((x) => '<li>' + il(x) + '</li>').join('') + '</ul>'); list = []; } };
37
+ for (const raw of String(text || '').split('\n')) {
38
+ const l = raw.trim(), b = /^[-*]\s+(?:\[[ xX]\]\s+)?(.*)$/.exec(l), h = /^#{1,6}\s+(.*)$/.exec(l);
39
+ if (b) { list.push(b[1]); continue; }
40
+ flush();
41
+ if (h) out.push('<h4>' + il(h[1]) + '</h4>'); else if (l) out.push('<p>' + il(l) + '</p>');
42
+ }
43
+ flush();
44
+ return out.join('');
45
+ }
46
+ /** The bullets of a section (the acceptance criteria), or its lines when it has none. */
47
+ const itemsOf = (text) => { const L = String(text || '').split('\n').map((x) => x.trim()).filter(Boolean), b = L.filter((x) => /^[-*]\s+/.test(x)); return (b.length ? b : L.filter((x) => !/^#/.test(x))).map((x) => x.replace(/^[-*]\s+(?:\[[ xX]\]\s+)?/, '')); };
48
+
49
+ /**
50
+ * One ticket in one shape. src = { base, model, notes, ini, iniTitle, stage, readAt, trail }
51
+ * base a Board ticket { key, title, status, raw, blocked, reason, points, url, sprint, sprintEnd, assignee, blockedDays, due }
52
+ * model premium-vw-jira-model.js ticketModel(...) when it is ok: the sections, the links, the epic, the subtasks, the sprint read
53
+ * trail the Board's trail of this ticket { reason, subtasks: { done, total, items } }
54
+ */
55
+ export function ticketOf(src = {}) {
56
+ const k = src.base || {}, m = src.model && src.model.ok ? src.model : null, tr = src.trail || null;
57
+ const secs = (m && m.sections) || [];
58
+ const acc = secs.find((x) => x.key === 'acceptance');
59
+ const sub = tr && tr.subtasks && tr.subtasks.total ? tr.subtasks : m && m.subtasks ? m.subtasks : null;
60
+ const blocked = !!(k.blocked || (m && m.flagged));
61
+ return {
62
+ key: k.key || (m && m.key) || '', title: (m && m.title) || k.title || k.key || '', url: k.url || (m && m.url) || '', inJira: m ? !!m.inJira : !!k.key,
63
+ status: k.raw || k.status || (m && m.status) || '', blocked, reason: blocked ? k.reason || (tr && tr.reason) || (m && m.reason) || '' : '', blockedDays: k.blockedDays != null ? k.blockedDays : null,
64
+ assignee: k.assignee || (m && m.assignee) || '', sprint: k.sprint || (m && m.sprint && m.sprint.name) || '', sprintEnd: k.sprintEnd || '', points: k.points != null ? k.points : m && m.points != null ? m.points : null, priority: k.priority || (m && m.priority) || '',
65
+ due: k.due || '', readAt: src.readAt || (m && m.readAt) || '',
66
+ description: secs.filter((x) => x.key !== 'acceptance').map((x) => (secs.length > 1 ? '### ' + x.name + '\n' : '') + x.text).join('\n'),
67
+ acceptance: acc ? itemsOf(acc.text) : [], subtasks: sub && sub.total ? { done: Math.min(sub.done || 0, sub.total), total: sub.total, items: Array.isArray(sub.items) ? sub.items : null } : null,
68
+ links: (m && m.links) || [], prd: (m && m.prd) || '', epic: (m && m.epic) || (k.epic ? { key: k.epic, title: '' } : null), notes: src.notes != null ? String(src.notes) : '',
69
+ ini: src.ini || '', iniTitle: src.iniTitle || (m && m.initiative) || '', stage: src.stage || '', release: src.release || null,
70
+ };
71
+ }
72
+
73
+ /** The summary card: only what blocks it (canvas OvViewers: "Blocked by PLAT-88 · Jira · 4 min ago", what it holds up). Not blocked: none,
74
+ * because a card that repeated the facts below would say it twice. o: { now, blockerTitle(key) } */
75
+ export function tkSummary(t, o = {}) {
76
+ if (!t.blocked) return null;
77
+ const reason = t.reason || 'Flagged as blocked in Jira', on = KEY_RE.exec(reason), bt = on && o.blockerTitle ? o.blockerTitle(on[1]) : '';
78
+ const since = t.blockedDays != null ? ' for ' + t.blockedDays + ' ' + plural(t.blockedDays, 'day', 'days') : '';
79
+ const said = reason.replace(/^Waiting on /i, '').replace(/\.$/, '');
80
+ const holds = t.stage ? 'It holds ' + t.stage + '.' : '';
81
+ const slip = t.sprintEnd ? 'If it is not fixed by ' + day(t.sprintEnd) + ', the end of ' + (t.sprint || 'its sprint') + ', ' + (t.release ? t.release.name + ' on ' + day(t.release.iso) + ' slips.' : 'it carries into the next sprint.')
82
+ : t.release ? 'It holds up ' + t.release.name + ' on ' + day(t.release.iso) + '.' : '';
83
+ const fr = freshness(t.readAt, o.now || Date.now());
84
+ return { line: 'Blocked' + (on ? ' by ' + on[1] : '') + since, tone: 'warn', right: fr ? 'Jira · ' + fr.replace(/^read /, '') : '',
85
+ text: [on && said === on[1] ? (bt ? on[1] + ' is ' + bt + '.' : '') : said + (bt ? ' (' + bt + ')' : '') + '.', holds, slip].filter(Boolean).join(' ') };
86
+ }
87
+
88
+ const DESC_CUT = 320; // about five lines at the Viewer's width; a shorter text is shown whole, with no icon
89
+ /** The ticket's body. o: { now, extra: [czSections rows], more: the description is open, notes: the open notes field's value } */
90
+ export function tkHtml(t, o = {}) {
91
+ const now = o.now || Date.now(), S = tkSummary(t, o), fr = freshness(t.readAt, now);
92
+ const facts = [['Status', esc(t.status || (t.inJira ? 'No status read' : 'Not in Jira yet'))], ['Due', esc(day(t.due))],
93
+ ['Assignee', t.assignee ? `<span class="av j">${esc(initials(t.assignee))}</span>${esc(t.assignee)}` : ''], ['Sprint', esc(t.sprint)], ['Points', t.points != null ? esc(t.points) : ''], ['Priority', esc(t.priority || '')]]
94
+ .filter((x) => x[1]).map(([k, v]) => `<span class="k">${k}</span><span class="v" data-tkv-f="${k.toLowerCase()}">${v}</span>`).join('');
95
+ const foot = 'Jira owns these. They change only in Jira.' + (!S && fr ? ' ' + fr.charAt(0).toUpperCase() + fr.slice(1) + '.' : '');
96
+ const card = `<div class="ovf tkv-f">${facts}<p class="foot">${foot}</p></div>`;
97
+ const long = t.description.length > DESC_CUT || t.description.split('\n').filter((x) => x.trim()).length > 5;
98
+ const desc = t.description ? `<div class="ovb"><p class="ovl">Description <small>· ${t.inJira ? 'from Jira' : 'draft, not in Jira yet'}</small></p><div class="ovd${long && !o.more ? ' cut' : ''}"><div class="ovdx">${textHtml(t.description)}</div>`
99
+ + (long ? `<div class="ovdm"><button type="button" class="ovib" data-tkv="more" aria-expanded="${o.more ? 'true' : 'false'}" aria-label="${o.more ? 'Show less' : 'Show all of it'}" title="${o.more ? 'Show less' : 'Show all of it'}">${ico(o.more ? I.up : I.down, 16)}</button></div>` : '') + '</div></div>' : '';
100
+ const notes = `<div class="ovb"><label class="ovl" for="tkvNotes">Your notes</label><textarea class="nt" id="tkvNotes" data-tkv-notes rows="2" maxlength="4000" placeholder="Add notes. Only you see them.">${esc(o.notes != null ? o.notes : t.notes)}</textarea></div>`;
101
+ const path = [t.stage, t.epic ? (t.epic.title ? 'Epic ' + t.epic.title : t.epic.key) : ''].filter(Boolean).map(esc);
102
+ const where = t.ini ? `<div class="ovw"><button type="button" class="go" data-tkv="ini" aria-label="Open ${esc(t.iniTitle || t.ini)}"><span class="tl" aria-hidden="true">${ico(I.flag, 15)}</span>`
103
+ + `<span class="tx"><b>${esc(t.iniTitle || t.ini)}</b>${path.length ? `<small>${path.join('<span class="sep" aria-hidden="true">›</span>')}</small>` : ''}</span><span class="cv">${ico(I.chev, 15)}</span></button></div>` : t.inJira ? '<p class="tkv-q">On no initiative of this board.</p>' : '';
104
+ const sub = t.subtasks;
105
+ const rows = (o.extra || []).concat([
106
+ t.acceptance.length ? { id: 'ac', title: 'Acceptance criteria', count: t.acceptance.length, render: () => `<ul class="tkv-ac">${t.acceptance.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>` } : null,
107
+ sub ? { id: 'sub', title: 'Subtasks', count: sub.done + ' of ' + sub.total + ' done', render: () => (sub.items && sub.items.length
108
+ ? `<ul class="tkv-sub">${sub.items.map((y) => `<li class="${y.done ? 'd' : ''}">${ico(y.done ? I.done : I.todo, 15)}<span>${esc(y.name || y.summary || '')}</span></li>`).join('')}</ul>`
109
+ : `<p class="tkv-q">${sub.done} done, ${sub.total - sub.done} open. The Jira read holds the count, not the list: Open in Jira has them.</p>`) } : null,
110
+ t.links.length || t.prd ? { id: 'links', title: 'Linked', count: t.links.length + (t.prd ? 1 : 0), render: () => `<ul class="tkv-ln">${t.links.map((l) => `<li><em>${esc(l.rel)}</em>${l.open
111
+ ? `<button type="button" data-tkv-link="${esc(l.ref)}"><b>${esc(l.key || l.ref)}</b> ${esc(l.title)}</button>` : `<span><b>${esc(l.ref)}</b></span>`}</li>`).join('')}${t.prd ? `<li><em>drafted from</em><span>${esc(t.prd)}</span></li>` : ''}</ul>` } : null,
112
+ ]).filter(Boolean);
113
+ const folds = VW.czSections(rows, { key: 'ticket' });
114
+ const ft = t.url ? `<div class="ovft"><a href="${esc(t.url)}" target="_blank" rel="noopener">${ico(I.ext, 15)}Open in Jira</a></div>` : '';
115
+ return `<div class="tkv">${S ? VW.czSummary(S) : ''}${card}${desc}${notes}${where}${folds}${ft}<p class="tkc-msg tkv-msg" role="status"></p></div>`;
116
+ }
117
+
118
+ let cssOn = false;
119
+ function style() {
120
+ cardStyle();
121
+ if (cssOn || typeof document === 'undefined') return; cssOn = true;
122
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./tk-view.css', import.meta.url).href; document.head.append(l);
123
+ }
124
+
125
+ /** Draws the ticket in a body and wires its presses: the description's open icon, the notes (saved on blur with Undo), the initiative row,
126
+ * a linked ticket. h: { ws, board, post(path, body) → json, toast(msg, undo?), openIni(id), openRef(ref), changed(t), now(), extra(t) } */
127
+ export function mountTicket(el, t, h = {}) {
128
+ style();
129
+ const st = { more: false };
130
+ const draw = () => {
131
+ const ae = document.activeElement; if (ae && el.contains(ae) && ae.matches('[data-tkv-notes]')) return; // never redraw under the PM's typing
132
+ el.innerHTML = tkHtml(t, { now: h.now ? h.now() : Date.now(), more: st.more, extra: h.extra ? h.extra(t) : [], blockerTitle: h.blockerTitle });
133
+ };
134
+ const say = (m) => { const x = el.querySelector('.tkv-msg'); if (x) x.textContent = m || ''; };
135
+ const toast = h.toast || toastUndo;
136
+ const save = async (notes) => {
137
+ const from = t.notes; t.notes = notes;
138
+ if (!h.post || !h.board) { t.notes = from; say('Notes save on a board with its own state. Nothing was changed.'); return; }
139
+ const r = await h.post('/api/boards/tickets/note', { ws: h.ws, board: h.board, ref: t.key, notes }).catch(() => null);
140
+ if (!r || r.ok === false) { t.notes = from; draw(); say((r && r.error) || 'The notes could not be saved. Nothing was changed.'); return; }
141
+ if (h.changed) h.changed(t);
142
+ toast('Notes saved', async () => { const u = await h.post('/api/boards/tickets/note', { ws: h.ws, board: h.board, ref: t.key, notes: from }).catch(() => null); if (u && u.ok !== false) { t.notes = from; draw(); } return u || { ok: false }; });
143
+ };
144
+ el.addEventListener('click', (e) => {
145
+ const b = e.target.closest('[data-tkv], [data-tkv-link]'); if (!b || !el.contains(b)) return;
146
+ if (b.dataset.tkvLink) { if (h.openRef) h.openRef(b.dataset.tkvLink); return; }
147
+ const k = b.dataset.tkv;
148
+ if (k === 'more') { st.more = !st.more; draw(); const m = el.querySelector('[data-tkv="more"]'); if (m) m.focus(); }
149
+ else if (k === 'ini' && h.openIni) h.openIni(t.ini);
150
+ });
151
+ el.addEventListener('focusout', (e) => {
152
+ const n = e.target.closest && e.target.closest('[data-tkv-notes]'); if (!n) return;
153
+ const v = n.value.replace(/\s+$/, ''); if (v !== (t.notes || '')) setTimeout(() => save(v), 0);
154
+ });
155
+ el.addEventListener('keydown', (e) => {
156
+ const n = e.target.closest && e.target.closest('[data-tkv-notes]'); if (!n) return;
157
+ if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); n.blur(); }
158
+ else if (e.key === 'Escape') { e.stopPropagation(); n.value = t.notes || ''; n.blur(); }
159
+ });
160
+ draw();
161
+ return { draw, ticket: t };
162
+ }
163
+
164
+ const getJson = async (p, q) => {
165
+ const s = new URLSearchParams(Object.entries(q).filter(([, v]) => v)).toString();
166
+ try { const r = await fetch(p + (s ? '?' + s : ''), { credentials: 'same-origin' }); return await r.json(); } catch { return null; }
167
+ };
168
+ const postJson = async (p, body) => { const H = await import('./http.js'); return H.pmPost(p, body); };
169
+ /** Everything the records hold about one ticket: the Jira tickets route (its text, links, epic), the sprints (sprint, points, assignee),
170
+ * the board's items (the PM's notes). A ticket on no initiative of the board falls back to the stored Jira read. */
171
+ export async function readTicket(o) {
172
+ const [view, sprints, items] = await Promise.all([o.ini ? getJson('/api/jira/tickets', { ws: o.ws, initiative: o.ini }) : null,
173
+ o.board ? getJson('/api/boards/sprints', { ws: o.ws, board: o.board }) : null, o.board ? getJson('/api/boards/items', { ws: o.ws, board: o.board }) : null]);
174
+ let m = ticketModel(view, o.ref, sprints);
175
+ if (!m.ok && !(view && view.ok === false && view.error)) m = storedModel(await getJson('/api/jira/ticket', { ws: o.ws, key: o.ref }), o.ref); // nothing stored holds it: Not read yet, with Read it now (popup context slice 4)
176
+ const it = items && items.ok ? (items.items || []).find((x) => x.src === 'jira' && x.key === o.ref) : null;
177
+ const ini = o.ini || (it && it.ini) || '';
178
+ const iniRow = items && items.ok ? (items.initiatives || []).find((x) => x.id === ini) : null;
179
+ return { model: m, notes: it ? it.notes || '' : null, ini, iniTitle: o.iniTitle || (iniRow && iniRow.title) || '', epicKey: it && it.epic };
180
+ }
181
+
182
+ /** The ticket in the Viewer. It draws at once from what the page holds (o.base), then again once the records are read. */
183
+ export function openTicketView(o = {}) {
184
+ if (!o.ref) return null;
185
+ style();
186
+ let t = ticketOf({ base: o.base || { key: o.ref }, ini: o.ini, iniTitle: o.iniTitle, stage: o.stage, readAt: o.readAt, trail: o.trail, release: o.release, notes: o.notes });
187
+ let mounted = null;
188
+ const more = () => {
189
+ const L = [];
190
+ if (o.refresh) L.push({ label: 'Read Jira again', on: () => o.refresh() });
191
+ if (L.length) L.push({ sep: true });
192
+ if (t.url) L.push({ label: 'Copy link', on: () => copy(t.url, 'Link copied.') });
193
+ L.push({ label: 'Copy as text', on: () => copy(textOf(t), 'Copied as text.') });
194
+ return L;
195
+ };
196
+ const body = VW.open({ kind: 'Jira ticket', title: t.key + ' ' + t.title, icon: 'jira', id: 'tk:' + (o.ini || '') + ':' + o.ref, url: t.url, back: !!o.back, more,
197
+ discuss: o.askHref ? () => location.assign(o.askHref(t.key + ': ')) : true,
198
+ render: (el) => {
199
+ if (o.onShow) o.onShow();
200
+ mounted = mountTicket(el, t, { ws: o.ws, board: o.board, post: o.post || postJson, toast: o.toast, openIni: o.openIni, blockerTitle: o.blockerTitle, extra: o.extra,
201
+ openRef: (ref) => openTicketView({ ...o, ref, base: { key: ref }, back: true, trail: null, notes: null }) });
202
+ },
203
+ onClose: () => { if (o.onHide) o.onHide(); } });
204
+ readTicket({ ws: o.ws, board: o.board, ini: o.ini, iniTitle: o.iniTitle, ref: o.ref }).then((R) => {
205
+ if (!body || !body.isConnected || !mounted) return;
206
+ const base = o.base || { key: o.ref, epic: R.epicKey };
207
+ t = Object.assign(mounted.ticket, ticketOf({ base, model: R.model, notes: R.notes != null ? R.notes : o.notes, ini: R.ini, iniTitle: R.iniTitle, stage: o.stage, readAt: o.readAt || (R.model && R.model.readAt), trail: o.trail, release: o.release }));
208
+ if (R.model && R.model.ok && R.model.title && VW.retitle) VW.retitle('tk:' + (o.ini || '') + ':' + o.ref, t.key + ' ' + t.title);
209
+ mounted.draw();
210
+ });
211
+ return body;
212
+ }
213
+ const textOf = (t) => [t.key + ' ' + t.title, [t.status, t.assignee, t.sprint, t.points != null ? t.points + ' ' + plural(t.points, 'point', 'points') : ''].filter(Boolean).join(' · '), t.blocked ? 'Blocked: ' + (t.reason || 'flagged in Jira') : '', t.url].filter(Boolean).join('\n');
214
+ function copy(text, said) { try { navigator.clipboard.writeText(text).then(() => toastUndo(said), () => toastUndo('This browser did not allow the copy.')); } catch { toastUndo('This browser did not allow the copy.'); } }
215
+
216
+ if (typeof window !== 'undefined') window.__tkView = { openTicketView };
@@ -13,6 +13,7 @@
13
13
  import { pmGet, pmPost, pmHeaders } from './http.js';
14
14
  import { esc, svg, ICON, wsParam, wsQ } from './cozy-evui.js';
15
15
  import { mountNav } from './cozy-nav.js';
16
+ import { mountLivePill } from './cozy-live-pill.js';
16
17
  import * as VW from './cozy-viewer.js';
17
18
  import { CATS, wfIcon, PRODUCT_FEATURE_ID } from './wf-model.js';
18
19
  import * as E from './wf-edit.js';
@@ -393,6 +394,7 @@ function bind() {
393
394
 
394
395
  export function boot() {
395
396
  mountNav('settings');
397
+ mountLivePill();
396
398
  setStageHost(stageCtx());
397
399
  bind();
398
400
  draw();
@@ -3025,6 +3025,7 @@ function persist(s) {
3025
3025
  if (s.workType) meta.workType = s.workType;
3026
3026
  if (s.nameBy) meta.nameBy = s.nameBy; // session names A: the PM named it, so Claude never renames it
3027
3027
  if (s.autoName) meta.autoName = s.autoName; // the name Claude gave it after its first real answer
3028
+ if (s.touchedAt) meta.touchedAt = s.touchedAt; // the Live pill: when the PM last opened, typed in or answered it
3028
3029
  try {
3029
3030
  fs.writeFileSync(path.join(SESS_DIR, s.id + '.json'), JSON.stringify(meta));
3030
3031
  fs.writeFileSync(path.join(SESS_DIR, s.id + '.scrollback'), s.buf);
@@ -3450,6 +3451,8 @@ function sessionList() {
3450
3451
  fmtDur: treeShare.ago,
3451
3452
  }),
3452
3453
  lastOutputAt: s.lastOutputAt || null,
3454
+ // the Live pill (batch 6 item 2): when the PM last opened, typed in or answered it (ms), when it ended, and whether PMOS ended it for room
3455
+ touched_at: s.touchedAt || null, exited_at: s.exitedAt || null, auto_ended: !!s.autoEnded,
3453
3456
  lastWords: h.lastWords,
3454
3457
  // the harness proper — structured record, not rendered bytes. Resolved ONCE above and
3455
3458
  // reused: it also feeds the join, and calling it twice per session per broadcast would
@@ -3504,6 +3507,14 @@ function sessionList() {
3504
3507
  });
3505
3508
  }
3506
3509
  function pushSessions() { broadcast({ t: 'sessions', sessions: sessionList() }); }
3510
+ /* The Live pill (batch 6 item 2): the PM opened, typed in or answered this session now. Kept on the session and in its record, written
3511
+ * at most every 30 s, so typing does not write the record on each key. Only the PM's own presses call it (page presses and the terminal). */
3512
+ function touchSession(s, now = Date.now()) {
3513
+ if (!s) return;
3514
+ const last = s.touchedAt || 0;
3515
+ s.touchedAt = now;
3516
+ if (now - (s._touchSaved || 0) > 30000 || now - last > 30000) { s._touchSaved = now; persist(s); }
3517
+ }
3507
3518
  function pushWorkspaces() { broadcast({ t: 'workspaces', workspaces: wsList() }); }
3508
3519
 
3509
3520
  // ── The liveness heartbeat. ───────────────────────────────────────────────────────────────────
@@ -6809,6 +6820,7 @@ async function handleRequest(req, res) {
6809
6820
  const sess = sessions.get(String(body.id || ''));
6810
6821
  if (!sess || !sess.pty || sess.state === 'exited') return json(res, { ok: false, error: 'That session is not running.' }, 409);
6811
6822
  if (sess.agent === 'shell') return json(res, { ok: false, error: 'A terminal shell takes input in the console.' }, 409);
6823
+ touchSession(sess);
6812
6824
  if (p === '/api/session/say') {
6813
6825
  const t = String(body.text == null ? '' : body.text).trim();
6814
6826
  if (!t) return json(res, { ok: false, error: 'Write a message for Claude.' }, 400);
@@ -6820,6 +6832,17 @@ async function handleRequest(req, res) {
6820
6832
  if (!data) return json(res, { ok: false, error: 'press must be esc or 1 to 9' }, 400);
6821
6833
  return chatSessions.keys(sess.id, data) ? json(res, { ok: true, session: sess.id }) : json(res, { ok: false, error: 'The key did not reach the session.' }, 409);
6822
6834
  }
6835
+ // The Live pill (batch 6 item 2): Home opened this session's chat. A page press only; it changes no session, it only keeps the time.
6836
+ if (p === '/api/session/touch' && req.method === 'POST') {
6837
+ let body = {};
6838
+ try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
6839
+ const g = pmGuard.requirePagePress(req, body);
6840
+ if (!g.ok) return json(res, { ok: false, error: g.error }, g.status);
6841
+ const sess = sessions.get(String(body.id || ''));
6842
+ if (!sess) return json(res, { ok: false, error: 'That session is not on this machine.' }, 404);
6843
+ touchSession(sess);
6844
+ return json(res, { ok: true, id: sess.id, touched_at: sess.touchedAt });
6845
+ }
6823
6846
  if (p === '/api/session/remove' && req.method === 'POST') {
6824
6847
  let body = {};
6825
6848
  try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
@@ -10277,7 +10300,7 @@ wss.on('connection', (ws) => {
10277
10300
  } else if (m.t === 'detach') {
10278
10301
  const s = sessions.get(m.id); if (s) s.clients.delete(ws); ws.attached.delete(m.id);
10279
10302
  } else if (m.t === 'input') {
10280
- const s = sessions.get(m.id); if (s && s.pty) s.pty.write(m.data);
10303
+ const s = sessions.get(m.id); if (s && s.pty) { s.pty.write(m.data); if (typeof m.data === 'string' && !/^\x1b/.test(m.data)) touchSession(s); } // a key the PM typed, not the terminal's own reply to a query
10281
10304
  } else if (m.t === 'resize') {
10282
10305
  const s = sessions.get(m.id);
10283
10306
  if (s && s.pty) {
@@ -4,9 +4,9 @@
4
4
  * desktop; initiative premium-agreed-design). Two halves:
5
5
  * P pure: home-stage-card.js (the order of the steps, the cap of 4 with "N more", the clock, the next stage's line) and headModel's
6
6
  * bars (one a stage of the initiative's own workflow, a skipped one dashed), and cozy-steps.js (the shared step list).
7
- * D the real page from the real server, its routes answered from the fixtures: the card's header, bars, steps and last node; the one
8
- * primary; the done fold; the move popover under the line on a desktop and the sheet on the phone, with the switch, Move now (open
9
- * steps ask for a note) and Back; the spinner only for a running session; every step done before a milestone: "Move to ◆ Deliver".
7
+ * D the real page from the real server, its routes answered from the fixtures. Re-pointed to the ONE view (batch 6 items 1 and 3): the
8
+ * card's header, bars, day clock and next stage; the move popover under the line on a desktop and the sheet on the phone, with the
9
+ * switch, Move now (open steps ask for a note) and Back; every step done before a milestone: Move now moves it to ◆ Deliver.
10
10
  * PMOS_SHOTS=<dir> also saves a screenshot of each state there. */
11
11
  const path = require('path');
12
12
  const fs = require('fs');
@@ -97,7 +97,9 @@ async function pure() {
97
97
  const BOARD = BP.build(BF.facts()), BRIEF = BRP.build(BRF.facts());
98
98
  if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
99
99
 
100
- const open = async ({ w = 1280, h = 900, theme = 'light', model = SCEN.build(), sessions = null, trail = null } = {}) => {
100
+ // the board the page reads (the one view draws the board's row): the scenario's stage, so the page and the board agree as the records do
101
+ const boardAt = (stage) => { const f = BF.facts(); f.rows = f.rows.map((r) => (r.id === 'self-serve-v2' ? { ...r, stage } : r)); return BP.build(f); };
102
+ const open = async ({ w = 1280, h = 900, theme = 'light', model = SCEN.build(), board = BOARD, sessions = null, trail = null } = {}) => {
101
103
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
102
104
  const page = await ctx.newPage();
103
105
  const errors = [], posts = [];
@@ -105,49 +107,41 @@ async function pure() {
105
107
  page.on('request', (rq) => { if (rq.method() === 'POST') posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); });
106
108
  const json = (r, b) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(b) });
107
109
  await page.route('**/api/initiative-premium*', (r) => json(r, { ok: true, state: 'ready', model, as_of: Date.now() }));
108
- await page.route(/\/api\/board-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BOARD, as_of: Date.now() }));
110
+ await page.route(/\/api\/board-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: board, as_of: Date.now() }));
109
111
  await page.route(/\/api\/briefing-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BRIEF, as_of: Date.now() }));
110
112
  await page.route('**/api/briefing-premium/**', (r) => json(r, { ok: true, turns: [], working: false }));
111
113
  for (const p of ['**/api/boards/move', '**/api/initiative-layout', '**/api/boards/ini-auto']) await page.route(p, (r) => (r.request().method() === 'POST' ? json(r, { ok: true, auto: false, held: [], by: 'stage', names: [], of: {}, stage: {}, sets: [] }) : r.fallback()));
112
114
  if (sessions) await page.route(/\/api\/sessions(\?.*)?$/, (r) => json(r, { sessions }));
113
115
  if (trail) await page.route('**/api/board-trail*', (r) => json(r, trail));
114
116
  await page.goto(BASE + '/premium.html?ini=self-serve-v2&ws=w1&board=w1&theme=' + theme);
115
- const up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer [data-hi-v="page"] .hm-sc .cz-sl')), 30000);
117
+ const up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer [data-hi-v="page"] .iv-sc')), 30000);
116
118
  return { ctx, page, errors, posts, up };
117
119
  };
118
120
  const V = '#czViewer [data-hi-v="page"]';
119
121
  const shot = async (p, name, sel) => { if (!SHOTS) return; await sleep(300); await (sel ? p.locator(sel).first() : p).screenshot({ path: path.join(SHOTS, name + '.png') }); };
122
+ /* re-pointed (batch 6 items 1 and 3, the one view): the page's stage card is the one the Board draws. It says where the stage is (the
123
+ * ladder, n of m), how much of its section is done, the day clock, the dates line and the next stage; the steps are said once, in Tasks */
120
124
  const card = (p) => p.evaluate((v) => {
121
- const c = document.querySelector(v + ' .hm-sc'); const t = (n) => (n ? n.textContent.replace(/\s+/g, ' ').trim() : '');
122
- return { head: t(c.querySelector('.hm-sch')), stage: t(c.querySelector('.hm-sch > b')), of: t(c.querySelector('.hm-sch .of')), bars: c.querySelectorAll('.hm-bars i').length, now: c.querySelectorAll('.hm-bars i.now').length,
123
- rows: [...c.querySelectorAll('.cz-sl > li')].map((li) => ({ cls: (li.querySelector('.cz-st') || {}).className || '', text: t(li) })), gob: c.querySelectorAll('.cz-gob').length,
124
- cta: !!c.querySelector('[data-hm-cta]'), ov: !!c.querySelector('[data-hm-ov]'), sw: !!c.querySelector('.hi-sw'), tail: t(c.querySelector('.cz-sli.tail')), next: !!c.querySelector('[data-hi-next]'), move: t(c.querySelector('[data-hi-move]')) };
125
+ const c = document.querySelector(v + ' .iv-sc'); const t = (n) => (n ? n.textContent.replace(/\s+/g, ' ').trim() : '');
126
+ return { head: t(c.querySelector('.iv-sch')), stage: t(c.querySelector('.iv-sch > b')), where: t(c.querySelector('.iv-sch .iv-r')), bars: c.querySelectorAll('.iv-lad i').length, now: c.querySelectorAll('.iv-lad i.now').length,
127
+ titles: [...c.querySelectorAll('.iv-lad i')].map((i) => i.title), steps: document.querySelectorAll(v + ' .cz-sl').length, pri: document.querySelectorAll(v + ' [data-iv-primary]').length,
128
+ cta: !!document.querySelector(v + ' [data-hm-cta]'), ov: !!document.querySelector(v + ' [data-hm-ov]'), sw: !!c.querySelector('.hi-sw'), tail: t(c.querySelector('.iv-nx')), next: !!c.querySelector('[data-iv-next]'), ms: !!c.querySelector('.iv-nx .iv-nd.ms'), kr: t(c.querySelector('.iv-nx .iv-kr')) };
125
129
  }, V);
126
130
 
127
131
  /* D1 a desktop: the Build stage of the fixture (the contract waits for you, a Jira ticket open, Deliver next) */
128
132
  {
129
133
  const A = await open(), p = A.page;
130
- ok('D1 the initiative\'s page draws the stage card D', A.up);
134
+ ok('D1 the initiative\'s page draws the one view\'s stage card', A.up);
131
135
  const c = await card(p);
132
- ok('D1 the header: the stage and "N of M done"', c.stage === 'Build' && /^\d+ of \d+ done$/.test(c.of), JSON.stringify(c));
136
+ ok('D1 the header names the stage', c.stage === 'Build', JSON.stringify(c));
133
137
  ok('D1 one bar a stage of the workflow, the current one marked', c.bars === 8 && c.now === 1, JSON.stringify(c));
134
- { const tt = await p.evaluate(() => [...document.querySelectorAll('.hm-scbars i')].map((i) => i.getAttribute('title') || ''));
135
- ok('D1 every bar names its stage on hover (the current one says now)', tt.length === 8 && tt.every(Boolean) && tt.some((x) => /^Build · now$/.test(x)), JSON.stringify(tt)); }
136
- ok('D1 the old CTA button, the C overview tile and the switch are gone from the card', !c.cta && !c.ov && !c.sw, JSON.stringify(c));
137
- ok('D1 the PM\'s step comes first with the one blue go button', c.gob === 1 && /\bnow\b/.test(c.rows.find((r) => !/cz-fold/.test(r.cls)).cls), JSON.stringify(c.rows));
138
- ok('D1 the Jira step is owned by Jira, with its ticket bar', await p.evaluate((v) => { const j = document.querySelector(v + ' .cz-jb'); return !!j && !!j.closest('.cz-st').querySelector('.cz-own.j'); }, V));
139
- ok('D1 the last node is ◆ Deliver: the KR it moves, by the board\'s name, it waits for you, and it has no moves-on-by-itself icon', c.next && /Deliver/.test(c.tail) && /Moves KR 1\.1\. Waits for you/.test(c.tail) && await p.evaluate((v) => !!document.querySelector(v + ' .cz-sli.tail .cz-ms') && !document.querySelector(v + ' .cz-sli.tail .cz-auto'), V), c.tail);
140
- ok('D1 with no session at work, no spinner', !(await p.evaluate((v) => !!document.querySelector(v + ' .cz-nd.run'), V)));
141
- await shot(p, 'desk-build', V + ' .hm-sc');
142
- if (await p.evaluate((v) => !!document.querySelector(v + ' [data-hm-done]'), V)) {
143
- const before = (await card(p)).rows.length;
144
- await p.click(V + ' [data-hm-done]');
145
- ok('D1 the done steps open from their one line', await until(async () => (await card(p)).rows.length > before && await p.evaluate((v) => document.querySelector(v + ' [data-hm-done]').getAttribute('aria-expanded') === 'true', V)));
146
- await p.click(V + ' [data-hm-done]');
147
- }
138
+ ok('D1 every bar names its stage on hover (the current one says now)', c.titles.length === 8 && c.titles.every(Boolean) && c.titles.some((x) => /^Build · now$/.test(x)), JSON.stringify(c.titles));
139
+ ok('D1 the old CTA button, the C overview tile, the switch and the step list are gone from the card; at most one primary on the page', !c.cta && !c.ov && !c.sw && c.steps === 0 && c.pri <= 1, JSON.stringify(c));
140
+ ok('D1 the last line is ◆ Deliver, with the KR it moves, by the board\'s name', c.next && /^Deliver/.test(c.tail) && c.ms && c.kr === 'KR 1.1', c.tail);
141
+ await shot(p, 'desk-build', V + ' .iv-sc');
148
142
  // the move popover opens under the next-stage line
149
- await p.click(V + ' [data-hi-next]');
150
- const pop = await until(() => p.evaluate((v) => { const el = document.querySelector('.hi-pop'); const a = document.querySelector(v + ' [data-hi-next]'); if (!el || !a) return null; const r = el.getBoundingClientRect(), ar = a.getBoundingClientRect();
143
+ await p.click(V + ' [data-iv-next]');
144
+ const pop = await until(() => p.evaluate((v) => { const el = document.querySelector('.hi-pop'); const a = document.querySelector(v + ' [data-iv-next]'); if (!el || !a) return null; const r = el.getBoundingClientRect(), ar = a.getBoundingClientRect();
151
145
  return { sheet: el.classList.contains('sheet'), text: el.textContent.replace(/\s+/g, ' ').trim(), under: r.top >= ar.bottom - 1, sw: !!el.querySelector('[data-hi-auto]'), go: !!el.querySelector('[data-hi-go]'), back: !!el.querySelector('[data-hi-goback]'), exp: a.getAttribute('aria-expanded') }; }, V));
152
146
  ok('D2 a press on the next stage opens a popover under the line on a desktop, not a sheet', pop && !pop.sheet && pop.under && pop.exp === 'true', JSON.stringify(pop));
153
147
  ok('D2 it says the next stage and why; a milestone has no switch and says it never moves in by itself', pop && /^Next: ?Deliver/.test(pop.text) && !pop.sw && /never moves into the Deliver milestone by itself/.test(pop.text), JSON.stringify(pop));
@@ -156,7 +150,7 @@ async function pure() {
156
150
  await p.click('.hi-pop [data-hi-go]');
157
151
  ok('D2 Move now with open steps asks for a note first (Move anyway), and moves nothing yet', await until(() => p.evaluate(() => !!document.querySelector('.hi-pop [data-hi-go]') && /Move anyway/.test(document.querySelector('.hi-pop').textContent) && !!document.querySelector('.hi-pop #hiNote'))) && !A.posts.some((x) => x.path === '/api/boards/move'));
158
152
  await p.click('.hi-pop [data-hi-x]');
159
- await p.click(V + ' [data-hi-next]');
153
+ await p.click(V + ' [data-iv-next]');
160
154
  await until(() => p.evaluate(() => !!document.querySelector('.hi-pop [data-hi-goback]')));
161
155
  await p.click('.hi-pop [data-hi-goback]');
162
156
  ok('D2 Back asks for a reason', await until(() => p.evaluate(() => /Back a stage/.test((document.querySelector('.hi-pop') || {}).textContent || '') && document.querySelector('.hi-pop [data-hi-go]').disabled)));
@@ -167,17 +161,16 @@ async function pure() {
167
161
 
168
162
  /* D3 the phone, dark: Discover, Plan next (moves on by itself), an agent at work, over its usual time */
169
163
  {
170
- const since = new Date(Date.now() - 9 * 864e5).toISOString().slice(0, 10);
164
+ const DB = boardAt('Discover'), since = new Date(Date.parse(DB.today + 'T12:00:00Z') - 9 * 864e5).toISOString().slice(0, 10); // 9 days before the board's own day
171
165
  const sessions = [{ id: 's1', name: 'chat: Claude drafts the stakeholder note', agent: 'claude', state: 'running', shown: 'working', origin: 'chat:init:self-serve-v2', created: new Date(Date.now() - 6 * 6e4).toISOString(), hx: { title: 'Claude drafts the stakeholder note' } }];
172
166
  const trail = { ok: true, items: { 'self-serve-v2': { since } }, usual: { discover: { n: 5, days: 7 } }, usualBy: {} };
173
- const A = await open({ w: 390, h: 844, theme: 'dark', model: SCEN.discover(), sessions, trail }), p = A.page;
167
+ const A = await open({ w: 390, h: 844, theme: 'dark', model: SCEN.discover(), board: DB, sessions, trail }), p = A.page;
174
168
  ok('D3 the phone draws the same card', A.up);
175
169
  const c = await card(p);
176
- ok('D3 a session at work: a spinner with "Running · N min" and Claude\'s avatar', await p.evaluate((v) => { const n = document.querySelector(v + ' .cz-nd.run'); return !!n && /Running · \d+ min/.test(n.closest('.cz-st').textContent) && !!n.closest('.cz-st').querySelector('.cz-own.c'); }, V), JSON.stringify(c.rows));
177
- ok('D3 the clock: "9 of ~7 days", amber when over', await p.evaluate((v) => { const t = document.querySelector(v + ' .hm-sct'); return !!t && /9 of ~7 days/.test(t.textContent) && t.classList.contains('over'); }, V), c.head);
178
- ok('D3 the last node is Plan with the moves-on-by-itself icon', /Plan/.test(c.tail) && await p.evaluate((v) => !!document.querySelector(v + ' .cz-sli.tail .cz-auto'), V), c.tail);
170
+ ok('D3 the clock: "day 9 of ~7", amber when over', await p.evaluate((v) => { const t = document.querySelector(v + ' .iv-sch .iv-r span.w'); return !!t && /^day 9 of ~7$/.test(t.textContent); }, V), c.head);
171
+ ok('D3 the last line is Plan, the next stage', /^Plan/.test(c.tail) && c.next && !c.ms, c.tail);
179
172
  await shot(p, 'phone-discover');
180
- await p.click(V + ' [data-hi-next]');
173
+ await p.click(V + ' [data-iv-next]');
181
174
  const sh = await until(() => p.evaluate(() => { const el = document.querySelector('.hi-pop'); if (!el) return null; const s = el.querySelector('[data-hi-auto]'); const r = s && s.getBoundingClientRect(), tr = s && getComputedStyle(s, '::before');
182
175
  return { sheet: el.classList.contains('sheet'), text: el.textContent.replace(/\s+/g, ' ').trim(), sw: r ? { w: Math.round(r.width), h: Math.round(r.height), track: tr.height, trackBg: tr.backgroundColor, blue: (() => { const x = document.createElement('i'); x.style.backgroundColor = 'var(--cz-blue)'; document.body.appendChild(x); const c = getComputedStyle(x).backgroundColor; x.remove(); return c; })(), bg: getComputedStyle(s).backgroundColor } : null, on: s && s.getAttribute('aria-checked') }; }));
183
176
  ok('D4 on the phone the next stage opens a sheet', sh && sh.sheet, JSON.stringify(sh));
@@ -194,19 +187,34 @@ async function pure() {
194
187
  { const sessions = [{ id: 's9', name: 'chat: Loose notes chat', agent: 'claude', state: 'running', shown: 'working', origin: 'chat:loose-9', created: new Date().toISOString(), hx: { title: 'Loose notes chat' } }];
195
188
  const A = await open({ sessions }), p = A.page;
196
189
  const row = await until(() => p.evaluate(() => [...document.querySelectorAll('#hmList button, #hmList [role="button"], #hmList a')].some((b) => /Loose notes chat/.test(b.textContent))), 15000);
197
- if (row) await p.locator('#hmList').getByText('Loose notes chat').first().click();
190
+ if (row) await p.evaluate(() => [...document.querySelectorAll('#hmList button')].find((b) => /Loose notes chat/.test(b.textContent)).click()); // a press on the row's own button
198
191
  const gone = await until(() => p.evaluate(() => !document.querySelector('#czViewer [data-hi-v="page"]')), 6000);
199
192
  ok('D6 a loose session opened from the list closes the initiative page in the Viewer', A.up && row && gone, JSON.stringify({ up: A.up, row, gone }));
200
193
  ok('D6 the page raised no error', A.errors.length === 0, A.errors.join(' | '));
201
194
  await A.ctx.close(); }
202
- /* D5 every step done, a milestone next: the last node is the one primary, "Move to ◆ Deliver" */
195
+ /* D7 a session opened from the list takes the Viewer back to its own initiative's page from anywhere inside it (Wawan, 2026-10-25,
196
+ * batch 6 item 4): the Documents or Tasks view the page drilled into does not stay beside the session */
197
+ { const sessions = [{ id: 's7', name: 'chat: Tender plan chat', agent: 'claude', state: 'running', shown: 'working', initiative: 'self-serve-v2', created: new Date().toISOString(), hx: { title: 'Tender plan chat' } }];
198
+ const A = await open({ sessions }), p = A.page;
199
+ const drill = await until(() => p.evaluate(() => { const b = document.querySelector('#czViewer [data-iv-docs]'); if (!b) return null; b.click(); return 'docs'; }), 15000);
200
+ const left = await until(() => p.evaluate(() => !document.querySelector('#czViewer [data-hi-v="page"]')), 6000);
201
+ await p.evaluate(() => { const k = document.querySelector('#hmList [data-hm-kids="i:self-serve-v2"]'); if (k && k.getAttribute('aria-expanded') !== 'true') k.click(); }); // its sessions unfold under it
202
+ const row = await until(() => p.evaluate(() => [...document.querySelectorAll('#hmList button, #hmList [role="button"], #hmList a')].some((b) => /Tender plan chat/.test(b.textContent))), 15000);
203
+ if (row) await p.evaluate(() => [...document.querySelectorAll('#hmList button')].find((b) => /Tender plan chat/.test(b.textContent)).click());
204
+ const back = await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-hi-v="page"]')), 6000);
205
+ ok('D7 a session of the initiative brings its page back from the ' + (drill || '?') + ' view', A.up && drill && left && row && back, JSON.stringify({ up: A.up, drill, left, row, back }));
206
+ ok('D7 the page raised no error', A.errors.length === 0, A.errors.join(' | '));
207
+ await A.ctx.close(); }
208
+ /* D5 every step done, a milestone next: the next stage is ◆ Deliver; its sheet moves it with nothing open, and says so with Undo */
203
209
  {
204
210
  const A = await open({ model: SCEN.ready() }), p = A.page;
205
211
  const c = await card(p);
206
- ok('D5 every step done: the steps fold to one line and the last node is "Move to ◆ Deliver"', A.up && c.move === 'Move to Deliver' && await p.evaluate((v) => !!document.querySelector(v + ' [data-hi-move] .cz-ms'), V) && c.gob === 0 && c.rows.filter((r) => !/cz-fold|mvr/.test(r.cls)).length === 0, JSON.stringify(c));
207
- await shot(p, 'desk-ready', V + ' .hm-sc');
208
- await p.click(V + ' [data-hi-move]');
209
- ok('D5 a press moves it to Deliver with nothing open, and says so with Undo', await until(() => A.posts.some((x) => x.path === '/api/boards/move' && x.body.to === 'Deliver')) && await until(() => p.evaluate(() => /Undo/.test((document.querySelector('#hiToast') || {}).textContent || ''))), JSON.stringify(A.posts));
212
+ ok('D5 every step done: the last line is ◆ Deliver', A.up && /^Deliver/.test(c.tail) && c.ms, JSON.stringify(c));
213
+ await shot(p, 'desk-ready', V + ' .iv-sc');
214
+ await p.click(V + ' [data-iv-next]');
215
+ await until(() => p.evaluate(() => !!document.querySelector('.hi-pop [data-hi-go]')));
216
+ await p.click('.hi-pop [data-hi-go]');
217
+ ok('D5 Move now moves it to Deliver with nothing open, and says so with Undo', await until(() => A.posts.some((x) => x.path === '/api/boards/move' && x.body.to === 'Deliver')) && await until(() => p.evaluate(() => /Undo/.test((document.querySelector('#hiToast') || {}).textContent || ''))), JSON.stringify(A.posts));
210
218
  ok('D5 the page raised no error', A.errors.length === 0, A.errors.join(' | '));
211
219
  await A.ctx.close();
212
220
  }