create-pmos 0.843.0 → 0.845.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.
@@ -11,6 +11,7 @@
11
11
  * title }], projects: [Jira project key] (empty = every project), today: 'YYYY-MM-DD', me, pmName }
12
12
  * row: { uid, id, src: jira|pmos, key, title, ini, iniTitle, who, state: To do|In progress|In review|Done, due, late (days), moved (other
13
13
  * sprints the ticket was in), url, open (the row is in the Backlog's task list, so it opens as a task) }
14
+ * row.epic: { key, name, url } | null, the Jira ticket's epic; summary: summaryOf(rows), the Summary card's counts (board TbSprint)
14
15
  * nextSprintOf(R, projects) → { name, label, start, end } | null the earliest future sprint (the Backlog pulls work into it)
15
16
  */
16
17
  const BL = require('./backlog.js');
@@ -21,6 +22,23 @@ const str = (v, n) => String(v == null ? '' : v).slice(0, n);
21
22
  const labelOf = (name) => { const m = /(sprint\s*\d+)\s*$/i.exec(String(name || '')); return m ? m[1].replace(/^s/, 'S') : String(name || ''); };
22
23
  const stateOfJira = (rd) => (rd.category === 'done' ? 'Done' : rd.category === 'doing' ? (/review/i.test(rd.status || '') ? 'In review' : 'In progress') : 'To do');
23
24
  const OPEN = new Set(['To do', 'In progress', 'In review']);
25
+ /** The Jira link of another key on the same site as a reading's link: https://x.atlassian.net/browse/A-1 → …/browse/<key>. */
26
+ const urlOf = (key, rd) => { const m = /^(https:\/\/[^/]+\/browse\/)[A-Z][A-Z0-9_]*-\d+$/i.exec(String((rd && rd.url) || '')); return m ? m[1] + String(key).toUpperCase() : null; };
27
+ const tabOf = (state) => (state === 'Done' ? 'done' : state === 'To do' ? 'todo' : 'doing');
28
+ /** The sprint in three counts and who holds what (board TbSprint, Summary): { todo, doing, done, all, by: [{ who, todo, doing, open }] }.
29
+ * by: the holders of open work, most first; work with no owner is one entry with who '' (no one), last. Done work is in no one's hands. */
30
+ function summaryOf(rows) {
31
+ const s = { todo: 0, doing: 0, done: 0, all: 0, by: [] }, m = new Map();
32
+ for (const r of rows || []) {
33
+ const k = tabOf(r.state); s[k]++; s.all++;
34
+ if (k === 'done') continue;
35
+ const w = String(r.who || '');
36
+ if (!m.has(w)) m.set(w, { who: w, todo: 0, doing: 0, open: 0 });
37
+ const e = m.get(w); e[k]++; e.open++;
38
+ }
39
+ s.by = [...m.values()].sort((a, b) => (!a.who) - (!b.who) || b.open - a.open || a.who.localeCompare(b.who));
40
+ return s;
41
+ }
24
42
 
25
43
  function sprintsNowOf(I) {
26
44
  const R = I.R instanceof Map ? I.R : new Map();
@@ -35,6 +53,16 @@ function sprintsNowOf(I) {
35
53
  if (/^(pm|you|me)$/i.test(o) || /^pm:/i.test(o) || (me && o.toLowerCase() === me)) return I.pmName || 'You';
36
54
  return BL.firstName(o);
37
55
  };
56
+ // the ticket's epic: the Backlog task's own, else the parent the reading names (lib/jira-status.js parent, parentName); its name from
57
+ // the epic's own reading when there is one. A parent that is not an epic (a sub-task's story) is not an epic.
58
+ const epicOf = (t, rd) => {
59
+ if (t && t.epic && t.epic.key) return { key: str(t.epic.key, 40), name: str(t.epic.name, 120), url: urlOf(t.epic.key, rd) };
60
+ const k = rd && rd.parent ? String(rd.parent).toUpperCase() : '';
61
+ if (!k) return null;
62
+ const p = R.get(k);
63
+ if (p && p.type && !/^epic$/i.test(p.type)) return null;
64
+ return { key: str(k, 40), name: str((p && p.summary) || rd.parentName || '', 120), url: urlOf(k, rd) };
65
+ };
38
66
  const lateOf = (due, state) => { const d = dayNum(due); return d != null && t0 != null && d < t0 && OPEN.has(state) ? t0 - d : 0; };
39
67
  const by = new Map();
40
68
  for (const rd of R.values()) {
@@ -51,8 +79,9 @@ function sprintsNowOf(I) {
51
79
  const ini = t ? t.ini : null;
52
80
  const moved = Array.isArray(rd.sprints) ? rd.sprints.filter((s) => s && s.name && s.name !== name).length : 0;
53
81
  const due = t ? t.due : null;
82
+ const epic = epicOf(t, rd);
54
83
  sp.rows.push({ uid: t ? t.ws + '|' + t.board + '|' + t.id : key, id: key, src: 'jira', key, title: str((t && t.title) || rd.summary || key, 300), ini, iniTitle: ini && iniBy.has(ini) ? str(iniBy.get(ini).title, 160) : '',
55
- who: t ? t.who : whoOf(rd.assignee), state, due, late: lateOf(due, state), moved, url: (t && t.url) || rd.url || null, open: !!t });
84
+ who: t ? t.who : whoOf(rd.assignee), state, due, late: lateOf(due, state), moved, url: (t && t.url) || rd.url || null, open: !!t, epic });
56
85
  }
57
86
  for (const sp of by.values()) {
58
87
  const s = dayNum(sp.start), e = dayNum(sp.end);
@@ -68,12 +97,12 @@ function sprintsNowOf(I) {
68
97
  const state = w.status === 'Done' ? 'Done' : OPEN.has(w.status) ? w.status : 'To do';
69
98
  const ini = iniBy.has(w.ini) ? w.ini : null;
70
99
  sp.rows.push({ uid: t ? t.ws + '|' + t.board + '|' + t.id : id, id, src: 'pmos', key: '', title: str(w.title, 300), ini, iniTitle: ini ? str(iniBy.get(ini).title, 160) : '',
71
- who: t ? t.who : whoOf(w.owner), state, due: w.end || null, late: lateOf(w.end, state), moved: 0, url: null, open: !!t });
100
+ who: t ? t.who : whoOf(w.owner), state, due: w.end || null, late: lateOf(w.end, state), moved: 0, url: null, open: !!t, epic: null });
72
101
  }
73
102
  }
74
103
  return [...by.values()].map((sp) => {
75
104
  const jira = sp.rows.filter((r) => r.src === 'jira').length;
76
- return { ...sp, jira, other: sp.rows.length - jira, done: sp.rows.filter((r) => r.state === 'Done').length, total: sp.rows.length };
105
+ return { ...sp, jira, other: sp.rows.length - jira, done: sp.rows.filter((r) => r.state === 'Done').length, total: sp.rows.length, summary: summaryOf(sp.rows) };
77
106
  }).sort((a, b) => b.total - a.total || a.name.localeCompare(b.name));
78
107
  }
79
108
 
@@ -93,4 +122,10 @@ function nextSprintOf(R, projects) {
93
122
  return [...by.values()].sort((a, b) => (a.start || '9999').localeCompare(b.start || '9999') || a.name.localeCompare(b.name))[0] || null;
94
123
  }
95
124
 
96
- module.exports = { sprintsNowOf, nextSprintOf, labelOf };
125
+ /** "By person: Wawan 4 to do · Suhas 1 to do, 1 in progress · no one 5"; '' when nobody holds open work (pm/bd-sprint-ds.js byText too). */
126
+ function byTextOf(S) {
127
+ const one = (e) => (e.who ? [e.todo ? e.todo + ' to do' : '', e.doing ? e.doing + ' in progress' : ''].filter(Boolean).join(', ') : String(e.open));
128
+ return S && S.by && S.by.length ? 'By person: ' + S.by.map((e) => (e.who || 'no one') + ' ' + one(e)).join(' · ') : '';
129
+ }
130
+
131
+ module.exports = { sprintsNowOf, nextSprintOf, labelOf, summaryOf, byTextOf };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.843.0",
3
+ "version": "0.845.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.843.0",
9
+ "version": "0.845.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.843.0",
3
+ "version": "0.845.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -62,11 +62,10 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
62
62
  ok('R3 a paused note offers Resume in its recording line, with no Waiting for design marker', await until(async () => !!(await p.$('#czViewer .czs-sum [data-a="resume"]')) && !(await p.$('#czViewer [data-cz-placeholder]'))));
63
63
  await tap(p, '.czs-sum [data-a="resume"]');
64
64
  ok('R3 Resume records again', await until(() => posted(A.S, '/api/notes/record').length === 2));
65
- await until(async () => !!(await p.$('#czViewer .czs-sum [data-a="stop"]')));
66
- await tap(p, '.czs-sum [data-a="stop"]');
67
- ok('R3 Stop asks first', await until(async () => /Stop for good/.test(await text(p))));
68
- await tap(p, '[data-a="stopgo"]');
69
- ok('R3 Stop and write the notes stops the recorder', await until(() => posted(A.S, '/api/notes/stop').length === 1));
65
+ // Resume's answer redraws the card: a press that lands on the old card, or just before the redraw, is lost. Press again until it takes.
66
+ const pressUntil = (sel, done, ms = 20000) => until(async () => { if (await done()) return true; await tap(p, sel).catch(() => {}); return until(done, 2000); }, ms);
67
+ ok('R3 Stop asks first', await pressUntil('.czs-sum [data-a="stop"]', async () => /Stop for good/.test(await text(p))));
68
+ ok('R3 Stop and write the notes stops the recorder', await pressUntil('[data-a="stopgo"]', () => posted(A.S, '/api/notes/stop').length >= 1) && posted(A.S, '/api/notes/stop').length === 1, JSON.stringify(posted(A.S, '/api/notes/stop')));
70
69
  ok('R3 no page error', A.errors.length === 0, A.errors.join(' | '));
71
70
  await A.ctx.close();
72
71
 
@@ -14,7 +14,7 @@ import { canEdit } from './inline-fields.js'; // a task's sprint and priority,
14
14
 
15
15
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
16
16
  const SV = (d, n = 16) => `<svg class="pm-ic" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
17
- const I = { star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01', down: 'M7 10l5 5 5-5',
17
+ const I = { out: 'M14 5h5v5M19 5l-8 8M17 14v5H5V7h5', star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01', down: 'M7 10l5 5 5-5',
18
18
  sprint: 'M4 12h11M11 8l4 4-4 4M19 6v12', flag: 'M6 21V4M6 4h11l-2 4 2 4H6' };
19
19
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
20
20
  const DAY = 864e5;
@@ -191,6 +191,26 @@ export function captureOf(line, inis) {
191
191
  return { title: text, ini: null };
192
192
  }
193
193
 
194
+ /** A Jira link of another key on the same site as a task's own link (…/browse/A-1 → …/browse/<key>); null when the task has none. */
195
+ const linkOf = (key, url) => { const m = /^(https:\/\/[^/]+\/browse\/)[A-Z][A-Z0-9_]*-\d+$/i.exec(String(url || '')); return m ? m[1] + String(key).toUpperCase() : null; };
196
+ /** The Ticket cell (board TbBacklog): the Jira key, a link to the ticket; a task outside Jira says so. */
197
+ export function ticketHtml(t) {
198
+ if (!t.key) return '<span class="pm-chip">Not in Jira</span>';
199
+ return t.url ? `<a class="pm-meta code wk-tk" href="${esc(t.url)}" target="_blank" rel="noopener" data-splink title="Open ${esc(t.key)} in Jira">${esc(t.key)}${SV(I.out, 12)}</a>` : `<span class="pm-meta code">${esc(t.key)}</span>`;
200
+ }
201
+ /** The epic most of a group's tickets sit under (board TbBacklog: on the initiative's group line), with a link when a ticket has one. */
202
+ export function epicOfGroup(rows) {
203
+ const m = new Map();
204
+ for (const t of rows || []) if (t.epic && t.epic.key) { const e = m.get(t.epic.key) || { key: t.epic.key, name: t.epic.name || '', url: linkOf(t.epic.key, t.url), n: 0 }; e.n++; if (!e.url) e.url = linkOf(t.epic.key, t.url); m.set(t.epic.key, e); }
205
+ return [...m.values()].sort((a, b) => b.n - a.n || a.key.localeCompare(b.key))[0] || null;
206
+ }
207
+ /** The epic as a link: its key and name; '' with no epic. */
208
+ export function epicHtml(e) {
209
+ if (!e || !e.key) return '';
210
+ const inner = `<b class="code">${esc(e.key)}</b>${e.name ? ' ' + esc(e.name) : ''}`;
211
+ return e.url ? ` <a class="wk-ep" href="${esc(e.url)}" target="_blank" rel="noopener" data-splink title="Open epic ${esc(e.key)} in Jira">${inner}</a>` : ` <span class="wk-ep">${inner}</span>`;
212
+ }
213
+
194
214
  /** The Backlog block. o: { tab, group, menu, today, rank (number by id), sel: Set of uids, picking, act(t) → the row's action html,
195
215
  * stateOf(t) → { text, tone } for PMOS's own states, groupsPmos(rows) → [{ k, n, rows, yes }], mode (the kind-of-work line's html) } */
196
216
  export function tableHtml(order, o = {}) {
@@ -213,9 +233,9 @@ export function tableHtml(order, o = {}) {
213
233
  for (const g of G) { const e = whole.get(g.k); g.sub = `${plural(e.n, 'item', 'items')} · ${e.r} ready`; }
214
234
  }
215
235
  const drag = group !== 'pmos';
216
- const body = G.map((g) => (g.n ? `<tr class="wk-g"><td colspan="7"><div class="pm-group"><b>${esc(g.n)}</b>${g.sub ? ` <span class="pm-meta">${esc(g.sub)}</span>` : ''}${g.yes || ''}</div></td></tr>` : '')
236
+ const body = G.map((g) => (g.n ? `<tr class="wk-g"><td colspan="7"><div class="pm-group"><b>${esc(g.n)}</b>${g.sub ? ` <span class="pm-meta">${esc(g.sub)}</span>` : ''}${group === 'ini' ? epicHtml(epicOfGroup(g.rows)) : ''}${g.yes || ''}</div></td></tr>` : '')
217
237
  + g.rows.map((t) => rowHtml(t, o, drag)).join('')).join('');
218
- const table = R.length ? `<table class="pm-table wk-bkt${o.picking ? ' picking' : ''}"><thead><tr><th class="wk-rk">Rank</th><th>Item</th><th>Who</th><th>State</th><th>Source</th><th>Last change</th><th class="wk-ac" aria-label="Actions"></th></tr></thead><tbody>${body}</tbody></table>`
238
+ const table = R.length ? `<table class="pm-table wk-bkt${o.picking ? ' picking' : ''}"><thead><tr><th class="wk-rk">Rank</th><th>Item</th><th>Who</th><th>State</th><th>Ticket</th><th>Last change</th><th class="wk-ac" aria-label="Actions"></th></tr></thead><tbody>${body}</tbody></table>`
219
239
  : `<p class="pm-meta">${order.length ? 'Nothing here.' : 'Nothing waits outside the sprint.'}</p>`;
220
240
  const foot = R.length && drag ? '<p class="pm-meta">Drag a row to change its rank. The rank is one list across initiatives; groups only show where each item belongs.</p>' : '';
221
241
  return `<section class="pm-block wk-blk wk-bk" aria-label="Backlog"><div class="head"><h2 class="pm-h">Backlog</h2><span class="sp"></span>${tabs}${menu}${tune}</div>${cap}${o.above || ''}${o.said || ''}${table}${foot}${o.mode || ''}</section>`;
@@ -226,7 +246,7 @@ function rowHtml(t, o, drag) {
226
246
  const who = pmosHas(t) ? '<span class="pm-star">✦</span> PMOS' : t.who ? esc(t.who) : '<span class="pm-meta">no one</span>';
227
247
  const ps = o.stateOf ? o.stateOf(t) : null;
228
248
  const state = ps ? `<span class="pm-badge${ps.tone === 'late' ? ' alert' : ' blue'}" title="${esc(ps.title || ps.text)}">${esc(ps.text)}</span>` : `<span class="pm-badge${ready ? ' blue' : ''}">${ready ? 'Ready' : 'Needs detail'}</span>`;
229
- const src = t.key ? `<span class="pm-meta code">${esc(t.key)}</span>` : '<span class="pm-chip">Not in Jira</span>';
249
+ const src = ticketHtml(t);
230
250
  const n = o.rank ? o.rank.get(t.id) : null;
231
251
  // Sprint and Priority in the row (inline-sprint-priority): an open PMOS task only, when the page wires them (o.inline); a set priority shows
232
252
  const ib = (attr, label, d) => `<button type="button" class="pm-btn" ${attr}="${esc(u)}" aria-haspopup="menu" aria-label="${esc(label)}" title="${esc(label)}">${SV(d, 14)}</button>`;
@@ -2,11 +2,13 @@
2
2
  * WorkSprintDS). Pure: HTML from data, no state and no fetch. pm/bd-sprint.js keeps the state (the tab, the group, the goal being edited)
3
3
  * and the presses.
4
4
  *
5
- * · cardHtml(N, o): the one Summary card. The sprint, its end and what it holds ("21 Jira tickets and 7 tasks outside Jira"), "11 of 28
6
- * done" with a bar, then four columns: Sprint goal (o.goal, editable), In progress, To do and Done, each with its count and top tasks;
7
- * then one Suggestion (o.sug). No other metric: Wawan was not confident in them.
5
+ * · cardHtml(N, o): the right column (board TbSprint, page balanced, 2026-11-25): the Summary card (the sprint, how much it holds, its
6
+ * end, one bar of To do, In progress and Done, the three counts and who holds what), the Sprint goal (o.goal, editable) and PMOS
7
+ * suggests (o.sug). No other metric: Wawan was not confident in them.
8
+ * · stripHtml(N, o): the four counts over the page: To do, In progress, Done "n of m", No initiative.
8
9
  * · tasksHtml(N, o): the Tasks Table. Tabs All / To do / In progress / Done (no Late tab), the Group menu (Initiative by default, Who,
9
- * State, Theme, none), columns Task, Who, State, Source (the Jira key, or "Not in Jira") and Due. Late = the due date has passed and the
10
+ * State, Theme, none), columns Task, Who, State, Ticket (the Jira key, a link, or "Not in Jira") and Epic (its key and name).
11
+ * The due date and its badges follow the title. Late = the due date has passed and the
10
12
  * task is not done: a red badge after the date. "Moved twice" is a plain badge.
11
13
  * N is one sprint of GET /api/backlog's sprintNow (lib/sprint-now.js): all work in the sprint's dates, Jira and not. */
12
14
  import { sugHtml } from './bd-stands.js';
@@ -14,10 +16,11 @@ import { sugHtml } from './bd-stands.js';
14
16
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
15
17
  const SV = (d, n = 16) => `<svg class="pm-ic" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
16
18
  const I = { star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', pen: 'M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4', read: 'M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7',
17
- down: 'M7 10l5 5 5-5', ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18' };
19
+ out: 'M14 5h5v5M19 5l-8 8M17 14v5H5V7h5', down: 'M7 10l5 5 5-5', ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18' };
18
20
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
19
21
  export const dayText = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
20
22
  const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
23
+ const SPARK = '✦';
21
24
 
22
25
  export const TABS = [['all', 'All'], ['todo', 'To do'], ['doing', 'In progress'], ['done', 'Done']];
23
26
  export const GROUPS = [['ini', 'Initiative'], ['who', 'Who'], ['state', 'State'], ['theme', 'Theme'], ['none', 'None']];
@@ -36,24 +39,105 @@ export function holdsText(N) {
36
39
  /** Due first (no date last), then the title. */
37
40
  const byDue = (a, b) => (a.due || '9999').localeCompare(b.due || '9999') || a.title.localeCompare(b.title);
38
41
 
39
- /** The Summary card. o: { label (the sprint's name or its picker), goal: { lines: [text], mine, editing, edit (the textarea's html),
40
- * newer (html) }, read: { old, title }, sug: the Suggestion's html } */
42
+ /** The sprint in three counts and who holds what: the server's summary (lib/sprint-now.js summaryOf), else the same from the rows. */
43
+ export function summaryOf(N) {
44
+ if (N && N.summary) return N.summary;
45
+ const s = { todo: 0, doing: 0, done: 0, all: 0, by: [] }, m = new Map();
46
+ for (const r of N ? N.rows : []) {
47
+ const k = tabOfRow(r); s[k]++; s.all++;
48
+ if (k === 'done') continue;
49
+ const w = String(r.who || '');
50
+ if (!m.has(w)) m.set(w, { who: w, todo: 0, doing: 0, open: 0 });
51
+ const e = m.get(w); e[k]++; e.open++;
52
+ }
53
+ s.by = [...m.values()].sort((a, b) => (!a.who) - (!b.who) || b.open - a.open || a.who.localeCompare(b.who));
54
+ return s;
55
+ }
56
+ /** "By person: Wawan 4 to do · Suhas 1 to do, 1 in progress · no one 5". Only what each one holds; '' when nobody holds open work. */
57
+ export function byText(S) {
58
+ const one = (e) => (e.who ? [e.todo ? e.todo + ' to do' : '', e.doing ? e.doing + ' in progress' : ''].filter(Boolean).join(', ') : String(e.open));
59
+ return S.by.length ? 'By person: ' + S.by.map((e) => (e.who || 'no one') + ' ' + one(e)).join(' · ') : '';
60
+ }
61
+ /** "11 tickets" when all the work is in Jira, else "11 tasks". */
62
+ const workText = (N, n) => plural(n, N.other ? 'task' : 'ticket', N.other ? 'tasks' : 'tickets');
63
+ const SEGS = [['todo', 'To do'], ['doing', 'In progress'], ['done', 'Done']];
64
+ const WORD = ['No', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve'];
65
+ const word = (n, low) => { const w = n < WORD.length ? WORD[n] : String(n); return low && n < WORD.length ? w.toLowerCase() : w; };
66
+ /** Whole days from today to the sprint's end, or null (no end, or already past). */
67
+ export function daysLeft(N, today) {
68
+ const t0 = Date.parse(String(today || new Date().toISOString()).slice(0, 10)), t1 = Date.parse(String((N && N.end) || '').slice(0, 10));
69
+ return Number.isFinite(t0) && Number.isFinite(t1) && t1 >= t0 ? Math.round((t1 - t0) / 864e5) : null;
70
+ }
71
+ /** PMOS's one sentence per state (board TbSprint, ✦ under each count), written from the sprint's own rows, never by a model:
72
+ * "Ten of eleven are not started with 6 days left. Five have no owner." → { todo, doing, done }; a state with no work has no sentence. */
73
+ export function sentencesOf(N, o = {}) {
74
+ const R = (N && N.rows) || [], S = summaryOf(N), left = daysLeft(N, o.today), out = { todo: '', doing: '', done: '' };
75
+ const of = (k) => R.filter((r) => tabOfRow(r) === k);
76
+ const lateN = (L) => L.filter((r) => r.late > 0).length, movedN = (L) => L.filter((r) => r.moved >= 2).length;
77
+ const tail = left == null ? '' : left === 0 ? ' on the last day' : ` with ${plural(left, 'day', 'days')} left`;
78
+ if (S.todo) {
79
+ const L = of('todo'), none = L.filter((r) => !r.who).length, late = lateN(L), mv = movedN(L);
80
+ out.todo = (S.todo === S.all ? (S.all === 1 ? 'The only task is not started' : `All ${S.all} are not started`) : `${word(S.todo)} of ${word(S.all, true)} ${S.todo === 1 ? 'is' : 'are'} not started`) + tail + '.'
81
+ + (none ? (none === S.todo && S.todo > 1 ? ' None has an owner.' : ` ${word(none)} ${none === 1 ? 'has' : 'have'} no owner.`) : '')
82
+ + (late ? ` ${word(late)} ${late === 1 ? 'is' : 'are'} past the due date.` : '') + (mv ? ` ${word(mv)} moved from earlier sprints.` : '');
83
+ }
84
+ if (S.doing) {
85
+ const L = of('doing'), late = lateN(L);
86
+ const by = new Map(); for (const r of L) by.set(r.who || '', (by.get(r.who || '') || 0) + 1);
87
+ const holders = [...by.entries()].sort((a, b) => (!a[0]) - (!b[0]) || b[1] - a[1]).map(([w, n]) => (w || 'no one') + (S.doing > 1 ? ' ' + n : ''));
88
+ out.doing = (S.doing === 1 ? `${holders[0].replace(/^no one$/, 'No one')} ${holders[0] === 'no one' ? 'holds' : 'has'} the one under way.` : `${word(S.doing)} under way: ${holders.join(', ')}.`)
89
+ + (late ? ` ${word(late)} ${late === 1 ? 'is' : 'are'} past the due date.` : '');
90
+ }
91
+ if (S.done) {
92
+ const L = of('done'), out1 = L.filter((r) => !r.key).length;
93
+ out.done = `${word(S.done)} of ${word(S.all, true)} done${tail}.` + (out1 && out1 < S.done ? ` ${word(out1)} ${out1 === 1 ? 'was' : 'were'} outside Jira.` : out1 && out1 === S.done ? (S.done === 1 ? ' It was outside Jira.' : ' All were outside Jira.') : '');
94
+ }
95
+ return out;
96
+ }
97
+
98
+ /** The right column of This sprint (board TbSprint, page balanced): the Summary card, the Sprint goal and PMOS suggests, each its own block.
99
+ * o: { label (the sprint's name or its picker), goal: { lines: [text], mine, editing, edit (the textarea's html), newer (html) },
100
+ * read: { old, title }, sug: the Suggestion's html }. '' when the sprint holds no work (zero is silence). */
41
101
  export function cardHtml(N, o = {}) {
42
- const c = countsOf(N), pct = c.all ? Math.round((c.done / c.all) * 1000) / 10 : 0;
43
- const meta = [o.label || esc(N.label || N.name), N.end ? 'ends ' + dayText(N.end) : '', esc(holdsText(N))].filter(Boolean).join(' · ');
102
+ const S = summaryOf(N);
103
+ if (!S.all) return '';
104
+ const meta = [o.label || esc(N.label || N.name), workText(N, S.all), N.end ? 'ends ' + dayText(N.end) : ''].filter(Boolean).join(' · ');
44
105
  const read = o.read ? `<button type="button" class="pm-btn wk-rd${o.read.old ? ' old' : ''}" data-spread aria-label="Read Jira again" title="${esc(o.read.title || 'Read Jira again')}">${SV(I.read)}</button>` : '';
45
- const head = `<div class="head"><h2 class="pm-h-sm pm-row">${SV(I.star).replace('pm-ic', 'pm-ic pm-star')}This sprint</h2><span class="sp"></span><span class="pm-meta wk-spm">${meta}</span>${read}</div>`;
46
- const done = c.all ? `<div class="pm-row wk-spd"><b>${c.done} of ${c.all} done</b><div class="wk-spbar" role="progressbar" aria-label="${c.done} of ${c.all} done" aria-valuenow="${c.done}" aria-valuemin="0" aria-valuemax="${c.all}"><span style="width:${pct}%"></span></div></div>` : '';
106
+ const pct = (n) => Math.round((n / S.all) * 1000) / 10;
107
+ const bar = `<div class="wk-sp3" role="img" aria-label="${S.todo} to do, ${S.doing} in progress, ${S.done} done">${SEGS.filter(([k]) => S[k]).map(([k]) => `<span class="${k}" style="width:${pct(S[k])}%"></span>`).join('')}</div>`;
108
+ const say = sentencesOf(N, { today: o.today });
109
+ const rows = SEGS.map(([k, n]) => `<div class="pm-row wk-sprw"><i class="wk-dot ${k}" aria-hidden="true"></i><span>${n}</span><b>${S[k]}</b></div>`
110
+ + (say[k] ? `<p class="pm-meta wk-spsay"><span class="pm-star" aria-hidden="true">${SPARK}</span> ${esc(say[k])}</p>` : '')).join('');
111
+ const by = byText(S);
112
+ const sum = `<section class="pm-block wk-spsum" aria-label="Summary"><div class="head"><h2 class="pm-h-sm">Summary</h2><span class="sp"></span>${read}</div>`
113
+ + `<p class="pm-meta wk-spm">${meta}</p>${bar}${rows}${by ? `<p class="pm-meta wk-spby">${esc(by)}</p>` : ''}</section>`;
47
114
  const g = o.goal || { lines: [] };
48
- const goal = `<div class="wk-spc1"><div class="pm-row wk-sph"><b>Sprint goal</b><button type="button" class="pm-btn" data-spedit="goals" aria-label="Edit Sprint goal" title="Edit Sprint goal">${SV(I.pen)}</button></div>`
115
+ const goal = `<section class="pm-block wk-spgoal" aria-label="Sprint goal"><div class="head"><h2 class="pm-h-sm">Sprint goal</h2><span class="sp"></span><button type="button" class="pm-btn" data-spedit="goals" aria-label="Edit Sprint goal" title="Edit Sprint goal">${SV(I.pen)}</button></div><div class="wk-spc1">`
49
116
  + (g.editing ? g.edit : g.lines.length ? `<ul>${g.lines.map((t) => `<li>${esc(t)}</li>`).join('')}</ul>` : '<p class="pm-meta">No goal yet. Write one; it can name work outside Jira.</p>')
50
- + (g.editing ? '' : g.newer || (!g.mine && g.lines.length ? '<p class="pm-meta">Drafted from the sprint\'s work. Edit to make it yours.</p>' : '')) + '</div>';
51
- const col = (tab, name) => {
52
- const R = rowsOf(N, tab).slice().sort(byDue).slice(0, 3);
53
- if (!c[tab]) return `<div class="wk-spc1"><div class="pm-row wk-sph"><b>${name}</b></div></div>`;
54
- return `<div class="wk-spc1"><div class="pm-row wk-sph"><b>${name} <span class="pm-meta">${c[tab]}</span></b></div><ul>${R.map((r) => `<li>${esc(r.title)}${movedText(r.moved) ? ` <span class="pm-badge">${movedText(r.moved)}</span>` : ''}</li>`).join('')}</ul></div>`;
55
- };
56
- return `<section class="pm-block wk-sp" aria-label="This sprint">${head}${done}<div class="wk-spcols">${goal}${col('doing', 'In progress')}${col('todo', 'To do')}${col('done', 'Done')}</div>${o.sug || ''}</section>`;
117
+ + (g.editing ? '' : g.newer || (!g.mine && g.lines.length ? '<p class="pm-meta">Drafted from the sprint\'s work. Edit to make it yours.</p>' : '')) + '</div></section>';
118
+ const sug = o.sug ? `<section class="pm-block wk-spsg" aria-label="PMOS suggests"><div class="head"><h2 class="pm-h-sm">PMOS suggests</h2></div>${o.sug}</section>` : '';
119
+ return `<div class="wk-sp wk-spside">${sum}${goal}${sug}</div>`;
120
+ }
121
+
122
+ /** The strip over This sprint (board TbSprint): To do, In progress, Done and No initiative, each a count and one sub-line. o: { today }.
123
+ * A zero sub-line says nothing; No initiative shows only when some work has none. '' when the sprint holds no work. */
124
+ export function stripHtml(N, o = {}) {
125
+ const S = summaryOf(N);
126
+ if (!S.all) return '';
127
+ const R = N.rows || [];
128
+ const noOwner = R.filter((r) => tabOfRow(r) === 'todo' && !r.who).length;
129
+ const first = R.filter((r) => tabOfRow(r) === 'doing').sort(byDue)[0];
130
+ const t0 = Date.parse(String(o.today || new Date().toISOString()).slice(0, 10)), t1 = Date.parse(String(N.end || '').slice(0, 10));
131
+ const left = Number.isFinite(t0) && Number.isFinite(t1) && t1 >= t0 ? Math.round((t1 - t0) / 864e5) : null;
132
+ const noIni = R.filter((r) => !r.ini).length;
133
+ const tile = (n, name, sub) => `<div class="wk-stat"><b>${n}</b><span class="name">${name}</span>${sub ? `<span class="pm-meta">${esc(sub)}</span>` : ''}</div>`;
134
+ const tiles = [
135
+ tile(S.todo, 'To do', noOwner ? noOwner + ' with no owner' : ''),
136
+ tile(S.doing, 'In progress', first ? (first.who ? first.who + ': ' : '') + first.title : ''),
137
+ tile(`${S.done} of ${S.all}`, 'Done', left != null ? (left === 0 ? 'Last day of ' : plural(left, 'day', 'days') + ' left in ') + (N.label || N.name) : ''),
138
+ noIni ? tile(noIni, 'No initiative', noIni === S.all ? 'all the work in this sprint' : 'of ' + S.all) : '',
139
+ ];
140
+ return `<div class="wk-stats" role="group" aria-label="This sprint in numbers">${tiles.join('')}</div>`;
57
141
  }
58
142
 
59
143
  /** The Suggestion of one sprint proposal (pm/bk-sprint.js proposalsOf): Why, PMOS will, What changes, Based on. */
@@ -86,14 +170,24 @@ export function groupsOf(rows, o = {}) {
86
170
  .map((g) => ({ ...g, rows: g.rows.slice().sort((a, b) => (a.state === 'Done') - (b.state === 'Done') || byDue(a, b)) }));
87
171
  }
88
172
 
173
+ /** The Ticket cell: the Jira key, a link to the ticket (counted as sprintLink); a task outside Jira says so. */
174
+ export function ticketHtml(r) {
175
+ if (!r.key) return '<span class="pm-chip">Not in Jira</span>';
176
+ return r.url ? `<a class="pm-meta code wk-tk" href="${esc(r.url)}" target="_blank" rel="noopener" data-splink title="Open ${esc(r.key)} in Jira">${esc(r.key)}${SV(I.out, 12)}</a>` : `<span class="pm-meta code">${esc(r.key)}</span>`;
177
+ }
178
+ /** The Epic cell: the epic's key and name, a link to it in Jira; no epic says nothing. */
179
+ export function epicHtml(e) {
180
+ if (!e || !e.key) return '';
181
+ const inner = `<b class="code">${esc(e.key)}</b>${e.name ? ' ' + esc(e.name) : ''}`;
182
+ return e.url ? `<a class="wk-ep" href="${esc(e.url)}" target="_blank" rel="noopener" data-splink title="Open epic ${esc(e.key)} in Jira">${inner}</a>` : `<span class="wk-ep">${inner}</span>`;
183
+ }
89
184
  const badgeOf = (s) => `<span class="pm-badge${s === 'In progress' || s === 'In review' ? ' blue' : ''}">${esc(s)}</span>`;
90
185
  function rowHtml(r, nest, sel) {
91
186
  const on = !!(sel && sel.has(r.uid));
92
187
  const t = r.open ? `<button type="button" class="wk-tt" data-spopen="${esc(r.uid)}">${esc(r.title)}</button>`
93
188
  : r.url ? `<a class="wk-tt" href="${esc(r.url)}" target="_blank" rel="noopener">${esc(r.title)}</a>` : esc(r.title);
94
- const src = r.key ? `<span class="pm-meta code">${esc(r.key)}</span>` : '<span class="pm-chip">Not in Jira</span>';
95
- const due = `<span class="pm-row wk-due">${r.due ? `<span class="pm-meta code">${dayText(r.due)}</span>` : ''}${r.late ? `<span class="pm-badge alert">${lateText(r.late)}</span>` : ''}${movedText(r.moved) ? `<span class="pm-badge">${movedText(r.moved).replace(/^m/, 'M')}</span>` : ''}</span>`;
96
- return `<tr class="wk-sr${r.state === 'Done' ? ' wk-dn' : ''}${on ? ' sel' : ''}" data-sp="${esc(r.uid)}"${sel && sel.size ? ` aria-selected="${on}"` : ''}><td class="${nest ? 'wk-nest' : ''}"><b>${t}</b></td><td>${esc(r.who) || '<span class="pm-meta">No one</span>'}</td><td>${badgeOf(r.state)}</td><td>${src}</td><td>${due}</td></tr>`;
189
+ const due = r.due || r.late || movedText(r.moved) ? ` <span class="pm-row wk-due">${r.due ? `<span class="pm-meta code">${dayText(r.due)}</span>` : ''}${r.late ? `<span class="pm-badge alert">${lateText(r.late)}</span>` : ''}${movedText(r.moved) ? `<span class="pm-badge">${movedText(r.moved).replace(/^m/, 'M')}</span>` : ''}</span>` : '';
190
+ return `<tr class="wk-sr${r.state === 'Done' ? ' wk-dn' : ''}${on ? ' sel' : ''}" data-sp="${esc(r.uid)}"${sel && sel.size ? ` aria-selected="${on}"` : ''}><td class="${nest ? 'wk-nest' : ''}"><b>${t}</b>${due}</td><td>${esc(r.who) || '<span class="pm-meta">No one</span>'}</td><td>${badgeOf(r.state)}</td><td>${ticketHtml(r)}</td><td>${epicHtml(r.epic)}</td></tr>`;
97
191
  }
98
192
  /** The Tasks block. o: { tab, group, menu (the Group menu is open), themes, sel (the picked rows, Set of uid: Cmd, Ctrl or Shift-click picks) } */
99
193
  export function tasksHtml(N, o = {}) {
@@ -110,7 +204,7 @@ export function tasksHtml(N, o = {}) {
110
204
  const head = g.name ? `<tr class="wk-g"><td colspan="5"><div class="pm-group"><b>${esc(g.name)}</b> <span class="pm-meta">${whole.rows.filter((r) => r.state === 'Done').length} of ${whole.rows.length} done</span></div></td></tr>` : '';
111
205
  return head + g.rows.map((r) => rowHtml(r, !!g.name, o.sel)).join('');
112
206
  }).join('');
113
- const table = R.length ? `<table class="pm-table wk-spx"><thead><tr><th>Task</th><th>Who</th><th>State</th><th>Source</th><th>Due</th></tr></thead><tbody>${body}</tbody></table>`
207
+ const table = R.length ? `<table class="pm-table wk-spx"><thead><tr><th>Task</th><th>Who</th><th>State</th><th>Ticket</th><th>Epic</th></tr></thead><tbody>${body}</tbody></table>`
114
208
  : '<p class="pm-meta">Nothing here.</p>';
115
209
  return `<section class="pm-block wk-blk wk-spt" aria-label="Sprint tasks"><div class="head"><h2 class="pm-h">Tasks</h2><span class="sp"></span>${tabs}${menu}</div>${table}</section>`;
116
210
  }
@@ -22,6 +22,7 @@
22
22
  * press() first on each press in the Backlog. */
23
23
  import * as SK from './bk-sprint.js';
24
24
  import * as DS from './bd-sprint-ds.js'; // This sprint from the system's parts (WorkSprintDS)
25
+ import { noteUse } from './use-log.js';
25
26
 
26
27
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
27
28
  const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
@@ -111,10 +112,15 @@ export function bandHtml(o, deps) {
111
112
 
112
113
  /** The sprint's open tickets as This sprint's rows, until GET /api/backlog answers with sprintNow. */
113
114
  function nowOf(sp) {
114
- const rows = sp.tasks.map((t) => ({ uid: SK.uidOf(t), id: t.id, src: t.src, key: t.key || '', title: t.title, ini: t.ini || null, iniTitle: t.iniTitle || '', who: t.who || '', state: t.state, due: t.due || null, late: t.late || 0, moved: 0, url: t.url || null, open: true }));
115
+ const rows = sp.tasks.map((t) => ({ uid: SK.uidOf(t), id: t.id, src: t.src, key: t.key || '', title: t.title, ini: t.ini || null, iniTitle: t.iniTitle || '', who: t.who || '', state: t.state, due: t.due || null, late: t.late || 0, moved: 0, url: t.url || null, open: true, epic: t.epic && t.epic.key ? { key: t.epic.key, name: t.epic.name || '', url: null } : null }));
115
116
  const jira = rows.filter((r) => r.key).length;
116
117
  return { name: sp.name, label: sp.label, start: null, end: null, rows, jira, other: rows.length - jira, done: 0, total: rows.length };
117
118
  }
119
+ /** The strip of four counts over This sprint (board TbSprint, page balanced); '' when a past sprint shows or the sprint holds no work. */
120
+ export function stripNowHtml() {
121
+ if (!CUR || !CUR.now || CURP) return '';
122
+ return DS.stripHtml(CUR.now, {});
123
+ }
118
124
  /** The Tasks block of the sprint shown (WorkSprintDS); '' when a past sprint shows (its list is pastListHtml). */
119
125
  export function tasksNowHtml(sel) {
120
126
  if (!CUR || !CUR.now || CURP) return '';
@@ -282,6 +288,8 @@ export async function press(e, deps) {
282
288
  const t0 = e.target;
283
289
  const hit = (a) => t0.closest('[' + a + ']');
284
290
  let b;
291
+ // a Ticket or Epic link opens Jira itself; counted on this computer only (the health number of tb-sprint-balanced)
292
+ if (hit('data-splink')) { noteUse('sprintLink'); console.info('[tb-sprint-balanced] Jira link opened'); return false; }
285
293
  if ((b = hit('data-sppick'))) { PICK = b.dataset.sppick; PAST = ''; THEME = ''; EDIT = ''; deps.draw(); return true; }
286
294
  if (hit('data-spmenu')) { MENU = !MENU; deps.draw(); const f = document.querySelector('.sbo-mi.on, .sbo-mi'); if (MENU && f) f.focus(); return true; }
287
295
  if (hit('data-spolder')) { OLDER = true; deps.draw(); return true; }
@@ -143,6 +143,33 @@ body.bd-page.sp-on [id="bkBody"] { display: flex; flex-direction: column; gap: v
143
143
  .wk-spx .wk-due { gap: var(--space-8); flex-wrap: nowrap; }
144
144
  .wk-spx tr.wk-g td { padding: 0; }
145
145
 
146
+ /* ── This sprint, balanced (board TbSprint, page balanced): the strip, Tasks beside the right column, the Summary card ── */
147
+ .wk-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-12); }
148
+ .wk-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: var(--space-12) var(--space-16); background: var(--card); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--line); }
149
+ .wk-stat > b { font-size: var(--fs-display); line-height: 28px; font-weight: var(--fw-strong); color: var(--ink); font-variant-numeric: tabular-nums; }
150
+ .wk-stat .name { font-size: var(--fs-row); color: var(--ink); }
151
+ .wk-stat .pm-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
152
+ .wk-spgrid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: var(--space-16); align-items: start; }
153
+ @media (max-width: 1099px) { .wk-spgrid { grid-template-columns: minmax(0, 1fr); } }
154
+ .wk-spside { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
155
+ .wk-spsum .wk-spm { margin: 0 0 var(--space-12); }
156
+ .wk-sp3 { display: flex; height: 8px; border-radius: var(--radius-pill); background: var(--well); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; margin-bottom: var(--space-8); }
157
+ .wk-sp3 > span { display: block; height: 100%; }
158
+ .wk-sp3 > .todo, .wk-dot.todo { background: var(--muted); }
159
+ .wk-sp3 > .doing, .wk-dot.doing { background: var(--blue); }
160
+ .wk-sp3 > .done, .wk-dot.done { background: var(--leaf); }
161
+ .wk-sprw { gap: var(--space-8); height: 28px; font-size: var(--fs-row); }
162
+ .wk-sprw > span { flex: 1; }
163
+ .wk-sprw > b { font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; }
164
+ .wk-dot { width: 8px; height: 8px; border-radius: var(--radius-pill); flex: none; }
165
+ .wk-spby { margin: var(--space-8) 0 0; }
166
+ .wk-bkt .wk-tk, .wk-bk .wk-ep, .wk-spx .wk-tk, .wk-spx .wk-ep { color: var(--blue); text-decoration: none; display: inline-flex; align-items: center; gap: var(--space-4); }
167
+ .wk-bkt .wk-tk:hover, .wk-bk .wk-ep:hover, .wk-spx .wk-tk:hover, .wk-spx .wk-ep:hover { text-decoration: underline; }
168
+ .wk-bkt .wk-tk:focus-visible, .wk-bk .wk-ep:focus-visible, .wk-spx .wk-tk:focus-visible, .wk-spx .wk-ep:focus-visible { box-shadow: var(--glow); border-radius: var(--radius-sm); outline: none; }
169
+ .wk-bk .wk-ep, .wk-spx .wk-ep { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; color: var(--ink); }
170
+ .wk-bk .wk-ep b, .wk-spx .wk-ep b { font-weight: var(--fw-strong); color: var(--blue); }
171
+ .wk-spx td > .wk-due { display: inline-flex; margin-left: var(--space-8); }
172
+
146
173
  /* ── Backlog (WorkBacklogDS): Where it stands, the capture, the ranked Table ── */
147
174
  body.bd-page.bk-on [id="bdFilter"] { display: none; }
148
175
  body.bd-page.bk-on [id="bkBody"] { display: flex; flex-direction: column; gap: var(--space-16); max-width: none; }
@@ -221,6 +248,8 @@ body.bd-page.bk-on [id="bkBody"] { display: flex; flex-direction: column; gap: v
221
248
  @media (max-width: 760px) {
222
249
  .lb-m .lb-said span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
223
250
  }
251
+ .wk-spsay { margin: 0 0 var(--space-8) 16px; }
252
+ .wk-spsay .pm-star { margin-right: 2px; }
224
253
 
225
254
  /* Work › Initiatives (board TbInitiatives, slice 2, job 2038): the summary strip, the chips, and the list beside the Key results column 2 : 1.
226
255
  Under 1100 px the column sits under the list and the strip takes two cells a row. */
@@ -617,8 +617,11 @@ function redrawView() {
617
617
  if (cur.id === 'all:' + X.ctx.S.ini) { if (ALLB && ALLB.isConnected) { const M = curM(), st = ALLB.scrollTop; ALLB.innerHTML = M ? pageHtml(X.ctx.S.ini, M) : ''; light(ALLB, X.ctx.S.ini); ALLB.scrollTop = st; } return; }
618
618
  if (cur.id !== 'ov:' + X.ctx.S.ini) return;
619
619
  const ae = document.activeElement, keep = ae && BODY.contains(ae) && ae.id ? ae.id : null, val = keep && ae.value != null ? ae.value : null;
620
+ // a stage's New task field has no id: a redraw while it is typed in (another save landing) keeps its text and the focus
621
+ const addv = !keep && ae && BODY.contains(ae) && ae.matches('[data-iv-addinp]') ? ae.value : null;
620
622
  const st = BODY.scrollTop; draw(BODY); BODY.scrollTop = st;
621
623
  if (keep) { const n = BODY.querySelector('#' + keep); if (n) { if (val != null) n.value = val; n.focus(); } }
624
+ else if (addv != null) { const n = BODY.querySelector('[data-iv-addinp]'); if (n) { n.value = addv; n.focus({ preventScroll: true }); } }
622
625
  else if (ADDING && X.view === 'page') { const f = BODY.querySelector('#ivAddTask'); if (f) f.focus(); } // New → A task on a page still reading
623
626
  }
624
627
  /** ⋯ of the initiative in the Viewer (xvMore order: change it, then look back). */
@@ -154,9 +154,18 @@ function onKey(e) {
154
154
  else if ((e.key === 'Delete' || e.key === 'Backspace') && tabs[i].dataset.vw !== 'main') { vwClose(tabs[i].dataset.vw); return; }
155
155
  if (n < 0) return; e.preventDefault(); vwShow(tabs[n].dataset.vw); const f = q(`#vTabs .vtab[data-vw="${CSS.escape(tabs[n].dataset.vw)}"]`); if (f) f.focus();
156
156
  }
157
+ /** Loads a view's stylesheet once. Returns a promise that settles when it has loaded (or failed, or after 3 s), so a view can
158
+ * draw its content styled, never as bare buttons for a moment. Callers that do not wait keep working as before. */
159
+ const VW_CSS = new Map();
157
160
  export function vwStyle(name) {
158
- if (!/^[a-z0-9-]+$/.test(name || '') || document.querySelector(`link[data-vw-css="${name}"]`)) return;
159
- const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL(`./premium-vw-${name}.css`, import.meta.url).href; l.dataset.vwCss = name; document.head.append(l);
161
+ if (!/^[a-z0-9-]+$/.test(name || '')) return Promise.resolve();
162
+ if (VW_CSS.has(name)) return VW_CSS.get(name);
163
+ const have = document.querySelector(`link[data-vw-css="${name}"]`);
164
+ if (have) { const p = Promise.resolve(); VW_CSS.set(name, p); return p; }
165
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL(`./premium-vw-${name}.css`, import.meta.url).href; l.dataset.vwCss = name;
166
+ const p = new Promise((done) => { l.onload = l.onerror = () => done(); setTimeout(done, 3000); });
167
+ VW_CSS.set(name, p); document.head.append(l);
168
+ return p;
160
169
  }
161
170
  export function vwConfirm(el, o) {
162
171
  return new Promise((done) => {
@@ -130,10 +130,10 @@ export async function openSprint(o) {
130
130
  const { ws, board } = o || {};
131
131
  let name = (o && o.name) || '';
132
132
  let past = false; // the Past sprints fold, open or shut, kept across a redraw of the tab
133
- vwStyle('jira');
133
+ const css = vwStyle('jira');
134
134
  const draw = async (el) => {
135
135
  el.innerHTML = '<div class="jv"><p class="jnote">Reading the sprint</p></div>';
136
- const sprints = await getJson('/api/boards/sprints', { ws, board });
136
+ const [sprints] = await Promise.all([getJson('/api/boards/sprints', { ws, board }), css]); // the cards draw styled, never as bare buttons
137
137
  const m = sprintModel(sprints, name, { today: new Date().toISOString() });
138
138
  el.innerHTML = sprintHtml(m, past); bars(el);
139
139
  el.querySelectorAll('[data-sp]').forEach((b) => { b.onclick = () => { name = b.dataset.sp; draw(el); }; });
@@ -234,12 +234,13 @@ const TICKETS = [{ key: 'IDPF-3387', title: 'Refactor the AppAuthService', statu
234
234
  ok('S6 Move to a stage lists the workflow\'s stages, the task\'s own checked', sl && sl.includes('Build*') && sl.includes('Deliver') && sl[sl.length - 1] === 'Not in a stage', JSON.stringify(sl));
235
235
  await p.click('.tkc.ivq [data-ive-to="deliver"]');
236
236
  const mv = await until(() => { const x = lastPost(A, '/api/boards/tasks/edit'); return x && x.body.section === 'deliver' ? x : null; });
237
- // 10 s, not 4: with three browser suites at once on 4 cores the toast and the moved row came after 4 s (2026-11-25). The toast stays 9 s.
238
- const t6 = await until(async () => { const t = await toast(p); return /Moved to Deliver/.test(t) ? t : null; }, 10000);
237
+ // 30 s: the toast shows only after the reload and redraw (ini-edit.js move), which took over 10 s with four browser suites at once
238
+ // on 4 cores (2026-11-25). The toast then stays 9 s. Any toast that says it (an earlier pill can still be the first visible one); its own Undo is kept for the Undo step below
239
+ const t6 = await until(() => p.evaluate(() => { const e = [...document.querySelectorAll('#bdToast, .cz-toast, #czToast, #hiToast, [class*="toast"]')].find((x) => !x.hidden && x.getClientRects().length > 0 && /Moved to Deliver/.test(x.textContent)); if (!e) return null; window.__u6 = [...e.querySelectorAll('button')].find((b) => b.textContent.trim() === 'Undo') || null; return e.textContent; }), 30000);
239
240
  const inD = await until(async () => ((await rowsOf(p, 'deliver')).includes('task-b1') ? true : null), 10000);
240
241
  ok('S6 a stage picked there moves the task (section), "Moved to Deliver" with Undo, and it shows under Deliver', mv && /Undo/.test(t6 || '') && inD, JSON.stringify({ mv, t6 }));
241
- await undo(p);
242
- const mu = await until(() => { const x = lastPost(A, '/api/boards/tasks/edit'); return x && x.body.section === 'build' ? x : null; });
242
+ await p.evaluate(() => { if (window.__u6) window.__u6.click(); });
243
+ const mu = await until(() => { const x = lastPost(A, '/api/boards/tasks/edit'); return x && x.body.section === 'build' ? x : null; }, 10000);
243
244
  ok('S6 Undo puts it back in Build', !!mu, JSON.stringify(A.posts.slice(-2)));
244
245
 
245
246
  /* S7 a milestone has one date */
@@ -274,13 +275,20 @@ const TICKETS = [{ key: 'IDPF-3387', title: 'Refactor the AppAuthService', statu
274
275
  await p.keyboard.type('Release note for app teams'); await p.keyboard.press('Enter');
275
276
  const ad = await until(() => lastPost(A, '/api/boards/tasks/add'));
276
277
  ok('S8 Enter adds the task into that stage (section build)', ad && ad.body.title === 'Release note for app teams' && ad.body.section === 'build', JSON.stringify(ad));
277
- const t8 = await until(async () => { const t = await toast(p); return /Added to Build/.test(t) ? t : null; }, 4000);
278
+ // any toast that says it: an earlier one (S7's date Undo) can still be the first visible pill
279
+ const t8 = await until(() => p.evaluate(() => { const e = [...document.querySelectorAll('#bdToast, .cz-toast, #czToast, #hiToast, [class*="toast"]')].find((x) => !x.hidden && x.getClientRects().length > 0 && /Added to Build/.test(x.textContent)); if (!e) return null; window.__u8 = [...e.querySelectorAll('button')].find((b) => b.textContent.trim() === 'Undo') || null; return e.textContent; }), 15000);
280
+ // The field is disabled while the add is saved and gets the focus back only after the host's reload and redraw (home-ini.js
281
+ // addTask); with four browser suites at once on 4 cores that took over 10 s (2026-11-25). Read it before Undo, whose own redraw
282
+ // draws the field again without the focus.
283
+ const k8 = await until(() => p.evaluate(() => { const i = document.querySelector('#czViewer .iv-addin input'); return i && i.value === '' && document.activeElement === i ? true : null; }), 30000)
284
+ || await p.evaluate(() => { const a = document.activeElement, i = document.querySelector('#czViewer .iv-addin input'); return { field: !!i, value: i ? i.value : null, disabled: i ? i.disabled : null, active: a ? a.tagName + '.' + a.className : null }; });
285
+ ok('S8 the toast says "Added to Build" with Undo; the field stays open, empty and focused', /Undo/.test(t8 || '') && k8 === true, JSON.stringify({ t8, k8 }));
278
286
  await shot(p, 'S8-add-390');
279
- // Undo first: the toast holds it for 9 s (hi-pop.js undoToast), and on a busy runner the waits before it ran past that (2026-11-25).
280
- const u8 = await undo(p);
281
- const k8 = await until(() => p.evaluate(() => { const i = document.querySelector('#czViewer .iv-addin input'); return i && i.value === '' && document.activeElement === i ? true : null; }), 10000);
282
- ok('S8 the toast says "Added to Build" with Undo; the field stays open, empty and focused', /Undo/.test(t8 || '') && k8, JSON.stringify({ t8, k8 }));
283
- const du = await until(() => lastPost(A, '/api/boards/tasks/delete'));
287
+ // the toast's own Undo: once the list is drawn again, the new row carries an Undo of its own too, which undo() would pick
288
+ // kept when the toast showed: a later toast reuses the same pill and replaces its button, whose own handler still runs the delete
289
+ const u8 = await p.evaluate(() => { const b = window.__u8; if (b) b.click(); return !!b; });
290
+ // the delete queues behind the reload's reads, which took over 10 s under the same load
291
+ const du = await until(() => lastPost(A, '/api/boards/tasks/delete'), 30000);
284
292
  ok('S8 Undo takes the new task out', du && /^task-n/.test(du.body.task || ''), JSON.stringify({ u8, du, last: A.posts.slice(-3) }));
285
293
  await p.keyboard.press('Escape');
286
294
  ok('S8 Esc closes the field', await until(() => p.evaluate(() => !document.querySelector('#czViewer .iv-addin')), 3000));