create-pmos 0.768.0 → 0.770.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.
@@ -33,7 +33,7 @@ const B = require(repoScript('boards.js'));
33
33
  const TI = require('./task-items.js');
34
34
  const rowsLib = require('./initiative-rows.js');
35
35
 
36
- const COMMANDS = { task: ['add', 'list', 'state', 'set', 'remove', 'link', 'unlink', 'describe'] };
36
+ const COMMANDS = { task: ['add', 'list', 'state', 'set', 'remove', 'link', 'unlink', 'describe', 'comment'] };
37
37
  const USAGE = [
38
38
  'usage: pmos task add|list|state|set|remove — an initiative\'s tasks, the ones the PM sees in its Tasks section',
39
39
  ' pmos task add <initiative> "<title>" [--stage <stage>] [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>] [--parent <task>]',
@@ -58,6 +58,7 @@ const USAGE = [
58
58
  ' The Tasks section groups tasks by the workflow\'s stages: --stage places a task there. It never changes the task\'s state or',
59
59
  ' moves the initiative. Move the initiative with pmos workflow move.',
60
60
  ' pmos task describe <task> ["<text>"]',
61
+ ' pmos task comment <task> ["<text>"]',
61
62
  ' Print the task\'s description, or write it when the PM asks (what it is, why, and when it is done). "none" clears it.',
62
63
  ' The page shows it at once, with Undo. A Jira ticket keeps its description in Jira: it is refused here.',
63
64
  ' pmos task link <from> <to> [--type fs|ss|ff|sf] [--lag <days>] [--propose --why <text>]',
@@ -70,7 +71,7 @@ const USAGE = [
70
71
  const BOOL = new Set(['json', 'help', 'all', 'milestone', 'no-milestone', 'pin', 'no-pin', 'pin-default', 'propose']);
71
72
  const PIN_FLAGS = ['pin', 'no-pin', 'pin-default'];
72
73
  const VALUE = new Set(['to', 'why', 'root', 'due', 'start', 'owner', 'notes', 'stage', 'type', 'lag', 'parent']);
73
- const ONLY = { add: ['due', 'start', 'owner', 'notes', 'stage', 'parent'], list: ['all'], state: ['to', 'why'], remove: ['why'], set: ['due', 'start', 'owner', 'notes', 'stage', 'parent'], link: ['type', 'lag', 'why'], unlink: [], describe: [] };
74
+ const ONLY = { add: ['due', 'start', 'owner', 'notes', 'stage', 'parent'], list: ['all'], state: ['to', 'why'], remove: ['why'], set: ['due', 'start', 'owner', 'notes', 'stage', 'parent'], link: ['type', 'lag', 'why'], unlink: [], describe: [], comment: [] };
74
75
  const OPEN = new Set(['To do', 'In progress']);
75
76
  /** The PM's words for a state: any case, with or without the apostrophe or the space. */
76
77
  function stateOf(s) {
@@ -282,6 +283,28 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
282
283
  return 0;
283
284
  }
284
285
 
286
+ if (verb === 'comment') {
287
+ // initiative task-detail-one-column: chat writes every card. List with one argument, add one with two; the same route as the page's box
288
+ const [id, text] = pos;
289
+ if (!id || pos.length > 2) { say('usage: pmos task comment <task> ["<text>"]'); return 2; }
290
+ const folded = boards.foldOf(ctx, w);
291
+ const t = findTask(folded, id);
292
+ if (!t) return fail(`no task ${id}; pmos task list <initiative> names them`);
293
+ if (text === undefined) {
294
+ const L = (folded.comments || new Map()).get(id) || [];
295
+ const by = (c) => (/^pm:/.test(String(c.by || '')) ? 'You' : /^agent:/.test(String(c.by || '')) ? 'PMOS' : c.by || 'You');
296
+ if (json) say(JSON.stringify({ ok: true, task: id, comments: L.map((c) => ({ text: c.text, by: by(c), at: c.at })) }));
297
+ else if (!L.length) say(`${id} has no comments yet.`);
298
+ else for (const c of L) say(`${String(c.at || '').slice(0, 10)} ${by(c)}: ${c.text}`);
299
+ return 0;
300
+ }
301
+ const e = boards.taskComment(ctx, { ws: w.id, board: t.board, task: id, text: String(text) }, g);
302
+ if (!e.body || e.body.ok !== true) return fail((e.body && e.body.error) || 'the write was refused');
303
+ if (json) say(JSON.stringify({ ok: true, task: id, comment: e.body.comment }));
304
+ else say(`✓ ${id} has your comment: ${t.title}. The page shows it under Activity › Comments. Nothing was sent.`);
305
+ return 0;
306
+ }
307
+
285
308
  if (verb === 'remove') {
286
309
  // batch 7 item 5: a task added by mistake goes from every list (POST /api/boards/tasks/delete, the page's ⋯ Delete)
287
310
  if (!pos.length) { say('usage: pmos task remove <task> [<task> …] [--why <text>]'); return 2; }
@@ -28,7 +28,7 @@ const path = require('path');
28
28
  const ledgers = require('./plan-ledgers.js');
29
29
 
30
30
  const LEDGER = 'initiative-tasks.jsonl';
31
- const TASK_KINDS = Object.freeze(['task', 'task-update', 'task-remove', 'task-restore', 'task-section', 'task-milestone', 'task-pin', 'task-order', 'task-parent', 'task-priority', 'task-description']);
31
+ const TASK_KINDS = Object.freeze(['task', 'task-update', 'task-remove', 'task-restore', 'task-section', 'task-milestone', 'task-pin', 'task-order', 'task-parent', 'task-priority', 'task-description', 'task-comment']);
32
32
  const KINDS = new Set(TASK_KINDS);
33
33
  const isTaskKind = (k) => KINDS.has(k);
34
34
  const isTaskLine = (r) => !!r && typeof r === 'object' && !Array.isArray(r) && isTaskKind(r.kind);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.768.0",
3
+ "version": "0.770.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.768.0",
9
+ "version": "0.770.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.768.0",
3
+ "version": "0.770.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",
@@ -53,17 +53,55 @@ button.ctp-cr:hover { text-decoration: underline; }
53
53
  .ctp-hx .grey { color: var(--cz-ink2); }
54
54
  .ctp-hx .warn { color: var(--cz-late); }
55
55
 
56
- /* viewer-ds-task (board ViewerDS): the full popup is main + side, built from Komorebi blocks (pm/vw-ds.js); here only their places.
57
- * With no popup behind (a task opened from Today, Events, Goals or Search) it is centred and near full (ctp-solo). */
58
- .ctp.ctp-full.ctp-solo { left: var(--space-24); top: var(--space-24); right: var(--space-24); bottom: var(--space-24); margin: 0 auto; max-width: 1280px; }
59
- .ctp-full .ctp-th { margin-bottom: var(--space-4); }
60
- .ctp-meta { margin: 0 0 var(--space-16); }
61
- .ctp-g { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: var(--space-16); align-items: start; }
62
- .ctp-main { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
63
- .ctp-main > div:empty { display: none; }
64
- .ctp-main .ctp-hx { margin: 0; }
56
+ /* task-detail-one-column (board TjC): the full popup is ONE column of Komorebi blocks (pm/vw-ds.js), under the title and its chip row, so it
57
+ * reads the same beside the open chat (TjCChat). With no popup behind (a task opened from Today, Events, Goals or Search) it is centred and
58
+ * near full (ctp-solo). */
59
+ .ctp.ctp-full.ctp-solo { left: var(--space-24); top: var(--space-24); right: var(--space-24); bottom: var(--space-24); margin: 0 auto; max-width: 880px; }
60
+ .ctp-full .ctp-th { margin-bottom: var(--space-8); }
61
+ .ctp-mk { display: inline-flex; color: var(--muted); flex: none; }
62
+ .ctp-key { flex: none; }
63
+ .ctp-jira { text-decoration: none; }
64
+ .ctp-col { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; max-width: 760px; }
65
+ .ctp-col > div:empty { display: none; }
66
+ .ctp-col .ctp-hx { margin: 0; }
65
67
  .ctp-say { margin: 0; }
66
- .ctp-side { position: sticky; top: 0; min-width: 0; }
68
+ /* the chip row: Status, the owner, Start → Due, a chip per set field, + (task-card.js layout 'chips') */
69
+ .ctp-chips { margin: 0 0 var(--space-16); }
70
+ .ctp-chips .tkc-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8); }
71
+ .ctp-chips .tkc-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--space-12); border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--card); color: var(--ink); font: inherit; font-size: var(--fs-meta); line-height: 1; text-decoration: none; white-space: nowrap; cursor: pointer; }
72
+ .ctp-chips .tkc-chip:hover, .ctp-chips .tkc-chip.open { background: var(--well); }
73
+ .ctp-chips .tkc-chip:focus-visible { outline: none; box-shadow: var(--glow); }
74
+ .ctp-chips .tkc-chip:disabled, .ctp-chips .tkc-chip.ro { cursor: default; background: var(--card); }
75
+ .ctp-chips .tkc-chip .k { color: var(--muted); }
76
+ .ctp-chips .tkc-chip.ghost { color: var(--muted); border-style: dashed; }
77
+ .ctp-chips .tkc-chip.st { font-weight: var(--fw-strong); }
78
+ .ctp-chips .tkc-chip.s-prog { background: var(--blue-tint); }
79
+ .ctp-chips .tkc-chip.s-done { background: var(--leaf-tint); }
80
+ .ctp-chips .tkc-chip.late { color: var(--alert); }
81
+ .ctp-chips .tkc-chip.agent svg { color: var(--leaf); }
82
+ .ctp-chips .tkc-chip.plus { width: 32px; padding: 0; justify-content: center; color: var(--muted); }
83
+ .ctp-chips .tkc-chip .av { width: 20px; height: 20px; border-radius: var(--radius-pill); background: var(--well); color: var(--muted); font-size: var(--fs-badge); font-weight: var(--fw-strong); display: inline-flex; align-items: center; justify-content: center; }
84
+ .ctp-chips .tkc-msg:empty { display: none; }
85
+ .ctp-chips .tkc-msg { margin: var(--space-8) 0 0; color: var(--alert); font-size: var(--fs-meta); }
86
+ /* Notes, Subtasks, Activity */
87
+ .ctp-notes { display: flex; flex-direction: column; gap: var(--space-8); }
88
+ .ctp-notes .head, .ctp-actb .head, .ctp-subs .head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); flex-wrap: wrap; }
89
+ .ctp-sbar { height: 6px; margin: 0 var(--space-16) var(--space-8); }
90
+ .ctp-subs .ctp-sadd, .ctp-actb .ctp-cbox { margin: var(--space-4) var(--space-16) var(--space-16); }
91
+ .ctp-actb .pm-state, .ctp-actb .pm-fold { margin-left: var(--space-16); margin-right: var(--space-16); }
92
+ .ctp-sbar i { display: block; height: 100%; background: var(--leaf); border-radius: var(--radius-pill); }
93
+ .ctp-sub .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
94
+ .ctp-sub.on .t { color: var(--muted); text-decoration: line-through; }
95
+ .ctp-sadd, .ctp-cbox { display: flex; align-items: flex-end; gap: var(--space-8); }
96
+ .ctp-ci { height: auto; min-height: 40px; padding: var(--space-8) var(--space-12); resize: none; field-sizing: content; line-height: 1.5; }
97
+ .ctp-ct { white-space: normal; overflow-wrap: anywhere; }
98
+ .ctp-actb .pm-state { padding: 0 0 var(--space-8); }
99
+ .ctp-dmore { align-self: flex-start; }
100
+ .ctp-descw.ctp-fold .ctp-desc > :not(.head):not(:nth-child(2)) { display: none; }
101
+ .ctp-descw.ctp-fold .ctp-desc > :nth-child(2) { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
102
+ .ctp-menu .ctp-ph { display: none; }
103
+ .ctp-menu a { display: flex; align-items: center; gap: var(--space-8); padding: 7px var(--space-8); border-radius: 7px; font-size: var(--fs-meta); color: var(--cz-ink); text-decoration: none; }
104
+ .ctp-menu a:hover, .ctp-menu a:focus-visible { background: var(--cz-well); outline: none; }
67
105
  /* the Description block (initiative task-descriptions): the text, Done when as a short list, PMOS's sources; edited in place like the notes */
68
106
  .ctp-desc { display: flex; flex-direction: column; gap: var(--space-8); }
69
107
  .ctp-desc .head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
@@ -75,13 +113,9 @@ button.ctp-cr:hover { text-decoration: underline; }
75
113
  .ctp-dt:hover { background: var(--cz-well); }
76
114
  .ctp-dt:focus { background: var(--cz-card); box-shadow: 0 0 0 1.5px var(--cz-blue), 0 0 0 5px var(--cz-bluebg); }
77
115
  .ctp-ad { flex: none; width: 52px; }
78
- .ctp-main .pm-li { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
79
- .ctp-main .pm-li:hover { background: var(--well); }
80
- .ctp-main div.pm-li { cursor: default; }
81
- @media (max-width: 900px) {
82
- .ctp-g { grid-template-columns: minmax(0, 1fr); }
83
- .ctp-side { position: static; order: -1; }
84
- }
116
+ .ctp-col .pm-li { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
117
+ .ctp-col .pm-li:hover { background: var(--well); }
118
+ .ctp-col div.pm-li { cursor: default; }
85
119
 
86
120
  /* PhoneWorkDS (job 1540): on a phone a task or a milestone opens full screen, with ← back to the initiative. No margins, one column. */
87
121
  @media (max-width: 760px) {
@@ -94,4 +128,10 @@ button.ctp-cr:hover { text-decoration: underline; }
94
128
  .ctp-full .ovw.tk-ini { background: none; padding-left: 0; padding-right: 0; border-radius: 0; }
95
129
  .ctp-full .pm-block.list .head, .ctp-full .pm-block.list .pm-li { padding-left: 0; padding-right: 0; }
96
130
  .ctp-full .ctp-b { padding: 0; }
131
+ /* TjPhone: the same chip row and order, 44 px targets, ↑ ↓ in ⋯, the comment box pinned at the bottom */
132
+ .ctp-full .ctp-step, .ctp-full .ctp-jira, .ctp-full .ctp-key { display: none; }
133
+ .ctp-menu .ctp-ph { display: flex; }
134
+ .ctp-full .ctp-ib, .ctp-chips .tkc-chip, .ctp-col .pm-btn { min-height: 44px; min-width: 44px; }
135
+ .ctp-chips .tkc-chip.plus { width: 44px; }
136
+ .ctp-full .ctp-cbox { position: sticky; bottom: calc(-1 * var(--space-24)); background: var(--card); padding: var(--space-8) 0 calc(env(safe-area-inset-bottom, 0px) + var(--space-8)); margin-bottom: calc(-1 * var(--space-8)); }
97
137
  }
@@ -16,7 +16,14 @@
16
16
  * 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,
17
17
  * where it sits, what PMOS changed) whose status pick asks when it really happened (pm/cozy-status-when.js, point 18); ⋯ with Make it a
18
18
  * milestone, Archive and Delete (Undo). No chat inside: one level only, a second task replaces the content. On a phone it is a sheet from the bottom.
19
- * Every write is the PM's press, on the board's own routes. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
+ * Every write is the PM's press, on the board's own routes. The UI says PMOS, never Claude; icon-only buttons carry aria-label.
20
+ *
21
+ * The full popup is ONE column (task-detail-one-column, board TjC, Wawan 2026-11-24: "Go with C, because when chat is open it'll be on the
22
+ * right side"): the head (←, the path with the Jira key, ↑ ↓, Ask PMOS, Open in Jira, ⋯, ×), the title, ONE chip row (the card in its
23
+ * 'chips' layout: Status with its menu and the day it happened, the owner, Start → Due, a chip per field that has a value, +), then
24
+ * Where it stands, Description, Notes (only when there are notes), Subtasks, Linked and Activity (All · Comments · PMOS work log, the
25
+ * comment box). Make it a milestone, Move, Copy link, Archive and Delete are in ⋯. On a phone (TjPhone) the same order, 44 px targets,
26
+ * the Description folded to its first line, Activity's latest two, the comment box pinned at the bottom; ↑ ↓ go into ⋯. */
20
27
  import { taskOf, mountCard, boardSaver, cardStyle, historyFor, chatAbout } from './task-card.js';
21
28
  import * as SWN from './cozy-status-when.js';
22
29
  import { linkPath, copyLink } from './short-link.js'; // Copy link in ⋯ (bet A428)
@@ -31,7 +38,7 @@ const SVG = (d) => `<svg aria-hidden="true" width="16" height="16" viewBox="0 0
31
38
  const P = {
32
39
  back: 'M19 12H5M11 6l-6 6 6 6',
33
40
  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',
34
- 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',
41
+ dia: 'M12 4l8 8-8 8-8-8z', out: 'M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5', 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',
35
42
  };
36
43
  const ib = (attr, label, d) => `<button type="button" class="ctp-ib" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(d)}</button>`;
37
44
 
@@ -43,6 +50,8 @@ async function rowOf(uid, ctx) {
43
50
  const I = ctx.board ? await fetch('/api/boards/items?' + q, { credentials: 'same-origin' }).then((x) => x.json()).catch(() => null) : null;
44
51
  const it = I && I.ok ? (I.items || []).find((x) => x.uid === uid) : null;
45
52
  const own = ctx.row ? ctx.row(uid) : null;
53
+ // the board's items and initiatives stay for the one column: the subtasks, the linked tasks' names, the stages a task can sit in
54
+ if (S) { S.items = I && I.ok ? I.items || [] : []; S.inis = I && I.ok ? I.initiatives || [] : []; }
46
55
  return it ? { ...(own || {}), ...it } : own || null;
47
56
  }
48
57
 
@@ -79,7 +88,9 @@ function onKey(e) {
79
88
  if (!S) return;
80
89
  if (e.key === 'Escape') {
81
90
  // a picker open inside the card closes first (its own Escape); then only the small popup
82
- if (e.target.closest && e.target.closest('.hi-pop, .dp-cal, [data-tkc-notes]')) return;
91
+ if (e.target.closest && e.target.closest('.hi-pop, .dp-cal, [data-tkc-notes], [data-ctp-notes], [data-ctp-cbox], .ctp-sadd')) return;
92
+ // the chip row's open menu or picker closes first (task-detail-one-column)
93
+ if (S.card && S.card.open && S.el.querySelector('.ctp-chips .tkc-pop')) { e.preventDefault(); e.stopPropagation(); S.card.open(null); const c = S.el.querySelector('.ctp-chips [aria-expanded]'); if (c) c.focus(); return; }
83
94
  e.preventDefault(); e.stopPropagation(); closeTask(); return;
84
95
  }
85
96
  if ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && S.el.contains(e.target) && !e.target.closest('input, textarea, [role="menu"], .sw, .tkc-dp')) {
@@ -112,6 +123,10 @@ export async function openTask(uid, ctx = {}) {
112
123
  document.addEventListener('keydown', onKey, true);
113
124
  el.addEventListener('click', press);
114
125
  el.addEventListener('focusout', descOut); // the description saves when the PM leaves its box (task-descriptions)
126
+ el.addEventListener('focusout', notesOut); // the one column's Notes block saves the same way (task-detail-one-column)
127
+ el.addEventListener('submit', (e) => { const f = e.target; if (!S || !f.matches) return; if (f.matches('[data-ctp-sadd]')) { e.preventDefault(); subAdd(f); } else if (f.matches('[data-ctp-cform]')) { e.preventDefault(); sendComment(f); } });
128
+ el.addEventListener('input', (e) => { if (S && e.target.matches && e.target.matches('[data-ctp-cbox]')) S.draft = e.target.value; });
129
+ el.addEventListener('keydown', (e) => { const a = e.target; if (S && a.matches && a.matches('[data-ctp-cbox]') && e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); sendComment(a.form); } });
115
130
  // the status pick waits for the day (point 18): the card's own press is held here, the line opens under the card
116
131
  el.addEventListener('click', holdStatus, true);
117
132
  }
@@ -147,11 +162,15 @@ async function show(uid) {
147
162
  const crumbs = path.map((p, k) => (k === last ? `<button type="button" class="ctp-cr" ${lastAttr}>${esc(p)}</button>` : `<span class="ctp-cr">${esc(p)}</span>`)).join('<span class="ctp-sep" aria-hidden="true">›</span>');
148
163
  const head = ctx.head ? ctx.head(t) : '';
149
164
  const back = path.length && !ctx.iniCrumb ? 'Back to ' + path[last] : 'Close';
150
- S.el.innerHTML = `<div class="ctp-h ctp-fh">${ib('data-ctp-close', back, P.back)}<nav class="ctp-path" aria-label="Where this is">${crumbs}${t.jira ? '<span class="pm-chip">Jira</span>' : ''}</nav>`
151
- + `<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>`
152
- + `<div class="ctp-th">${kind}${title}</div><p class="pm-meta ctp-meta">${esc(VD.metaOf(t))}</p>`
153
- + `<div class="ctp-g"><div class="ctp-main">${head ? `<div class="ctp-hx">${head}</div>` : ''}<div class="ctp-stands"></div><div class="ctp-descw"></div><div class="ctp-linked"></div><div class="ctp-act"></div></div>`
154
- + '<aside class="ctp-side"><section class="pm-block" aria-label="Fields and notes"><div class="ctp-b"></div><div class="ctp-when" hidden></div></section></aside></div>';
165
+ // task-detail-one-column (TjC): the Jira key is a chip in the path; Open in Jira beside Ask PMOS; ⋯ holds milestone, move, archive
166
+ const jkey = t.jira ? t.jira.key : raw.tracker && raw.tracker.key ? raw.tracker.key : '';
167
+ const jurl = (raw.tracker && raw.tracker.url) || raw.url || '';
168
+ const jira = jurl ? `<a class="ctp-ib ctp-jira" href="${esc(jurl)}" target="_blank" rel="noopener" aria-label="Open in Jira" title="Open in Jira">${SVG(P.out)}</a>` : '';
169
+ const mark = t.milestone ? `<span class="ctp-mk" role="img" aria-label="Milestone" title="Milestone">${SVG(P.dia)}</span>` : '';
170
+ S.el.innerHTML = `<div class="ctp-h ctp-fh">${ib('data-ctp-close', back, P.back)}<nav class="ctp-path" aria-label="Where this is">${crumbs}</nav>${jkey ? `<span class="pm-chip ctp-key">${esc(jkey)}</span>` : ''}`
171
+ + `<span class="ctp-tools"><span class="ctp-step">${step}</span>${ctx.chat ? ib('data-ctp-chat', 'Ask PMOS about this', P.chat) : ''}${jira}${ib('data-ctp-more aria-haspopup="menu"', 'More for this task', P.more)}${ib('data-ctp-x', 'Close', P.x)}</span></div>`
172
+ + `<div class="ctp-th">${mark}${title}</div><div class="ctp-chips ctp-b"></div><div class="ctp-when" hidden></div>`
173
+ + `<div class="ctp-col">${head ? `<div class="ctp-hx">${head}</div>` : ''}<div class="ctp-stands"></div><div class="ctp-descw"></div><div class="ctp-notesw"></div><div class="ctp-subs"></div><div class="ctp-linked"></div><div class="ctp-act"></div></div>`;
155
174
  } else {
156
175
  S.el.innerHTML = `<div class="ctp-h">${kind}${title}<span class="ctp-tools">${step}${more}${ib('data-ctp-close', 'Close', P.x)}</span></div>`
157
176
  + '<div class="ctp-b"></div><div class="ctp-when" hidden></div>';
@@ -165,7 +184,7 @@ async function show(uid) {
165
184
  return base(patch);
166
185
  };
167
186
  // the host's row changes at once (ctx.patch: the list behind shows the new status and dates before the board is read again)
168
- const changed = () => { raw.status = t.status; raw.end = t.due; raw.start = t.start; raw.owner = t.owner; raw.notes = t.notes; raw.milestone = t.milestone; if (ctx.patch) { try { ctx.patch(t.uid, { status: t.status, end: t.due || '', start: t.start || '', milestone: !!t.milestone, title: t.title }); } catch { /* the reload still draws it */ } } clearTimeout(changed.t); changed.t = setTimeout(() => { if (ctx.onChange) ctx.onChange(); }, 400); if (ctx.full) drawMain(); };
187
+ const changed = () => { raw.status = t.status; raw.end = t.due; raw.start = t.start; raw.owner = t.owner; raw.notes = t.notes; raw.milestone = t.milestone; raw.priority = t.priority; if (ctx.patch) { try { ctx.patch(t.uid, { status: t.status, end: t.due || '', start: t.start || '', milestone: !!t.milestone, title: t.title }); } catch { /* the reload still draws it */ } } clearTimeout(changed.t); changed.t = setTimeout(() => { if (ctx.onChange) ctx.onChange(); }, 400); if (ctx.full) drawMain(); };
169
188
  const toast = (msg, undo) => (ctx.toast ? ctx.toast(msg, undo) : undefined);
170
189
  S.hist = historyFor({ ws: ctx.ws, board: raw.board || ctx.board, t, post: (p, b) => ctx.pmPost(p, b) });
171
190
  S.histL = null;
@@ -177,20 +196,123 @@ async function show(uid) {
177
196
  inis: () => (ctx.inis ? ctx.inis() : []),
178
197
  // the full popup says PMOS's changes once, in its Activity block; the small popup keeps the card's History fold
179
198
  history: ctx.full ? null : S.hist,
199
+ // the one column (TjC): the card is the chip row; + adds a note or a subtask here; the stages come from the board's initiatives
200
+ ...(ctx.full ? {
201
+ layout: 'chips',
202
+ sections: () => { const x = (S && S.inis || []).find((y) => y.id === t.ini); return x && x.stages && x.stages.length ? x.stages : null; },
203
+ kind: () => (ctx.kind ? ctx.kind(t) : workKind(t)),
204
+ add: (k) => addField(k),
205
+ canSub: () => !t.jira && !!t.ini && !t.parent,
206
+ } : {}),
180
207
  });
181
- if (ctx.full) { drawMain(); loadActivity(); describe(); }
208
+ if (ctx.full) { S.nopen = false; S.sadd = false; S.atab = S.atab || 'all'; S.draft = ''; S.propNo = false; S.dfull = false; S.links = null; drawMain(); loadActivity(); loadLinks(); describe(); }
182
209
  const f = S.el.querySelector('.ctp-t') || S.el.querySelector('button'); if (f) f.focus();
183
210
  }
184
- /* the full popup's main column (viewer-ds-task, pm/vw-ds.js): Where it stands and Linked from the task, Activity from PMOS's kept changes */
211
+ /* the one column (task-detail-one-column, pm/vw-ds.js): Where it stands, Description, Notes, Subtasks, Linked, Activity — in that order */
212
+ const phone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
213
+ const typing = (sel) => { const a = document.activeElement; return !!(a && S && S.el.contains(a) && a.matches(sel)); };
214
+ /** The task's relations from the board's items and its links: its subtasks, its parent, what it waits on and what it blocks. */
215
+ function relOf() {
216
+ const t = S.t, I = S.items || [];
217
+ const name = (uid, other) => { const x = I.find((y) => y.uid === uid); return x ? { uid, title: x.title, status: x.status } : { uid, title: (other && other.title) || '' }; };
218
+ const L = (S.links && S.links.links) || [];
219
+ return {
220
+ subs: VD.subtasksOf(I, t.uid),
221
+ parent: t.parent ? name(t.parent) : null,
222
+ waitsOn: L.filter((l) => l.to === t.uid).map((l) => name(l.from, l.other)),
223
+ blocks: L.filter((l) => l.from === t.uid).map((l) => name(l.to, l.other)),
224
+ };
225
+ }
185
226
  function drawMain() {
186
227
  if (!S || !S.ctx.full || !S.t) return;
187
228
  const put = (sel, html) => { const x = S.el.querySelector(sel); if (x) x.innerHTML = html; };
188
- put('.ctp-stands', VD.standsHtml(S.t, { waits: S.ctx.waits ? S.ctx.waits(S.t) : '' }));
189
- // the description (initiative task-descriptions): never redrawn under the PM's typing
229
+ const R = relOf();
230
+ put('.ctp-stands', VD.standsHtml(S.t, { waits: S.ctx.waits ? S.ctx.waits(S.t) : '', subs: R.subs, waitsOn: R.waitsOn, noProp: !!(S.propNo || S.t.jira) }));
231
+ // the description (initiative task-descriptions): never redrawn under the PM's typing; on a phone it folds to its first line (TjPhone)
190
232
  const dw = S.el.querySelector('.ctp-descw');
191
- if (dw && !(document.activeElement && dw.contains(document.activeElement) && document.activeElement.matches('[data-ctp-desc]'))) dw.innerHTML = VD.descriptionHtml(S.t, { busy: !!S.dbusy, edit: !!S.dedit, undo: !!S.dundo });
192
- put('.ctp-linked', VD.linkedHtml(S.t));
193
- put('.ctp-act', VD.activityHtml(S.histL || [], { open: !!S.aopen }));
233
+ if (dw && !typing('[data-ctp-desc]')) {
234
+ const fold = phone() && !S.dfull && !S.dedit && !!S.t.description;
235
+ dw.innerHTML = VD.descriptionHtml(S.t, { busy: !!S.dbusy, edit: !!S.dedit, undo: !!S.dundo })
236
+ + (fold ? '<button type="button" class="pm-fold ctp-dmore" data-ctp-dmore aria-expanded="false">More</button>' : '');
237
+ dw.classList.toggle('ctp-fold', fold);
238
+ }
239
+ // Notes: no empty block; + Note opens one, and a note that exists shows under the Description
240
+ if (!typing('[data-ctp-notes]')) put('.ctp-notesw', VD.notesHtml(S.t, { open: !!S.nopen }));
241
+ if (!typing('.ctp-sadd input')) put('.ctp-subs', VD.subtasksHtml(R.subs, { adding: !!S.sadd, canAdd: !S.t.jira && !!S.t.ini && !S.t.parent }));
242
+ put('.ctp-linked', VD.linkedHtml(S.t, R));
243
+ if (!typing('[data-ctp-cbox]')) put('.ctp-act', VD.activityHtml(S.histL || [], { open: !!S.aopen, tab: S.atab, comments: S.t.comments || [], draft: S.draft || '', first: phone() ? 2 : 3 }));
244
+ }
245
+ /** The kind of work a task reads as when its host does not say (TjKinds): a change or a done test reads Full ADLC, a sprint or an estimate
246
+ * reads Project, else Product. Only the order of the chips follows it. */
247
+ function workKind(t) { return t.change || t.doneTest ? 'adlc' : t.sprint || (t.estimate !== '' && t.estimate != null) ? 'project' : 'product'; }
248
+ /* + Note and + Subtask (TjC): the block opens with its box focused */
249
+ function addField(k) {
250
+ if (!S) return;
251
+ if (k === 'note') S.nopen = true; else if (k === 'sub') S.sadd = true;
252
+ drawMain();
253
+ const f = S.el.querySelector(k === 'note' ? '[data-ctp-notes]' : '.ctp-sadd input'); if (f) f.focus();
254
+ }
255
+ /* the links between tasks (lib/task-links.js): Waits on and Blocks */
256
+ function loadLinks() {
257
+ const s = S; if (!s || !s.t.ini || !(s.raw.board || s.ctx.board)) return;
258
+ const q = new URLSearchParams({ board: s.raw.board || s.ctx.board, initiative: s.t.ini, ...(s.ctx.ws ? { ws: s.ctx.ws } : {}) });
259
+ fetch('/api/task-links?' + q, { credentials: 'same-origin' }).then((x) => x.json()).catch(() => null).then((j) => { if (S !== s || !j || !j.ok) return; s.links = j.links || null; drawMain(); });
260
+ }
261
+ /* Notes save when the PM leaves the box, through the card's own change (Undo in the toast) */
262
+ function notesOut(e) {
263
+ const a = e.target; if (!S || !S.card || !a.matches || !a.matches('[data-ctp-notes]')) return;
264
+ const v = a.value.replace(/\s+$/, '');
265
+ if (v === (S.t.notes || '')) { if (!v) { S.nopen = false; setTimeout(drawMain, 0); } return; }
266
+ if (!v) S.nopen = false;
267
+ S.card.change('notes', { notes: v });
268
+ }
269
+ /* a subtask: tick (tasks/state, Undo in the toast), add (tasks/add with the parent), open (the same popup steps to it) */
270
+ async function subTick(uid, b) {
271
+ const s = S; if (!s) return;
272
+ const x = (s.items || []).find((y) => y.uid === uid); if (!x) return;
273
+ const was = x.status, to = /^done$/i.test(String(was)) ? 'To do' : 'Done', board = x.board || s.raw.board || s.ctx.board;
274
+ const post = (state) => s.ctx.pmPost('/api/boards/tasks/state', { ws: s.ctx.ws, board, task: uid, state });
275
+ b.disabled = true; x.status = to; drawMain();
276
+ const r = await post(to).catch(() => null);
277
+ if (!r || r.ok === false) { x.status = was; if (S === s) drawMain(); if (s.ctx.toast) s.ctx.toast((r && r.error) || 'Nothing was changed.'); return; }
278
+ if (s.ctx.onChange) s.ctx.onChange();
279
+ if (s.ctx.toast) s.ctx.toast((to === 'Done' ? 'Done · ' : 'Open again · ') + x.title, async () => { const u = await post(was).catch(() => null); if (u && u.ok !== false) { x.status = was; if (S === s) drawMain(); if (s.ctx.onChange) s.ctx.onChange(); } return u || { ok: false }; });
280
+ }
281
+ async function subAdd(form) {
282
+ const s = S; if (!s) return;
283
+ const inp = form.querySelector('input'), title = (inp.value || '').trim(); if (!title) return;
284
+ inp.disabled = true;
285
+ const board = s.raw.board || s.ctx.board;
286
+ const r = await s.ctx.pmPost('/api/boards/tasks/add', { ws: s.ctx.ws, board, initiative: s.t.ini, title, parent: s.t.uid }).catch(() => null);
287
+ if (S !== s) return;
288
+ inp.disabled = false;
289
+ if (!r || r.ok === false) { if (s.ctx.toast) s.ctx.toast((r && r.error) || 'The subtask was not added.'); return; }
290
+ const it = r.item || { uid: r.task || r.id || '', title, status: 'To do', owner: '', board };
291
+ s.items = (s.items || []).concat([{ ...it, parent: s.t.uid }]);
292
+ inp.value = ''; drawMain();
293
+ const f = s.el.querySelector('.ctp-sadd input'); if (f) f.focus();
294
+ if (s.ctx.onChange) s.ctx.onChange();
295
+ if (s.ctx.toast && it.uid) s.ctx.toast('Subtask added · ' + title, async () => {
296
+ const u = await s.ctx.pmPost('/api/boards/tasks/delete', { ws: s.ctx.ws, board, task: it.uid }).catch(() => null);
297
+ if (u && u.ok !== false) { s.items = (s.items || []).filter((y) => y.uid !== it.uid); if (S === s) drawMain(); if (s.ctx.onChange) s.ctx.onChange(); }
298
+ return u || { ok: false };
299
+ });
300
+ }
301
+ /* a comment (POST /api/boards/tasks/comment): kept in PMOS, never sent to Jira */
302
+ async function sendComment(form) {
303
+ const s = S; if (!s || !form) return;
304
+ const a = form.querySelector('[data-ctp-cbox]'), text = (a.value || '').replace(/\s+$/, '');
305
+ if (!text.trim()) { a.focus(); return; }
306
+ a.disabled = true;
307
+ const r = await s.ctx.pmPost('/api/boards/tasks/comment', { ws: s.ctx.ws, board: s.raw.board || s.ctx.board, task: s.t.jira ? s.t.jira.key : s.t.uid, text }).catch(() => null);
308
+ if (S !== s) return;
309
+ a.disabled = false;
310
+ if (!r || r.ok === false) { if (s.ctx.toast) s.ctx.toast((r && r.error) || 'The comment was not saved.'); return; }
311
+ s.t.comments = r.comments || (s.t.comments || []).concat([r.comment]); s.raw.comments = s.t.comments;
312
+ s.draft = ''; a.value = ''; a.blur(); if (s.atab === 'log') s.atab = 'comments';
313
+ drawMain();
314
+ if (s.ctx.onChange) s.ctx.onChange();
315
+ if (s.ctx.toast) s.ctx.toast('Comment added');
194
316
  }
195
317
  /* PMOS writes a task's description by itself when it has none (POST /api/boards/tasks/describe-draft): once per task, from the initiative's
196
318
  * own files, with its sources and Undo. The server never writes it twice, so opening the task again costs nothing. */
@@ -245,10 +367,12 @@ function holdStatus(e) {
245
367
  e.stopPropagation(); e.preventDefault();
246
368
  S.held = st;
247
369
  // the line sits right under the facts card (the status row), the card does not redraw while it waits
248
- const w = S.el.querySelector('.ctp-when'), facts = S.el.querySelector('.ctp-b .tkc-f');
370
+ const w = S.el.querySelector('.ctp-when'), facts = S.el.querySelector('.ctp-b .tkc-f') || S.el.querySelector('.ctp-chips');
371
+ if (S.ctx.full && S.card && S.card.open) S.card.open(null); // the chip row's Status menu closes; the day is asked under the row
249
372
  if (facts && w.previousElementSibling !== facts) facts.after(w);
250
373
  w.hidden = false; w.innerHTML = '';
251
374
  S.el.querySelectorAll('[data-tkc-state]').forEach((x) => x.classList.toggle('ctp-held', x.dataset.tkcState === st));
375
+ const chip = S.el.querySelector('.ctp-chips [data-tkc="status"]'); if (chip) chip.classList.add('ctp-held');
252
376
  const pick = (day) => { const s = S; if (!s) return; s.held = null; s.nextDay = day && day !== SWN.localDay() ? day : null; hideWhen(); s.card.setStatus(st); };
253
377
  const head = document.createElement('p'); head.className = 'ctp-wh'; head.textContent = st; w.appendChild(head);
254
378
  const box = document.createElement('div'); w.appendChild(box);
@@ -272,6 +396,13 @@ async function press(e) {
272
396
  return;
273
397
  }
274
398
  if ('ctpAfold' in d) { S.aopen = true; drawMain(); return; }
399
+ // the one column (task-detail-one-column): Activity's tabs, a linked task or a subtask opens here, its tick, the ✦ proposal, the phone's fold
400
+ if (d.ctpAtab) { S.atab = d.ctpAtab; S.aopen = false; drawMain(); const x = S.el.querySelector(`[data-ctp-atab="${d.ctpAtab}"]`); if (x) x.focus(); return; }
401
+ if (d.ctpOpen) { show(d.ctpOpen); return; }
402
+ if (d.ctpStick) { subTick(d.ctpStick, b); return; }
403
+ if (d.ctpProp && t) { S.propNo = true; S.card.setStatus(d.ctpProp); return; }
404
+ if ('ctpPropx' in d) { S.propNo = true; drawMain(); return; }
405
+ if ('ctpDmore' in d) { S.dfull = true; drawMain(); return; }
275
406
  if ('ctpDedit' in d) { S.dedit = true; drawMain(); const a = S.el.querySelector('[data-ctp-desc]'); if (a) { a.focus(); a.setSelectionRange(a.value.length, a.value.length); } return; }
276
407
  if ('ctpDundo' in d) { saveDesc('', { word: 'PMOS\'s description taken back' }); return; }
277
408
  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; }
@@ -294,15 +425,23 @@ async function kindOf(on) {
294
425
  if (s.ctx.onChange) s.ctx.onChange();
295
426
  if (S === s) show(s.uid);
296
427
  }
428
+ const jurlOf = (s) => (s.raw && ((s.raw.tracker && s.raw.tracker.url) || s.raw.url)) || '';
429
+ const jkeyOf = (s) => (s.t && s.t.jira ? s.t.jira.key : s.raw && s.raw.tracker && s.raw.tracker.key) || '';
297
430
  function moreMenu(btn) {
298
431
  const s = S; if (!s) return;
299
432
  let m = s.el.querySelector('.ctp-menu');
300
433
  if (m) { m.remove(); btn.setAttribute('aria-expanded', 'false'); return; }
301
434
  m = document.createElement('div'); m.className = 'ctp-menu'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'More for this task');
302
- m.innerHTML = `<button type="button" role="menuitem" data-k="kind">${SVG(s.t.milestone ? P.box : P.dia)}${s.t.milestone ? 'Make it a task' : 'Make it a milestone'}</button>`
435
+ // the full popup's ⋯ (TjC): milestone, Move, Copy link, Archive, Delete; on a phone also ↑ ↓ (TjPhone). A Jira ticket: Copy link only
436
+ const L = s.ctx.list ? s.ctx.list() : [], i = L.indexOf(s.uid), full = !!s.ctx.full, j = !!s.t.jira;
437
+ m.innerHTML = (j ? '' : `<button type="button" role="menuitem" data-k="kind">${SVG(s.t.milestone ? P.box : P.dia)}${s.t.milestone ? 'Make it a task' : 'Make it a milestone'}</button>`)
438
+ + (full && !j ? '<button type="button" role="menuitem" data-k="move">Move…</button>' : '')
303
439
  + (linkPath({ kind: 'task', id: s.uid }) ? '<button type="button" role="menuitem" data-k="link">Copy link</button>' : '') // the short link (bet A428)
304
- + (s.t.status !== 'Archived' ? '<button type="button" role="menuitem" data-k="arch">Archive</button>' : '')
305
- + '<button type="button" role="menuitem" data-k="del" class="ctp-del">Delete</button>';
440
+ + (!j && s.t.status !== 'Archived' ? '<button type="button" role="menuitem" data-k="arch">Archive</button>' : '')
441
+ + (full && L.length > 1 && i >= 0 ? `<button type="button" role="menuitem" class="ctp-ph" data-k="prev"${i === 0 ? ' disabled' : ''}>Previous task</button><button type="button" role="menuitem" class="ctp-ph" data-k="next"${i === L.length - 1 ? ' disabled' : ''}>Next task</button>` : '')
442
+ + (full && jurlOf(s) ? `<a role="menuitem" class="ctp-ph" href="${esc(jurlOf(s))}" target="_blank" rel="noopener">Open in Jira${jkeyOf(s) ? ' · ' + esc(jkeyOf(s)) : ''}</a>` : '')
443
+ + (j ? '' : '<button type="button" role="menuitem" data-k="del" class="ctp-del">Delete</button>');
444
+ if (!m.innerHTML) return;
306
445
  btn.setAttribute('aria-expanded', 'true');
307
446
  btn.closest('.ctp-h').appendChild(m);
308
447
  m.querySelector('button').focus();
@@ -312,6 +451,8 @@ function moreMenu(btn) {
312
451
  if (x.dataset.k === 'kind') kindOf(!s.t.milestone);
313
452
  else if (x.dataset.k === 'link') copyLink({ kind: s.t.milestone ? 'milestone' : 'task', id: s.uid, ws: s.ctx.ws || '' });
314
453
  else if (x.dataset.k === 'arch') s.card.setStatus('Archived');
454
+ else if (x.dataset.k === 'move') s.card.open('move');
455
+ else if (x.dataset.k === 'prev' || x.dataset.k === 'next') { const L2 = s.ctx.list ? s.ctx.list() : [], k = L2.indexOf(s.uid) + (x.dataset.k === 'prev' ? -1 : 1); if (k >= 0 && k < L2.length) show(L2[k]); }
315
456
  else if (x.dataset.k === 'del') delTask(s);
316
457
  });
317
458
  m.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); m.remove(); btn.setAttribute('aria-expanded', 'false'); btn.focus(); } });