create-pmos 0.422.0 → 0.424.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 (102) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +28 -0
  8. package/workspace/briefing-premium-adddoc-test.js +1 -1
  9. package/workspace/briefing-premium-board-test.js +12 -10
  10. package/workspace/briefing-premium-initiative-test.js +30 -38
  11. package/workspace/briefing-premium-products-test.js +16 -3
  12. package/workspace/changelog.json +24 -0
  13. package/workspace/guide/briefing-premium.md +1 -1
  14. package/workspace/guide/claude-proposes.md +37 -0
  15. package/workspace/guide/home.md +9 -2
  16. package/workspace/guide/index.md +1 -0
  17. package/workspace/guide/programs.md +1 -0
  18. package/workspace/guide/workflows.md +5 -1
  19. package/workspace/home-pill-test.js +138 -0
  20. package/workspace/ini-workflow-test.js +4 -4
  21. package/workspace/lib/board-premium.js +3 -2
  22. package/workspace/lib/custom-docs.js +65 -3
  23. package/workspace/lib/engine/boards.js +25 -2
  24. package/workspace/lib/headless.js +14 -1
  25. package/workspace/lib/initiative-writer.js +63 -1
  26. package/workspace/lib/plan-items.js +36 -5
  27. package/workspace/lib/pmos-verbs.js +3 -0
  28. package/workspace/lib/programs.js +11 -3
  29. package/workspace/lib/proposal-runs.js +148 -0
  30. package/workspace/lib/proposals.js +370 -0
  31. package/workspace/lib/propose-cli.js +96 -0
  32. package/workspace/lib/route-modules.js +2 -0
  33. package/workspace/lib/routes-board-premium.js +33 -0
  34. package/workspace/lib/routes-boards.js +50 -10
  35. package/workspace/lib/routes-initiatives.js +12 -0
  36. package/workspace/lib/routes-proposals.js +325 -0
  37. package/workspace/lib/routes-task-links.js +336 -0
  38. package/workspace/lib/split-merge-suggest.js +162 -0
  39. package/workspace/lib/split-merge.js +379 -0
  40. package/workspace/lib/task-cli.js +58 -5
  41. package/workspace/lib/task-items.js +14 -2
  42. package/workspace/lib/task-links.js +422 -0
  43. package/workspace/package-lock.json +2 -2
  44. package/workspace/package.json +1 -1
  45. package/workspace/premium-board-actions-test.js +4 -4
  46. package/workspace/premium-core-doc-issue-test.js +2 -2
  47. package/workspace/premium-vw-backlog-test.js +3 -3
  48. package/workspace/premium-vw-item-test.js +3 -3
  49. package/workspace/premium-vw-jira-test.js +6 -6
  50. package/workspace/product-lane-test.js +165 -0
  51. package/workspace/program-panel-test.js +1 -1
  52. package/workspace/public/pm/bd-asks.js +3 -0
  53. package/workspace/public/pm/bd-ini-panel.js +16 -6
  54. package/workspace/public/pm/bd-prog.js +6 -1
  55. package/workspace/public/pm/bd-span.js +69 -15
  56. package/workspace/public/pm/bd-views.js +3 -2
  57. package/workspace/public/pm/cozy-board.css +10 -0
  58. package/workspace/public/pm/cozy-today.css +23 -0
  59. package/workspace/public/pm/cozy-viewer.js +14 -3
  60. package/workspace/public/pm/cozy-vw-shell.css +8 -0
  61. package/workspace/public/pm/home-app.js +45 -14
  62. package/workspace/public/pm/home-ini-model.js +0 -34
  63. package/workspace/public/pm/home-ini.js +72 -204
  64. package/workspace/public/pm/home-task.js +2 -1
  65. package/workspace/public/pm/home-today.js +66 -16
  66. package/workspace/public/pm/ini-groups.js +253 -0
  67. package/workspace/public/pm/ini-links.js +519 -0
  68. package/workspace/public/pm/ini-props.js +218 -0
  69. package/workspace/public/pm/ini-tasks.js +58 -22
  70. package/workspace/public/pm/ini-versions.js +14 -9
  71. package/workspace/public/pm/ini-view-model.js +93 -4
  72. package/workspace/public/pm/ini-view.css +306 -18
  73. package/workspace/public/pm/ini-view.js +161 -36
  74. package/workspace/public/pm/premium-board.js +54 -6
  75. package/workspace/public/pm/premium-vw-item.js +2 -1
  76. package/workspace/public/pm/split-merge.css +77 -0
  77. package/workspace/public/pm/split-merge.js +265 -0
  78. package/workspace/public/pm/stage-line.js +414 -0
  79. package/workspace/public/pm/task-card.css +13 -0
  80. package/workspace/public/pm/task-card.js +42 -5
  81. package/workspace/public/pm/wf-page.css +2 -0
  82. package/workspace/public/pm/wf-page.js +2 -0
  83. package/workspace/public/pm/wf-stage.js +2 -1
  84. package/workspace/server.js +52 -3
  85. package/workspace/skills/initiative-propose.skill +45 -0
  86. package/workspace/split-merge-ui-test.js +175 -0
  87. package/workspace/stage-card-test.js +13 -12
  88. package/workspace/task-card-test.js +3 -2
  89. package/workspace/task-delete-test.js +126 -0
  90. package/workspace/task-links-test.js +239 -0
  91. package/workspace/task-milestones-test.js +1 -1
  92. package/workspace/task-plans-test.js +6 -0
  93. package/workspace/task-views-test.js +1 -1
  94. package/workspace/test-lists/bd-ini-panel.json +8 -2
  95. package/workspace/test-lists/claude-proposes.json +5 -0
  96. package/workspace/test-lists/home-sessions-pill.json +6 -0
  97. package/workspace/test-lists/product-lane.json +6 -0
  98. package/workspace/test-lists/split-merge.json +15 -0
  99. package/workspace/test-lists/task-delete.json +5 -0
  100. package/workspace/test-lists/task-links.json +6 -0
  101. package/workspace/tk-tasks-test.js +186 -57
  102. package/workspace/workflows-setup-test.js +4 -3
@@ -7,7 +7,10 @@
7
7
  * iniPage() the initiative's page in the Viewer: the ONE view the Board's panel draws too (ini-view.js; batch 6 items 1 and 3):
8
8
  * summary, stage card with the dates line, Tasks as the WBS, Documents and Linked. The next stage opens the move sheet;
9
9
  * Documents drills into the documents view, with ← back to the page. true when it opened.
10
- * iniOverview(v, o) the initiative in the Viewer: Tasks (the default), Documents or Stage; o.back keeps the page behind it. true when it opened.
10
+ * iniOverview(v, o) the initiative in the Viewer: Documents or Stage; o.back keeps the page behind it. true when it opened. Any other view
11
+ * opens the page: the old All tasks panel is gone (batch 11 item 20), its Group by and Send to Jira live in the page's Tasks
12
+ * (ini-groups.js).
13
+ * iniAddTask() New → A task: the page with the Tasks field open and the cursor in it (XtaA4NewTask). true when it opened.
11
14
  *
12
15
  * The stage move (stage card D, canvas XscD and XscDDesk; it replaced InStage's switch, Move to <next> and Back on the card): the card's last
13
16
  * node is the next stage (home-stage-card.js). A press opens the move sheet on the phone and a popover under it on a desktop, with the
@@ -16,17 +19,13 @@
16
19
  * (Move anyway, with a note); Back always asks for a reason. Both go to POST /api/boards/move
17
20
  * with the note or reason as the move's why. When every exit item is done and the switch is on, the page moves the stage by itself, never into a
18
21
  * milestone (Deliver, Evaluate), and says so in a toast with Undo; Undo moves it back and keeps it from moving out of that stage by itself again.
19
- * Tasks (InTasks): grouped by stage, by groups the PM names (drag a task between them; group sets are saved for the workspace), by owner, by status
20
- * or not at all. Core documents (InDocs): the list column shows only the documents that need a look; the Viewer lists them all with their details.
22
+ * Core documents (InDocs): the list column shows only the documents that need a look; the Viewer lists them all with their details.
21
23
  * Every write is the PM's press, file mode only: /api/boards/move, /api/boards/tasks/*, /api/lifecycle, /api/core-docs/draft, /api/initiative-layout.
22
24
  *
23
- * PRD to Jira (kit 2, T1 to T3; canvas PgTkList, PgTkSent, XvATasks): Tasks group by Epic too, the default once the PRD's stories have
24
- * drafted tickets (GET /api/jira/tickets). Each epic group lists its tasks, the drafted Jira tickets; its send icon opens the Send sheet
25
- * (tk-send.js), and a task opens its drafted ticket (tk-draft.js) or, once in Jira, the ticket's Jira view. The PM's own tasks follow
26
- * under "Your tasks". In shell A the summary card comes first and the group picker, Documents, Stage, the record and the sprint sit
27
- * under ⋯; the phone keeps the Tasks | Documents | Stage switch. The pure half of the tickets is tk-model.js. */
25
+ * Grouping the tasks (by epic, your groups, owner or status) and sending the drafted tickets to Jira were the old All tasks panel's; since
26
+ * batch 11 item 20 they are the page's Tasks section's, the same on the Board (ini-groups.js). In shell A Documents and Stage open from the
27
+ * page; the phone keeps the Documents | Stage switch. */
28
28
  import * as MD from './home-ini-model.js';
29
- import * as TKM from './tk-model.js';
30
29
  import * as WF from './ini-wf.js';
31
30
  import * as SC from './home-stage-card.js';
32
31
  import { viewHtml, wireView } from './ini-view.js'; // the one initiative view, the Board's panel's own renderer
@@ -40,8 +39,7 @@ const I = {
40
39
  };
41
40
  const PHONE = 760;
42
41
  const isPhone = () => innerWidth <= PHONE;
43
- const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'tasks', doc: { by: 'stage', filter: 'all', more: new Set() }, shut: new Set(), pop: null, toastT: 0, addTo: '',
44
- T: new Map(), tReading: new Set(), fold: new Map(), more: new Set() };
42
+ const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'page', doc: { by: 'stage', filter: 'all', more: new Set() }, pop: null, toastT: 0 };
45
43
 
46
44
  /* ── reading the layout record ── */
47
45
  const curM = () => { const S = X.ctx && X.ctx.S; return S && S.ini && S.ini !== 'product' && S.IMid === S.ini ? S.IM : null; };
@@ -56,18 +54,6 @@ async function readL(id, M, force) {
56
54
  X.ctx.drawList(); redrawView();
57
55
  }
58
56
  const Lof = (id) => X.L.get(id) || { auto: true, held: [], by: 'mine', names: [], of: {}, stage: {}, sets: [], read: false };
59
- /* ── the drafted Jira tickets (T1) ── */
60
- async function readT(id, M, force) {
61
- if (!force && (X.T.has(id) || X.tReading.has(id))) return;
62
- X.tReading.add(id);
63
- const r = await X.ctx.pmGet('/api/jira/tickets?initiative=' + encodeURIComponent(id) + (wsOf(M) ? '&ws=' + encodeURIComponent(wsOf(M)) : ''));
64
- X.tReading.delete(id);
65
- X.T.set(id, r && r.ok === true ? r : { ok: false, error: (r && r.error) || 'The tickets could not be read.' });
66
- redrawView();
67
- }
68
- const Tof = (id) => X.T.get(id) || null;
69
- /** The grouping: the PM's choice; until the PM chooses, Epic once tickets are drafted. */
70
- const byOf = (L, T) => { const b = (L.picked ? L.by : T && T.ok && T.drafted ? 'epic' : L.by) || 'mine'; return MD.BY_LABEL[b] ? b : 'mine'; }; // an old 'stage' reads as Your groups
71
57
  async function press(id, M, body) {
72
58
  const r = await X.ctx.pmPost('/api/initiative-layout', { ws: wsOf(M), initiative: id, ...body });
73
59
  if (r && r.ok) { X.L.set(id, { ...r, read: true }); X.ctx.drawList(); redrawView(); return true; }
@@ -259,6 +245,7 @@ export function iniList(sc) {
259
245
  * the dates line, Tasks as the WBS, Documents and Linked as folds. Home keeps its own presses: the next stage opens the move sheet, a task
260
246
  * drills into the task editor, Documents drills into the documents view. */
261
247
  let ADDING = null; // the initiative whose inline Add a task is open
248
+ let ADD_DATES = null; // the start and due a task added there takes (a gap's + under the stage card's line, batch 11 item 21)
262
249
  function pageHtml(id, M) {
263
250
  X.ctx.head(id); // the stage head the move sheet and the primary read (S.H)
264
251
  const v = X.ctx.view(id);
@@ -267,14 +254,34 @@ function pageHtml(id, M) {
267
254
  // a phone: the page is a sheet over the list, and the chat is one press away (HbCPhone)
268
255
  const talk = isPhone() ? `<button type="button" class="hi-talk" data-hi-talk>Message Claude about ${esc(X.ctx.iniTitle(id))}</button>` : '';
269
256
  return `<div class="hi-v hi-page" data-hi-v="page">${WF.endedHtml(rowOf(id))}`
270
- + viewHtml(v, { add: true, adding: ADDING === id, next: !!v.stage.next, openTask: true, quick: true, docs: docs.length ? { n: docs.length } : null, wf: !(M.acts && M.acts.self) && !rowOf(id).ended })
257
+ + viewHtml(v, { add: true, adding: ADDING === id, addHint: ADDING === id && ADD_DATES ? ADD_DATES.start + ' to ' + ADD_DATES.due : '', hold: true, next: !!v.stage.next, openTask: true, quick: true, docs: docs.length ? { n: docs.length } : null, wf: !(M.acts && M.acts.self) && !rowOf(id).ended })
271
258
  + `${talk}<p class="hi-small" role="status" id="ovMsg"></p></div>`;
272
259
  }
260
+ /** A hold's card from the stage card (batch 11 item 21): its words and the return date, which writes an on-hold line with the new date
261
+ * (POST /api/lifecycle, the same write as the Board's hold menu), or Resume. */
262
+ function holdPop(anchor, id) {
263
+ const M = curM(); if (!M) return;
264
+ const r = rowOf(id), a = r.acts || {};
265
+ openPop(anchor, 'hold', `<p class="hi-h3">On hold${a.reason ? ': ' + esc(a.reason) : ''}</p>`
266
+ + `<label class="hi-field"><span>Back on</span><input id="hiBack" type="date" value="${esc(a.back || '')}"></label>`
267
+ + `<div class="hi-acts"><button type="button" class="hi-btn dark" data-hi-go>Save</button><button type="button" class="hi-btn ghost" data-hi-resume>Resume now</button></div>`,
268
+ async (b, el) => {
269
+ const say = (res, m) => { if (res && res.ok !== false) { X.ctx.toast(m); X.ctx.load().then(() => redrawView()); } else X.ctx.toast((res && res.error) || 'Nothing was changed.'); };
270
+ if ('hiResume' in b.dataset) { closePop(); say(await X.ctx.pmPost('/api/lifecycle', { ws: M.board.ws, initiative_id: id, state: 'active', reason: 'resumed' }), 'Resumed.'); return; }
271
+ if ('hiGo' in b.dataset) {
272
+ const v = el.querySelector('#hiBack').value; if (!/^\d{4}-\d{2}-\d{2}$/.test(v)) return;
273
+ closePop(); say(await X.ctx.pmPost('/api/lifecycle', { ws: M.board.ws, initiative_id: id, state: 'on-hold', reason: a.reason || 'Held from the stage card', back: v }), 'Back on ' + v + '.');
274
+ }
275
+ }, { label: 'On hold', sheetFocus: '#hiBack' });
276
+ }
273
277
  /** The one view's presses on Home's page. */
274
278
  function wirePage(b, id) {
275
279
  const C = X.ctx, say = (m) => C.toast(m);
276
280
  wireView(b, {
277
281
  redraw: () => redrawView(),
282
+ // Claude's split or merge card (batch 11 item 14): ✕ Not now, ✎ Change it first, ✓ as suggested; the merged summary's link opens the one that stays
283
+ sm: (act) => { if (C.smPress) C.smPress(id, act); },
284
+ openIni: (to) => { if (C.goIni) C.goIni(to); },
278
285
  // planned versus actual (batch 11 item 8, pm/ini-versions.js): where a draft's writes go, the read after Make live, the toast with Undo
279
286
  where: () => { const M = curM(); return M ? bw(M) : {}; },
280
287
  reload: async () => { await C.load(); redrawView(); },
@@ -286,6 +293,7 @@ function wirePage(b, id) {
286
293
  status: (uid, state) => setState(id, uid, state),
287
294
  dates: (uid, patch) => setDates(id, uid, patch),
288
295
  milestone: (uid, on) => setDates(id, uid, { milestone: !!on }), // the ◇ in the status picker (batch 11 item 3)
296
+ remove: (uid) => removeTask(id, uid), // the trash in the status picker (batch 11 item 16)
289
297
  openTask: (uid) => {
290
298
  const M = curM();
291
299
  const row = M && (M.tasks.rows || []).find((x) => x.uid === uid || x.key === uid || x.key === 'task:' + uid);
@@ -296,12 +304,16 @@ function wirePage(b, id) {
296
304
  if (k && C.openBoardTask) { C.VW.drill(); C.openBoardTask({ ...k, ini: id, ws: (M && M.board.ws) || r.ws || undefined, board: (M && M.board.id) || r.boardId || undefined }); return; }
297
305
  if (M) { C.VW.drill(); openTask(id, M, 'task:' + uid); }
298
306
  },
299
- add: () => { ADDING = id; redrawView(); const f = BODY && BODY.querySelector('#ivAddTask'); if (f) f.focus(); },
300
- addCancel: () => { ADDING = null; redrawView(); },
307
+ // a Jira ticket in Tasks opens its ticket view (batch 11 item 20: the old All tasks panel was the only other way in)
308
+ openTicket: async (key) => { const M = curM(); if (!M) return; C.VW.drill(); (await import('./premium-vw-jira.js')).openTicket({ ...bw(M), initiative: id, ref: key }); },
309
+ add: (b, dates) => { ADDING = id; ADD_DATES = dates && dates.start ? dates : null; redrawView(); const f = BODY && BODY.querySelector('#ivAddTask'); if (f) f.focus(); },
310
+ addCancel: () => { ADDING = null; ADD_DATES = null; redrawView(); },
311
+ // the stage card's ⏸ or calendar on a hold (batch 11 item 21): what the hold says, and its return date set or changed here
312
+ hold: (i, btn) => holdPop(btn, id),
301
313
  addTask: async (title, inp) => {
302
314
  const M = curM(); if (!M) return;
303
315
  inp.disabled = true;
304
- const r = await C.pmPost('/api/boards/tasks/add', { ...bw(M), initiative: id, title });
316
+ const r = await C.pmPost('/api/boards/tasks/add', { ...bw(M), initiative: id, title, ...(ADD_DATES ? { start: ADD_DATES.start, due: ADD_DATES.due } : {}) });
305
317
  inp.disabled = false;
306
318
  if (!r || r.ok === false) { say((r && r.error) || 'The task was not added.'); return; }
307
319
  say('Task added.'); await C.load(); redrawView();
@@ -333,6 +345,15 @@ async function setState(id, uid, state) {
333
345
  if (was && was !== state && !(k.item && state === "Won't do")) undoToast(state + ': ' + k.title + '.', async () => { const u = await C.pmPost('/api/boards/tasks/state', { ...body, state: was }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
334
346
  else C.toast(state + (k ? ': ' + k.title : '') + '.');
335
347
  }
348
+ /** The status picker's trash (batch 11 item 16): POST /api/boards/tasks/delete, a Board task or a breakdown item; Undo restores it. */
349
+ async function removeTask(id, uid) {
350
+ const M = curM(); if (!M) return;
351
+ const k = taskAt(id, uid), C = X.ctx, body = { ...bw(M), task: uid }, title = (k && k.title) || uid;
352
+ const r = await C.pmPost('/api/boards/tasks/delete', body);
353
+ if (!r || r.ok === false) { C.toast((r && r.error) || 'The task was not deleted.'); return; }
354
+ await C.load(); redrawView();
355
+ undoToast('Deleted · ' + title + '.', async () => { const u = await C.pmPost('/api/boards/tasks/restore', body); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
356
+ }
336
357
  /** The quick dates (the date press, a Timeline drag): POST /api/boards/tasks/edit, Undo puts the old days back. */
337
358
  async function setDates(id, uid, patch) {
338
359
  const M = curM(); if (!M) return;
@@ -340,9 +361,9 @@ async function setDates(id, uid, patch) {
340
361
  const r = await C.pmPost('/api/boards/tasks/edit', { ...body, ...patch });
341
362
  if (!r || r.ok === false) { C.toast((r && r.error) || 'Nothing was changed.'); return; }
342
363
  await C.load(); redrawView();
343
- const back = {}; for (const f of Object.keys(patch)) back[f] = f === 'milestone' ? (r.from && 'milestone' in r.from ? !!r.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : '';
364
+ const back = {}; for (const f of Object.keys(patch)) back[f] = f === 'milestone' ? (r.from && 'milestone' in r.from ? !!r.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : r.from && f in r.from ? r.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
344
365
  if ('milestone' in patch) { undoToast((patch.milestone ? 'Milestone: ' : 'Not a milestone: ') + (k ? k.title : uid) + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); }); return; }
345
- if (k) undoToast('Dates saved: ' + k.title + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
366
+ if (k || (r.from && ('start' in r.from || 'due' in r.from))) undoToast('Dates saved: ' + (k ? k.title : uid + ', kept in PMOS') + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
346
367
  else C.toast('Dates saved.');
347
368
  }
348
369
  /** ⋯ of the page (HbCMore): change it, look at it elsewhere, then stop it, red and last. */
@@ -351,8 +372,6 @@ function pageMore(id) {
351
372
  const mv = mvOf(id, M), out = [], row = rowOf(id), self = !!(M.acts && M.acts.self);
352
373
  // D99 (WfAWontDo): Change workflow and Rename first; the PMOS-self board keeps its derived ladder, so it has no workflow to change
353
374
  if (!self && !row.ended) out.push({ label: 'Change workflow', note: (row.wf || {}).name || 'Product feature', on: (b) => WF.openPicker(b || moreBtn(), wfUi(), id) });
354
- // the one view lists the tasks as the WBS; grouping them by epic, owner or your own groups, and sending them to Jira, is the Tasks view
355
- out.push({ label: 'All tasks', note: 'Group, send to Jira', on: () => iniOverview('tasks', { back: true }) });
356
375
  if (X.ctx.renameIni) out.push({ label: 'Rename', on: () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } });
357
376
  if (!mv.why) out.push({ label: 'Moves on by itself', note: mv.auto ? 'On' : 'Off', on: () => (ownWf(row) ? autoPress(id, M, !mv.auto) : press(id, M, { kind: 'auto', on: !mv.auto })) });
358
377
  if (mv.canBack) out.push({ label: 'Move back a stage', note: mv.prev, on: (b) => popBack(b || document.querySelector('#czViewer [data-cz-vw="more"]'), id, M, mv) });
@@ -361,7 +380,9 @@ function pageMore(id) {
361
380
  // P7: an initiative in no program can become one; one in a program can move out of it or to another (batch 11 item 2, canvas LpA1More)
362
381
  const pm = X.ctx.moveItems ? X.ctx.moveItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], 'Move to another program')) : [];
363
382
  if (X.ctx.turnProgram && !pm.length) out.push({ label: 'Turn into a program', on: () => X.ctx.turnProgram(id) });
364
- if (pm.length) out.push({ sep: true }, ...pm);
383
+ // split it into a new initiative, or merge it into another, above the program moves (batch 11 item 14, canvas XsmA1Menu)
384
+ const sm = X.ctx.smItems && !row.ended ? X.ctx.smItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], label)) : [];
385
+ if (sm.length || pm.length) out.push({ sep: true }, ...sm, ...pm);
365
386
  out.push({ sep: true }, { label: 'Open on the Board', on: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); } },
366
387
  { label: 'The record', on: async () => (X.ctx.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }) });
367
388
  // Won't do and Archive hold from any stage (wfRules); Won't do comes back to Triage. Cancel stays red and last (HbCMore)
@@ -392,91 +413,22 @@ export function iniPage() {
392
413
  if (!curM()) { X.failed = null; X.ctx.loadIni().then(() => { if (S.ini !== id) return; if (!curM()) X.failed = id; redrawView(); }); }
393
414
  return true;
394
415
  }
416
+ /** New → A task (XtaA4NewTask): the initiative's page with the Tasks field open and the cursor in it. true when it opened. */
417
+ export function iniAddTask() {
418
+ if (!X.ctx) return false;
419
+ const id = X.ctx.S.ini, c = X.ctx.VW.current();
420
+ if (!id || id === 'product') return false;
421
+ if (!(c && c.id === 'ov:' + id && X.view === 'page') && !iniPage()) return false;
422
+ ADDING = id; redrawView();
423
+ setTimeout(() => { const f = BODY && BODY.querySelector('#ivAddTask'); if (f) f.focus(); }, 0);
424
+ return true;
425
+ }
395
426
 
396
- /* ── the Viewer: Tasks, Documents, Stage ── */
397
- const KIND = { tasks: 'Tasks', docs: 'Documents', stage: 'Stage' };
398
- const ICON = { tasks: 'list', docs: 'doc', stage: 'goal' };
427
+ /* ── the Viewer: Documents, Stage ── */
428
+ const KIND = { docs: 'Documents', stage: 'Stage' };
429
+ const ICON = { docs: 'doc', stage: 'goal' };
399
430
  let BODY = null;
400
431
  function segHtml(v) { return `<div class="cz-seg hi-seg" role="group" aria-label="Show">${Object.entries(KIND).map(([k, l]) => `<button type="button" data-hi-view="${k}" aria-pressed="${k === v}">${l}</button>`).join('')}</div>`; }
401
- function taskRowHtml(t, mine) {
402
- // a task's only stage is its state (Wawan, 2026-10-25): the checkbox, and the five states under ⋯; Won't do sits struck with the done ones
403
- return `<div class="hi-trow${t.closed ? ' done' : ''}${t.wontdo ? ' wontdo' : ''}" data-ov-tkrow="${esc(t.key)}"${mine ? ` draggable="true" data-hi-drag="${esc(t.key)}"` : ''}>`
404
- + (t.canCheck ? `<button type="button" class="hi-chk${t.done ? ' on' : ''}" data-hi-chk="${esc(t.key)}" aria-pressed="${t.done}" aria-label="${t.done ? 'Reopen' : 'Mark done'}: ${esc(t.title)}">${t.done ? SVG(I.check, 12, 3) : ''}</button>` : `<span class="hi-chk off${t.done ? ' on' : ''}" aria-hidden="true" title="${t.jira ? 'Jira keeps its state' : 'A PRD requirement has no state'}">${t.done ? SVG(I.check, 12, 3) : ''}</span>`)
405
- + `<button type="button" class="hi-tt" data-ov-tk="${esc(t.key)}" aria-label="Open ${esc(t.title)}">${esc(t.title)}${t.jira && t.ref ? ` <em>${esc(t.ref)}</em>` : ''}</button>`
406
- + (t.av ? `<span class="hi-av" title="${esc(t.owner)}">${esc(t.av)}</span>` : '') + `<span class="hi-due${t.late ? ' late' : ''}">${esc(t.due || (t.req ? 'PRD' : t.state === 'In progress' ? 'running' : ''))}</span>`
407
- + `<button type="button" class="hi-ib sm" data-hi-tmore="${esc(t.key)}" aria-haspopup="menu" aria-label="More for ${esc(t.title)}">${SVG(I.more, 14, 3)}</button></div>`;
408
- }
409
- /* ── the epic groups (T1) and shell A's summary card (XvATasks) ── */
410
- const TI = { send: 'M4 12l16-8-6 16-3-7z' };
411
- const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
412
- const foldOpen = (key, dflt) => (X.fold.has(key) ? X.fold.get(key) : dflt);
413
- /** A group header: the name, an optional send icon, the count and the fold chevron (PgTkList .gh). */
414
- function headHtml(key, title, n, open, send = '') {
415
- return `<div class="tk-gh${send ? ' s' : ''}"><button type="button" class="tk-ghb" data-tk-gfold="${esc(key)}" aria-expanded="${open}"><b>${esc(title)}</b><span class="tk-ghr"><span class="tk-gn">${n}</span>${SVG(open ? I.down : I.right, 16, 2)}</span></button>${send}</div>`;
416
- }
417
- function tkRowHtml(r) {
418
- const ck = r.inJira ? `<span class="tk-ck" role="img" aria-label="In Jira: ${esc(r.status)}"><i class="tk-sq ${esc(r.cat)}"></i></span>` : '<span class="tk-ck" aria-hidden="true"></span>';
419
- const mark = r.mark ? `<span class="tk-mk ${esc(r.mark[0])}" role="img" aria-label="${esc(r.mark[1])}" title="${esc(r.mark[1])}"></span>` : '';
420
- return `<button type="button" class="tk-row" data-tk-open="${esc(r.id)}">${ck}<span class="tk-t"><b>${esc(r.title)}</b>${r.sub ? `<span>${esc(r.sub)}</span>` : ''}</span>${mark}${r.av ? `<span class="tk-av" role="img" aria-label="Assigned to ${esc(r.who)}" title="${esc(r.who)}">${esc(r.av)}</span>` : ''}</button>`;
421
- }
422
- function epicGroupsHtml(id, M, T) {
423
- if (!T) return '<p class="hi-small" role="status">Reading the tickets.</p>';
424
- if (!T.ok) return `<p class="hi-empty">${esc(T.error)}</p>`;
425
- if (!T.drafted) return T.items
426
- ? `<div class="tk-card tk-empty"><p>The PRD lists ${plural(T.items, 'story', 'stories')}. Each one becomes a task with its Jira ticket drafted in your template. Nothing goes to Jira until you send it.</p><button type="button" class="hi-btn sm dark" data-tk-drafts>Draft the tickets</button></div>`
427
- : '<p class="hi-empty">The PRD lists no user stories yet. Give it a "User stories" section, one subheading per story, and each one becomes a task here.</p>';
428
- const out = TKM.ticketGroups(T).map((g) => {
429
- const key = 'ep:' + id + ':' + g.id, open = foldOpen(key, true);
430
- const shown = X.more.has(key) || g.rows.length <= 4 ? g.rows : g.rows.slice(0, 3);
431
- const send = g.send && !T.pushing ? `<button type="button" class="tk-snd" data-tk-sendg="${esc(g.id)}" aria-label="Send ${esc(g.name)} to Jira" title="Send to Jira">${SVG(TI.send, 17)}</button>` : '';
432
- return `<section class="tk-g" aria-label="${esc(g.name)}">${headHtml(key, g.name, g.n, open, send)}`
433
- + (open ? `<div class="tk-list">${shown.map(tkRowHtml).join('')}${shown.length < g.rows.length ? `<button type="button" class="tk-fold" data-tk-more="${esc(key)}">${g.rows.length - shown.length} more${SVG(I.down, 16, 2)}</button>` : ''}</div>` : '') + '</section>';
434
- }).join('');
435
- return out + (T.inJira && T.checkedAt ? `<p class="tk-read">${esc(TKM.readLine(T.checkedAt))}</p>` : '');
436
- }
437
- /** The summary card (shell A, desktop): what waits on the PM in the tasks, with one primary. Zero is silence. */
438
- function summaryHtml(id, M, rows, T, by) {
439
- const VW = X.ctx.VW;
440
- if (isPhone() || !VW.czSummary) return '';
441
- const open = rows.filter((r) => !r.closed && !r.req).length;
442
- const meta = [open ? open + ' open' : '', 'grouped by ' + MD.BY_LABEL[by].toLowerCase()].filter(Boolean).join(' · ');
443
- const G = T && T.ok ? TKM.ticketGroups(T) : [];
444
- const send = G.reduce((a, g) => a + g.send, 0);
445
- if (T && T.ok && T.pushing) return VW.czSummary({ line: 'Sending to Jira', tone: 'live', text: 'Claude is creating the tickets with your Atlassian connection. Each task shows its Jira key when it is done.', meta });
446
- if (send) return VW.czSummary({ line: plural(send, 'ticket is', 'tickets are') + ' drafted, not in Jira', tone: 'you', text: 'Each PRD story is a task with its Jira ticket drafted. Nothing reaches Jira until you send it.', meta, primary: { label: 'Send to Jira', act: 'tk-sendall' } });
447
- const week = Date.now() + 7 * 864e5;
448
- const due = rows.filter((r) => !r.closed && !r.req && r.end && Date.parse(r.end) <= week).sort((a, b) => a.end.localeCompare(b.end));
449
- if (!due.length) return VW.czSummary({ meta });
450
- const words = due.slice(0, 2).map((r) => r.title + (r.due ? ' ' + (/^(today|tomorrow|yesterday)$/.test(r.due) ? r.due : 'by ' + r.due) : ''));
451
- return VW.czSummary({ line: plural(due.length, 'is', 'are') + ' due this week', tone: due.some((r) => r.late) ? 'warn' : 'you', text: words.join(', and ') + '.', meta,
452
- primary: { label: 'Open ' + (due[0].title.length > 36 ? due[0].title.slice(0, 35) + '…' : due[0].title), act: 'tk-openfirst' } });
453
- }
454
- function tasksView(id, M) {
455
- const L = Lof(id), T = Tof(id), by = byOf(L, T), rows = MD.taskRows(M, L);
456
- if (!T) readT(id, M);
457
- const mine = by === 'mine';
458
- const target = mine ? (L.names.includes(X.addTo) ? X.addTo : L.names[0] || '') : '';
459
- let groups;
460
- if (by === 'epic') {
461
- // the PM's own tasks: the PRD stories are tasks of their epics once drafted, and a Jira row of a pushed ticket is that task
462
- const keys = new Set(((T && T.ok && T.tickets) || []).map((t) => t.key).filter(Boolean));
463
- const own = rows.filter((r) => !(T && T.ok && T.drafted && r.req) && !(r.jira && keys.has(r.ref)));
464
- const k2 = 'ep:' + id + ':mine', open2 = foldOpen(k2, false), n2 = own.filter((r) => !r.closed).length;
465
- groups = epicGroupsHtml(id, M, T)
466
- + `<section class="tk-g hi-tg" aria-label="Your tasks">${headHtml(k2, 'Your tasks', n2 || own.length, open2)}${open2 ? own.map((t) => taskRowHtml(t, false)).join('') || '<p class="hi-empty">No task of yours yet. Add one below.</p>' : ''}</section>`;
467
- } else {
468
- const G = MD.taskGroups(rows, L, by);
469
- groups = rows.length ? G.map((g) => {
470
- const shut = X.shut.has('vt:' + g.key);
471
- const head = g.title == null ? '' : `<div class="hi-gh"><button type="button" class="hi-ghb" data-hi-vfold="${esc(g.key)}" aria-expanded="${!shut}">${SVG(shut ? I.right : I.down, 14, 2)}<b>${esc(g.title)}</b><span>${g.open} open</span></button>`
472
- + (g.mine ? `<button type="button" class="hi-ib sm" data-hi-gmore="${esc(g.title)}" aria-haspopup="menu" aria-label="More for ${esc(g.title)}">${SVG(I.more, 14, 3)}</button>` : '') + '</div>';
473
- return `<section class="hi-tg" data-hi-drop="${esc(g.mine ? g.title : g.loose ? '' : '')}"${mine ? ' data-hi-dz' : ''} aria-label="${esc(g.title || 'Tasks')}">${head}${shut ? '' : g.rows.map((t) => taskRowHtml(t, mine)).join('') || '<p class="hi-empty">Drag a task here.</p>'}</section>`;
474
- }).join('') : `<p class="hi-empty">${esc((M.tasks && M.tasks.note) || 'No task yet.')} Add one below.</p>`;
475
- }
476
- return summaryHtml(id, M, rows, T, by) + groups
477
- + (mine ? `<button type="button" class="hi-btn sm ghost hi-self" data-hi-newgroup>${SVG(I.plus, 14)}New group</button>` : '')
478
- + `<div class="hi-add"><label for="ovTask" class="hi-vh">Add a task</label><input id="ovTask" maxlength="200" autocomplete="off" placeholder="Add a task${target ? ' to ' + esc(target) : ''}" data-hi-target="${esc(target)}"><button type="button" class="hi-ib sm" data-ov-add aria-label="Add the task">${SVG(I.next, 14)}</button></div>`;
479
- }
480
432
  function docRowHtml(d, cur, later, phases) {
481
433
  const draft = d.act && d.act.kind === 'draft' && !d.running && !d.path && d.st !== 'stale';
482
434
  if (later) return `<div class="czs-it hi-drow later" data-ov-doc="${esc(d.key)}"><span class="ut-tki dash" aria-hidden="true">${SVG(I.doc, 15)}</span><span class="w">${esc(d.title)}<span>comes in ${esc(d.phase)}</span></span>${draft ? `<button type="button" class="hi-btn sm ghost" data-ov-draft="${esc(d.key)}">Draft it now</button>` : ''}</div>`;
@@ -528,8 +480,8 @@ function draw(b) {
528
480
  if (v === 'page') { const h = pageHtml(id, M); if (b.__pg !== h || !b.firstChild) { b.__pg = h; b.innerHTML = h; } return; }
529
481
  // Documents is shell A (XvADocs): no tabs, the summary card and folding groups straight in the body
530
482
  if (v === 'docs') { b.innerHTML = docsView(id, M) + '<p class="hi-small" role="status" id="ovMsg"></p>'; return; }
531
- // the phone keeps the Tasks | Stage switch (PgTkList); in shell A on a desktop the other views sit under ⋯ (XvATasks)
532
- b.innerHTML = `<div class="hi-v" data-hi-v="${v}">${isPhone() || !X.ctx.VW.czSummary ? segHtml(v) : ''}${v === 'stage' ? stageView(id, M, STAGE_ASK) : tasksView(id, M)}<p class="hi-small" role="status" id="ovMsg"></p></div>`;
483
+ // the phone keeps the Documents | Stage switch (PgTkList); in shell A on a desktop the other view sits under ⋯ (XvATasks)
484
+ b.innerHTML = `<div class="hi-v" data-hi-v="${v}">${isPhone() || !X.ctx.VW.czSummary ? segHtml(v) : ''}${stageView(id, M, STAGE_ASK)}<p class="hi-small" role="status" id="ovMsg"></p></div>`;
533
485
  }
534
486
  function redrawView() {
535
487
  if (!BODY || !BODY.isConnected || !X.ctx) return;
@@ -537,46 +489,23 @@ function redrawView() {
537
489
  const ae = document.activeElement, keep = ae && BODY.contains(ae) && ae.id ? ae.id : null, val = keep && ae.value != null ? ae.value : null;
538
490
  const st = BODY.scrollTop; draw(BODY); BODY.scrollTop = st;
539
491
  if (keep) { const n = BODY.querySelector('#' + keep); if (n) { if (val != null) n.value = val; n.focus(); } }
492
+ else if (ADDING && X.view === 'page') { const f = BODY.querySelector('#ivAddTask'); if (f) f.focus(); } // New → A task on a page still reading
540
493
  }
541
494
  /** ⋯ of the initiative in the Viewer (xvMore order: change it, then look back). */
542
495
  function moreOf(id, view) {
543
496
  const M0 = () => curM();
544
497
  const out = [];
545
- if (view === 'tasks') out.push({ label: 'Group tasks by', on: (b) => { const M = M0(); if (M) groupMenu(b, id, M); } });
546
498
  for (const [k, l] of Object.entries(KIND)) if (k !== view) out.push({ label: l, on: () => iniOverview(k) });
547
499
  out.push({ sep: true }, { label: 'Open the full record', on: async () => { const M = M0(); if (M) (X.ctx.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }); } });
548
500
  if (M0() && M0().board && M0().board.id) out.push({ label: 'Sprint', on: async () => { const M = M0(); if (M) (X.ctx.VW.drill(), await import('./premium-vw-jira.js')).openSprint(bw(M)); } });
549
501
  return out;
550
502
  }
551
- function groupMenu(t, id, M) {
552
- const L = Lof(id), T = Tof(id), by = byOf(L, T);
553
- const same = (n) => n.join('|').toLowerCase() === L.names.join('|').toLowerCase();
554
- const G = T && T.ok ? TKM.ticketGroups(T) : [];
555
- menu(t, [{ head: 'Group by' }, ...['epic', 'mine', 'owner', 'status', 'none'].map((k) => ({ label: MD.BY_LABEL[k],
556
- sub: k === 'mine' && L.names.length ? L.names.join(', ') : k === 'epic' && G.length ? G.map((g) => g.name).slice(0, 2).join(', ') : '',
557
- radio: true, on: by === k, go: () => press(id, M, { kind: 'by', by: k }) })),
558
- { hr: true }, { head: 'Saved group sets' },
559
- ...(L.sets || []).map((s) => ({ label: s.names.join(' · '), sub: same(s.names) ? 'this one' : s.name !== s.names.join(' · ') ? s.name : '', go: async () => { if (await press(id, M, { kind: 'groups', names: s.names })) press(id, M, { kind: 'by', by: 'mine' }); } })),
560
- { label: 'Save these groups as a set', icon: I.plus, disabled: !L.names.length, go: () => press(id, M, { kind: 'set', name: L.names.join(' · '), names: L.names }) }], 'Group tasks by');
561
- }
562
- /** The Send sheet (T3): one path to Jira, from a group's send icon, a drafted ticket, the summary card or the Board's Commit row. */
563
- async function sendSheet(id, M, o = {}) {
564
- const S = await import('./tk-send.js');
565
- return S.openSend({ ws: wsOf(M), board: M.board && M.board.id, initiative: id, ...o, toast: X.ctx.toast,
566
- onDone: async () => { await readT(id, M, true); setTimeout(() => readT(id, curM() || M, true), 4000); } });
567
- }
568
- async function openTicket(id, M, tid) {
569
- const T = Tof(id), t = T && T.ok ? (T.tickets || []).find((x) => x.id === tid) : null;
570
- if (t && t.inJira && !t.selectable) { (await import('./premium-vw-jira.js')).openTicket({ ...bw(M), initiative: id, ref: t.key }); return; }
571
- const D = await import('./tk-draft.js');
572
- D.openDraft({ VW: X.ctx.VW, ws: wsOf(M), initiative: id, id: tid, view: T && T.ok ? T : null, toast: X.ctx.toast, ui: { menu, ask },
573
- onChange: () => readT(id, M, true), onSend: (x) => sendSheet(id, M, { ticket: x }) });
574
- }
575
503
  export function iniOverview(view, o = {}) {
576
504
  if (!X.ctx) return false;
577
505
  const S = X.ctx.S, id = S.ini;
578
506
  if (!id || id === 'product') return false;
579
- const v = KIND[view] ? view : 'tasks'; // the page's "Show N more" opens Tasks (InTasks); "Show all N" and ⋯ name their own view
507
+ if (!KIND[view]) return iniPage(); // the old Tasks view is the page's own Tasks now (batch 11 item 20)
508
+ const v = view;
580
509
  const c = X.ctx.VW.current(), keep = !o.back && !!c && c.id === 'ov:' + id && X.view !== 'page'; // a switch between views keeps the page behind them
581
510
  X.view = v;
582
511
  STAGE_ASK = o.ask || null;
@@ -602,7 +531,6 @@ function docsMore(id) {
602
531
  { label: 'Show', note: on ? on.label : '', on: (b) => menu(b, chips.map((c) => ({ label: c.label + ' ' + c.n, radio: true, on: X.doc.filter === c.k, go: () => { X.doc.filter = c.k; redrawView(); } })), 'Show documents') },
603
532
  { label: 'Add a document', on: () => addDoc(id) },
604
533
  { sep: true },
605
- { label: 'Tasks', on: () => iniOverview('tasks') },
606
534
  { label: 'Stage', on: () => iniOverview('stage') },
607
535
  { label: 'Open the full record', on: async () => (X.ctx.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }) },
608
536
  ];
@@ -613,69 +541,14 @@ async function addDoc(id) {
613
541
  A.openAddDocVw({ VW: X.ctx.VW, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, phases: MD.PHASES, title: X.ctx.iniTitle(id), back: () => iniOverview('docs'), onAdded: async () => { await X.ctx.load(); if (S.ini === id) iniOverview('docs'); } });
614
542
  }
615
543
  function wire(body, id) {
616
- const S = X.ctx.S;
617
544
  const say = (m) => { const el = body.querySelector('#ovMsg'); if (el) el.textContent = m; };
618
545
  const after = async (r, ok) => { if (r && r.ok !== false) { X.ctx.toast(ok); await X.ctx.load(); redrawView(); return true; } say((r && r.error) || 'Nothing was changed.'); return false; };
619
- const addTask = async () => {
620
- const M = curM(); const inp = body.querySelector('#ovTask'); if (!M || !inp) return;
621
- const v = inp.value.trim(); if (!v) return;
622
- const L = Lof(id), target = inp.dataset.hiTarget || '';
623
- const r = await X.ctx.pmPost('/api/boards/tasks/add', { ...bw(M), initiative: id, title: v });
624
- if (!r || r.ok === false) { say((r && r.error) || 'The task was not added.'); return; }
625
- const key = r.item ? 'task:' + (r.item.uid || r.item.key) : '';
626
- if (key && /^task:[A-Za-z0-9]/.test(key)) {
627
- if (L.by === 'mine' && target) await press(id, M, { kind: 'place', task: key, group: target });
628
- }
629
- inp.value = '';
630
- await after(r, 'Task added.');
631
- const n = body.querySelector('#ovTask'); if (n) n.focus();
632
- };
633
- body.onkeydown = (e) => { if (e.target.id === 'ovTask' && e.key === 'Enter') { e.preventDefault(); addTask(); } };
634
546
  body.onclick = async (e) => {
635
547
  const t = e.target.closest('button'); const M = curM(); if (!t || t.disabled || !M) return;
636
548
  const d = t.dataset;
637
549
  if (X.view === 'page' && pagePress(t, id, M)) return;
638
550
  if (d.hiView) { iniOverview(d.hiView); return; }
639
551
  if ('hiAuto' in d) { const on = t.getAttribute('aria-checked') !== 'true'; if (ownWf(rowOf(id))) autoPress(id, M, on); else press(id, M, { kind: 'auto', on }); return; }
640
- if ('hiBy' in d) { groupMenu(t, id, M); return; }
641
- // PRD to Jira (T1 to T3)
642
- if (d.czsAct === 'tk-sendall') { sendSheet(id, M); return; }
643
- if (d.czsAct === 'tk-openfirst') {
644
- const wk = Date.now() + 7 * 864e5, r = MD.taskRows(M, Lof(id)).filter((x) => !x.closed && !x.req && x.end && Date.parse(x.end) <= wk).sort((a, b) => a.end.localeCompare(b.end))[0];
645
- if (r) openTask(id, M, r.key); return;
646
- }
647
- if (d.tkGfold) { X.fold.set(d.tkGfold, t.getAttribute('aria-expanded') !== 'true'); redrawView(); return; }
648
- if (d.tkMore) { X.more.add(d.tkMore); redrawView(); return; }
649
- if (d.tkSendg != null) { sendSheet(id, M, { group: d.tkSendg }); return; }
650
- if (d.tkOpen) { openTicket(id, M, d.tkOpen); return; }
651
- if ('tkDrafts' in d) {
652
- t.disabled = true;
653
- const r = await X.ctx.pmPost('/api/jira/draft', { ws: wsOf(M), initiative: id });
654
- if (!r || r.ok === false) { say((r && r.error) || 'The tickets were not drafted.'); t.disabled = false; return; }
655
- X.ctx.toast(plural(r.tickets, 'ticket', 'tickets') + ' drafted. Nothing is in Jira yet.'); await readT(id, M, true); return;
656
- }
657
- if ('hiNewgroup' in d) { const L = Lof(id); ask(t, 'Name the group', '', (v) => press(id, M, { kind: 'groups', names: L.names.concat(v) })); return; }
658
- if (d.hiGmore) {
659
- const g = d.hiGmore, L = Lof(id);
660
- menu(t, [{ label: 'Rename', go: (a) => ask(a, 'Rename ' + g, g, (v) => press(id, M, { kind: 'rename', from: g, to: v })) },
661
- { label: 'Add a task here', go: () => { X.addTo = g; redrawView(); const n = body.querySelector('#ovTask'); if (n) n.focus(); } },
662
- { label: 'Delete the group', sub: 'Its tasks stay', go: () => press(id, M, { kind: 'groups', names: L.names.filter((x) => x !== g) }) }], 'More for ' + g);
663
- return;
664
- }
665
- if (d.hiVfold) { const k = 'vt:' + d.hiVfold; if (X.shut.has(k)) X.shut.delete(k); else X.shut.add(k); redrawView(); return; }
666
- if ('hiFocusadd' in d) { const n = body.querySelector('#ovTask'); if (n) n.focus(); return; }
667
- if ('ovAdd' in d) { addTask(); return; }
668
- if (d.hiChk) { const row = MD.taskRows(M, Lof(id)).find((x) => x.key === d.hiChk); if (row && row.canCheck) after(await X.ctx.pmPost('/api/boards/tasks/state', { ...bw(M), task: row.uid, state: row.done ? 'To do' : 'Done' }), row.done ? 'Reopened.' : 'Done.'); return; }
669
- if (d.hiTmore) {
670
- const key = d.hiTmore, row = MD.taskRows(M, Lof(id)).find((x) => x.key === key); if (!row) return;
671
- const L = Lof(id);
672
- const items = [{ label: 'Open', go: () => openTask(id, M, key) }];
673
- if (row.canCheck) { items.push({ head: 'Status' }); for (const s of MD.TASK_STATES) items.push({ label: s, radio: true, on: row.state === s, go: async () => after(await X.ctx.pmPost('/api/boards/tasks/state', { ...bw(M), task: row.uid, state: s }), 'Status changed.') }); }
674
- if (L.names.length) { items.push({ head: 'Group' }); for (const g of L.names) items.push({ label: g, radio: true, on: row.group === g, go: () => press(id, M, { kind: 'place', task: key, group: g }) }); items.push({ label: 'Not in a group', go: () => press(id, M, { kind: 'place', task: key, group: '' }) }); }
675
- menu(t, items, 'More for ' + row.title);
676
- return;
677
- }
678
- if (d.ovTk) { openTask(id, M, d.ovTk); return; }
679
552
  if ('ovRecord' in d || 'ovSprint' in d) {
680
553
  const o = bw(M);
681
554
  if ('ovSprint' in d) { (X.ctx.VW.drill(), await import('./premium-vw-jira.js')).openSprint(o); return; }
@@ -718,11 +591,6 @@ function wire(body, id) {
718
591
  if ('ovLifeNo' in d) { STAGE_ASK = null; redrawView(); return; }
719
592
  if ('ovLifeGo' in d) { const reason = (body.querySelector('#ovWhy').value || '').trim(); if (reason.length < 3) { say('Say why in a few words. It goes on the record.'); return; } const st = STAGE_ASK; STAGE_ASK = null; after(await X.ctx.pmPost('/api/lifecycle', { ws: M.board.ws, initiative_id: id, state: st, reason }), 'Recorded.'); }
720
593
  };
721
- // drag a task between the PM's groups (InTasks)
722
- body.ondragstart = (e) => { const r = e.target.closest && e.target.closest('[data-hi-drag]'); if (!r) return; e.dataTransfer.setData('text/plain', r.dataset.hiDrag); e.dataTransfer.effectAllowed = 'move'; r.classList.add('drag'); };
723
- body.ondragend = (e) => { const r = e.target.closest && e.target.closest('[data-hi-drag]'); if (r) r.classList.remove('drag'); body.querySelectorAll('.hi-tg.over').forEach((n) => n.classList.remove('over')); };
724
- body.ondragover = (e) => { const z = e.target.closest && e.target.closest('[data-hi-dz]'); if (!z) return; e.preventDefault(); body.querySelectorAll('.hi-tg.over').forEach((n) => { if (n !== z) n.classList.remove('over'); }); z.classList.add('over'); };
725
- body.ondrop = (e) => { const z = e.target.closest && e.target.closest('[data-hi-dz]'); if (!z) return; e.preventDefault(); z.classList.remove('over'); const key = e.dataTransfer.getData('text/plain'); const M = curM(); if (key && M) press(id, M, { kind: 'place', task: key, group: z.dataset.hiDrop || '' }); };
726
594
  }
727
595
  async function openTask(id, M, key) {
728
596
  const row = (M.tasks.rows || []).find((x) => x.key === key) || (/^task:/.test(key) ? { key, uid: key.slice(5), title: '', pmos: true } : null); if (!row) return;
@@ -744,7 +612,7 @@ function pagePress(t, id, M) {
744
612
  if ('hiTalk' in d) { C.talk(id); return true; }
745
613
  if ('hiMove' in d) { const mv = mvOf(id, M); if (!mv.canMove) return true; if (mv.open.length) popMove(t, id, M, mv); else doMove(id, M, mv.next, mv.allDone ? 'Moved by hand: every exit item is done.' : 'Moved by hand'); return true; }
746
614
  if ('hiBack' in d) { const mv = mvOf(id, M); if (mv.canBack) popBack(t, id, M, mv); return true; }
747
- if ('hiAddtask' in d) { iniOverview('tasks', { back: true }); setTimeout(() => { const n = document.querySelector('#czViewer #ovTask'); if (n) n.focus(); }, 0); return true; }
615
+ if ('hiAddtask' in d) { iniAddTask(); return true; }
748
616
  if (d.hiOpen) { iniOverview(d.hiOpen, { back: true }); return true; }
749
617
  if (d.hiTask) { VW.drill(); openTask(id, M, d.hiTask); return true; }
750
618
  if (d.hiChk) { const row = MD.taskRows(M, Lof(id)).find((x) => x.key === d.hiChk); if (row && row.canCheck) C.pmPost('/api/boards/tasks/state', { ...bw(M), task: row.uid, state: 'Done' }).then(async (r) => { if (r && r.ok !== false) { C.toast('Done: ' + row.title + '.'); await C.load(); redrawView(); } else C.toast((r && r.error) || 'Nothing was changed.'); }); return true; }
@@ -6,7 +6,7 @@
6
6
  * status, the dates, the owner and the notes, and its move icon the section, the group or the initiative. Every write is the board's own route and is the PM's press; each says so
7
7
  * in a toast with Undo, and a refusal shows the route's reason and changes nothing. Talk it through in chat is under ⋯ (the chat is beside
8
8
  * the Viewer on Home). The PM's own items (a note, a mention made into a task) open in My work's item view (home-work.js). */
9
- import { taskOf, checkOf, mountCard, boardSaver, cardStyle, placeOf } from './task-card.js';
9
+ import { taskOf, checkOf, mountCard, boardSaver, cardStyle, placeOf, historyFor } from './task-card.js';
10
10
 
11
11
  /** h: { VW, pmPost, toast, toastUndo?, now, ws, board, iniTitle(id), openIni(id), askInChat(task), onChange(), rename?(task),
12
12
  * owners?() → [names], inis?() → [{ id, title }] } */
@@ -41,6 +41,7 @@ export function openTask(task, h) {
41
41
  inis: () => (h.inis ? h.inis() : []),
42
42
  groups: () => (layout ? layout.names || [] : null),
43
43
  sections: () => sections,
44
+ history: historyFor({ ws, board, t, post: (p, b) => h.pmPost(p, b) }), // what Claude changed with your ✓ (batch 12, TpA6)
44
45
  });
45
46
  },
46
47
  });