create-pmos 0.830.0 → 0.832.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 (55) hide show
  1. package/package.json +129 -50
  2. package/payload/KIT-VERSION +1 -1
  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/workspace/changelog.json +128 -36
  7. package/workspace/guide/backlog.md +1 -1
  8. package/workspace/guide/cli.md +27 -1
  9. package/workspace/guide/layout.md +4 -1
  10. package/workspace/guide/programs.md +2 -1
  11. package/workspace/lib/anchor-id.js +226 -0
  12. package/workspace/lib/artefacts-cli.js +25 -1
  13. package/workspace/lib/events-place.js +11 -4
  14. package/workspace/lib/features.json +2 -0
  15. package/workspace/lib/initiative-cli.js +67 -2
  16. package/workspace/lib/layouts-cli.js +6 -0
  17. package/workspace/lib/lessons-draft.js +242 -0
  18. package/workspace/lib/list-balance.js +18 -3
  19. package/workspace/lib/pmos-verbs.js +6 -0
  20. package/workspace/lib/prefs-sync.js +1 -1
  21. package/workspace/lib/route-modules.js +2 -0
  22. package/workspace/lib/routes-c3-strategy.js +2 -1
  23. package/workspace/lib/routes-events-place.js +19 -1
  24. package/workspace/lib/routes-proposals.js +2 -2
  25. package/workspace/lib/routes-screen-layouts.js +56 -0
  26. package/workspace/lib/routes-switches.js +35 -0
  27. package/workspace/lib/switch-owners.js +152 -0
  28. package/workspace/lib/switches-cli.js +85 -0
  29. package/workspace/lib/three-layouts.js +214 -0
  30. package/workspace/package-lock.json +2 -2
  31. package/workspace/package.json +1 -1
  32. package/workspace/public/pm/bd-goal.js +33 -0
  33. package/workspace/public/pm/bd-pop-ds.css +16 -0
  34. package/workspace/public/pm/bd-work-ds.css +6 -0
  35. package/workspace/public/pm/bd-work.js +34 -8
  36. package/workspace/public/pm/card-fold.js +123 -0
  37. package/workspace/public/pm/cozy-ev.css +7 -0
  38. package/workspace/public/pm/cozy-events-view.js +8 -4
  39. package/workspace/public/pm/cozy-nav.js +2 -0
  40. package/workspace/public/pm/cozy-pop-work.js +8 -3
  41. package/workspace/public/pm/cozy-today-app.js +28 -1
  42. package/workspace/public/pm/cozy-today-model.js +13 -5
  43. package/workspace/public/pm/cozy-today-view.js +10 -1
  44. package/workspace/public/pm/list-balance.js +16 -2
  45. package/workspace/public/pm/premium-board.js +7 -1
  46. package/workspace/public/pm/readonly.js +2 -0
  47. package/workspace/public/pm/switch-owners.js +70 -0
  48. package/workspace/public/pm/three-layouts.js +66 -0
  49. package/workspace/public/premium-board.html +2 -0
  50. package/workspace/stage-card-tasks-test.js +1 -0
  51. package/workspace/test-lists/anchor-id.json +9 -0
  52. package/workspace/test-lists/card-fold.json +9 -0
  53. package/workspace/test-lists/lessons-on-close.json +9 -0
  54. package/workspace/test-lists/switch-owners.json +9 -0
  55. package/workspace/test-lists/three-layouts.json +9 -0
@@ -1,7 +1,8 @@
1
1
  /* pm/bd-work.js — Work, one view (slice 4 of the six-place navigation, initiative work-one-view; boards 4, 5 and 24 on Exploring 2).
2
2
  * One list of initiatives with the timeline on its right. No List / By stage / Track / Timeline tabs.
3
- * · Columns, in one order: Initiative, Product, Stage, Next milestone, Date. Status, Program, Goal and Workflow can be shown. Initiative
4
- * always shows. One text size, one row height; only the initiative name is bold.
3
+ * · Columns, in one order: Initiative, Product, Stage, Tasks done, Date, Owner, Jira epic (board TbInitiatives). Next milestone, Status,
4
+ * Program, Goal, Workflow and Raised by can be shown. Initiative always shows. Grouped by goal, the groups are the objectives (o.goalGroups)
5
+ * and each row says the key result it serves under its name (o.serves). One text size, one row height; only the initiative name is bold.
5
6
  * · Next milestone is the real milestone name; with none the cell is empty (never "Plan end", never a stage name), and Date is the plan end.
6
7
  * · Only a late or at-risk date has colour: "4 Nov · 14 days late", "27 Nov · at risk". A closed initiative is never late.
7
8
  * · The bar is the Board's own (Wawan, 2026-11-19, round 2; pm/bd-span.js rowBar, given by the page): done, now in blue, planned, every
@@ -27,11 +28,15 @@ const DAY = 864e5;
27
28
 
28
29
  /* ── the columns ─────────────────────────────────────────────────────────────────────────────────────────────── */
29
30
  /** Every column but Initiative, in its usual order, with its width in px. on: shown by default. */
31
+ // the usual ones are the board's (TbInitiatives, Exploring 3 page balanced): Stage, Tasks done, Date, Owner, Jira epic; Product with two products
30
32
  export const COLS = [
31
33
  { k: 'product', n: 'Product', w: 112, on: true },
32
34
  { k: 'stage', n: 'Stage', w: 160, on: true },
33
- { k: 'ms', n: 'Next milestone', w: 160, on: true },
35
+ { k: 'tasks', n: 'Tasks done', w: 104, on: true },
34
36
  { k: 'date', n: 'Date', w: 152, on: true },
37
+ { k: 'owner', n: 'Owner', w: 120, on: true },
38
+ { k: 'epic', n: 'Jira epic', w: 140, on: true },
39
+ { k: 'ms', n: 'Next milestone', w: 160, on: false },
35
40
  { k: 'status', n: 'Status', w: 104, on: false },
36
41
  { k: 'program', n: 'Program', w: 150, on: false },
37
42
  { k: 'goal', n: 'Goal', w: 170, on: false },
@@ -43,7 +48,7 @@ export const GROUPS = [['goal', 'Goal'], ['product', 'Product'], ['stage', 'Stag
43
48
  // the scale tabs (WorkDS, 2026-11-20): Week, Month, Quarter, Year and Full; the number is the window's length in days (Full fits the rows)
44
49
  export const SPANS = [['week', 'Week', 42], ['month', 'Month', 152], ['quarter', 'Quarter', 456], ['year', 'Year', 1096], ['full', 'Full', 0]];
45
50
  const OLD_SPAN = { half: 'quarter', y2: 'year', y5: 'year' }; // a view kept before the scale tabs
46
- export const KEY = 'pmos.work.view.3'; // .3 (WorkDS, 2026-11-20): every kept view starts again from the usual one, on Month
51
+ export const KEY = 'pmos.work.view.4'; // .4 (TbInitiatives, 2026-11-25): every kept view starts again from the board's columns; .3 (WorkDS) was Month
47
52
 
48
53
  /** The usual view: grouped by goal, the timeline on, the default columns in their order, Month (WorkDS). */
49
54
  export const usual = () => ({ group: 'goal', tl: true, span: 'month', cols: COLS.map((c) => ({ k: c.k, on: c.on })), sorts: [] });
@@ -209,7 +214,7 @@ export function addSort(k) {
209
214
  return write({ ...read(), sorts: S });
210
215
  }
211
216
  export const dropSort = (k) => write({ ...read(), sorts: read().sorts.filter((x) => x.k !== k) });
212
- export const SORT_KEYS = [['title', 'Initiative'], ['stage', 'Stage'], ['date', 'Date'], ['ms', 'Next milestone'], ['status', 'Status'], ['product', 'Product'], ['program', 'Program'], ['origin', 'Raised by']];
217
+ export const SORT_KEYS = [['title', 'Initiative'], ['stage', 'Stage'], ['tasks', 'Tasks done'], ['date', 'Date'], ['owner', 'Owner'], ['epic', 'Jira epic'], ['ms', 'Next milestone'], ['status', 'Status'], ['product', 'Product'], ['program', 'Program'], ['origin', 'Raised by']];
213
218
  const str = (v) => String(v || '~');
214
219
  /** Stage order: the row's own workflow's place, else (no workflow on record) the lifecycle's order by name, so Discover comes before Build. */
215
220
  const LIFE = ['triage', 'discover', 'discovery', 'plan', 'prioritize', 'build', 'deliver', 'monitor', 'evaluate', 'completed', 'closed'];
@@ -225,6 +230,9 @@ const SORTS = {
225
230
  program: (a, b, o) => str(o.programOf && o.programOf(a)).localeCompare(str(o.programOf && o.programOf(b))),
226
231
  goal: (a, b, o) => str(o.goalOf && o.goalOf(a)).localeCompare(str(o.goalOf && o.goalOf(b))),
227
232
  wf: (a, b) => String(wfOf(a).name).localeCompare(String(wfOf(b).name)),
233
+ tasks: (a, b) => { const x = tasksOf(a), y = tasksOf(b); return (x.n ? x.done / x.n : -1) - (y.n ? y.done / y.n : -1); },
234
+ owner: (a, b) => str(a.owner).localeCompare(str(b.owner)),
235
+ epic: (a, b) => str(epicOf(a)).localeCompare(str(epicOf(b))),
228
236
  origin: (a, b) => originPos(originGroup(a) || '~') - originPos(originGroup(b) || '~') || str(originText(a)).localeCompare(str(originText(b))),
229
237
  };
230
238
  const sortRows = (rows, o) => {
@@ -343,6 +351,15 @@ export function ticksOf(W) {
343
351
  const I = { print: 'M7 9V4h10v5M7 17H5a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-2M7 14h10v6H7z', hide: 'M13 6l6 6-6 6M6 6l6 6-6 6', show: 'M11 6l-6 6 6 6M18 6l-6 6 6 6', chev: 'M7 10l5 5 5-5', sort: 'M12 5v14M6 13l6 6 6-6', x: 'M6 6l12 12M18 6L6 18',
344
352
  back: 'M15 6l-6 6 6 6', on: 'M10 8l4 4-4 4', today: 'M12 3v18M7 8l-4 4 4 4M17 8l4 4-4 4', tune: 'M4 7h10M18 7h2M4 17h4M12 17h8M14 5v4M8 15v4' };
345
353
 
354
+ /** A row's own tasks: how many, and how many are done (status done, or closed). Never another row's. PURE. */
355
+ export function tasksOf(r) {
356
+ const T = Array.isArray(r && r.tasks) ? r.tasks.filter(Boolean) : [];
357
+ return { n: T.length, done: T.filter((x) => /^done$/i.test(String(x.status || '')) || !!x.closed).length };
358
+ }
359
+ /** The row's Jira epic: the first epic key it holds, '' when none. */
360
+ export const epicOf = (r) => String(((r && r.epics) || [])[0] || '');
361
+ const tasksText = (r) => { const t = tasksOf(r); return t.n ? t.done + ' of ' + t.n : ''; };
362
+
346
363
  function cellHtml(r, k, o) {
347
364
  if (k === 'product') return `<td>${esc(o.product(r))}</td>`;
348
365
  if (k === 'stage') { const s = stageText(r); return `<td class="wk-stc">${o.canMove && o.canMove(r) ? `<button type="button" class="wk-st" data-wkstage="${esc(r.key)}" aria-haspopup="menu" aria-label="Stage: ${esc(s || 'none')}. Change the stage" title="Change the stage">${esc(s)}</button>` : esc(s)}</td>`; }
@@ -355,6 +372,10 @@ function cellHtml(r, k, o) {
355
372
  if (k === 'goal') return `<td>${esc((o.goalOf && o.goalOf(r)) || '')}</td>`;
356
373
  if (k === 'wf') return `<td>${esc(wfOf(r).name)}</td>`;
357
374
  if (k === 'origin') return `<td>${esc(originText(r))}</td>`; // none: an empty cell (zero is silence)
375
+ // the board's columns: no tasks is an empty cell; no owner and no epic say so, muted, as they are what needs someone
376
+ if (k === 'tasks') return `<td>${esc(tasksText(r))}</td>`;
377
+ if (k === 'owner') return `<td>${r.owner ? esc(r.owner) : '<span class="pm-meta">no one</span>'}</td>`;
378
+ if (k === 'epic') return `<td>${epicOf(r) ? esc(epicOf(r)) : '<span class="pm-meta">no epic</span>'}</td>`;
358
379
  return '<td></td>';
359
380
  }
360
381
  const words = (r, keys, o) => keys.map((k) => {
@@ -367,6 +388,9 @@ const words = (r, keys, o) => keys.map((k) => {
367
388
  if (k === 'goal') return (o.goalOf && o.goalOf(r)) || '';
368
389
  if (k === 'wf') return wfOf(r).name;
369
390
  if (k === 'origin') return originText(r) ? 'raised by ' + originText(r) : '';
391
+ if (k === 'tasks') return tasksText(r) ? tasksText(r) + ' tasks done' : '';
392
+ if (k === 'owner') return r.owner ? 'owner ' + r.owner : 'no owner';
393
+ if (k === 'epic') return epicOf(r) ? 'epic ' + epicOf(r) : 'no epic';
370
394
  return '';
371
395
  }).filter(Boolean).join(', ');
372
396
 
@@ -397,7 +421,7 @@ export function cardHtml(r, W, now = new Date()) {
397
421
  export const isClosed = (r) => !!(r.closed || ['done', 'wontdo', 'archived'].includes(catOfRow(r)));
398
422
  let CARD = null, SHUT = true, COLS_OPEN = false, LAST = null, LASTW = null; // the row whose stage card is open; the closed ones folded; the menu's Columns open; the rows last drawn
399
423
 
400
- /** The whole list. rows: the initiatives on screen. o: { now, many, sel, canMove(r), product(r), programOf(r), goalOf(r), goalGroups(rows),
424
+ /** The whole list. rows: the initiatives on screen. o: { now, many, sel, canMove(r), product(r), programOf(r), goalOf(r), goalGroups(rows), serves(r),
401
425
  * bar(r, W): the Board's own bar for a row (else the plain one) } → html. The closed ones fold into one line at the end. */
402
426
  export function listHtml(rows, o = {}) {
403
427
  const v = read(), now = o.now || new Date(), keys = colsShown(v, o), tl = v.tl !== false;
@@ -422,8 +446,10 @@ export function listHtml(rows, o = {}) {
422
446
  let h = `<section class="pm-block wk-blk" aria-label="Initiatives">${head}${o.above || ''}${showingHtml(every.length - rows.length)}`
423
447
  + `<div class="wk-tw"><table class="pm-table wk${tl ? ' has-x' : ''}" aria-label="Initiatives"><colgroup><col class="c-title">${keys.map((k) => `<col class="c-${k}">`).join('')}${tl ? '<col class="c-x">' : ''}</colgroup>`
424
448
  + `<thead><tr>${sortHd('title', 'Initiative')}${keys.map((k) => sortHd(k, byK[k].n)).join('')}${tlHead}</tr></thead><tbody>`;
425
- const row = (r) => `<tr class="wk-i${o.sel === r.key ? ' sel' : ''}${CARD === r.key ? ' hov' : ''}${isClosed(r) ? ' cl' : ''}" tabindex="0" data-key="${esc(r.key)}" aria-label="${esc(r.title + (keys.length ? ', ' + words(r, keys, oo) : ''))}">`
426
- + `<td class="n">${((g) => stateGlyph(g.state, { why: g.why, progress: g.progress, cls: 'wk-sg' }))(rowState(r, now))}${esc(r.title)}</td>${keys.map((k) => cellHtml(r, k, oo)).join('')}`
449
+ // grouped by goal, each row says which key result it serves, under its name (TbInitiatives); grouped otherwise it says nothing
450
+ const sv = (r) => (v.group === 'goal' && o.serves ? o.serves(r) || '' : '');
451
+ const row = (r) => `<tr class="wk-i${o.sel === r.key ? ' sel' : ''}${CARD === r.key ? ' hov' : ''}${isClosed(r) ? ' cl' : ''}" tabindex="0" data-key="${esc(r.key)}" aria-label="${esc(r.title + (sv(r) ? ', ' + sv(r) : '') + (keys.length ? ', ' + words(r, keys, oo) : ''))}">`
452
+ + `<td class="n${sv(r) ? ' sv' : ''}">${((g) => stateGlyph(g.state, { why: g.why, progress: g.progress, cls: 'wk-sg' }))(rowState(r, now))}${esc(r.title)}${sv(r) ? `<small class="wk-sv">${esc(sv(r))}</small>` : ''}</td>${keys.map((k) => cellHtml(r, k, oo)).join('')}`
427
453
  + (tl ? `<td class="wk-x" data-wkbar="${esc(r.key)}"><div class="wk-bw pm-gt">${grid}${o.bar ? o.bar(r, W) : barHtml(r, W, { now })}</div>${CARD === r.key ? cardHtml(r, W, now) : ''}</td>` : '') + '</tr>';
428
454
  const all = o.order ? o.order(rows) : rows, base = all.filter((r) => !isClosed(r)), shut = all.filter(isClosed), G = groupsOf(base, v.group, oo);
429
455
  const gline = (inner) => `<tr class="wk-g"><td colspan="${ncol}"><div class="pm-group">${inner}</div></td></tr>`;
@@ -0,0 +1,123 @@
1
+ /* pm/card-fold.js — the big summary cards fold away (initiative card-fold).
2
+ *
3
+ * One shared fold for every big summary card: Strategy, Where it stands and North Star, on every page. An icon-only button at the
4
+ * right of the card's head folds the card to its head line; Where it stands keeps its first sentence on that line. A ✦ suggestion
5
+ * inside a folded card stays visible as a small "✦ 1" beside the head, which opens the card again. Zero suggestions: no mark.
6
+ * The fold is kept per page and per card in localStorage under 'pmos.fold:<page>:<card>'. That prefix is on the view-prefs allowlist
7
+ * (lib/prefs-sync.js), so the fold follows the person to their other browsers. No card's own markup or content changes: the module
8
+ * finds the cards by their aria-label and adds the button, so a card that redraws itself gets its button back on the next frame.
9
+ * A card that is being edited (it holds an input or a text box) never folds, so the PM can always see what they type.
10
+ *
11
+ * startCardFold(doc) called once by the menu (pm/cozy-nav.js mountNav), which every page mounts; a second call does nothing
12
+ * cardOf(label) PURE: the card's key for an aria-label, or '' when the card does not fold
13
+ * foldKey(page, card) PURE: the storage key · pageOf(path) PURE: '/premium-board.html' → 'premium-board'
14
+ * sugCount(section) the ✦ suggestions inside a card · enhance(section, doc) add the fold to one card · sweep(doc) every card
15
+ * btnHtml(card, folded, n, title) PURE: the head's fold controls */
16
+
17
+ export const CARDS = Object.freeze({ 'Strategy': 'strategy', 'Where it stands': 'stands', 'North Star': 'northstar' });
18
+ export const PREFIX = 'pmos.fold:';
19
+ const SEL = 'section.pm-block[aria-label]';
20
+ const SUG = '.pm-sug';
21
+ const EDITING = 'input, textarea, select, [contenteditable="true"], [contenteditable=""]';
22
+ const CHEV_UP = 'M7 14l5-5 5 5';
23
+ const CHEV_DOWN = 'M7 10l5 5 5-5';
24
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
25
+ const SV = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
26
+
27
+ export const cardOf = (label) => CARDS[String(label || '').trim()] || '';
28
+ export const pageOf = (path) => (String(path || '').split('/').pop() || 'index').replace(/\.html?$/i, '') || 'index';
29
+ export const foldKey = (page, card) => PREFIX + page + ':' + card;
30
+
31
+ /** PURE: the fold button, and when folded with suggestions inside, the small ✦ count that opens the card. */
32
+ export function btnHtml(card, folded, n, title) {
33
+ const t = String(title || card);
34
+ const mark = folded && n > 0
35
+ ? `<button type="button" class="pm-fold-sug" data-card-fold-sug="${esc(card)}" aria-label="${esc(n + (n === 1 ? ' suggestion' : ' suggestions') + ' from PMOS in ' + t + '. Open')}" title="${esc(n === 1 ? '1 suggestion waits inside' : n + ' suggestions wait inside')}">✦ ${n}</button>`
36
+ : '';
37
+ const label = (folded ? 'Open ' : 'Fold ') + t;
38
+ return mark + `<button type="button" class="pm-btn pm-fold-btn" data-card-fold="${esc(card)}" aria-expanded="${folded ? 'false' : 'true'}" aria-label="${esc(label)}" title="${esc(label)}">${SV(folded ? CHEV_DOWN : CHEV_UP)}</button>`;
39
+ }
40
+
41
+ /** The ✦ suggestions inside a card. */
42
+ export const sugCount = (sec) => (sec && sec.querySelectorAll ? sec.querySelectorAll(SUG).length : 0);
43
+
44
+ const store = (doc) => { try { return doc.defaultView.localStorage; } catch { return null; } };
45
+ const isFolded = (doc, key) => { const ls = store(doc); try { return !!ls && ls.getItem(key) === '1'; } catch { return false; } };
46
+ function setFolded(doc, key, on) {
47
+ const ls = store(doc); if (!ls) return;
48
+ try { if (on) ls.setItem(key, '1'); else ls.removeItem(key); } catch { /* storage blocked: the fold lasts for this page only */ }
49
+ }
50
+
51
+ /** The card's head: its .head row, else its first heading. */
52
+ function headOf(sec) {
53
+ for (const el of Array.from(sec.children || [])) {
54
+ if (el.classList && el.classList.contains('head')) return el;
55
+ if (/^H[1-6]$/.test(el.tagName || '')) return el;
56
+ }
57
+ return null;
58
+ }
59
+
60
+ /** Add the fold to one card, or bring its state up to date. Returns true when the card can fold. */
61
+ export function enhance(sec, doc) {
62
+ const card = cardOf(sec.getAttribute('aria-label'));
63
+ if (!card || sec.classList.contains('flat')) return false; // a one-line card (not written yet, drafting) has nothing to fold
64
+ const head = headOf(sec);
65
+ if (!head) return false;
66
+ const key = foldKey(pageOf(doc.defaultView && doc.defaultView.location ? doc.defaultView.location.pathname : ''), card);
67
+ const editing = !!sec.querySelector(EDITING);
68
+ const folded = !editing && isFolded(doc, key);
69
+ const n = folded ? sugCount(sec) : 0;
70
+ const sig = (folded ? 'f' : 'o') + n + (editing ? 'e' : '');
71
+ if (sec.dataset.cardFold === sig && head.querySelector('[data-card-fold]')) return true;
72
+ sec.dataset.cardFold = sig;
73
+ head.setAttribute('data-fold-head', '');
74
+ head.querySelectorAll('[data-card-fold], [data-card-fold-sug]').forEach((b) => b.remove());
75
+ if (!editing) {
76
+ const box = doc.createElement('span');
77
+ box.className = 'pm-fold-ctl';
78
+ box.innerHTML = btnHtml(card, folded, n, sec.getAttribute('aria-label'));
79
+ head.appendChild(box);
80
+ }
81
+ // Where it stands keeps its first sentence line on the folded head
82
+ const one = card === 'stands' ? Array.from(sec.children).find((el) => el !== head && el.tagName === 'P') : null;
83
+ sec.querySelectorAll(':scope > [data-fold-one]').forEach((el) => { if (el !== one) el.removeAttribute('data-fold-one'); });
84
+ if (one) one.setAttribute('data-fold-one', '');
85
+ sec.classList.toggle('pm-folded', folded);
86
+ return true;
87
+ }
88
+
89
+ /** Every card on the page. */
90
+ export function sweep(doc) {
91
+ let n = 0;
92
+ doc.querySelectorAll(SEL).forEach((sec) => { if (enhance(sec, doc)) n++; });
93
+ return n;
94
+ }
95
+
96
+ let started = false;
97
+ export function startCardFold(doc = typeof document !== 'undefined' ? document : null) {
98
+ if (started || !doc || !doc.body) return false;
99
+ started = true;
100
+ const win = doc.defaultView;
101
+ let queued = false;
102
+ const later = () => {
103
+ if (queued) return; queued = true;
104
+ const run = () => { queued = false; try { sweep(doc); } catch (e) { try { console.info('[card-fold] ' + e.message); } catch { /* no console */ } } };
105
+ if (win && win.requestAnimationFrame) win.requestAnimationFrame(run); else setTimeout(run, 16);
106
+ };
107
+ if (win) doc.defaultView.addEventListener('click', (e) => { // capture on the window, as focus mode does
108
+ const b = e.target && e.target.closest && e.target.closest('[data-card-fold], [data-card-fold-sug]');
109
+ if (!b) return;
110
+ const sec = b.closest(SEL);
111
+ if (!sec) return;
112
+ e.preventDefault();
113
+ const card = cardOf(sec.getAttribute('aria-label'));
114
+ const key = foldKey(pageOf(win && win.location ? win.location.pathname : ''), card);
115
+ setFolded(doc, key, b.hasAttribute('data-card-fold') ? !sec.classList.contains('pm-folded') : false);
116
+ enhance(sec, doc);
117
+ const again = sec.querySelector('[data-card-fold]');
118
+ if (again && again.focus) again.focus();
119
+ }, true);
120
+ if (win && win.MutationObserver) new win.MutationObserver(later).observe(doc.body, { childList: true, subtree: true });
121
+ later();
122
+ return true;
123
+ }
@@ -570,3 +570,10 @@ body.pm-focus .cz-pop-card { inset: 0; border-radius: 0; }
570
570
  ::highlight(pm-term) { text-decoration: underline dotted; text-underline-offset: var(--space-4); } /* the text's own colour: --muted means another thing inside .c3 */
571
571
  .gl-tip.pm-ds { position: fixed; z-index: 90; max-width: min(calc(var(--space-64) * 5), calc(100vw - var(--space-16))); background: var(--card); color: var(--ink); border-radius: var(--radius-md); box-shadow: var(--lift); padding: var(--space-8) var(--space-12); font-size: var(--fs-meta); line-height: var(--lh-meta); left: var(--fr-gl-x, 0); top: var(--fr-gl-y, 0); pointer-events: auto; }
572
572
  .gl-tip.pm-ds .gl-m { margin: var(--space-4) 0 0; }
573
+
574
+ /* ── card fold (pm/card-fold.js, initiative card-fold): Strategy, Where it stands and North Star fold to their head line. The fold button
575
+ * sits at the right of the head; a folded card keeps a small ✦ count when a suggestion waits inside. Tokens only. ── */
576
+ .pm-fold-ctl { display: inline-flex; align-items: center; gap: var(--space-8); margin-left: auto; flex: none; }
577
+ .pm-folded > :not([data-fold-head]):not([data-fold-one]) { display: none !important; }
578
+ .pm-folded > [data-fold-one] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; color: var(--muted); }
579
+ .pm-fold-sug { border: 0; cursor: pointer; display: inline-flex; align-items: center; padding: var(--space-4) var(--space-8); border-radius: var(--radius-pill); background: var(--blue-tint); color: var(--blue); font: inherit; font-size: var(--fs-badge); font-weight: var(--fw-strong); }
@@ -4,6 +4,7 @@
4
4
  * Main + side. Every group is a system block, and this file writes only the system's part classes (pm-block, pm-li, pm-sug, pm-ev,
5
5
  * pm-badge, pm-fold, pm-cal, pm-leg, pm-tabs, pm-btn); the evp-* names beside them are hooks for the page code and the placement sheet.
6
6
  * groupsOf(items, { show, day }) → { late, today, coming, later } the items the page shows, by group; show = the types on; day = one day
7
+ * (past: the meetings of a picked day before today, with Open notes)
7
8
  * listHtml(model, o) the main column: Late (a List block: one Suggestion "PMOS has a fix for all N late dates" with ✓ ✕, then
8
9
  * each row with PMOS's fix as its grey line, a late Badge and ✓ ✕; the newest LATE_SHOWN, then one fold),
9
10
  * Today (todayHtml), Coming up (a List block; a Suggestion under a date only where it is at risk; the later
@@ -73,13 +74,15 @@ export function groupsOf(items, o = {}) {
73
74
  const day = o.day || null;
74
75
  const list = visible(items, o).filter((x) => !day || x.date === day);
75
76
  const g = (k) => list.filter((x) => x.group === k);
76
- return { late: g('late'), today: g('today'), coming: g('coming'), later: g('later') };
77
+ // past: the meetings of a day before today. They are not late, so only a picked day shows them (and the calendar marks their days)
78
+ return { late: g('late'), today: g('today'), coming: g('coming'), later: g('later'), past: day ? g('past') : [] };
77
79
  }
78
80
 
79
81
  /** The day column: the date, or the time today. How late a date is goes on its Badge, not here. */
80
82
  function dayCell(x, today) {
81
83
  if (x.group === 'today' && x.time) return { b: x.time, s: x.until ? 'to ' + x.until : '' };
82
84
  if (x.group === 'today') return { b: 'Today', s: '' };
85
+ if (x.group === 'past') return { b: x.time || 'All day', s: x.until ? 'to ' + x.until : '' };
83
86
  const n = between(today, x.date);
84
87
  if (x.group === 'late') return { b: shortDay(x.date, today), s: '' };
85
88
  return { b: shortDay(x.date, today), s: x.time ? weekday(x.date) + ' ' + x.time : 'in ' + n + ' ' + plural(n, 'day', 'days') };
@@ -212,7 +215,7 @@ export function hiddenHtml(items, o = {}) {
212
215
  const typesCut = TYPES.some((t) => !on.has(t));
213
216
  const scoped = !!(o.scopeOk && o.scopeWords);
214
217
  if (!typesCut && !scoped) return '';
215
- const all = (items || []).filter((x) => x.group !== 'later' || x.kind === 'milestone');
218
+ const all = (items || []).filter((x) => (x.group !== 'later' || x.kind === 'milestone') && x.group !== 'past');
216
219
  const shown = visible(all, o).length, hidden = all.length - shown;
217
220
  if (!hidden) return '';
218
221
  const and = (L) => (L.length > 1 ? L.slice(0, -1).join(', ') + ' and ' + L[L.length - 1] : L[0] || 'nothing');
@@ -261,7 +264,8 @@ export function listHtml(model, o = {}) {
261
264
  }
262
265
  const coming = G.coming.length ? groupHtml('coming', 'Coming up', G.coming, ro, '', o.day ? '' : later, 0, o.day ? null : comingBody(G.coming, ro))
263
266
  : !o.day && later ? `<section class="evp-g evp-coming pm-block list" aria-label="Coming up"><div class="head"><h2 class="pm-h">Coming up</h2><span class="sp"></span></div>${later}</section>` : '';
264
- const body = groupHtml('late', 'Late', lateRows, ro, all, lateTail, G.late.length) + todayHtml(G.today, { ...ro, now: o.now }) + coming + (o.day ? later : '');
267
+ const past = G.past.length ? groupHtml('past', G.past.every((x) => typeOf(x) === 'focus') ? 'Focus time' : 'Meetings', G.past, ro, '', '', G.past.length, null, `<span class="pm-meta">${esc(weekday(o.day) + ' ' + shortDay(o.day, today))}</span>`) : '';
268
+ const body = past + groupHtml('late', 'Late', lateRows, ro, all, lateTail, G.late.length) + todayHtml(G.today, { ...ro, now: o.now }) + coming + (o.day ? later : '');
265
269
  if (body) return body;
266
270
  if (o.day) return `<p class="evp-quiet pm-meta">Nothing has a date on ${esc(weekday(o.day) + ' ' + shortDay(o.day, today))}.</p>`;
267
271
  return '<p class="evp-quiet pm-meta">Nothing is late, and nothing has a date in the next 30 days.</p>';
@@ -314,7 +318,7 @@ export function showHtml(show, o = {}) {
314
318
  /** How many dates of each type the page lists (Late, Today, Coming up and the far milestones), under the chip. */
315
319
  export function countsOf(items, o = {}) {
316
320
  const c = {};
317
- for (const x of items || []) { if (x.group === 'later' && x.kind !== 'milestone') continue; if (o.scopeOk && !o.scopeOk(x)) continue; c[typeOf(x)] = (c[typeOf(x)] || 0) + 1; }
321
+ for (const x of items || []) { if ((x.group === 'later' && x.kind !== 'milestone') || x.group === 'past') continue; if (o.scopeOk && !o.scopeOk(x)) continue; c[typeOf(x)] = (c[typeOf(x)] || 0) + 1; }
318
322
  return c;
319
323
  }
320
324
 
@@ -49,6 +49,7 @@ import { startUseLog } from './use-log.js'; // bet A466: every page mounts the
49
49
  import { startActionKeys } from './action-keys.js'; // bet A477: y o s p z act on the item under the pointer, ? lists the keys
50
50
  import { startGlossary } from './glossary.js'; // bet A386: a product's own words show their meaning on hover (a long press on a phone)
51
51
  import { startFocusMode } from './focus-mode.js'; // bet A335: f shows only the item under the pointer and its chat; f again puts the page back
52
+ import { startCardFold } from './card-fold.js'; // card-fold: Strategy, Where it stands and North Star fold to one line, kept per person
52
53
 
53
54
  /* The six places (slice 1). A place shows once it has an href: Events, Library and Routine get theirs when their slice ships. Until then
54
55
  * Today is today.html (slice 5; Home before it), Work is the Board and Goals is premium-goals.html (slice 9; Intelligence before it); the keys stay the pages' own (home, board, insights). */
@@ -209,6 +210,7 @@ export function mountNav(here, doc = document, opts = {}) {
209
210
  askHere(doc, () => import('./ask-here.js')); // ask-anywhere: a right-click (a phone: a long-press) asks PMOS about what was pressed
210
211
  startActionKeys(doc);
211
212
  startFocusMode(doc);
213
+ startCardFold(doc);
212
214
  startGlossary(doc);
213
215
  const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
214
216
  const draw = () => {
@@ -37,6 +37,7 @@ import * as IF from './inline-fields.js'; // a task's sprint and priority, set
37
37
  import * as SD from './star-draft.js'; // a ✦ draft runs as a PMOS background job and lands on its line (star-buttons-act-directly A7)
38
38
  import * as CAP from './pop-cap.js'; // five actions at most: Ask PMOS and the toolbar's four, the rest under ⋯ (popup-cap, idea A498)
39
39
  import { noteUse } from './use-log.js';
40
+ import * as TLY from './three-layouts.js'; // three layouts for a new screen, pick one (initiative three-layouts, A317)
40
41
  import * as PR from './print-pdf.js'; // Print or PDF under ⋯ (job #1911, A379)
41
42
  import * as SMAP from './stakeholder-map.js'; // the People block: who decides, must agree, needs to know (stakeholder-map, A371)
42
43
  import * as PD from './bd-pop-ds.js'; // the popup on a computer, built from the design system's blocks (initiative work-ds-popup) // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
@@ -105,7 +106,7 @@ export const resetItems = () => { ITEMS.clear(); CRIT.clear(); };
105
106
  /* A chat turn may have written what the popup shows (initiative chat-saves-to-cards, Wawan 2026-11-23: the chat saved the case and the card
106
107
  * kept saying no line is written): the popup's reads of one initiative (the case's artefacts, the Library's rows, the done test's criteria)
107
108
  * were kept for the page's life, so they are read again after every chat turn, and when the page comes back into view. */
108
- function rereadAll() { ART.clear(); ITEMS.clear(); CRIT.clear(); if (artRedraw) artRedraw(); }
109
+ function rereadAll() { ART.clear(); ITEMS.clear(); CRIT.clear(); TLY.forget(); if (artRedraw) artRedraw(); }
109
110
  if (typeof document !== 'undefined' && document.addEventListener) {
110
111
  document.addEventListener('cz:chat-turn', () => rereadAll());
111
112
  document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') rereadAll(); });
@@ -492,9 +493,11 @@ function dsHtml(r, v, o, W, S, C, mode) {
492
493
  const crit = S.sel.size || dropped().has('crit:' + id) ? '' : critSugHtml(CRIT.get(id));
493
494
  // Overview (Wawan, 2026-11-23): Where it stands, The case and its facts in one block across the top; folded or open is the person's choice
494
495
  // one column (artefacts-in-more-menu, Wawan 2026-11-23): the Stages and the breakdown take the full width; the artefacts are in ⋯ (moreItems)
496
+ // a new screen's three layouts under the stages (three-layouts, A317): zero is silence, so an initiative that adds no screen shows nothing
497
+ const lay = TLY.html(TLY.seen(id));
495
498
  // the People block under the Overview (stakeholder-map, BatchPeopleDS panel 9): drawn from memory, read once per initiative; no name, no block
496
499
  const ppl = SMAP.blockFor(id, o.ws, () => { if (artRedraw) artRedraw(); });
497
- return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}${ppl}<div class="pwd-main">${PD.stagesHtml(st, W)}${crit}${wbs}</div></div>`;
500
+ return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}${ppl}<div class="pwd-main">${PD.stagesHtml(st, W)}${lay}${crit}${wbs}</div></div>`;
498
501
  }
499
502
 
500
503
  /** The grouping ✦ the PM said no to, for this initiative: 'group:<stage>'. */
@@ -905,7 +908,7 @@ export function wire(body, h0, x0) {
905
908
  // the Viewer reuses its body for the next item: the presses read the item shown now from the body, so one set of listeners serves all
906
909
  body.__pwh = ED.writes(h0); body.__pwx = x0;
907
910
  { const o = x0 && x0.o ? x0.o() || {} : {}; ASK_AT = o.id ? { id: String(o.id), ws: o.ws || '' } : null; }
908
- { const c = cur(); if (c) { readItems(c.id, (x0.o() || {}).ws, () => redraw()); readCrit(c.id, (x0.o() || {}).ws, () => redraw()); if (c.S.top) body.scrollTop = c.S.top; }
911
+ { const c = cur(); if (c) { readItems(c.id, (x0.o() || {}).ws, () => redraw()); readCrit(c.id, (x0.o() || {}).ws, () => redraw()); if (!RO && !phone()) TLY.read((x0.o() || {}).ws, c.id, () => redraw()); if (c.S.top) body.scrollTop = c.S.top; }
909
912
  const q = OPEN_ON_DRAW;
910
913
  if (c && q && q.id === String(c.id) && Date.now() - q.at < 15000) { OPEN_ON_DRAW = null; setTimeout(() => { const c2 = cur(); if (c2) openSmall(q.uid, c2, body.__pwh, body.__pwx, body); }, 0); } }
911
914
  if (body.__pw) return;
@@ -987,6 +990,8 @@ export function wire(body, h0, x0) {
987
990
  if ('pwTickNo' in d) { const u = S.tickAsk; S.tickAsk = ''; redraw(); if (u && h.status) await h.status(u, 'Done'); return; }
988
991
  if (d.pwSub) { const u = d.pwSub, open = b.getAttribute('aria-expanded') === 'true'; S.subOpen.delete(u); S.subShut.delete(u); (open ? S.subShut : S.subOpen).add(u); redraw(); return; }
989
992
  if ('pwEpicFix' in d) { b.disabled = true; await epicFix(c, h, x); return; }
993
+ if (d.tlPick) { b.disabled = true; const at = atOf(h, x); await TLY.pick(at.ws, c.id, d.tlPick, { toast: h.toast, undoToast, redraw }); return; }
994
+ if ('tlUndo' in d) { b.disabled = true; const at = atOf(h, x); await TLY.undo(at.ws, c.id, { toast: h.toast, redraw }); return; }
990
995
  if ('pwCritOk' in d) { b.disabled = true; await critFix(c, h, x); return; }
991
996
  if ('pwCritDrop' in d) { const dd = dropped(); dd.add('crit:' + c.id); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
992
997
  if ('pwEpicDrop' in d) { const dd = dropped(); dd.add('epic:' + c.id); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
@@ -47,6 +47,7 @@ export function mountToday(ctx) {
47
47
  readReports();
48
48
  readQuestions();
49
49
  readSignoffs();
50
+ readSwitches();
50
51
  readLine();
51
52
  readDigest();
52
53
  readSync();
@@ -182,6 +183,29 @@ export function mountToday(ctx) {
182
183
  X.soSeen = next; X.signoffs = rows; X.signoffSuggest = suggest;
183
184
  draw();
184
185
  }
186
+ /* switch-owners (A263, LINE.md Rule 12): each product's switch turns that wait on the PM (GET /api/switches), one Your move row each. A
187
+ * product that does not answer is left out; with nothing waiting there is no row (zero is silence). */
188
+ async function readSwitches() {
189
+ const P = ((ctx.S.M && ctx.S.M.products) || []).filter((p) => p && p.model);
190
+ const L = [...new Set((P.length ? P.map((p) => p.ws || ctx.boardWs() || '') : [ctx.boardWs() || '']))];
191
+ const got = await Promise.all(L.map((ws) => ctx.pmGet('/api/switches' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)));
192
+ const rows = [];
193
+ got.forEach((r, i) => { if (!r || !r.ok) return; for (const w of r.switches || []) if (w && w.waiting) rows.push({ ...w, ws: L[i] }); });
194
+ const next = JSON.stringify(rows);
195
+ if (next === (X.swSeen || '[]')) return;
196
+ X.swSeen = next; X.switches = rows;
197
+ draw();
198
+ }
199
+ /** ✓ "I turned it in the product" or ✕ "keep it as it is" on a switch row: the PM's own press, the one way its recorded state changes. */
200
+ async function switchPress(r, yes) {
201
+ const w = r.ref || {};
202
+ const res = await ctx.pmPost('/api/switches', { ws: w.ws || null, act: yes ? 'confirm' : 'cancel', id: w.id }).catch(() => null);
203
+ if (!res || !res.ok) return ctx.toast((res && res.error) || 'It did not go through. Nothing changed.');
204
+ const n = res.row || w;
205
+ ctx.toast(yes ? `${n.name} is ${n.on ? 'on' : 'off'} for ${n.customer}.` : `${n.name} stays ${n.on ? 'on' : 'off'} for ${n.customer}.`);
206
+ await readSwitches();
207
+ return after(true);
208
+ }
185
209
  /** ✓ on a sign-off row: recorded with its source; when it was the stage's last missing item the stage moves in the same press. One Undo. */
186
210
  async function signoffRecord(r) {
187
211
  const s = r.ref || {};
@@ -314,6 +338,7 @@ export function mountToday(ctx) {
314
338
  const L = TM.logModel({ rank: ctx.rank(), move, items: tdItems(), drafts, review: R && R.open && !R.done ? { title: 'Your weekly review' } : null,
315
339
  own: X.log.entries, marks: X.log.marks, lab, questions: X.questions || [], titleOf: ctx.titleOf, productOf, now, fixed: X.log.fixed || {},
316
340
  signoffs: X.signoffs || [], signoffSuggest: X.signoffSuggest || [],
341
+ switches: X.switches || [],
317
342
  // your-move (A468): an initiative's ship date is its board end date; a line with no default on work that ships soon blocks it
318
343
  shipOf: (id) => { const r = byId.get('i:' + id); return (r && r.board && r.board.end) || ''; } });
319
344
  if (L.move.length !== X.ymN) { X.ymN = L.move.length; console.info('[your-move] rows=' + L.move.length + ' shown=' + L.first.length + (L.move[0] ? ' first-tier=' + L.move[0].tier : '')); }
@@ -463,6 +488,7 @@ export function mountToday(ctx) {
463
488
  if (r.src === 'item') { if (r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini); return; } pop(r); import('./home-work.js').then((M) => M.openWorkItem(ref.key)).catch(() => {}); return; }
464
489
  if (r.src === 'question') { openQuestion(ref); return; }
465
490
  if (r.src === 'signoff') { if (ref.ini && ctx.hasIni(ref.ini)) ctx.goIni(ref.ini); return; }
491
+ if (r.src === 'switch') { location.href = '/premium-board.html' + (ref.ws ? '?ws=' + encodeURIComponent(ref.ws) : ''); return; } // the Switches block on Work
466
492
  if (r.src === 'signoff-by') { if (ref.ini && ctx.hasIni(ref.ini)) ctx.goIni(ref.ini); return; }
467
493
  if (r.src === 'draft') { pop(r); ctx.openFinished(ref.fin); return; }
468
494
  if (r.src === 'review') { pop(r); ctx.openReviewVw(); return; }
@@ -765,7 +791,7 @@ export function mountToday(ctx) {
765
791
  }
766
792
  if (act === 'open' && key === 'digest') { openDigest(); return; }
767
793
  const r = rowOf(key); if (!r) return;
768
- if (r.tier != null && (act === 'open' || act === 'done' || act === 'tomorrow' || /^(so|sb)-/.test(act))) noteUse('ym-act'); // your-move's health number
794
+ if (r.tier != null && (act === 'open' || act === 'done' || act === 'tomorrow' || /^(so|sb|sw)-/.test(act))) noteUse('ym-act'); // your-move's health number
769
795
  if (act === 'q-remind') { remindQuestion(r.ref); return; }
770
796
  if (act === 'open') { open(r); return; }
771
797
  if (act === 'so-open') { signoffOpen(r); return; }
@@ -783,6 +809,7 @@ export function mountToday(ctx) {
783
809
  else if (act === 'plain') await plain(r);
784
810
  else if (act === 'lab-keep' || act === 'lab-drop') await lab(r, act === 'lab-keep');
785
811
  else if (act === 'so-record') await signoffRecord(r);
812
+ else if (act === 'sw-yes' || act === 'sw-no') await switchPress(r, act === 'sw-yes');
786
813
  else if (act === 'so-ask') await signoffAsk(r);
787
814
  else if (act === 'sb-keep' || act === 'sb-change') await signoffSuggest(r, act === 'sb-keep');
788
815
  else if (act === 'lk-yes' || act === 'lk-no') await looks(r, act === 'lk-yes');
@@ -143,7 +143,7 @@ function typeOf(r) {
143
143
  const ref = r.ref || {};
144
144
  if (r.bullet === 'note' || r.src === 'note') return 'Note';
145
145
  if (r.src === 'draft') return 'Report';
146
- if (r.src === 'lab' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by') return 'Decision';
146
+ if (r.src === 'lab' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch') return 'Decision';
147
147
  if (r.src !== 'ask') return 'Task';
148
148
  switch (ref.kind) {
149
149
  case 'mention': return 'Ask';
@@ -161,7 +161,8 @@ function typeOf(r) {
161
161
  * questions: GET /api/open-questions lines, each with its ws (open-questions-today), titleOf(ini) → the initiative's name,
162
162
  * shipOf(ini) → its ship date 'YYYY-MM-DD' or '' (Your move: a line with no default on work that ships soon blocks it), now,
163
163
  * fixed: GET /api/today-log fixed ({ [ws]: keys }, quiet-rows: the line rows Your move shows today per product),
164
- * signoffs: GET /api/stage-signoffs rows, each with its ws; signoffSuggest: its suggest list (factory-signoffs-reach-you) }
164
+ * signoffs: GET /api/stage-signoffs rows, each with its ws; signoffSuggest: its suggest list (factory-signoffs-reach-you);
165
+ * switches: GET /api/switches rows with a waiting turn, each with its ws (switch-owners) }
165
166
  * quiet-rows: the drafts in the outbox are one row, Today's batch (pm/quiet-rows.js batchRow); Your move keeps at most 3 line rows a day per
166
167
  * product (capLine), the rest wait under Later (`held`), and `toFix` is what the page writes once to the day ledger.
167
168
  * A row: { key, src, bullet, first, title, work, ini, ws, job, when, late, carried, done, dates: 'task' | 'item' | 'mark', drop, ref }
@@ -272,6 +273,13 @@ export function logModel(o = {}) {
272
273
  put({ key: g.key, src: 'signoff-by', bullet: 'task', title: 'Sign-offs for ' + (g.stageName || g.stage) + ': ' + items.join(', '), ini: null, ws: g.ws || '', work: '', job: 'Decide',
273
274
  carried: 0, late: false, when: '', reason: 'PMOS suggests ' + (items.length === 1 ? 'it is' : 'they are') + ' a person’s yes, by ' + [...new Set(Object.values(g.by))].join(', '), age: 0, ref: g });
274
275
  }
276
+ // switch-owners (A263, LINE.md Rule 12): a switch turn that waits on the PM is one Decide row, ✓ "I turned it" or ✕ "keep it". PMOS turns nothing
277
+ for (const w of o.switches || []) {
278
+ if (!w || !w.id || !w.waiting) continue;
279
+ const at = String(w.waiting.at || '').slice(0, 10);
280
+ put({ key: 'switch:' + (w.ws || '') + ':' + w.id, src: 'switch', bullet: 'task', title: 'Turn ' + w.name + ' ' + w.waiting.to + ' for ' + w.customer, ini: null, ws: w.ws || '', work: '', job: 'Decide',
281
+ carried: 0, late: false, when: '', reason: 'Waits for you: PMOS turns nothing', age: at ? Math.max(0, between(at, today) || 0) : 0, ref: w });
282
+ }
275
283
  oneLine(out);
276
284
  // a row done today whose source has let it go keeps its × from what it said when it was done
277
285
  for (const [k, m] of Object.entries(marks)) {
@@ -448,10 +456,10 @@ export function costOf(r, today, shipOf = () => '') {
448
456
  if (r.type === 'Ask' && !(r.who && r.who.length)) return null; // nobody waits on the answer
449
457
  if (r.src === 'batch') return [2, r.left == null ? QR.LAPSE_DAYS : r.left, r.why]; // quiet-rows: Today's batch, a send today, soonest lapse first
450
458
  const ref = r.ref || {}, c = ref.call || null, ld = lateDays(r, today);
451
- const waits = r.src === 'ask' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'draft' || r.src === 'review' || (r.src === 'own' && r.first) || ld > 0;
459
+ const waits = r.src === 'ask' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch' || r.src === 'draft' || r.src === 'review' || (r.src === 'own' && r.first) || ld > 0;
452
460
  if (!waits) return null;
453
461
  if (r.src === 'own' && r.first) return [0, 0, 'You marked it first'];
454
- const age = r.src === 'question' || r.src === 'signoff' ? r.age || 0 : r.carried || 0;
462
+ const age = r.src === 'question' || r.src === 'signoff' || r.src === 'switch' ? r.age || 0 : r.carried || 0;
455
463
  const ship = r.ini ? String(shipOf(r.ini) || '') : '', sd = ship ? between(today, ship) : null;
456
464
  const dflt = r.src === 'question' && r.hasDefault && r.due ? r.due : '';
457
465
  if (sd != null && sd >= 0 && sd <= SHIP_SOON && !dflt) return [1, sd, shipWhy(ship, today) + (r.src === 'question' ? '; no safe default' : '')];
@@ -461,7 +469,7 @@ export function costOf(r, today, shipOf = () => '') {
461
469
  if (r.type === 'Ask' && r.carried >= 1) return [3, -r.carried, names(r.who) + ' ' + (r.who.length > 1 ? 'wait' : 'waits') + ' on you ' + plural(r.carried, 'day', 'days')];
462
470
  if (c && c.kind === 'session' && (c.state === 'blocked' || c.state === 'needs')) return [3, 0, 'A session waits on you; its work stops until you answer'];
463
471
  if (r.src === 'question') return [4, -age, r.reason || 'Waits on you ' + plural(age, 'day', 'days')];
464
- if (r.src === 'signoff' || r.src === 'signoff-by') return [4, -age, r.reason || 'Waits on you'];
472
+ if (r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch') return [4, -age, r.reason || 'Waits on you'];
465
473
  const w = whyOf(r, today);
466
474
  return [4, -age, w && !/^Waits on you$/.test(w) ? w : age ? 'Waits on you ' + plural(age, 'day', 'days') : 'Waits on you'];
467
475
  }
@@ -84,6 +84,12 @@ export function signoffActs(r) {
84
84
  return ib('so-ask', 'Ask in the tracker: ' + (s.draft || t), I.send, r.key);
85
85
  }
86
86
 
87
+ /** switch-owners (A263): ✓ records that the PM turned the switch in the product; ✕ keeps it as it is. PMOS turns nothing itself. */
88
+ export function switchActs(r) {
89
+ const w = r.ref || {}, to = (w.waiting || {}).to || '';
90
+ return ib('sw-yes', 'I turned ' + w.name + ' ' + to + ' for ' + w.customer, I.yes, r.key) + ib('sw-no', 'Keep ' + w.name + ' ' + (w.on ? 'on' : 'off') + ' for ' + w.customer, I.no, r.key);
91
+ }
92
+
87
93
  /** name-links (A536): the words of a line you typed, with the names that resolve to one record as links (r.ref.links: GET /api/name-links);
88
94
  * any other row's words, escaped. The words never change. */
89
95
  export function ownWords(r) { return r && r.src === 'own' && r.ref && r.ref.links ? linkedHtml(r.title, r.ref.links, esc) : esc(r && r.title); }
@@ -96,6 +102,7 @@ export function rowHtml(r, o = {}) {
96
102
  if (!r.done && r.src !== 'note') {
97
103
  if (r.src === 'question') acts = ib('open', 'Answer: ' + t, I.decide, r.key); // the register's line: it is answered where it opens, not marked done here
98
104
  else if (r.src === 'signoff' || r.src === 'signoff-by') acts = signoffActs(r);
105
+ else if (r.src === 'switch') acts = switchActs(r);
99
106
  else if (r.src === 'lab') acts = ib('lab-keep', 'Keep it: start an initiative from ' + t, I.yes, r.key) + ib('lab-drop', 'Drop it: ' + t, I.no, r.key);
100
107
  else {
101
108
  const j = JOB_ACT[r.job];
@@ -184,12 +191,13 @@ export function overviewHtml(O) {
184
191
  * work, the kind, the age), the ✦ line that says why it is in that place, and two icon Buttons: one action for its kind, and Put off a day. */
185
192
  export const YM_SHOW = 5;
186
193
  const KIND_WORD = { Ask: 'reply', Decision: 'a decision', Check: 'a check', Milestone: 'a date change', Task: 'task', Report: 'a draft to send' };
187
- const ageOf = (r) => Math.max(0, r.src === 'question' || r.src === 'signoff' ? r.age || 0 : r.carried || 0);
194
+ const ageOf = (r) => Math.max(0, r.src === 'question' || r.src === 'signoff' || r.src === 'switch' ? r.age || 0 : r.carried || 0);
188
195
  /** The one action of a Your move row: an answer, a reply, a decision or a send opens the item; a thing to do is Done. */
189
196
  function moveAct(r) {
190
197
  const t = r.title;
191
198
  if (r.src === 'question') return ib('open', 'Answer: ' + t, I.decide, r.key);
192
199
  if (r.src === 'signoff' || r.src === 'signoff-by') return signoffActs(r);
200
+ if (r.src === 'switch') return switchActs(r);
193
201
  const j = JOB_ACT[r.job];
194
202
  if (j) return ib('open', j[1] + ': ' + t, j[2], r.key);
195
203
  if (r.members) return ib('open', 'Show them: ' + t, I.more, r.key, ` aria-expanded="false"`);
@@ -343,6 +351,7 @@ export function swipeActs(r) {
343
351
  if (r.looks) return { right: 'lk-yes', left: 'lk-no' };
344
352
  if (r.members && r.drafts) return { right: 'same-yes', left: 'same-no' };
345
353
  // a Your move row (your-move): right does its action, so a reply, an answer, a decision or a send opens the item; left puts it off a day
354
+ if (r.src === 'switch') return { right: '', left: 'tomorrow' }; // a turn is recorded by a press, never by a swipe
346
355
  if (r.src === 'signoff-by') return { right: 'sb-keep', left: 'tomorrow' };
347
356
  if (r.src === 'signoff') { const a = (r.ref || {}).action; return { right: a === 'record' ? 'so-record' : a === 'open' ? 'so-open' : 'so-ask', left: 'tomorrow' }; }
348
357
  if (r.tier != null && (r.src === 'question' || JOB_ACT[r.job] || r.members)) return { right: 'open', left: 'tomorrow' };
@@ -30,10 +30,24 @@ function wordKind(w) {
30
30
  return '';
31
31
  }
32
32
 
33
- /** The item's kind from its own fields (kind, lane, type, issuetype), never from its title. */
33
+ /** The kind a workflow's name (or id) names: "Simple feature" → feature, "Bug triage" → fix; '' when it names none. */
34
+ export function workflowKind(wf) {
35
+ if (!wf || typeof wf !== 'object') return '';
36
+ for (const src of [wf.name, wf.id]) {
37
+ const w = norm(String(src == null ? '' : src).replace(/[-]+/g, ' ')).split(' ').filter(Boolean);
38
+ for (let i = 0; i < w.length; i++) { const k = wordKind(w[i] + ' ' + (w[i + 1] || '')) || wordKind(w[i]); if (k) return k; }
39
+ }
40
+ return '';
41
+ }
42
+
43
+ /** The item's kind from its own fields, never from its title. An initiative on a workflow (a row with `wf`): the kind its workflow
44
+ * names, else its lane; a legacy `type:` decides nothing there, since the workflow sets the kind (kind-follows-workflow, #1731).
45
+ * Any other item: kind, lane, type (a Jira issue type). */
34
46
  export function kindOf(item) {
35
47
  if (!item || typeof item !== 'object') return 'other';
36
- for (const f of ['kind', 'lane', 'type', 'issuetype']) {
48
+ const onWf = item.wf && typeof item.wf === 'object';
49
+ if (onWf) { const k = workflowKind(item.wf); if (k) return k; }
50
+ for (const f of onWf ? ['lane'] : ['kind', 'lane', 'type', 'issuetype']) {
37
51
  const v = valOf(item[f]);
38
52
  const k = wordKind(v && typeof v === 'object' ? v.name : v);
39
53
  if (k) return k;