create-pmos 0.649.0 → 0.651.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.649.0",
3
+ "version": "0.651.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,32 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.651.0",
38
+ "at": "2026-11-20T07:19:20.677Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1433,
43
+ "t": "Quick edit in a row and full popups for a task and a milestone",
44
+ "s": "Quick edit in a row and full popups for a task and a milestone",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.650.0",
51
+ "at": "2026-11-20T06:52:20.858Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1432,
56
+ "t": "The initiative popup is built from design system blocks",
57
+ "s": "The initiative popup is built from design system blocks",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.649.0",
38
64
  "at": "2026-11-20T06:16:36.793Z",
@@ -284,38 +310,6 @@
284
310
  "k": "fix"
285
311
  }
286
312
  ]
287
- },
288
- {
289
- "v": "0.626.0",
290
- "at": "2026-11-19T05:42:19.332Z",
291
- "f": 4,
292
- "prs": [
293
- {
294
- "n": 1406,
295
- "t": "One product-name rule for desk and shared copy; no raw report ids on Events",
296
- "s": "One product-name rule for desk and shared copy; no raw report ids on Events",
297
- "k": "fix"
298
- },
299
- {
300
- "n": 1407,
301
- "t": "Sprint overview on Work > Backlog > This sprint",
302
- "s": "Sprint overview on Work > Backlog > This sprint",
303
- "k": "new"
304
- }
305
- ]
306
- },
307
- {
308
- "v": "0.623.0",
309
- "at": "2026-11-19T05:21:06.341Z",
310
- "f": 4,
311
- "prs": [
312
- {
313
- "n": 1405,
314
- "t": "Work's bars stop at the timeline's edge at every span",
315
- "s": "Work's bars stop at the timeline's edge at every span",
316
- "k": "fix"
317
- }
318
- ]
319
313
  }
320
314
  ]
321
315
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@6a943aac
1
+ kernel-source: pmos@e9a16d4c
2
2
  assembled: 2026-11-20
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-20T06:16:33Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T07:19:17Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-20T06:16:33Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T07:19:17Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-20T06:16:33Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T07:19:17Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.651.0",
4
+ "at": "2026-11-20T07:19:20.677Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1433,
9
+ "t": "Quick edit in a row and full popups for a task and a milestone",
10
+ "s": "Quick edit in a row and full popups for a task and a milestone",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.650.0",
17
+ "at": "2026-11-20T06:52:20.858Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1432,
22
+ "t": "The initiative popup is built from design system blocks",
23
+ "s": "The initiative popup is built from design system blocks",
24
+ "k": "new"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.649.0",
4
30
  "at": "2026-11-20T06:16:36.793Z",
@@ -135,7 +135,22 @@ A phone keeps its own layout. A shared read-only Board has no popup.
135
135
 
136
136
  ### What the popup shows for an initiative
137
137
 
138
- The work side has three parts, top to bottom. They use the full width of the popup: in a wide popup the timeline gets the extra width. A done task shows in grey text, never struck through.
138
+ On a computer the popup is built from the parts of the PMOS design system. The top line shows **Work ›**, the initiative's name, the **Initiative** chip and one line under it: the stage, the goal it is anchored to, when it opened and its owner. Press **Work** or ← to go back to the page.
139
+
140
+ The left column has three blocks:
141
+
142
+ - **Where it stands.** What is happening, in a few sentences. Then **Next**: the next three dates, a milestone as a diamond and the outcome check as a circle; press a milestone to open it. Then one suggestion from PMOS with **Why**, **PMOS will** and **Based on**. The pencil opens it so you can change it first, ✓ does it and ✕ drops it. Other suggestions are one link under it.
143
+ - **Stages.** Each stage of the workflow, with its dates under its name or "no dates yet", on a month scale with a red line for today. A stage has a bar only when it has real dates. A milestone is a diamond on its stage's row.
144
+ - **Work breakdown.** **List** or **Gantt**; PMOS keeps your choice on this computer. **List** has one box on top: type a task and press Enter. Say its stage ("… in Plan"), or it goes to the stage in progress; start with ◇ to add a milestone. Each stage with tasks is one group that says how much is done, for example "1 of 3 done". A done task stays in its stage, in grey with a check. Stages with no tasks fold into one line at the end. Press the box before a task to mark it done, with **Undo**. Press its name to rename it: Enter saves and Escape cancels. When you point at the row, four icons show: **Who** (You, the people on this initiative, or **PMOS does it**, which gives the task to PMOS), **Due date**, **Stage** (moves the task to another stage) and ⋯ (**Status**, **Make it a milestone** and **Open the task**). Each change has **Undo**. A Jira ticket keeps its owner and stage from Jira. **Gantt** is the table described below, with its bars.
145
+
146
+ Press the rest of a row, or a milestone, to open it as a full popup in place of the work side. Its top line has ←, the path (**Work › product › initiative**), the chat button, ⋯ and ×. ← or the initiative's name goes back to the initiative, where you left it. The chat button shows **Ask PMOS** beside it. × closes the popup. A task shows its status, dates, owner, notes and what changed. A milestone also shows its date and how many days are left, the done test, **Kill if**, and the suggestion from PMOS about it when there is one.
147
+
148
+ The right column has two blocks:
149
+
150
+ - **The case.** **Problem**, **Goal** and **Done when** from the initiative's records, then its facts (status, dates, the next milestone, goal, product, program, workflow and what is open). Press a line to change it. A line not written offers a PMOS draft (✦) or ✕. When no line is written yet, one suggestion offers to draft them all from what is linked: ✓ sends the request to the chat, ✕ says not this, and the pencil lets you write it yourself.
151
+ - **Artefacts.** The brief, the prototype and the documents, each with its kind and date. A document the gate needs that nobody wrote is grey and says which gate. + adds a file, a link or a new document.
152
+
153
+ On a phone, in a shared read-only copy and in a breakdown given the whole popup, the work side keeps the three parts below. They use the full width of the popup: in a wide popup the timeline gets the extra width. A done task shows in grey text, never struck through.
139
154
 
140
155
  - **Overview.** Three short lines from the initiative's own records: **Problem**, **Goal** (with the goal it serves, by name) and **Done when**. A line with no record says **Not written yet.** and offers a draft with ✓ and ✕. Press a line to change it; it saves when you leave the field, with **Undo**. Then one line on where it stands, **PMOS suggests** (at most three, each with ✓ and ✕), and **Details ›** for the facts: Stage, Status, Start, Target end, Next milestone, Goal, Product, Program, Workflow and Open. A fact with no value is not shown. Goal, Product, Program and Next milestone are in the link colour and open their thing; the others are plain text. An initiative that is closed or done but has open tasks shows one suggestion: **Close them** or **Reopen**.
141
156
  - **Work breakdown.** Each stage is a row that folds and says how much is done, for example "3 of 9 done". Only the stage in progress opens by itself. In a long stage you see the late tasks, the tasks in progress and the next five, then **N more tasks**. Done tasks fold to one line, and the stages after the next one fold to one row. A task in no stage is not in the breakdown: it is in Work › Backlog, and one quiet line under the breakdown says how many, for example **2 tasks with no stage are in the Backlog ›**. A task with no date shows no date and is never late. The timeline is on the right, with **Today** on it. Drag the grip between the columns and the timeline to make the timeline wider or narrower; a double press puts it back. Choose its span (Quarter to Full) beside the tune icon, which shows or hides columns. The four-corners icon gives the breakdown the whole popup. Type in the last row of a stage to add a task; the **Task** choice beside it makes the next one a milestone.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.649.0",
3
+ "version": "0.651.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.649.0",
9
+ "version": "0.651.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.649.0",
3
+ "version": "0.651.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -320,6 +320,12 @@ export const vidOf = (r) => (r.id ? String(r.id) : 'bd:' + r.key);
320
320
  /** A published copy (pm/readonly.js) opens a row of Work in the one popup, read only (shared-copy brief Part A 4); the four views a phone and
321
321
  * the narrow form keep open their side viewer, as before. */
322
322
  const roPop = () => (window.PMOS_READONLY && document.body.classList.contains('wk-on') ? { ro: true, force: true } : {});
323
+ const MON3 = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
324
+ /** The popup head's meta line (WorkPopupDS): "Triage · anchored to KR 2.3 · opened 11 Oct · owner Dara". A part the record does not hold is left out. */
325
+ export function metaOf(r) {
326
+ const d = /^(\d{4})-(\d{2})-(\d{2})/.exec(String((r && r.start) || ''));
327
+ return [r && r.stage, r && r.kr ? 'anchored to ' + r.kr : '', d ? 'opened ' + +d[3] + ' ' + MON3[+d[2] - 1] : '', r && r.owner ? 'owner ' + r.owner : ''].filter(Boolean).join(' · ');
328
+ }
323
329
  export function openIni(r, from, o = {}) {
324
330
  if (!O || !r || !r.track) return;
325
331
  adding = o.addTo != null ? r.key : null; addTo = o.addTo || ''; addDates = o.addDates || null;
@@ -330,7 +336,7 @@ export function openIni(r, from, o = {}) {
330
336
  // the same tile as Home's initiative page; no "Open in full": the header's expand already opens it wide (batch 14 item 5)
331
337
  // on a desk it opens in the one popup with Ask PMOS about it beside it (slice 2 of the six-place navigation); a phone keeps its sheet
332
338
  const B = (O.M() || {}).board || {};
333
- VW.open({ kind: 'Initiative', title: r.title, icon: 'goal', wrap: true, id: vidOf(r), pop: { id: r.id || '', kind: 'initiative', title: r.title, ws: r.ws || B.ws || undefined, ...roPop() },
339
+ VW.open({ kind: 'Initiative', title: r.title, icon: 'goal', wrap: true, id: vidOf(r), from: 'Work', kindChip: 'Initiative', sub: metaOf(r), pop: { id: r.id || '', kind: 'initiative', title: r.title, ws: r.ws || B.ws || undefined, ...roPop() },
334
340
  discuss: r.id ? true : () => location.assign(O.askHref(r, '')), more: () => { const x = O.rowOf(r.key) || r, b = VW.bodyOf(vidOf(x)); return (PW.on(b) ? PW.moreItems(null, popExtra(x)) : []).concat(iniMore(x)); }, rename: O.rename ? O.rename(r) : null,
335
341
  // the kind of work (batch 29 item 11, KdV1-3): its glyph stands before Discuss; a tap opens the three kinds. A published copy
336
342
  // (pm/readonly.js) cannot change it, so it has no press: the Board's icon still names the kind
@@ -0,0 +1,80 @@
1
+ /* pm/bd-pop-ds.css — the initiative popup on a computer, built from PMOS Komorebi parts (initiative work-ds-popup; Exploring 3 page "work",
2
+ * boards WorkPopupDS, WorkGanttDS, WorkCaseEmptyDS). It only places the parts pm/bd-pop-ds.js draws (pm-block, pm-sug x, pm-tabs, pm-gt,
3
+ * pm-dia, pm-now, pm-group, pm-li, pm-fold, pm-input); the look is the system's. */
4
+
5
+ /* ── two columns: the work on the left, the case and its artefacts on the right ── */
6
+ .pw.pwd { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: var(--space-16); align-items: start; padding-bottom: var(--space-24); }
7
+ .pwd-main, .pwd-side { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
8
+ .pwd-blk { gap: var(--space-12); }
9
+ .pwd-bh { justify-content: space-between; gap: var(--space-8); }
10
+ .pwd-bh .pm-h-sm { margin: 0; }
11
+ @container (max-width: 860px) { .pw.pwd { grid-template-columns: minmax(0, 1fr); } }
12
+ @media (max-width: 1100px) { .pw.pwd { grid-template-columns: minmax(0, 1fr); } }
13
+
14
+ /* ── Where it stands ── */
15
+ .pwd-say { margin: 0; font-size: var(--fs-body); line-height: 24px; }
16
+ .pwd-next { flex-wrap: wrap; gap: var(--space-8) var(--space-16); margin: 0; font-size: var(--fs-row); }
17
+ .pwd-nx { display: inline-flex; align-items: center; gap: var(--space-4); border: 0; background: none; padding: 0; font: inherit; color: var(--ink); cursor: pointer; }
18
+ span.pwd-nx { cursor: default; }
19
+ .pwd-nx:focus-visible { outline: none; box-shadow: var(--glow); border-radius: var(--radius-sm); }
20
+ .pwd-mk { display: inline-block; width: 10px; height: 10px; box-sizing: border-box; border: 2px solid var(--ink); flex: none; }
21
+ .pwd-mk.dia { transform: rotate(45deg); border-radius: 2px; }
22
+ .pwd-mk.ring { border-radius: 50%; }
23
+ .pwd-moresug { margin: 0; }
24
+
25
+ /* ── Stages: the name and its dates on the left, the track on the right ── */
26
+ .pwd-st { display: flex; flex-direction: column; }
27
+ .pwd-sr { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; min-height: 52px; }
28
+ .pwd-sr.pwd-sh { min-height: 24px; }
29
+ .pwd-sn { display: flex; flex-direction: column; font-size: var(--fs-row); line-height: 20px; }
30
+ .pwd-sn b { font-weight: var(--fw-strong); }
31
+ .pwd-sr.now .pwd-sn b { color: var(--blue); }
32
+ .pwd-tk { position: relative; height: 100%; min-height: 24px; }
33
+ .pwd-sh .pwd-tk { height: 24px; }
34
+ .pwd-mo { position: absolute; top: 2px; transform: translateX(-50%); font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; }
35
+ .pwd-mo.td { color: var(--alert); font-weight: var(--fw-strong); }
36
+ .pwd-sr .pm-gt { height: 52px; }
37
+ .pwd-sr .pm-gt > .b { top: 21px; }
38
+ .pwd-sr .pm-now > span { display: none; }
39
+
40
+ /* ── the Work breakdown: List ── */
41
+ .pwd-cap { width: 100%; box-sizing: border-box; }
42
+ .pwd-list { display: flex; flex-direction: column; margin: 0 calc(-1 * var(--space-16)); }
43
+ .pwd-list .pm-group { margin-top: var(--space-4); }
44
+ .pwd-li { cursor: pointer; }
45
+ .pwd-li .pwd-tt { border: 0; background: none; padding: 0; font: inherit; font-weight: var(--fw-strong); color: inherit; text-align: left; cursor: text; max-width: 100%; }
46
+ .pwd-li .w.late { color: var(--alert); }
47
+ .pwd-li.dn { color: var(--muted); }
48
+ .pwd-li.dn .t { font-weight: var(--fw-regular); }
49
+ .pwd-ck { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; border-radius: var(--radius-sm); background: none; padding: 0; color: var(--muted); }
50
+ button.pwd-ck { cursor: pointer; }
51
+ button.pwd-ck:hover { color: var(--ink); background: var(--well); }
52
+ .pwd-ck.dn { color: var(--leaf); }
53
+ .pwd-fold { cursor: default; }
54
+ .pwd-none { margin: var(--space-8) var(--space-16); }
55
+ .pwd-loose { margin: 0; }
56
+
57
+ /* ── the Work breakdown: Gantt (the breakdown table inside the block) ── */
58
+ .pwd-wbs.pw-sec { margin: 0; }
59
+ .pwd-wbs .pw-sech { margin-bottom: 0; }
60
+ .pwd-wbs .pw-sech .pwd-bh { flex: 1; }
61
+
62
+ /* ── The case ── */
63
+ .pwd-cl { display: flex; flex-direction: column; gap: var(--space-4); }
64
+ .pwd-cl p { margin: 0; font-size: var(--fs-body); line-height: 24px; }
65
+ .pwd-cv { cursor: text; border-radius: var(--radius-sm); }
66
+ .pwd-cv:hover { background: var(--well); }
67
+ .pwd-cv:focus-visible { outline: none; box-shadow: var(--glow); }
68
+ .pwd-cv.grey, .pwd-case .grey { color: var(--muted); }
69
+ .pwd-off { display: inline-flex; gap: var(--space-4); margin-left: var(--space-4); vertical-align: middle; }
70
+ .pwd-facts { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--space-4) var(--space-12); margin: 0; font-size: var(--fs-row); }
71
+ .pwd-facts dt { color: var(--muted); }
72
+ .pwd-facts dd { margin: 0; min-width: 0; }
73
+ .pwd-case .warn { color: var(--alert); }
74
+
75
+ /* ── Artefacts ── */
76
+ .pwd-art { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; margin: 0 calc(-1 * var(--space-8)); width: calc(100% + 2 * var(--space-8)); }
77
+ div.pwd-art { cursor: default; }
78
+ .pwd-art.miss .t { color: var(--muted); }
79
+ .pwd-art .w.warn { color: var(--alert); }
80
+ .pwd-ai { flex: none; color: var(--muted); display: inline-flex; }
@@ -0,0 +1,239 @@
1
+ /* pm/bd-pop-ds.js — the initiative popup on a computer, built from the design system's blocks (initiative work-ds-popup; Exploring 3 page
2
+ * "work", boards WorkPopupDS, WorkGanttDS, WorkCaseEmptyDS; brief /mnt/project-files/design-system/work-rebuild/brief.md). Pure: strings
3
+ * only, no DOM and no reads. pm/cozy-pop-work.js draws it from pm/pop-work-model.js and wires its presses: every press here carries the
4
+ * popup's own data-pw-* attribute, so the handlers stay the ones the popup already has.
5
+ *
6
+ * nextOf(r, W, n) → [{ kind: 'ms' | 'check', date, text, name, uid }] the next n dates: open milestones, then the outcome check
7
+ * standsHtml(W, r, o) → the Where it stands block: the summary, the Next line, one expanded Suggestion. Nothing to say: ''
8
+ * stagesHtml(st, W) → the Stages block: each stage, its dates or "no dates yet", a month scale, the today line; a bar only for real dates
9
+ * listHtml(rows, W, o) → the Work breakdown's List: one capture Input, one group per stage with tasks, empty stages folded into one line
10
+ * wbsHead(view) → the Work breakdown's head: its name and the List / Gantt tabs
11
+ * caseHtml(W, o) → The case: its lines (each editable), the facts; no line written: one Suggestion to draft them all
12
+ * artsHtml(arts) → Artefacts: a List with Add in the head
13
+ * stageKeyOf(text, st) → { key, name, title } the stage a captured line names ("… in Plan"), else the stage in progress
14
+ *
15
+ * The UI says PMOS, never Claude. Buttons are icons with aria-label. */
16
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
17
+ const SV = (d, w = 16) => `<svg class="pm-ic" aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
18
+ export const I = {
19
+ star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', pen: 'M4 20h4L19 9l-4-4L4 16z', ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18',
20
+ plus: 'M12 5v14M5 12h14', more: 'M5 12h.01M12 12h.01M19 12h.01', open: 'M14 5h5v5M19 5l-8 8M18 14v5H5V6h5', box: 'M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z',
21
+ dia: 'M12 4l8 8-8 8-8-8z', doc: 'M7 3h7l4 4v14H7zM14 3v4h4M9.5 12h6M9.5 16h6', deck: 'M4 5h16v11H4zM12 16v4M8 20h8', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
22
+ proto: 'M4 5h16v12H4zM9 21h6M12 17v4', right: 'M10 7l5 5-5 5',
23
+ who: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM5 20a7 7 0 0 1 14 0', cal: 'M5 6h14v14H5zM5 10h14M9 4v4M15 4v4', stage: 'M5 7h14M5 12h10M5 17h6',
24
+ };
25
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
26
+ const DAY = 864e5;
27
+ const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
28
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
29
+ /** "4 Nov"; a year that is not today's: "13 Jan 2027". */
30
+ export function dayText(v, today) {
31
+ const d = day(v); if (d == null) return '';
32
+ const x = new Date(d), ty = new Date(day(today) || Date.now()).getUTCFullYear();
33
+ return x.getUTCDate() + ' ' + MON[x.getUTCMonth()] + (x.getUTCFullYear() !== ty ? ' ' + x.getUTCFullYear() : '');
34
+ }
35
+ /** A stage's dates: "4 – 25 Nov", "4 Nov – 9 Jan", "from 4 Nov", "ends 20 Feb", "no dates yet". */
36
+ export function spanText(a, b, today) {
37
+ if (a && b && a.slice(0, 10) === b.slice(0, 10)) return dayText(a, today);
38
+ if (a && b) {
39
+ const x = new Date(day(a)), y = new Date(day(b));
40
+ return x.getUTCMonth() === y.getUTCMonth() && x.getUTCFullYear() === y.getUTCFullYear() ? x.getUTCDate() + ' – ' + dayText(b, today) : dayText(a, today) + ' – ' + dayText(b, today);
41
+ }
42
+ if (a) return 'from ' + dayText(a, today);
43
+ if (b) return 'ends ' + dayText(b, today);
44
+ return 'no dates yet';
45
+ }
46
+ const inDays = (iso, today) => { const n = Math.round((day(iso) - day(today)) / DAY); return n === 0 ? 'today' : n === 1 ? 'tomorrow' : n > 1 ? 'in ' + n + ' days' : ''; };
47
+ const pct = (v, S) => { const a = day(S.a), b = day(S.b); return ((day(v) - a) / Math.max(DAY, b - a)) * 100; };
48
+
49
+ /* ── Where it stands ── */
50
+ /** The next dates of this initiative from today on: its open milestones, and the outcome check when the record holds one. */
51
+ export function nextOf(r, W, n = 3) {
52
+ const t = W.today, out = [];
53
+ for (const m of (r && r.milestones) || []) if (m && !m.done && m.date && m.date >= t) out.push({ kind: 'ms', date: m.date, name: m.name, uid: m.id || '' });
54
+ const ck = r && r.outcome && /^\d{4}-\d{2}-\d{2}/.test(String(r.outcome.next || '')) ? String(r.outcome.next).slice(0, 10) : '';
55
+ if (ck && ck >= t) out.push({ kind: 'check', date: ck, name: 'Check the outcome', uid: '' });
56
+ return out.sort((a, b) => a.date.localeCompare(b.date)).slice(0, n).map((x) => ({ ...x, text: dayText(x.date, t) }));
57
+ }
58
+ const sugWill = (s) => {
59
+ if (s.choices) return [];
60
+ const it = (s.items || []).filter((x) => x && (x.title || x.task));
61
+ if (s.group === 'dates' && it.length) return it.slice(0, 4).map((x) => 'Move ' + (x.title || x.task) + (x.to ? ' to ' + dayText(x.to) : ''));
62
+ if (it.length) return it.slice(0, 4).map((x) => String(x.title || x.task));
63
+ return s.ask || s.move || s.moveAll ? [s.say] : [];
64
+ };
65
+ /** One proposal as the expanded Suggestion. Pencil opens it (its page: change it first, ask about it), ✓ does it, ✕ says no. */
66
+ export function sugHtml(s) {
67
+ if (!s || !s.say) return '';
68
+ const row = (k, v, cls = '') => (v ? `<dt>${k}</dt><dd${cls ? ` class="${cls}"` : ''}>${v}</dd>` : '');
69
+ const will = sugWill(s), src = (s.sources || []).map((x) => x && x.label).filter(Boolean).join(', ');
70
+ const ans = s.choices
71
+ ? s.choices.map((c, i) => `<button type="button" class="pm-btn outline" data-pw-choice="${esc(s.id + '|' + i)}">${esc(c.label)}</button>`).join('') + `<button type="button" class="pm-btn outline" data-pw-drop="${esc(s.id)}" aria-label="Not now" title="Not now">${SV(I.x)}</button>`
72
+ : `<button type="button" class="pm-btn" data-pw-sug="${esc(s.id)}" aria-label="Change it first" title="Change it first">${SV(I.pen)}</button>`
73
+ + `<button type="button" class="pm-btn primary" data-pw-keep="${esc(s.id)}" aria-label="Yes, do it" title="Yes, do it">${SV(I.ok)}</button>`
74
+ + `<button type="button" class="pm-btn outline" data-pw-drop="${esc(s.id)}" aria-label="No" title="No">${SV(I.x)}</button>`;
75
+ return `<div class="pm-sug x" role="group" aria-label="PMOS suggests"><div class="ttl">${SV(I.star)}<b class="say">${esc(s.say)}</b></div>`
76
+ + `<dl>${row('Why', esc(s.why))}${row('PMOS will', will.length && !(will.length === 1 && will[0] === s.say) ? `<ul>${will.map((w) => `<li>${esc(w)}</li>`).join('')}</ul>` : '')}${row('Based on', esc(src), 'src')}</dl>`
77
+ + `<div class="ans">${ans}</div></div>`;
78
+ }
79
+ export function standsHtml(W, r, o = {}) {
80
+ const say = (W.summary && W.summary.text) || '';
81
+ const nx = nextOf(r, W);
82
+ const next = nx.length ? `<p class="pm-row pwd-next"><span class="pm-meta">Next</span>${nx.map((x) => {
83
+ const mk = x.kind === 'ms' ? '<i class="pwd-mk dia" aria-hidden="true"></i>' : '<i class="pwd-mk ring" aria-hidden="true"></i>';
84
+ const soon = inDays(x.date, W.today), when = soon && /^(today|tomorrow|in [1-7] days)$/.test(soon) ? ` <span class="pm-badge">${esc(soon)}</span>` : '';
85
+ const lbl = `${mk}<span class="pm-meta code">${esc(x.text)}</span> <span>${esc(x.name)}</span>${when}`;
86
+ return x.uid ? `<button type="button" class="pwd-nx" data-pw-open="${esc(x.uid)}" aria-label="${esc('Open ' + x.name + ', ' + x.text)}">${lbl}</button>` : `<span class="pwd-nx">${lbl}</span>`;
87
+ }).join('')}</p>` : '';
88
+ const s = (W.suggests || [])[0], more = Math.max(0, (W.suggests || []).length - 1) + (W.more || 0);
89
+ const sug = o.ro ? '' : sugHtml(s) + (more ? `<p class="pwd-moresug"><button type="button" class="pw-lk" data-pw-props>${esc(plural(more, 'more suggestion', 'more suggestions'))}</button></p>` : '');
90
+ if (!say && !next && !sug) return '';
91
+ return `<section class="pm-block pwd-blk pwd-stands" aria-label="Where it stands"><h2 class="pm-h-sm pm-row">${SV(I.star).replace('pm-ic', 'pm-ic pm-star')}Where it stands</h2>`
92
+ + (say ? `<p class="pwd-say">${esc(say)}</p>` : '') + next + sug + '</section>';
93
+ }
94
+
95
+ /* ── Stages ── */
96
+ /** st: the stage rows of the breakdown with every stage drawn ({ key, name, start, end, now, done, marks }). */
97
+ export function stagesHtml(st, W) {
98
+ const S = W.span, list = (st || []).filter((x) => x && x.kind === 'stage' && x.key !== '');
99
+ if (!list.length) return '';
100
+ const a = day(S.a), b = day(S.b), months = [];
101
+ for (let d = new Date(a); d.getTime() < b; ) {
102
+ d = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 1));
103
+ if (d.getTime() >= b) break;
104
+ months.push({ x: pct(new Date(d).toISOString().slice(0, 10), S), label: MON[d.getUTCMonth()] + (d.getUTCMonth() === 0 ? ' ' + d.getUTCFullYear() : '') });
105
+ }
106
+ const step = months.length > 14 ? 3 : 1;
107
+ const tx = W.today >= S.a && W.today <= S.b ? pct(W.today, S) : null;
108
+ const now = tx != null ? `<i class="pm-now" style="left:${tx.toFixed(2)}%"></i>` : '';
109
+ const scale = `<div class="pwd-sr pwd-sh" aria-hidden="true"><span></span><div class="pwd-tk">${months.filter((m, i) => i % step === 0 && m.x > 2 && m.x < 97 && !(tx != null && Math.abs(m.x - tx) < 6)).map((m) => `<span class="pwd-mo" style="left:${m.x.toFixed(2)}%">${esc(m.label)}</span>`).join('')}${tx != null ? `<span class="pwd-mo td" style="left:${tx.toFixed(2)}%">${esc(dayText(W.today, W.today))}</span>` : ''}</div></div>`;
110
+ const rows = list.map((x) => {
111
+ const bar = x.start && x.end ? (() => { const l = Math.max(0, pct(x.start, S)), r = Math.min(100, pct(x.end, S)); return r > l ? `<i class="b${x.done ? ' dn' : x.now ? ' nw' : ''}" style="left:${l.toFixed(2)}%;width:${Math.max(0.8, r - l).toFixed(2)}%"></i>` : ''; })() : '';
112
+ const marks = (x.marks || []).filter((m) => m.end >= S.a && m.end <= S.b).map((m) => `<button type="button" class="pm-dia${m.done ? ' dn' : m.late ? ' late' : ''}" style="left:${pct(m.end, S).toFixed(2)}%" data-pw-open="${esc(m.uid)}" aria-label="${esc(m.title + ', ' + dayText(m.end, W.today))}" title="${esc(m.title + ' · ' + dayText(m.end, W.today))}"></button>`).join('');
113
+ return `<div class="pwd-sr${x.now ? ' now' : ''}" role="row"><span class="pwd-sn"><b>${esc(x.name)}</b><span class="pm-meta">${esc(spanText(x.start, x.end, W.today))}</span></span><div class="pm-gt pwd-tk">${bar}${marks}${now}</div></div>`;
114
+ }).join('');
115
+ return `<section class="pm-block pwd-blk pwd-stages" aria-label="Stages"><h2 class="pm-h-sm">Stages</h2><div class="pwd-st" role="table" aria-label="Stages">${scale}${rows}</div></section>`;
116
+ }
117
+
118
+ /* ── the Work breakdown ── */
119
+ export function wbsHead(view) {
120
+ const t = (k, l) => `<button type="button" class="pm-tab" role="tab" aria-selected="${view === k}" data-pwv="${k}">${l}</button>`;
121
+ return `<div class="pm-row pwd-bh"><h2 class="pm-h-sm">Work breakdown</h2><div class="pm-tabs" role="tablist" aria-label="View of the work breakdown">${t('list', 'List')}${t('gantt', 'Gantt')}</div></div>`;
122
+ }
123
+ /** The stage a captured line names: "Write the runbook in Plan" → Plan; else the stage in progress, else the first stage. */
124
+ export function stageKeyOf(text, st) {
125
+ const L = (st || []).filter((x) => x && x.kind === 'stage' && x.key !== '');
126
+ const s = String(text || '').trim();
127
+ for (const x of L) {
128
+ const re = new RegExp('\\s+(?:in|for|under|to)\\s+(?:the\\s+)?' + x.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '(?:\\s+stage)?\\s*$', 'i');
129
+ if (re.test(s)) return { key: x.key, name: x.name, title: s.replace(re, '').trim() };
130
+ }
131
+ const cur = L.find((x) => x.now) || L.find((x) => !x.done) || L[0];
132
+ return cur ? { key: cur.key, name: cur.name, title: s, guessed: true } : null;
133
+ }
134
+ /** rows: the breakdown with every stage open, its done tasks shown and no fold (pop-work-model.js breakdownOf). o: { ro, looseN, ms } */
135
+ export function listHtml(rows, W, o = {}) {
136
+ const groups = [], empty = [];
137
+ let g = null;
138
+ for (const x of rows || []) {
139
+ if (x.kind === 'stage') { g = x.key === '' ? null : { s: x, tasks: [] }; if (g) groups.push(g); continue; }
140
+ if (g && x.kind === 'task') g.tasks.push(x);
141
+ }
142
+ const li = (x) => {
143
+ const sub = [x.date, x.who && x.who !== 'You' ? x.who : ''].filter(Boolean).join(' · ');
144
+ // the tick (WorkStatesDS 3): marks it done, with Undo; a done task and a Jira ticket show their state only
145
+ const box = x.done ? `<span class="pwd-ck dn" aria-label="Done" role="img">${SV(I.ok, 14)}</span>`
146
+ : o.ro || x.jira ? `<span class="pwd-ck" aria-hidden="true">${SV(x.ms ? I.dia : I.box, 14)}</span>`
147
+ : `<button type="button" class="pwd-ck" data-pw-tick="${esc(x.uid)}" aria-label="${esc('Mark ' + x.title + ' done')}" title="Mark it done">${SV(x.ms ? I.dia : I.box, 14)}</button>`;
148
+ const title = x.jira || o.ro || x.done ? `<span class="t">${esc(x.title)}</span>` : `<button type="button" class="t pwd-tt" data-pw-name="${esc(x.uid)}" aria-label="${esc('Rename ' + x.title)}">${esc(x.title)}</button>`;
149
+ // on hover (WorkStatesDS 1): Who, Due date, Stage and More, each a small picker; a Jira ticket keeps Jira's owner and stage
150
+ const ab = (attr, label, d) => `<button type="button" class="pm-btn" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SV(d)}</button>`;
151
+ const acts = o.ro ? '' : '<span class="acts">'
152
+ + (x.jira || x.done ? '' : ab(`data-pw-who="${esc(x.uid)}" aria-haspopup="menu"`, 'Who: ' + (x.who || 'no one'), I.who))
153
+ + (x.done ? '' : ab(`data-pw-date="${esc(x.uid)}" aria-haspopup="dialog"`, x.date ? (x.ms ? 'Date: ' : 'Due: ') + x.date : 'Set a date', I.cal))
154
+ + (x.jira ? '' : ab(`data-pw-stage="${esc(x.uid)}" aria-haspopup="menu"`, 'Stage', I.stage))
155
+ + ab(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, I.more) + '</span>';
156
+ return `<div class="pm-li pwd-li${x.done ? ' dn' : ''}${x.lit ? ' now' : ''}" data-pwli="${esc(x.uid)}" data-pw-row="${esc(x.uid)}">${box}<span class="txt">${title}${sub ? `<span class="w${x.late ? ' late' : ''}">${esc(sub)}</span>` : ''}</span>${acts}</div>`;
157
+ };
158
+ const body = groups.map((G) => {
159
+ if (!G.tasks.length) { empty.push(G.s.name); return ''; }
160
+ const open = G.tasks.filter((x) => !x.done), dn = G.tasks.filter((x) => x.done);
161
+ return `<div class="pm-group${G.s.now ? ' now' : ''}"><b>${esc(G.s.name)}</b> <span class="pm-meta">${esc(dn.length + ' of ' + G.tasks.length + ' done')}</span></div>` + open.concat(dn).map(li).join('');
162
+ }).join('');
163
+ const fold = empty.length ? `<div class="pm-fold pwd-fold">${esc(empty.length === 1 ? empty[0] + ' has no tasks yet' : empty.slice(0, -1).join(', ') + ' and ' + empty[empty.length - 1] + ' have no tasks yet')}</div>` : '';
164
+ const cap = o.ro ? '' : `<input class="pm-input pwd-cap" data-pw-cap placeholder="Add a task; say its stage, or PMOS picks one" aria-label="Add a task. Say its stage, or PMOS picks one" maxlength="200" autocomplete="off">`;
165
+ const loose = o.looseN && !o.ro ? `<p class="pwd-loose"><button type="button" class="pw-lk" data-pw-backlog>${esc(o.looseN === 1 ? '1 task with no stage is in the Backlog' : o.looseN + ' tasks with no stage are in the Backlog')}${SV(I.right, 13)}</button></p>` : '';
166
+ return cap + `<div class="pwd-list" role="list" aria-label="Work breakdown">${body || (fold ? '' : '<p class="pm-meta pwd-none">No task yet.</p>')}${fold}</div>` + loose;
167
+ }
168
+
169
+ /* ── the side column ── */
170
+ /** The case: the lines PMOS read from the records, each a press that edits it in place; a line not written offers a PMOS draft. No line
171
+ * written: one Suggestion drafts them all (✓ sends the asks to Ask PMOS), ✕ says not now, the pencil starts the first line yourself. */
172
+ export function caseHtml(W, o = {}) {
173
+ const ov = W.overview || { lines: [] }, dr = o.dropped || new Set(), oid = o.oid || '';
174
+ const L = ov.lines || [], none = L.length && L.every((x) => !x.text);
175
+ const sid = (x) => 'ov:' + oid + ':' + x.id;
176
+ const ask = L.filter((x) => !x.text && x.ask && !dr.has(sid(x)));
177
+ let top = '';
178
+ if (none && !o.ro && ask.length) {
179
+ top = `<div class="pm-sug x" role="group" aria-label="PMOS suggests"><div class="ttl">${SV(I.star)}<b class="say">Let PMOS draft the case from what is linked</b></div>`
180
+ + `<dl><dt>Why</dt><dd>No line of the case is written yet.</dd><dt>PMOS will</dt><dd><ul>${ask.map((x) => `<li>${esc('Draft the ' + x.k.toLowerCase() + ' from the linked tickets, documents and meetings')}</li>`).join('')}</ul></dd><dt>What changes</dt><dd>You read the draft before it is saved.</dd></dl>`
181
+ + `<div class="ans"><button type="button" class="pm-btn" data-pw-line="${esc(L[0].id)}" aria-label="Write it yourself" title="Write it yourself">${SV(I.pen)}</button>`
182
+ + `<button type="button" class="pm-btn primary" data-pw-lkeep="${esc(ask.map((x) => x.id).join(','))}" aria-label="Use a PMOS draft" title="Use a PMOS draft">${SV(I.ok)}</button>`
183
+ + `<button type="button" class="pm-btn outline" data-pw-ldrop="${esc(ask.map(sid).join(','))}" aria-label="Not this" title="Not this">${SV(I.x)}</button></div></div>`;
184
+ }
185
+ const lines = L.filter((x) => !(none && top) || x.text).map((x) => {
186
+ const ed = !o.ro && x.edit;
187
+ const words = x.text ? esc(x.text) : 'Not written yet.';
188
+ const tx = ed ? `<span class="pwd-cv${x.text ? '' : ' grey'}" data-pw-line="${esc(x.id)}" tabindex="0" role="button" aria-label="${esc((x.text ? 'Change the ' : 'Write the ') + x.k.toLowerCase())}">${words}</span>` : `<span class="${x.text ? '' : 'grey'}">${words}</span>`;
189
+ const src = !o.ro && x.text && x.src ? (x.path ? ` <button type="button" class="pw-osrc" data-pw-src="${esc(x.path)}">from ${esc(x.src)}</button>` : ` <span class="pm-meta">from ${esc(x.src)}</span>`) : '';
190
+ const off = !o.ro && !x.text && x.ask && !dr.has(sid(x)) ? `<span class="pm-row pwd-off"><button type="button" class="pm-btn" data-pw-lkeep="${esc(x.id)}" aria-label="Yes, PMOS drafts it" title="Yes, PMOS drafts it">${SV(I.star, 14)}</button><button type="button" class="pm-btn" data-pw-ldrop="${esc(sid(x))}" aria-label="No" title="No">${SV(I.x, 14)}</button></span>` : '';
191
+ return `<div class="pwd-cl"><span class="pm-meta">${esc(x.k)}</span><p>${tx}${x.serves ? ' <span class="pm-meta">' + esc(x.serves) + '</span>' : ''}${src}${off}</p></div>`;
192
+ }).join('');
193
+ const F = (W.facts || []).filter((f) => f && f.k !== 'Stage' && !/^no signal$/i.test(String(f.v || '').trim()));
194
+ const facts = F.length ? `<dl class="pwd-facts">${F.map((f) => `<dt>${esc(f.k)}</dt><dd>${f.act && !f.read && !o.ro ? `<button type="button" class="pw-lk" data-pw-fact="${esc(f.act)}">${esc(f.v)}</button>` : `<span class="${f.grey ? 'grey' : ''}${f.warn && !f.note ? ' warn' : ''}">${esc(f.v)}</span>`}${f.note ? ` <span class="pm-meta${f.warn ? ' warn' : ''}">${esc(f.note)}</span>` : ''}</dd>`).join('')}</dl>` : '';
195
+ return `<section class="pm-block pwd-blk pwd-case" aria-label="The case"><h2 class="pm-h-sm">The case</h2>${top}${lines}${ov.status && !W.summary ? `<p>${esc(ov.status)}</p>` : ''}${facts}</section>`;
196
+ }
197
+ const iconOf = (a) => (a.link || /^link/i.test(a.kind || '') ? I.link : /slide|deck/i.test(a.kind || '') ? I.deck : /proto|design/i.test((a.kindName || '') + ' ' + (a.kind || '') + ' ' + (a.akind || '')) ? I.proto : I.doc);
198
+ /** arts: the model's artefacts, in its order (each row's press is its index, as the popup's handler reads it). o: { ro, merge (the ✦ line) } */
199
+ export function artsHtml(arts, o = {}) {
200
+ const R = (arts || []).map((a, i) => ({ a, i })).filter((x) => !(o.ro && x.a.missing));
201
+ if (o.ro && !R.length) return '';
202
+ const rows = R.map(({ a, i }) => {
203
+ const meta = a.missing ? String(a.missing) : [a.kindName || a.kind, a.came, a.when].filter(Boolean).join(' · ');
204
+ const inner = `<span class="pwd-ai">${SV(iconOf(a))}</span><span class="txt"><span class="t">${esc(a.title)}</span>${meta ? `<span class="w${a.missing ? ' warn' : ''}">${esc(meta)}</span>` : ''}</span>`;
205
+ return a.missing || o.ro ? `<div class="pm-li pwd-art${a.missing ? ' miss' : ''}">${inner}</div>` : `<button type="button" class="pm-li pwd-art" data-pw-art="${i}">${inner}</button>`;
206
+ }).join('');
207
+ const add = o.ro ? '' : `<button type="button" class="pm-btn" data-pw-addart aria-label="Add an artefact: a file, a link, or a new document" title="Add an artefact">${SV(I.plus)}</button>`;
208
+ return `<section class="pm-block pwd-blk pwd-arts" aria-label="Artefacts"><div class="pm-row pwd-bh"><h2 class="pm-h-sm">Artefacts</h2>${add}</div>${o.merge || ''}${rows || '<p class="pm-meta">Nothing yet.</p>'}</section>`;
209
+ }
210
+
211
+ /** Who can have a task (WorkStatesDS 1): You first, then the people who own tasks of this initiative, then PMOS. → [{ k, label, pmos? }] */
212
+ export function whoOf(rows, cur = '') {
213
+ const S = new Set();
214
+ for (const x of rows || []) if (x && x.kind === 'task' && !x.jira && x.who && x.who !== 'You') S.add(x.who);
215
+ return [{ k: 'You', label: 'You', on: cur === 'You' || cur === '' }].concat([...S].sort().map((n) => ({ k: n, label: n, on: n === cur })), [{ k: '', label: 'PMOS does it', pmos: true }]);
216
+ }
217
+ /** The stages a task can move to: the workflow's, in order. → [{ key, name, on }] */
218
+ export function stageList(st, cur) {
219
+ return (st || []).filter((x) => x && x.kind === 'stage' && x.key !== '').map((x) => ({ key: x.key, name: x.name, on: x.key === cur }));
220
+ }
221
+ /** The stage a task sits in: the last stage row above it in the breakdown. → key, or '' when it is in no stage */
222
+ export function stageOfTask(st, uid) {
223
+ let k = '';
224
+ for (const x of st || []) { if (x.kind === 'stage') k = x.key; else if (x.uid === uid) return k; }
225
+ return '';
226
+ }
227
+ /** A milestone's full popup, under its title (WorkStatesDS 6): its date and how far off, the initiative's done test and Kill if, then PMOS's
228
+ * suggestion about it when there is one. row: { uid, end, start, done }. o: { kill, ro } */
229
+ export function msHead(row, W, o = {}) {
230
+ const d = day(row.end || row.start), t = day(W.today);
231
+ const n = d != null && t != null ? Math.round((d - t) / DAY) : null;
232
+ const left = row.done || n == null ? '' : n === 0 ? 'today' : n > 0 ? 'in ' + n + (n === 1 ? ' day' : ' days') : (-n === 1 ? '1 day' : -n + ' days') + ' late';
233
+ const when = d == null ? 'No date yet' : [dayText(row.end || row.start, W.today), row.done ? 'done' : left].filter(Boolean).join(' · ');
234
+ const dt = ((W.overview && W.overview.lines) || []).find((l) => l.id === 'done');
235
+ const r = (k, v, cls = '') => `<dt>${k}</dt><dd${cls ? ` class="${cls}"` : ''}>${esc(v)}</dd>`;
236
+ const facts = `<dl class="pwd-facts">${r('Date', when, n != null && n < 0 && !row.done ? 'warn' : '')}${r('Done test', dt && dt.text ? dt.text : 'Not written yet', dt && dt.text ? '' : 'grey')}${o.kill ? r('Kill if', o.kill) : ''}</dl>`;
237
+ const s = W.rowSuggests && W.rowSuggests.get ? W.rowSuggests.get(row.uid) : null;
238
+ return `<div class="pwd-msh">${facts}${s && !o.ro ? sugHtml(s) : ''}</div>`;
239
+ }
@@ -26,12 +26,16 @@ import * as ED from './ini-edit.js';
26
26
  import * as SW from './cozy-status-when.js'; // When did this happen? after a status pick (round 3 point 18)
27
27
  import * as DP from './cozy-day-pick.js'; // the app's own day field, "15 Oct 2026"
28
28
  const { localToday } = DP;
29
- import * as AK from './artefact-kind.js'; // 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)
29
+ import * as AK from './artefact-kind.js';
30
+ 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)
30
31
 
31
- const CSS = new URL('./cozy-pop-work.css', import.meta.url).href;
32
+ const CSS = new URL('./cozy-pop-work.css', import.meta.url).href, DSCSS = new URL('./bd-pop-ds.css', import.meta.url).href;
32
33
  if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
33
34
  const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l);
34
35
  }
36
+ if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${DSCSS}"]`)) {
37
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = DSCSS; document.head.appendChild(l);
38
+ }
35
39
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
36
40
  const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
37
41
  const P = {
@@ -291,9 +295,30 @@ export function html(r, v, o = {}) {
291
295
  const { W, S } = model(r, v, o), C = cols(), mode = store.get(SPAN, 'full');
292
296
  if (phone() && !RO) return phoneHtml(W, S, keyOf(v, o), v);
293
297
  if (S.big) return `<div class="pw" data-pw-big-on>${breakdownHtml(W, C, mode, true, S)}</div>`;
298
+ if (!RO && !phone()) return dsHtml(r, v, o, W, S, C, mode);
294
299
  return `<div class="pw">${overviewHtml(W, S, keyOf(v, o))}${breakdownHtml(W, C, mode, false, S)}${artefactsHtml(W.artefacts, C, true, { scope: keyOf(v, o), recPath: v.prd && (v.prd.path || v.prd) })}</div>`;
295
300
  }
296
301
 
302
+ /* ── a computer (initiative work-ds-popup; boards WorkPopupDS, WorkGanttDS, WorkCaseEmptyDS): the main column (Where it stands, Stages, the
303
+ * Work breakdown as List or Gantt) and the side column (The case, Artefacts), from the system's blocks (pm/bd-pop-ds.js). The Gantt view is the
304
+ * breakdown table with its bars and tools; List and Gantt are one remembered choice ('pw-view'). */
305
+ const VIEW = 'pw-view';
306
+ const allOpen = (v) => { const k = new Set(((v.tasks || {}).sections || []).filter((s) => s.kind === 'stage').map((s) => s.key)); return k; };
307
+ function stagesOf(r, v, o) {
308
+ const k = allOpen(v);
309
+ return M.breakdownOf(r, v, { ...o, open: k, shut: new Set(), doneOpen: k, moreOpen: k, farOpen: true }).rows;
310
+ }
311
+ function dsHtml(r, v, o, W, S, C, mode) {
312
+ const id = keyOf(v, o), view = store.get(VIEW, 'list') === 'gantt' ? 'gantt' : 'list';
313
+ const st = stagesOf(r, v, { ...o, today: W.today, focus: S.focus });
314
+ const wbs = view === 'gantt'
315
+ ? breakdownHtml(W, C, mode, false, S).replace('<h3>Work breakdown</h3>', PD.wbsHead('gantt')).replace('class="pw-sec"', 'class="pw-sec pm-block pwd-blk pwd-wbs"')
316
+ : `<section class="pm-block pwd-blk pwd-wbs" aria-label="Work breakdown">${PD.wbsHead('list')}${PD.listHtml(st, W, { looseN: W.looseN })}</section>`;
317
+ const mg = mergeOf(W.artefacts), merge = mg ? `<div class="pw-sugs pw-amg" role="list" aria-label="PMOS suggests">${sugLine({ id: mg.id, say: mg.say, merge: mg })}</div>` : '';
318
+ return `<div class="pw pwd">${'<div class="pwd-main">'}${PD.standsHtml(W, r)}${PD.stagesHtml(st, W)}${wbs}</div>`
319
+ + `<aside class="pwd-side">${PD.caseHtml(W, { oid: id, dropped: dropped() })}${PD.artsHtml(W.artefacts, { merge })}</aside></div>`;
320
+ }
321
+
297
322
  /* ── a phone (board Ph2_init; build brief nav-structure/phone/build-brief-v2.md item 8): the popup's content in a phone layout. No cards and
298
323
  * no table: the stage and its days over, the gate line, ✦ Overview with the lines that are written and one proposal for the ones that are not,
299
324
  * the status line and PMOS's proposals, the Work breakdown as rows with a status dot (grey done, blue in progress, an empty ring to do), the
@@ -450,10 +475,14 @@ export function wire(body, h0, x0) {
450
475
  body.addEventListener('scroll', () => { if (!body.querySelector(':scope > .pw, .pw:not(.pw-sp)')) return; const c = cur(); if (c) c.S.top = body.scrollTop; }, { passive: true });
451
476
  body.addEventListener('click', async (e) => {
452
477
  if (!live(e)) return;
453
- const b = e.target.closest('button, [data-pw-line]'); if (!b || b.disabled || !body.contains(b)) return;
478
+ const b = e.target.closest('button, [data-pw-line]');
479
+ // a List row (work-ds-popup): a press on the rest of the row opens the task
480
+ if (!b) { const li = e.target.closest('[data-pwli]'); if (li && !e.target.closest('input, textarea')) { const c0 = cur(); if (c0) openSmall(li.dataset.pwli, c0, body.__pwh, body.__pwx, body); } return; }
481
+ if (b.disabled || !body.contains(b)) return;
454
482
  const c = cur(); if (!c) return;
455
483
  const h = body.__pwh, x = body.__pwx;
456
484
  const d = b.dataset, S = c.S, W = c.W;
485
+ if (d.pwv) { store.set(VIEW, d.pwv); redraw(); return; }
457
486
  if ('pwDetails' in d) { S.details = !S.details; redraw(); return; }
458
487
  if (d.pwFold != null) { const k = d.pwFold, open = b.getAttribute('aria-expanded') === 'true'; S.open.delete(k); S.shut.delete(k); (open ? S.shut : S.open).add(k); if (k === '') looseKeep(c.id, !open); redraw(); return; }
459
488
  if ('pwFar' in d) { S.farOpen = true; redraw(); return; }
@@ -479,6 +508,10 @@ export function wire(body, h0, x0) {
479
508
  if (d.pwMore != null) { S.moreOpen.add(d.pwMore); redraw(); return; }
480
509
  if (d.pwVer) { if (ARTOPEN.has(d.pwVer)) ARTOPEN.delete(d.pwVer); else ARTOPEN.add(d.pwVer); redraw(); return; }
481
510
  if (d.pwRowMore) { rowMenu(b, d.pwRowMore, c, h, body); return; }
511
+ // quick edit in the row (work-ds-quick-edit, WorkStatesDS 1 and 3): the tick, Who and Stage
512
+ if (d.pwTick) { b.disabled = true; if (h.status) await h.status(d.pwTick, 'Done'); return; }
513
+ if (d.pwWho) { whoMenu(b, d.pwWho, c, h, x); return; }
514
+ if (d.pwStage) { stageMenu(b, d.pwStage, c, h, x); return; }
482
515
  if ('pwAddty' in d) { S.msAdd = !S.msAdd; const f = b.closest('.pw-add'), k = f && f.querySelector('[data-pw-add]') && f.querySelector('[data-pw-add]').dataset.pwAdd; redraw(); if (k != null) setTimeout(() => { const i = body.querySelector(`[data-pw-add="${window.CSS.escape(k)}"]`); if (i) i.focus(); }, 0); return; }
483
516
  if (d.pwFact) { fact(d.pwFact, b, c, h); return; }
484
517
  if (d.pwStatus) { statusMenu(b, d.pwStatus, h, c); return; }
@@ -486,7 +519,8 @@ export function wire(body, h0, x0) {
486
519
  if (d.pwName) { rename(b, d.pwName, h); return; }
487
520
  if (d.pwOpen) { openSmall(d.pwOpen, c, h, x, body); return; }
488
521
  if ('pwBacklog' in d) { const o = x.o() || {}, w = h.where ? h.where() : {}, q = new URLSearchParams({ work: 'backlog' }); if (w.ws || o.ws) q.set('ws', w.ws || o.ws); if (o.id) q.set('ini', o.id); location.href = '/premium-board.html?' + q.toString(); return; }
489
- if (d.cbMs != null) { msPop(b, d.cbMs, W, h); return; }
522
+ // a milestone ◇ opens its full popup (WorkStatesDS 6); a Jira one and a phone keep the small card
523
+ if (d.cbMs != null) { const rw = W.rows.find((r) => r.uid === d.cbMs); if (rw && !rw.jira && !phone()) openSmall(d.cbMs, c, h, x, body); else msPop(b, d.cbMs, W, h); return; }
490
524
  if (d.pwArt != null) { openArt(W.artefacts[+d.pwArt], h, x); return; }
491
525
  if ('pwAddart' in d) { addArt(x, h); return; }
492
526
  });
@@ -494,6 +528,15 @@ export function wire(body, h0, x0) {
494
528
  if (!live(e)) return;
495
529
  const t = e.target, h = body.__pwh;
496
530
  if (t.matches && t.matches('[data-pw-line]') && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); t.click(); return; }
531
+ // the List's one capture Input (work-ds-popup): the task goes to the stage it names ("… in Plan"), else the stage in progress
532
+ if (t.matches && t.matches('[data-pw-cap]') && e.key === 'Enter') {
533
+ e.preventDefault(); const v0 = t.value.trim(), c = cur(); if (!v0 || !h.addTask || !c) return;
534
+ const ms = /^◇\s*/.test(v0), k = PD.stageKeyOf(v0.replace(/^◇\s*/, ''), stagesOf(c.r, c.v, { ...(body.__pwx.o() || {}), today: c.W.today }));
535
+ if (!k || !k.title) return;
536
+ await h.addTask(k.title, t, { section: k.key, name: k.name, ...(ms ? { milestone: true } : {}) });
537
+ setTimeout(() => { const f = body.querySelector('[data-pw-cap]'); if (f) { f.value = ''; f.focus(); } }, 0);
538
+ return;
539
+ }
497
540
  if (t.matches && t.matches('[data-pw-add]') && e.key === 'Enter') {
498
541
  e.preventDefault(); const v0 = t.value.trim(); if (!v0 || !h.addTask) return;
499
542
  const sec = t.dataset.pwAdd, c = cur();
@@ -661,13 +704,49 @@ function dateMenu(btn, uid, c, h) {
661
704
  }
662
705
  function rowMenu(btn, uid, c, h, body) {
663
706
  const row = c.W.rows.find((x) => x.uid === uid) || {};
664
- openPop(btn, 'pw-rowm', `<button type="button" class="hi-mi" role="menuitem" data-k="kind">${SVG(row.ms ? P.box : P.dia, 14, 2)} ${row.ms ? 'Make it a task' : 'Make it a milestone'}</button>`
707
+ openPop(btn, 'pw-rowm', `<button type="button" class="hi-mi" role="menuitem" data-k="status">${SVG(P.box, 14, 2)} Status: ${esc(row.status || 'To do')}</button>`
708
+ + `<button type="button" class="hi-mi" role="menuitem" data-k="kind">${SVG(row.ms ? P.box : P.dia, 14, 2)} ${row.ms ? 'Make it a task' : 'Make it a milestone'}</button>`
665
709
  + `<button type="button" class="hi-mi" role="menuitem" data-k="open">${SVG(P.open, 14)} Open the task</button>` + jiraNote(row), (b) => {
710
+ const k = b.dataset.k;
711
+ // Status opens its own list (and its "when did this happen" line) in place of this menu
712
+ if (k === 'status') { statusMenu(btn, uid, h, c); return; }
666
713
  closePop();
667
- if (b.dataset.k === 'kind') setKind(row, !row.ms, h);
668
- else if (b.dataset.k === 'open') openSmall(uid, c, h, body.__pwx, body);
714
+ if (k === 'kind') setKind(row, !row.ms, h);
715
+ else if (k === 'open') openSmall(uid, c, h, body.__pwx, body);
669
716
  }, { menu: true, label: 'Task' });
670
717
  }
718
+ /* Who (WorkStatesDS 1): You, the people who own this initiative's tasks, and "PMOS does it". A name writes the owner (Undo puts the old one
719
+ * back, POST /api/boards/tasks/edit with `from`); PMOS does it gives the task to PMOS (POST /api/backlog/give; Undo is /api/backlog/stop). */
720
+ function whoMenu(btn, uid, c, h, x) {
721
+ const row = c.W.rows.find((r) => r.uid === uid) || {};
722
+ const L = PD.whoOf(c.W.rows, row.who || '');
723
+ openPop(btn, 'pw-who', L.map((p, i) => `<button type="button" class="hi-mi" role="menuitemradio" aria-checked="${!!p.on}" data-i="${i}">${SVG(p.pmos ? P.spark : PD.I.who, 14, 2)} ${esc(p.label)}</button>`).join(''), async (b) => {
724
+ const p = L[+b.dataset.i]; closePop(); if (!p || p.on) return;
725
+ const o = (x && x.o && x.o()) || {}, w = h.where ? h.where() : {}, ws = w.ws || o.ws, board = w.board || o.board;
726
+ const say = (m) => (h.toast ? h.toast(m) : undoToast(m));
727
+ if (p.pmos) {
728
+ const r = await pmPost('/api/backlog/give', { ws, board, tasks: [uid] }).catch(() => null);
729
+ if (!r || r.ok === false) { say((r && r.error) || 'PMOS did not take it.'); return; }
730
+ undoToast('PMOS does ' + (row.title || 'it') + '.', async () => { const u = await pmPost('/api/backlog/stop', { ws, board, task: uid }).catch(() => null); if (!u || u.ok === false) say((u && u.error) || 'The undo did not land.'); if (h.reload) await h.reload(); });
731
+ if (h.reload) await h.reload();
732
+ return;
733
+ }
734
+ const owner = p.k === 'You' ? '' : p.k;
735
+ const r = await pmPost('/api/boards/tasks/edit', { ws, board, task: uid, owner }).catch(() => null);
736
+ if (!r || r.ok === false) { say((r && r.error) || 'The owner was not changed.'); return; }
737
+ const was = (r.from && r.from.owner) || '';
738
+ undoToast((owner ? owner + ' has ' : 'You have ') + (row.title || 'it') + '.', async () => { const u = await pmPost('/api/boards/tasks/edit', { ws, board, task: uid, owner: was }).catch(() => null); if (!u || u.ok === false) say((u && u.error) || 'The undo did not land.'); if (h.reload) await h.reload(); });
739
+ if (h.reload) await h.reload();
740
+ }, { menu: true, label: 'Who', focus: '[aria-checked="true"]' });
741
+ }
742
+ /* Stage (WorkStatesDS 1): the workflow's stages; a pick moves the task there through the host's move (its toast carries the Undo) */
743
+ function stageMenu(btn, uid, c, h, x) {
744
+ const st = stagesOf(c.r, c.v, { ...((x && x.o && x.o()) || {}), today: c.W.today }), cur = PD.stageOfTask(st, uid), L = PD.stageList(st, cur);
745
+ openPop(btn, 'pw-stage', L.map((s, i) => `<button type="button" class="hi-mi" role="menuitemradio" aria-checked="${s.on}" data-i="${i}">${esc(s.name)}</button>`).join('') || '<p class="hi-small">This work has no stages.</p>', (b) => {
746
+ const s = L[+b.dataset.i]; closePop(); if (!s || s.on || !h.move) return;
747
+ h.move(uid, { to: s.key, from: cur, name: s.name });
748
+ }, { menu: true, label: 'Stage', focus: '[aria-checked="true"]' });
749
+ }
671
750
  /* "Open the task" opens the small task popup on top (round 3 point 20, pm/cozy-task-pop.js); ↑ ↓ step through this list. A Jira ticket keeps its
672
751
  * ticket view. On close the row is lit for a moment. */
673
752
  async function openSmall(uid, c, h, x, body, bt) {
@@ -685,6 +764,24 @@ async function openSmall(uid, c, h, x, body, bt) {
685
764
  // the row behind changes at once (Wawan, 2026-11-19: a new date or status did not show until the board was read again); the reload follows
686
765
  patch: (u, p) => { const rr = x && x.r && x.r(), tk = rr && Array.isArray(rr.tasks) ? rr.tasks.find((q) => q && q.uid === u) : null; if (!tk) return; if (!p) { rr.tasks.splice(rr.tasks.indexOf(tk), 1); if (h.redraw) h.redraw(); return; } Object.assign(tk, { status: p.status || tk.status, end: p.end, start: p.start, milestone: p.milestone }); if (h.redraw) h.redraw(); },
687
766
  onChange: () => { if (h.reload) h.reload(); },
767
+ // the full popup over the work side (work-ds-quick-edit, WorkStatesDS 4 and 6): ← and the path go back to this initiative, the chat button
768
+ // shows the popup's chat, × closes the popup; a milestone shows its date, the done test and PMOS's suggestion about it
769
+ full: !phone(), path: [o.from || 'Work', o.product || '', ((x && x.v && x.v()) || {}).title || ''].filter(Boolean),
770
+ chat: () => { const a = document.querySelector('.cz-pop [data-pop="ask"]'); if (a) a.click(); },
771
+ closeAll: () => { const k = document.querySelector('.cz-pop [data-pop="close"]'); if (k) k.click(); },
772
+ head: (t) => {
773
+ if (!t.milestone) return '';
774
+ const cc = body.__pwx && body.__pwx.r() ? model(body.__pwx.r(), body.__pwx.v(), body.__pwx.o()) : c, rr = (x && x.r && x.r()) || {};
775
+ return PD.msHead({ uid: t.uid, end: t.due, start: t.start, done: /^done$/i.test(t.status || '') }, cc.W, { kill: rr.kill || (rr.outcome && rr.outcome.kill) || '' });
776
+ },
777
+ headPress: async (b, tp) => {
778
+ const d = b.dataset, cc = body.__pwx && body.__pwx.r() ? model(body.__pwx.r(), body.__pwx.v(), body.__pwx.o()) : c;
779
+ const sg = findSug(cc.W, d.pwKeep || d.pwDrop || d.pwSug || ''); if (!sg) return false;
780
+ if (d.pwKeep) { b.disabled = true; await keepSug(sg, x, h); tp.refresh(); return true; }
781
+ if (d.pwDrop) { b.disabled = true; await dropSug(sg, x, h); tp.refresh(); return true; }
782
+ if (d.pwSug) { tp.close(); openSug(sg, cc, x, h); return true; }
783
+ return false;
784
+ },
688
785
  onClose: (u) => { const r = body.querySelector(`[data-pw-row="${window.CSS.escape(u)}"]`); if (r) { r.classList.add('lit'); r.scrollIntoView({ block: 'nearest' }); setTimeout(() => r.classList.remove('lit'), 1600); } },
689
786
  });
690
787
  }
@@ -33,3 +33,22 @@ button.ctp-t:hover { background: var(--cz-well); }
33
33
  }
34
34
  .ctp-when .sw { border-top: 0; margin-top: 0; padding-top: 0; }
35
35
  .ctp-menu button.ctp-del { color: var(--cz-late); }
36
+ /* the full popup (work-ds-quick-edit, WorkStatesDS 4 and 6): it takes the place of the popup's work side, the same size; the chat beside it stays
37
+ * usable, so its scrim neither dims nor catches presses. Head: ← and the path, then chat, ⋯ and ×; under it the kind and the title. */
38
+ .ctp-scrim.ctp-full { background: transparent; pointer-events: none; }
39
+ .ctp.ctp-full { transform: none; max-height: none; width: auto; border-radius: 28px; padding: var(--space-16) var(--space-24) var(--space-24); box-shadow: 0 0 0 1px var(--cz-hair); }
40
+ .ctp-full .ctp-fh { margin-bottom: var(--space-16); }
41
+ .ctp-path { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-4); font-size: var(--fs-row); color: var(--cz-ink2); overflow: hidden; white-space: nowrap; }
42
+ .ctp-cr { border: 0; background: none; padding: 0; font: inherit; color: inherit; overflow: hidden; text-overflow: ellipsis; }
43
+ button.ctp-cr { cursor: pointer; color: var(--cz-ink); }
44
+ button.ctp-cr:hover { text-decoration: underline; }
45
+ .ctp-sep { color: var(--cz-ink2); }
46
+ .ctp-th { display: flex; align-items: center; gap: var(--space-8); margin: 0 0 var(--space-12); }
47
+ .ctp-full .ctp-t { font-size: var(--fs-panel); }
48
+ .ctp-full .ctp-b, .ctp-full .ctp-hx { max-width: 720px; }
49
+ .ctp-hx { margin: 0 0 var(--space-16); display: flex; flex-direction: column; gap: var(--space-12); }
50
+ .ctp-hx .pwd-facts { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--space-4) var(--space-12); margin: 0; }
51
+ .ctp-hx .pwd-facts dt { color: var(--cz-ink2); }
52
+ .ctp-hx .pwd-facts dd { margin: 0; }
53
+ .ctp-hx .grey { color: var(--cz-ink2); }
54
+ .ctp-hx .warn { color: var(--cz-late); }
@@ -5,7 +5,11 @@
5
5
  * row?(uid) → the row the host drew (GET /api/boards/items adds the owner and notes when it answers), list?() → [uid] (↑ ↓ step through it),
6
6
  * rename?(task, title) → Promise (the title,
7
7
  * pressed, becomes a field; Enter or leaving it saves), onClose?(uid) (the host
8
- * lights the row), openIni?(id) }
8
+ * lights the row), openIni?(id),
9
+ * full?: true → the full popup over the work side of the popup (work-ds-quick-edit, WorkStatesDS 4 and 6): ← and the
10
+ * path (path?: [crumb]) go back to the initiative, chat?() shows the popup's chat, × closes the task and the popup
11
+ * (closeAll?()); head?(t) → html under the title (a milestone's date, done test and suggestion), its presses go to
12
+ * headPress?(button, { refresh, close }) }
9
13
  * closeTask() closes it, as ✕, Esc or a press outside do. Esc closes only the small popup.
10
14
  *
11
15
  * Inside: the kind (Task or Milestone, pressed to switch) and the title; the one task card (pm/task-card.js mountCard: status, due, owner, notes,
@@ -22,6 +26,7 @@ if (typeof document !== 'undefined' && document.head && !document.querySelector(
22
26
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
23
27
  const SVG = (d) => `<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
24
28
  const P = {
29
+ back: 'M19 12H5M11 6l-6 6 6 6',
25
30
  x: 'M6 6l12 12M18 6L6 18', up: 'M7 14l5-5 5 5', down: 'M7 10l5 5 5-5', chat: 'M4 5h16v11H9l-5 4z', more: 'M5 12h.01M12 12h.01M19 12h.01',
26
31
  dia: 'M12 4l8 8-8 8-8-8z', box: 'M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z',
27
32
  };
@@ -40,15 +45,24 @@ async function rowOf(uid, ctx) {
40
45
 
41
46
  export function closeTask() {
42
47
  if (!S) return;
43
- const { el, scrim, uid, ctx, prevFocus } = S;
48
+ const S0 = S, { el, scrim, uid, ctx, prevFocus } = S;
44
49
  S = null;
45
50
  document.removeEventListener('keydown', onKey, true);
51
+ if (S0.ro) S0.ro.disconnect(); if (S0.offPop) document.removeEventListener('click', S0.offPop, true); window.removeEventListener('resize', place);
46
52
  el.remove(); scrim.remove();
47
53
  document.body.classList.remove('ctp-on');
48
54
  if (ctx.onClose) ctx.onClose(uid);
49
55
  if (prevFocus && prevFocus.isConnected) prevFocus.focus();
50
56
  }
51
57
 
58
+ /** The full popup takes the place of the popup's work side; with no popup open it stays centred. */
59
+ function place() {
60
+ if (!S || !S.el.classList.contains('ctp-full')) return;
61
+ const L = document.querySelector('.cz-pop .cz-pop-l'), r = L && L.getBoundingClientRect();
62
+ if (!r || !r.width) { S.el.removeAttribute('style'); return; }
63
+ Object.assign(S.el.style, { left: r.left + 'px', top: r.top + 'px', width: r.width + 'px', height: r.height + 'px' });
64
+ }
65
+
52
66
  function onKey(e) {
53
67
  if (!S) return;
54
68
  if (e.key === 'Escape') {
@@ -71,6 +85,16 @@ export async function openTask(uid, ctx = {}) {
71
85
  document.body.append(scrim, el);
72
86
  document.body.classList.add('ctp-on');
73
87
  S = { el, scrim, ctx, uid, prevFocus: document.activeElement };
88
+ // the full popup lies over the work side of the popup and follows its size (the chat opening beside it narrows it)
89
+ if (ctx.full) {
90
+ el.classList.add('ctp-full'); scrim.classList.add('ctp-full');
91
+ const L = document.querySelector('.cz-pop .cz-pop-l');
92
+ if (L && typeof ResizeObserver !== 'undefined') { S.ro = new ResizeObserver(place); S.ro.observe(L); }
93
+ window.addEventListener('resize', place); place();
94
+ // the popup behind closing (its scrim or its own ×) takes the full popup with it
95
+ S.offPop = (e) => { if (e.target.closest && e.target.closest('.cz-pop [data-pop="close"]')) closeTask(); };
96
+ document.addEventListener('click', S.offPop, true);
97
+ }
74
98
  document.addEventListener('keydown', onKey, true);
75
99
  el.addEventListener('click', press);
76
100
  // the status pick waits for the day (point 18): the card's own press is held here, the line opens under the card
@@ -96,9 +120,20 @@ async function show(uid) {
96
120
  const title = !t.jira && ctx.rename ? `<button type="button" class="ctp-t" data-ctp-rename aria-label="${esc('Rename ' + t.title)}">${esc(t.title)}</button>` : `<span class="ctp-t">${esc(t.title)}</span>`;
97
121
  const step = L.length > 1 && i >= 0 ? ib(`data-ctp-step="-1"${i === 0 ? ' disabled' : ''}`, 'Previous task', P.up) + ib(`data-ctp-step="1"${i === L.length - 1 ? ' disabled' : ''}`, 'Next task', P.down) : '';
98
122
  const more = !t.jira ? ib('data-ctp-more aria-haspopup="menu"', 'More for this task', P.more) : '';
99
- S.el.setAttribute('aria-label', 'Task: ' + t.title);
100
- S.el.innerHTML = `<div class="ctp-h">${kind}${title}<span class="ctp-tools">${step}${more}${ib('data-ctp-close', 'Close', P.x)}</span></div>`
101
- + '<div class="ctp-b"></div><div class="ctp-when" hidden></div>';
123
+ S.el.setAttribute('aria-label', (t.milestone ? 'Milestone: ' : 'Task: ') + t.title);
124
+ if (ctx.full) {
125
+ // WorkStatesDS 4 and 6: ← and the path back to the initiative, then chat, ⋯ and ×; the kind and the title under it
126
+ const path = ctx.path || [], last = path.length - 1;
127
+ const crumbs = path.map((p, k) => (k === last ? `<button type="button" class="ctp-cr" data-ctp-close>${esc(p)}</button>` : `<span class="ctp-cr">${esc(p)}</span>`)).join('<span class="ctp-sep" aria-hidden="true">›</span>');
128
+ const head = ctx.head ? ctx.head(t) : '';
129
+ S.el.innerHTML = `<div class="ctp-h ctp-fh">${ib('data-ctp-close', 'Back to ' + (path[last] || 'the initiative'), P.back)}<nav class="ctp-path" aria-label="Where this is">${crumbs}</nav>`
130
+ + `<span class="ctp-tools">${step}${ctx.chat ? ib('data-ctp-chat', 'Ask PMOS about this', P.chat) : ''}${more}${ib('data-ctp-x', 'Close', P.x)}</span></div>`
131
+ + `<div class="ctp-th">${kind}${title}</div>${head ? `<div class="ctp-hx">${head}</div>` : ''}`
132
+ + '<div class="ctp-b"></div><div class="ctp-when" hidden></div>';
133
+ } else {
134
+ S.el.innerHTML = `<div class="ctp-h">${kind}${title}<span class="ctp-tools">${step}${more}${ib('data-ctp-close', 'Close', P.x)}</span></div>`
135
+ + '<div class="ctp-b"></div><div class="ctp-when" hidden></div>';
136
+ }
102
137
  const base = boardSaver({ ws: ctx.ws, board: raw.board || ctx.board, t, post: (p, b) => ctx.pmPost(p, b) });
103
138
  const save = (patch) => {
104
139
  // a status the PM dated earlier carries that day; Undo and every other change go as they always did
@@ -147,7 +182,10 @@ async function press(e) {
147
182
  if (!S) return;
148
183
  const b = e.target.closest('button'); if (!b || b.disabled || !S.el.contains(b)) return;
149
184
  const d = b.dataset, ctx = S.ctx, t = S.t;
185
+ if (b.closest('.ctp-hx')) { if (ctx.headPress) { const s0 = S; await ctx.headPress(b, { refresh: () => { if (S === s0) show(s0.uid); }, close: closeTask }); } return; }
150
186
  if ('ctpClose' in d) { closeTask(); return; }
187
+ if ('ctpChat' in d) { if (ctx.chat) ctx.chat(); return; }
188
+ if ('ctpX' in d) { const all = ctx.closeAll; closeTask(); if (all) all(); return; }
151
189
  if (d.ctpStep) { const L = ctx.list ? ctx.list() : [], j = L.indexOf(S.uid) + Number(d.ctpStep); if (j >= 0 && j < L.length) show(L[j]); return; }
152
190
  if ('ctpRename' in d && t && ctx.rename) { renameField(b); return; }
153
191
  if ('ctpKind' in d && t) { kindOf(!t.milestone); return; }
@@ -291,7 +291,7 @@ export function goalName(list, anchor) {
291
291
  function taskRow(x, t) {
292
292
  const dl = x.end ? dateLate(x.end, t, !x.closed) : { text: x.start ? 'from ' + dayText(x.start, t) : '', late: false };
293
293
  const st = taskStatus(x);
294
- return { kind: 'task', uid: x.uid, title: x.title, status: st, date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', since: x.since || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck,
294
+ return { kind: 'task', uid: x.uid, title: x.title, who: x.owner || '', status: st, date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', since: x.since || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck,
295
295
  prog: /progress|review/i.test(st), wont: !!x.wont || st === "Won't do" };
296
296
  }
297
297
  /** o.focus: the task a Today row opened (round 3 item 11b): its stage, its done fold and the far stages open, and its row lit. */